Exemple #1
0
 function sync_data()
 {
     hg_flushMsg('开始同步数据');
     $sql = "SELECT COUNT(*) as total FROM " . DB_PREFIX . "nums";
     $total = $this->db->query_first($sql);
     $total = $total['total'];
     $offset = 0;
     $count = 10000;
     //查询存在的分表
     include_once CUR_CONF_PATH . 'lib/cache.class.php';
     $cache = new CacheFile();
     while ($offset < $total) {
         hg_flushMsg('开始同步第' . $offset . '到' . ($offset + $count) . '条');
         $table = $cache->get_cache('access_table_name');
         $table = convert_table_name($table);
         $table_str = '';
         if ($table) {
             $table_str = implode(',', $table);
         }
         $sql = "ALTER TABLE " . DB_PREFIX . "merge UNION(" . $table_str . ")";
         $this->db->query($sql);
         //查询存在的分表
         $sql = "SELECT app_bundle, module_bundle, cid, title FROM " . DB_PREFIX . "nums WHERE 1 ORDER BY id ASC LIMIT " . $offset . ", " . $count;
         $q = $this->db->query($sql);
         while (($row = $this->db->fetch_array($q)) != false) {
             $sql = "UPDATE " . DB_PREFIX . "merge SET title = '" . $row['title'] . "'\n                        WHERE app_bundle='" . $row['app_bundle'] . "' AND module_bundle = '" . $row['module_bundle'] . "' AND cid='" . $row['cid'] . "'";
             //                hg_flushMsg($sql);
             $this->db->query($sql);
         }
         $offset += $count;
     }
     hg_flushMsg('数据同步完成');
 }
Exemple #2
0
 function show()
 {
     if ($this->input['id']) {
         $cond = ' AND id=' . intval($this->input['id']);
     }
     $sql = "SELECT * FROM " . DB_PREFIX . "ranking_sort WHERE status = 1{$cond} ORDER BY last_time ASC LIMIT 10";
     $qq = $this->db->query($sql);
     include_once ROOT_PATH . 'lib/class/publishcontent.class.php';
     $this->publishcontent = new publishcontent();
     include CUR_CONF_PATH . 'lib/access.class.php';
     $this->obj = new access();
     include_once CUR_CONF_PATH . 'lib/cache.class.php';
     $cache = new CacheFile();
     $exists_table = $cache->get_cache('access_table_name');
     while ($info = $this->db->fetch_array($qq)) {
         $params = array('start_time' => $info['start_time'], 'duration' => $info['duration'], 'last_time' => $info['last_time'], 'column_id' => $info['column_id'], 'type' => $info['type'], 'output_type' => $info['output_type'], 'count' => $info['limit_num'], 'title' => $info['k'], 'publish_duration' => $info['publish_duration']);
         $rankingCon = $this->obj->get_content($params);
         $sql = "DELETE FROM " . DB_PREFIX . "ranking_cont WHERE sort_id = " . $info['id'];
         $this->db->query($sql);
         if (!empty($rankingCon)) {
             //查询发布到发布库的内容标识,用于判断内容是否是发布库数据
             $content_type = $this->publishcontent->get_all_content_type();
             $pub_content_bundle = array();
             foreach ((array) $content_type as $k => $v) {
                 $pub_content_bundle[] = $v['bundle_id'];
             }
             $rankingChunk = array_chunk($rankingCon, 30, true);
             foreach ($rankingChunk as $key => $val) {
                 $sql = "INSERT INTO " . DB_PREFIX . "ranking_cont(sort_id,cid,app_bundle,title,url,count) VALUES";
                 $space = '';
                 foreach ($val as $k => $v) {
                     //非发布库数据标题使用库里存储内容
                     //从merge表统计出来如果没有title,到nums表查询标题
                     //merge表结构不好更改,更改后客户升级也比较麻烦 所以临时解决方案 到nums表再查询一次
                     if (!$v['title'] && $v['app_bundle'] && !in_array($v['app_bundle'], $pub_content_bundle)) {
                         $sql_nums = "SELECT title FROM " . DB_PREFIX . "nums WHERE app_bundle = '" . $v['app_bundle'] . "' AND cid=" . $v['cid'];
                         $nums_q = $this->db->query_first($sql_nums);
                         $v['title'] = $nums_q['title'];
                     }
                     !$v['url'] && ($v['url'] = $v['refer_url']);
                     $sql .= $space . "('{$info['id']}','{$v['cid']}','{$v['app_bundle']}','{$v['title']}','{$v['url']}','{$v['num']}')";
                     $space = ',';
                 }
                 $this->db->query($sql);
             }
         }
         $sql = "UPDATE " . DB_PREFIX . "ranking_sort SET last_time = " . TIMENOW . " WHERE id = " . $info['id'];
         $this->db->query($sql);
         echo $info['title'] . "<br/>";
         flush();
         ob_flush();
     }
     exit;
 }
