View file template/inc_down.php

File size: 1.58Kb
<?php
$filtime=filemtime(BASEDIR."local/datatmp/down.dat");
$down_count=file_get_contents(BASEDIR."local/datatmp/down.dat");
$down_count=strtok($down_count,'/');

$filtime=$filtime+(3600*$config_downloadcache);

if($sitetime>$filtime || $down_count<50){
	
$dir = opendir (BASEDIR."down"); 
while ($file = readdir ($dir)) {
if (is_dir(BASEDIR."down/$file")) {
if($file=="."||$file=="..") continue;
$downdir_array[]=$file;
}}  
closedir ($dir);  

$totaldir = count($downdir_array); 
$downtime_array=array();

for ($i = 0; $i < $totaldir; $i++){ 
$dir = opendir (BASEDIR."down/$downdir_array[$i]"); 
while ($file = readdir ($dir)) {
if (( $file != ".")&&($file != "..")&&($file != ".htaccess")&&($file != "index.php")&&($file != "name.dat")&& !ereg (".txt$", "$file")&& !ereg (".JPG$", "$file")&& !ereg (".PNG$", "$file")&& !ereg (".GIF$", "$file")) {
	
$downfile_array[]=$file;

$filetime=filemtime(BASEDIR."down/$downdir_array[$i]/$file")+(3600*24*3);
if($filetime>$sitetime){	
$downtime_array[]=$file;

}}} 
closedir ($dir);
}


$totalfile = count($downfile_array); 
$totalnewfile = count($downtime_array); 

if($totalnewfile>0){	
$dtext=(int)$totalfile.'|<a href="'.$config_home.'/down/new.php?'.SID.'"><font color="red">+'.(int)$totalnewfile; 
}else{
$dtext =(int)$totalfile;
}


$fp = fopen(BASEDIR."local/datatmp/down.dat","a+");
flock ($fp,LOCK_EX);
ftruncate($fp,0);
fputs($fp,$dtext);
fflush ($fp);
flock ($fp,LOCK_UN);
fclose($fp);
@chmod ($fp, 0777); 
@chmod (BASEDIR."local/datatmp/down.dat", 0777); 

}


$dinput = file_get_contents(BASEDIR."local/datatmp/down.dat"); 
echo ' ('.$dinput.'</font></a>)<br>';

?>