File size: 2.17Kb
<?
function del_slash($str)
{
$l = StrLen($str);
$one = SubStr($str,0,1);
if($one=='/') $strn = SubStr($str,1); else $strn=$str;
$l = StrLen($strn);
$two = SubStr($strn,$l-1,1);
if($two=='/') $strok = SubStr($strn,0,$l-1); else $strok=$strn;
return $strok;
}
function mas_ms($mas1,$mas2)
{
$str1 = implode("\n",$mas1);
$str2 = implode("\n",$mas2);
$mas = explode("\n",($str1.$str2));
//$mas = $mas1+$mas2;
return $mas;
}
function kolvo_files($dirname)
{
if(!Is_Dir($dirname)) { return $kol=0; exit; }
$dir = opendir($dirname);
$i=0;
while(($file=readdir($dir))!==false)
{
$pos = StrPos('@'.$file,'.');
if($pos)
{
$ps = Strrpos($file,'.');
$rsh_name = substr($file,$ps+1);
}
else
{ $rsh_name = $file; }
if(is_dir($dirname.'/'.$file)) continue;
if($rsh_name=='info' || $rsh_name=='dat' || $rsh_name=='cmt' || $rsh_name=='name') continue;
if($file=='.' || $file=='..' || $file=='index.php' || $file=='name.dat') continue;
$i++;
}
closedir($dir);
$kol=$i;
return $kol;
}
function rsh($fname)
{
$pos = StrPos('@'.$fname,'.');
if($pos)
{
$ps = Strrpos($fname,'.');
$rsh_name = substr($fname,$ps+1);
}
else
{ $rsh_name = ''; }
return $rsh_name;
}
function ext_rsh($fname)
{
$pos = StrPos('@'.$fname,'.');
if($pos)
{
$ps = Strrpos($fname,'.');
$rsh_name = substr($fname,0,$ps);
}
else
{ $rsh_name = $fname; }
return $rsh_name;
}
function top_dir($dirname)
{
$pos = StrPos('@'.$dirname,'/');
if($pos)
{
$pos = STRRPOS($dirname,'/');
$str = SUBSTR($dirname,0,$pos);
}
else { $str = '..'; }
$l = StrLen($str);
$one = SubStr($str,0,1);
if($one=='/') $strn = SubStr($str,1); else $strn=$str;
$l = StrLen($strn);
$two = SubStr($strn,$l-1,1);
if($two=='/') $strok = SubStr($strn,0,$l-1); else $strok=$strn;
return $strok;
}
function PrintKolvo($fname)
{
$kolvo = 0;
$file = file($fname);
$count = count($file);
for($i=0;$i<$count;$i++)
{
$str = $file[$i];
$kol = kolvo_files(trim($str));
$kolvo=$kolvo+$kol;
}
return $kolvo;
}
?>