/** * 通用的点击统计处理 * * 先判断是否重复的点击、然后检查是否缓存点击,然后更新点击数 * * @param int $id 点击对象ID * @param string $table 点击对象表名 * @param string $fieldstat 点击数的字段名 * @param string $fieldid ID的字段名 * @param object $query 查询对象,不存在会自动创建 * @param int $addnum 每次点击加几个点击数,默认1 * @access public * @return bool */ function jieqi_visit_stat($id, $table, $fieldstat, $fieldid, $query = NULL, $addnum = 1) { if (jieqi_visit_valid($id, $table . '_' . $fieldstat)) { if ($ids = jieqi_visit_ids($id, $table . '_' . $fieldstat)) { global $query; if (!is_a($query, 'JieqiQueryHandler')) { jieqi_includedb(); $query = JieqiQueryHandler::getInstance('JieqiQueryHandler'); } foreach ($ids as $k => $v) { $v['visitnum'] = intval($v['visitnum'] * $addnum); $sql = 'UPDATE ' . $table . ' SET ' . $fieldstat . '=' . $fieldstat . '+' . $v['visitnum'] . ' WHERE ' . $fieldid . '=' . intval($k); $query->execute($sql); } } return true; } else { return false; } }
* @author $Author: juny $ * @version $Id: votedo.php 339 2009-06-23 03:03:24Z juny $ */ define('JIEQI_MODULE_NAME', 'article'); require_once '../../global.php'; jieqi_checklogin(); if (empty($_REQUEST['vid']) || empty($_REQUEST['aid'])) { jieqi_printfail(LANG_ERROR_PARAMETER); } jieqi_loadlang('avote', JIEQI_MODULE_NAME); $_REQUEST['vid'] = intval($_REQUEST['vid']); $_REQUEST['aid'] = intval($_REQUEST['aid']); //载入统计处理函数 include_once JIEQI_ROOT_PATH . '/include/funstat.php'; //检查是否已投票文章 if (!jieqi_visit_valid($_REQUEST['aid'], 'article_articlevotes')) { jieqi_printfail($jieqiLang['article']['avote_already_do']); } else { jieqi_getconfigs(JIEQI_MODULE_NAME, 'configs'); $jieqiConfigs['article']['articlevote'] = intval($jieqiConfigs['article']['articlevote']); if ($jieqiConfigs['article']['articlevote'] <= 0) { jieqi_printfail($jieqiLang['article']['article_vote_close']); } if (!empty($_REQUEST['voteitem'])) { $upstr = ''; $votenum = 0; $addnum = 1; if (is_array($_REQUEST['voteitem'])) { foreach ($_REQUEST['voteitem'] as $v) { $v = intval($v); if ($v >= 1 && $v <= $jieqiConfigs['article']['articlevote']) {
if (!defined('JIEQI_GLOBAL_INCLUDE')) { include_once '../../global.php'; } if (!isset($jieqiConfigs['article'])) { jieqi_getconfigs('article', 'configs'); } $addnum = 1; if (isset($jieqiConfigs['article']['visitstatnum']) && is_numeric($jieqiConfigs['article']['visitstatnum']) && intval($jieqiConfigs['article']['visitstatnum']) >= 0) { $addnum = intval($jieqiConfigs['article']['visitstatnum']); } if ($addnum > 0) { if (!empty($_REQUEST['id']) && is_numeric($_REQUEST['id'])) { //载入统计处理函数 include_once JIEQI_ROOT_PATH . '/include/funstat.php'; //检查是否有效的点击 if (jieqi_visit_valid($_REQUEST['id'], 'article_articleviews')) { if (!is_object($article)) { include_once $jieqiModules['article']['path'] . '/class/article.php'; $article_handler =& JieqiArticleHandler::getInstance('JieqiArticleHandler'); $article = $article_handler->get($_REQUEST['id']); } if (is_object($article)) { $lastvisit = $article->getVar('lastvisit', 'n'); //缓存id,或者返回id数组 if ($ids = jieqi_visit_ids($_REQUEST['id'], 'article_articleviews', $lastvisit)) { $nowdate = date('Y-m-d', JIEQI_NOW_TIME); $nowweek = date('w', JIEQI_NOW_TIME); if ($nowweek == 0) { $nowweek = 7; } foreach ($ids as $k => $v) {