| [ PHPXref.com ] | [ Generated: Sun Jul 20 21:03:02 2008 ] | [ webXadmin 2.0 ] |
| [ Index ] [ Variables ] [ Functions ] [ Classes ] [ Constants ] [ Statistics ] | ||
[Summary view] [Print] [Text view]
1 <? 2 class Explorer 3 { 4 var $parms=array(); 5 var $mess=array(); 6 var $rep; 7 var $root; // physical path 8 var $url_root; // how to get with navigator 9 var $action_priv=1; 10 var $auth_mod_topdir=0; 11 var $filter=array(".",".."); 12 var $file_image_path = "i/"; 13 var $insidebordercolor="#009999"; 14 var $filelinelink=""; 15 var $folderlinelink=""; 16 var $display_size = 1; 17 var $display_type=1; 18 var $display_date=1; 19 20 function Explorer($root,$url_root) 21 { 22 $this->root = $root; 23 $this->url_root = $url_root; 24 25 26 $this->parms["head_color"]="efefef"; 27 $this->parms["line_color1"]="white"; 28 $this->parms["line_color2"]="white"; 29 $this->parms["higlight_color2"]="#fee3bc"; 30 $this->parms["error_message"]="990000"; 31 $this->parms["img_dir"]="i/ContextMenu/"; 32 $this->parms["img_sup"]=$this->parms["img_dir"] . "del.gif"; 33 $this->parms["img_mod"]=$this->parms["img_dir"] . "edit.gif"; 34 $this->parms["maxchars"] = 30; 35 $this->parms["class"]="explorer_entry"; 36 $this->parms["basedir"]="/modules/thirdparty/explorer/"; 37 38 39 $this->mess=array( 40 "0" => "Dernière version", 41 "1" => "Fichier", 42 "2" => "Taille", 43 "3" => "Type", 44 "4" => "Modifié le", 45 "5" => "Actions", 46 "6" => "Renommer", 47 "7" => "Supprimer", 48 "8" => "Dossier", 49 "9" => "Fichier MIDI", 50 "10" => "Document texte", 51 "11" => "Javascript", 52 "12" => "Image GIF", 53 "13" => "Image JPG", 54 "14" => "Page HTML", 55 "15" => "Page HTML", 56 "16" => "Fichier REAL", 57 "17" => "Fichier REAL", 58 "18" => "Script PERL", 59 "19" => "Fichier ZIP", 60 "20" => "Son WAV", 61 "21" => "Script PHP", 62 "22" => "Script PHP", 63 "23" => "Fichier", 64 "24" => "Dossier parent", 65 "25" => "Transférer un fichier (taille maxi 500ko) dans : ", 66 "26" => "Créer un nouveau répertoire dans : ", 67 "27" => "Transférer", 68 "28" => "Créer un nouveau fichier dans : ", 69 "29" => "Créer", 70 "30" => "Saisissez un nom de répertoire et cliquez sur "Créer"", 71 "31" => "Vous n'avez pas sélectionné de fichier", 72 "32" => "Retour", 73 "33" => "Erreur de transfert !", 74 "34" => "Le Fichier", 75 "35" => "a été enregistré dans le répertoire", 76 "36" => "Sa taille est de", 77 "37" => "Veuillez saisir un nom de fichier valide", 78 "38" => "Le dossier", 79 "39" => "a été créé dans le répertoire", 80 "40" => "Ce dossier existe déjà", 81 "41" => "a été renommé en", 82 "42" => "en", 83 "43" => "existe déjà", 84 "44" => "a été effacé", 85 "45" => "répertoire", 86 "46" => "fichier", 87 "47" => "Voulez-vous supprimer définitivement le", 88 "48" => "OUI", 89 "49" => "NON", 90 "50" => "Fichier EXE", 91 "51" => "Editer", 92 "52" => "Edition du fichier", 93 "53" => "Enregistrer", 94 "54" => "Annuler", 95 "55" => "a été modifié", 96 "56" => "Image BMP", 97 "57" => "Image PNG", 98 "58" => "Fichier CSS", 99 "59" => "Fichier MP3", 100 "60" => "Fichier RAR", 101 "61" => "Fichier GZ", 102 "62" => "root du site", 103 "63" => "Déconnexion", 104 "64" => "Fichier Excel", 105 "65" => "Fichier Word", 106 "66" => "Copier", 107 "67" => "Fichier sélectionné", 108 "68" => "Coller dans", 109 "69" => "Ou choisissez un autre répertoire", 110 "70" => "Déplacer", 111 "71" => "Ce fichier existe déjà", 112 "72" => "La root du répertoire est incorrecte. Vérifier la variable dans le fichier telech.php3", 113 "73" => "a été copié dans le répertoire", 114 "74" => "a été déplacé dans le répertoire", 115 "75" => "Le fichier users.txt n'est pas dans le répertoire prive", 116 "76" => "Ce fichier a été supprimé", 117 "77" => "Erreur de création répertoire :", 118 "visu"=>"Visualiser" 119 ); 120 $this->input_action(); 121 } 122 function input_action() 123 { 124 global $_POST,$_GET; 125 $arr_data=array(); 126 127 /*if ($_POST["a"]!="" || $_POST["rep"]!="") 128 {$arr_data=$_POST;} 129 if ($_GET["a"]!="" || $_GET["rep"]!="") 130 {$arr_data=$_GET;}*/ 131 $arr_data =array_merge($_GET,$_POST); 132 $this->rep = $arr_data["rep"]; 133 134 if ($arr_data["a"]!="") $this->action($arr_data); 135 } 136 function slash() 137 { 138 if(ereg("\\\\",$this->root)){$slash="\\";} 139 else {$slash="/";} 140 return $slash; 141 } 142 143 function listing($nom_rep) 144 { 145 global $sens,$ordre,$font; 146 $handle=opendir($nom_rep); 147 while ($fichier = readdir($handle)) 148 { 149 if(!in_array($fichier, $this->filter)) 150 { 151 $liste_nom[$fichier]=$this->mimetype($nom_rep.$this->slash().$fichier,"image"); 152 $liste_taille[$fichier]=filesize($nom_rep.$this->slash().$fichier); 153 $liste_mod[$fichier]=filemtime($nom_rep.$this->slash().$fichier); 154 $liste_type[$fichier]=$this->mimetype($nom_rep.$this->slash().$fichier,"type"); 155 } 156 } 157 closedir($handle); 158 159 if($ordre=="nom") 160 { 161 if (is_array($liste_nom)) 162 {if($sens==0){ksort($liste_nom);}else{krsort($liste_nom);} 163 } 164 $liste=$liste_nom; 165 } 166 else if($ordre=="taille") 167 { 168 if($sens==0){asort($liste_taille);}else{arsort($liste_taille);} 169 $liste=$liste_taille; 170 } 171 else if($ordre=="mod") 172 { 173 if($sens==0){asort($liste_mod);}else{arsort($liste_mod);} 174 $liste=$liste_mod; 175 } 176 else if($ordre=="type") 177 { 178 if($sens==0){asort($liste_type);}else{arsort($liste_type);} 179 $liste=$liste_type; 180 } 181 else 182 { 183 // ORDRE PAR DEFAUT (type) 184 if(is_array($liste_type)) 185 { 186 if($sens==0){asort($liste_type);}else{arsort($liste_type);} 187 } 188 $liste=$liste_type; 189 } 190 return $liste; 191 } 192 function mimetype($fichier,$quoi) 193 { 194 195 if(is_dir($fichier)){$image="repertoire-ferme.gif";$nom_type=$this->mess[8];} 196 else if(eregi("\.mid",$fichier)){$image="mid.gif";$nom_type=$this->mess[9];} 197 else if(eregi("\.txt",$fichier)){$image="txt.gif";$nom_type=$this->mess[10];} 198 else if(eregi("\.js",$fichier)){$image="js.gif";$nom_type=$this->mess[11];} 199 else if(eregi("\.gif",$fichier)){$image="gif.gif";$nom_type=$this->mess[12];} 200 else if(eregi("\.jpg",$fichier)){$image="jpg.gif";$nom_type=$this->mess[13];} 201 else if(eregi("\.html",$fichier)){$image="html.gif";$nom_type=$this->mess[14];} 202 else if(eregi("\.htm",$fichier)){$image="html.gif";$nom_type=$this->mess[15];} 203 else if(eregi("\.rar",$fichier)){$image="rar.gif";$nom_type=$this->mess[60];} 204 else if(eregi("\.gz",$fichier)){$image="zip.gif";$nom_type=$this->mess[61];} 205 else if(eregi("\.ra",$fichier)){$image="ram.gif";$nom_type=$this->mess[16];} 206 else if(eregi("\.ram",$fichier)){$image="ram.gif";$nom_type=$this->mess[17];} 207 else if(eregi("\.rm",$fichier)){$image="ram.gif";$nom_type=$this->mess[17];} 208 else if(eregi("\.pl",$fichier)){$image="pl.gif";$nom_type=$this->mess[18];} 209 else if(eregi("\.zip",$fichier)){$image="zip.gif";$nom_type=$this->mess[19];} 210 else if(eregi("\.wav",$fichier)){$image="wav.gif";$nom_type=$this->mess[20];} 211 else if(eregi("\.php",$fichier)){$image="php.gif";$nom_type=$this->mess[21];} 212 else if(eregi("\.php3",$fichier)){$image="php.gif";$nom_type=$this->mess[22];} 213 else if(eregi("\.exe",$fichier)){$image="exe.gif";$nom_type=$this->mess[50];} 214 else if(eregi("\.bmp",$fichier)){$image="bmp.gif";$nom_type=$this->mess[56];} 215 else if(eregi("\.png",$fichier)){$image="gif.gif";$nom_type=$this->mess[57];} 216 else if(eregi("\.css",$fichier)){$image="css.gif";$nom_type=$this->mess[58];} 217 else if(eregi("\.mp3",$fichier)){$image="mp3.gif";$nom_type=$this->mess[59];} 218 else if(eregi("\.xls",$fichier)){$image="xls.gif";$nom_type=$this->mess[64];} 219 else if(eregi("\.doc",$fichier)){$image="doc.gif";$nom_type=$this->mess[65];} 220 else {$image="defaut.gif";$nom_type=$this->mess[23];} 221 if($quoi=="image"){return $image;} else {return $nom_type;} 222 } 223 function fsize($fichier) 224 { 225 global $size_unit; 226 $taille=filesize($fichier); 227 if ($taille >= 1073741824) {$taille = round($taille / 1073741824 * 100) / 100 . " G".$size_unit;} 228 elseif ($taille >= 1048576) {$taille = round($taille / 1048576 * 100) / 100 . " M".$size_unit;} 229 elseif ($taille >= 1024) {$taille = round($taille / 1024 * 100) / 100 . " K".$size_unit;} 230 else {$taille = $taille . " ".$size_unit;} 231 if($taille==0 || is_dir($fichier)) {$taille=" ";} 232 return $taille; 233 } 234 235 function date_modif($fichier) 236 { 237 $tmp = filemtime($fichier); 238 return date("d/m/Y",$tmp); 239 } 240 241 function init() 242 { 243 global $sens,$mess,$font; 244 if($this->rep==""){$nom_rep=$this->root;} 245 if($sens==""){$sens=0;} 246 else 247 { 248 if($sens==1){$sens=0;}else{$sens=1;} 249 } 250 if($this->rep!=""){$this->rep=stripslashes($this->rep);$nom_rep=$this->root.$this->slash().$this->rep;} 251 if(!file_exists($this->root)) {echo "<font face=\"$font\" size=\"2\">".$this->mess[72]."</font>\n";exit;} 252 if(!is_dir($nom_rep)) {echo "<font face=\"$font\" size=\"2\">".$this->mess[76]."<br><br><a href=\"javascript:window.history.back()\">".$this->mess[32]."</a></font>\n";exit;} 253 return $nom_rep; 254 } 255 function deldir($location) 256 { 257 if(is_dir($location)) 258 { 259 $all=opendir($location); 260 while ($file=readdir($all)) 261 { 262 if (is_dir($location.$this->slash().$file) && $file <> ".." && $file <> ".") 263 { 264 $this->deldir($location.$this->slash().$file); 265 if(file_exists($location.$this->slash().$file)){rmdir($location.$this->slash().$file); } 266 unset($file); 267 } 268 elseif (!is_dir($location.$this->slash().$file)) 269 { 270 unlink($location.$this->slash().$file); 271 unset($file); 272 } 273 } 274 275 closedir($all); 276 unset($all); 277 rmdir($location); 278 } 279 else 280 { 281 closedir($all); 282 unset($all); 283 unlink($location); 284 } 285 } 286 function toHTML() 287 { 288 // $rep,$ordre,$sens passes dans l'url 289 global $ordre,$sens,$id,$font; 290 $str=array(); 291 echo $this->js(); 292 if(eregi("\.\.",$this->rep) || $this->rep==".") {$this->rep="";} 293 $nom_rep=$this->init(); 294 $base_nom_rep=str_replace($this->root,"",$nom_rep); 295 if($base_nom_rep==""){$base_nom_rep=$this->slash();} 296 $this->rep=stripslashes($this->rep); 297 298 $titre_root = "Index des documents"; 299 // AFFICHAGE DU REPERTOIRE COURANT ET root 300 //$str[] = "<table bgcolor=white width=100% cellpadding=0 cellspacing=0 border=0><tr><td><img src=\"i/repertoire-ferme.gif\" width=\"20\" height=\"20\" align=\"ABSMIDDLE\"><font face=\"$font\" size=\"2\"><a href=\"" . $sess->url("telech.php") . "\"><b>$titre_root</b></a> $base_nom_rep</font></td>"; 301 //$str[] = "<td align=\"right\"><font face=\"$font\" size=\"2\">"; 302 //if($users==1) {$str[] = "<a href=\"telech.php?action=deconnexion&id=$id\">$this->mess[63]</a>";} 303 //$str[] = "</font></td></tr></table><br>"; 304 305 $str[] = "<div id=filelist><TABLE width=100% cellpadding=0 cellspacing=0 border=0 style='border:solid 1px $this->insidebordercolor' bgcolor=white>"; 306 307 308 // PREMIERE LIGNE DU TABLEAU : Nom du fichier / Taille / Type / Modifié le / Actions 309 if($this->rep!="" ){$lien="&rep=".$this->rep;} 310 311 $str[] = "<tr bgcolor=" . $this->parms["head_color"] . " >"; 312 313 $str[] = "<td align=center height=20 style='border-bottom:solid black 1px'><b><a href=\"" . $this->get_url( "&sens=$sens&ordre=nom".$lien ) ."\" class=explorer_entry>" . $this->mess[1] . "</a></b></td>\n"; 314 if ($this->display_size) $str[] = "<td style='border-bottom:solid black 1px'><b><a href=\"" .$this->get_url( "&sens=$sens&ordre=taille".$lien) ."\" class=explorer_entry>" .$this->mess[2]. "</a></b></td>\n"; 315 if ($this->display_type) $str[] = "<td style='border-bottom:solid black 1px'><b><a href=\"" .$this->get_url( "&sens=$sens&ordre=type".$lien )."\" class=explorer_entry>" .$this->mess[3]. "</a></b></td>\n"; 316 if ($this->display_date) $str[] = "<td style='border-bottom:solid black 1px'><b><a href=\"" .$this->get_url( "&sens=$sens&ordre=mod".$lien) ."\" class=explorer_entry>" .$this->mess[4]. "</a></b></td>\n"; 317 /*if ($this->rep!="") $str[] = "<td align=center><b>" .$this->mess[5]. "</b></td>\n"; */ 318 319 320 // LIEN DOSSIER PARENT 321 if($this->rep!="") 322 { 323 $nom=dirname($this->rep); 324 $str[] = "<tr bgcolor=" . $this->parms["head_color"] . "><td nowrap colspan=4><a href=\"" . $this->get_url( $this->rep!=$nom?"&rep=$nom":""); 325 $str[] = "\" class=explorer_entry><img src=\"" . $this->file_image_path . "parent.gif\" width=\"20\" align=\"absmiddle\" border=\"0\" alt=\"".$this->mess[24]."\" class=explorer_entry><b>$base_nom_rep</b></font></a></td>"; 326 //if ( $this->rep!="") $str[] = "<td> </td></tr>\n"; 327 } 328 329 // LECTURE DU REPERTOIRE ET CLASSEMENT DES FICHIERS 330 $liste=$this->listing($nom_rep); 331 332 // AFFICHAGE 333 $lineno=0; 334 if(is_array($liste)) 335 { 336 while (list($fichier,$mime) = each($liste)) 337 338 { 339 // DEFINITION DU LIEN SUR LE FICHIER 340 if(is_dir($nom_rep.$this->slash().$fichier)) 341 { 342 $lien= $this->get_url ( "&rep=" . ($this->rep!=""?$this->rep.$this->slash():"") . $fichier); 343 $affiche_copier="non"; 344 } 345 else 346 { 347 $lien=$this->url_root . "/"; 348 if($this->rep!=""){$lien.=$this->rep ."/";} 349 $lien.="$fichier"; 350 $affiche_copier="non"; 351 } 352 353 if (!is_dir($nom_rep.$this->slash().$fichier)) 354 { 355 if ($this->filelinelink!="" ) 356 $lien = str_replace("--", $this->rep . "/" . $fichier, $this->filelinelink); 357 } 358 else 359 { 360 if ($this->folderlinelink!="" ) 361 $lien = str_replace("--", $lien, $this->filelinelink); 362 } 363 364 // AFFICHAGE DE LA LIGNE 365 if ($color==$this->parms["line_color1"] ) 366 $color= $this->parms["line_color2"] ; 367 else $color=$this->parms["line_color1"]; 368 369 //NAME OF FILE IN THIS LINE FOR URL 370 $this->linefilename = $this->rep!=""?$this->rep."&fic=".$this->rep.$this->slash().$fichier:"&fic=" .$fichier; 371 $lineno++; 372 $str[] = "<tr bgcolor=$color ondblclick='select_line(this,$lineno,\"". str_replace("&fic=","",$this->linefilename) ."\")'>"; 373 374 $str[] = "<td nowrap class=explorer_entry>"; 375 376 $str[] = "<a href=\"$lien\""; 377 if (!is_dir($nom_rep.$this->slash().$fichier) && $this->filelinelink=="") $str[] = " target=_blank"; 378 $str[] = "><img src=\"" . $this->file_image_path . $this->mimetype($nom_rep.$this->slash().$fichier,"image")."\" width=\"20\" height=\"20\" align=\"ABSMIDDLE\" border=\"0\"> "; 379 $str[] = "$fichier</a>\n"; 380 $str[] = "</td>\n"; 381 382 383 384 if ($this->display_size) 385 { 386 $str[] = "<td class=explorer_entry>"; 387 $str[] = $this->fsize($nom_rep.$this->slash().$fichier); 388 $str[] = "</td>"; 389 } 390 if ($this->display_type) 391 { 392 $str[] = "<td class=explorer_entry>"; 393 $str[] = $this->mimetype($nom_rep.$this->slash().$fichier,"type"); 394 $str[] = "</td>"; 395 } 396 if ($this->display_date) 397 { 398 $str[] = "<td class=explorer_entry>"; 399 $str[] = $this->date_modif($nom_rep.$this->slash().$fichier); 400 $str[] = "</td>"; 401 } 402 403 $str[] = "<td nowrap align=center >"; 404 // IMAGE COPIER 405 if($affiche_copier=="oui") 406 { 407 $str[] = "<a href=\"" . $this->get_url( "&action=copier&rep=" . ($rep!=""?"$rep&fic=$rep".$this->slash():"&fic=") ); 408 $str[] = "$fichier\"><img src=\"" . $this->file_image_path . "copier.gif\" alt=\"". $this->mess[66]."\" width=\"20\" height=\"20\" border=\"0\"></a>\n"; 409 } 410 411 412 // IMAGE DEPLACER 413 if(!is_dir($this->root.$this->slash().$fichier)) 414 { 415 //$str[] = "<a href=\"" . $sess->url($PHP_SELF) . "&action=deplacer&rep=";if($rep!=""){$str[] = "$rep&fic=$rep".slash();}else{$str[] = "&fic=";} 416 //$str[] = "$fichier\"><img src=\"i/deplacer.gif\" alt=\"$this->mess[70]\" width=\"20\" height=\"20\" border=\"0\"></a>\n"; 417 } 418 /* 419 if (($this->rep!="" || $this->auth_mod_topdir) && $this->action_priv) 420 { 421 // IMAGE RENOMMER 422 if (!is_dir($nom_rep.$this->slash().$fichier)) 423 $this_item = "ce fichier"; 424 else 425 $this_item = "ce répertoire"; 426 427 428 429 $str[] = " <a href=\"javascript:precise_url('" . $this->get_url( "&a=rename&rep=" .$this->linefilename); 430 $str[] = "','fic_new','Renommer $this_item','$fichier')\"><img src=\"" . $this->parms["img_mod"] . "\" alt=\"".$this->mess[6]."\" border=\"0\" align=absmiddle> ". $this->mess[6]."</a>\n"; 431 432 // IMAGE SUPPRIMER 433 $str[] = " <a href=\"javascript:confirm_url('" . $this->get_url( "&a=sup&rep=" .($this->linefilename)); 434 $str[] = "',' $this_item')\"><img src=\"" . $this->parms["img_sup"] . "\" alt=\"".$this->mess[7]."\" border=\"0\" align=absmiddle> ".$this->mess[7]."</a>\n"; 435 }*/ 436 // IMAGE EDITER 437 //if(eregi("\.txt|\.php|\.php3|\.htm|\.html|\.cgi|\.pl|\.js",$fichier) && !is_dir($this->root.slash().$fichier)) 438 // { 439 // $str[] = "<a href=\"" . $sess->url($PHP_SELF) . "&action=editer&rep=";if($rep!=""){$str[] = "$rep&fic=$rep".slash();}else{$str[] = "&fic=";} 440 // $str[] = "$fichier\"><img src=\"i/editer.gif\" alt=\"$this->mess[51]\" width=\"20\" height=\"20\" border=\"0\"></a>\n"; 441 // } 442 443 $str[] = "</td>\n"; 444 445 } 446 } 447 else $str[] = "<tr><th colspan=6 bgcolor=" . $this->parms["line_color2"] . " height=60 class=explorer_entry>Ce répertoire est vide</th></tr>"; 448 $str[] = "</table></div>" . $this->horizontal_space(); 449 return join('',$str); 450 } 451 452 function horizontal_space() 453 { 454 return "<table border=0 cellpadding=1 cellspacing=1><tr><td></td></tr></table>"; 455 } 456 function getfilename($nom) 457 { 458 $nom=stripslashes($nom); 459 $nom=str_replace("'","",$nom); 460 $nom=str_replace("\"","",$nom); 461 $nom=str_replace("\"","",$nom); 462 $nom=str_replace("&","",$nom); 463 $nom=str_replace(",","",$nom); 464 $nom=str_replace(";","",$nom); 465 $nom=str_replace("/","",$nom); 466 $nom=str_replace("\\","",$nom); 467 $nom=str_replace("`","",$nom); 468 $nom=str_replace("<","",$nom); 469 $nom=str_replace(">","",$nom); 470 $nom=str_replace(" ","_",$nom); 471 $nom=str_replace(":","",$nom); 472 $nom=str_replace("*","",$nom); 473 $nom=str_replace("|","",$nom); 474 $nom=str_replace("?","",$nom); 475 $nom=str_replace("é","e",$nom); 476 $nom=str_replace("è","e",$nom); 477 $nom=str_replace("ç","c",$nom); 478 $nom=str_replace("@","",$nom); 479 $nom=str_replace("â","a",$nom); 480 $nom=str_replace("ê","e",$nom); 481 $nom=str_replace("î","i",$nom); 482 $nom=str_replace("ô","o",$nom); 483 $nom=str_replace("û","u",$nom); 484 $nom=str_replace("ù","u",$nom); 485 $nom=str_replace("à","a",$nom); 486 $nom=str_replace("!","",$nom); 487 $nom=str_replace("§","",$nom); 488 $nom=str_replace("+","",$nom); 489 $nom=str_replace("^","",$nom); 490 $nom=str_replace("(","",$nom); 491 $nom=str_replace(")","",$nom); 492 $nom=str_replace("#","",$nom); 493 $nom=str_replace("=","",$nom); 494 $nom=str_replace("$","",$nom); 495 $nom=str_replace("%","",$nom); 496 //$nom = strtolower(substr ($nom,0,$this->parms["maxchars"])); 497 $nom = strtolower($nom); 498 return $nom; 499 } 500 function enlever_controlM($fichier) 501 { 502 $fic=file($fichier); 503 $fp=fopen($fichier,"w"); 504 while (list ($cle, $val) = each ($fic)) 505 { 506 $val=str_replace(CHR(10),"",$val); 507 $val=str_replace(CHR(13),"",$val); 508 fputs($fp,"$val\n"); 509 } 510 fclose($fp); 511 } 512 function action($arr_data) 513 { 514 $action=$arr_data["a"]; 515 516 switch($action) { 517 case "sup"; $this->action_delete($arr_data);break; 518 case "upload";$this->action_upload($arr_data);break; 519 case "mkdir"; $this->action_mkdir($arr_data);break; 520 case "rename"; $this->action_rename($arr_data); break; 521 } 522 }//end of function act 523 function action_rename($arr_data) 524 { 525 $err=0; 526 //$this->rep=stripslashes($arr_data["rep"]); 527 $fic=stripslashes($arr_data["fic"]); 528 $nom_fic=basename($arr_data["fic"]); 529 $messtmp="<font color=red>"; 530 $newdirname=$this->getfilename($arr_data["fic_new"]); 531 $old=$this->root.$this->slash().$fic; 532 $new=dirname($old).$this->slash().$newdirname; 533 534 if($newdirname=="") 535 { 536 $messtmp.="$fic_new :". $this->mess[37] ; $err=1; 537 } 538 //else if(file_exists($new)) 539 // { 540 // $messtmp.="<b>$fic_new</b> $this->mess[43]"; $err=1; 541 // } 542 else 543 { 544 rename($old,$new); 545 $messtmp.="<b>$fic</b>". $this->mess[41] ."<b>$newdirname</b>"; 546 } 547 $messtmp.="<br><br>"; 548 $messtmp.="</font>"; 549 if ($err) 550 {echo "<center>\n"; 551 echo "$messtmp";} 552 } 553 function create_dir($dir) 554 { 555 umask(000); 556 $rep = $this->root.$this->slash().$this->rep.$this->slash().$dir; 557 if (!mkdir($rep,0777)) 558 echo $this->mess[77] . " $rep - $dir"; 559 } 560 function createIfNotExists($dir) 561 { 562 $full_rep=$this->root.$this->slash().$this->rep.$this->slash().$dir; 563 if (!file_exists($full_rep)) 564 $this->create_dir($dir); 565 } 566 function action_mkdir($arr_data) 567 { 568 $err=""; 569 $messtmp="<font color=" . $this->parms["error_message"] . ">"; 570 $this->rep=stripslashes($arr_data["rep"]); 571 $nomdir=$this->getfilename($arr_data["newdirname"]); 572 573 if($nomdir=="") 574 { 575 $messtmp.=$this->mess[37] ." $nomdir"; $err=1; 576 } 577 else if(file_exists($this->root.$this->slash().$this->rep.$this->slash().$nomdir)) 578 { 579 $messtmp.=$this->mess[40]; $err=1; 580 } 581 else 582 { 583 $this->create_dir($nomdir); 584 //umask(000); 585 //mkdir($this->root.$this->slash().$this->rep.$this->slash().$nomdir,0777); 586 $messtmp.=$this->mess[38] ."<b>$nomdir</b>". $this->mess[39] ." <b>"; 587 if($this->rep=="") {$messtmp.="/";} else {$messtmp.="$rep";} 588 $messtmp.="</b>"; 589 } 590 $messtmp.="</font>"; 591 if ($err) 592 {echo "<center>\n"; 593 echo "$messtmp";} 594 } 595 function action_delete($arr_data) 596 { 597 //$this->rep=stripslashes($arr_data["rep"]); 598 $fic=stripslashes($arr_data["fic"]); 599 if ($fic!="") 600 { 601 $messtmp="<font face=\"$font\" size=\"2\">"; 602 $a_effacer=$this->root.$this->slash().$fic; 603 604 if(file_exists($a_effacer)) 605 { 606 if(is_dir($a_effacer)){$this->deldir($a_effacer);$messtmp.="$this->mess[38] <b>$fic</b> $this->mess[44].";} 607 else {unlink($a_effacer); $messtmp.="$this->mess[34] <b>$fic</b> $this->mess[44].";} 608 } 609 else {$messtmp.=$this->mess[76];} 610 } 611 else echo "erreur (file delete) : aucun fichier spécifié "; 612 613 //$messtmp.="</font>"; 614 //echo "<center>\n"; 615 //echo "$messtmp"; 616 } 617 function action_upload($arr_data) 618 { 619 global $_FILES; 620 $InputFile = "userfile"; 621 $this->rep=stripslashes($arr_data["rep"]); 622 623 $userfile = $_FILES[$InputFile]['tmp_name']; 624 $userfile_size = $_FILES[$InputFile]['size']; 625 $userfile_name = $_FILES[$InputFile]['name']; 626 $FileType = $_FILES[$InputFile]['type']; 627 628 $messtmp="<font color=" . $this->parms["error_message"] . ">"; 629 if($this->rep!=""){$rep_source=$this->slash().$this->rep;} 630 $destination=$this->root.$rep_source; 631 if ($userfile_size!=0) {$taille_ko=$userfile_size/1024;} else {$taille_ko=0;} 632 if ($userfile=="none") {$message=$this->mess[31];} 633 if ($userfile!="none" && $userfile_size!=0) 634 { 635 $userfile=stripslashes($userfile); 636 $userfile_name=$this->getfilename($userfile_name); 637 if (!copy($userfile, "$destination/$userfile_name")) 638 { 639 $message="<br>$this->mess[33]<br>$userfile_name"; 640 } 641 else 642 { 643 if(eregi("\.txt","$userfile_name") 644 ||eregi("\.html","$userfile_name") 645 ||eregi("\.htm","$userfile_name") 646 ||eregi("\.php","$userfile_name") 647 ||eregi("\.php3","$userfile_name") 648 ||eregi("\.htaccess","$userfile_name") 649 ||eregi("\.htpasswd","$userfile_name") 650 ||eregi("\.pl","$userfile_name") 651 ||eregi("\.cgi","$userfile_name") 652 ||eregi("\.js","$userfile_name") 653 ) 654 { 655 $this->enlever_controlM("$destination/$userfile_name"); 656 } 657 $message="$this->mess[34] <b>$userfile_name</b> $this->mess[35] <b>$rep</b>"; 658 } 659 } 660 $messtmp.="$message<br>"; 661 $messtmp.="</font>"; 662 if ($err) 663 {echo "<center>\n"; 664 echo "$messtmp";} 665 } 666 function frm_new() 667 { 668 global $self; 669 $str=array(); 670 $str[] = "<table width=100% bgcolor=white style='border:solid 1px $this->insidebordercolor'> <form enctype=\"multipart/form-data\" action=\"$self\" method=\"post\"><tr > 671 <td colspan=\"2\" class=explorer_entry>" . $this->mess[25]; 672 if($this->rep==""){$str[] = "/";}else{$str[] = $this->rep;} 673 $str[] = "</b><br> 674 <input type=\"file\" name=\"userfile\" size=\"30\" class=explorer_entry> 675 <INPUT TYPE=\"hidden\" name=\"a\" value=\"upload\"> 676 <INPUT TYPE=\"hidden\" name=\"id\" value=\"$id\"> 677 <input type=\"hidden\" name=\"rep\" value=\"" . $this->rep ."\"> 678 <input type=\"submit\" name=\"Submit\" value=\"" . $this->mess[27]."\" class=explorer_entry> 679 680 </td> 681 </tr></form> 682 <form method=\"post\" action=\"$self\"><tr bgcolor=white> 683 <td colspan=\"2\" class=explorer_entry> " . $this->mess[26] .""; 684 if($this->rep==""){$str[] = "/";}else{$str[] = $this->rep;} 685 $str[] = "</font><br> 686 <input type=\"text\" name=\"newdirname\" size=\"30\" class=explorer_entry> 687 <input type=\"hidden\" name=\"rep\" value=\"" . $this->rep ."\"> 688 <input type=\"hidden\" name=\"a\" value=\"mkdir\"> 689 <INPUT TYPE=\"hidden\" name=\"id\" value=\"$id\"> 690 <input class=explorer_entry type=\"submit\" name=\"Submit\" value=\"" . $this->mess[29]."\" > 691 692 </td> 693 </tr> </form></table>"; 694 return join("",$str); 695 } 696 function HTML_buttons() 697 { 698 global $libdir; 699 $str=array(); 700 //See 701 $button_see=$this->mess["visu"]; 702 $href_see = "javascript:openPopWin('" . $libdir . $this->parms["basedir"]. "file.php?f=" . $this->url_root . "/' + get_current_id() )"; 703 704 $str[] = "<a href=\"" . $href_see ."\" class=explorer_entry >$button_see</a>"; 705 706 //Rename 707 $button_rename =$this->mess[6]; 708 $href_rename="javascript:precise_url('" . $this->get_url('&a=rename&rep=' . $this->rep ) . "&fic=' + get_current_id() ,'fic_new','Renommer ', get_current_id() )"; 709 $str[] = "<a href=\"" . $href_rename ."\" class=explorer_entry>$button_rename</a>"; 710 711 //Delete 712 $button_delete =$this->mess[7]; 713 $href_delete="javascript:confirm_url('" . $this->get_url('&a=sup&rep=' . $this->rep ) . "&fic=' + get_current_id() , 'ce fichier')"; 714 $str[] = "<a href=\"" . $href_delete."\" class=explorer_entry>$button_delete</a>"; 715 $return_string = "<table width=100% style='border:solid 1px $this->insidebordercolor' bgcolor=white><tr><td align=right class=explorer_entry>" . join(' | ', $str) . "</td></tr></table>" . $this->horizontal_space(); 716 return $return_string; 717 } 718 719 720 function js() 721 { 722 return "<script> 723 var selected = ''; 724 var dest='' 725 function select_line(obj,num,id){ 726 if (selected!='' ){ selected.bgColor = '#ffffff';} 727 obj.bgColor = '#ff9900'; 728 selected = obj; 729 dest=id; 730 document.selection.empty(); 731 } 732 function get_current_id() 733 { 734 return dest; 735 } 736 </script>"; 737 } 738 function get_url($parms) 739 { 740 global $self; 741 return $self . "?$parms"; 742 } 743 } 744 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| [ Powered by PHPXref - Served by Debian GNU/Linux ] |