/** * Connecte un utilisateur * @param array $user Le tableau contenant les données utilisateur */ public function logUserIn($user) { $app = getApp(); //retire le mot de passe de la session unset($user[$app->getConfig('security_password_property')]); $_SESSION["user"] = $user; }
/** * Redirige vers une route nommée * @param string $routeName Le nom de route vers laquelle rediriger * @param array $params Tableau de paramètres optionnel de cette route */ public function redirectToRoute($routeName, array $params = array()) { $app = getApp(); $router = $app->getRouter(); $uri = $router->generate($routeName, $params); $this->redirect($uri); }
public function contactAdmin() { $errors = array(); $app = getApp(); $mail = new PHPMailer(); if (!empty($_POST)) { // Faire vérification des champs ICI if (empty($_POST['email'])) { $errors[] = 'l\'email est vide'; } if (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) !== false) { $errors[] = 'L\'email est invalide'; } if (empty($_POST['objet'])) { $errors[] = 'l\'objet est vide'; } if (empty($_POST['message'])) { $errors[] = 'le message est vide'; } if (empty($_POST['nom'])) { $errors[] = 'le nom est vide'; } if (empty($_POST['prenom'])) { $errors[] = 'le prenom est vide'; } // si pas d'erreurs, if (count($errors) == 0) { $mail->setLanguage('fr', '../../vendor/phpmailer/phpmailer/language/'); $mail->isSMTP(); // Set mailer to use SMTP $mail->Host = $app->getConfig("phpmailer_server"); // Specify main and backup SMTP servers $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = $app->getConfig("phpmailer_user"); // SMTP username $mail->Password = $app->getConfig("phpmailer_pass"); // SMTP password $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted $mail->Port = $app->getConfig('phpmailer_port'); // TCP port to connect to $mail->setFrom($_POST['email'], $_POST['nom'] . $_POST['prenom']); $mail->addAddress('Mettre le mail de l\'admin', 'Admin'); // Add a recipient $mail->isHTML(true); // Set email format to HTML $mail->Subject = $_POST['objet']; $mail->Body = $_POST['message']; $mail->AltBody = $_POST['message']; if (!$mail->send()) { $errors[] = 'l\'email n\'a pas pu être envoyé veuillez réessayer'; } else { $params['success'] = 'Votre message à bien été envoyé !'; } } } $params['errors'] = $errors; $this->show('front/contactAdmin', $params); }
/** * Crée une nouvelle connexion à la base */ public static function setNewDbh() { $app = getApp(); try { //connexion à la base avec la classe PDO et le dsn self::$dbh = new PDO('mysql:host=' . $app->getConfig('db_host') . ';dbname=' . $app->getConfig('db_name'), $app->getConfig('db_user'), $app->getConfig('db_pass'), array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8", PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING)); } catch (PDOException $e) { //attrappe les éventuelles erreurs de connexion echo 'Erreur de connexion : ' . $e->getMessage(); } }
public function forgotPassword() { $userManager = new UserManager(); $succes = ""; $error = ""; if (!empty($_POST)) { $factory = new \RandomLib\Factory(); $generator = $factory->getGenerator(new \SecurityLib\Strength(\SecurityLib\Strength::MEDIUM)); $token = $generator->generateString(32, '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'); $email = $_POST['email']; // Verif si email existe dans la BDD if ($userManager->emailExists($email)) { $user = $userManager->getUserByUsernameOrEmail($email); $userManager->update(array("token" => $token), $user['id']); // Envois du mail $mail = new \PHPMailer(); $mail->isSMTP(); $mail->setLanguage('fr'); $mail->CharSet = 'UTF-8'; $mail->SMTPDebug = 2; //0 pour désactiver les infos de débug $mail->Debugoutput = 'html'; $mail->Host = 'smtp.gmail.com'; $mail->Port = 587; $mail->SMTPSecure = 'tls'; $mail->SMTPAuth = true; $mail->Username = "******"; $mail->Password = "******"; $mail->setFrom('ServiceMessagerie@BDloc', 'Service de Messagerie BDloc'); $mail->addAddress($email, $user['username']); $mail->isHTML(true); $mail->Subject = 'Envoyé par PHP !'; $app = getApp(); $router = $app->getRouter(); $url = $router->generate("resetMotdepasse", array("token" => $token)); $mail->Body = 'Nous avons bien reçu votre demande de renouvellement de mot de passe <br> pour changer votre mot de passe <a href="http://www.bdloc.dev' . $url . '">Cliquer ici</a>'; // SI email est bien envoyer if (!$mail->send()) { echo "Mailer Error: " . $mail->ErrorInfo; } else { echo "Message envoyé"; } $_SESSION['mail_succes'] = "Le mail a bien été envoyé !"; $this->redirectToRoute('oublieMotdepasse'); } else { $error = "Adresse Email non trouvé !"; } } $data = []; $data['succes'] = $succes; $data['error'] = $error; $this->show('user/forgotPassword', $data); }
function editModal($AppID) { $AppInfo = getApp($AppID); $Links = getAppLinks($AppID); $Title = $AppInfo[0]; $Category = $AppInfo[1]; $Desc = $AppInfo[2]; $Src = $AppInfo[3]; $img = "" . "<div class = 'col-xs-12 col-sm-12 col-md-4 col-lg-4'><div class = 'row'>" . "<div class = 'col-xs-2 col-sm-2 col-md-1 col-lg-1'> </div>" . "<div class = 'col-xs-8 col-sm-8 col-md-10 col-lg-10' id = 'AppImg'>" . "<img src=" . $Src . " class = 'img-responsive img-rounded text-center' style = 'height: auto; width: 100%;'>" . "</div>" . "</div>"; $BtnDiv = createLinkButtons($Links); $AppDesc = "<div class = 'col-xs-12 col-sm-12 col-md-4 col-lg-4'>\n <h3 id = 'AppTitle'>" . $Title . "</h3>\n <hr>\n <h4 id = 'AppCategory'>" . $Category . "</h4>\n <p id = 'AppDesc'>" . $Desc . "</p>\n </div>"; echo $img . $BtnDiv . $AppDesc; }
/** * Génère l'URL correspondant à une route nommée * @param string $routeName Le nom de route * @param mixed $params Tableau de paramètres optionnel de cette route * @param boolean $absolute Retourne une url absolue si true (relative si false) * @return L'URL correspondant à la route */ public static function generateUrl($routeName, $params = array(), $absolute = false) { $params = empty($params) ? array() : $params; $app = getApp(); $router = $app->getRouter(); $routeUrl = $router->generate($routeName, $params); $url = $routeUrl; if ($absolute) { $u = \League\Url\Url::createFromServer($_SERVER); $url = $u->getBaseUrl() . $routeUrl; } return $url; }
/** * Déduit le nom de la table en fonction du nom du Manager enfant * @return W\Manager $this */ private function setTableFromClassName() { $app = getApp(); //nom de la class enfant $className = get_class($this); //retire le Manager, les backslashes et ajoute un "s" $tableName = str_replace("Manager", "", $className); $tableName = strtolower(str_replace("\\", "", $tableName)); if (substr($tableName, -1) != "s") { $tableName .= "s"; } $this->table = $app->getConfig('db_table_prefix') . $tableName; return $this; }
/** * Utilise les données utilisateurs présentes en base pour mettre à jour les données en session * @return boolean */ public function refreshUser() { $app = getApp(); $usersModel = new UsersModel(); $userFromSession = $this->getLoggedUser(); if ($userFromSession) { $userFromDb = $userModel->find($userFromSession[$app->getConfig('security_id_property')]); if ($userFromDb) { $this->logUserIn($userFromDb); return true; } } return false; }
/** * Teste si un pseudo est présent en base de données * @param string $username Le pseudo à tester * @return boolean true si présent en base de données, false sinon */ public function usernameExists($username) { $app = getApp(); $sql = 'SELECT ' . $app->getConfig('security_username_property') . ' FROM ' . $this->table . ' WHERE ' . $app->getConfig('security_username_property') . ' = :username LIMIT 1'; $dbh = ConnectionModel::getDbh(); $sth = $dbh->prepare($sql); $sth->bindValue(':username', $username); if ($sth->execute()) { $foundUser = $sth->fetch(); if ($foundUser) { return true; } } return false; }
public function idExists($userId) { $app = getApp(); $sql = "SELECT " . $app->getConfig('security_id_property') . " FROM " . $app->getConfig('security_user_table') . " WHERE " . $app->getConfig('security_id_property') . " = :userId LIMIT 1"; $dbh = \W\Manager\ConnectionManager::getDbh(); $sth = $dbh->prepare($sql); $sth->bindValue(":userId", $userId); if ($sth->execute()) { $foundUser = $sth->fetch(); if ($foundUser) { return true; } } return false; }
/** * Utilise les données utilisateurs présentes en base pour mettre à jour les données en session * @return boolean */ public function refreshUser() { $app = getApp(); $userManager = new UserManager(); $userManager->setTable($app->getConfig('security_user_table')); $userFromSession = $this->getLoggedUser(); if ($userFromSession) { $userFromDb = $userManager->find($userFromSession[$app->getConfig('security_id_property')]); if ($userFromDb) { $_SESSION["user"] = $userFromDb; return true; } } return false; }
/** * Déduit le nom de la table en fonction du nom du modèle enfant * @return W\Model $this */ private function setTableFromClassName() { $app = getApp(); if (empty($this->table)) { // Nom de la class enfant $className = get_class($this); // Retire le Model et les antislashes et converti en underscore_case (snake_case) $tableName = str_replace('Model', '', $className); $tableName = explode('\\', $tableName); $tableName = ltrim(strtolower(preg_replace('/[A-Z]/', '_$0', end($tableName))), '_'); } else { $tableName = $this->table; } $this->table = $app->getConfig('db_table_prefix') . $tableName; return $this; }
/** * Récupère un utilisateur en fonction de son email ou de son pseudo * @param string $usernameOrEmail Le pseudo ou l'email d'un utilisateur * @return mixed L'utilisateur, ou false si non trouvé */ public function getUserByUsernameOrEmail($usernameOrEmail) { $app = getApp(); $sql = "SELECT * FROM " . $app->getConfig('security_user_table') . " WHERE " . $app->getConfig('security_username_property') . " = :username OR " . $app->getConfig('security_email_property') . " = :email LIMIT 1"; $dbh = ConnectionManager::getDbh(); $sth = $dbh->prepare($sql); $sth->bindValue(":username", $usernameOrEmail); $sth->bindValue(":email", $usernameOrEmail); if ($sth->execute()) { $foundUser = $sth->fetch(); if ($foundUser) { return $foundUser; } } return false; }
/** * Affiche un template * @param string $file Chemin vers le template, relatif à app/Views/ * @param array $data Données à rendre disponibles à la vue */ public function show($file, array $data = array()) { //incluant le chemin vers nos vues $engine = new \League\Plates\Engine(self::PATH_VIEWS); //charge nos extensions (nos fonctions personnalisées) $engine->loadExtension(new \W\View\Plates\PlatesExtensions()); $app = getApp(); // Rend certaines données disponibles à tous les vues // accessible avec $w_user & $w_current_route dans les fichiers de vue $engine->addData(['w_user' => $this->getUser(), 'w_current_route' => $app->getCurrentRoute()]); // Retire l'éventuelle extension .php $file = str_replace('.php', '', $file); // Affiche le template echo $engine->render($file, $data); die; }
/** * Cherche une correspondance entre l'URL et les routes, et appelle la méthode appropriée */ public function match() { $router = getApp()->getRouter(); $match = $router->match(); if ($match) { $callableParts = explode('#', $match['target']); // Retire l'optionnel suffixe 'Controller', pour le remettre ci-dessous $controllerName = ucfirst(str_replace('Controller', '', $callableParts[0])); $methodName = $callableParts[1]; $controllerFullName = 'Controller\\' . $controllerName . 'Controller'; $controller = new $controllerFullName(); // Appelle la méthode, en lui passant les paramètres d'URL en arguments call_user_func_array(array($controller, $methodName), $match['params']); } else { $controller = new \W\Controller\Controller(); $controller->showNotFound(); } }
public function refreshUserMulti() { $app = getApp(); $userManager = new UserManager(); $userManager->setTable($app->getConfig('security_user_table')); $userFromSession = $this->getLoggedUser(); if ($userFromSession) { $user_part1 = $userManager->find($userFromSession[$app->getConfig('security_id_property')]); //se connecte a la table wusers $UserManagerSuite = new GeneralManager(); $id_user = $user_part1['id']; $user_part2 = $UserManagerSuite->findAllLogUser($id_user); $userFromDb = array_merge($user_part1, $user_part2); // ajout de $user2 dans $user if ($userFromDb) { $_SESSION["user"] = $userFromDb; return true; } } return false; }
/** * Retourne l'URL relative d'un asset * @param string $path Le chemin vers le fichier, relatif à public/assets/ * @return string L'URL relative vers le fichier */ public function assetUrl($path) { $app = getApp(); return $app->getBasePath() . '/assets/' . ltrim($path, '/'); }
<?php $pageTitle = "App"; $appID = isset($_GET['appid']) ? $_GET['appid'] != '' ? $_GET['appid'] : '0' : '0'; include_once 'includes/session.php'; include_once 'includes/functions_steam.php'; include_once 'includes/functions_apps.php'; // are we supplying data via GET? → show app? if ($appID == '0' and !is_numeric($appID)) { header("HTTP/1.0 404 Not Found"); exit; } $gameProfile = getApp($appID); if ($gameProfile == false) { header("HTTP/1.0 404 Not Found"); exit; } $recentEvents = getRecentEventsForApp($appID); $gameImages = getAppImages($appID); $pageTitle = " – ‘{$gameProfile['name']}’ Page"; $description = $gameProfile['name'] . ' is ' . ($gameProfile['onlinux'] == 1 ? 'on Linux' : 'not yet on Linux'); $extraCrap = <<<TWITCARD \t\t<meta name="twitter:card" content="summary_large_image"> \t\t<meta name="twitter:site" content="@SteamLUG"> \t\t<meta name="twitter:title" content="{$gameProfile['name']}"> \t\t<meta name="twitter:description" content="{$description}…"> \t\t<meta name="twitter:image:src" content="{$gameImages['header']}"> TWITCARD; include_once 'includes/header.php'; $onlinux = $gameProfile['onlinux'] ? '<i class="fa-linux"> Yes</i>' : '<i class=""> No</i>';
<?php $loader = (require 'vendor/autoload.php'); $loader->add('App', __DIR__); $loader->add('Lib', __DIR__); function getApp() { return $app = (require __DIR__ . '/../app/config.php'); } getApp();
function setUp() { $this->app = getApp(); $this->userManager = new UserManager(new \Mongo('localhost'), "test", $this->app); }
public function reiniPass() { $login = new AuthentificationModel(); $userModel = new UserModel(); $errors = array(); $mail = new PHPMailer(); $params = array(); // Les paramètres qu'on envoi a la vue, on utilisera les clés du tableau précédé par un $ pour les utiliser dans la vue if (!empty($_POST)) { // Faire vérification des champs ICI if (empty($_POST['email'])) { $errors[] = 'l\'email est vide'; } if (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) !== false) { $errors[] = 'L\'email est invalide'; } // si pas d'erreurs, if (count($errors) == 0) { // on va vérifier qu'il existe un utilisateur avec cet email dans la base if ($idUser = $userModel->emailExists($_POST['email'])) { $token = password_hash($_POST['pass'], PASSWORD_DEFAULT); // on génère un 'token', identifiant unique $idUser = $userModel->getUserByUsernameOrEmail($_POST['email'])['id']; //chercher id $userModel->update(["confirmedToken" => $token, "dateConfirmedToken" => date('Y-m-d', strtotime('+1 week'))], $idUser); // on stocke le token dans la bdd pour cet utilisateur $successUrl = $this->generateUrl('reiniPassTok') . '?email=' . $_POST['email'] . '&token=' . $token; // on crée le lien permettant à l'utilisateur de resaisir un $successLink = "http://localhost" . $successUrl; // nouveau mot de passe // on envoie le mail avec le lien: $app = getApp(); //$mail->SMTPDebug = 3; // Enable verbose debug output $mail->setLanguage('fr', '../../vendor/phpmailer/phpmailer/language/'); $mail->isSMTP(); // Set mailer to use SMTP $mail->send(); $mail->Host = $app->getConfig("phpmailer_server"); // Specify main and backup SMTP servers $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = $app->getConfig("phpmailer_user"); // SMTP username $mail->Password = $app->getConfig("phpmailer_pass"); // SMTP password $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted $mail->Port = $app->getConfig('phpmailer_port'); // TCP port to connect to $mail->setFrom($_POST['email'], 'vous même'); // Add a recipient $mail->addAddress($_POST['email']); //$mail->addAddress($_POST['email']); // Name is optional $mail->addReplyTo('*****@*****.**', 'Information'); /*$mail->addCC('*****@*****.**'); $mail->addBCC('*****@*****.**'); $mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments $mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name */ $mail->isHTML(true); $mail->Body = '<a href="' . $successLink . '">Reinitialisez votre mot de passe en cliquant sur cette phrase ce liens est valable une semaine après merci de refaire une demande.</a>'; // Set email format to HTML } else { // si non: // message d'erreur: cette adresse mail ne correspond pas à un membre du site $errors[] = 'L\'email n\'existe pas'; } // si oui: // on génère un 'token', identifiant unique // on stocke le token dans la bdd pour cet utilisateur // on crée le lien permettant à l'utilisateur de resaisir un nouveau mot de passe // ce lien doit contenir le token, c'est ce qui nous permettra de vérifier que l'utilisateur qui saisit le nouveau mot de passe est bien le propriétaire de l'adresse email (qui a cliqué sur le lien) if (!$mail->send()) { $errors[] = 'L\'email n\'a pas pu être envoyé'; echo 'Mailer Error: ' . $mail->ErrorInfo; } else { $params['success'] = 'Youhou, c\'est envoyé!'; } } } if (count($errors) > 0) { $params['errors'] = $errors; } $this->show('admin/reiniPass', $params); }
/** * 检查参数签名 */ function authSig($request) { $method = $request['m']; $param = $request['p']; if ($param['signature']) { $signature = $param['signature']; unset($param['signature']); $keys = array_keys($param); sort($keys); $s = ''; foreach ($keys as $key) { $value = $param[$key]; if (is_string($value) || is_numeric($value) || is_bool($value)) { $s .= '&' . $key . '=' . $value; } } $s = substr($s, 1) . $method . P_VERSION . '~@#1xdaf,dmuopamie%%123.'; $mysig = md5($s); if ($mysig != $signature) { glog::info("签名不对[{$mysig}]!=[{$signature}], " . json_encode($request), 'sign'); return array('s' => StatusCode::invalid_siginature, 'msg' => 'invalid signature'); } $timestamp = $param['timestamp']; if ($method == 'System.login') { // 手机设备时间和服务器时间可能有差异,所以第一次请求 System.login 时不验证时间。 return false; } // 1. 对 timestamp 做验证 与 服务器当前时间相差太多的 认为是不合法的请求 $now = getApp()->now; if (abs($now - $timestamp) > 300) { $ts1 = date('Y-m-d H:i:s', $now); $ts2 = date('Y-m-d H:i:s', $timestamp); glog::info("请求时间异常 server[{$ts1}], client[{$ts2}], " . json_encode($request), 'sign'); return false; return array('s' => StatusCode::invalid_request_time, 'msg' => 'invalid timestamp'); } // 2. 记录用户上次调用这个接口的时间戳,如果新的 timestamp <= old_timestamp 则认为是不合法的请求 $uid = getApp()->getuid(); $section_id = getApp()->getsec(); if ($uid && $section_id) { if (model_Util::inBlacklist($uid)) { //黑名单访问,禁止 glog::info("黑名单中玩家[{$uid}]访问分区[{$section_id}] " . json_encode($request), 'blacklist'); return array('s' => StatusCode::invalid_request_time, 'msg' => "uid[{$uid}] is in blacklist"); } try { $redis = DbConfig::getRedis('cache'); $timestamp_key = "sig_{$section_id}_{$uid}_{$method}"; $old_timestamp = $redis->get($timestamp_key); if (is_numeric($old_timestamp)) { // 手机端网络超时后重试,后台可能会收到两次同样时间戳的请求 所以 $timestamp == $old_timestamp 还是很有可能的 if ($timestamp < $old_timestamp) { $ts1 = date('Y-m-d H:i:s', $old_timestamp); $ts2 = date('Y-m-d H:i:s', $timestamp); glog::info("请求时间异常, 上次请求[{$ts1}], 本次请求[{$ts2}], " . json_encode($request), 'sign'); return false; return array('s' => StatusCode::outdated_siginature, 'msg' => 'outdated signature', 'debug' => "old_timestamp: {$old_timestamp}"); } else { $redis->multi(); $redis->set($timestamp_key, $timestamp); $redis->expire($timestamp_key, 360); $redis->exec(); return false; } } else { $redis->multi(); $redis->set($timestamp_key, $timestamp); $redis->expire($timestamp_key, 360); $redis->exec(); return false; } } catch (Exception $ex) { error_log("无法连接 cache redis "); return false; } } return false; } glog::info("没有签名," . json_encode($request), 'sign'); return array('s' => StatusCode::invalid_siginature, 'msg' => 'no signature'); }
/** * Redirige vers la page de connexion */ public function redirectToLogin() { $app = getApp(); $controller = new \W\Controller\Controller(); $controller->redirectToRoute($app->getConfig('security_login_route_name')); }
function actionSendMsgToAwardUsers() { $uid_secs = self::getParam('uid_secs'); $content = self::getParam('content'); $desc = self::getParam('desc'); $items = self::getParam('items'); $task_num = self::getParam('num'); error_log("====接受到奖励信息==" . json_encode($uid_secs)); if (!$uid_secs) { return; } foreach ((array) $items as $value) { $tag = $value['tag']; $num = intval($value['num']); if ($tag == 'gem' && $num > 100000) { echo "error, 元宝不能大于100000"; exit; } } $key = uniqid(); $msg = array('key' => $key, 'time' => app()->now, 'content' => $content, 'type' => 'system'); //福利号总服务器地址 $all_config = (include_once ROOT . "/admin/view/public_const_config.php"); //设置作废福利号接口 $server_url = $all_config['server_api_url'] . "?action=setRepeal&mod=admin"; $DEBUG = true; foreach ((array) $uid_secs as $uid => $sec) { //if( $uid != 3879133 )continue;//temp //error_log("send[$uid][$sec]"); //check 是否合服 改变UID $sec_config = getApp()->getSectionConfig($sec); if (isset($sec_config['merge'])) { $uid = "{$sec}_{$uid}"; $sec = $sec_config['merge']; } if ($DEBUG) { error_log("开始发送元宝:{$uid}--{$sec}"); } $player = new model_Player($uid, $sec); $player->getFields(array('level', 'test_status', 'login_t', 'gem')); $level = $player->numberGet("base", "level"); $gem = $player->objectGet("base", "gem"); $login = $player->objectGet("base", "login_t"); //只执行一次 执行一次没有句号的描述 就可以将大于20w的置为20w $bool = $content == "鉴于掌门对武林做出了卓越贡献,特此奖励掌门一些物件,方便行走江湖,还望掌门笑纳" ? true : false; if ($bool && $gem > 200000) { //当前元宝大于20w 且 不是单次发送 将该玩家元宝置为20w 不给发此次元宝 error_log("change_gem:uid:{$uid},{$sec},gem:{$gem}"); $player->numberPut('base', 'gem', 200000); $player->commit(); if ($DEBUG) { error_log("error.20w"); } continue; } if ($task_num != 1 && $gem > 50000) { //现有元宝数量大于N不给发 且 不是单次发送 if ($DEBUG) { error_log("{$gem}元宝大于5w,{$task_num}"); } continue; } if ($_SERVER['REQUEST_TIME'] - $login > 10 * 86400) { //10天没登陆 设置为作废福利号 model_Util::send_post($server_url, array('uid' => $uid, 'sec' => $sec)); if ($DEBUG) { error_log("大于10天没登录"); } continue; } foreach ($items as $key => $value) { $tag = $value['tag']; $num = intval($value['num']); if ($tag == 'qiyu_zhidian') { $zhidian_lvl = max(1, $level * 3 - 34); for ($i = 0; $i < $num; $i++) { $items[] = array('tag' => 'qiyu_zhidian', 'level' => $zhidian_lvl, 'num' => 1); } unset($items[$key]); } } if ($DEBUG) { error_log("====={$value['tag']}={$value['num']}"); } if ($value['tag'] == 'gem') { if ($DEBUG) { error_log("enter"); } $player->checkVipUpgradeAward($value['num']); $player->commit(); } if (is_array($items) && count($items) > 0) { $msg['status'] = 'award'; #$msg['content'].="\n$desc"; $cdkey = model_Cdkey::gen($items, $desc, 1, 'def'); $msg['cdkey'] = $cdkey; } $r = model_Chat::sendMsg($msg, $uid, 'origin', $sec); } }
include_once "ini.config.php"; include_once "ini.dbstring.php"; include_once "ini.functions.php"; sec_session_start(); include_once "mod.order.php"; include_once "mod.login.php"; include_once "mod.optional.php"; include_once "ctrl.order.php"; include_once "ctrl.client.php"; include_once "ctrl.login.php"; // check user authentication checkSession($_SESSION['sess_user_id']); checkOrderSession($_SESSION['sess_order_type'], $_SESSION['sess_client']); $rf = getRf($db); $os = getOS($db); $app = getApp($db); $showclient = getClient($db); ?> <html lang="en-US"> <head> <meta charset="utf-8"> <link href="<?php echo CSS; ?> import.css" type="text/css" rel="stylesheet"/> <link href="<?php echo CSS; ?> style.css" type="text/css" rel="stylesheet"/> <script src="<?php echo JS;
function appHandler() { getApp($_GET['selID']); }
/** * actionCashierGetInfo * @author cq * @date 2014/07/01 * @param * id:uid或者pid * @return * s * info * uid * create_t * pid * istest * sections * s1 * name * level * vip * gem * defaul * s2 * ... * payment_config * 系统的payment_config */ public function actionCashierGetInfo() { $now = getApp()->now; //$ip = getApp()->getClientIP(); //验证消息来源是否合法 $valid_ip_list = array('115.29.193.89', '115.29.225.243', '115.29.229.132', '115.29.229.113', '117.121.10.35'); /* if(!in_array($ip, $valid_ip_list)){ return array('s'=>StatusCode::invalid_ip); }*/ $id = $_POST['id']; if (empty($id)) { echo json_encode(array('s' => StatusCode::invalid_param)); return; } $mon = new PL_Db_Mongo(DbConfig::getMongodb('userlogin')); $um = $mon->findOne(array('email' => $id)); if (!$um) { $um = $mon->findOne(array('pid' => $id)); } if (!$um) { echo json_encode(array('s' => StatusCode::invalid_param)); return; } $ret = array(); $ret['s'] = StatusCode::ok; //获取用户登录信息 $ret['info'] = array(); $ret['info']['uid'] = $um['_id']; //接口中需要添加pid by zhangjun $ret['info']['pid'] = $um['pid']; $ret['info']['create_t'] = $um['_ct']; $ret['info']['istest'] = 0; $ret['info']['istest'] = $um['istest'] ? 'istest' : 0; $ret['info']['istest'] = $um['isdev'] ? 'isdev' : $ret['info']['istest']; //获取用户各个分区信息 $section_config = getApp()->getSectionConfig(); $ret['info']['sections'] = array(); if (isset($um['secs'])) { foreach ($um['secs'] as $sec => $last_t) { $um_mc = new model_Player($um['_id'], $sec); $um_data = $um_mc->getFields(array('name', 'level', 'vip', 'gem', '_it')); $um_data['vip'] = $um_data['vip']['lvl']; $um_data['default'] = $sec == $um['_ld']['sec'] ? 1 : 0; $um_data['section_name'] = $section_config[$sec]['name']; $ret['info']['sections'][$sec] = $um_data; } } //获取支付信息 $ret['payment_config'] = getApp()->getPaymentConifg(); //NULL, $um['source']); $ret['payment_unit'] = '元宝'; $list = $ret['payment_config']; //添加自定义支付项 $max_product_config = array('cash' => -1); foreach ($ret['payment_config'] as $index => $p_config) { //修改一下提示信息 $trans_config = PL_Config_Numeric::get('translate', $p_config['desc']); $ret['payment_config'][$index]['desc'] = $trans_config['zh_CN']; if ($p_config['cash'] > $max_product_config['cash']) { $max_product_config = $p_config; $product_config_list[] = $p_config; } } $ret['payment_config'] = array(); $max_product = 1000; if ($max_product_config['cash'] > 0) { $custom_config = array('type' => 'define', 'gt' => $max_product, 'inputdesc' => '首次充值翻倍额度以游戏内最高可充值额度为准', 'gemcalc' => "Math.ceil(cash*10 + cash*1300/998)", 'product_id' => 'custom'); $ret['payment_config'][] = $custom_config; } foreach ($list as $k => $v) { //if($v['gemaward'] > 0 && !isset($v['hide'])){ if (isset($v['forweb'])) { $ret['payment_config'][] = $v; } } echo json_encode($ret); }
/** * Retourne l'URI absolue d'une route nommée */ public function generateUrl($routeName, array $params = array()) { $app = getApp(); $router = $app->getRouter(); return $router->generate($routeName, $params); }
/** *@note @phpunit nettoyer après un test */ function tearDown() { $this->articleManager = new ArticleManager(new Mongo("localhost"), "test"); $this->userManager = new UserManager(new Mongo("localhost"), "test", getApp()); $this->userManager->remove(new MongoId($this->user['_id'])); $this->articleManager->remove(new MongoId($this->article['_id'])); }