Beispiel #1
0
 public function addAction()
 {
     global $_F;
     $_F["debug"] = true;
     if ($this->isPost()) {
         $manager = $_POST['manager'];
         $password = FRequest::getPostString('password');
         $manager['password'] = md5($password);
         if (trim($manager[username]) == '') {
             return $this->error('用户名不能为空!', '/admin/manager/edit');
         }
         if (trim($manager[email]) == '') {
             return $this->error('邮箱不能为空!', '/admin/manager/edit');
         }
         if ($password == '') {
             return $this->error('密码不能为空!', '/admin/manager/edit');
         }
         $username = FDB::fetch("select username from manager where username ='******'");
         if ($username) {
             return $this->error('用户名重复!', '/admin/manager/edit');
         }
         $email = FDB::fetch("select email from manager where email ='" . trim($manager[email]) . "'");
         if ($email) {
             return $this->error('邮箱重复!', '/admin/manager/edit');
         }
         // 添加管理员用户
         $user_id = Service_Edit::addUser();
         if ($user_id <= 0) {
             return $this->error('添加管理员失败', '/admin/manager/edit');
         }
         $manager["user_id"] = $user_id;
         $quanxianid = FRequest::getPostString('quanxianid');
         $quanxianidx = FRequest::getPostString('quanxianidx');
         if ($quanxianid && count($quanxianid) > 0) {
             $top_menus_id = implode(",", $quanxianid);
         }
         if ($quanxianidx && count($quanxianidx) > 0) {
             $left_menus_id = implode(",", $quanxianidx);
         }
         $manager['top_menus_id'] = $top_menus_id;
         $manager['left_menus_id'] = $left_menus_id;
         $result = $this->db_manager->insert($manager);
         if ($result) {
             return $this->success('添加成功!', '/admin/manager/list');
         }
     }
 }
Beispiel #2
0
 /**
  * 根据时间进行统计
  */
 public function doReportByTimeAction()
 {
     global $_F;
     $_F["debug"] = true;
     $report_log = new FLogger("report_log");
     // 获取统计的日期
     $time_str = FRequest::getString('time');
     $report_log->append("~~~~~统计开始 by time,时间:" . $time_str);
     echo "~~~~~统计开始 by time,时间:" . $time_str . "<br>";
     $tm = date("Y-m-d 00:00:00", strtotime($time_str));
     echo $tm . "<br>";
     $b = time();
     for ($i = 0; $i < 24; $i++) {
         $stm = date("Y-m-d H:00:00", strtotime($tm) + $i * 3600);
         $etm = date("Y-m-d H:00:00", strtotime($tm) + ($i + 1) * 3600);
         //  echo($stm."----".$etm."<br>");
         Service_Edit::statistics($stm, $etm);
     }
     $e = time();
     $report_log->append("~~~~~统计结束,时间:" . $time_str . "---- cost : " . ($e - $b));
     echo "~~~~~统计结束,时间:" . $time_str . "---- cost : " . ($e - $b);
 }
