예제 #1
0
파일: game.php 프로젝트: sherdog/wnd
 public function gamedata($playerID = null, $return = false)
 {
     Validate::player($playerID);
     //we are going to pass all data's
     $array = array();
     //this is what we store the data in.
     $player = new PlayerModel();
     $level = new LevelModel();
     $playerLevel = new PlayerLevelModel($playerID);
     $store = new StoreModel();
     $abModel = new ABModel();
     $rankModel = new RankModel();
     $array['status'] = 'ok';
     $array['player'] = $player->getPlayerData(array($playerID, false));
     $array['featuretests'] = $abModel->getTests($playerID);
     $array['scores'] = $playerLevel->load($playerID);
     $array['stores'] = $store->getStores();
     $array['gifts'] = $player->getGifts($playerID);
     $array['liferequests'] = $player->getRequests($playerID);
     $array['levels'] = $level->getLevelData();
     $array['ranks'] = $rankModel->getRanks();
     $levelData = null;
     $tmpObject = null;
     if ($return) {
         return $array;
     } else {
         $this->printJson($array);
     }
 }
예제 #2
0
 private function update()
 {
     if (isset($_POST['send'])) {
         $this->_model->id = $_POST['id'];
         if (trim($_POST['admin_pass']) == '') {
             $this->_model->admin_pass = $_POST['pass'];
         } else {
             if (Validate::checkLength($_POST['admin_pass'], 6, 'min')) {
                 Tool::alertBack('警告:密码不得小于六位!');
             }
             $this->_model->admin_pass = sha1($_POST['admin_pass']);
         }
         $this->_model->level = $_POST['level'];
         $this->_model->updateManage() ? Tool::alertLocation('恭喜你,修改管理员成功!', $_POST['prev_url']) : Tool::alertBack('很遗憾,修改管理员失败!');
     }
     if (isset($_GET['id'])) {
         $this->_model->id = $_GET['id'];
         $_manage = $this->_model->getOneManage();
         is_object($_manage) ? true : Tool::alertBack('管理员传值的id有误!');
         $this->_tpl->assign('id', $_manage->id);
         $this->_tpl->assign('level', $_manage->level);
         $this->_tpl->assign('admin_user', $_manage->admin_user);
         $this->_tpl->assign('admin_pass', $_manage->admin_pass);
         $this->_tpl->assign('update', true);
         $this->_tpl->assign('title', '修改管理员');
         $this->_tpl->assign('prev_url', PREV_URL);
         $_level = new LevelModel();
         $this->_tpl->assign('AllLevel', $_level->getAllLevel());
     } else {
         Tool::alertBack('非法操作!');
     }
 }
