本文最后更新于 1417 天前,其中的信息可能已经有所发展或是发生改变。
在研究了
$pages = $db->fetchAll($db->select()->from('table.contents')
->where('table.contents.status = ?', 'publish')
->where('table.contents.created < ?', $options->gmtTime)
->where('table.contents.type = ?', 'page')
->order('table.contents.created', Typecho_Db::SORT_DESC));
$articles = $db->fetchAll($db->select()->from('table.contents')
->where('table.contents.status = ?', 'publish')
->where('table.contents.created < ?', $options->gmtTime)
->where('table.contents.type = ?', 'post')
->order('table.contents.created', Typecho_Db::SORT_DESC));
foreach($pages AS $page) {
$type = $page['type'];
$routeExists = (NULL != Typecho_Router::get($type));
$page['pathinfo'] = $routeExists ? Typecho_Router::url($type, $page) : '#';
$page['permalink'] = Typecho_Common::url($page['pathinfo'], $options->index);
}
foreach($articles AS $article) {
$type = $article['type'];
$article['categories'] = $db->fetchAll($db->select()->from('table.metas')
->join('table.relationships', 'table.relationships.mid = table.metas.mid')
->where('table.relationships.cid = ?', $article['cid'])
->where('table.metas.type = ?', 'category')
->order('table.metas.order', Typecho_Db::SORT_ASC));
$article['category'] = urlencode(current(Typecho_Common::arrayFlatten($article['categories'], 'slug')));
$article['slug'] = urlencode($article['slug']);
$article['date'] = new Typecho_Date($article['created']);
$article['year'] = $article['date']->year;
$article['month'] = $article['date']->month;
$article['day'] = $article['date']->day;
$routeExists = (NULL != Typecho_Router::get($type));
$article['pathinfo'] = $routeExists ? Typecho_Router::url($type, $article) : '#';
$article['permalink'] = Typecho_Common::url($article['pathinfo'], $options->index);
}
和有后台页面mrasong的插件源码后
public static function config(Typecho_Widget_Helper_Form $form){
preg_match("/^(http(s)?:\/\/)?([^\/]+)/i", Helper::options()->siteUrl, $matches);
$domain = $matches[2] ? $matches[2] : '';
$site = new Typecho_Widget_Helper_Form_Element_Text('site', NULL, $domain, _t('站点域名'), _t('站长工具中添加的域名'));
$form->addInput($site->addRule('required', _t('请填写站点域名')));
$token = new Typecho_Widget_Helper_Form_Element_Text('token', NULL, '', _t('准入密钥'), _t('更新密钥后,请同步修改此处密钥,否则身份校验不通过将导致数据发送失败。'));
$form->addInput($token->addRule('required', _t('请填写准入密钥')));
}
思路已经初步形成
首先需要获取网站的站点地图
配置路由页面
将站点地图以表格的形式列出
在后面添加检测是否在百度的php
// public function action(){
// function baidu_record($a) {
// //$url='http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
// $url=$a;
// if(checkBaidu($url)==1) {
// echo "百度已收录";
// }
// else {
// echo "<a style=\"color:red;\" rel=\"external nofollow\" title=\"点击提交收录!\" target=\"_blank\" href=\"http://zhanzhang.baidu.com/sitesubmit/index?sitename=$url\">百度未收录</a>";
// }
// }
// function checkBaidu($url) {
// $url = 'http://www.baidu.com/s?wd=' . urlencode($url);
// $curl = curl_init();
// curl_setopt($curl, CURLOPT_URL, $url);
// curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
// $rs = curl_exec($curl);
// curl_close($curl);
// if (!strpos($rs, '没有找到')) { //没有找到说明已被百度收录
// return 1;
// } else {
// return -1;
// }
// }
但是发现这个可能会对服务器ip造成不好的影响,比如,如果不设置一些header,百度就会禁止你浏览,而返回一个验证链接。甚至会被列入黑名单!
https://wappass.baidu.com/static/captcha/tuxing.html
然后在每条链接后面设置提交按钮