Beispiel #3
0
 /**
  * 按时间地区在线人数
  */
 public function zaixianAction()
 {
     $c_uid = CommonUtil::getDefStr(FRequest::getString('c_uid'), "");
     $c_sid = CommonUtil::getDefStr(FRequest::getString('c_sid'), "");
     $stats_date = FRequest::getString('stats_date');
     $province = FRequest::getString('province');
     $user_type = CommonUtil::getComParam(FRequest::getInt('user_type'), -1);
     $this->assign('sc_uid', $c_uid);
     $this->assign('sc_sid', $c_sid);
     $this->assign('stats_date', $stats_date);
     $this->assign('province', $province);
     $this->assign('user_type', $user_type);
     $table = new FTable("user_province_area");
     $user_province = $table->groupBy("province")->order(array("id" => "asc"))->select();
     $this->assign('user_province', $user_province);
     $data = array();
     $data_1 = array();
     $data_2 = array();
     $where = array("s.key" => "on_top_users");
     if ($c_uid != "") {
         $where["channel"] = $c_uid;
     }
     if ($c_sid != "") {
         $where["sub_channel"] = $c_sid;
     }
     if ($province) {
         $where["province"] = $province;
     }
     if ($user_type >= 0) {
         // $where["user_type"] = $user_type;
     }
     if ($stats_date && $stats_date != "") {
         $where["tm"] = array('like' => $stats_date);
         $where["s.interval"] = "hour";
     } else {
         $where["s.interval"] = "day";
     }
     $fields = array("s.tm", "s.key", "s.gender", "sum(s.value) as sum");
     $table2 = new FTable("Stat", "s", FDB::$DB_MUMU_STAT);
     $total_rs = $table2->fields($fields)->where($where)->groupBy("s.tm")->order(array("s.tm" => "desc"))->select();
     $total = count($total_rs);
     $kaishi_time = $total_rs[30][tm];
     $jieshu_time = $total_rs[0][tm];
     /* if ($total>30) {
            $jieshu_time=$total_rs[29][tm];
        } else {
            $jieshu_time=$total_rs[$total-1][tm];
        }*/
     // echo($kaishi_time.$jieshu_time);
     if ($total > 0) {
         $query_str = " s.tm >= '" . $kaishi_time . "' and  s.tm <= '" . $jieshu_time . "'   ";
         $where["str"] = $query_str;
     }
     $table = new FTable("Stat", "s", FDB::$DB_MUMU_STAT);
     $Stat = $table->fields($fields)->where($where)->groupBy("s.tm,s.key,s.gender")->order(array("s.tm" => "desc"))->select();
     $Stats = array();
     foreach ($Stat as &$s) {
         $sub_arr = array();
         $s["tm"] = $s["tm"];
         if (array_key_exists($s["tm"], $Stats)) {
             $sub_arr = $Stats[$s["tm"]];
         }
         array_push($sub_arr, $s);
         $Stats[$s["tm"]] = $sub_arr;
     }
     $Stats2 = array();
     foreach ($Stats as &$s) {
         $sub_arr = array("tm" => "");
         foreach ($s as &$s_x) {
             $sub_arr["tm"] = $s_x["tm"];
             $stats_key = $s_x["key"] . "_" . $s_x["gender"];
             $sub_arr[$stats_key] = $s_x["sum"];
         }
         $data[$sub_arr["tm"]] = $sub_arr["tm"];
         if ($sub_arr["on_top_users_1"]) {
             $data_1[$sub_arr["tm"]] = $sub_arr["on_top_users_1"];
         } else {
             $data_1[$sub_arr["tm"]] = 0;
         }
         if ($sub_arr["on_top_users_2"]) {
             $data_2[$sub_arr["tm"]] = $sub_arr["on_top_users_2"];
         } else {
             $data_2[$sub_arr["tm"]] = 0;
         }
         array_push($Stats2, $sub_arr);
     }
     $data1 = array();
     $i = 0;
     foreach ($data as $d) {
         if ($stats_date && $stats_date != "") {
             $data1[$i] = substr(substr($d, 0, 13), -2);
         } else {
             $data1[$i] = substr($d, 0, 10);
         }
         $i++;
     }
     $data1_1 = array();
     $i = 0;
     foreach ($data_1 as $d) {
         $data1_1[$i] = $d;
         $i++;
     }
     $data1_2 = array();
     $i = 0;
     foreach ($data_2 as $d) {
         $data1_2[$i] = $d;
         $i++;
     }
     $spmList = Service_Edit::getAllSpm();
     $this->assign('spmarr', json_encode($spmList));
     $c_names = Service_Edit::getSpmMap($spmList);
     $this->assign('spmList', $c_names);
     $this->assign("data_1", json_encode(array_reverse($data1_1)));
     $this->assign("data_2", json_encode(array_reverse($data1_2)));
     $this->assign("data", json_encode(array_reverse($data1)));
     $this->display('admin/user_spread_zaixian');
 }
Beispiel #4
0
 public function addUpdateAction()
 {
     if ($this->isPost()) {
         return;
     }
     $ver = CommonUtil::getComParam(FRequest::getInt("ver"), 0);
     if ($ver == 0) {
         $this->error("ver 版本错误");
         return;
     }
     $table = new FTable("app_version_config");
     $app_data = $table->where(array("ver" => $ver))->find();
     $summary_arr = explode("\n", $app_data["summary"]);
     $app_data["summary"] = $summary_arr;
     $table2 = new FTable("app_version");
     $update_data = $table2->where(array("ver" => $ver))->order(array("tm" => "desc"))->select();
     $this->assign("update_data", $update_data);
     $this->assign("app_version", $app_data);
     $spmList = Service_Edit::getAllSpm();
     $this->assign('spmarr', json_encode($spmList));
     $c_names = Service_Edit::getSpmMap($spmList);
     $this->assign('spmList', $c_names);
     $this->display("add_version");
 }
