帝国CMS借助宝塔计划任务定时审核文章
帝国CMS借助宝塔计划任务定时审核文章,代码如下:
- <?phpdefined('ECMSAPI_MOD') or exit;$fun = $api->load('fun');$enews=RepPostVar($_POST['enews']);if($enews=="audittiming"){//定时审核$notcheck = $api->load('db')->query('select id,newstime from [!db.pre!]ecms_article_check order by newstime asc');$currtime = time(); // 获取当前时间戳$check = [];if ($notcheck) { foreach ($notcheck as $i => $v) { if ($v['newstime'] < $currtime) { $check[$i]['ischecked'] = 1; $check[$i]['id'] = $v['id']; $check[$i]['newstime'] = date('Y-m-d H:i:s', $v['newstime']); if (!function_exists('GetHtml')) { require_once (ECMS_PATH . '/e/class/t_functions.php'); require (ECMS_PATH . '/e/class/functions.php'); } $api->load('table')->setChecked('article', $v['id'], 1); $article = $api->load('table')->get('article', $v['id']); GetHtml($article['classid'], $article['id'], $article, 1, 0); $cr=$empire->fetch1("select classid,addinfofen from {$dbtbpre}enewsclass where classid='$article[classid]'"); $fen=$cr['addinfofen']; $sql=$empire->query("update {$dbtbpre}enewsmember set userfen=userfen+$fen where userid='$article[userid]'"); } else { $check[$i]['ischecked'] = 0; $check[$i]['id'] = $v['id']; $check[$i]['newstime'] = date('Y-m-d H:i:s', $v['newstime']); } } $fun->json(1, $check, '操作成功');} else { $fun->json(0, '暂无待审核数据');}}