예제 #3
0
 /**
  * 检查用户是否升级
  * 升级时加150金币coins 1个购买的币reward_points
  * @param $userinfo 
  */
 private function checkUserLevel($userinfo)
 {
     if (!$userinfo) {
         return;
     }
     $level = $userinfo->level;
     $experience = $userinfo->experience;
     $model = new LevelModel();
     $new_level = $model->getLevelByExp($experience);
     if ($new_level != $level) {
         $coins = $userinfo->coins + self::UPGRADE_ADD_COIN;
         $reward_points = $userinfo->reward_points + self::UPGRADE_ADD_CASH;
         $user = new UserModel();
         $user->updateUser($this->uid, array('level' => $new_level, 'coins' => $coins, 'reward_points' => $reward_points));
         $userinfo->level = $new_level;
         $userinfo->coins = $coins;
         $userinfo->reward_points = $reward_points;
         unset($user);
     }
     return $userinfo;
 }
 public static function dashboardWebService($acc)
 {
     $agent_id = $acc->admin_id;
     $mon = isset($_GET['mon']) ? addslashes($_GET['mon']) : date("n");
     $y = isset($_GET['y']) ? addslashes($_GET['y']) : date("Y");
     $date = new DateTime();
     $date->setDate($y, $mon, 1);
     $ymd = $date->format('Y-m-d');
     $monthNum = $mon;
     $dateObj = DateTime::createFromFormat('!m', $monthNum);
     $monthName = $dateObj->format('F');
     // March
     $sales = AppearSales::calculatePaidSalesCount($agent_id, $mon, $y);
     //                                        pr($sales);
     $lastmon = getFirstDayOfLastMonth($mon, $y, "n");
     $lastyear = getFirstDayOfLastMonth($mon, $y, "Y");
     $lastmonsales = AppearSales::calculatePaidSalesCount($agent_id, $lastmon, $lastyear);
     //revenue
     $rev = AppearSales::calculateRevenueCount($agent_id);
     $paid_count = AppearSales::paidCount($agent_id);
     $target = AppearSales::calculateTarget($paid_count);
     $dateObj = DateTime::createFromFormat('!m', $lastmon);
     $monthNameLast = $dateObj->format('F');
     // March
     $free = AppearSales::calculateFree($agent_id, $mon, $y);
     $json['acc_id'] = $acc->admin_id;
     $json['mon'] = $mon;
     $json['y'] = $y;
     $json['cube']['target']['total'] = $target['total'];
     $json['cube']['target']['nr'] = $target['nr'];
     if ($sales->total == null) {
         $sales->total = 0;
     }
     if ($sales->nr == null) {
         $sales->nr = 0;
     }
     $json['cube']['paidsales']['total'] = $sales->total;
     $json['cube']['paidsales']['nr'] = $sales->nr;
     $json['cube']['paidsales']['mon'] = $mon;
     $json['cube']['paidsales']['y'] = $y;
     if ($lastmonsales->total == null) {
         $lastmonsales->total = 0;
     }
     if ($lastmonsales->nr == null) {
         $lastmonsales->nr = 0;
     }
     $json['cube']['lastmon_paidsales']['total'] = $lastmonsales->total;
     $json['cube']['lastmon_paidsales']['nr'] = $lastmonsales->nr;
     $json['cube']['lastmon_paidsales']['mon'] = $lastmon;
     $json['cube']['lastmon_paidsales']['y'] = $lastyear;
     $json['cube']['freebies']['total'] = $free['total'];
     $json['cube']['freebies']['nr'] = $free['total_free'];
     $json['cube']['freebies']['mon'] = $mon;
     $json['cube']['freebies']['y'] = $y;
     $json['cube']['payout']['total'] = AppearSales::calculatePayout($agent_id, $mon, $y)['total'];
     $json['cube']['payout']['mon'] = $mon;
     $json['cube']['payout']['y'] = $y;
     $json['cube']['revenue']['total'] = AppearSales::calculateRevenue($agent_id);
     $json['cube']['revenue']['paid_nr'] = $paid_count;
     $json['cube']['revenue']['free_nr'] = AppearSales::freeCount($agent_id);
     //get applied banner
     $bm = new BannerModel();
     $arrBm = $bm->getWhere("banner_interval_begin <= {$paid_count} AND banner_interval_end >= {$paid_count} AND banner_active = 1");
     //        pr($arrBm);
     if (count($arrBm) > 0) {
         $selBanner = $arrBm[0];
         $json['banner'][] = array("url" => $selBanner->banner_link_url, "img" => _BPATH . _PHOTOURL . $selBanner->banner_img);
     }
     //get applied level
     $lv = new LevelModel();
     $arrLvl = $lv->getWhere("level_start<={$paid_count} AND level_end>={$paid_count} AND level_active = 1");
     if (count($arrLvl) > 0) {
         $selLvl = $arrLvl[0];
         $json['level'] = array("name" => $selLvl->level_name, "img" => _BPATH . _PHOTOURL . $selLvl->level_img);
     }
     $json['status_code'] = 1;
     $json['status_message'] = "Success";
     echo json_encode($json);
     die;
 }
