标签:extra rip array ssi 时间 empty 用户 yesterday div
将以下代码放到 api/count.php 文件最后 的 ?>之前
//add 定时发布审核功能 $modelid = $modelid ? $modelid : intval($_GET[‘modelid‘]); $content_db = $content_db ? $content_db : pc_base::load_model(‘content_model‘); $content_db->set_model($modelid); $where = ‘ status = 1 and inputtime <= ‘.SYS_TIME; $r = $content_db->count($where); if( !empty($r) ){ //执行update操作 $content_db->update( array(‘status‘=>99),$where ); }
这样就行了.
然后记得修改文字发布需要审核才能通过,不然发出去直接就通过了.
另外就是发布时间要设置为未来的时间,这样才能定时.
不是严格意义上的定时发布,当有用户访问你的内容页时,触发了内容页的
<script language="JavaScript" src="{APP_PATH}api.php?op=count&id={$id}&modelid={$modelid}"></script>
js,就会执行上面的通过审核代码.
注意,仅适用于伪静态.生成静态的需要额外的静态化操作.可跟帖说明是否需要,需求大可以提供代码.
静态方法:
//add 定时发布审核功能 $urlobj = pc_base::load_app_class(‘url‘, ‘content‘); $html = pc_base::load_app_class(‘html‘, ‘content‘); $modelid = $modelid ? $modelid : intval($_GET[‘modelid‘]); $content_db = $content_db ? $content_db : pc_base::load_model(‘content_model‘); $content_db->set_model($modelid); $where = ‘ status = 1 and inputtime <= ‘.SYS_TIME; $r = $content_db->count($where); if( !empty($r) ){ //执行update操作 $ids = $content_db->select($where, ‘id,catid‘, $r, ‘‘, ‘‘, ‘id‘); foreach($ids AS $kid=>$v){ $catid = $v[‘catid‘]; $id = $kid; $r = $content_db->get_content($catid,$id); $urls = $urlobj->show($id, 0, $catid, $r[‘inputtime‘], $r[‘prefix‘],$r,‘add‘); if($urls[‘content_ishtml‘]) $html->show($urls[1],$urls[‘data‘],0); $html->index(); $html->create_relation_html($catid); } $content_db->update( array(‘status‘=>99),$where ); }
修改过的count.php文件已经提供:
<?php defined(‘IN_PHPCMS‘) or exit(‘No permission resources.‘); /** * 点击统计 */ $db = ‘‘; $db = pc_base::load_model(‘hits_model‘); if($_GET[‘modelid‘] && $_GET[‘id‘]) { $model_arr = array(); $model_arr = getcache(‘model‘,‘commons‘); $modelid = intval($_GET[‘modelid‘]); $hitsid = ‘c-‘.$modelid.‘-‘.intval($_GET[‘id‘]); $r = get_count($hitsid); if(!$r) exit; extract($r); hits($hitsid); echo "\$(‘#todaydowns‘).html(‘$dayviews‘);"; echo "\$(‘#weekdowns‘).html(‘$weekviews‘);"; echo "\$(‘#monthdowns‘).html(‘$monthviews‘);"; } elseif($_GET[‘module‘] && $_GET[‘id‘]) { $module = $_GET[‘module‘]; if((preg_match(‘/([^a-z0-9_\-]+)/i‘,$module))) exit(‘1‘); $hitsid = $module.‘-‘.intval($_GET[‘id‘]); $r = get_count($hitsid); if(!$r) exit; extract($r); hits($hitsid); } /** * 获取点击数量 * @param $hitsid */ function get_count($hitsid) { global $db; $r = $db->get_one(array(‘hitsid‘=>$hitsid)); if(!$r) return false; return $r; } /** * 点击次数统计 * @param $contentid */ function hits($hitsid) { global $db; $r = $db->get_one(array(‘hitsid‘=>$hitsid)); if(!$r) return false; $views = $r[‘views‘] + 1; $yesterdayviews = (date(‘Ymd‘, $r[‘updatetime‘]) == date(‘Ymd‘, strtotime(‘-1 day‘))) ? $r[‘dayviews‘] : $r[‘yesterdayviews‘]; $dayviews = (date(‘Ymd‘, $r[‘updatetime‘]) == date(‘Ymd‘, SYS_TIME)) ? ($r[‘dayviews‘] + 1) : 1; $weekviews = (date(‘YW‘, $r[‘updatetime‘]) == date(‘YW‘, SYS_TIME)) ? ($r[‘weekviews‘] + 1) : 1; $monthviews = (date(‘Ym‘, $r[‘updatetime‘]) == date(‘Ym‘, SYS_TIME)) ? ($r[‘monthviews‘] + 1) : 1; $sql = array(‘views‘=>$views,‘yesterdayviews‘=>$yesterdayviews,‘dayviews‘=>$dayviews,‘weekviews‘=>$weekviews,‘monthviews‘=>$monthviews,‘updatetime‘=>SYS_TIME); return $db->update($sql, array(‘hitsid‘=>$hitsid)); } //add 定时发布审核功能 $urlobj = pc_base::load_app_class(‘url‘, ‘content‘); $html = pc_base::load_app_class(‘html‘, ‘content‘); $modelid = $modelid ? $modelid : intval($_GET[‘modelid‘]); $content_db = $content_db ? $content_db : pc_base::load_model(‘content_model‘); $content_db->set_model($modelid); $where = ‘ status = 1 and inputtime <= ‘.SYS_TIME; $r = $content_db->count($where); if( !empty($r) ){ //执行update操作 $ids = $content_db->select($where, ‘id,catid‘, $r, ‘‘, ‘‘, ‘id‘); foreach($ids AS $kid=>$v){ $catid = $v[‘catid‘]; $id = $kid; $r = $content_db->get_content($catid,$id); $urls = $urlobj->show($id, 0, $catid, $r[‘inputtime‘], $r[‘prefix‘],$r,‘add‘); if($urls[‘content_ishtml‘]) $html->show($urls[1],$urls[‘data‘],0); $html->index(); $html->create_relation_html($catid); } $content_db->update( array(‘status‘=>99),$where ); } ?> $(‘#hits‘).html(‘<?php echo $views?>‘);
注意:生成静态的网站请看14楼代码或者上面的附件, 需要访问了待定时发布的文章所在模型的任意一篇可正常浏览的文章即可,主要是为了触发上面的js,搜索引擎访问的无效,必须是人为访问,js能得以执行.
标签:extra rip array ssi 时间 empty 用户 yesterday div
原文地址:http://www.cnblogs.com/xiaomifeng/p/7993294.html