mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-05 07:20:58 +08:00
paid torrent
This commit is contained in:
@@ -1045,74 +1045,74 @@ function docleanup($forceAll = 0, $printProgress = false) {
|
||||
}
|
||||
|
||||
//1.delete torrents that doesn't exist any more
|
||||
do {
|
||||
$res = sql_query("SELECT id FROM torrents") or sqlerr(__FILE__, __LINE__);
|
||||
$ar = array();
|
||||
while ($row = mysql_fetch_array($res)) {
|
||||
$id = $row[0];
|
||||
$ar[$id] = 1;
|
||||
}
|
||||
|
||||
if (!count($ar))
|
||||
break;
|
||||
|
||||
$dp = @opendir($torrent_dir);
|
||||
if (!$dp)
|
||||
break;
|
||||
|
||||
$ar2 = array();
|
||||
while (($file = readdir($dp)) !== false) {
|
||||
if (!preg_match('/^(\d+)\.torrent$/', $file, $m))
|
||||
continue;
|
||||
$id = $m[1];
|
||||
$ar2[$id] = 1;
|
||||
if (isset($ar[$id]) && $ar[$id])
|
||||
continue;
|
||||
$ff = $torrent_dir . "/$file";
|
||||
unlink($ff);
|
||||
}
|
||||
closedir($dp);
|
||||
|
||||
if (!count($ar2))
|
||||
break;
|
||||
|
||||
$delids = array();
|
||||
foreach (array_keys($ar) as $k) {
|
||||
if (isset($ar2[$k]) && $ar2[$k])
|
||||
continue;
|
||||
$delids[] = $k;
|
||||
unset($ar[$k]);
|
||||
}
|
||||
if (count($delids))
|
||||
sql_query("DELETE FROM torrents WHERE id IN (" . join(",", $delids) . ")") or sqlerr(__FILE__, __LINE__);
|
||||
|
||||
$res = sql_query("SELECT torrent FROM peers GROUP BY torrent") or sqlerr(__FILE__, __LINE__);
|
||||
$delids = array();
|
||||
while ($row = mysql_fetch_array($res)) {
|
||||
$id = $row[0];
|
||||
if (isset($ar[$id]) && $ar[$id])
|
||||
continue;
|
||||
$delids[] = $id;
|
||||
}
|
||||
if (count($delids))
|
||||
sql_query("DELETE FROM peers WHERE torrent IN (" . join(",", $delids) . ")") or sqlerr(__FILE__, __LINE__);
|
||||
|
||||
$res = sql_query("SELECT torrent FROM files GROUP BY torrent") or sqlerr(__FILE__, __LINE__);
|
||||
$delids = array();
|
||||
while ($row = mysql_fetch_array($res)) {
|
||||
$id = $row[0];
|
||||
if ($ar[$id])
|
||||
continue;
|
||||
$delids[] = $id;
|
||||
}
|
||||
if (count($delids))
|
||||
sql_query("DELETE FROM files WHERE torrent IN (" . join(",", $delids) . ")") or sqlerr(__FILE__, __LINE__);
|
||||
} while (0);
|
||||
$log = "delete torrents that doesn't exist any more";
|
||||
do_log($log);
|
||||
if ($printProgress) {
|
||||
printProgress($log);
|
||||
}
|
||||
// do {
|
||||
// $res = sql_query("SELECT id FROM torrents") or sqlerr(__FILE__, __LINE__);
|
||||
// $ar = array();
|
||||
// while ($row = mysql_fetch_array($res)) {
|
||||
// $id = $row[0];
|
||||
// $ar[$id] = 1;
|
||||
// }
|
||||
//
|
||||
// if (!count($ar))
|
||||
// break;
|
||||
//
|
||||
// $dp = @opendir($torrent_dir);
|
||||
// if (!$dp)
|
||||
// break;
|
||||
//
|
||||
// $ar2 = array();
|
||||
// while (($file = readdir($dp)) !== false) {
|
||||
// if (!preg_match('/^(\d+)\.torrent$/', $file, $m))
|
||||
// continue;
|
||||
// $id = $m[1];
|
||||
// $ar2[$id] = 1;
|
||||
// if (isset($ar[$id]) && $ar[$id])
|
||||
// continue;
|
||||
// $ff = $torrent_dir . "/$file";
|
||||
// unlink($ff);
|
||||
// }
|
||||
// closedir($dp);
|
||||
//
|
||||
// if (!count($ar2))
|
||||
// break;
|
||||
//
|
||||
// $delids = array();
|
||||
// foreach (array_keys($ar) as $k) {
|
||||
// if (isset($ar2[$k]) && $ar2[$k])
|
||||
// continue;
|
||||
// $delids[] = $k;
|
||||
// unset($ar[$k]);
|
||||
// }
|
||||
// if (count($delids))
|
||||
// sql_query("DELETE FROM torrents WHERE id IN (" . join(",", $delids) . ")") or sqlerr(__FILE__, __LINE__);
|
||||
//
|
||||
// $res = sql_query("SELECT torrent FROM peers GROUP BY torrent") or sqlerr(__FILE__, __LINE__);
|
||||
// $delids = array();
|
||||
// while ($row = mysql_fetch_array($res)) {
|
||||
// $id = $row[0];
|
||||
// if (isset($ar[$id]) && $ar[$id])
|
||||
// continue;
|
||||
// $delids[] = $id;
|
||||
// }
|
||||
// if (count($delids))
|
||||
// sql_query("DELETE FROM peers WHERE torrent IN (" . join(",", $delids) . ")") or sqlerr(__FILE__, __LINE__);
|
||||
//
|
||||
// $res = sql_query("SELECT torrent FROM files GROUP BY torrent") or sqlerr(__FILE__, __LINE__);
|
||||
// $delids = array();
|
||||
// while ($row = mysql_fetch_array($res)) {
|
||||
// $id = $row[0];
|
||||
// if ($ar[$id])
|
||||
// continue;
|
||||
// $delids[] = $id;
|
||||
// }
|
||||
// if (count($delids))
|
||||
// sql_query("DELETE FROM files WHERE torrent IN (" . join(",", $delids) . ")") or sqlerr(__FILE__, __LINE__);
|
||||
// } while (0);
|
||||
// $log = "delete torrents that doesn't exist any more";
|
||||
// do_log($log);
|
||||
// if ($printProgress) {
|
||||
// printProgress($log);
|
||||
// }
|
||||
|
||||
//8.lock topics where last post was made more than x days ago
|
||||
$secs = 365*24*60*60;
|
||||
|
||||
Reference in New Issue
Block a user