[ PHPXref.com ] [ Generated: Sun Jul 20 17:00:47 2008 ] [ Clide 1.4.1 ]
[ Index ]     [ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/ -> generator.php (source)

   1  <?PHP
   2  
   3  /*

   4   * Project:     Clide FTP

   5   * File:        generator.php 

   6   * Author:      Absynthe <absynthe.is@free.fr> 

   7   * Version:     1.4.1 @ 25/06/2006

   8   * License:     GPL

   9   *

  10   * The lastest version of Clide FTP can be obtained from:

  11   * http://clide.is.free.fr/

  12   *

  13   * You can visit the forum about Clide FTP at:

  14   * http://clide.is.free.fr/forum/

  15   */
  16   
  17  
  18  // Fonctions

  19  function filepath()
  20  {
  21      $request_uri    = $_SERVER['SCRIPT_NAME'];
  22      $clean_uri         = array('index.php' => '', 'player.php' => '');
  23      $request_uri    = strtr($request_uri, $clean_uri);
  24      return $request_uri;
  25  }
  26  
  27  function mime_content ($filename)
  28  {
  29      
  30      if (function_exists('mime_content_type'))
  31      {
  32          return mime_content_type($filename);
  33      }
  34      else
  35      {
  36          $ext = strtolower(end(explode(".", $filename)));
  37          $mime = array(
  38          "ai" => "application/postscript",
  39           "aif" => "audio/x-aiff",
  40          "aifc" => "audio/x-aiff",
  41          "aiff" => "audio/x-aiff",
  42           "asc" => "text/plain",
  43            "au" => "audio/basic",
  44           "avi" => "video/x-msvideo",
  45         "bcpio" => "application/x-bcpio",
  46           "bin" => "application/octet-stream",
  47             "c" => "text/plain",
  48            "cc" => "text/plain",
  49          "ccad" => "application/clariscad",
  50           "cdf" => "application/x-netcdf",
  51         "class" => "application/octet-stream",
  52          "cpio" => "application/x-cpio",
  53           "cpt" => "application/mac-compactpro",
  54           "csh" => "application/x-csh",
  55           "css" => "text/css",
  56           "dcr" => "application/x-director",
  57           "dir" => "application/x-director",
  58           "dms" => "application/octet-stream",
  59           "doc" => "application/msword",
  60           "drw" => "application/drafting",
  61           "dvi" => "application/x-dvi",
  62           "dwg" => "application/acad",
  63           "dxf" => "application/dxf",
  64           "dxr" => "application/x-director",
  65           "eps" => "application/postscript",
  66           "etx" => "text/x-setext",
  67           "exe" => "application/octet-stream",
  68            "ez" => "application/andrew-inset",
  69             "f" => "text/plain",
  70           "f90" => "text/plain",
  71           "fli" => "video/x-fli",
  72           "gif" => "image/gif",
  73          "gtar" => "application/x-gtar",
  74            "gz" => "application/x-gzip",
  75             "h" => "text/plain",
  76           "hdf" => "application/x-hdf",
  77            "hh" => "text/plain",
  78           "hqx" => "application/mac-binhex40",
  79           "htm" => "text/html",
  80          "html" => "text/html",
  81           "ice" => "x-conference/x-cooltalk",
  82           "ief" => "image/ief",
  83          "iges" => "model/iges",
  84           "igs" => "model/iges",
  85           "ips" => "application/x-ipscript",
  86           "ipx" => "application/x-ipix",
  87           "jpe" => "image/jpeg",
  88          "jpeg" => "image/jpeg",
  89           "jpg" => "image/jpeg",
  90            "js" => "application/x-javascript",
  91           "kar" => "audio/midi",
  92         "latex" => "application/x-latex",
  93           "lha" => "application/octet-stream",
  94           "lsp" => "application/x-lisp",
  95           "lzh" => "application/octet-stream",
  96             "m" => "text/plain",
  97           "man" => "application/x-troff-man",
  98            "me" => "application/x-troff-me",
  99          "mesh" => "model/mesh",
 100           "mid" => "audio/midi",
 101          "midi" => "audio/midi",
 102           "mif" => "application/vnd.mif",
 103          "mime" => "www/mime",
 104           "mov" => "video/quicktime",
 105         "movie" => "video/x-sgi-movie",
 106           "mp2" => "audio/mpeg",
 107           "mp3" => "audio/mpeg",
 108           "mp4" => "video/mpeg",
 109           "mpe" => "video/mpeg",
 110          "mpeg" => "video/mpeg",
 111           "mpg" => "video/mpeg",
 112          "mpga" => "audio/mpeg",
 113            "ms" => "application/x-troff-ms",
 114           "msh" => "model/mesh",
 115            "nc" => "application/x-netcdf",
 116           "oda" => "application/oda",
 117           "pbm" => "image/x-portable-bitmap",
 118           "pdb" => "chemical/x-pdb",
 119           "pdf" => "application/pdf",
 120           "pgm" => "image/x-portable-graymap",
 121           "pgn" => "application/x-chess-pgn",
 122           "png" => "image/png",
 123           "pnm" => "image/x-portable-anymap",
 124           "pot" => "application/mspowerpoint",
 125           "ppm" => "image/x-portable-pixmap",
 126           "pps" => "application/mspowerpoint",
 127           "ppt" => "application/mspowerpoint",
 128           "ppz" => "application/mspowerpoint",
 129           "pre" => "application/x-freelance",
 130           "prt" => "application/pro_eng",
 131            "ps" => "application/postscript",
 132            "qt" => "video/quicktime",
 133            "ra" => "audio/x-realaudio",
 134           "ram" => "audio/x-pn-realaudio",
 135           "ras" => "image/cmu-raster",
 136           "rgb" => "image/x-rgb",
 137            "rm" => "audio/x-pn-realaudio",
 138          "roff" => "application/x-troff",
 139           "rpm" => "audio/x-pn-realaudio-plugin",
 140           "rtf" => "text/rtf",
 141           "rtx" => "text/richtext",
 142           "scm" => "application/x-lotusscreencam",
 143           "set" => "application/set",
 144           "sgm" => "text/sgml",
 145          "sgml" => "text/sgml",
 146            "sh" => "application/x-sh",
 147          "shar" => "application/x-shar",
 148          "silo" => "model/mesh",
 149           "sit" => "application/x-stuffit",
 150           "skd" => "application/x-koan",
 151           "skm" => "application/x-koan",
 152           "skp" => "application/x-koan",
 153           "skt" => "application/x-koan",
 154           "smi" => "application/smil",
 155          "smil" => "application/smil",
 156           "snd" => "audio/basic",
 157           "sol" => "application/solids",
 158           "spl" => "application/x-futuresplash",
 159           "src" => "application/x-wais-source",
 160          "step" => "application/STEP",
 161           "stl" => "application/SLA",
 162           "stp" => "application/STEP",
 163       "sv4cpio" => "application/x-sv4cpio",
 164        "sv4crc" => "application/x-sv4crc",
 165           "swf" => "application/x-shockwave-flash",
 166             "t" => "application/x-troff",
 167           "tar" => "application/x-tar",
 168           "tcl" => "application/x-tcl",
 169           "tex" => "application/x-tex",
 170          "texi" => "application/x-texinfo",
 171        "texinfo" => "application/x-texinfo",
 172           "tif" => "image/tiff",
 173          "tiff" => "image/tiff",
 174            "tr" => "application/x-troff",
 175           "tsi" => "audio/TSP-audio",
 176           "tsp" => "application/dsptype",
 177           "tsv" => "text/tab-separated-values",
 178           "txt" => "text/plain",
 179           "unv" => "application/i-deas",
 180         "ustar" => "application/x-ustar",
 181           "vcd" => "application/x-cdlink",
 182           "vda" => "application/vda",
 183           "viv" => "video/vnd.vivo",
 184          "vivo" => "video/vnd.vivo",
 185          "vrml" => "model/vrml",
 186           "wav" => "audio/x-wav",
 187           "wrl" => "model/vrml",
 188           "xbm" => "image/x-xbitmap",
 189           "xlc" => "application/vnd.ms-excel",
 190           "xll" => "application/vnd.ms-excel",
 191           "xlm" => "application/vnd.ms-excel",
 192           "xls" => "application/vnd.ms-excel",
 193           "xlw" => "application/vnd.ms-excel",
 194           "xml" => "text/xml",
 195           "xpm" => "image/x-xpixmap",
 196           "xwd" => "image/x-xwindowdump",
 197           "xyz" => "chemical/x-pdb",
 198           "zip" => "application/zip");
 199             return $mime[$ext];
 200      }
 201  }     
 202  
 203  function fsize($file) 
 204  {
 205      if ($file < '1024') { 
 206            return $file." b"; 
 207        }
 208      elseif ($file >= '1024' && $file < '1048576') { 
 209            return round($file/1024,1)." Kb"; 
 210      }
 211        elseif ($file >= '1048576' && $file < '1073741824') {
 212            return round($file/1048576,1)." Mb"; 
 213      }
 214        else { 
 215          return round($file/1073741824,1)." Gb"; 
 216      }
 217  }
 218  
 219  $path         = $_SERVER['REQUEST_URI'];
 220  $clean_path = array('generator.php' => '');
 221  $path         = strtr($path, $clean_path);
 222  
 223  
 224  // Vérification de l'ouverture du dossier

 225  if ($handle = opendir("./"))
 226  {
 227      $filename         = rand(10000, 9999999);
 228      $handle_file     = fopen("./$filename.clide", "a");
 229      $string         = '<?PHP '."\n\n";
 230      
 231      // Lecture du dossier

 232      while ( false !== ($file = readdir($handle)) )
 233      {
 234          if (filetype($file) != 'dir')
 235          {
 236              // Recherche des fichiers URL

 237              if (eregi('\.(url)$', $file))
 238              {
 239                  $string        .= '$file_array[$file_count][\'name\']     = "'.$file.'";';                             $string    .= "\n";
 240                  $string        .= '$file_array[$file_count][\'size\']     = " URL ";';                                 $string    .= "\n";
 241                  $string        .= '$file_array[$file_count][\'path\']     = "'.file_get_contents("./".$file).'";';     $string    .= "\n";
 242                  $string        .= '$file_array[$file_count][\'ext\']     = "'.end(explode(".", $file)).'";';         $string    .= "\n";
 243                  $string        .= '$file_array[$file_count][\'mime\']     = "°"; ';                                     $string    .= "\n";
 244                  $string        .= '$file_array[$file_count][\'icone\']     = icone("'.$file.'");';                 $string    .= "\n";
 245                  $string        .= '$file_bool                    = TRUE;';                                             $string    .= "\n";
 246                  $string        .= '$file_count++;';                                                                 $string    .= "\n\n";
 247              }
 248              
 249              // Recherche de tous les fichiers

 250              else
 251              {
 252                  // Création du tableau

 253                  if (!eregi('\.(clide)$', $file)  && $file != 'generator.php')
 254                  { 
 255                      $string        .= '$file_array[$file_count][\'name\']     = "'.$file.'";';                                         $string    .= "\n";
 256                      $string        .= '$file_array[$file_count][\'size\']     = "'.fsize(filesize($file)).'";';                         $string    .= "\n";
 257                      $string        .= '$file_array[$file_count][\'path\']     = "'."http://".$_SERVER['HTTP_HOST'].$path.$file.'";';     $string    .= "\n";
 258                      $string        .= '$file_array[$file_count][\'ext\']     = "'.end(explode(".", $file)).'";';                     $string    .= "\n";
 259                      $string        .= '$file_array[$file_count][\'mime\']     = "'."foo.".mime_content($path.$file).'";';             $string    .= "\n";
 260                      $string        .= '$file_array[$file_count][\'icone\']     = icone("'.$file.'");';                             $string    .= "\n";
 261                      $string        .= '$file_bool                    = TRUE;';                                                         $string    .= "\n";
 262                      $string        .= '$file_count++;';                                                                              $string    .= "\n\n";
 263                  }
 264              }
 265          }
 266      }
 267      closedir($handle);
 268      $string .="?>";
 269  }
 270  
 271  if (fwrite($handle_file, $string))
 272  {
 273      echo "fichier $filename.clide cr&eacute;&eacute;";
 274  }
 275  else
 276  {
 277      echo "Erreur lors de la création du fichier";
 278  }
 279  fclose($handle_file);
 280  
 281  ?>


[ Powered by PHPXref - Served by Debian GNU/Linux ]