Exemple #3
0
 function show()
 {
     $cid = urldecode($this->input['cid']);
     if (!$cid) {
         $this->errorOutput('no cid');
     }
     $sql = "UPDATE " . DB_PREFIX . "nums SET del = 1 WHERE cid IN(" . $cid . ")";
     $this->db->query($sql);
     include_once CUR_CONF_PATH . 'lib/cache.class.php';
     $cache = new CacheFile();
     $table = $cache->get_cache('access_table_name');
     $table = convert_table_name($table);
     if ($table) {
         $table_str = implode(',', $table);
     }
     $sql = "ALTER TABLE " . DB_PREFIX . "merge UNION(" . $table_str . ")";
     $this->db->query($sql);
     $sql = "UPDATE " . DB_PREFIX . "merge SET del = 1 WHERE cid IN(" . $cid . ")";
     $this->db->query($sql);
     exit('sucess');
 }
Exemple #4
0
 function get_content()
 {
     if ($this->settings['cache_expire_time']) {
         /**先从缓存读取数据 缓存不存在或过期时再从表中查询*/
         include_once ROOT_PATH . 'lib/class/cache/cache.class.php';
         $cache_factory = cache_factory::get_instance();
         $cache_type = $this->settings['cache_type'] ? $this->settings['cache_type'] : 'file';
         $cache_driver = $cache_factory->get_cache_driver($cache_type);
         $input = $this->input;
         unset($input['access_token'], $input['lpip']);
         $cache_id = md5(serialize($input));
         $data = $cache_driver->get($cache_id);
         if ($data) {
             $this->addItem($data);
             $this->output();
         }
         /**先从缓存读取数据 缓存不存在或过期时再从表中查询*/
     }
     //$condition = $this->get_condition();
     $offset = $this->input['page'] ? $this->input['page_num'] * ($this->input['page'] - 1) : 0;
     $count = $this->input['page_num'] ? intval($this->input['page_num']) : 20;
     $con = $con_count = $this->con_process();
     $con['offset'] = $offset;
     $con['count'] = $count;
     $content = $this->obj->get_content($con);
     include_once ROOT_PATH . 'lib/class/publishcontent.class.php';
     $this->publishcontent = new publishcontent();
     $content_type = $this->publishcontent->get_all_content_type();
     $pub_content_bundle = array();
     foreach ((array) $content_type as $k => $v) {
         $pub_content_bundle[] = $v['bundle_id'];
     }
     include_once ROOT_PATH . 'lib/class/auth.class.php';
     $this->auth = new Auth();
     $app_info = $this->auth->get_app();
     $module = array();
     foreach ((array) $app_info as $k => $v) {
         if (!empty($v)) {
             $module[$v['bundle']] = $v['name'];
         }
     }
     $cidArr = array();
     $conArr = array();
     $other_content = array();
     foreach ((array) $content as $row) {
         if (!in_array($row['app_bundle'], $pub_content_bundle)) {
             $row['bundle_name'] = $module[$row['app_bundle']];
             if (!$row['bundle_name']) {
                 $row['bundle_name'] = $this->settings["App_{$row['app_bundle']}"]['name'];
             }
             if (!$row['bundle_name']) {
                 $row['bundle_name'] = $row['app_bundle'];
             }
             $row['content_url'] = $row['url'];
             $row['access_nums'] = $row['num'];
             $other_content[] = $row;
         } else {
             $cidArr[] = $row['cid'];
             $conArr[$row['cid']] = array('access_nums' => $row['num']);
         }
     }
     $cidStr = implode(',', $cidArr);
     $ret = $this->publishcontent->get_content_by_cid($cidStr);
     if (!is_array($ret)) {
         //return array();
     }
     $ret = (array) $ret;
     $arExistIds = array();
     foreach ($ret as $k => $v) {
         $arExistIds[] = $v['cid'];
         $ret[$k]['bundle_name'] = $module[$v['bundle_id']];
         if (!$ret[$k]['bundle_name']) {
             $ret[$k]['bundle_name'] = $this->settings["App_{$v['bundle_id']}"]['name'];
         }
         if (!$ret[$k]['bundle_name']) {
             $ret[$k]['bundle_name'] = $v['bundle_id'];
         }
         $ret[$k] = array_merge($ret[$k], $conArr[$k]);
     }
     $ret = array_merge($ret, $other_content);
     //发布库删除没有更新统计时条数不准确 下面代码为解决此bug
     //对比cid差集
     $delCid = array_diff($cidArr, $arExistIds);
     //更新已经不存在的内容
     if (!empty($delCid)) {
         $cid = implode(',', $delCid);
         $sql = "UPDATE " . DB_PREFIX . "nums SET del = 1 WHERE cid IN(" . $cid . ")";
         $this->db->query($sql);
         include_once CUR_CONF_PATH . 'lib/cache.class.php';
         $cache = new CacheFile();
         $table = $cache->get_cache('access_table_name');
         $table = convert_table_name($table);
         if ($table) {
             $table_str = implode(',', $table);
         }
         $sql = "ALTER TABLE " . DB_PREFIX . "merge UNION(" . $table_str . ")";
         $this->db->query($sql);
         $sql = "UPDATE " . DB_PREFIX . "merge SET del = 1 WHERE cid IN(" . $cid . ")";
         $this->db->query($sql);
     }
     $ret = hg_array_sort($ret, 'access_nums', 'DESC');
     $pagearr = $this->obj->get_content($con_count, 1);
     $pagearr['page_num'] = $count;
     $pagearr['total_num'] = $pagearr['total'];
     $pagearr['total_page'] = ceil($pagearr['total'] / $count);
     $pagearr['current_page'] = floor($offset / $count) + 1;
     $ret = array('content' => array_values($ret), 'page' => $pagearr);
     if ($this->settings['cache_expire_time']) {
         /*将数据写入缓存*/
         $cache_driver->set($cache_id, $ret, $this->settings['cache_expire_time']);
         /*将数据写入缓存*/
     }
     $this->addItem($ret);
     $this->output();
 }
