迅睿CMS框架是一款PHP8高性能·簡單易用的CMS開源開發(fā)框架,基于MIT開源許可協(xié)議發(fā)布,免費且不限制商業(yè)使用,是免費開源的產(chǎn)品,以萬端互聯(lián)為設(shè)計理念,支持的微信公眾號、小程序、APP客戶端、移動端網(wǎng)站、PC網(wǎng)站等多終端式管理系統(tǒng)。
聯(lián)系官方銷售客服
1835022288
028-61286886
頁面默認的閱讀數(shù),是根據(jù)ip來判斷的,一個ip只能計算一次,請問怎么把這個限制取消?就是不限制ip增加閱讀計數(shù)。
不能取消限制,但是你可以把控制器復制出來,重新做一個統(tǒng)計方法的js
要想不改主程序只能復制出來改api控制器類文件
回復@sk360c 如果這樣改的話,怎么收費?
5元賞金,我按一樓思路給你改,不影響升級
回復@靠懸賞(設(shè)置懸賞)賺錢買授權(quán) 可以,需要我重新發(fā)個懸賞(設(shè)置懸賞)貼嗎?
追加懸賞(設(shè)置懸賞)金額
回復@靠懸賞(設(shè)置懸賞)賺錢買授權(quán) 你做好了我再加,還是我現(xiàn)在加懸賞(設(shè)置懸賞)?
1、config/custom.php
function dr_show_hits($id, $dom = "", $dir = MOD_DIR) { $is = $dom; !$dom && $dom = "dr_show_hits_{$id}"; $html = $is ? "" : "<span id=\"{$dom}\">0</span>"; return $html."<script type=\"text/javascript\"> $.ajax({ type: \"GET\", url:\"".ROOT_URL."index.php?s=api&c=mymodule&siteid=".SITE_ID."&app=".$dir."&m=hits&id={$id}\", dataType: \"jsonp\", success: function(data){ if (data.code) { $(\"#{$dom}\").html(data.msg); } else { dr_tips(0, data.msg); } } }); </script>"; }
2、復制文件dayrui/Core/Controllers/Api/Module.php,到,dayrui/Core/Controllers/Api/Mymodule.php
內(nèi)如如下:
<?php namespace Phpcmf\Controllers\Api; // 模塊ajax操作接口 class Mymodule extends \Phpcmf\Common { private $siteid; private $dirname; private $tablename; protected $content_model; public function __construct(...$params) { parent::__construct(...$params); // 初始化模塊 $this->siteid = (int)\Phpcmf\Service::L('input')->get('siteid'); !$this->siteid && $this->siteid = SITE_ID; $this->dirname = dr_safe_replace(\Phpcmf\Service::L('input')->get('app')); if (!$this->dirname || !dr_is_app_dir(($this->dirname))) { $this->_msg(0, dr_lang('模塊目錄[%s]不存在', $this->dirname)); exit; } $this->tablename = $this->siteid.'_'.$this->dirname; $this->content_model = \Phpcmf\Service::M('Content', $this->dirname); $this->_module_init($this->dirname, $this->siteid); } /** * 閱讀數(shù)統(tǒng)計 */ public function hits() { $id = (int)\Phpcmf\Service::L('input')->get('id'); if (!$id) { $this->_jsonp(0, dr_lang('閱讀統(tǒng)計: id參數(shù)不完整')); } $data = \Phpcmf\Service::M()->db->table($this->tablename)->where('id', $id)->select('hits,updatetime')->get()->getRowArray(); if (!$data) { $this->_jsonp(0, dr_lang('閱讀統(tǒng)計: 模塊內(nèi)容不存在')); } $plus = defined('IS_HITS_PLUS') && is_numeric(IS_HITS_PLUS) ? intval(IS_HITS_PLUS) : 1; if (!$plus) { // 增量為0時原樣輸出 $this->_jsonp(1, $data['hits']);exit; } $hits = (int)$data['hits'] + $plus; // 更新主表 \Phpcmf\Service::M()->db->table($this->tablename)->where('id', $id)->set('hits', $hits)->update(); // 獲取統(tǒng)計數(shù)據(jù) $total = \Phpcmf\Service::M()->db->table($this->tablename.'_hits')->where('id', $id)->get()->getRowArray(); if (!$total) { $total['day_hits'] = $total['week_hits'] = $total['month_hits'] = $total['year_hits'] = 0; $total['day_time'] = $total['week_time'] = $total['month_time'] = $total['year_time'] = SYS_TIME; } else { // 按類別歸零 if (date('Ymd', $total['day_time']) != date('Ymd', SYS_TIME)) { $total['day_time'] = SYS_TIME; $total['day_hits'] = 0; } if (date('YW', $total['week_time']) != date('YW', SYS_TIME)) { $total['week_time'] = SYS_TIME; $total['week_hits'] = 0; } if (date('Ym', $total['month_time']) != date('Ym', SYS_TIME)) { $total['month_time'] = SYS_TIME; $total['month_hits'] = 0; } if (date('Y', $total['year_time']) != date('Y', SYS_TIME)) { $total['year_time'] = SYS_TIME; $total['year_hits'] = 0; } } // 更新到統(tǒng)計表 $save = [ 'id' => $id, 'hits' => $hits, 'day_hits' => $total['day_hits'] + $plus, 'day_time' => $total['day_time'], 'week_hits' => $total['week_hits'] + $plus, 'week_time' => $total['week_time'], 'month_hits' => $total['month_hits'] + $plus, 'month_time' => $total['month_time'], 'year_hits' => $total['year_hits'] + $plus, 'year_time' => $total['year_time'], ]; \Phpcmf\Service::M()->table($this->tablename.'_hits')->replace($save); // 輸出 $this->_jsonp(1, $hits); } }
回復@靠懸賞(設(shè)置懸賞)賺錢買授權(quán) 我等會試下。先謝謝了
回復@靠懸賞(設(shè)置懸賞)賺錢買授權(quán) 試過了不行啊,有問題,可以加QQ聯(lián)系嗎:351703406
回復@靠懸賞(設(shè)置懸賞)賺錢買授權(quán) 直接使用你的代碼,可是報錯,怎么回事?
什么錯誤呢,我運行一切正常
回復@龍媒
真復雜,寫一個update,然后寫一小段js就完事了
五樓的代碼和方法很完美了,非常不錯
回復迅??蚣軇?chuàng)始人
五樓的代碼,確實是不行的!500錯誤
<?php namespace Phpcmf\Controllers\Api; /** * http://223987.com * 本文件是框架系統(tǒng)文件,二次開發(fā)時不可以修改本文件 **/ // 模塊ajax操作接口 class Mymodule extends \Phpcmf\Common { private $siteid; private $dirname; private $tablename; protected $content_model; public function __construct(...$params) { parent::__construct(...$params); // 初始化模塊 $this->siteid = (int)\Phpcmf\Service::L('input')->get('siteid'); !$this->siteid && $this->siteid = SITE_ID; $this->dirname = dr_safe_replace(\Phpcmf\Service::L('input')->get('app')); if (!$this->dirname || !dr_is_app_dir(($this->dirname))) { $this->_msg(0, dr_lang('模塊目錄[%s]不存在', $this->dirname)); exit; } $this->tablename = $this->siteid.'_'.$this->dirname; $this->content_model = \Phpcmf\Service::M('Content', $this->dirname); $this->_module_init($this->dirname, $this->siteid); } public function index() { exit('module api'); } /** * 閱讀數(shù)統(tǒng)計 */ public function hits() { $id = (int)\Phpcmf\Service::L('input')->get('id'); if (!$id) { $this->_jsonp(0, dr_lang('閱讀統(tǒng)計: id參數(shù)不完整')); } $data = \Phpcmf\Service::M()->db->table($this->tablename)->where('id', $id)->select('hits,updatetime')->get()->getRowArray(); if (!$data) { $this->_jsonp(0, dr_lang('閱讀統(tǒng)計: 模塊內(nèi)容不存在')); } $plus = defined('IS_HITS_PLUS') && is_numeric(IS_HITS_PLUS) ? intval(IS_HITS_PLUS) : 1; if (!$plus) { // 增量為0時原樣輸出 $this->_jsonp(1, $data['hits']);exit; } /* $name = 'module-'.md5($this->tablename).'-'.$id; if (\Phpcmf\Service::L('input')->get_cookie($name)) { $this->_jsonp(1, $data['hits']); } */ $hits = (int)$data['hits'] + $plus; // 更新主表 \Phpcmf\Service::M()->db->table($this->tablename)->where('id', $id)->set('hits', $hits)->update(); // 獲取統(tǒng)計數(shù)據(jù) $total = \Phpcmf\Service::M()->db->table($this->tablename.'_hits')->where('id', $id)->get()->getRowArray(); if (!$total) { $total['day_hits'] = $total['week_hits'] = $total['month_hits'] = $total['year_hits'] = $plus; } // 更新到統(tǒng)計表 \Phpcmf\Service::M()->table($this->tablename.'_hits')->replace([ 'id' => $id, 'hits' => $hits, 'day_hits' => (date('Ymd', $data['updatetime']) == date('Ymd', SYS_TIME)) ? $hits : $plus, 'week_hits' => (date('YW', $data['updatetime']) == date('YW', SYS_TIME)) ? ($total['week_hits'] + $plus) : $plus, 'month_hits' => (date('Ym', $data['updatetime']) == date('Ym', SYS_TIME)) ? ($total['month_hits'] + $plus) : $plus, 'year_hits' => (date('Ymd', $data['updatetime']) == date('Ymd', strtotime('-1 day'))) ? $hits : $total['year_hits'], ]); //session()->save($name, $id, 300); 考慮并發(fā)性能還是不用session了 //\Phpcmf\Service::L('input')->set_cookie($name, $id, 300); \Phpcmf\Service::M()->table($this->tablename.'_hits')->replace($save); // 輸出 $this->_jsonp(1, $hits); } }
不能取消限制,但是你可以把控制器復制出來,重新做一個統(tǒng)計方法的js
要想不改主程序只能復制出來改api控制器類文件
回復@sk360c 如果這樣改的話,怎么收費?
5元賞金,我按一樓思路給你改,不影響升級
回復@靠懸賞(設(shè)置懸賞)賺錢買授權(quán) 可以,需要我重新發(fā)個懸賞(設(shè)置懸賞)貼嗎?
追加懸賞(設(shè)置懸賞)金額
回復@靠懸賞(設(shè)置懸賞)賺錢買授權(quán) 你做好了我再加,還是我現(xiàn)在加懸賞(設(shè)置懸賞)?
1、config/custom.php
2、復制文件dayrui/Core/Controllers/Api/Module.php,到,dayrui/Core/Controllers/Api/Mymodule.php
內(nèi)如如下:
回復@靠懸賞(設(shè)置懸賞)賺錢買授權(quán) 我等會試下。先謝謝了
回復@靠懸賞(設(shè)置懸賞)賺錢買授權(quán) 試過了不行啊,有問題,可以加QQ聯(lián)系嗎:351703406
回復@靠懸賞(設(shè)置懸賞)賺錢買授權(quán) 直接使用你的代碼,可是報錯,怎么回事?
什么錯誤呢,我運行一切正常
回復@龍媒
真復雜,寫一個update,然后寫一小段js就完事了
五樓的代碼和方法很完美了,非常不錯
回復迅??蚣軇?chuàng)始人
五樓的代碼,確實是不行的!500錯誤