1 Star 3 Fork 0

sking / thugui

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
functions.php 2.50 KB
一键复制 编辑 原始数据 按行查看 历史
sking 提交于 2019-05-02 20:19 . thug响应式主题
<?php
if (!defined('__TYPECHO_ROOT_DIR__')) exit;
/* 后台设置 */
function themeConfig($form) {
//站点logo地址
$logoUrl = new Typecho_Widget_Helper_Form_Element_Text('logoUrl', NULL, NULL, _t('站点LOGO地址'), _t('在这里填入一个图片URL地址, 以在网站标题前加上一个LOGO'));
$form->addInput($logoUrl->addRule('xssCheck', _t('请不要在图片链接中使用特殊字符')));
//首页博客的介绍
$blogMesg = new Typecho_Widget_Helper_Form_Element_Text('blogMesg', NULL, NULL, _t('首页博客的介绍'), _t('在这里填入首页博客的介绍, 以在网站首页显示'));
$form->addInput($blogMesg->addRule('xssCheck', _t('请不要在图片链接中使用特殊字符')));
//侧边栏
$sidebarBlock = new Typecho_Widget_Helper_Form_Element_Checkbox('sidebarBlock',
array(
'ShowBlogmiao' => _t('站点描述'),
'ShowCategory' => _t('文章分类'),
'ShowRecentPosts' => _t('最新文章'),
'ShowRecentComments' => _t('最新评论'),
'ShowAdmin' => _t('系统设置')),
array('ShowBlogmiao', 'ShowCategory', 'ShowRecentPosts', 'ShowAdmin'), _t('侧边栏显示'));
$form->addInput($sidebarBlock->multiMode());
//统计代码
$GoogleAnalytics = new Typecho_Widget_Helper_Form_Element_Textarea('GoogleAnalytics', NULL, NULL, _t('统计代码'), _t('填写你的各种跟踪统计代码,相当于页尾代码'));
$form->addInput($GoogleAnalytics);
}
/*文章阅读次数统计*/
function get_post_view($archive) {
$cid = $archive->cid;
$db = Typecho_Db::get();
$prefix = $db->getPrefix();
if (!array_key_exists('views', $db->fetchRow($db->select()->from('table.contents')))) {
$db->query('ALTER TABLE `' . $prefix . 'contents` ADD `views` INT(10) DEFAULT 0;');
echo 0;
return;
}
$row = $db->fetchRow($db->select('views')->from('table.contents')->where('cid = ?', $cid));
if ($archive->is('single')) {
$views = Typecho_Cookie::get('extend_contents_views');
if (empty($views)) {
$views = array();
} else {
$views = explode(',', $views);
}
if (!in_array($cid, $views)) {
$db->query($db->update('table.contents')->rows(array('views' => (int)$row['views'] + 1))->where('cid = ?', $cid));
array_push($views, $cid);
$views = implode(',', $views);
Typecho_Cookie::set('extend_contents_views', $views); //记录查看cookie
}
}
echo $row['views'];
}
PHP
1
https://gitee.com/hkq15/thugui.git
git@gitee.com:hkq15/thugui.git
hkq15
thugui
thugui
master

搜索帮助