= 1073741824) {$sz = round($sz / 1073741824 * 100) / 100 . $StrLang["GB"];} elseif ($sz >= 1048576) {$sz = round($sz / 1048576 * 100) / 100 . $StrLang["MB"];} elseif ($sz >= 1024) {$sz = round($sz / 1024 * 100) / 100 . $StrLang["KB"];} else {$sz = $sz . $StrLang["Byte"];} } return $sz; } /*-----------------------------------------------------------------*/ function LastUpdate($file) { $buf = filemtime($file); return date("d-m-Y H:i:s",$buf); //linux ??? comme ça d/m/Y H:i } /*-----------------------------------------------------------------*/ function is_editable($file) { global $EditableExt; $string=""; for ($i=0;$i"; if($ver){ echo " "; echo ""; echo ""; echo ""; echo "

Powred by "._App_." "._AppVer_." ( Check for update )
[ "._HomeUrl_." ]

"; } echo ""; } /*-----------------------------------------------------------------*/ function GetDirList ($dir) { chdir ($dir); $handle=opendir("."); while ($file = readdir($handle)) if(is_dir($file) && $file!="." && $file!="..") $Dirslist[$file]=$file; closedir($handle); return $Dirslist; } /*-----------------------------------------------------------------*/ function GetFilesList ($dir) { $handle=opendir($dir); while ($file = readdir($handle)) if(!is_dir($file) && $file!="." && $file!="..") $Fileslist[$file]=$file; closedir($handle); return $Fileslist; } /*-----------------------------------------------------------------*/ function ChangeNameIfExists($dir,$file) { if(file_exists($dir."/".$file) ) { $num=2; $name= $num."_copy_of_".$file; while (file_exists($dir."/".$name) ) {$num++; $name= $num."_copy_of_".$file; } } else $name=$file; return $name; } /*-----------------------------------------------------------------*/ function CopyInTemp($file) { $MAX=10; $p="abcdefghijklmnopqurstvwxyz0123456789"; $name=""; srand((float) microtime()*1000000); for ($j=0;$j<$MAX;$j++) { $name .= substr($p,(rand()%(strlen($p))),1); } $new=ChangeNameIfExists(_ScriptDir."/temp",$name) ; $fftt=explode(".",$file); $tmp=(count($fftt)-1); $ff=$fftt[$tmp]; if(copy($file , _ScriptDir."/temp/".$new.".".$ff)) return $new.".".$ff; else return false; } /*-----------------------------------------------------------------*/ function ClearTemp() { $tab=GetFilesList (_ScriptDir."/temp/"); while (list ($file, $file2) = each ($tab)) { $df=date("d-m-Y",fileatime(_ScriptDir."/temp/".$file)); $today= date("d-m-Y"); if($df<$today && $file!=".htaccess") unlink(_ScriptDir."/temp/".$file); } } /*-----------------------------------------------------------------*/ function RemoveDir($dir) { if($handle=@opendir($dir)) { while ($file=readdir($handle)) { if (is_dir($dir."/".$file) && $file !=".." && $file!="." ) { RemoveDir($dir."/".$file); if (file_exists($dir."/".$file)) { rmdir($dir."/".$file); } } else{ if (is_file($dir."/".$file) && file_exists($dir."/".$file)) { /* $fp=fopen($dir."/".$file,"rb"); $contents=fread($fp,filesize($dir."/".$file)); $buf=gzencode($contents); chdir (_ScriptDir_."/trash/"); $sauv=$file."\n".$dir.$file."\n".date("d/m/Y h:m:s")."\n".filesize($dir."/".$file)."\n"; $MAX=30; $p="abcdefghijklmnopqurstvwxyzABCDEFGHIJKLMNOPQURSTVWXYZ0123456789"; $name=""; srand((float) microtime()*1000000); for ($j=0;$j<$MAX;$j++) { $name .= substr($p,(rand()%(strlen($p))),1); } $fpout=fopen($name.".gz","wb"); $fpsauv=fopen($name.".info","wb"); fwrite($fpsauv,$sauv); fclose($fpsauv); if($fpout){ set_file_buffer($fpout, 0); fputs($fpout, $buf,strlen($buf)); fclose($fpout); fclose($fp); chdir ($dir); */ unlink($dir."/".$file); // } } } } closedir($handle); rmdir($dir); } else return FALSE; } /*-----------------------------------------------------------------*/ function Puterror($message) { echo "$message"; } /*-----------------------------------------------------------------*/ function GetTypeView($file) { $ret = array(); //ret[0] -> what is / ret[1] -> label global $TypeView, $StrLang; if (is_image($file)) { $ret[0] = "image"; $ret[1]=$StrLang["View"]; //view image } else { $i = 0; $c_bon = FALSE; while ($i < count($TypeView)) { if (eregi($TypeView[$i][0] . "$", $file)) { $ret[0] = $TypeView[$i][1]; $ret[1] = $TypeView[$i][2]; $c_bon = TRUE; break; } $i++; } if (!$c_bon) { if(is_editable($file)) { $ret[0] = "code"; $ret[1] = $StrLang["View"]; } else { $ret[0] = "anything"; $ret[1] = $StrLang["View"]; } } } } /*-----------------------------------------------------------------*/ function GetDirSize($rep) { $dossier=opendir($rep); $total=0; while ($fichier = readdir($dossier)) { $l = array('.', '..'); if (!in_array( $fichier, $l)) { if (is_dir($rep."/".$fichier)) { $total += GetDirSize($rep."/".$fichier); } else { $total+=filesize($rep."/".$fichier); } } } return $total; } /*-----------------------------------------------------------------*/ function CovertDirSize($rep,$create_if_dont_exist="no") { if($create_if_dont_exist=="yes") { if(!is_dir($rep) ) mkdir($rep,0700); } global $StrLang; $zz=GetDirSize($rep) ; if ($zz >= 1073741824) {$zz = round($zz / 1073741824 * 100) / 100 . $StrLang["GB"];} elseif ($zz >= 1048576) {$zz = round($zz / 1048576 * 100) / 100 . $StrLang["MB"];} elseif ($zz >= 1024) {$zz = round($zz / 1024 * 100) / 100 . $StrLang["KB"];} else {$zz = $zz . $StrLang["Byte"];} return $zz; } /*-----------------------------------------------------------------*/ // This function takes file name and checks it for validity. If name is invalid, //function return false. If filename is ok, function returns true. Tha caller function //has responsibility to check if checkFileName failed and to display message before die //Invalid character for windows file name: \/:"?*<>| // created by voyager function checkFileName($file){ //Here 255 is maxpath for windows system. It`s a good idea to be defined a constant MAX_PATH //wich can be changed on different file system such as UNIX global $cd,$HTTP_SESSION_VARS; $ret=true; if(_OS=="windows"){ if(eregi("[\/:\"?*<>|]", $file)) $ret= 0; } else{ if(eregi("[/]", $file)) $ret= 0; //Linux and Unix - there are no fobidden letters except "/" } if($file==$HTTP_SESSION_VARS["s_home"].'/'.$cd) $ret= 0; //empty filename in fact if(strlen($file)>255) $ret= 0; return $ret; } /*-----------------------------------------------------------------*/ // check $dir directory to make sure it is in the authorized path // and that $dir exists function CheckDirAccess($dir) { global $HTTP_SESSION_VARS; $ret = false; if (is_dir($HTTP_SESSION_VARS["s_home"] . "/" . $dir)) { $d1 = realpath($HTTP_SESSION_VARS["s_home"]); $d2 = realpath($HTTP_SESSION_VARS["s_home"] . "/" . $dir); // see if someone attempted to change dir down $pos = strpos($d2, $d1); if ($pos === false || $pos != 0) { // note: three equal signs $ret = false; } else { $ret = true; } } return $ret; } /*-----------------------------------------------------------------*/ function CheckUpdate($CurVer) { $ret= array(); // 0: status connection |1:new available|2:num of version if($tmp=@file("http://philex.sf.net/version.dat") ) { $NewVer = @join('',$tmp); if ($CurVer < $NewVer) { $ret[0]=TRUE ;$ret[1]=TRUE ;$ret[2]= $NewVer; } else {$ret[0]=TRUE ;$ret[1]=FALSE ; } } else $ret[0]=FALSE ; return $ret; } /*-----------------------------------------------------------------*/ /* * Regular expression by Dennis Vervest */ function wildcard($filter,$filename) { $filter = preg_replace('/[:^~`!#$%^&[]|\/]/','',$filter); // safety, remove illegal characters $filter = preg_replace('/(\.|\(|\))/',"\\\\$1",$filter); // escape some characters $filter = preg_replace('/\?/','.{1}',$filter); // prepare ? $filter = preg_replace('/\*/','.*',$filter); // prepare * $filter = '/^'.$filter.'$/'; // prepare complete regular expression string if(preg_match($filter,$filename) ) return TRUE; else return FALSE; } /*-----------------------------------------------------------------*/ function Lostfile($file) { $name=date("h_i_s_d_m_Y_").basename($file); if(@is_dir($file))$exec="copydir"; else $exec="copy"; if($exec($file , _ScriptDir."/lost+found/".$name)) return TRUE; else return FALSE; } /*-----------------------------------------------------------------*/ ?>