View file fun.php

File size: 1.48Kb
<?
function buffer($query){ 
if(mb_strlen(file_get_contents("image/buffer.dat","UTF-8"))>1){ echo '<a href=edit.php?'.$query.'>Копировать из буфера<br></a>'; } 
}
function copyDir($in,$to){
$open=opendir($in); while($while=readdir($open)){ if($while=='.' & $while=='..') continue;
if(is_dir("$in/$while")){
if(!is_dir($to)){  mkdir($to); chmod($to,0777); }
copyDir("$in/$while","$to/$while");  } if(is_file("$in/$while")){  copy("$in/$while","$to/$while"); }
}
}
function clearDir($path){ 
$open=opendir($path); while($while=readdir($open)){  if(is_file("$path/$while")){ unlink("$path/$while"); } else
if(is_dir("$path/$while") & $while!='.' & $while!='..'){  clearDir("$path/$while"); 
} rmdir("$path/$while"); }
closedir($open);
}
function size($size){ if($size<1024) $size="".$size."B"; if($size<1048576 and $size>=1024) $size=''.round($size/1024,2).'KB'; if($size>1048576) $size=''.round($size/1024/1024,2).'MB'; return $size; } 
function deleteDir($path){ 
if(is_file($path)){ unlink($path); }
$open=opendir($path); while($while=readdir($open)){ 
if(is_file("$path/$while")){ unlink("$path/$while"); } else
if(is_dir("$path/$while") && $while!='.' && $while!='..'){

deleteDir("$path/$while");
}
}
closedir($open); rmdir($path); 
}
function name_ext($file){
$pos_name=mb_strrpos(basename($file),'.','UTF-8');
    $str['name']=mb_substr(basename($file),0,$pos_name,'UTF-8');
   
  $str['ext']=mb_substr(basename($file),$pos_name,mb_strlen(basename($file),'UTF-8'),'UTF-8');
 return $str;
 
 }
?>