Exemple #5
0
    /**
     * 叮当内容统计add
     */
    public function dingdoneAddNums()
    {
        $id = intval($this->input['id']);
        $content_fromid = intval($this->input['content_fromid']);
        if (!$id) {
            $this->errorOutput(NOID);
        }
        $rec = intval($this->input['rec']);
        $appunid = addslashes($this->input['app_uniqueid']);
        $modunid = addslashes($this->input['mod_uniqueid']);
        //叮当原有数据兼容
        $old_sql = 'SELECT id, access_nums, is_sync,url, last_sync_time, create_time, title
				FROM ' . DB_PREFIX . "nums\r\n\t\t\tWHERE app_bundle='{$appunid}' AND module_bundle='{$modunid}' AND cid='{$id}' AND content_fromid = 0";
        $old_row = $this->db->query_first($old_sql);
        if ($old_row && is_array($old_row)) {
            $count = intval($old_row['access_nums']);
            //删除此数据
            $delete_old_sql = "delete from " . DB_PREFIX . "nums where cid =" . $id;
            $this->db->query($delete_old_sql);
        } else {
            $sql = 'SELECT id, access_nums, is_sync,url, last_sync_time, create_time, title
				FROM ' . DB_PREFIX . "nums\r\n\t\t\t\t\t\t\tWHERE app_bundle='{$appunid}' AND module_bundle='{$modunid}' AND content_fromid='{$content_fromid}'";
            $row = $this->db->query_first($sql);
            $count = intval($row['access_nums']);
            $delete_new_sql = "delete from " . DB_PREFIX . "nums where content_fromid =" . $content_fromid . "";
            $this->db->query($delete_new_sql);
        }
        if ($rec) {
            $title = $this->input['title'];
            if (!$title && !$row['title']) {
                include_once ROOT_PATH . 'lib/class/publishcontent.class.php';
                $this->publishcontent = new publishcontent();
                $content_type = $this->publishcontent->get_all_content_type();
                $this->pub_content_bundle = $pub_content_bundle = array();
                foreach ((array) $content_type as $k => $v) {
                    $this->pub_content_bundle[] = $pub_content_bundle[] = $v['bundle_id'];
                }
                if ($appunid && in_array($appunid, $pub_content_bundle)) {
                    //统计时如果没有传并且库里没有标题,去发布库查询标题,用户统计后台搜索
                    include_once ROOT_PATH . 'lib/class/publishcontent.class.php';
                    $this->publishtcontent = new publishcontent();
                    $content = $this->publishtcontent->get_content_by_cid($id);
                    $title = $content[$id]['title'];
                }
            }
            $title = $title ? addslashes($title) : addslashes($row['title']);
            $reffer = addslashes($this->input['reffer']);
            $type = intval($this->input['type']);
            $columnid = intval($this->input['column_id']);
            // 			if((TIMENOW - $row['last_sync_time']) >= SYNC_SPACE * 3600)
            // 			{
            $count = $count + 1;
            // 			}
            $ip = hg_getip();
            $time = date('Ym', TIMENOW);
            if (!$row['id']) {
                $row['create_time'] = TIMENOW;
            }
            $tableName = "record_" . $time;
            //			$sql = "SHOW TABLES LIKE '" . DB_PREFIX . $tableName. "'";
            //			$this->db->query($sql);
            //			if(!$this->db->affected_rows())
            ### 读取已经存在的表验证新表是否已经存在
            include_once CUR_CONF_PATH . 'lib/cache.class.php';
            $cache = new CacheFile();
            $oldTable = $cache->get_cache('access_table_name');
            if (!in_array($tableName, $oldTable)) {
                $sql = "CREATE TABLE " . DB_PREFIX . $tableName . " LIKE " . DB_PREFIX . "record";
                $this->db->query($sql);
                // 				###保存已建的表 关联时验证表是否存在
                $newTable = array($tableName);
                $allTable = array_merge($oldTable, $newTable);
                $allTable = array_unique($allTable);
                $cache->set_cache('access_table_name', $allTable);
                // 				###保存结束
            }
            $sql = 'INSERT INTO ' . DB_PREFIX . "record_" . $time . " (app_bundle, module_bundle, type, content_fromid ,cid, column_id, refer_url, ip, access_time, appid, appname,user_id, user_name, title) VALUES\r\n\t\t\t('{$appunid}', '{$modunid}', '{$type}', {$content_fromid} ,'{$id}', '{$columnid}', '{$reffer}', '{$ip}', " . TIMENOW . ", '{$this->user['appid']}', '{$this->user['appname']}', '{$this->user['user_id']}', '{$this->user['user_name']}', '{$title}')";
            $this->db->query($sql);
            if (!$row['url']) {
                $row['url'] = $reffer;
            }
            $sql = 'INSERT INTO ' . DB_PREFIX . "nums (app_bundle, module_bundle, content_fromid,cid, title, access_nums, last_sync_time, is_sync, url, create_time, update_time) VALUES\r\n\t\t\t('{$appunid}', '{$modunid}', '{$content_fromid}', '{$id}' ,'{$title}', " . $count . ", '{$row['last_sync_time']}', '{$row['is_sync']}', '{$row['url']}', '{$row['create_time']}', " . TIMENOW . ")";
            $this->db->query($sql);
            $this->dingdoneSync($content_fromid, $row['last_sync_time'], $row['create_time'], $count, $appunid, $modunid);
        }
        if (isset($this->settings['default_number']) && $this->settings['default_number']) {
            @srand($id);
            $min = $max = 0;
            list($min, $max) = @split(',', $this->settings['default_number']);
            $count += @rand($min, $max);
        }
        $this->addItem($count);
        $this->output();
    }
