From 82f00f8ea1e441f49e83c56da808f8adb24ff3ac Mon Sep 17 00:00:00 2001 From: Mitsukarenai Date: Thu, 24 Jan 2013 11:20:23 +0100 Subject: [PATCH] =?UTF-8?q?=09modified:=20=20=20index.php=20=09modified:?= =?UTF-8?q?=20=20=20xsaf2.php=20-=20ajout:=20validation=20W3C=20du=20flux?= =?UTF-8?q?=20=C3=A0=20l'ajout=20et=20import=20-=20changement:=20les=20flu?= =?UTF-8?q?x=20des=20Identica=20et=20Statusnet=20sont=20d=C3=A9sormais=20R?= =?UTF-8?q?SS=20(l'ATOM=20est=20invalide=20W3C)=20-=20ajout:=20"bootstrap"?= =?UTF-8?q?=20du=20XSAF=20depuis=20un=20r=C3=A9pertoire=20Github=20d=C3=A9?= =?UTF-8?q?di=C3=A9=20(nombre=20d'autoblogs=20r=C3=A9duit)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit /!\ la validation du flux rallentit horriblement XSAF, erreurs 500 sur l'export à Oros. Eviter donc le XSAF depuis des grosses fermes tant que le XSAF n'a pas une fonction limitant le nombre de nouveaux autoblogs crées en une fois. --- index.php | 7 +++++-- xsaf2.php | 18 +++++++++++------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/index.php b/index.php index f6985df..3cff6fe 100755 --- a/index.php +++ b/index.php @@ -21,6 +21,9 @@ function get_title_from_feed($url) function get_link_from_feed($url) { // get site link from feed + $validator = "http://validator.w3.org/feed/check.cgi";$validator .= "?url=".$url;$validator .= "&output=soap12"; + $response = file_get_contents($validator);$a = strpos($response, '', 0)+12;$b = strpos($response, '', $a);$result = substr($response, $a, $b-$a); + if($result == "false") { die('le flux n\'a pas une syntaxe valide'); } $data = file_get_contents("$url"); $check = substr($data, 0, 5); if($check !== 'existe déjà.'); } if($socialinstance === 'twitter') { $siteurl = "http://twitter.com/$socialaccount"; $rssurl = "http://api.twitter.com.nyud.net/1/statuses/user_timeline.rss?screen_name=$socialaccount"; } - if($socialinstance === 'identica') { $siteurl = "http://identi.ca/$socialaccount"; $rssurl = "http://identi.ca.nyud.net/api/statuses/user_timeline/$socialaccount.atom"; } - if($socialinstance === 'statusnet' && !empty($_POST['socialurl'])) { $siteurl = "http://".escape($_POST['socialurl'])."/$socialaccount"; $rssurl = "http://".escape($_POST['socialurl'])."/api/statuses/user_timeline/$socialaccount.atom"; } + if($socialinstance === 'identica') { $siteurl = "http://identi.ca/$socialaccount"; $rssurl = "http://identi.ca.nyud.net/api/statuses/user_timeline/$socialaccount.rss"; } + if($socialinstance === 'statusnet' && !empty($_POST['socialurl'])) { $siteurl = "http://".escape($_POST['socialurl'])."/$socialaccount"; $rssurl = "http://".escape($_POST['socialurl'])."/api/statuses/user_timeline/$socialaccount.rss"; } $headers = get_headers($rssurl, 1); if (strpos($headers[0], '200') == FALSE) {$error[] = "Flux inaccessible (compte inexistant ?)";} else { } if( empty($error) ) { diff --git a/xsaf2.php b/xsaf2.php index 5c29a3e..a0f9ef8 100755 --- a/xsaf2.php +++ b/xsaf2.php @@ -37,7 +37,7 @@ function NoProtocolSiteURL($url) } function xsafimport($xsafremote) { - $json_import = file_get_contents($xsafremote); + $json_import = file_get_contents($xsafremote); if(!empty($json_import)){ $to_update=array(); foreach (json_decode($json_import) as $value) { @@ -67,8 +67,11 @@ function xsafimport($xsafremote) if ( mkdir('./'. $foldername, 0755, false) ) { $fp = fopen('./'. $foldername .'/index.php', 'w+'); + $validator = "http://validator.w3.org/feed/check.cgi";$validator .= "?url=".$rssurl;$validator .= "&output=soap12"; + $response = file_get_contents($validator);$a = strpos($response, '', 0)+12;$b = strpos($response, '', $a);$result = substr($response, $a, $b-$a); + /* autoblog */ -if($social==FALSE) +if($social==FALSE and $result!=="false") { if( !fwrite($fp, "") ){ $infos = "Impossible d'écrire le fichier index.php dans ".$foldername; @@ -92,7 +95,7 @@ DOWNLOAD_MEDIA_FROM='.$sitedomain) ){ } } /* automicroblog */ -else +else if($social!==FALSE and $result!=="false") { if( !fwrite($fp, "") ){ $infos = "Impossible d'écrire le fichier index.php dans ".$foldername; @@ -114,12 +117,12 @@ FEED_URL="'. $rssurl .'"') ){ } } -} +} else { $infos = "$rssurl -> flux invalide"; } /* end of file writing */ }else { $infos = "Impossible de créer le répertoire ".$foldername; } - } /* else { $infos = "Le répertoire ".$foldername." existe déjà ($sitename;$siteurl;$rssurl)"; } */ + } else { $infos = "Le répertoire ".$foldername." existe déjà ($sitename;$siteurl;$rssurl)"; } if(DEBUG){ echo $infos."\n"; } } } @@ -135,9 +138,10 @@ FEED_URL="'. $rssurl .'"') ){ } /* And now, the XSAF links to be imported ! */ - +xsafimport('https://raw.github.com/mitsukarenai/xsaf-bootstrap/master/2.json'); //xsafimport('https://www.ecirtam.net/autoblogs/?export'); -xsafimport('http://autoblog.suumitsu.eu/?export'); +//xsafimport('http://autoblog.suumitsu.eu/?export'); + if(DEBUG){ echo "\n\nXSAF import finished\n\n"; } ?>