phpop3clean.emptycache.php
来自「一个基于页面实现的pop客户端程序」· PHP 代码 · 共 94 行
PHP
94 行
<?php//////////////////////////////////////////////////////////////////// phPOP3clean() by James Heinrich <info@silisoftware.com> //// available at http://phpop3clean.sourceforge.net ///////////////////////////////////////////////////////////////////require_once(dirname(__FILE__).'/phPOP3clean.config.php');require_once(dirname(__FILE__).'/phPOP3clean.login.php');if (!IsAdminUser()) { echo 'You do not have permission to use this file'; exit;}$yearmonth = (ereg('^[0-9]{6}$', @$_GET['go']) ? $_GET['go'] : '');$totalfiles = 0;$filecounter = 0;$tarcounter = -1;$filesintar = 1000;$starttime = time();if ($yearmonth && is_dir(PHPOP3CLEAN_QUARANTINE.$yearmonth.'/')) { if ($dh = opendir(PHPOP3CLEAN_QUARANTINE.$yearmonth.'/')) { while (($file = readdir($dh)) !== false) { if (is_file(PHPOP3CLEAN_QUARANTINE.$yearmonth.'/'.$file)) { $totalfiles++; } } rewinddir($dh); echo '<hr>0 / '.number_format($totalfiles).' [0.0% done]<hr>'; while (($file = readdir($dh)) !== false) { if (is_file(PHPOP3CLEAN_QUARANTINE.$yearmonth.'/'.$file)) { if (($filecounter % $filesintar) === 0) { set_time_limit(300); $pct_done = (($tarcounter * $filesintar) + $filecounter) / $totalfiles; if ($pct_done > 0) { $timeleft = (1 - $pct_done) * ((time() - $starttime) / $pct_done); } $tarcounter++; $filecounter = 0; $command = 'cd "'.PHPOP3CLEAN_QUARANTINE.'" && tar -cf "'.$yearmonth.'_'.$tarcounter.'.tar" "'.$yearmonth.'/'.$file.'"'; echo '<hr>'; echo number_format(($tarcounter * $filesintar) + $filecounter).' / '.number_format($totalfiles); echo (($pct_done > 0) ? ' ['.number_format($pct_done * 100, 1).'% done]' : ''); echo (isset($timeleft) ? ' ('.number_format($timeleft / 60, 1).' minutes remaining)' : ''); echo '<br>'.$command.'<hr>'; } else { $command = 'cd "'.PHPOP3CLEAN_QUARANTINE.'" && tar -rf "'.$yearmonth.'_'.$tarcounter.'.tar" "'.$yearmonth.'/'.$file.'"'; echo '. '; } $filecounter++; echo `$command`; flush(); } } for ($i = 0; $i <= $tarcounter; $i++) { chmod(PHPOP3CLEAN_QUARANTINE.$yearmonth.'_'.$i.'.tar', 0666); } closedir($dh); } $deleCommand = 'rm -dvrf "'.PHPOP3CLEAN_QUARANTINE.$yearmonth.'"'; $deleteCommandOutput = `$deleCommand`; echo '<hr><b>'.$deleCommand.'</b><hr>'; echo '<textarea rows="10" cols="100" wrap="off">'.htmlentities($deleteCommandOutput).'</textarea><hr>'; echo 'Processed '.number_format(($tarcounter * $filesintar) + $filecounter).' files in '.number_format((time() - $starttime) / 60, 2).' minutes<hr>';} elseif (@$_GET['go']) { echo '!isdir('.PHPOP3CLEAN_QUARANTINE.$yearmonth.'/'.')<br>';} else { if ($dh = @opendir(PHPOP3CLEAN_QUARANTINE)) { $thisyearmonth = date('Ym'); $SubDirsLinks = ''; while ($subdir = readdir($dh)) { if (is_dir(PHPOP3CLEAN_QUARANTINE.$subdir) && ereg('^[0-9]{6}$', $subdir)) { $SubDirsLinks .= '<li>'.PHPOP3CLEAN_QUARANTINE.$subdir.' -- click here to proceed: <a href="'.$_SERVER['PHP_SELF'].'?go='.$subdir.'">do it</a></li>'; } } closedir($dh); if ($SubDirsLinks) { echo 'TAR up all the files in:<ul>'.$SubDirsLinks.'</ul>'; } else { echo 'There are no previous-month archived data directories available. If there were, this demo would TAR them all up (in batches of 1000) and remove the files and directories, to allow you to archive them offsite if you want, and generally just free up server disk space.'; } } else { echo 'ERROR: Could not opendir("'.PHPOP3CLEAN_QUARANTINE.'")<br>'; }}?>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?