modified: index.php
modified: xsaf2.php - ajout: validation W3C du flux à l'ajout et import - changement: les flux des Identica et Statusnet sont désormais RSS (l'ATOM est invalide W3C) - ajout: "bootstrap" du XSAF depuis un répertoire Github dédié (nombre d'autoblogs réduit) /!\ 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.
This commit is contained in:
parent
2dc65ecdea
commit
82f00f8ea1
2 changed files with 16 additions and 9 deletions
|
@ -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, '<m:validity>', 0)+12;$b = strpos($response, '</m:validity>', $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 !== '<?xml') { die('n\'est pas un flux valide'); }
|
||||
|
@ -255,8 +258,8 @@ $socialaccount = strtolower(escape($_POST['socialaccount']));
|
|||
if(escape($_POST['socialinstance']) === 'statusnet') { $socialinstance = 'statusnet'; }
|
||||
$folder = "$socialinstance-$socialaccount";if(file_exists($folder)) { die('Erreur: l\'autoblog <a href="./'.$folder.'/">existe déjà</a>.'); }
|
||||
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) ) {
|
||||
|
|
18
xsaf2.php
18
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, '<m:validity>', 0)+12;$b = strpos($response, '</m:validity>', $a);$result = substr($response, $a, $b-$a);
|
||||
|
||||
/* autoblog */
|
||||
if($social==FALSE)
|
||||
if($social==FALSE and $result!=="false")
|
||||
{
|
||||
if( !fwrite($fp, "<?php require_once dirname(__DIR__) . '/autoblog.php'; ?>") ){
|
||||
$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, "<?php require_once dirname(__DIR__) . '/automicroblog.php'; ?>") ){
|
||||
$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"; }
|
||||
|
||||
?>
|
||||
|
|
Loading…
Reference in a new issue