3 * PIO Condition Object
\r
5 * 判斷文章是否符合刪除條件並列出刪除編號
\r
7 * @package PMCLibrary
\r
8 * @version $Id: lib_pio.cond.php 578 2008-01-13 03:51:18Z roytam1 $
\r
9 * @date $Date: 2008-01-13 11:51:18 +0800 (星期日, 13 一月 2008) $
\r
13 class ByPostCountCondition{
\r
14 /*public static */function check($type, $limit){
\r
16 return $PIO->postCount() >= $limit * ($type=='predict' ? 0.95 : 1);
\r
19 /*public static */function listee($type, $limit){
\r
21 return $PIO->fetchPostList(0, intval($limit * ($type=='predict' ? 0.95 : 1)) - 1, $limit);
\r
24 /*public static */function info($limit){
\r
26 return "ByPostCountCondition: ".($pcnt=$PIO->postCount()).'/'.$limit.sprintf(' (%.2f%%)',($pcnt/$limit*100));
\r
31 class ByThreadCountCondition{
\r
32 /*public static */function check($type, $limit){
\r
34 return $PIO->threadCount() >= ($type=='predict' ? $limit * 0.95 : 1);
\r
37 /*public static */function listee($type, $limit){
\r
39 return $PIO->fetchThreadList(intval($limit * ($type=='predict' ? 0.95 : 1)), $limit);
\r
42 /*public static */function info($limit){
\r
44 return "ByThreadCountCondition: ".($tcnt=$PIO->threadCount()).'/'.$limit.sprintf(' (%.2f%%)',($tcnt/$limit*100));
\r
48 /* 以討論串生存時間作為刪除判斷 */
\r
49 class ByThreadAliveTimeCondition{
\r
50 /*public static */function check($type, $limit){
\r
52 $oldestThreadNo = $PIO->fetchThreadList($PIO->threadCount() - 1, 1, true); // 最舊討論串編號
\r
53 $oldestThread = $PIO->fetchPosts($oldestThreadNo);
\r
54 return (time() - substr($oldestThread[0]['tim'], 0, 10) >= 86400 * $limit * ($type=='predict' ? 0.95 : 1));
\r
57 /*public static */function listee($type, $limit){
\r
59 $ThreadNo = $PIO->fetchThreadList(0, 0, true); sort($ThreadNo); // 討論串編號陣列 (由舊到新)
\r
62 foreach($ThreadNo as $t){
\r
63 $post = $PIO->fetchPosts($t);
\r
64 if($NowTime - substr($post[0]['tim'], 0, 10) < 86400 * $limit * ($type=='predict' ? 0.95 : 1)) break; // 時間不符合
\r
67 if(count($ThreadNo)===$i){ $i--; } // 保留最新的一篇避免全部刪除
\r
68 return array_slice($ThreadNo, 0, $i);
\r
71 /*public static */function info($limit){
\r
72 return "ByThreadAliveTimeCondition: ".$limit.' day(s)';
\r