Exemple #6
0
 public function get_content($params = array(), $get_count = false)
 {
     $timefield = 'create_time';
     if (!$params['start_time'] && !$params['duration'] && !$params['column_id']) {
         //不限制开始和时间和时长时表示所有查询所有内容 从汇总表 nums表查询
         if (!$get_count) {
             $sql = "SELECT cid, access_nums AS num, column_id, app_bundle, title, url FROM " . DB_PREFIX . "nums WHERE 1 AND del = 0";
         } else {
             $sql = "SELECT COUNT(*) AS total FROM " . DB_PREFIX . "nums WHERE 1 AND del = 0";
         }
     } else {
         $mergeall = false;
         if ($params['start_time']) {
             $start_time = $params['start_time'];
             if ($params['duration']) {
                 $time = $params['duration'] * 60;
                 $end_time = $params['start_time'] + $time;
             } else {
                 $timefield = 'create_time';
                 $end_time = TIMENOW;
             }
             if ($end_time < TIMENOW && $end_time < $params['last_time']) {
                 //continue;
             }
         } else {
             if ($params['duration']) {
                 $time = $params['duration'] * 60;
                 $start_time = TIMENOW - $time;
                 $end_time = $params['end_time'] ? $params['end_time'] : TIMENOW;
             } else {
                 $mergeall = true;
             }
         }
         //查询存在的分表
         include_once CUR_CONF_PATH . 'lib/cache.class.php';
         $cache = new CacheFile();
         $exists_table = $cache->get_cache('access_table_name');
         //查询存在的分表
         if (!$mergeall) {
             ###根据起始时间关联merge表
             $start_year = intval(date('Y', $start_time));
             $start_month = intval(date('m', $start_time));
             $end_year = intval(date('Y', $end_time));
             $end_month = intval(date('m', $end_time));
             $table = array();
             $i = $start_year;
             $j = $start_month;
             while ($i < $end_year || $j <= $end_month) {
                 if ($i > $end_year) {
                     //年份大于等于当前年份时跳出循环
                     break;
                 }
                 $j = strlen($j) != 2 ? '0' . $j : $j;
                 $table_name = "record_" . $i . $j;
                 if (in_array($table_name, $exists_table)) {
                     $table[] = $table_name;
                 }
                 if ($j == 12) {
                     $i++;
                     $j = 1;
                 } else {
                     $j++;
                 }
             }
         } else {
             $table = $exists_table;
         }
         $table = $this->convert_table_name($table);
         if ($table) {
             $table_str = implode(',', $table);
         }
         $sql = "ALTER TABLE " . DB_PREFIX . "merge UNION(" . $table_str . ")";
         $this->db->query($sql);
         ###关联结束
         if (!$get_count) {
             $sql = "SELECT cid,count(*) AS num, column_id, app_bundle, refer_url AS url FROM " . DB_PREFIX . "merge WHERE 1 AND del = 0";
         } else {
             $sql = "SELECT COUNT(*) AS total FROM ( SELECT cid,count(*) AS num FROM " . DB_PREFIX . "merge WHERE 1 AND del = 0";
         }
         if ($start_time) {
             $sql .= " AND {$timefield} >= " . $start_time;
         }
         if ($end_time) {
             $sql .= " AND {$timefield} <= " . $end_time;
         }
     }
     if ($params['column_id']) {
         include_once ROOT_PATH . 'lib/class/publishconfig.class.php';
         $this->publish_column = new publishconfig();
         $ret = $this->publish_column->get_column_by_ids('id,childs', $params['column_id']);
         $idArr = array();
         if ($ret && is_array($ret)) {
             foreach ($ret as $k => $v) {
                 $idArr[] = $v['childs'];
             }
         }
         $idStr = implode(",", $idArr);
         if ($idStr) {
             $sql .= " AND column_id IN(" . $idStr . ")";
         }
     }
     if ($params['type']) {
         $params['type'] = explode(',', $params['type']);
         $params['type'] = implode("','", $params['type']);
         $sql .= " AND app_bundle IN('" . $params['type'] . "')";
     }
     if ($params['title']) {
         $sql .= ' AND title LIKE \'%' . trim(urldecode($params['title'])) . '%\'';
     }
     if ($params['cid']) {
         $params['cid'] = explode(",", $params['cid']);
         $params['cid'] = implode("','", $params['cid']);
         $sql .= " AND cid IN('" . $params['cid'] . "')";
     }
     /** begin zbb 2015-4-20 加了一个筛选条件publish_duration **/
     /*
     if($params['publish_duration'] > 0){
         $sql .= ' AND publish_time > ' . (TIMENOW - $params['publish_duration'] * 60);
     }
     */
     /** end **/
     ###从merge表查询需要group by cid
     if ($params['output_type'] == 1) {
         //统计栏目
         $sql .= " GROUP BY column_id ";
     } else {
         $sql .= $params['start_time'] || $params['duration'] || $params['column_id'] ? " GROUP BY cid " : "";
     }
     if (!$get_count) {
         $sql .= " ORDER BY num DESC ";
         if ($params['count']) {
             $sql .= " LIMIT " . intval($params['offset']) . "," . intval($params['count']);
         }
         $q = $this->db->query($sql);
         $rankingCon = array();
         while ($row = $this->db->fetch_array($q)) {
             $params['output_type'] == 1 && ($row['cid'] = $row['column_id']);
             //排行类型为栏目时 记录column_id
             $rankingCon[] = $row;
         }
         return $rankingCon;
     } else {
         if ($params['start_time'] || $params['duration']) {
             $sql .= " ) AS a";
         }
         $q = $this->db->query_first($sql);
         return $q;
     }
 }