Beispiel #5
0
 /**
  * 用户地区分部或者年龄分部
  */
 public function ageSpreadAction()
 {
     $c_uid = CommonUtil::getDefStr(FRequest::getString('c_uid'), "");
     $c_sid = CommonUtil::getDefStr(FRequest::getString('c_sid'), "");
     $stats_date = FRequest::getString('stats_date');
     $this->assign('sc_uid', $c_uid);
     $this->assign('sc_sid', $c_sid);
     $this->assign('stats_date', $stats_date);
     $where = array("um.uid" => array("gt" => 5000000));
     if ($c_uid != "") {
         $where["um.channel_uid"] = $c_uid;
     }
     if ($c_sid != "") {
         $where["um.channel_sid"] = $c_sid;
     }
     if ($stats_date) {
         $stm = date("Y-m-d 00:00:00", strtotime($stats_date));
         // 昨天凌晨
         $etm = date("Y-m-d 00:00:00", strtotime($stats_date . "+1 day"));
         $where["str"] = " um.reg_time > '" . $stm . "' and um.reg_time < '" . $etm . "'";
     }
     // 查询用户省份数据
     $user_table = new FTable("user_main", "um");
     $data = $user_table->fields(array("(YEAR(curdate())-YEAR(ud.birthday)) as age", "um.gender", "count(*) as num"))->leftJoin("user_detail", "ud", "um.uid = ud.uid")->groupBy("um.gender,YEAR(ud.birthday)")->where($where)->select();
     // echo(json_encode($data));
     $user_table2 = new FTable("user_main", "um");
     $data2 = $user_table2->fields(array("(YEAR(curdate())-YEAR(ud.birthday)) as age", "count(*) as num"))->leftJoin("user_detail", "ud", "um.uid = ud.uid")->groupBy("YEAR(ud.birthday)")->where($where)->order(array("num" => "desc"))->limit(30)->select();
     $rs = array("default" => array("1" => 0, "2" => 0));
     $p_arr = array();
     foreach ($data2 as $ages) {
         $age = $ages["age"];
         if (!$age || empty($age)) {
             $age = "缺省";
         }
         array_push($p_arr, $age);
     }
     foreach ($data as $d) {
         $rm = array("1" => 0, "2" => 0);
         $age = $d["age"];
         if (!$age || empty($age)) {
             $age = "缺省";
         }
         $gender = $d["gender"];
         if (array_key_exists($age, $rs)) {
             $rm = $rs[$age];
         }
         $rm[$gender] += $d["num"];
         $rs[$age] = $rm;
     }
     $data_1 = array();
     $data_2 = array();
     foreach ($p_arr as $p) {
         $d = $rs[$p];
         $d_1 = 0;
         $d_2 = 0;
         if ($d && $d["1"]) {
             $d_1 = $d["1"];
         }
         if ($d && $d["2"]) {
             $d_2 = $d["2"];
         }
         $data_1[count($data_1)] = $d_1;
         $data_2[count($data_2)] = $d_2;
     }
     $spmList = Service_Edit::getAllSpm();
     $this->assign('spmarr', json_encode($spmList));
     $c_names = Service_Edit::getSpmMap($spmList);
     $this->assign('spmList', $c_names);
     $this->assign("data_1", json_encode($data_1));
     $this->assign("data_2", json_encode($data_2));
     $this->assign("ages", json_encode($p_arr));
     $this->display('admin/user_age_spread');
 }