예제 #5
0
 private function update()
 {
     if (isset($_POST['send'])) {
         $this->_model->id = $_POST['id'];
         if (trim($_POST['admin_pass']) == '') {
             $this->_model->admin_pass = $_POST['pass'];
         } else {
             if (Validate::checkLength($_POST['admin_pass'], 6, 'min')) {
                 Tool::alertBack('password less than 6');
             }
             $this->_model->admin_pass = md5($_POST['admin_pass']);
         }
         $this->_model->level = $_POST['level'];
         $this->_model->updateManage() ? Tool::alertLocation('Succeed', $_POST['prev_url']) : Tool::alertBack('You did not make any change. please click return to list');
     }
     if (isset($_GET['id'])) {
         $this->_model->id = $_GET['id'];
         is_object($this->_model->getOneManage()) ? true : Tool::alertBack('wrong id');
         $this->_tpl->assign('id', $this->_model->getOneManage()->id);
         $this->_tpl->assign('level', $this->_model->getOneManage()->level);
         $this->_tpl->assign('admin_user', $this->_model->getOneManage()->admin_user);
         $this->_tpl->assign('admin_pass', $this->_model->getOneManage()->admin_pass);
         $this->_tpl->assign('update', true);
         $this->_tpl->assign('title', 'Update Existing Administrator');
         $this->_tpl->assign('prev_url', PREV_URL);
         $_level = new LevelModel();
         $this->_tpl->assign('AllLevel', $_level->getAllLevel());
     } else {
         Tool::alertBack('illegal act');
     }
 }
