📄 crondelete.php
字号:
<?
/*
+--------------------------------------------------------------------------
| Mega File Hosting Script v1.1
| ========================================
| by Stephen Yabziz
| (c) 2005-2006 YABSoft Services
| http://www.yabsoft.com
| ========================================
| Web: http://www.yabsoft.com
| Email: ywyhnchina@163.com
+--------------------------------------------------------------------------
|
| > Script written by Stephen Yabziz
| > Date started: 1th March 2006
+--------------------------------------------------------------------------
*/
include "../includes/inc.php";
###########################################################
# Crontab id
###########################################################
$cron_id = is_numeric($input[cron_id]) ? $input[cron_id] : 3;
###########################################################
# Crontab code begin
###########################################################
if(function_exists('register_shutdown_function'))
register_shutdown_function('shutdown_update_db');
/*
* loading groups
*/
$db->setQuery("select * from groups where 1");
$db->query();
$groups=$db->loadRowList();
$files=array();
/*
* loading deleted files
*/
foreach($groups as $group)
{
$minviews = $group[cron_views];
$deldate = time()-$group[cron_days]*24*60*60;
$gid = intval($group[id]);
if($group[cron_enabled]==1)
{
$group_cron = "
(f.downloads<=$minviews
AND (f.lastdownload<$deldate
OR (f.time<$deldate AND f.lastdownload is NULL)
)
AND (u.gid='$gid' or f.uid=0)
)
";
}
else
{
$group_cron = 0;
}
$db->setQuery("select f.id,f.file,s.domain,s.upload_dir from files as f
left join server as s on s.server_id=f.server_id
left join users as u on u.id=f.uid
where f.deleted=1 and f.server_id='$server_id'
OR
$group_cron
limit 100
");
$db->query();
$newfiles=$db->loadRowList('id' );
$files=array_merge($files,$newfiles);
}
$files = array_unique($files);
/**
* delete files
*/
$ids=array();
foreach($files as $file)
{
$filename=valid_file($file[file]);
@unlink((substr($file[upload_dir],0,1)=='/'?'':'../').$file[upload_dir].'/'.$filename);
$ids[]=$file[id];
}
if(!function_exists('register_shutdown_function'))
shutdown_update_db();
/**
* update the server's stats
*/
function shutdown_update_db()
{
global $db,$ids,$cron_id,$server_id;
$whereids = implode(',',$ids);
if(!$whereids)
{
echo 'No files are deleted!';
return '';
}
$db->setQuery("delete from files where id in ($whereids)");
$db->query();
$db->setQuery("select server_id,count(id) as hosted,sum(size) as webspace from files where server_id='$server_id' and deleted=0 group by server_id");
$db->query();
$row=$db->loadRow();
$db->setQuery("update server set hosted='$row[hosted]',webspace='$row[webspace]' where server_id='$row[server_id]' ");
$db->query();
###########################################################
# Record crontab result
###########################################################
$results = 'Server ID '.$server_id.':'.count($ids).' files are deleted!';
CrontabLog($cron_id,$results);
unset($ids);
exit;
}
?>
DONE!
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -