public function index(){
     $days = 7;
     $this -> assign('days', $days);
     $where = array('token' => $this -> token);
     $where['time'] = array('gt', time() - $days * 24 * 3600);
     $where['module'] = array('neq', '');
     $db = M('Share');
     $items = $db -> where($where) -> select();
     $datas = array();
     if ($items){
         foreach ($items as $item){
             if (trim($item['module'])){
                 if (!key_exists($item['module'], $datas)){
                     $datas[$item['module']] = array('module' => $item['module'], 'count' => 1, 'moduleName' => funcDict :: moduleName($item['module']));
                 }else{
                     $datas[$item['module']]['count']++;
                 }
             }
         }
     }
     $xml = '<chart borderThickness="0" caption="' . $days . '日内分享统计" baseFontColor="666666" baseFont="宋体" baseFontSize="14" bgColor="FFFFFF" bgAlpha="0" showBorder="0" bgAngle="360" pieYScale="90"  pieSliceDepth="5" smartLineColor="666666">';
     if ($datas){
         foreach ($datas as $item){
             $xml .= '<set label="' . $item['moduleName'] . '" value="' . $item['count'] . '"/>';
         }
     }
     $xml .= '</chart>';
     $this -> assign('items', $items);
     $this -> assign('xml', $xml);
     $this -> assign('list', $datas);
     $this -> assign('listinfo', 1);
     $this -> assign('tab', 'stastic');
     $this -> display();
 }
示例#2
0
 public function moduleName($index)
 {
     $moudles = funcDict::modules();
     if (key_exists(strtolower($index), $moudles)) {
         return $moudles[strtolower($index)]['name'];
     } else {
         if (!$index) {
             return '其他';
         } else {
             return $index;
         }
     }
 }
示例#3
0
 public function tongji()
 {
     $db = D('Share');
     $where['token'] = $this->token;
     $count = $db->where($where)->count();
     $page = new Page($count, 1000);
     $info = $db->where($where)->order('id DESC')->limit($page->firstRow . ',' . $page->listRows)->select();
     $wecha_ids = array();
     if ($info) {
         foreach ($info as $item) {
             if (!in_array($item['wecha_id'], $wecha_ids)) {
                 array_push($wecha_ids, $item['wecha_id']);
             }
         }
         $users = M('Userinfo')->where(array('wecha_id' => array('in', $wecha_ids)))->select();
         if ($users) {
             foreach ($users as $useritem) {
                 $users[$useritem['wecha_id']] = $useritem;
             }
         }
         $i = 0;
         foreach ($info as $item) {
             $info[$i]['user'] = $users[$item['wecha_id']];
             $info[$i]['moduleName'] = funcDict::moduleName($item['module']);
             $i++;
         }
     }
     $r = 0;
     foreach ($info as $item) {
         $iinfo[$r] = $info[$r]['wecha_id'];
         $r++;
     }
     $ac = array_count_values($iinfo);
     $this->assign('page', $page->show());
     $this->assign('info', $info);
     $this->assign('ac', $ac);
     $this->assign('tab', 'tongji');
     $this->display();
 }