<?php // $res = exec('ps xa | grep "downloads_check.php" | grep -v grep | wc -l'); // if ($res > 1) exit; if (preg_match("/(.*)downloads_check.php\$/", $_SERVER['SCRIPT_FILENAME'], $m)) { @chdir($m[1]); } require "../adei.php"; $lock = new LOCK("downloads_check"); $lock->Lock(LOCK::BLOCK); global $ADEI; global $ADEI_ROOTDIR; $ADEI->RequireClass("download"); $cache = new CACHEDB(); $dm = new DOWNLOADMANAGER(); $res = $cache->GetDownloads("", "ASC"); while ($row = mysql_fetch_array($res)) { $download = $row['dl_id']; $status = $row['status']; $name = $dm->Getfilename($download); $file = $ADEI_ROOTDIR . "tmp/downloads/" . $name; if (file_exists($file)) { $fsize = filesize($file); $lastmodified = time() - filemtime($file); } else { $fsize = 0; $lastmodified = 0; } if ($fsize > 1 && $lastmodified > 1 && $status != 'Ready') { // We should check if it's really complete (I think - not), and remove failed downloads // We also should check that it is not in progress (old mtime?)
<?php if (preg_match("/(.*)downloads_clean.php\$/", $_SERVER['SCRIPT_FILENAME'], $m)) { @chdir($m[1]); } require "../adei.php"; global $ADEI; global $TMP_PATH; global $DOWNLOAD_DECAY_TIME; $ADEI->RequireClass("download"); $dm = new DOWNLOADMANAGER(); //$dm->Logit("Clearing old downloads\n"); $dir = opendir("{$TMP_PATH}/downloads"); while ($file = readdir($dir)) { $fullname = "{$TMP_PATH}/downloads/{$file}"; if (filetype($fullname) == "dir") { continue; } if (time() - fileatime($fullname) > $DOWNLOAD_DECAY_TIME) { $dotind = strrpos($file, '_'); $download = substr($file, $dotind + 1, 32); $res = $dm->cache->GetDownloads($download); if ($res) { $row = mysql_fetch_assoc($res); if ($row["auto_delete"] == "true") { $dm->RemoveDownload($download, true); } } else { echo "Removing rogue file: {$file}\n"; unlink($file); }
<?php header("Content-type: text/xml"); header("Cache-Control: no-cache, must-revalidate"); header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); global $ADEI; $ADEI->RequireClass("download"); try { $target = $_GET["target"]; $dm = new DOWNLOADMANAGER(); switch ($target) { case "dlmanager_add": $dm->AddDownload(); break; case "dlmanager_remove": $dm->RemoveDownload(); break; case "dlmanager_list": CreateDownloadXml($dm->GetDownloads(), $target); break; case "dlmanager_run": $dm->DlManagerRun(); break; case "dlmanager_sort": $dm->SortBy(); break; case "dlmanager_details": CreateDownloadXml($dm->GetDownloadDetails(), $target); break; case "dlmanager_download": $dm->GetFile();