[更新]去除CNZZ统计Hook

This commit is contained in:
Anyon 2017-06-02 14:51:11 +08:00
parent 6cc0665237
commit 70b4433f6a
3 changed files with 25 additions and 52 deletions

View File

@ -44,14 +44,6 @@
</div> </div>
</div> </div>
<div class="form-group">
<label class="col-sm-2 control-label">CNZZ <span class="nowrap">(友盟统计)</span></label>
<div class='col-sm-8'>
<input type="text" name="tongji_cnzz_key" maxlength="32" pattern="^[0-9]{10}$" title="请输入10位CNZZ统计应用ID" placeholder="请输入10位CNZZ统计应用ID" value="{:sysconf('tongji_cnzz_key')}" class="layui-input">
<p class="help-block">友盟统计应用ID可以在<a target="_blank" href="https://web.umeng.com">友盟网站统计</a>申请并获取</p>
</div>
</div>
<div class="form-group"> <div class="form-group">
<label class="col-sm-2 control-label">BrowserIcon <span class="nowrap">(浏览器图标)</span></label> <label class="col-sm-2 control-label">BrowserIcon <span class="nowrap">(浏览器图标)</span></label>
<div class='col-sm-8'> <div class='col-sm-8'>

View File

@ -56,34 +56,30 @@ class BasicAdmin extends Controller {
* @param string $tplFile 显示模板名字 * @param string $tplFile 显示模板名字
* @param string $pkField 更新主键规则 * @param string $pkField 更新主键规则
* @param array $where 查询规则 * @param array $where 查询规则
* @param array $data 扩展数据 * @param array $extendData 扩展数据
* @return array|string * @return array|string
*/ */
protected function _form($dbQuery = null, $tplFile = '', $pkField = '', $where = [], $data = []) { protected function _form($dbQuery = null, $tplFile = '', $pkField = '', $where = [], $extendData = []) {
$db = is_null($dbQuery) ? Db::name($this->table) : (is_string($dbQuery) ? Db::name($dbQuery) : $dbQuery); $db = is_null($dbQuery) ? Db::name($this->table) : (is_string($dbQuery) ? Db::name($dbQuery) : $dbQuery);
$pk = empty($pkField) ? ($db->getPk() ? $db->getPk() : 'id') : $pkField; $pk = empty($pkField) ? ($db->getPk() ? $db->getPk() : 'id') : $pkField;
$pkValue = $this->request->request($pk, isset($where[$pk]) ? $where[$pk] : (isset($data[$pk]) ? $data[$pk] : null)); $pkValue = $this->request->request($pk, isset($where[$pk]) ? $where[$pk] : (isset($extendData[$pk]) ? $extendData[$pk] : null));
// POST请求, 数据自动存库 // 非POST请求, 获取数据并显示表单页面
if ($this->request->isPost()) { if (!$this->request->isPost()) {
$data = array_merge($this->request->post(), $data); $vo = ($pkValue !== null) ? array_merge((array) $db->where($pk, $pkValue)->where($where)->find(), $extendData) : $extendData;
if (false !== $this->_callback('_form_filter', $data)) { if (false !== $this->_callback('_form_filter', $vo)) {
$result = DataService::save($db, $data, $pk, $where); empty($this->title) || $this->assign('title', $this->title);
if (false === $this->_callback('_form_result', $result)) { return $this->fetch($tplFile, ['vo' => $vo]);
return $result;
} }
if ($result !== false) {
$this->success('恭喜, 数据保存成功!', '');
}
$this->error('数据保存失败, 请稍候再试!');
}
}
// GET请求, 获取并显示表单页面
$vo = ($pkValue !== null) ? array_merge((array) $db->where($pk, $pkValue)->where($where)->find(), $data) : $data;
if (false === $this->_callback('_form_filter', $vo)) {
return $vo; return $vo;
} }
empty($this->title) or $this->assign('title', $this->title); // POST请求, 数据自动存库
return $this->fetch($tplFile, ['vo' => $vo]); $data = array_merge($this->request->post(), $extendData);
if (false !== $this->_callback('_form_filter', $data)) {
$result = DataService::save($db, $data, $pk, $where);
if (false !== $this->_callback('_form_result', $result)) {
$result !== false ? $this->success('恭喜, 数据保存成功!', '') : $this->error('数据保存失败, 请稍候再试!');
}
}
} }
/** /**
@ -108,15 +104,15 @@ class BasicAdmin extends Controller {
$this->success('列表排序成功, 正在刷新列表', ''); $this->success('列表排序成功, 正在刷新列表', '');
} }
// 列表数据查询与显示 // 列表数据查询与显示
$result = array();
if (null === $db->getOptions('order')) { if (null === $db->getOptions('order')) {
$fields = $db->getTableFields(['table' => $db->getTable()]); $fields = $db->getTableFields(['table' => $db->getTable()]);
in_array('sort', $fields) && $db->order('sort asc'); in_array('sort', $fields) && $db->order('sort asc');
} }
$result = array();
if ($isPage) { if ($isPage) {
$row_page = $this->request->get('rows', cookie('rows'), 'intval'); $rowPage = intval($this->request->get('rows', cookie('rows')));
cookie('rows', $row_page >= 10 ? $row_page : 20); cookie('rows', $rowPage >= 10 ? $rowPage : 20);
$page = $db->paginate($row_page, $total, ['query' => $this->request->get()]); $page = $db->paginate($rowPage, $total, ['query' => $this->request->get()]);
$result['list'] = $page->all(); $result['list'] = $page->all();
$result['page'] = preg_replace(['|href="(.*?)"|', '|pagination|'], ['data-open="$1" href="javascript:void(0);"', 'pagination pull-right'], $page->render()); $result['page'] = preg_replace(['|href="(.*?)"|', '|pagination|'], ['data-open="$1" href="javascript:void(0);"', 'pagination pull-right'], $page->render());
} else { } else {

View File

@ -37,17 +37,14 @@ class FilterView {
*/ */
public function run(&$params) { public function run(&$params) {
$this->request = Request::instance(); $this->request = Request::instance();
$app = $this->request->root(true); $appRoot = $this->request->root(true);
$replace = [ $replace = [
'__APP__' => $app, '__APP__' => $appRoot,
'__SELF__' => $this->request->url(true), '__SELF__' => $this->request->url(true),
'__PUBLIC__' => strpos($app, EXT) ? ltrim(dirname($app), DS) : $app, '__PUBLIC__' => strpos($appRoot, EXT) ? ltrim(dirname($appRoot), DS) : $appRoot,
]; ];
$params = str_replace(array_keys($replace), array_values($replace), $params); $params = str_replace(array_keys($replace), array_values($replace), $params);
if (!IS_CLI) { !IS_CLI && $this->baidu($params);
$this->baidu($params);
$this->cnzz($params);
}
} }
/** /**
@ -71,16 +68,4 @@ SCRIPT;
} }
} }
/**
* CNZZ统计实现代码
* @param $params
*/
public function cnzz(&$params) {
if (($key = sysconf('tongji_cnzz_key'))) {
$query = ['siteid' => $key, 'r' => $this->request->server('HTTP_REFERER'), 'rnd' => mt_rand(100000, 999999)];
$imgSrc = 'https://c.cnzz.com/wapstat.php?' . http_build_query($query);
$params = preg_replace('|</body>|i', "<img src='{$imgSrc}' style='display:block;position:absolute' width='0' height='0'/>\n </body>", $params);
}
}
} }