Exemple #7
0
 function show()
 {
     $id = intval($this->input['sort_id']);
     $column_id = $this->input['column_id'];
     $exclude_column_id = $this->input['exclude_column_id'];
     if ($id) {
         $sql = "SELECT status,output_type,column_id FROM " . DB_PREFIX . "ranking_sort WHERE id = " . $id;
         $sort = $this->db->query_first($sql);
         if (empty($sort) || $sort['status'] != 1) {
             $this->errorOutput("unexist or unaudited");
         }
         include_once ROOT_PATH . 'lib/class/publishcontent.class.php';
         $this->publishcontent = new publishcontent();
         $content_type = $this->publishcontent->get_all_content_type();
         $pub_content_bundle = array();
         foreach ((array) $content_type as $k => $v) {
             $pub_content_bundle[] = $v['bundle_id'];
         }
         $offset = intval($this->input['offset']) ? intval($this->input['offset']) : 0;
         $count = intval($this->input['count']) ? intval($this->input['count']) : 30;
         $data_limit = " LIMIT " . $offset . ", " . $count;
         $sql = "SELECT * FROM " . DB_PREFIX . "ranking_cont WHERE sort_id = " . $id . " ORDER BY count DESC " . $data_limit;
         $q = $this->db->query($sql);
         $cidArr = array();
         $conArr = array();
         $other_content = array();
         while ($row = $this->db->fetch_array($q)) {
             if ($row['app_bundle'] && !in_array($row['app_bundle'], $pub_content_bundle)) {
                 $row['update_time'] = date('Y-m-d H:i:s', $row['update_time']);
                 $row['content_url'] = $row['url'];
                 $other_content[] = $row;
             } else {
                 $cidArr[] = $row['cid'];
                 $conArr[$row['cid']] = $row['count'];
             }
         }
         $cidStr = implode(',', $cidArr);
         $blDirectReturn = $this->input['direct_return'] && $this->input['direct_return'] != 'false' ? 1 : 0;
         if ($blDirectReturn) {
             $this->addItem($cidStr);
         } else {
             if ($cidStr) {
                 if ($sort['output_type'] == 1) {
                     include_once ROOT_PATH . 'lib/class/publishconfig.class.php';
                     $this->publishconfig = new publishconfig();
                     $ret = $this->publishconfig->get_column_info_by_ids($cidStr);
                 } else {
                     include_once ROOT_PATH . 'lib/class/publishcontent.class.php';
                     $this->publishtcontent = new publishcontent();
                     $useColumn = array();
                     if ($column_id) {
                         $sort['column_id'] = $column_id;
                     }
                     if ($exclude_column_id) {
                         $exclude_column_id = explode(',', $exclude_column_id);
                         $sort['column_id'] = explode(',', $sort['column_id']);
                         $sort['column_id'] = array_diff($sort['column_id'], $exclude_column_id);
                         $sort['column_id'] = implode(',', $sort['column_id']);
                     }
                     foreach ($cidArr as $cv) {
                         $useColumn[$cv] = $sort['column_id'];
                     }
                     $ret = $this->publishtcontent->get_content_by_cid($cidStr, $useColumn);
                 }
                 $arExistIds = array();
                 if (is_array($ret) && count($ret) > 0) {
                     foreach ($ret as $k => $v) {
                         $arExistIds[] = $sort['output_type'] == 1 ? $v['id'] : $v['cid'];
                         //栏目时统计记录的是id  内容统计记录的是cid
                         $ret[$k]['count'] = $sort['output_type'] == 1 ? $conArr[$v['id']] : $conArr[$v['cid']];
                     }
                 }
                 //发布库删除没有更新统计时条数不准确 下面代码为解决此bug
                 //对比cid差集
                 $cidStr = explode(',', $cidStr);
                 $delCid = array_diff($cidStr, $arExistIds);
                 //更新已经不存在的内容
                 if (0 && !empty($delCid)) {
                     $cid = implode(',', $delCid);
                     $sql = "UPDATE " . DB_PREFIX . "nums SET del = 1 WHERE cid IN(" . $cid . ")";
                     $this->db->query($sql);
                     include_once CUR_CONF_PATH . 'lib/cache.class.php';
                     $cache = new CacheFile();
                     $table = $cache->get_cache('access_table_name');
                     $table = convert_table_name($table);
                     if ($table) {
                         $table_str = implode(',', $table);
                     }
                     $sql = "ALTER TABLE " . DB_PREFIX . "merge UNION(" . $table_str . ")";
                     $this->db->query($sql);
                     $sql = "UPDATE " . DB_PREFIX . "merge SET del = 1 WHERE cid IN(" . $cid . ")";
                     $this->db->query($sql);
                     $sql = "DELETE FROM " . DB_PREFIX . "ranking_cont WHERE sort_id=" . $id . " AND cid IN(" . $cid . ")";
                     $this->db->query($sql);
                 }
                 //
                 $ret = (array) $ret;
                 $ret = array_merge($other_content, $ret);
                 if (is_array($ret) && count($ret)) {
                     $ret = hg_array_sort($ret, 'count', 'DESC');
                     foreach ($ret as $k => $v) {
                         if ($sort['output_type'] == 1) {
                             $v['title'] = $v['name'];
                         }
                         $this->addItem($v);
                     }
                 }
             }
         }
     } else {
         $sql = "SELECT * FROM " . DB_PREFIX . "ranking_sort WHERE status = 1 ";
         $q = $this->db->query($sql);
         $ret = array();
         while ($row = $this->db->fetch_array($q)) {
             $ret[] = $row;
         }
         if ($ret) {
             foreach ($ret as $k => $v) {
                 $this->addItem($v);
             }
         }
     }
     $this->output();
 }