首先,先要确定你的服务器是否可以设置计划任务。
根据服务器的不同,或有或没有支持计划任务的,这里不多叙说。
如果不支持计划任务,却还要使用,你可以利用 PHP 或其他脚本进行,但并不推荐!
话不多说,附上代码。
<?php
// 文件编码
header("Content-Type: text/html; charset=utf-8");
// 设置时间地区 -> 上海
date_default_timezone_set("Asia/Shanghai");
// 引入文件
require_once dirname(__FILE__) . './config.inc.php';
$db = Typecho_Db::get();
// 获取用户信息
$getUserSql = $db -> select() -> from('table.users') -> limit(1);
$user = $db -> fetchRow($getUserSql);
// 浏览器 UA, 如果要显示来自微信, 更改为: "weChat"
$agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.80 Safari/537.36";
// 获取说说 cid
$getCrossSql = $db -> fetchAll($db -> select() -> from('table.contents') -> where('template = ?', 'cross.php'));
// 是否有创建 cross 模板的独立页
if(count($getCrossSql) > 0) {
$Source = json_decode(file_get_contents("http://open.iciba.com/dsapi"), 1);
// 内容
$content = "<img src=\"{$Source['picture2']}\"/>
- {$Source['content']}
- {$Source['note']}
[hplayer title=\"{$Source['caption']}\" author=\"{$Source['dateline']}\" url=\"{$Source['tts']}\" size=\"small\" auto=\"false\" /]";
$cid = $getCrossSql[0]['cid'];
// 添加记录
$insert = $db -> insert('table.comments') -> rows(array("cid" => $cid, "created" => time(), "author" => $user['screenName'], "authorId" => $user['uid'], "ownerId" => $user['uid'], "text"=> $content, "url" => $user['url'], "mail" => $user['mail'], "agent" => $agent));
$insertId = $db->query($insert);
// 修改新鲜事 + 1
$row = $db -> fetchRow($db -> select('commentsNum') -> from('table.contents') -> where('cid = ?', $cid));
$db -> query($db -> update('table.contents') -> rows(array('commentsNum' => (int) $row['commentsNum'] + 1)) -> where('cid = ?', $cid));
echo "success!";
} else {
echo "error!";
}
?>
将代码复制保存到文件名.php
中,上传至typecho
根目录,保证与文件config.inc.php
在同一目录中,通过url
访问即可。
例:https://你的域名/文件名.php
当然,你也可以修改内容,这里只是作为一个引子。
效果详见说说
Ps: 我设置的是 17:17 更新,请忽视。
Ps: 我设置的是 17:17 更新,请忽视。
我想要dnf GM工具的参数...
哪个工具, 参数不是都有么?
收藏下,希望能用到