// Use exaple: *******/ //$url="download/file1.zip"; //DEBUG $url=strtolower($_GET['url']); //NODEBUG $nfile = "dlcnt.txt"; // ful path to file count $now = gmDate("Y.m.d H:i:s"); $newline = TRUE; if (!file_exists($nfile)) { $fp=MYfopen($nfile,"w"); fwrite ($fp,"",0); @chmod($fp, 0664); MYfclose($fp, $nfile); } if (file_exists($nfile)) { $afile = MYfile($nfile); //load file for($j = 0; $j < count($afile); $j++) { //scan array $ln = explode("|", $afile[$j]); //str-->arr if(!strcmp(trim($ln[0]),$url) && $ln[1]==gmDate("m") ) { //find line $ln[3]=$now; //last $ln[35]++; //count for month $ln[gmDate("d")+3]++; //count for day $afile[$j] = implode($ln,"|"); //arr-->str $fp = MYfopen($nfile,"w"); // if(flock($fp,LOCK_EX)) { for($j = 0; $j < count($afile); $j++) fputs($fp, $afile[$j]); //write file fflush($fp); // flock($fp,LOCK_UN); // } MYfclose($fp, $nfile); $newline = FALSE; } } if($newline == TRUE) { // url | month |first|last|cntmonth cntdays $ln = array(str_pad($url,32),gmDate("m"),$now,$now,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,001,"."); $ln[gmDate("d")+3]++; //count for day $ln=implode($ln,"|")."\n"; //arr-->str $fp = MYfopen($nfile,"a"); //for append line // if(flock($fp,LOCK_EX)) { fputs($fp,$ln,256); fflush($fp); flock($fp,LOCK_UN); // } MYfclose($fp, $nfile); } } // echo "------- $url
"; //DEBUG header("Location: $url"); //NODEBUG ?>