婷姐 发表于 2025-1-4 19:32:50

帝国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_checkorder 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'");            $fen=$cr['addinfofen'];            $sql=$empire->query("update {$dbtbpre}enewsmember set userfen=userfen+$fen where userid='$article'");      } 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, '暂无待审核数据');}}

拾光 发表于 2025-1-4 19:33:50

有点高产啊

独家记忆 发表于 2025-1-4 19:34:10

如果需要效率更高,采用多进程异步最好。前提还是得安装workerman。安装了也可以不用宝塔的计划任务了,因为workerman提供了两种定时器。

Crystαl 发表于 2025-1-4 19:34:45

***内容可能违规暂时被隐藏***

TyCoding 发表于 2025-1-4 19:35:24

内容可能违规暂时被隐藏
除了缓存外可以多看看workerman的吗?能给任意CMS与框架加速的!新版的5.0更强大了,支持Fiber协程,支持Swoole协程,支持Swow协程

Crystαl 发表于 2025-1-4 19:35:57

***内容可能违规暂时被隐藏***

IT618发布 发表于 2025-1-4 19:36:35

信息收藏成功

TyCoding 发表于 2025-1-4 19:37:04

这个实用啊,小本本记上了。

独家记忆 发表于 2025-1-4 19:37:57

厉害厉害

婷姐 发表于 2025-1-4 19:38:42

这家伙是把网站卖掉了,无站一身轻啊
页: [1] 2
查看完整版本: 帝国CMS借助宝塔计划任务定时审核文章