ppypp伦理天堂,91手机在线视频,免费在线观看黄色毛片,夜夜穞天天穞狠狠穞AV美女按摩

聯(lián)系官方銷售客服

1835022288

028-61286886

投訴 解決中 / 官方已回 文件原始地址新建地址在文件中添加新方法用于定時(shí)發(fā)布文章代碼邏 2 0
迅睿CMS版本:4.0.1 #文章
PHP程序里面


PHP文件:dayrui\Core\Controllers\Api\Run.php

原始URL地址:/index.php?s=api&c=run

新建URL地址:/index.php?s=api&c=run&m=time_post

在Run.php文件中添加新方法time_post,用于定時(shí)發(fā)布文章,代碼邏輯是抽取index方法的發(fā)布文章邏輯

public function time_post() {

// 未到時(shí)間
if (\Phpcmf\Service::L('input')->get_cookie('cron')) {
exit('未到發(fā)布文章時(shí)間');
}

foreach ($this->site_info as $siteid => $site) {
// 刪除網(wǎng)站首頁(yè)
if ($site['SITE_INDEX_HTML']) {
@unlink(\Phpcmf\Service::L('html')->get_webpath($siteid,'site', 'index.html'));
@unlink(\Phpcmf\Service::L('html')->get_webpath($siteid,'site', 'mobile/index.html'));
}
// 模塊
$module = \Phpcmf\Service::L('cache')->get('module-'.$siteid.'-content');
if ($module) {
foreach ($module as $dir => $mod) {
// 刪除模塊首頁(yè)
if ($mod['is_index_html']) {
if ($mod['domain']) {
// 綁定域名時(shí)
$file = 'index.html';
} else {
$file = ltrim(\Phpcmf\Service::L('Router')->remove_domain(MODULE_URL), '/'); // 從地址中獲取要生成的文件名;
}
if ($file) {
@unlink(\Phpcmf\Service::L('html')->get_webpath($siteid, $dir, $file));
@unlink(\Phpcmf\Service::L('html')->get_webpath($siteid, $dir, 'mobile/'.$file));
}
}
// 定時(shí)發(fā)布動(dòng)作
$db = \Phpcmf\Service::M('Content', $dir);
$db->_init($dir, $siteid);
$this->module = \Phpcmf\Service::L('cache')->get('module-'.$siteid.'-'.$dir);
$times = $db->table($siteid.'_'.$dir.'_time')->where('posttime < '.SYS_TIME)->getAll();
if ($times) {
foreach ($times as $t) {
$rt = $db->post_time($t);
if (!$rt['code']) {
log_message('error', '定時(shí)發(fā)布('.$t['id'].')失敗:'.$rt['msg']);
}
}
}

}
}

}

exit('Run time_post');
}

index方法注釋了原來(lái)發(fā)布文章的邏輯

public function index() {

// 未到時(shí)間
if (\Phpcmf\Service::L('input')->get_cookie('cron')) {
exit('未到執(zhí)行時(shí)間');
}

// 批量執(zhí)行站點(diǎn)動(dòng)作
// foreach ($this->site_info as $siteid => $site) {
// // 刪除網(wǎng)站首頁(yè)
// if ($site['SITE_INDEX_HTML']) {
// @unlink(\Phpcmf\Service::L('html')->get_webpath($siteid,'site', 'index.html'));
// @unlink(\Phpcmf\Service::L('html')->get_webpath($siteid,'site', 'mobile/index.html'));
// }
// // 模塊
// $module = \Phpcmf\Service::L('cache')->get('module-'.$siteid.'-content');
// if ($module) {
// foreach ($module as $dir => $mod) {
// // 刪除模塊首頁(yè)
// if ($mod['is_index_html']) {
// if ($mod['domain']) {
// // 綁定域名時(shí)
// $file = 'index.html';
// } else {
// $file = ltrim(\Phpcmf\Service::L('Router')->remove_domain(MODULE_URL), '/'); // 從地址中獲取要生成的文件名;
// }
// if ($file) {
// @unlink(\Phpcmf\Service::L('html')->get_webpath($siteid, $dir, $file));
// @unlink(\Phpcmf\Service::L('html')->get_webpath($siteid, $dir, 'mobile/'.$file));
// }
// }
// // 定時(shí)發(fā)布動(dòng)作
// $db = \Phpcmf\Service::M('Content', $dir);
// $db->_init($dir, $siteid);
// $this->module = \Phpcmf\Service::L('cache')->get('module-'.$siteid.'-'.$dir);
// $times = $db->table($siteid.'_'.$dir.'_time')->where('posttime < '.SYS_TIME)->getAll();
// if ($times) {
// foreach ($times as $t) {
// $rt = $db->post_time($t);
// if (!$rt['code']) {
// log_message('error', '定時(shí)發(fā)布('.$t['id'].')失敗:'.$rt['msg']);
// }
// }
// }
//
// }
// }
//
// }

// 執(zhí)行隊(duì)列
$i = \Phpcmf\Service::M('cron')->run_cron();

// 3天未付款的清理
\Phpcmf\Service::M('pay')->clear_paylog();

// 100秒調(diào)用本程序
\Phpcmf\Service::L('input')->set_cookie('cron', 1, 100);

// 任務(wù)計(jì)劃
\Phpcmf\Hooks::trigger('cron');

// 項(xiàng)目計(jì)劃
if (is_file(MYPATH.'Config/Cron.php')) {
require MYPATH.'Config/Cron.php';
}

// 為插件單獨(dú)執(zhí)行計(jì)劃
$local = dr_dir_map(dr_get_app_list(), 1);
if ($local) {
foreach ($local as $dir) {
$path = dr_get_app_dir($dir);
if (is_file($path.'Config/Cron.php')
&& is_file($path.'Config/App.php')) {
require $path.'Config/Cron.php';
}
}
}


exit('Run '.$i);

}

但是執(zhí)行/index.php?s=api&c=run&m=time_post時(shí),未到發(fā)布時(shí)間,文章就發(fā)布出去了,而且是重復(fù)的兩篇文章

希望管理員幫忙看看是什么原因,十分感謝!

解決方案
  • 這個(gè)文件不能擅自修改,新建App文件吧

    • 回復(fù)迅睿框架創(chuàng)始人 主要是代碼路由和代碼邏輯都沒(méi)問(wèn)題,雖然不符合開(kāi)發(fā)手冊(cè)規(guī)范,但是為什么會(huì)有這種問(wèn)題出現(xiàn)的?