[{"ID":"97F1F418-C3E6-4512-873F-CC9BFA081167","title":"Create Auth Tokens with PHP","tags":"astuce php securite","date":"18\/04\/2019","timestamp":"1555607575","rss_date":"Thu, 18 Apr 2019 19:12:55 +0200","status":"public","dependency":"","source":"https:\/\/davidwalsh.name\/random_bytes","content":"\/\/ php7\r\n\/\/ bin2hex(random_bytes($length))\r\n$token = bin2hex(random_bytes(64));\r\n\r\n\/\/ fallback\r\n$token = bin2hex(openssl_random_pseudo_bytes($length));\r\n\r\n"},{"ID":"833135D2-F937-408F-986D-20EF6DB966B7","title":"striptags","tags":"python securite","date":"13\/03\/2018","timestamp":"1520944129","rss_date":"Tue, 13 Mar 2018 13:28:49 +0100","status":"public","dependency":"","source":"http:\/\/warriordudimanche.net","content":"# strip tags function\r\ndef striptags(string):\t\r\n\treturn re.sub(u\"[^^]*?<\/head>|<[^>]*?>|<[^>]*?>| \",u\" \",string)\r\n"},{"ID":"6569B0B0-BD38-4E48-99A3-8716E92CF2D1","title":"Generate_salt - g\u00e9n\u00e9re une chaine aleatoire","tags":"fonctions php securite","date":"29\/09\/2016","timestamp":"1475134967","rss_date":"Thu, 29 Sep 2016 09:42:47 +0200","status":"public","dependency":"","source":"http:\/\/warriordudimanche.net","content":"function generate_salt($length=256){\r\n\t$salt='';\r\n\tfor($i=1;$i<=$length;$i++){\r\n\t\t$salt.=chr(mt_rand(35,126));\r\n\t}\r\n\treturn str_replace(['\"',\"'\"],'!',$salt);\r\n}"},{"ID":"BA45EC4C-8ED7-413C-B4A0-2A7FBBB24D93","title":"astuce s\u00e9curit\u00e9 PHP - Le Hollandais Volant","tags":"php securite","date":"19\/03\/2016","timestamp":"1458397218","rss_date":"Sat, 19 Mar 2016 15:20:18 +0100","status":"public","dependency":"","source":"http:\/\/lehollandaisvolant.net\/?mode=links&id=20160319122329","content":"# en d\u00e9but de script\r\nif (basename($_SERVER['SCRIPT_NAME']) === 'index.php' and strpos(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH), 'index.php') === FALSE ) {\r\n\t$var_request_URI = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH).'index.php';\r\n} else {\r\n\t$var_request_URI = $_SERVER['REQUEST_URI'];\r\n}\r\nif (parse_url($var_request_URI, PHP_URL_PATH) !== $_SERVER['SCRIPT_NAME']) {\r\n\theader('Location: '.$_SERVER['SCRIPT_NAME']);\r\n}\r\n\r\n"},{"ID":"4C6CB4AE-8661-496A-AC95-17CCB6C6E9E5","title":"ssave-sload: secured data saving","tags":"astuce fichiers php securite","date":"13\/09\/2015","timestamp":"1442138415","rss_date":"Sun, 13 Sep 2015 12:00:15 +0200","status":"public","dependency":"","source":"","content":"# Secured save\/load variable data (inspired by Oros)\r\nfunction ssave($file=null,$content=''){\r\n\tif (!$file){return false;}\r\n\tfile_put_contents($file.'.php', '');\r\n}\r\nfunction sload($file=null){\r\n\tif (!$file || !is_file($file)){return false;}\r\n\treturn unserialize(gzinflate(base64_decode(substr(file_get_contents($file),9,-strlen(6)))));\r\n}"},{"ID":"785D2572-BA7F-47D2-A200-E673805D71A4","title":"FORMULAIRE DE MODIFICATION DES DROITS CHMOD DES FICHIERS ET DOSSIERS","tags":"astuce php securite","date":"04\/06\/2015","timestamp":"1433421476","rss_date":"Thu, 04 Jun 2015 14:37:56 +0200","status":"public","dependency":"","source":"http:\/\/legissa.ovh\/internet-se-proteger-des-pirates-et-hackers.html#","content":"\";\r\n print \"

Changer les droits d'accès CHMOD aux dossiers et fichiers
dans votre hébergement.<\/h3>\";\r\n print \"
\";\r\n print \"
\";\r\n print \"
Droits des dossiers: <\/td>\";\r\n print \"
Droits des fichiers: <\/td>\";\r\n print \"
Répertoire à contrôler: <\/td>\";\r\n print \"\".ABSPATH.\" <\/td><\/tr>\";\r\n print \"
<\/td>\";\r\n print \"<\/form>\";\r\n print \"<\/td><\/tr><\/table>\";\r\n\r\nif ( ($dosPerm||$ficPerm) > 0 ){\r\n\r\n function rChmod($chem,$dosPerm,$ficPerm) {\r\n echo \"

Journal:<\/b><\/p>\\r\\n\";\r\n\r\n $d = new RecursiveDirectoryIterator($chem); \r\n $d ->setFlags(RecursiveDirectoryIterator::SKIP_DOTS); \r\n foreach (new RecursiveIteratorIterator($d, 1) as $path) {\r\n $chmodret = false;\r\n $chmodresultat = \"\";\r\n if ( $path->isDir() ) {\r\n $chmodret = chmod( $path, $dosPerm ); }\r\n else {\r\n if ( is_file( $path ) ) {\r\n $chmodret = chmod( $path, $ficPerm ); }\r\n }\r\n if ($chmodret) {$chmodresultat = \"OK\"; }\r\n else {\r\n $chmodresultat = \"ERREUR\";\r\n ++$retval;\r\n }\r\n echo $chmodresultat . \" \" . $path . \"
\\r\\n\";\r\n }\r\n return $retval;\r\n}\r\n $nbfailed = rChmod($chem,$dosPerm,$ficPerm);\r\n echo \"

\";\r\n if ($nbfailed > 0) {\r\n echo $nbfailed . \" erreur(s) CHMOD. Voyez le journal ci-dessus.\";\r\n }\r\n else echo \"Pas d'erreur apparente. V\u00e9rifiez par vous-m\u00eame.<\/b><\/p>\\r\\n\";\r\n}\r\n?>"},{"ID":"C5985B87-6CBD-4238-875F-B32F902C11DF","title":"deep_strip_tags - un strip_tags pour arrays","tags":"fonctions php securite texte","date":"29\/05\/2015","timestamp":"1432896548","rss_date":"Fri, 29 May 2015 12:49:08 +0200","status":"public","dependency":"","source":"http:\/\/warriordudimanche.net","content":"function deep_strip_tags($var){\r\n\tif (is_string($var)){return strip_tags($var);}\r\n\tif (is_array($var)){return array_map('deep_strip_tags',$var);}\r\n\treturn $var;\r\n}"},{"ID":"A68C484F-4B57-40C0-978B-BEDC063712B2","title":"strip_almost_all_tags","tags":"fonctions php securite texte","date":"23\/09\/2014","timestamp":"1411492537","rss_date":"Tue, 23 Sep 2014 19:15:37 +0200","status":"public","dependency":"","source":"","content":"function strip_almost_all_tags($chaine){\r\n\t\/\/ ajouter le strip attributes\r\n\t\/\/ \u00e0 la barbare\r\n\t$secure='#on(click|dblclick|blur|change|dragdrop|focus|keydown|keyup|keypress|mouseover|mouseout|load|unload|keydown)=#i';\r\n\t$keep=array('','','<\/a', '<\/em', '
','

\/g) || [])\r\n\t\t\t\t.join(''); \/\/ making sure the allowed arg is a string containing only tags in lowercase ()\r\n\t\t\t\tvar tags = \/<\\\/?([a-z][a-z0-9]*)\\b[^>]*>\/gi,\r\n\t\t\t\tcommentsAndPhpTags = \/|<\\?(?:php)?[\\s\\S]*?\\?>\/gi;\r\n\t\t\t\treturn input.replace(commentsAndPhpTags, '')\r\n\t\t\t\t.replace(tags, function($0, $1) {\r\n\t\t\t\t return allowed.indexOf('<' + $1.toLowerCase() + '>') > -1 ? $0 : '';\r\n\t\t\t\t});\r\n\t\t\t}"},{"ID":"1898F45F-A80A-45FE-90E6-5DD6B0BB732B","title":"clean - nettoyer une variable","tags":"fonctions php securite","date":"25\/01\/2014","timestamp":"1390657728","rss_date":"Sat, 25 Jan 2014 14:48:48 +0100","status":"public","dependency":"","source":"","content":"function clean($value) {\r\n\r\n \/\/ If magic quotes not turned on add slashes.\r\n if(!get_magic_quotes_gpc())\r\n\r\n \/\/ Adds the slashes.\r\n { $value = addslashes($value); }\r\n\r\n \/\/ Strip any tags from the value.\r\n $value = strip_tags($value);\r\n\r\n \/\/ Return the value out of the function.\r\n return $value;\r\n\r\n}"},{"ID":"A089C8FF-1023-44F5-AF93-7BC2E54DDA56","title":"secure - s\u00e9curiser une chaine ou un tableau contre le XSS","tags":"astuce fonctions php securite texte","date":"30\/09\/2013","timestamp":"1380544236","rss_date":"Mon, 30 Sep 2013 14:30:36 +0200","status":"public","dependency":"","source":"http:\/\/www.warriordudimanche.net","content":"function secure($var,$level=0){\r\n \/\/ $level=0 > returns text only (no html or script), 1 > text + html (no script), 2 > all content secured with entities\r\n if (is_array($var)){foreach ($var as $index=>$v){$var[$index]=secure($v,$level);}}\r\n else if (is_string($var)){\r\n if ($level==0){$var=strip_tags($var);}\r\n else if ($level==1){$var=preg_replace('#on[a-z]+ ?= ?[\"\\'].*?[\"\\'](?=[ \/>])|<\/?script>|javascript:#i','',$var);}\r\n else {$var=htmlspecialchars($var);}\r\n }\r\n return $var;\r\n}"},{"ID":"8F2931F1-1057-4D70-921B-217D430F9799","title":"Googol","tags":"php astuce securite html","date":"25\/05\/2013","timestamp":"1369485531","rss_date":"Sat, 25 May 2013 14:38:51 +0200","status":"public","dependency":"","source":"http:\/\/warriordudimanche.net","content":"(.*?)<\/a>.*?(?<=)(.*?)(?=<\/span>)#');\r\n\tdefine('REGEX_PAGES','#&start=([0-9]+)|&start=([0-9]+)#');\r\n\tdefine('REGEX_IMG','#(?<=imgurl=)(.*?)&imgrefurl=(.*?)&.*?h=([0-9]+)&w=([0-9]+)&sz=([0-9]+)|(?<=imgurl=)(.*?)&imgrefurl=(.*?)&.*?h=([0-9]+)&w=([0-9]+)&sz=([0-9]+)#');\r\n\tdefine('REGEX_THMBS','#

#title<\/h3>#link<\/a>

#description<\/p><\/div>');\r\n\tdefine('TPLIMG','

#thumbs<\/a><\/p>

#W x #H (#SZ ko) ►<\/a><\/p><\/div>');\r\n\tdefine('LOGO1','G<\/em>o<\/em>');\r\n\tdefine('LOGO2','o<\/em>g<\/em>o<\/em>l<\/em>');\r\n\tdefine('URL','https:\/\/www.google.fr\/search?q=');\r\n\tdefine('URLIMG','&tbm=isch&biw=1920&bih=1075&sei=v5ecUb6OG-2l0wW554GYBQ');\r\n\tdefine('VERSION','v1.1');\r\n\tdefine('LANGUAGE',$langue);\r\n\tdefine('RACINE','http:\/\/'.$_SERVER['SERVER_NAME']);\r\n\tdefine('USE_WEB_OF_TRUST',true);\r\n\tdefine('USE_GOOGLE_THUMBS',false);\r\n\t\/\/ true = googol utilise les miniatures de google (c'est l'ip du visiteur que google verra mais c'est rapide et sans charge pour le servuer h\u00e9bergeant googol)\r\n\t\/\/ false = c'est le serveur googol qui t\u00e9l\u00e9charge les miniatures (ip user cach\u00e9e \u00e0 google, il ne verra que l'ip du serveur, mais c'est sensiblement plus lent)\r\n\t\r\n\tif (!USE_GOOGLE_THUMBS){ \/\/ on va t\u00e9l\u00e9charger temporairement les miniatures pour cacher l'ip du visiteur \u00e0 google\r\n\t\tsession_start();\r\n\t\tif (!isset($_SESSION['ID'])){$_SESSION['ID']=uniqid();}\r\n\t\tdefine('UNIQUE_THUMBS_PATH','thumbs\/'.$_SESSION['ID']);\r\n\t\tif (!is_dir('thumbs')){mkdir('thumbs');}\/\/ cr\u00e9e le dossier thumbs si n\u00e9cessaire\r\n\t}\r\n\t$lang['fr']=array(\r\n\t\t'previous'=>htmlspecialchars('Page pr\u00e9c\u00e9dente'),\r\n\t\t'next'=>'Page suivante',\r\n\t\t'The thumbnails are temporarly stored in this server to hide your ip from Google...'=>htmlspecialchars('les miniatures sont temporairement r\u00e9cup\u00e9r\u00e9es sur ce serveur, google n'a pas votre IP...'),\r\n\t\t'Search anonymously on Google (direct links, fake referer)'=>htmlspecialchars('Rechercher anonymement sur Google (liens directs et referrer cach\u00e9)'),\r\n\t\t'Free and open source (please keep a link to warriordudimanche.net for the author ^^)'=>htmlspecialchars('Libre et open source, merci de laisser un lien vers warriordudimanche.net pour citer l'auteur ;)'),\r\n\t\t'Googol - google without lies'=>'Googol - google sans mensonge',\r\n\t\t'on GitHub'=>'sur GitHub',\r\n\t\t'no results'=>htmlspecialchars('pas de r\u00e9sultat'),\r\n\t\t'by'=>'par',\r\n\t\t'search '=>'recherche ',\r\n\t\t'Search'=>'Rechercher',\r\n\t\t'Otherwise, use a real Search engine !'=>'Sinon, utilisez un vrai moteur de recherche !',\r\n\t\t);\r\n\r\n\r\n\r\n\tfunction aff($a,$stop=true){echo 'Arret a la ligne '.__LINE__.' du fichier '.__FILE__.'

';var_dump($a);echo '<\/pre>';if ($stop){exit();}}\r\n\tfunction msg($m){global $lang;if(isset($lang[LANGUAGE][$m])){return $lang[LANGUAGE][$m];}else{return $m;}}\r\n\tfunction lang($default='fr'){if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){$l=explode(',',$_SERVER['HTTP_ACCEPT_LANGUAGE']);return substr($l[0],0,2);}else{return $default;}}\r\n\tfunction Random_referer(){\r\n\t\t$rr=array(\r\n\t\t\t'http:\/\/oudanstoncul.com.free.fr\/\u200e',\r\n\t\t\t'http:\/\/googlearretedenousfliquer.fr\/\u200e',\r\n\t\t\t'http:\/\/stopspyingme.fr\/\u200e',\r\n\t\t\t'http:\/\/spyyourassfuckinggoogle.fr\/\u200e',\r\n\t\t\t'http:\/\/dontfuckinglookatme.fr\/\u200e',\r\n\t\t\t'http:\/\/matemonculgoogle.fr\/\u200e',\r\n\t\t\t'http:\/\/auxarmescitoyens.fr\/\u200e',\r\n\t\t\t'http:\/\/jetlametsavecdugravier.con\/\u200e',\r\n\t\t\t'http:\/\/lesdeuxpiedsdanstagueule.fr\/\u200e',\r\n\t\t\t'http:\/\/moncoudedanstabouche.con\/\u200e',\r\n\t\t\t'http:\/\/monpieddanston.uk\/\u200e',\r\n\t\t\t'http:\/\/bienfaitpourvosgueul.es\/\u200e',\r\n\t\t\t'http:\/\/pandanstesdents.fr\/\u200e',\r\n\t\t\t'http:\/\/tupuessouslesbras.fr\/\u200e',\r\n\t\t);\r\n\t\tshuffle($rr);\r\n\t\treturn $rr[0];\r\n\t}\r\n\tfunction file_curl_contents($url){\r\n\t\t$ch = curl_init();\r\n\t\tcurl_setopt($ch, CURLOPT_HEADER, 0);\r\n\t\tcurl_setopt($ch, CURLOPT_SSL_VERIFYPEER,  FALSE);     \r\n\t\tcurl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);     \r\n\t\tcurl_setopt($ch, CURLOPT_URL, $url);     \r\n\t\tif (!ini_get(\"safe_mode\") && !ini_get('open_basedir') ) {curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);}    \r\n\t\tcurl_setopt($ch, CURLOPT_MAXREDIRS, 10); \r\n\t\tcurl_setopt($ch, CURLOPT_REFERER, random_referer());\/\/ notez le referer \"custom\"\r\n\t\t$data = curl_exec($ch);     \r\n\t\tcurl_close($ch);     \r\n\t\treturn $data; \r\n\t}  \r\n\tfunction add_search_engine(){\r\n\t\tif(!is_file('googol.xml')){\r\n\t\t\tfile_put_contents('googol.xml', '\r\n\t\t\t  Googole<\/ShortName>\r\n\t\t\t  '.msg('Googol - google without lies').'<\/Description>\r\n\t\t\t  UTF-8<\/InputEncoding>\r\n\t\t\t  data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAABCFJREFUeNrEV21MW2UUfm7v7QcwWqj9YBQyEAdqwBGGY3xkQRlLRjLnsmnUOOOSJYsmxvhDo\/7VRH+YaPxhYqLRiAkuccbh5jbFRZgR3IbpwphG0wxaSgOUXgot7W177\/V9L\/DDrLv3bcK2kzy97e15zz3vOc85573c4bfOY112ruNuyATBKP0iQNVufETwKu6ufElwTFBVtf0ePJzKiwQniQNoLmRVYyUHT5kNT3f7YLbatHtkE4gvr+LsWATT82kEoszm2gVFVZk0K+0qnulwoM7nAG82gxfM2n2OM5HfAjzeYhw76EIuk8HV6zP4engBYoozMmuhKTB8eJ0LeHlvGc74VzHwexyz8f\/\/73NweNBnRU9rJWq3VaBzVwNqKkrwdv9NpHP6Thg6QHfe12TDO6dFiKv5dWaWVIIUhiYDeK4rhid7m+D2utDkm8blKUXXvommQA9HO4rw1Wgai0l9vQ2cGotBSiaQTafwz5xsqC+oOg4+QEIfJrtbTLCTtLyIQyqxjIGLIaZ1gqLcPgVVTko2CxQlxexAx3YbRv4M46cJtjW6HOA4DntaqiApPC5eEzEj6uezs94Kj8OCjy8sMTusG4EbYYlEQMChfU040C1BzmZJzed3wmTiwfE8hq8GYeVFpLKsDuiQIBgDBkcCOLyvEcX2MvC8QMNyW31VUdDbaSNlCbzRH2JMgaJfhv3DIubFcRx5rAZljhItLXkjQJyzFhVrTcphL4aRXaYUbMg5f5Jg0lDv2T0ezdFvfw1CYXaAsRWziN2SwXdDf+FHf2JzSJhPdtaYsbvBjrb6LWuVQsgXislaCn6biOLMeLwge0yzYENe6fPi8UercWUygte+CCK6osBVasKJ\/T50tdaiurIcgYifVE+W2aaJMpcFT7U7sL\/7ISQlBR9+P4OFeE67T6\/vfjONqdA8vF433jvRgupyDqx2TQr5MIKzBDja97A2\/3+4NIVEWr5FZ+DnAGQ5h1KnG4c6PGCxS2Gi5WKEtu0lsG0p1UK2nJDy6oz9TQaQlNac7GmrAYtdCiYOVDhthGQ8NnTzrUlKZLqRCNA+QQl5H+FodEVlaUSKoVIimdUeSjshdUZvjSzLWIonCTdkRhISw0b4N5wgRy0JJjIXdjVuzatTZFnrhlkphV\/+mAaLXQqmKrgeTCOysKql4f7areh5xH6LTm9zuTaQZkNhnBqZZa4C3U74wfNubKtyacSyWbNYic5rUXj9hRZymhnHkH9t7O7d4cDxJ+oRCUfw5qfXMLcsM\/cBrvnIZy+R6yesCw7udqK1wY0ddXbkshJlJObEDM5dmcPg5aVCu\/f7AgqcBadHFzVslhTUiu+AZOh54OY9dOAGLcPzBJ+zls0m4izBSXLG0lJwnL4oEnTRxneHdx1bfzUfpD\/+E2AAqmeV253DYKAAAAAASUVORK5CYII=<\/Image>\r\n\t\t\t  \r\n\t\t\t  \r\n\t\t\t  <\/Url>\r\n\t\t\t  '.RACINE.'<\/moz:SearchForm> \r\n\t\t\t<\/OpenSearchDescription>');\r\n\t\t}\r\n\t}\r\n\tfunction parse_query($query,$start=0,$img=false){\r\n\t\tif (!$img){ \/\/ web\r\n\t\t\t$page=file_curl_contents(URL.str_replace(' ','+',urlencode($query)).'&start='.$start);\r\n\t\t\tif (!$page){return false;}\r\n\t\t\tpreg_match_all(REGEX_WEB, $page, $r);\r\n\t\t\tpreg_match_all(REGEX_PAGES,$page,$p);\r\n\t\t\t$p=count($p[2]);\r\n\t\t\t$retour=array(\r\n\t\t\t\t'links'=>$r[1],\r\n\t\t\t\t'titles'=>$r[2],\r\n\t\t\t\t'descriptions'=>$r[3],\r\n\t\t\t\t'nb_pages'=>$p,\r\n\t\t\t\t'current_page'=>$start,\r\n\t\t\t\t'query'=>$query\r\n\t\t\t\t);\r\n\t\t\treturn $retour;\r\n\t\t}else{ \/\/images\r\n\t\t\t$page=file_curl_contents(URL.str_replace(' ','+',urlencode($query)).URLIMG.'&start='.$start);\t\t\t\r\n\t\t\tif (!$page){return false;}\r\n\t\t\tpreg_match_all(REGEX_IMG,$page,$r);\r\n\t\t\tpreg_match_all(REGEX_PAGES,$page,$p);\r\n\t\t\tpreg_match_all(REGEX_THMBS,$page,$t);\r\n\t\t\t$p=count($p[2]);\r\n\t\t\t$retour=array(\r\n\t\t\t\t'site'=>$r[2],\r\n\t\t\t\t'links'=>$r[1],\r\n\t\t\t\t'h'=>$r[3],\r\n\t\t\t\t'w'=>$r[4],\r\n\t\t\t\t'sz'=>$r[5],\r\n\t\t\t\t'thumbs'=>$t[3],\r\n\t\t\t\t'thumbs_w'=>$t[2],\r\n\t\t\t\t'thumbs_h'=>$t[1],\r\n\t\t\t\t'nb_pages'=>$p,\r\n\t\t\t\t'current_page'=>$start,\r\n\t\t\t\t'query'=>$query\r\n\t\t\t\t);\t\t\t\r\n\t\t\treturn $retour;\t\t\r\n\t\t}\r\n\t}\r\n\r\n\tfunction render_query($array){\r\n\t\tglobal $start,$langue;\r\n\t\tif (!is_array($array)||count($array)==0){return false;}\r\n\t\tif (!isset($array['sz'][0])){\r\n\t\t\tforeach ($array['links'] as $nb => $link){\r\n\t\t\t\t$r=str_replace('#link',$link,TPL);\r\n\t\t\t\t$r=str_replace('#title',$array['titles'][$nb],$r);\r\n\t\t\t\t$d=str_replace('
','',$array['descriptions'][$nb]);\r\n\t\t\t\t$d=str_replace('','',$d);\r\n\t\t\t\t$r=str_replace('#description',$d,$r);\r\n\t\t\t\techo $r;\r\n\t\t\t}\r\n\t\t\t$img='';\r\n\t\t}else{\r\n\t\t\tforeach ($array['links'] as $nb => $link){\r\n\t\t\t\t$r=str_replace('#link',$link,TPLIMG);\r\n\t\t\t\t$r=str_replace('#SZ',$array['sz'][$nb],$r);\r\n\t\t\t\t$r=str_replace('#H',$array['h'][$nb],$r);\r\n\t\t\t\t$r=str_replace('#W',$array['w'][$nb],$r);\r\n\t\t\t\t$r=str_replace('#site',$array['site'][$nb],$r);\r\n\t\t\t\tif (!USE_GOOGLE_THUMBS){\r\n\t\t\t\t\t$repl='';\r\n\t\t\t\t}else if (USE_GOOGLE_THUMBS){\r\n\t\t\t\t\t$repl='';\r\n\t\t\t\t}\t\t\t\t\r\n\t\t\t\t$r=str_replace('#thumbs',$repl,$r);\r\n\t\t\t\t$r=str_replace('#thumbs_h',$array['thumbs_h'][$nb],$r);\r\n\t\t\t\t$r=str_replace('#thumbs_w',$array['thumbs_w'][$nb],$r);\r\n\t\t\t\techo $r;\r\n\t\t\t}\t\r\n\t\t\t$img='&img';\r\n\r\n\t\t}\r\n\r\n\t\tif($array['nb_pages'] != 0){\r\n\t\t\techo '

'.LOGO1.str_repeat('o<\/em>', $array['nb_pages']-1).LOGO2.'<\/p>

';\r\n\t\t}\r\n\t\telse{\r\n\t\t\techo '
'.msg('no results').' <\/div>';\r\n\t\t}\r\n\r\n\t\tif ($start>0){echo '◄<\/a>';}\r\n\t\tfor ($i=0;$i<$array['nb_pages']-1;$i++){\r\n\t\t\tif ($i*10==$array['current_page']){echo ''.($i+1).'<\/em>';}\r\n\t\t\telse{echo ''.($i+1).'<\/a>';}\r\n\t\t}\r\n\t\tif ($start<($array['nb_pages']-2)*10){echo '►<\/a>';}\r\n\t\t\r\n\t\techo '<\/div>';\r\n\t}\r\n\tfunction grab_google_thumb($link){\r\n\t\tif ($thumb=file_curl_contents($link)){\r\n\t\t\t$local='thumbs\/'.str_replace(array('?','\/',':'),'',$link).'.jpg';\r\n\t\t\tif (!is_file($local)){file_put_contents($local,$thumb);}\r\n\t\t\treturn $local;\r\n\t\t}else{\r\n\t\t\treturn $link;\r\n\t\t}\r\n\t}\r\n\tfunction clear_cache($delay=180){$fs=glob('thumbs\/*'); if(!empty($fs)){foreach ($fs as $file){if (@date('U')-@date(filemtime($file))>$delay){unlink ($file);}}}}\r\n\tfunction is_active($first,$second){if ($first==$second){echo 'active';}else{echo '';}}\r\n\r\n\r\n\t\/\/ Gestion GET\r\n\tif (isset($_GET['img'])){$img=true;}else{$img=false;}\r\n\tif (isset($_GET['start'])){$start=$_GET['start'];}else{$start='';}\r\n\tif (isset($_GET['q'])){$q=$_GET['q'];$title='Googol '.msg('search ').htmlspecialchars($q);}else{$q='';$title=msg('Googol - google without lies');}\r\n?>\r\n\r\n\r\n\r\n\r\n\t<?php echo htmlspecialchars($title); ?> <\/title>\r\n\t<style>\r\n\t\t*{-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;}\r\n\t\tbody{padding:0;margin:0;font-family:arial, sans-serif;}\r\n\t\taside{padding:0 25px 100px;}\r\n\t\ta {text-decoration: none; }\r\n\t\thr{border:none;border-top:1px solid #aaa;}\r\n\t\tform{margin-bottom:20px;padding:0;line-height:20px;}\r\n\t\theader{text-align:center;width:auto;background-color:#ddd;padding-bottom:20px;padding-top:0;border-bottom:1px solid #ddd;}\r\n\t\theader,footer{\r\n\t\t\tbackground-image: -moz-linear-gradient(top, #eeeeee, #cccccc);\r\n\t\t\tbackground-image: -ms-linear-gradient(top, #eeeeee, #cccccc);\r\n\t\t\tbackground-image: -o-linear-gradient(top, #eeeeee, #cccccc);\r\n\t\t\tbackground-image: -webkit-gradient(linear, center top, center bottom, from(#eeeeee), to(#cccccc));\r\n\t\t\tbackground-image: -webkit-linear-gradient(top, #eeeeee, #cccccc);\r\n\t\t\tbackground-image: linear-gradient(top, #eeeeee, #cccccc);\r\n\t\t}\r\n\t\theader em{font-family:Georgia, Times, serif;font-size:80px;font-style: normal;text-shadow:0 1px 2px #555;-webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none;}\r\n\t\tem.g{color:blue;}em.o1{color:red;}em.o2{color:orange;}em.l{color:green;}\r\n\t\theader .mini{font-size:14px;padding:0 0 0 220px;margin:0;margin-top:-15px;text-shadow:0 1px 1px white;}\r\n\t\theader .msg{font-size:16px;color:#444;font-style:italic;text-shadow:0 1px 1px #FFF;}\r\n\t\theader .langue{margin:0;padding:0;padding-right:20px;text-align:right;font-weight: bold}\r\n\t\theader .langue a:hover{color:black;}\r\n\t\theader .langue a{color:#444;}\r\n\t\tnav{padding-left:35px;background-color:white;border-bottom:1px solid #ccc;}\r\n\t\tnav li{border-bottom:4px solid transparent;background-color:white; display:inline-block;list-style:none;width:100px;height:30px;font-size:18px;text-align: center;padding-top:4px;}\r\n\t\tnav li.active,header .langue a.active{color:red;font-weight: bold;border-bottom:4px solid red;}\r\n\t\tnav li a{color:#666;}\r\n\t\tnav li a:hover{color:#111;}\r\n\t\tinput[type=text]{font-size:16px;height:30px;width:30%;min-width:200px;border-radius: 3px; padding:3px;border:1px solid #ccc;box-shadow: inset 0 1px 2px #ddd}\r\n\t\tinput[type=text]:hover{border-color:#aaa;}\r\n\t\tinput[type=submit]{height:30px;width:40px;font-size:14px;background-color:#4a8cf7;border:1px solid #397be6;border-radius: 3px;color:#eee; box-shadow: 0 1px 2px #397be6}\r\n\t\tinput[type=submit]:hover{background-color:#397be6;border-color:#286ad5 }\r\n\t\tinput[type=submit]:active{background-color:#397be6;border-color:transparent;border-top:2px solid transparent;box-shadow: 0 0px 1px #397be6;}\r\n\t\t.result{padding:0 10px ;margin:0;border-radius:3px;word-wrap:break-word;overflow-wrap: break-word;-webkit-hyphens:auto;-moz-hyphens:auto;-ms-hyphens:auto;}\r\n\t\t.result:hover,.image:hover{background-color:#EEE;}\r\n\t\t.result a {color:#0B0;}\r\n\t\t.result h3 {text-decoration: underline; color:#00B!important;}\r\n\t\t.result .title{margin-bottom:0;}\r\n\t\t.result .description{margin-top:3px;}\r\n\t\t.image{display:inline-block;padding:5px; margin:5px;text-align: center;border-radius:3px;}\r\n\t\t.image p{margin:0;padding: 0;}\r\n\t\t.image .description{font-size: 12px;}\r\n\t\t.image img{border:1px solid transparent;border-radius: 4px; box-shadow: 0 1px 2px #555}\r\n\t\t.image img:hover{border:1px solid #333;}\r\n\t\t.pagination{font-size:18px!important;text-align:center;width:auto;padding-top:5px;}\r\n\t\t.pagination a{text-decoration: none;padding:5px;border-radius: 4px;display:inline-block;}\r\n\t\t.pagination a:hover{background-color:#DDD;}\r\n\t\t.pagination em{padding:5px;background-color:#CCC;border-radius: 4px;display:inline-block;}\r\n\t\t.pagination .next,.pagination .previous{display:inline-block;width: 50px;}\r\n\t\t.footerlogo{text-align:center;padding:0;margin:0;font-size:22px;font-weight:bold;user-select: none;-webkit-user-select: none;}\r\n\t\t.footerlogo em{font-style: normal;display:inline-block;}\r\n\t\tfooter{position:fixed;bottom:0;left:0;right:0;height:auto;min-height:40px;border-top:solid 1px #ddd;margin-top:30px;background-color:#EEE;text-align: right;color:#555;line-height: 30px;padding-right:10px;padding-bottom:5px;}\r\n\t\tfooter a{color:#444;font-weight: bold;}\r\n\t\tfooter img{vertical-align: middle}\r\n\t\t.noresult{text-align:center;margin-top:5px;}\r\n\t<\/style>\r\n\t<?php if (is_file('favicon.png')){echo '<link rel=\"shortcut icon\" href=\"favicon.png\" \/> ';}?>\r\n\t<link rel=\"search\" type=\"application\/opensearchdescription+xml\" title=\"<?php echo msg('Googol - google without lies'); ?>\" href=\"<?php echo RACINE;?>\/googol.xml\">\r\n\t<!--[if IE]><script> document.createElement(\"article\");document.createElement(\"aside\");document.createElement(\"section\");document.createElement(\"footer\");<\/script> <![endif]-->\r\n<\/head>\r\n<body>\r\n<header>\r\n\t<p class=\"langue\"><a class=\"<?php is_active(LANGUAGE,'fr'); ?>\" href=\"?lang=fr\">FR<\/a> <a class=\"<?php is_active(LANGUAGE,'en'); ?>\" href=\"?lang=en\">EN<\/a><\/p>\r\n\t<?php echo LOGO1.LOGO2; ?>\r\n\t<p class=\"mini\"><?php echo htmlspecialchars(VERSION); ?><\/p><p class=\"msg\"><?php echo msg('Search anonymously on Google (direct links, fake referer)'); if ($img){echo '<br\/>'.msg('The thumbnails are temporarly stored in this server to hide your ip from Google...');} ?> <\/p>\r\n\t<form action=\"\" method=\"get\" >\r\n\t\t<input type=\"hidden\" name=\"lang\" value=\"<?php echo LANGUAGE;?>\"\/>\r\n\t<input type=\"text\" name=\"q\" placeholder=\"<?php echo msg('Search'); ?>\" value=\"<?php echo htmlspecialchars($q); ?>\"\/><input type=\"submit\" value=\"OK\"\/>\r\n\t<?php if ($img){echo '<input type=\"hidden\" name=\"img\"\/>';}?>\r\n\t<\/form>\r\n\r\n<\/header>\r\n<nav>\r\n<?php \r\n\tif (!$img){echo '<li class=\"active\">Web<\/li><li><a href=\"?q='.htmlspecialchars($q).'&img\">Images<\/a><\/li>';}\r\n\telse{echo '<li><a href=\"?q='.htmlspecialchars($q).'\">Web<\/a><\/li><li class=\"active\">Images<\/li>';}\r\n?>\r\n<\/nav>\r\n<aside>\r\n\t<?php if ($q!=''){render_query(parse_query($q,$start,$img));} ?>\r\n<\/aside>\r\n<footer><a href=\"<?php echo RACINE;?>\">Googol<\/a> <?php echo msg('by');?> <a href=\"http:\/\/warriordudimanche.net\">Bronco - warriordudimanche.net<\/a> <a href=\"#\" title=\"<?php echo msg('Free and open source (please keep a link to warriordudimanche.net for the author ^^)');?>\"><em>Licence<\/em><\/a> <a href=\"https:\/\/github.com\/broncowdd\/googol\" title=\"<?php echo msg('on GitHub');?>\"><img width=\"32\" src=\"github.png\" alt=\"logoGH\"\/><\/a> <a href=\"http:\/\/flattr.com\/thing\/1319925\/broncowddSnippetVamp-on-GitHub\" target=\"_blank\"><img src=\"http:\/\/images.warriordudimanche.net\/flattr.png\" alt=\"Flattr this\" title=\"Flattr this\" border=\"0\" \/><\/a><a href=\"http:\/\/duckduckgo.com\" title=\"<?php echo msg('Otherwise, use a real Search engine !');?>\"><img src=\"ddg.png\" alt=\"ddg icon\"\/><\/a><\/footer>\r\n<?php if(USE_WEB_OF_TRUST){echo '<script type=\"text\/javascript\" src=\"http:\/\/api.mywot.com\/widgets\/ratings.js\"><\/script>';}?> \r\n<\/body>\r\n<\/html>\r\n<?php add_search_engine(); ?>\r\n"},{"ID":"B77DF45C-77E4-4593-90D8-15F22E0AFE87","title":"Nettoyer les variables post\/get","tags":"php securite","date":"09\/05\/2013","timestamp":"1368090871","rss_date":"Thu, 09 May 2013 11:14:31 +0200","status":"public","dependency":"","source":"http:\/\/perishablepress.com\/code-snippets\/#code-snippets_php","content":"$_POST[\"name\"] = strtolower(stripslashes(trim(htmlspecialchars($_POST[\"name\"]))));\r\n$_POST[\"message\"] = strtolower(stripslashes(trim(htmlspecialchars($_POST[\"message\"]))));\r\n"},{"ID":"015A4E79-8509-47E2-B4EA-BC96E175238D","title":"auto_error_handler","tags":"php fonctions securite debug auto_","date":"23\/04\/2013","timestamp":"1366748260","rss_date":"Tue, 23 Apr 2013 22:17:40 +0200","status":"public","dependency":"","source":"http:\/\/warriordudimanche.net","content":"<?php\r\n# Error handler by bronco@warriordudimanche.net #################\r\nfunction showline($line,$file){\r\n\t$f=file($file);$r='';\r\n\tfor ($l=$line-2;$l<$line+2;$l++){\r\n\t\tif (isset($f[$l])){\r\n\t\t\tif ($l==$line-1){\r\n\t\t\t\t$r.='<em style=\"color:white;text-shadow:0 0 2px black\"><strong>'.$l.' >> <\/strong> '.$f[$l].'<\/em>';\r\n\t\t\t}else{\r\n\t\t\t\t$r.='<strong>'.$l.' >> <\/strong> '.$f[$l];\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn $r;\r\n}\r\nfunction error_handler($number, $message, $file, $line, $vars){\r\n\techo \"\r\n\t\t<div style='word-wrap: break-word;Box-sizing: Border-box ;border-radius:5px;padding:15px;margin-bottom:20px;box-shadow:0 2px 1px maroon;font-family:courier;position:absolute;top:0;left:0;background-color:rgba(255,100,100,0.2);width:100%;height:auto;position:relative;min-width:320px;'>\r\n\t\t\t<h1 style='color:red;border-radius:5px;background-color:pink;padding:5px;box-shadow:0 2px 1px maroon'>Erreur $number<\/h1>\r\n\t\t\t<p style=''> <em>$message <\/em> a la ligne <strong style='font-size:24px'>$line<\/strong> dans le fichier <strong style='font-size:24px'>file: $file.<\/strong><\/p>\r\n\t\t\t\r\n\t\t\t<pre style='font-weight:bold;padding:20px;margin-left:10px;color:orange;text-shadow:0 1px 1px maroon;box-shadow:inset 0 2px 1px maroon;border-radius:5px;background-color:red;'><code>\".showline($line,$file).\"<\/pre><\/code>\r\n\t\t\t<h1 style='color:red;border-radius:5px;background-color:pink;padding:5px;box-shadow:0 2px 1px maroon'>Variables<\/h1>\r\n\t\t\t<pre style='overflow:scroll;height:200px;'>\";\r\n\t\t\tvar_dump($vars) ;\r\n\t\t\techo \"<\/pre>\r\n\t\t\t<a style='display:block;text-align:right;font-size:14px;color:maroon;text-decoration:none;font-weight:bold;font-styl:italic;' href='http:\/\/warriordudimanche.net\/'>Error handler par warriordudimanche.net<\/a>\r\n\t\t<\/div>\";\r\n\r\n\tif ( ($number !== E_NOTICE) && ($number < 2048) ) {die(\"Erreur fatale.\");}\r\n}\r\n\r\nset_error_handler('error_handler');\r\n#################################################################\r\n?>"},{"ID":"82945B35-8B11-4E93-B089-DC678A32AB46","title":"R\u00e9cup\u00e9rer l'IP r\u00e9elle du user","tags":"php fonctions securite","date":"16\/04\/2013","timestamp":"1366143460","rss_date":"Tue, 16 Apr 2013 22:17:40 +0200","status":"public","dependency":"","source":"http:\/\/webdeveloperplus.com\/php\/21-really-useful-handy-php-code-snippets\/","content":"function getRealIpAddr() \r\n{ \r\n if (!emptyempty($_SERVER['HTTP_CLIENT_IP'])) \r\n { \r\n $ip=$_SERVER['HTTP_CLIENT_IP']; \r\n } \r\n elseif (!emptyempty($_SERVER['HTTP_X_FORWARDED_FOR'])) \r\n \/\/to check ip is pass from proxy \r\n { \r\n $ip=$_SERVER['HTTP_X_FORWARDED_FOR']; \r\n } \r\n else \r\n { \r\n $ip=$_SERVER['REMOTE_ADDR']; \r\n } \r\n return $ip; \r\n} "},{"ID":"8CD208DC-46A3-40A5-9984-00101594E574","title":"S\u00e9curiser des chaines","tags":"php securite","date":"03\/04\/2013","timestamp":"1365020260","rss_date":"Wed, 03 Apr 2013 22:17:40 +0200","status":"public","dependency":"","source":"","content":"function cleanInput($input) {\r\n \r\n $search = array(\r\n '@<script[^>]*?>.*?<\/script>@si', \/\/ Strip out javascript\r\n '@<[\/!]*?[^<>]*?>@si', \/\/ Strip out HTML tags\r\n '@<style[^>]*?>.*?<\/style>@siU', \/\/ Strip style tags properly\r\n '@<![sS]*?--[ tnr]*>@' \/\/ Strip multi-line comments\r\n );\r\n \r\n $output = preg_replace($search, '', $input);\r\n return $output;\r\n }\r\n\r\nfunction sanitize($input) {\r\n if (is_array($input)) {\r\n foreach($input as $var=>$val) {\r\n $output[$var] = sanitize($val);\r\n }\r\n }\r\n else {\r\n if (get_magic_quotes_gpc()) {\r\n $input = stripslashes($input);\r\n }\r\n $input = cleanInput($input);\r\n $output = mysql_real_escape_string($input);\r\n }\r\n return $output;\r\n}\r\n\r\n\/\/ Usage:\r\n$bad_string = \"Hi! <script src='http:\/\/www.evilsite.com\/bad_script.js'><\/script> It's a good day!\";\r\n $good_string = sanitize($bad_string);\r\n \/\/ $good_string returns \"Hi! It's a good day!\"\r\n\r\n \/\/ Also use for getting POST\/GET variables\r\n $_POST = sanitize($_POST);\r\n $_GET = sanitize($_GET);"},{"ID":"C4F40F3A-2B6F-4ACE-9A57-BE78207D207E","title":"S\u00e9curiser GET et POST","tags":"php securite","date":"03\/04\/2013","timestamp":"1365020260","rss_date":"Wed, 03 Apr 2013 22:17:40 +0200","status":"public","dependency":"","source":"","content":"$_ = array();\r\nforeach($_POST as $key=>$val){\r\n$_[$key]=mysql_escape_string(htmlentities($val));\r\n}\r\nforeach($_GET as $key=>$val){\r\n$_[$key]=mysql_escape_string(htmlentities($val));\r\n}\r\n\r\nutilisation:\r\necho $_['MaVariablePostOuGet'];"}]