예제 #6
0
 public function login()
 {
     IMBAuth::checkOAuth();
     $username = addslashes($_POST['username']);
     $password = addslashes($_POST['password']);
     //untuk deviceModel
     $device_id = addslashes($_POST['device_id']);
     $type = addslashes($_POST['type']);
     $acc = new Account();
     $arr = $acc->getWhere("admin_username = '******' OR admin_email ='{$username}'");
     //        pr($arr);
     if (count($arr) > 0) {
         $acc = $arr[0];
         if ($password == $acc->admin_password) {
             $json['status_code'] = 1;
             $json['status_message'] = "Success";
             $json_acc['acc_id'] = $acc->admin_id;
             $json_acc['username'] = $acc->admin_username;
             $json_acc['email'] = $acc->admin_email;
             $json_acc['user_token'] = md5($acc->admin_email . $acc->admin_password);
             $json['account'] = $json_acc;
             //dashboard
             $myid = $acc->admin_id;
             $kom = new KomisiModel();
             $arrKom = $kom->getWhere("komisi_acc_id = '{$myid}'  ORDER BY komisi_app_date ASC");
             $paid = 0;
             $unpaid = 0;
             $total = 0;
             $free = 0;
             $android = 0;
             $androidios = 0;
             $totalpaketbayar = 0;
             $totalpaket = 0;
             foreach ($arrKom as $kom) {
                 if ($kom->komisi_status == 1) {
                     $paid += $kom->komisi_value;
                 } else {
                     $unpaid += $kom->komisi_value;
                 }
                 $total += $kom->komisi_value;
                 if ($kom->komisi_paket_id == 1) {
                     //free
                     $free++;
                 }
                 if ($kom->komisi_paket_id == 2) {
                     //free
                     $android++;
                     $totalpaketbayar++;
                 }
                 if ($kom->komisi_paket_id == 3) {
                     //free
                     $androidios++;
                     $totalpaketbayar++;
                 }
                 $totalpaket++;
             }
             //get applied banner
             $bm = new BannerModel();
             $arrBm = $bm->getWhere("banner_interval_begin <= {$totalpaketbayar} AND banner_interval_end >= {$totalpaketbayar} AND banner_active = 1");
             if (count($arrBm) > 0) {
                 $selBanner = $arrBm[0];
                 $json_banner['banner_img'] = _BPATH . _PHOTOURL . $selBanner->banner_img;
                 $json_banner['banner_link_url'] = $selBanner->banner_link_url;
             }
             //get applied level
             $lv = new LevelModel();
             $arrLvl = $lv->getWhere("level_start<={$totalpaketbayar} AND level_end>={$totalpaketbayar} AND level_active = 1");
             if (count($arrLvl) > 0) {
                 $selLvl = $arrLvl[0];
                 $json_lvl['level_name'] = $selLvl->level_name;
                 $json_lvl['level_img'] = _BPATH . _PHOTOURL . $selLvl->level_img;
             }
             $dashboard['sales_total'] = $totalpaket;
             $dashboard['sales_paid'] = $totalpaketbayar;
             $dashboard['sales_fee'] = $free;
             $dashboard['sales_android'] = $android;
             $dashboard['sales_androidios'] = $androidios;
             $dashboard['money_total'] = $total;
             $dashboard['money_paid'] = $paid;
             $dashboard['money_unpaid'] = $unpaid;
             $dashboard['banner'] = $json_banner;
             $dashboard['level'] = $json_lvl;
             $json['dashboard'] = $dashboard;
             //myapps
             $app2acc = new App2Acc();
             //AND app_active = 1
             $apps = $app2acc->getWhereFromMultipleTable("ac_admin_id = '" . $acc->admin_id . "' AND ac_app_id = app_id ", array("AppAccount"));
             if (count($apps) > 0) {
                 foreach ($apps as $ap) {
                     $rr = array();
                     $rr['app_id'] = $ap->app_id;
                     $rr['app_icon'] = $ap->app_icon;
                     $rr['app_name'] = $ap->app_name;
                     $rr['app_active'] = $ap->app_active;
                     $rr['app_shortdes'] = $ap->app_shortdes;
                     $rr['app_token'] = $ap->app_token;
                     $rr['app_contract_end'] = $ap->app_contract_end;
                     $rr['app_google_play_link'] = $ap->app_google_play_link;
                     $rr['app_google_version'] = $ap->app_google_version;
                     $rr['app_ios_link'] = $ap->app_ios_link;
                     $rr['app_ios_version'] = $ap->app_ios_version;
                     $paket = new Paket();
                     $paket->getByID($ap->app_paket_id);
                     $rr['paket']['paket_id'] = $paket->paket_id;
                     $rr['paket']['paket_name'] = $paket->paket_name;
                     $json['apps'][] = $rr;
                 }
             } else {
                 $json['apps'] = array();
             }
             //update the device id on deviceModelCaps
             $dn = new DeviceModelCapsule();
             $dnquery = new DeviceModelCapsule();
             // langkah 1 , device ID ada device type ada
             $arrs = $dnquery->getWhere("device_id = '{$device_id}' AND device_type = '{$type}'");
             $dn = $arrs[0];
             if ($dn->did == "") {
                 $dn = new DeviceModelCapsule();
                 $dn->device_id = $device_id;
                 $dn->device_type = $type;
                 $dn->acc_id = $acc->admin_id;
                 $dn->firstlogin = leap_mysqldate();
             } else {
                 //kalau device id ada, acc di update
                 $dn->load = 1;
                 $dn->acc_id = $acc->admin_id;
             }
             $dn->dev_lng = addslashes($_POST['lng']);
             $dn->dev_lat = addslashes($_POST['lat']);
             $dn->logindate = leap_mysqldate();
             if ($dn->save()) {
                 $json['save_device_status'] = 1;
             }
             $json['powered_by_link'] = Efiwebsetting::getData("Powered_By_Link_Caps");
             echo json_encode($json);
             die;
         } else {
             $json['status_code'] = 0;
             $json['status_message'] = "Password Mismatched";
             echo json_encode($json);
             die;
         }
     } else {
         $json['status_code'] = 0;
         $json['status_message'] = "User Not Found";
         echo json_encode($json);
         die;
     }
 }