From a94ca31a857fe132274543987d394137e8ec94ca Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Fri, 1 Mar 2013 12:12:54 +0100 Subject: [PATCH] Antibot --- 0.3/index.php | 136 ++++++++++++++++++++++++++++---------------------- 1 file changed, 76 insertions(+), 60 deletions(-) diff --git a/0.3/index.php b/0.3/index.php index c70f468..1069d9a 100755 --- a/0.3/index.php +++ b/0.3/index.php @@ -91,7 +91,7 @@ function objectCmp($a, $b) { function generate_antibot() { $letters = array('zéro', 'un', 'deux', 'trois', 'quatre', 'cinq', 'six', 'sept', 'huit', 'neuf', 'dix', 'onze', 'douze', 'treize', 'quatorze', 'quinze', 'seize', 'dix-sept', 'dix-huit', 'dix-neuf', 'vingt'); - return $letters[mt_rand(0, 20)]; + return $letters[mt_rand(1, 20)]; } function check_antibot($number, $text_number) { @@ -142,7 +142,7 @@ if (isset($_GET['check'])) } /** - * Simple and Full Export + * JSON Export **/ if (isset($_GET['export'])) { header('Content-Type: application/json'); @@ -339,42 +339,47 @@ if(!empty($_GET['via_button']) && $_GET['number'] === '17' && ALLOW_NEW_AUTOBLOG **/ if(!empty($_POST['socialaccount']) && !empty($_POST['socialinstance']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY_SOCIAL) { - $socialaccount = strtolower(escape($_POST['socialaccount'])); - $socialinstance = strtolower(escape($_POST['socialinstance'])); - - if($socialinstance === 'twitter') { - $sitetype = 'microblog'; - $siteurl = "http://twitter.com/$socialaccount"; - $rssurl = "http://api.twitter.com/1/statuses/user_timeline.rss?screen_name=$socialaccount"; - } - elseif($socialinstance === 'identica') { - $sitetype = 'microblog'; - $siteurl = "http://identi.ca/$socialaccount"; - $rssurl = "http://identi.ca/api/statuses/user_timeline/$socialaccount.rss"; - } - elseif($socialinstance === 'statusnet' && !empty($_POST['statusneturl'])) { - $sitetype = 'microblog'; - $siteurl= NoProtocolSiteURL(escape($_POST['statusneturl'])); - $rssurl = DetectRedirect("http://".$siteurl."/api/statuses/user_timeline/$socialaccount.rss"); - $siteurl = DetectRedirect("http://".$siteurl."/$socialaccount"); - } - elseif($socialinstance === 'shaarli' && !empty($_POST['shaarliurl'])) { - $sitetype = 'shaarli'; - $siteurl = NoProtocolSiteURL(escape($_POST['shaarliurl'])); - $siteurl = DetectRedirect("http://".$siteurl."/"); - $rssurl = $siteurl."?do=rss"; - $socialaccount = get_title_from_feed($rssurl); - } - - $headers = get_headers($rssurl, 1); - if (strpos($headers[0], '200') == FALSE) { - $error[] = "Flux inaccessible (compte inexistant ?)"; - } - if( empty($error) ) { - $error = createAutoblog($sitetype, ucfirst($socialinstance) .' - '. $socialaccount, $siteurl, $rssurl, $error); - if( empty($error)) - $success[] = ''.ucfirst($socialinstance) .' - '. $socialaccount.' ajouté avec succès.'; + if( !empty($_POST['number']) && !empty($_POST['antibot']) && check_antibot($_POST['number'], $_POST['antibot']) ) { + + $socialaccount = strtolower(escape($_POST['socialaccount'])); + $socialinstance = strtolower(escape($_POST['socialinstance'])); + + if($socialinstance === 'twitter') { + $sitetype = 'microblog'; + $siteurl = "http://twitter.com/$socialaccount"; + $rssurl = "http://api.twitter.com/1/statuses/user_timeline.rss?screen_name=$socialaccount"; + } + elseif($socialinstance === 'identica') { + $sitetype = 'microblog'; + $siteurl = "http://identi.ca/$socialaccount"; + $rssurl = "http://identi.ca/api/statuses/user_timeline/$socialaccount.rss"; + } + elseif($socialinstance === 'statusnet' && !empty($_POST['statusneturl'])) { + $sitetype = 'microblog'; + $siteurl= NoProtocolSiteURL(escape($_POST['statusneturl'])); + $rssurl = DetectRedirect("http://".$siteurl."/api/statuses/user_timeline/$socialaccount.rss"); + $siteurl = DetectRedirect("http://".$siteurl."/$socialaccount"); + } + elseif($socialinstance === 'shaarli' && !empty($_POST['shaarliurl'])) { + $sitetype = 'shaarli'; + $siteurl = NoProtocolSiteURL(escape($_POST['shaarliurl'])); + $siteurl = DetectRedirect("http://".$siteurl."/"); + $rssurl = $siteurl."?do=rss"; + $socialaccount = get_title_from_feed($rssurl); + } + + $headers = get_headers($rssurl, 1); + if (strpos($headers[0], '200') == FALSE) { + $error[] = "Flux inaccessible (compte inexistant ?)"; + } + if( empty($error) ) { + $error = createAutoblog($sitetype, ucfirst($socialinstance) .' - '. $socialaccount, $siteurl, $rssurl, $error); + if( empty($error)) + $success[] = ''.ucfirst($socialinstance) .' - '. $socialaccount.' ajouté avec succès.'; + } } + else + $error[] = 'Antibot : Chiffres incorrects.'; } /** @@ -427,29 +432,35 @@ if( !empty($_POST['generic']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY_L /** * ADD BY OPML **/ -if( !empty($_POST['opml']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY_OPML) { - if (is_uploaded_file($_FILES['file']['tmp_name'])) { - $opml = null; - if( ($opml = simplexml_load_file( $_FILES['file']['tmp_name'])) !== false ) { - foreach( $opml->body->outline as $outline ) { - if ( !empty( $outline['title'] ) && !empty( $outline['xmlUrl']) && !empty( $outline['htmlUrl'] )) { - $siteurl = escape($outline['htmlUrl']); - $rssurl = DetectRedirect(escape( $outline['xmlUrl'])); - $sitename = escape( $outline['title'] ); - - $error = createAutoblog( 'generic', $sitename, $siteurl, $rssurl, $error ); - if( empty ( $error )) - $success[] = 'Autoblog "'. $sitename .'" crée avec succès. → afficher l\'autoblog.'; +if( !empty($_POST['opml']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY_OPML) { + if(empty($_POST['number']) || empty($_POST['antibot']) ) + {$error[] = "Vous êtes un bot ?";} + elseif(! check_antibot($_POST['number'], $_POST['antibot'])) + {$error[] = "Antibot : Ce n'est pas le bon nombre.";} + + if( empty( $error)) { + if (is_uploaded_file($_FILES['file']['tmp_name'])) { + $opml = null; + if( ($opml = simplexml_load_file( $_FILES['file']['tmp_name'])) !== false ) { + foreach( $opml->body->outline as $outline ) { + if ( !empty( $outline['title'] ) && !empty( $outline['xmlUrl']) && !empty( $outline['htmlUrl'] )) { + $siteurl = escape($outline['htmlUrl']); + $rssurl = DetectRedirect(escape( $outline['xmlUrl'])); + $sitename = escape( $outline['title'] ); + + $error = createAutoblog( 'generic', $sitename, $siteurl, $rssurl, $error ); + if( empty ( $error )) + $success[] = 'Autoblog "'. $sitename .'" crée avec succès. → afficher l\'autoblog.'; + } } } - } - else - $error[] = "Impossible de lire le contenu du fichier OPML."; - unlink($_FILES['file']['tmp_name']); - } else { - $error[] = "Le fichier n'a pas été envoyé."; - } - + else + $error[] = "Impossible de lire le contenu du fichier OPML."; + unlink($_FILES['file']['tmp_name']); + } else { + $error[] = "Le fichier n'a pas été envoyé."; + } + } } ?> @@ -468,7 +479,7 @@ if( !empty($_POST['opml']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY_OPML input {width:30em;} input[type="radio"] { width:1em; } input[type="submit"] { width:8em; } - input[type="text"]#socialaccount, input[type="text"]#statusneturl, input[type="text"]#shaarliurl {width:12em;} + input[type="text"]#socialaccount, input[type="text"]#statusneturl, input[type="text"]#shaarliurl,input[type="text"].smallinput {width:15em;} div.form {padding:0.2em;border:1px solid #fff;} div.form:hover {background-color:#FAF4DA;border:1px dotted; } .vignette { width:20em;height:2em;float:left;margin:0; padding:20px;background-color:#eee;border: 1px solid #888;} @@ -560,7 +571,8 @@ if( !empty($_POST['opml']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY_OPML Identica

- +
+ @@ -571,6 +583,8 @@ if( !empty($_POST['opml']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY_OPML

+
+
@@ -583,6 +597,8 @@ if( !empty($_POST['opml']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY_OPML

+
+