/** * destroy administrator session * role: administrator */ public function logout() { $auth = new Authenticate(); if ($auth->logout(Authenticate::SUPERUSER)) { transport("administrator"); } else { transport("dashboard"); } }
/** * export/download top 10 player into pdf * role: administrator */ public function get_player_top_10() { if (authenticate::is_authorized()) { $model_report = new ReportGenerator(); $model_leaderboard = Leaderboard::getInstance(); $model_report->get_report_top_10($model_leaderboard->get_top10_ranking()); $model_report->print_report(); } else { transport("administrator"); } }
/** * show feedback management page on administrator feature. * role: administrator */ public function index() { if (Authenticate::is_authorized()) { $model_player = Player::getInstance(); $model_player->get_total_player(); $model_player->unread_new_player(); $this->framework->view->page = "feedback"; $this->framework->view->content = "/backend/pages/feedback"; $this->framework->view->show("backend/template"); } else { transport("administrator"); } }
/** * export/download overall report into pdf * role: administrator */ public function get_overall() { if (Authenticate::is_authorized()) { $model_player = Player::getInstance(); $model_feedback = Feedback::getInstance(); $model_administrator = Administrator::getInstance(); $model_leaderboard = Leaderboard::getInstance(); $model_report = new ReportGenerator(); $model_report->get_report_overall($model_player->get_player_report(), $model_feedback->retrieve_feedback_report(), $model_administrator->retrieve_traffic_report(), $model_leaderboard->get_top10_ranking()); $model_report->print_report(); } else { transport("administrator"); } }
/** * update product price. * * role: player */ public function update_product_price() { if (Authenticate::is_player()) { if (isset($_POST['token']) && Authenticate::is_valid_token($_POST['token'])) { $this->model_product = Product::getInstance(); $product = $_POST['product_data']; $result = $this->model_product->update_player_product($product); $binding = array("result_var" => "session_ready", "status_var" => $result); binding_data($binding); } else { transport("error404"); } } else { $binding = array("result_var" => "no_session"); binding_data($binding); } }
/** * retrieve player ranking and global ranking. * route : player */ public function retrieve_leaderboard() { if (Authenticate::is_player()) { if (isset($_POST['token']) && Authenticate::is_valid_token($_POST['token'])) { $this->model_leaderboard = Leaderboard::getInstance(); $player_ranking = $this->model_leaderboard->get_player_ranking(); $global_ranking = $this->model_leaderboard->get_global_ranking(); $binding = array("result_var" => "session_ready", "leaderboard_player_var" => json_encode($player_ranking), "leaderboard_global_var" => json_encode($global_ranking)); binding_data($binding); } else { transport("error404"); } } else { $binding = array("result_var" => "no_session"); binding_data($binding); } }
/** * save new achievement via REST. * role: player */ public function unlock_achievement() { if (Authenticate::is_player()) { if (isset($_POST['token']) && Authenticate::is_valid_token($_POST['token'])) { $this->model_achievement = Achievement::getInstance(); /* * populate type of achievement. * invoke method to unlock the achievement. * log this event about achievement earning. */ $achievement = $_POST["achievement"]; $result = $this->model_achievement->unlock_achievement($achievement); $log = Log::getInstance(); $log->logging_game_earn_achievement("Achievement id {$achievement}"); $binding = array("result_var" => "session_ready", "unlock_status" => $result); binding_data($binding); } else { transport("error404"); } } else { $binding = array("result_var" => "no_session"); binding_data($binding); } }
/** * retrieve balance sheet from database. * role: player */ public function retrieve_balance() { if (Authenticate::is_player()) { if (isset($_POST['token']) && Authenticate::is_valid_token($_POST['token'])) { $this->model_journal = Journal::getInstance(); /* * invoke method to retrieve balance data. * convert into json format and binding these data. */ $result = $this->model_journal->get_balance_sheet(); $binding = array("result_var" => "session_ready", "balance_var" => json_encode($result, JSON_PRETTY_PRINT)); binding_data($binding); } else { transport("error404"); } } else { $binding = array("result_var" => "no_session"); binding_data($binding); } }
supprimer($article); break; case 'modifier': modifier($article, $quantite); break; case 'connexion': connexion($email, $motdepasse, $urlok, $urlerr); break; case 'deconnexion': deconnexion(); break; case 'paiement': paiement($type_paiement); break; case 'transport': transport($id); break; case 'creercompte': creercompte($raison, $entreprise, $siret, $intracom, $prenom, $nom, $adresse1, $adresse2, $adresse3, $cpostal, $ville, $pays, $telfixe, $telport, $email1, $email2, $motdepasse1, $motdepasse2, $parrain, $obligetel, $urlok, $urlerr); break; case 'modifiercompte': modifiercompte($raison, $entreprise, $siret, $intracom, $prenom, $nom, $adresse1, $adresse2, $adresse3, $cpostal, $ville, $pays, $telfixe, $telport, $email1, $email2, $motdepasse1, $motdepasse2, $obligetel, $urlok, $urlerr); break; case 'modifiermotdepasse': modifiermotdepasse($motdepasse1, $motdepasse2, $urlok, $urlerr); break; case 'creerlivraison': creerlivraison($id, $libelle, $raison, $entreprise, $prenom, $nom, $adresse1, $adresse2, $adresse3, $cpostal, $ville, $tel, $pays, $urlok, $urlerr); break; case 'supprimerlivraison': supprimerlivraison($id);
**/ $timestamp = time(); //采用同步的方式更新总结分排行(一分钟更新一次) if (file_exists(DEDEASK . '/data/cache/scorestime.txt')) { $fp = fopen(DEDEASK . '/data/cache/scorestime.txt', 'r'); $scorestime = trim(fread($fp, 64)); fclose($fp); $hours = ($timestamp - $scorestime) / 60; if ($hours > 1) { transport(); $fp = fopen(DEDEASK . '/data/cache/scorestime.txt', "w") or die("写入文件失败,请检查权限!"); fwrite($fp, $timestamp); fclose($fp); } } else { transport(); $fp = fopen(DEDEASK . '/data/cache/scorestime.txt', "w") or die("写入文件失败,请检查权限!"); fwrite($fp, $timestamp); fclose($fp); } //获取用户总积分 if (file_exists(DEDEASK . "/data/cache/scores.inc")) { require_once DEDEASK . "/data/cache/scores.inc"; $memberlists = unserialize($memberlists); } else { $memberlists = ""; } //处理周积分上升排行 $path = DEDEASK . "/data/cache/week.txt"; if (file_exists($path)) { $fp = fopen($path, 'r');
<?php $xmlDoc = new DOMDocument(); $encodedMessage = file_get_contents("php://input"); $xmlDoc->loadXML($encodedMessage); $url = $xmlDoc->getElementsByTagName("url")->item(0)->nodeValue; //the GoodData url for the zendesk data source for your account $goodDataurl = 'https://secure.gooddata.com/gdc/connectors/zendesk/fetchdata?p=fd483ea6789e1a5ba6d38ce150f90785d4dc3837'; //$username = ''; //$password = ''; $csvName = parse_url($url, PHP_URL_PATH); $csvNamePath = explode('/', $csvName); $pathCSVsize = sizeof($csvNamePath) - 1; $csvFileName = $csvNamePath[$pathCSVsize]; //fire the function downloading the csv to local server transport($url, $csvFileName); //fire the function to send the location of the datasource to GoodData goodData($encodedMessage, $goodDataurl); //the fucntion to send the location of the data source to GoodData function goodData($encodedMessage, $goodDataurl) { $headers = array('Content-type: application/xml', 'Content-Length: ' . strlen($encodedMessage)); $cobj = curl_init(); curl_setopt($cobj, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($cobj, CURLOPT_RETURNTRANSFER, 1); //curl_setopt($cobj, CURLOPT_USERPWD, $username .":".$password); curl_setopt($cobj, CURLOPT_URL, $goodDataurl); curl_setopt($cobj, CURLOPT_POST, 1); curl_setopt($cobj, CURLOPT_HTTPHEADER, $headers); curl_setopt($cobj, CURLOPT_POSTFIELDS, $encodedMessage); curl_setopt($cobj, CURLOPT_FOLLOWLOCATION, false);
echo $email; } ?> for signing up. Please check your email for confirmation!</p> <p><a href="<?php echo $this->framework->url->get_base_url(); ?> ">Click here</a> to login</p> </div> </div> <?php } } unset($_SESSION['operation']); } else { transport("page"); } ?> <div class="row discovery"> <div class="col-md-3 col-sm-6"> <h1>Learn</h1> <h3>Basic Accounting</h3> <img src="<?php echo $this->framework->url->get_base_url(); ?> /assets/images/layout/icon-list.png" class="img-responsive"> <p>Creating your finance report, writing, tracing, managing. keep your money and assets recorded actually.</p> <a href="<?php echo $this->framework->url->get_base_url(); ?>
/** * retrieve another avatar from another user. * role: player * @return string */ public function get_simulation_avatar() { if (Authenticate::is_player()) { if (true || isset($_POST['token']) && Authenticate::is_valid_token($_POST['token'])) { $this->model_player = Player::getInstance(); /* * retrieve at least 3 avatar except player. * wrap it up and convert to json format. */ $avatar = $this->model_player->fetch_simulation_avatar(); $binding = array("result_var" => "session_ready", "avatar_var" => json_encode($avatar, JSON_PRETTY_PRINT)); binding_data($binding); } else { transport("error404"); } } else { $binding = array("result_var" => "no_session"); binding_data($binding); } }
/** * show game page via user profile. * game could be played if user has been logged in. * role: player */ public function game() { if (Authenticate::is_player()) { $this->framework->view->page = "game"; $this->framework->view->content = "/frontend/pages/game"; $this->framework->view->show("frontend/game"); $log = Log::getInstance(); $log->logging_web_play(uniqid()); } else { transport("page"); } }
} //sprawdź czy wybrana akcja jest akcją admina i czy gracz ma do niej dostęp, musi mieć ustawione rola = 1 if (in_Array($_GET['akcja'], $akcje_admin) && $gracz['rola'] == 1) { $top_strony = 'strony/admin/top_strony.php'; $dol_strony = 'strony/admin/dol_strony.php'; $strona = 'strony/admin/' . $_GET['akcja'] . '.php'; } elseif (in_Array($_GET['akcja'], $akcje_gracz) && $gracz['rola'] >= 0) { if ($gracz['id_miasta'] == 0) { fx('nowa_osada'); nowa_osada($gracz); reload('konto'); } fx('main_town'); main_town($gracz['id_miasta']); fx('transport'); transport($gracz['id_miasta']); $top_strony = 'strony/gracz/top_strony.php'; $dol_strony = 'strony/gracz/dol_strony.php'; $strona = 'strony/gracz/' . $_GET['akcja'] . '.php'; } elseif (in_Array($_GET['akcja'], $akcje_ogolne)) { $top_strony = 'strony/ogolne/top_strony.php'; $dol_strony = 'strony/ogolne/dol_strony.php'; $strona = 'strony/ogolne/' . $_GET['akcja'] . '.php'; } else { $top_strony = 'strony/ogolne/top_strony.php'; $dol_strony = 'strony/ogolne/dol_strony.php'; $strona = 'strony/ogolne/start.php'; } //pobierz pliki i wyświetl stronę require_once $top_strony; require_once $strona;
} //sprawdź czy wybrana akcja jest akcją admina i czy gracz ma do niej dostęp, musi mieć ustawione rola = 1 if (in_Array($_GET['akcja'], $akcje_admin) && $User['rola'] == 1) { $top_strony = 'strony/admin/top_strony.php'; $dol_strony = 'strony/admin/dol_strony.php'; $strona = 'strony/admin/' . $_GET['akcja'] . '.php'; } elseif (in_Array($_GET['akcja'], $akcje_gracz) && $User['rola'] >= 0) { if ($User['id_miasta'] == 0) { require_once 'funkcje/nowa_osada.php'; nowa_osada($User); header('location: ?akcja=konto'); } require_once 'funkcje/main_town.php'; main_town($User['id_miasta']); require_once 'funkcje/transport.php'; transport($User['id_miasta']); $top_strony = 'strony/gracz/top_strony.php'; $dol_strony = 'strony/gracz/dol_strony.php'; $strona = 'strony/gracz/' . $_GET['akcja'] . '.php'; } elseif (in_Array($_GET['akcja'], $akcje_ogolne)) { $top_strony = 'strony/ogolne/top_strony.php'; $dol_strony = 'strony/ogolne/dol_strony.php'; $strona = 'strony/ogolne/' . $_GET['akcja'] . '.php'; } else { $top_strony = 'strony/ogolne/top_strony.php'; $dol_strony = 'strony/ogolne/dol_strony.php'; $strona = 'strony/ogolne/start.php'; } //pobierz pliki i wyświetl stronę require_once $top_strony; require_once $strona;
/** * delete player and all related data with this player * role: administrator */ public function delete() { if (Authenticate::is_authorized()) { $model_player = Player::getInstance(); $id = $_POST["id"]; if ($model_player->delete_player($id)) { $_SESSION['operation'] = 'success'; } else { $_SESSION['operation'] = 'error'; } transport("player"); } else { transport("administrator"); } }
/** * role: player */ public function update_material() { if (Authenticate::is_player()) { if (isset($_POST['token']) && Authenticate::is_valid_token($_POST['token'])) { $this->model_material = Material::getInstance(); $material = $_POST["material_data"]; $result = true; foreach (json_decode($material) as $attribute) { $result = $this->model_material->update_material($attribute->pma_id, $attribute->pma_stock, $attribute->pma_expired_remaining); } $binding = array("result_var" => "session_ready", "status_var" => $result); binding_data($binding); } else { transport("error404"); } } else { $binding = array("result_var" => "no_session"); binding_data($binding); } }
/** * update employee status. * role: player */ public function update_employee() { if (Authenticate::is_player()) { if (isset($_POST['token']) && Authenticate::is_valid_token($_POST['token'])) { $this->model_employee = Employee::getInstance(); $employee = $_POST['employee_data']; $result = $this->model_employee->update_employee_status($employee); $binding = array("result_var" => "session_ready", "status_var" => $result); binding_data($binding); } else { transport("error404"); } } else { $binding = array("result_var" => "no_session"); binding_data($binding); } }
/** * update profile data from setting page. * role: administrator */ public function setting_update() { if (Authenticate::is_authorized()) { $model_administrator = Administrator::getInstance(); /* * populate data from post request. * make sure form data match with setting keys */ $data = [Administrator::COLUMN_STG_NAME => $_POST["website_name"], Administrator::COLUMN_STG_DESCRIPTION => $_POST["website_description"], Administrator::COLUMN_STG_KEYWORD => $_POST["website_keyword"], Administrator::COLUMN_STG_EMAIL => $_POST["website_email"], Administrator::COLUMN_STG_NUMBER => $_POST["website_number"], Administrator::COLUMN_STG_ADDRESS => $_POST["website_address"], Administrator::COLUMN_STG_FACEBOOK => $_POST["website_facebook"], Administrator::COLUMN_STG_TWITTER => $_POST["website_twitter"]]; /* * invoke update_setting() method in administrator model. * check the return value that indicate upload favicon and update database are success */ if ($model_administrator->update_setting($data)) { $_SESSION['setting_operation'] = 'success'; } else { $_SESSION['setting_operation'] = 'error'; } transport("dashboard/setting"); } else { transport("administrator"); } }