X-Git-Url: http://git.cyclocoop.org/?p=velocampus%2Fweb%2Fwww.git;a=blobdiff_plain;f=www%2Fplugins%2Fauto%2Fcouteau_suisse%2Fcouteau_suisse%2Fexec%2Ftest_couteau_suisse.php;fp=www%2Fplugins%2Fauto%2Fcouteau_suisse%2Fcouteau_suisse%2Fexec%2Ftest_couteau_suisse.php;h=b0e9caf7618f834603159295dc5667301b5c7c07;hp=0000000000000000000000000000000000000000;hb=80b4d3e85f78d402ed2e73f8f5d1bf4c19962eed;hpb=aaf970bf4cdaf76689ecc10609048e18d073820c diff --git a/www/plugins/auto/couteau_suisse/couteau_suisse/exec/test_couteau_suisse.php b/www/plugins/auto/couteau_suisse/couteau_suisse/exec/test_couteau_suisse.php new file mode 100644 index 0000000..b0e9caf --- /dev/null +++ b/www/plugins/auto/couteau_suisse/couteau_suisse/exec/test_couteau_suisse.php @@ -0,0 +1,225 @@ +

', gros_titre(_T('couteauprive:titre_tests'), '', false), + '
'; + // et hop, on lance les tests ! + cs_les_tests(); + echo '
'; + + echo fin_page(); +cs_log(" FIN : exec_test_couteau_suisse()"); +} + +// renvoie un tableau contenant le texte original et sa transfrmation par la fonction $fonction +// $textes est un tableau de chaines +function cs_test_fun(&$textes, $fonction) { + $a = array(); + if (!function_exists($fonction)) return array('erreur' => "$fonction() introuvable : outil non activé !"); + foreach ($textes as $i=>$t) { + $b = $fonction($t); + $a["$i. test"] = htmlentities($t, ENT_COMPAT, $GLOBALS['meta']['charset']); +// $a["\$resultat[$i]"] = htmlentities($b); + $a["$i. résultat"] = str_replace("\n",'\n', $b); + } + return $a; +} + +// affiche un cadre de titre $titre base sur les donnees de $array +function test_outil($array, $titre) { + global $icone; + static $i; $i++; + echo "",debut_cadre_trait_couleur($icone,true,'',"$i. $titre"); + foreach($array as $s=>$v) if(is_array($v)) + foreach($v as $s2=>$v2) echo "\n{$s}[$s2] = ".trim($v2)."
"; + else echo "\n$s = ".trim($v)."
"; + echo fin_cadre_trait_couleur(true); +} + +// affiche un text en rouge +function cs_red($s){ return "$s"; } + +// effectue tous les tests ! +function cs_les_tests() { + global $icone, $metas_vars, $metas_outils; + $icone = find_in_path('img/couteau-24.gif'); + + test_outil($_SERVER, 'Echo de : $_SERVER[]'); + test_outil($_ENV, 'Echo de : $_ENV[]'); + global $HTTP_ENV_VARS; + test_outil($HTTP_ENV_VARS, 'Echo de : $HTTP_ENV_VARS'); + $a = array('DOCUMENT_ROOT'=>getenv('DOCUMENT_ROOT'), + 'REQUEST_URI'=>getenv('REQUEST_URI'), + 'SCRIPT_NAME'=>getenv('SCRIPT_NAME'), + 'PHP_SELF'=>getenv('PHP_SELF'), + ); + test_outil($a, 'Echo de : getenv()'); + + // lecture des variables stockees en meta + test_outil($metas_outils, 'Outils actifs : $metas_outils[]'); + test_outil($metas_vars, 'Contenu des variables : $metas_vars[]'); + + // test de url_absolue() + $relative_path = find_in_path('img/smileys'); + $realpath = str_replace("\\", "/", realpath($relative_path)); + $root = preg_replace(',/$,', '', $_SERVER['DOCUMENT_ROOT']); + $test_result=substr($realpath, strlen($root)); + $dir = dirname(!empty($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : + (!empty($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : + (!empty($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME'] : str_replace('\\','/',__FILE__) + ))); + $a = array('DOCUMENT_ROOT'=>$_SERVER['DOCUMENT_ROOT'], + 'REQUEST_URI'=>$_SERVER['REQUEST_URI'], + 'SCRIPT_NAME'=>$_SERVER['SCRIPT_NAME'], + 'PHP_SELF'=>$_SERVER['PHP_SELF'], + '__FILE__'=>__FILE__, + '$root'=>$root, + "find_in_path('img/smileys')"=>find_in_path('img/smileys'), + "str_replace('\\', '/', realpath('$relative_path'))"=>$realpath, + "substr('$realpath', strlen('$root'))"=>cs_red($test_result), + "return?"=>(strlen($root) && strpos($realpath, $root)===0)?'oui':'non', + "url_absolue('$relative_path')"=>url_absolue($relative_path), + '$dir'=>$dir, + "cs_canonicalize('$dir'.'/'.'$relative_path')"=>cs_red(cs_canonicalize($dir.'/'.$relative_path)), + ); + test_outil($a, 'Test sur : url_absolue()'); + + // test de cs_canonicalize() + $dir = $dir.'/'.$relative_path; + $address = str_replace("//", "/", $dir); + $address1 = $address2 = explode('/', $address); + $keys = array_keys($address2, '..'); + foreach($keys as $keypos => $key) array_splice($address2, $key - ($keypos * 2 + 1), 2); + $address3 = preg_replace(',([^.])\./,', '\1', implode('/', $address2)); + $a = array('$dir'=>$dir, + '$address'=>$address, + "explode('/', '$address')"=>$address1, + 'array_keys($dessus, "..")'=>$keys, + 'array_spliced()'=>$address2, + '$resultat'=>cs_red($address3), + ); + test_outil($a, 'Test sur : cs_canonicalize()'); + + // charger mes_fonctions, utile pour les filtres ou certains outils + include_spip('public/parametrer'); + + // test de typo_exposants() + include_spip('inc/charsets'); + $textes = array( + "Pr Paul, Dr Jules, Prs Pierre & Paul, Drs Pierre & Paul. Surveiller : Pré-St-Gervais ou Dré", + "Ste Lucie, St-Lucien, St.Patrick, St Patrick, st-jules (laisser?), Sts Pierre & Paul, STe Lucie (laisser?)", + "Bse Lucie, Bx-Lucien, Bx.Patrick, Bx Patrick, bx-jules (laisser?), Bses Jeanne & Julie", + "Ier, Iers, Iier, Iiers, Ire (laisser?), Ires (laisser?), Ière, 1ière, 1ères, 1ières", + unicode2charset("Accents : Ière, 1ière, 1ères, 1ières - ro, vo, rro, 1o, 2o, 22o, Mgr J.XXIII"), + unicode2charset("Ie IIème IIIe IVe Ve VIe VIIe VIIIe IXe Xe XIe XVe XXe"), + unicode2charset("Erreurs de typo : 2me, 3ème, 4ième, 5mes, 6èmes, 7ièmes"), + unicode2charset("Cas problématique du L (50) : XLe XLème XLième Lème LIe"), + "1er 1ers, 1eres, 2e 2es, IIIe IIIes, 2nd 22nd 21nd 2ndes. Vve Martin Cie Tartuffe, 3 Bd Voltaire.", + "3 ou 4 m², 3 ou 4 m2 et 2 m3. 50 Mds ou 50 Mns ! Sté, Stés, Stés, Ste, Ets, Éts, Éts, Éts, Éts ...", + "Mlle, Mlles, Mme, Mmes et erreurs Melle, Melles", + "Me, Me martin, Me Martin, Mes M.&T., MMes M.&T.", + 'avant Mon 1er lien et logo 6e', + 'avant [Mon 1er lien->www.mon-1er-lien.com] apres le "test"!', + 'on est passé du 7e au 15e rang, pas du 17e au 5e, des 7es aux 3emes !', + 'on est passé du 7eme au 15ème rang, pas du 17ieme au 5ème', + ); + test_outil(cs_test_fun($textes, 'typo_exposants'), 'Test sur : typo_exposants() - Charset du site : '.$GLOBALS['meta']['charset']); + + // test de typo_guillemets() + $textes = array( + 'avant le "test"!', + 'avant toto. apres le "test"!', + 'avant '.echappe_html('', 'TEST', true).'apres le "test"!', + 'avant '.echappe_html('toto', 'TEST', true).'apres le "test"!', + 'avant Mon lien apres le "test"!', + 'avant [Mon lien->www.monlien.com] apres le "test"!', + ); + test_outil(cs_test_fun($textes, 'typo_guillemets'), 'Test sur : typo_guillemets()'); + + // test des smileys + $textes = array( + "Doubles : :-(( :-)) :)) :'-)) :’-))", + "Simples : :-> :-> :-( :-D :-) |-) :'-) :’-) :'-D :’-D :'-( :’-( :-( :o) B-) ;-) :-p :-P' :-| :-/ :-o :-O", + "les courts (reconnus s'il y a un espace avant) : :) :( ;) :| |) :/ :(", + ); + test_outil(cs_test_fun($textes, 'cs_smileys_pre_typo'), 'Test sur : cs_smileys_pre_typo()'); + + // test des filets + $textes = array( + "__degrade.png__\n__ornement.png__", + "\n__6__\n__5__\n__4__\n__3__\n__2__\n__1__\n__0__\n", + ); + if(function_exists('filets_sep')) + test_outil(cs_test_fun($textes, create_function('$t','return propre(filets_sep($t));')), 'Test sur : filets_sep()'); + + // test des liens orphelins + $GLOBALS["liens_orphelins_etendu"]=true; + $textes = array( + "http://google.fr et http://google.fr et http://google.fr et http://google.fr", + "Voici : http://google.fr. Voici :http://www.google.fr. Voici http://www.google.fr", + "voici : https://mabanque.fr ou encore ftp://mabanque.fr!", + "www.google.fr ou bien : www.google.fr", + "http://user:password@www.commentcamarche.net:80/glossair/glossair.php3 et http://serveur:port/repertoire/fichier.html", + "ftp://serveur/repertoire/fichier.qqchose, ou encore ftp.stockage.fr/tropdelaballe...", + "file:///disque|/repertoire/fichier.qqchose et : file:///c|/tmp/fichier.txt", + "mailto:nom@organisation.domaine et : mailto:Fabien.Gandon@sophia.inria.fr", + "telnet://bbs.monsite.com/ et telnet://Nom:Password@serveur.ici:port", + "telnet://gandonf:abcde@gopa.insa.fr:23", + "gopher://serveur.ici:port/repertoire/fichier#marqueur et gopher://gopher.monsite.com/", + "newsrc://serveur:port/repertoire/nom.de.la.news", + "wais://host.ici:port/database et wais://wais.monsite.com/", + "news:fr.comp.lang.c++ et pkoi pas :
http://google.fr", + "moi+moi@world.com, mailto:moi-moi@world.com, mailto:nom@provider.com?subject=renseignement", + "moi+moi@kekpar.tm.fr, mailto:moi-moi@kekpar.tm.fr, mailto:nom@provider.com.tm.fr?subject=renseignement", + 'une image ? ', + '[->http://www.americas-society.org/] ', + ); +// test_outil(cs_test_fun($textes, 'typo'), 'Test sur : echappements'); + test_outil(cs_test_fun($textes, 'liens_orphelins'), 'Test sur : liens_orphelins()'); + + $textes = array( + "mailto:nom@organisation.domaine et : mailto:Fabien.Gandon@sophia.inria.fr (on supprime ces liens)", + "moi+moi@world.com, mailto:moi-moi@world.com, mailto:nom@provider.com?subject=renseignement", + "pat@moi.com [->pat@moi.com] [pat->pat@moi.com]", + "pat@moi.com.tm.fr [->pat@moi.com.tm.fr] [pat->pat@moi.com.tm.fr]", + "Moi et : moi@toto.com", + "Moi et : moi@kekpar.tm.fr", + '[Navigation->/@mot.html] Navigation', + ); + test_outil(cs_test_fun($textes, 'mailcrypt'), 'Test sur : mailcrypt()'); + +/* +define('_COULEURS_FONDS', 1); define('_COULEURS_SET', 1); +define('_COULEURS_PERSO', "bas =#99CC11, haut= brown, test= bleu"); +couleurs_installe_dist(); +print_r(couleurs_pre_typo("to[bas]to[/bas]to[haut]to[/haut]toto[test]to[/couleur]to\nto[bg bas]to[/bg]to[bg haut]to[/bg]toto[bg test]to[/bg test]to\n")); +print_r(couleurs_pre_typo("to[red]to[/red]to[bleu]to[/bleu]toto[rouge]to[/couleur]to\nto[bg red]to[/bg]to[bg bleu]to[/bg]toto[bg rouge]to[/bg rouge]to\n")); +*/ +} +?> \ No newline at end of file