function stats() { if ($this->admin_model->require_login() === false) { redirect('admin/login'); } $page = !isset($_GET['page']) ? "1" : $this->input->get("page"); $pid = $this->input->get('pid', 1); $args = $this->uri->uri_to_assoc(); if (!$pid) { if (isset($args['pid'])) { $pid = $args['pid']; } } $where = []; if ($pid) { $where = array("nickname" => urldecode($pid)); $data = ModelFactory::User()->get($where); $where = array("parent_id" => $data['id']); } $per_page = 40; $userdata["list"] = ModelFactory::Invitehistory()->get_list($where, $page - 1, $per_page); foreach ($userdata["list"] as &$user) { $user['user_info'] = ModelFactory::User()->get_user_data($user['user_id']); $user['pt_info'] = ModelFactory::User()->get_user_data($user['parent_id']); } $count = ModelFactory::Invitehistory()->get_count($where); $userdata['count'] = $count; $userdata['page_url'] = "/admin/stats"; if ($pid) { $userdata['page_url'] .= '/pid/' . $pid; } // echo $count;exit; $this->parser->parse('admin/stats.php', $userdata); }
public function check_login() { $id = $this->session->userdata($this->id_name); if (!isset($id)) { return false; } $userdata = $this->get(array("id" => $id)); if ($userdata["avatar"] == NULL) { $userdata["avatar"] = "static/image/default.jpg"; } $this->load->model("news_model"); $userdata['news_nuw'] = $this->news_model->get_count(array("target" => $id, "status" => 0)); return $userdata; } public function get_user_data($id) { $userdata = parent::get(array("id" => $id)); $userdata["skilled_tags"] = $this->tag_model->get_list_by_json($userdata['skilled_tags']); if (count($userdata) <= 0) { return false; } if (@$userdata["avatar"] == NULL) { @($userdata["avatar"] = "static/image/default.jpg"); } return $userdata; } // email, nickname, pwd public function create($params) { extract($params); $oauthkey = isset($params['oauth_key']) ? $params['oauth_key'] : false; if ($this->is_exist(array('email' => $email))) { return '该邮箱已被使用'; } if ($this->is_exist(array('nickname' => $nickname))) { return '该昵称已被使用';
public function get_invite() { $userdata = ModelFactory::User()->check_login(); if (!$userdata) { echo json_encode(['result' => false]); return; } $where = ['parent_id' => $userdata['id']]; $id = ModelFactory::Invitehistory()->getInviteKey($userdata); $list = $this->cache()->get($id); if (!$list) { $list = (array) ModelFactory::Invitehistory()->get_list($where, 0, 10); foreach ($list as &$user) { $user['avatar'] = "static/image/default.jpg"; $get_user = ModelFactory::User()->get(array("id" => $user['user_id'])); if ($get_user) { $user['avatar'] = $get_user['avatar']; } } if (count($list) == 10) { // $this->cache()->save($id,$list,86400); } else { // $this->cache()->save($id,$list,86400); } } echo json_encode(['list' => $list]); }