Beispiel #6
0
 /**
  * 主报表查询
  */
 public function reportAction()
 {
     //global $_F;
     //$_F["debug"] = true;
     $page_size = 30;
     $page = max(1, FRequest::getInt('page'));
     $c_uid = CommonUtil::getDefStr(FRequest::getString('c_uid'), "");
     $user_gender = CommonUtil::getComParam(FRequest::getInt('user_gender'), -1);
     $stats_date = FRequest::getString('stats_date');
     $stats_key = FRequest::getString('stats_key');
     $province = FRequest::getString('province');
     $ver = FRequest::getString('ver');
     $table = new FTable("user_province_area");
     $user_province = $table->groupBy("province")->order(array("id" => "asc"))->select();
     $this->assign('user_province', $user_province);
     $this->assign('province', $province);
     $this->assign('ver', $ver);
     if (!$stats_key) {
         $stats_key = "online_award_users";
         // $stats_key="on_top_users";
         //            $this->showMessage("查询留存不能为空",error,"/admin/ReportLiucun/default");
         //
         //        return;
         //            exit;
     }
     $where = array("s.interval" => "day");
     if ($c_uid != "") {
         $where["channel"] = $c_uid;
     }
     if ($user_gender >= 0) {
         $where["gender"] = $user_gender;
     }
     if ($province) {
         $where["province"] = $province;
     }
     if ($ver) {
         $where["ver"] = $ver;
     }
     $stats_key0 = $stats_key . "_lc_0";
     $stats_key1 = $stats_key . "_lc_1";
     $stats_key2 = $stats_key . "_lc_2";
     $stats_key3 = $stats_key . "_lc_3";
     $stats_key4 = $stats_key . "_lc_4";
     $stats_key5 = $stats_key . "_lc_5";
     $stats_key6 = $stats_key . "_lc_6";
     $stats_key7 = $stats_key . "_lc_7";
     $stats_key15 = $stats_key . "_lc_15";
     $stats_key30 = $stats_key . "_lc_30";
     $stats_key_array = array("'register'", "'" . $stats_key0 . "'", "'" . $stats_key1 . "'", "'" . $stats_key2 . "'", "'" . $stats_key3 . "'", "'" . $stats_key4 . "'", "'" . $stats_key5 . "'", "'" . $stats_key6 . "'", "'" . $stats_key7 . "'", "'" . $stats_key15 . "'", "'" . $stats_key30 . "'");
     $fields = array("s.tm", "s.key", "sum(s.value) as sum");
     //echo(json_encode($stats_key_array));
     $where["s.key"] = array('in' => $stats_key_array);
     $datetime_riqi_qiantian = date("Y-m-d", time() - 86400);
     $query_str = " s.tm <= '" . $datetime_riqi_qiantian . " 00:00:00'  ";
     $where["str"] = $query_str;
     $table2 = new FTable("Stat", "s", FDB::$DB_MUMU_STAT);
     $total_rs = $table2->fields($fields)->where($where)->groupBy("s.tm")->order(array("s.tm" => "desc"))->select();
     //echo(json_encode($where));
     $total = count($total_rs);
     $jieshu_time = $total_rs[$page_size * $page - $page_size][tm];
     if ($page_size * $page > $total) {
         $kaishi_time = $total_rs[$total - 1][tm];
     } else {
         $kaishi_time = $total_rs[$page_size * $page - 1][tm];
     }
     //echo($kaishi_time.$jieshu_time);
     if ($total > 0) {
         $query_str = " s.tm >= '" . $kaishi_time . "' and  s.tm <= '" . $jieshu_time . "'   ";
         $where["str"] = $query_str;
     }
     $table = new FTable("Stat", "s", FDB::$DB_MUMU_STAT);
     $Stat = $table->fields($fields)->where($where)->groupBy("s.tm,s.key")->order(array("s.tm" => "desc"))->select();
     $Stats = array();
     foreach ($Stat as &$s) {
         $sub_arr = array();
         $s["tm"] = substr($s["tm"], 0, 10);
         if (array_key_exists($s["tm"], $Stats)) {
             $sub_arr = $Stats[$s["tm"]];
         }
         array_push($sub_arr, $s);
         $Stats[$s["tm"]] = $sub_arr;
         //            $where["s.tm"] = $s["tm"];
         //            $where["s.key"] = "register";
         //            $table = new FTable("Stat","s",FDB::$DB_MUMU_STAT);
         //            $data = $table->fields(array("sum(s.value) as sum" )) ->where($where)->find();
         //            $s["register"] = $data["sum"];
         //
         //
         //            if ($stats_key) { $where["s.key"] = $stats_key1;  }
         //         $table1 = new FTable("Stat","s",FDB::$DB_MUMU_STAT);
         //            $data1 = $table1->fields(array("sum(s.value) as sum" )) ->where($where)->find();
         //            $s["stats_key1"] = $data1["sum"];
         //            if ($stats_key) { $where["s.key"] = $stats_key2;  }
         //            $table2 = new FTable("Stat","s",FDB::$DB_MUMU_STAT);
         //            $data2 = $table2->fields(array("sum(s.value) as sum" )) ->where($where)->find();
         //            $s["stats_key2"] = $data2["sum"];
         //            if ($stats_key) { $where["s.key"] = $stats_key3;  }
         //            $table3 = new FTable("Stat","s",FDB::$DB_MUMU_STAT);
         //            $data3 = $table3->fields(array("sum(s.value) as sum")) ->where($where)->find();
         //            $s["stats_key3"] = $data3["sum"];
         //            if ($stats_key) { $where["s.key"] = $stats_key4;  }
         //            $table4 = new FTable("Stat","s",FDB::$DB_MUMU_STAT);
         //            $data4 = $table4->fields(array("sum(s.value) as sum")) ->where($where)->find();
         //            $s["stats_key4"] = $data4["sum"];
         //            if ($stats_key) { $where["s.key"] = $stats_key5;  }
         //            $table5 = new FTable("Stat","s",FDB::$DB_MUMU_STAT);
         //            $data5 = $table5->fields(array("sum(s.value) as sum")) ->where($where)->find();
         //            $s["stats_key5"] = $data5["sum"];
         //            if ($stats_key) { $where["s.key"] = $stats_key6;  }
         //            $table6 = new FTable("Stat","s",FDB::$DB_MUMU_STAT);
         //            $data6 = $table6->fields(array("sum(s.value) as sum")) ->where($where)->find();
         //            $s["stats_key6"] = $data6["sum"];
         //            if ($stats_key) { $where["s.key"] = $stats_key7;  }
         //            $table7 = new FTable("Stat","s",FDB::$DB_MUMU_STAT);
         //            $data7 = $table7->fields(array("sum(s.value) as sum")) ->where($where)->find();
         //            $s["stats_key7"] = $data7["sum"];
         //            if ($stats_key) { $where["s.key"] = $stats_key15;  }
         //            $table15 = new FTable("Stat","s",FDB::$DB_MUMU_STAT);
         //            $data15 = $table15->fields(array("sum(s.value) as sum")) ->where($where)->find();
         //            $s["stats_key15"] = $data15["sum"];
         //            if ($stats_key) { $where["s.key"] = $stats_key30;  }
         //            $table30 = new FTable("Stat","s",FDB::$DB_MUMU_STAT);
         //            $data30 = $table30->fields(array("sum(s.value) as sum")) ->where($where)->find();
         //            $s["stats_key30"] = $data30["sum"];
         //$s["stats_date"] = substr($s["tm"],0,10);
     }
     /*print_r($Stats);*/
     $Stats2 = array();
     foreach ($Stats as &$s) {
         $sub_arr = array("tm" => "", "register" => 0, $stats_key0 => 0, $stats_key1 => 0, $stats_key2 => 0, $stats_key3 => 0, $stats_key4 => 0, $stats_key5 => 0, $stats_key6 => 0, $stats_key7 => 0, $stats_key15 => 0, $stats_key30 => 0);
         foreach ($s as &$s_x) {
             $sub_arr["tm"] = $s_x["tm"];
             if ($s_x["key"] == "register") {
                 $sub_arr["register"] = $s_x["sum"];
             }
             if ($s_x["key"] == $stats_key0) {
                 $sub_arr[$stats_key0] = $s_x["sum"];
             }
             if ($s_x["key"] == $stats_key1) {
                 $sub_arr[$stats_key1] = $s_x["sum"];
             }
             if ($s_x["key"] == $stats_key2) {
                 $sub_arr[$stats_key2] = $s_x["sum"];
             }
             if ($s_x["key"] == $stats_key3) {
                 $sub_arr[$stats_key3] = $s_x["sum"];
             }
             if ($s_x["key"] == $stats_key4) {
                 $sub_arr[$stats_key4] = $s_x["sum"];
             }
             if ($s_x["key"] == $stats_key5) {
                 $sub_arr[$stats_key5] = $s_x["sum"];
             }
             if ($s_x["key"] == $stats_key6) {
                 $sub_arr[$stats_key6] = $s_x["sum"];
             }
             if ($s_x["key"] == $stats_key7) {
                 $sub_arr[$stats_key7] = $s_x["sum"];
             }
             if ($s_x["key"] == $stats_key15) {
                 $sub_arr[$stats_key15] = $s_x["sum"];
             }
             if ($s_x["key"] == $stats_key30) {
                 $sub_arr[$stats_key30] = $s_x["sum"];
             }
         }
         array_push($Stats2, $sub_arr);
     }
     //echo(json_encode($Stats2));
     // $total = count($Stats);
     $page_info = FPager::getPagerInfo($total, $page, $page_size);
     $spmList = Service_Edit::getAllSpm();
     $this->assign('spmarr', json_encode($spmList));
     $c_names = Service_Edit::getSpmMap($spmList);
     $this->assign('spmList', $c_names);
     $this->assign('page_info', $page_info);
     $this->assign('Stat', $Stats2);
     $this->assign('stats_key', $stats_key);
     $this->assign('sc_uid', $c_uid);
     $this->assign('user_gender', $user_gender);
     $this->assign('stats_date', $stats_date);
     $this->assign('stats_key0', $stats_key0);
     $this->assign('stats_key1', $stats_key1);
     $this->assign('stats_key2', $stats_key2);
     $this->assign('stats_key3', $stats_key3);
     $this->assign('stats_key4', $stats_key4);
     $this->assign('stats_key5', $stats_key5);
     $this->assign('stats_key6', $stats_key6);
     $this->assign('stats_key7', $stats_key7);
     $this->assign('stats_key15', $stats_key15);
     $this->assign('stats_key30', $stats_key30);
     $this->display('admin/stats_liucun');
 }