public function profile() { $profile['user_id'] = $this->me['id']; $avatar = $this->input->post("avatar_url"); $fav_tag = $this->input->post("fav_tag"); $profile['type'] = $this->input->post("type"); $profile['company'] = $this->input->post("company"); $profile['station'] = $this->input->post("station"); $profile['school'] = $this->input->post("school"); $profile['professional'] = $this->input->post("professional"); if ($avatar) { ModelFactory::User()->edit($this->me['id'], ['avatar' => $avatar]); } $tags = explode(' ', $fav_tag); foreach ($tags as $tag) { $trim = trim($tag); if ($trim) { $tag = ModelFactory::Tag()->get_tag_withtype($tag); if (!$tag && $trim) { ModelFactory::Tag()->add_tag($tag); $tag = ModelFactory::Tag()->get_tag_withtype($tag); } $is_col = ModelFactory::Tag()->is_collect_tag($tag['id']); if (!$is_col) { ModelFactory::Tag()->collect_tag($tag['id']); } } } if (!($pro = ModelFactory::UserProfile()->getbyuserid($this->me['id']))) { ModelFactory::UserProfile()->create($profile); } else { ModelFactory::UserProfile()->edit($pro['id'], $profile); } header("location: /home?home=index&uid=" . $this->me['id']); }
public function index() { $userdata = $this->user_model->check_login(); // 课程处理通用Tab $userdata['type_name'] = $this->input->get('type'); if (isset($_GET['type'])) { switch ($userdata['type_name']) { case 'u3d': $type = 0; break; case 'Egret': $type = 1; break; case 'Web': $type = 2; break; case 'Cocos2d-x': $type = 3; break; case 'Android': $type = 4; break; default: $type = 0; $userdata['type_name'] = "u3d"; break; } $userdata['types'] = $type; } else { $userdata['types'] = 0; $userdata['type_name'] = "u3d"; } // 分页通用 $userdata["page"] = !isset($_GET['page']) ? "1" : $this->input->get("page"); $userdata['page_max'] = $this->user_model->get_count(array("type" => 1, "father_tag" => $userdata['types'])); $userdata['data'] = (array) $this->user_model->get_god_list(array("type" => 1, "father_tag" => $userdata['types']), $userdata["page"] - 1, 10); foreach ($userdata['data'] as $key => $god) { $level_id = ModelFactory::User()->get_god_level(0, $god); $level_name = ModelFactory::User()->get_god_level_name($level_id); $god['level_name'] = $level_name; $userdata['data'][$key] = $god; } $this->load->view('miaoda/god/list.php', $userdata); }
function week_integral_rank() { $date = date('Y-m-d'); //当前日期 $first = 1; //$first =1 表示每周星期一为开始日期 0表示每周日为开始日期 $w = date('w', strtotime($date)); //获取当前周的第几天 周日是 0 周一到周六是 1 - 6 $now_start = date('Y-m-d', strtotime("{$date} -" . ($w ? $w - $first : 6) . ' days')); //获取本周开始日期,如果$w是0,则表示周日,减去 6 天 $now_end = date('Y-m-d', strtotime("{$now_start} +6 days")); //本周结束日期 $last_start = date('Y-m-d', strtotime("{$now_start} - 7 days")); //上周开始日期 $last_end = date('Y-m-d', strtotime("{$now_start} - 1 days")); //上周结束日期 echo '本周开始日期:', $now_start, '<br />'; echo '本周结束日期:', $now_end, '<br />'; echo '上周开始日期:', $last_start, '<br />'; echo '上周结束日期:', $last_end, '<br />'; $peoples = ModelFactory::Changelog()->groupBy(['type' => CONSTFILE::USER_INTEGRAL, 'created_at >=' => strtotime("{$now_start} - 7 days"), 'created_at <=' => strtotime("{$now_start} - 1 days")], 20); if ($peoples) { foreach ($peoples as $key => $people) { $key = $key + 1; if ($key == 1) { ModelFactory::User()->coin($people['user_id'], 200, true, 'silver_coin', CONSTFILE::CHANGE_LOG_COUNT_TYPE_INTEGRAL_TOP); } if ($key >= 2 && $key <= 5) { ModelFactory::User()->coin($people['user_id'], 100, true, 'silver_coin', CONSTFILE::CHANGE_LOG_COUNT_TYPE_INTEGRAL_TOP); } if ($key >= 6 && $key <= 20) { ModelFactory::User()->coin($people['user_id'], 50, true, 'silver_coin', CONSTFILE::CHANGE_LOG_COUNT_TYPE_INTEGRAL_TOP); } } } }
public function sign() { parent::require_login(); $id = $this->me['id']; $userdata = ModelFactory::User()->get_user($id); $sign = ModelFactory::User()->is_sign($id, $userdata); if ($sign) { parent::finish(false, "今日已签到!"); } $keep = ModelFactory::User()->is_keep_sign($id, $userdata); try { ModelFactory::User()->begin(); $result = ModelFactory::User()->sign($id, date('Y-m-d'), $keep + 1); if ($keep) { $update_integral_result = ModelFactory::User()->Integral($id, 20 * ($keep + 1), true); $silver_coin = 10 + $keep * 5; if ($silver_coin > 50) { $silver_coin = 50; } $update_coin_result = ModelFactory::User()->coin($id, $silver_coin, true, 'silver_coin'); } else { $update_integral_result = ModelFactory::User()->Integral($id, 20, true); $update_coin_result = ModelFactory::User()->coin($id, 10, true, 'silver_coin'); } if ($result && $update_coin_result && $update_integral_result) { ModelFactory::User()->commit(); parent::finish(true, '签到成功!'); } else { ModelFactory::User()->rollback(); parent::finish(false, "签到失败!"); } } catch (Exception $e) { ModelFactory::User()->rollback(); parent::finish(false, "数据库异常"); } }
public function invite() { $userdata = ModelFactory::User()->check_login(); $id = $userdata['id']; if (!$id) { show_error("请先登录!", null, '提示'); } $userdata['qqshare'] = site_url('share?' . http_build_query(['type' => 'qq', 'from' => 'invite'])); $userdata['qqzshare'] = site_url('share?' . http_build_query(['type' => 'qqz', 'from' => 'invite'])); $userdata['sinashare'] = site_url('share?' . http_build_query(['type' => 'sina', 'from' => 'invite'])); $userdata['invate_url'] = base_url('/share/people?' . http_build_query(['trace' => base64_encode($id), 'from_invite' => 1])); $this->parser->parse("share/invite.php", $userdata); }
</div> <div class="login-content cf"> <div style="text-align: center; position: relative; margin-top: 50px;"> <p style="font-size: 30px; color: #0092a4; ">全新秒答,任性壕礼</p> </div> <div style="margin:0 auto;width:200px; relative; margin-top: 20px;"> <form action="/godHelp/gift"> <input type="submit" value="去看看" id="ajax_login" > </form> </div> </div> </div> <?php $userinfo = ModelFactory::User()->check_login(); ?> <form method="post" action="/userset/profile" style="margin-top:45px"> <div class="regist-box" style="<?php if (isset($_GET['editprofile'])) { echo 'display:block;'; } else { echo 'display:none;'; } ?> "> <dl class="reg-top c"> <dt><img src="<?php echo '/static/login/images/head.png'; ?>
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 login() { $params = parent::get_params('POST', array('name', 'pwd', 'vcode', 'remind')); extract($params); if (!trim($params['name'])) { parent::finish(false, '用户名不能为空!'); } if (!trim($params['pwd'])) { parent::finish(false, '密码不能为空!'); } if (md5($params['vcode']) != $_SESSION["verification"]) { parent::finish(false, '验证码错误!'); } if ($params['remindme'] == 'yes') { $this->load->helper('cookie'); $cookie = $this->input->cookie('ci_session'); $this->input->set_cookie('ci_session', $cookie, '35580000'); } $result = ModelFactory::User()->login($name, $pwd); if ($result === false) { parent::finish(false, '用户名或密码错误'); } parent::finish(true, '', $result); }
public function index() { $date = date('Y-m-d'); //当前日期 $first = 1; //$first =1 表示每周星期一为开始日期 0表示每周日为开始日期 $w = date('w', strtotime($date)); //获取当前周的第几天 周日是 0 周一到周六是 1 - 6 $now_start = date('Y-m-d', strtotime("{$date} -" . ($w ? $w - $first : 6) . ' days')); //获取本周开始日期,如果$w是0,则表示周日,减去 6 天 $now_end = date('Y-m-d', strtotime("{$now_start} +6 days")); //本周结束日期 $last_start = date('Y-m-d', strtotime("{$now_start} - 7 days")); //上周开始日期 $last_end = date('Y-m-d', strtotime("{$now_start} - 1 days")); //上周结束日期 echo '本周开始日期:', $now_start, '<br />'; echo '本周结束日期:', $now_end, '<br />'; echo '上周开始日期:', $last_start, '<br />'; echo '上周结束日期:', $last_end, '<br />'; $peoples = ModelFactory::Changelog()->groupBy(['type' => CONSTFILE::USER_INTEGRAL], 20); if ($peoples) { foreach ($peoples as $key => $people) { $key = $key + 1; if ($key == 1) { ModelFactory::User()->coin($people['user_id'], 200, true, 'silver_coin', CONSTFILE::CHANGE_LOG_COUNT_TYPE_INTEGRAL_TOP); } if ($key >= 2 && $key <= 5) { ModelFactory::User()->coin($people['user_id'], 100, true, 'silver_coin', CONSTFILE::CHANGE_LOG_COUNT_TYPE_INTEGRAL_TOP); } if ($key >= 6 && $key <= 20) { ModelFactory::User()->coin($people['user_id'], 50, true, 'silver_coin', CONSTFILE::CHANGE_LOG_COUNT_TYPE_INTEGRAL_TOP); } } } $date = date('Y-m-d'); //当前日期 $first = 1; //$first =1 表示每周星期一为开始日期 0表示每周日为开始日期 $w = date('w', strtotime($date)); //获取当前周的第几天 周日是 0 周一到周六是 1 - 6 $now_start = date('Y-m-d', strtotime("{$date} -" . ($w ? $w - $first : 6) . ' days')); //获取本周开始日期,如果$w是0,则表示周日,减去 6 天 $now_end = date('Y-m-d', strtotime("{$now_start} +6 days")); //本周结束日期 $last_start = date('Y-m-d', strtotime("{$now_start} - 7 days")); //上周开始日期 $last_end = date('Y-m-d', strtotime("{$now_start} - 1 days")); //上周结束日期 echo '本周开始日期:', $now_start, '<br />'; echo '本周结束日期:', $now_end, '<br />'; echo '上周开始日期:', $last_start, '<br />'; echo '上周结束日期:', $last_end, '<br />'; $peoples = ModelFactory::Changelog()->groupBy(['type' => CONSTFILE::USER_INTEGRAL], 20); if ($peoples) { foreach ($peoples as $key => $people) { $key = $key + 1; if ($key == 1) { ModelFactory::User()->coin($people['user_id'], 200, true, 'silver_coin', CONSTFILE::CHANGE_LOG_COUNT_TYPE_INTEGRAL_TOP); } if ($key >= 2 && $key <= 5) { ModelFactory::User()->coin($people['user_id'], 100, true, 'silver_coin', CONSTFILE::CHANGE_LOG_COUNT_TYPE_INTEGRAL_TOP); } if ($key >= 6 && $key <= 20) { ModelFactory::User()->coin($people['user_id'], 50, true, 'silver_coin', CONSTFILE::CHANGE_LOG_COUNT_TYPE_INTEGRAL_TOP); } } } $is_keep = ModelFactory::Usertask()->is_keep_answer($id); ModelFactory::Usertask()->answer_sign($id, date('Y-m-d'), $is_keep + 1); exit; $sign = ModelFactory::User()->coin($id, 3000, true, 'silver_coin'); var_dump($sign); exit; // $sign = ModelFactory::User()->is_sigin($id,['date'=>'2015-08-17','time'=>1]); $userdata = ModelFactory::User()->get_user($id); $sign = ModelFactory::User()->is_sigin($id, $userdata); $keep = ModelFactory::User()->is_keep_sign($id, $userdata); if ($keep) { ModelFactory::User()->sigin($id, date('Y-m-d'), $keep + 1); echo "lx\n"; exit; } else { ModelFactory::User()->sigin($id, date('Y-m-d'), 1); echo "pm\n"; } var_dump($sign); }
/** * 编辑用户信息 * @return [type] [description] */ public function editData() { parent::require_login(); $params = parent::get_params('POST', array("nickname", "name", "email", "cellphone", "alipay", "type")); if (empty($params)) { return; } extract($params); $id = $this->input->post("id"); /* $teacher = !isset($_POST['teacher']) ? false : true; if(isset($_POST['teacher'])){ $params['teacher'] = 1; }else{ $params['teacher'] = 0; } */ $edit_gold_coin = $this->input->post('edit_gold_coin'); $edit_silver_coin = $this->input->post('edit_silver_coin'); $edit_Integral = $this->input->post('edit_Integral'); if ($edit_gold_coin) { ModelFactory::User()->coin($id, $edit_gold_coin, $edit_gold_coin > 0, 'gold_coin', CONSTFILE::CHANGE_LOG_COUNT_TYPE_ADMIN); } if ($edit_silver_coin) { ModelFactory::User()->coin($id, $edit_silver_coin, $edit_silver_coin > 0, 'silver_coin', CONSTFILE::CHANGE_LOG_COUNT_TYPE_ADMIN); } if ($edit_Integral) { ModelFactory::User()->coin($id, $edit_Integral, $edit_Integral > 0, 'Integral', CONSTFILE::CHANGE_LOG_COUNT_TYPE_ADMIN); } $type = $this->input->post('type'); $do_task = ModelFactory::Usertask()->get_count(['user_id' => $id, 'task_id' => CONSTFILE::USER_TASK_AUDIT_GOD_OK]); if ($type == 1 && !$do_task) { $user_data = ModelFactory::User()->get_user($id); if ($user_data['parent_id']) { $parent_user_data = ModelFactory::User()->get_user($user_data['parent_id']); if ($parent_user_data['parent_id'] != $id && !$do_task) { ModelFactory::Usertask()->create(['user_id' => $id, 'created_at' => time(), 'task_id' => CONSTFILE::USER_TASK_AUDIT_GOD_OK]); ModelFactory::User()->coin($user_data['parent_id'], 20, true, 'prestige', CONSTFILE::CHANGE_LOG_COUNT_TYPE_AUDIT_GOD_OK); } } } $password = $this->input->post("password"); if ($password != "") { $userdata = $this->user_model->get(array("id" => $id)); $params['pwd'] = md5($password . $userdata['salt']); } if ($this->user_model->edit($id, $params)) { $this->finish(true); } else { $this->finish(false, "无法修改用户资料"); } }
public function week() { $userdata = ModelFactory::User()->check_login(); $id = $userdata['id']; $price_list = $this->cache()->get('price_list'); if (!$price_list) { $price_list = ModelFactory::Pricelist()->get_list([]); if ($price_list) { $this->cache()->save('price_list', $price_list, 600); } else { $this->cache()->save('price_list', [], 5); } } $silver_get = 0; if ($id) { $silver_get = $this->getUserTask($userdata, CONSTFILE::USER_TASK_HUODONG_SILVER_CION); } $userdata['qqshare'] = site_url('share?' . http_build_query(['type' => 'qq', 'from' => 'xiaobai'])); $userdata['qqzshare'] = site_url('share?' . http_build_query(['type' => 'qqz', 'from' => 'xiaobai'])); $userdata['sinashare'] = site_url('share?' . http_build_query(['type' => 'sina', 'from' => 'xiaobai'])); $userdata['invate_url'] = base_url('/share/people?' . http_build_query(['trace' => base64_encode($id), 'from_invite' => 1])); $userdata['silver_get'] = $silver_get; $userdata['price_list'] = $price_list; $userdata['me'] = $this->me; $this->load->view("help/week.php", $userdata); }
public function active($key = '') { if ($key === '') { show_404(); } if ($this->me === false) { show_404(); } if ($this->me['key'] !== $key) { echo '无效激活码'; return; } if ($this->me['email_active'] == 1) { echo '该账户已激活'; return; } $resutl = $this->user_model->edit($this->me['id'], array('email_active' => 1)); if ($resutl) { ModelFactory::User()->coin($this->me['id'], 300, true, 'silver_coin', CONSTFILE::CHANGE_LOG_COUNT_TYPE_CLICK_EMAIL_ACTIVE); } $this->load->model('news_model'); $this->news_model->create(array('target' => $this->me['id'], 'type' => '002')); redirect('userset'); }
public function debug() { $dd = '{"openid":"oqxzrssbmhrcqYWFdS2bwN3epmQk","nickname":"星火","sex":1,"language":"zh_CN","city":"Hangzhou","province":"Zhejiang","country":"CN","headimgurl":"123","privilege":[],"unionid":"oQrBswSYRdpUk61PIRZgtlycNXqY"}'; $userinfo = json_decode($dd, 1); if (isset($userinfo['openid'])) { $this->load->helper('cookie'); $parent_id = get_cookie('parent_id'); $parent_id = $parent_id ? $parent_id : 0; $key = 'weixin:' . $userinfo['openid']; $user = ModelFactory::User()->get_by_oauth($key); $first = 'yes'; if (!$user) { $params = ['email' => $userinfo['openid'], 'oauth_key' => $key, 'nickname' => $userinfo['nickname'], 'pwd' => $userinfo['openid'], 'avatar' => $userinfo['headimgurl'], 'parent_id' => $parent_id]; $true = ModelFactory::User()->create($params); if ($true == "该邮箱已被使用") { $params['nickname'] = $userinfo['nickname'] . mt_rand(40000, 90000); $params['email'] = $userinfo['nickname'] . mt_rand(40000, 90000); $true = ModelFactory::User()->create($params); } if ($true == "'该邮箱已被使用'") { $params['nickname'] = $userinfo['nickname'] . mt_rand(40000, 90000); $params['email'] = $userinfo['nickname'] . mt_rand(40000, 90000); $true = ModelFactory::User()->create($params); } if ($true) { $first = 'yes'; $user = $params; $user['id'] = $true; } } ModelFactory::User()->login_by_oauth($user['id']); } if ($first == 'yes') { echo "<script>window.opener.openprofile();window.close();</script>"; exit; } else { echo "<script>window.opener.location.reload();window.close();</script>"; exit; } }
"> <dl class="reg-top c"> <dt><img src="<?php echo '/static/login/images/head.png'; ?> " width="96" height="96" /></dt> <dd> <h2>感谢您加入秒答</h2> <p class="m-b10">不要害羞,介绍一下自己吧...</p> <!-- 4 qq 2 wx 3 weibo--> <!-- <P><span class="reg-icon1"></span>微博<span class="wb-add">(--><?php //echo $userinfo['email']; ?> <!--)</span></P>--> <P><span class="<?php echo ModelFactory::User()->getUserType($userinfo); ?> "></span><span class="wb-add"><?php echo $userinfo['email']; ?> </span></P> </dd> </dl> <div class="reg-con c"> <div class="reg-left"> <P><img src="<?php if (isset($userinfo['avatar'])) { echo $userinfo['avatar']; } else { echo '/static/login/images/head1.png'; }
public function up_problem() { $up_down_type = false; $temp = array(); parent::require_login(); $params = $this->get_params('POST', array('problem_id')); extract($params); $return_data = ModelFactory::Problem()->get_problem($problem_id); $up_users = json_decode($return_data[0]['up_users']); if ($return_data && $return_data[0]['up_count'] >= 20 && $return_data[0]['is_prestige'] != 1) { $god_level = ModelFactory::User()->get_god_level($return_data[0]['answer_id']); $cg_value = 0; if ($god_level >= 1 && $god_level <= 2) { $cg_value = 5; } if ($god_level <= 7 && $god_level >= 3) { $cg_value = 8; } if ($god_level <= 10 && $god_level >= 8) { $cg_value = 15; } if ($cg_value) { try { ModelFactory::Usertask()->begin(); $r2 = ModelFactory::Problem()->edit($problem_id, ['is_prestige' => 1]); if ($r2) { ModelFactory::User()->coin($return_data[0]['answer_id'], $cg_value, true, 'prestige', CONSTFILE::CHANGE_LOG_COUNT_TYPE_ZAN); ModelFactory::Usertask()->commit(); } else { ModelFactory::Usertask()->rollback(); } } catch (Exception $e) { ModelFactory::Usertask()->rollback(); } } } foreach ($up_users as $key => $value) { if ($value->id != $this->me['id']) { array_push($temp, array("id" => $value->id)); } else { $up_down_type = true; } } $up_users = $temp; if ($up_down_type == true) { //取消点赞 if ($this->problem_model->up(array("id" => $problem_id, "up_count" => $return_data[0]["up_count"] - 1, "hot" => $return_data[0]["hot"] - 5, "up_users" => json_encode($up_users)))) { // 积分需求 ModelFactory::User()->Integral($this->me['id'], CONSTFILE::USER_ACTION_ZAN_INTEGRAL_VALUE, false, 'Integral', CONSTFILE::CHANGE_LOG_COUNT_TYPE_CLICK_ZAN); ModelFactory::User()->coin($this->me['id'], CONSTFILE::USER_ACTION_ZAN_SILVER_VALUE, false, 'silver_coin', CONSTFILE::CHANGE_LOG_COUNT_TYPE_CLICK_ZAN); $this->finish(true, "", "1"); } else { $this->finish(false, "未知的网络原因导致操作失败"); } } else { array_push($up_users, array("id" => $this->me['id'])); if ($this->problem_model->up(array("id" => $problem_id, "up_count" => $return_data[0]["up_count"] + 1, "hot" => $return_data[0]["hot"] + 5, "up_users" => json_encode($up_users)))) { ModelFactory::User()->coin($this->me['id'], CONSTFILE::USER_ACTION_ZAN_SILVER_VALUE, true, 'silver_coin', CONSTFILE::CHANGE_LOG_COUNT_TYPE_CLICK_ZAN); ModelFactory::User()->Integral($this->me['id'], CONSTFILE::USER_ACTION_ZAN_INTEGRAL_VALUE, true, 'Integral', CONSTFILE::CHANGE_LOG_COUNT_TYPE_CLICK_ZAN); $this->finish(true, "", "0"); } else { $this->finish(false, "未知的网络原因导致操作失败"); } } }