\n"); define("sCharEncoding",""); function getTimer() { $t = gettimeofday(); return (double)(sprintf( '%d.%06d', $t['sec'], $t['usec'])); } /// function pour créer un fichier de description. /// $file est un nom de fichier à lire. /// $option est une valeur numérique 1 mets en titre H2 - 2 mets en paragraphe. /// $output est le fichier dans lequel écrire. function echofile($file , $option, $output){ $line = 0 ; $bNullP = 'false'; $inf = fopen($file ,"r"); $text = ''; while (!feof($inf)) { $text = fgets($inf,4096); $text = str_replace( "&", "&", $text ); $text = str_replace( "", "", $text ); if ($option == 1) { if (($line == 0) && ($text != "" )) { $text = "

".$text."

"; $text = str_replace( "
\r\n", "
\r\n", $text ); } if (($line > 0) && ($text != "" )) { if ($bNullP == 'false') { $text = "

".$text; $bNullP = 'true'; } } } else // dans le cas de option = 2 , pas de balise (p) ajoutée fichier .meta // dans le cas de option = 3 , pas de balise (p) ajoutée et pas de contenue meta ajouté. if ($option <2) { if ($text != "") { if ($bNullP == 'false') { $text = "

".$text; $bNullP = 'true'; } } } fwrite($output , $text); $line = $line +1; } if ($bNullP == 'true') { fwrite($output , "

\n"); } if ($option==2) { fwrite($output, sCharEncoding); } fclose($inf); } // fonction qui determine quoi faire en fonction du type d'extension // $path est un chemin. // $file un nom de fichier. // $output le fichier dans lequel écrire les informations. function testFile($path,$file,$output) { // echo "testFile(".$path.",".$file.",".$output.");
"; // on ignore par défaut certains types de fichiers if ( !ereg("\.hide$", $file) && !ereg("\.desc$", $file) && !ereg("\.meta$", $file) && !ereg("\.prio$", $file) && !ereg("\._ga_$", $file) && !ereg("\.stop$", $file) && !ereg("index\.",$file) && !ereg("\.shot\.png$", $file) ) { if (is_file($path.$file.".desc")) echofile($path.$file.".desc",0,$output); if (!is_file($path.$file.".hide") && !is_file($path.basename($file,".JPG").".thmb.JPG") ) { if ( (ereg("\.thmb.png", $file) )) { fwrite($output , "
screenshot
"); fwrite($output , "\"".$path.$file."\""); fwrite($output , "
\n"); } if ( (ereg("\.thmb.JPG", $file) )) { fwrite($output , "
"); fwrite($output , "\"".$path.$file."\""); fwrite($output , "
\n"); } else { fwrite($output , "
".$file."
\n"); } } } else if (ereg("\.hide$", $file )) echo "hidden path: ".$path."
\n"; } function actOnFile($path,$file,$output) { if (is_file($path.$file)) testFile($path,$file,$output); if (is_dir($path.$file)&& $file) { if (!is_file($path.$file."/.stop")) { // echo "parsing folder: $file"; listDir($path.$file."/",'true',$output,'false'); $newhan = fopen($path.$file."/index.php" ,"w"); listDir($path.$file."/",'false',$newhan,'true'); fclose($newhan); } else { echo "non explored path: ".$path.$file."
\n"; } } } function listDir($path,$ignore,$output,$header) { // echo "listDir( $path, $ignore, $output, $header)"; $dir = opendir($path); if (!is_file($path.".hide") || ($ignore=='false')) { if ($header=='true') { fwrite($output, sDocType); fwrite($output, "\n"); fwrite($output, "\n"); if (is_file($path.".meta")) { echofile($path.".meta",2,$output); } fwrite($output, "\n\n"); if (is_file($path.".title")) { echofile($path.".title",0,$output); } fwrite($output,"\n\n"); fwrite($output,"\n"); fwrite($output,"\n"); } } if (is_file($path.".desc")) { echofile($path.".desc", 1 ,$output); } if (!is_file($path.".hide") || ($ignore=='false')) { $priostack = array(1 => '' ); if (is_file($path.".prio") && !$prio) { echo "Parsing priority file ".$path.".prio
"; $priof = fopen($path.".prio" ,"r"); $line = 1; while (!feof($priof)) { $val = fgets($priof,4096); $val = rtrim($val); $prioStack[$line] = $val; echo "setting priority in $path on $val
\n" ; actOnFile($path,$val,$output); $line++; } echo "Closing ".$path.".prio"; fclose($priof); } while ($file = readdir($dir)) { if(($file != "." ) && ($file != ".." ) && ((count($prioStack)==0) || !(array_search($file ,$prioStack ))) ) { actOnFile($path,$file,$output); } } unset($priostack); // fwrite($output , "
"); closeDir($dir); } } $output = "index.php"; $han = fopen($output ,"w"); echo sDocType; echo "\n"; echo sCharEncoding."\n"; echo "index.php generation\n"; echo "\n"; echo ""; echo "

Generating ".$output."
\n"; $start = getTimer(); listDir("./",'false',$han,'true'); $end = getTimer(); fwrite($han,"


"); fwrite($han,"The script used to generate this page
"); // attention le document ne sera valide que si les .desc sont localement 'valide'. // si on se plante de tag localement, ca marche plus evidement... $validation = "

"; $validation = $validation." "; $validation = $validation."

"; fwrite($han,$validation . "\n"); // adding _ga content if (is_file("._ga_")) { echofile('._ga_',3,$han); } fwrite($han,"\n"); fwrite($han,""); fclose($han); echo "
\n"; echo "generation done in "; echo ($end-$start)*1000 ."ms
"; echo "
\n"; echo "Check site"; echo "
\n"; echo "Generate again"; echo "

\n"; echo str_replace("referer","http://esby.free.fr", $validation ); echo ""; // generation du source $output = "gindex.txt"; $han = fopen($output ,"w"); echofile("gindex.php",false,$han); fclose($han); ?>