当前位置: 首页>>代码示例>>PHP>>正文


PHP PlayerUtil::cryptPassword方法代码示例

本文整理汇总了PHP中PlayerUtil::cryptPassword方法的典型用法代码示例。如果您正苦于以下问题:PHP PlayerUtil::cryptPassword方法的具体用法?PHP PlayerUtil::cryptPassword怎么用?PHP PlayerUtil::cryptPassword使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PlayerUtil的用法示例。


在下文中一共展示了PlayerUtil::cryptPassword方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: newPassword

 function newPassword()
 {
     global $LNG;
     $userID = HTTP::_GP('u', 0);
     $validationKey = HTTP::_GP('k', '');
     $db = Database::get();
     $sql = "SELECT COUNT(*) as state FROM %%LOSTPASSWORD%% WHERE userID = :userID AND `key` = :validationKey AND `time` > :time AND hasChanged = 0;";
     $isValid = $db->selectSingle($sql, array(':userID' => $userID, ':validationKey' => $validationKey, ':time' => TIMESTAMP - 1800), 'state');
     if (empty($isValid)) {
         $this->printMessage($LNG['passwordValidInValid'], array(array('label' => $LNG['passwordBack'], 'url' => 'index.php')));
     }
     $newPassword = uniqid();
     $sql = "SELECT username, email_2 as mail, universe FROM %%USERS%% WHERE id = :userID;";
     $userData = $db->selectSingle($sql, array(':userID' => $userID));
     $config = Config::get($userData['universe']);
     $MailRAW = $LNG->getTemplate('email_lost_password_changed');
     $MailContent = str_replace(array('{USERNAME}', '{GAMENAME}', '{GAMEMAIL}', '{PASSWORD}'), array($userData['username'], $config->game_name . ' - ' . $config->uni_name, $config->smtp_sendmail, $newPassword), $MailRAW);
     $sql = "UPDATE %%USERS%% SET password = :newPassword WHERE id = :userID;";
     $db->update($sql, array(':userID' => $userID, ':newPassword' => PlayerUtil::cryptPassword($newPassword)));
     require 'includes/classes/Mail.class.php';
     $subject = sprintf($LNG['passwordChangedMailTitle'], $config->game_name);
     Mail::send($userData['mail'], $userData['username'], $subject, $MailContent);
     $sql = "UPDATE %%LOSTPASSWORD%% SET hasChanged = 1 WHERE userID = :userID AND `key` = :validationKey;";
     $db->update($sql, array(':userID' => $userID, ':validationKey' => $validationKey));
     $this->printMessage($LNG['passwordChangedMailSend'], array(array('label' => $LNG['passwordNext'], 'url' => 'index.php')));
 }
开发者ID:sincilite,项目名称:Evermoon,代码行数:26,代码来源:ShowLostPasswordPage.class.php

示例2: show

 function show()
 {
     if (empty($_POST)) {
         HTTP::redirectTo('index.php');
     }
     $db = Database::get();
     $username = HTTP::_GP('username', '', UTF8_SUPPORT);
     $password = HTTP::_GP('password', '', true);
     $sql = "SELECT id, password FROM %%USERS%% WHERE universe = :universe AND username = :username;";
     $loginData = $db->selectSingle($sql, array(':universe' => Universe::current(), ':username' => $username));
     if (isset($loginData)) {
         $hashedPassword = PlayerUtil::cryptPassword($password);
         if ($loginData['password'] != $hashedPassword) {
             // Fallback pre 1.7
             if ($loginData['password'] == md5($password)) {
                 $sql = "UPDATE %%USERS%% SET password = :hashedPassword WHERE id = :loginID;";
                 $db->update($sql, array(':hashedPassword' => $hashedPassword, ':loginID' => $loginData['id']));
             } else {
                 HTTP::redirectTo('index.php?code=1');
             }
         }
         $session = Session::create();
         $session->userId = (int) $loginData['id'];
         $session->adminAccess = 0;
         $session->save();
         HTTP::redirectTo('game.php');
     } else {
         HTTP::redirectTo('index.php?code=1');
     }
 }
开发者ID:tatarysh,项目名称:2Moons,代码行数:30,代码来源:ShowLoginPage.class.php

示例3: ShowPassEncripterPage

function ShowPassEncripterPage()
{
    global $LNG;
    $Password = HTTP::_GP('md5q', '', true);
    $template = new template();
    $template->assign_vars(array('md5_md5' => $Password, 'md5_enc' => PlayerUtil::cryptPassword($Password), 'et_md5_encripter' => $LNG['et_md5_encripter'], 'et_encript' => $LNG['et_encript'], 'et_result' => $LNG['et_result'], 'et_pass' => $LNG['et_pass']));
    $template->show('PassEncripterPage.tpl');
}
开发者ID:tatarysh,项目名称:2Moons,代码行数:8,代码来源:ShowPassEncripterPage.php

示例4: ShowLoginPage

function ShowLoginPage()
{
    global $USER;
    $session = Session::create();
    if ($session->adminAccess == 1) {
        HTTP::redirectTo('admin.php');
    }
    if (isset($_REQUEST['admin_pw'])) {
        $password = PlayerUtil::cryptPassword($_REQUEST['admin_pw']);
        if ($password == $USER['password']) {
            $session->adminAccess = 1;
            HTTP::redirectTo('admin.php');
        }
    }
    $template = new template();
    $template->assign_vars(array('bodyclass' => 'standalone', 'username' => $USER['username']));
    $template->show('LoginPage.tpl');
}
开发者ID:tatarysh,项目名称:2Moons,代码行数:18,代码来源:ShowLoginPage.php

示例5: newPassword

 function newPassword()
 {
     $userID = HTTP::_GP('u', 0);
     $validationKey = HTTP::_GP('k', '');
     $isValid = $GLOBALS['DATABASE']->getFirstCell("SELECT COUNT(*) FROM " . LOSTPASSWORD . " WHERE userID = " . $userID . " AND `key` = '" . $GLOBALS['DATABASE']->escape($validationKey) . "' AND time > " . (TIMESTAMP - 1800) . " AND hasChanged = 0;");
     if (empty($isValid)) {
         $this->printMessage(t('passwordValidInValid'), NULL, array(array('label' => t('passwordBack'), 'url' => 'index.php')));
     }
     $newPassword = uniqid();
     $userData = $GLOBALS['DATABASE']->getFirstRow("SELECT username, email_2 as mail FROM " . USERS . " WHERE id = " . $userID . ";");
     $MailRAW = $GLOBALS['LNG']->getTemplate('email_lost_password_changed');
     $MailContent = str_replace(array('{USERNAME}', '{GAMENAME}', '{GAMEMAIL}', '{PASSWORD}', '{EMAIL}', '{IP}', '{DATE}'), array($userData['username'], Config::get('game_name') . ' - ' . Config::get('uni_name'), Config::get('smtp_sendmail'), $newPassword, $email_2, $_SERVER['REMOTE_ADDR'], date("m.d.y")), $MailRAW);
     $GLOBALS['DATABASE']->query("UPDATE " . USERS . " SET password = '" . PlayerUtil::cryptPassword($newPassword) . "' WHERE id = " . $userID . ";");
     require 'includes/classes/Mail.class.php';
     $headers = "From: support@battle-fighter.org\r\n";
     $headers .= "Reply-To: support@battle-fighter.org\r\n";
     $headers .= "MIME-Version: 1.0\r\n";
     $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
     mail($userData['mail'], t('passwordChangedMailTitle', Config::get('game_name')), $MailContent, $headers);
     $GLOBALS['DATABASE']->query("UPDATE " . LOSTPASSWORD . " SET hasChanged = 1 WHERE userID = " . $userID . " AND `key` = '" . $GLOBALS['DATABASE']->escape($validationKey) . "';");
     $this->printMessage(t('passwordChangedMailSend'), NULL, array(array('label' => t('passwordNext'), 'url' => 'index.php')));
 }
开发者ID:fuding,项目名称:Antaris,代码行数:22,代码来源:ShowLostPasswordPage.class.php

示例6: delete

 function delete()
 {
     global $LNG, $PLANET, $USER;
     $password = HTTP::_GP('password', '', true);
     if (!empty($password)) {
         $db = Database::get();
         $sql = "SELECT COUNT(*) as state FROM %%FLEETS%% WHERE\n                      (fleet_owner = :userID AND (fleet_start_id = :planetID OR fleet_start_id = :lunaID)) OR\n                      (fleet_target_owner = :userID AND (fleet_end_id = :planetID OR fleet_end_id = :lunaID));";
         $IfFleets = $db->selectSingle($sql, array(':userID' => $USER['id'], ':planetID' => $PLANET['id'], ':lunaID' => $PLANET['id_luna']), 'state');
         if ($IfFleets > 0) {
             $this->sendJSON(array('message' => $LNG['ov_abandon_planet_not_possible']));
         } elseif ($USER['id_planet'] == $PLANET['id']) {
             $this->sendJSON(array('message' => $LNG['ov_principal_planet_cant_abanone']));
         } elseif (PlayerUtil::cryptPassword($password) != $USER['password']) {
             $this->sendJSON(array('message' => $LNG['ov_wrong_pass']));
         } else {
             if ($PLANET['planet_type'] == 1) {
                 $sql = "UPDATE %%PLANETS%% SET destruyed = :time WHERE id = :planetID;";
                 $db->update($sql, array(':time' => TIMESTAMP + 86400, ':planetID' => $PLANET['id']));
                 $sql = "DELETE FROM %%PLANETS%% WHERE id = :lunaID;";
                 $db->delete($sql, array(':lunaID' => $PLANET['id_luna']));
             } else {
                 $sql = "UPDATE %%PLANETS%% SET id_luna = 0 WHERE id_luna = :planetID;";
                 $db->update($sql, array(':planetID' => $PLANET['id']));
                 $sql = "DELETE FROM %%PLANETS%% WHERE id = :planetID;";
                 $db->delete($sql, array(':planetID' => $PLANET['id']));
             }
             $session->planetId = $USER['id_planet'];
             $this->sendJSON(array('ok' => true, 'message' => $LNG['ov_planet_abandoned']));
         }
     }
 }
开发者ID:FrancisLeRoy,项目名称:2Moons,代码行数:31,代码来源:ShowOverviewPage.class.php

示例7: send

 function send()
 {
     global $LNG;
     $config = Config::get();
     if ($config->game_disable == 0 || $config->reg_closed == 1) {
         $this->printMessage($LNG['registerErrorUniClosed'], array(array('label' => $LNG['registerBack'], 'url' => 'javascript:window.history.back()')));
     }
     $userName = HTTP::_GP('username', '', UTF8_SUPPORT);
     $password = HTTP::_GP('password', '', true);
     $password2 = HTTP::_GP('passwordReplay', '', true);
     $mailAddress = HTTP::_GP('email', '');
     $mailAddress2 = HTTP::_GP('emailReplay', '');
     $rulesChecked = HTTP::_GP('rules', 0);
     $language = HTTP::_GP('lang', '');
     $referralID = HTTP::_GP('referralID', 0);
     $externalAuth = HTTP::_GP('externalAuth', array());
     if (!isset($externalAuth['account'], $externalAuth['method'])) {
         $externalAuthUID = 0;
         $externalAuthMethod = '';
     } else {
         $externalAuthUID = $externalAuth['account'];
         $externalAuthMethod = strtolower(str_replace(array('_', '\\', '/', '.', ""), '', $externalAuth['method']));
     }
     $errors = array();
     if (empty($userName)) {
         $errors[] = $LNG['registerErrorUsernameEmpty'];
     }
     if (!PlayerUtil::isNameValid($userName)) {
         $errors[] = $LNG['registerErrorUsernameChar'];
     }
     if (strlen($password) < 6) {
         $errors[] = $LNG['registerErrorPasswordLength'];
     }
     if ($password != $password2) {
         $errors[] = $LNG['registerErrorPasswordSame'];
     }
     if (!PlayerUtil::isMailValid($mailAddress)) {
         $errors[] = $LNG['registerErrorMailInvalid'];
     }
     if (empty($mailAddress)) {
         $errors[] = $LNG['registerErrorMailEmpty'];
     }
     if ($mailAddress != $mailAddress2) {
         $errors[] = $LNG['registerErrorMailSame'];
     }
     if ($rulesChecked != 1) {
         $errors[] = $LNG['registerErrorRules'];
     }
     $db = Database::get();
     $sql = "SELECT (\n\t\t\t\tSELECT COUNT(*)\n\t\t\t\tFROM %%USERS%%\n\t\t\t\tWHERE universe = :universe\n\t\t\t\tAND username = :userName\n\t\t\t) + (\n\t\t\t\tSELECT COUNT(*)\n\t\t\t\tFROM %%USERS_VALID%%\n\t\t\t\tWHERE universe = :universe\n\t\t\t\tAND username = :userName\n\t\t\t) as count;";
     $countUsername = $db->selectSingle($sql, array(':universe' => Universe::current(), ':userName' => $userName), 'count');
     $sql = "SELECT (\n\t\t\tSELECT COUNT(*)\n\t\t\tFROM %%USERS%%\n\t\t\tWHERE universe = :universe\n\t\t\tAND (\n\t\t\t\temail = :mailAddress\n\t\t\t\tOR email_2 = :mailAddress\n\t\t\t)\n\t\t) + (\n\t\t\tSELECT COUNT(*)\n\t\t\tFROM %%USERS_VALID%%\n\t\t\tWHERE universe = :universe\n\t\t\tAND email = :mailAddress\n\t\t) as count;";
     $countMail = $db->selectSingle($sql, array(':universe' => Universe::current(), ':mailAddress' => $mailAddress), 'count');
     if ($countUsername != 0) {
         $errors[] = $LNG['registerErrorUsernameExist'];
     }
     if ($countMail != 0) {
         $errors[] = $LNG['registerErrorMailExist'];
     }
     if ($config->capaktiv === '1') {
         require_once 'includes/libs/reCAPTCHA/recaptchalib.php';
         $recaptcha_challenge_field = HTTP::_GP('recaptcha_challenge_field', '');
         $recaptcha_response_field = HTTP::_GP('recaptcha_response_field', '');
         $resp = recaptcha_check_answer($config->capprivate, Session::getClientIp(), $recaptcha_challenge_field, $recaptcha_response_field);
         if (!$resp->is_valid) {
             $errors[] = $LNG['registerErrorCaptcha'];
         }
     }
     if (!empty($errors)) {
         $this->printMessage(implode("<br>\r\n", $errors), array(array('label' => $LNG['registerBack'], 'url' => 'javascript:window.history.back()')));
     }
     $path = 'includes/extauth/' . $externalAuthMethod . '.class.php';
     if (!empty($externalAuth['account']) && file_exists($path)) {
         require $path;
         $methodClass = ucwords($externalAuthMethod) . 'Auth';
         /** @var $authObj externalAuth */
         $authObj = new $methodClass();
         $externalAuthUID = 0;
         if ($authObj->isActiveMode() && $authObj->isValid()) {
             $externalAuthUID = $authObj->getAccount();
         }
     }
     if ($config->ref_active == 1 && !empty($referralID)) {
         $sql = "SELECT COUNT(*) as state FROM %%USERS%% WHERE id = :referralID AND universe = :universe;";
         $Count = $db->selectSingle($sql, array(':referralID' => $referralID, ':universe' => Universe::current()), 'state');
         if ($Count == 0) {
             $referralID = 0;
         }
     } else {
         $referralID = 0;
     }
     $validationKey = md5(uniqid('2m'));
     $sql = "INSERT INTO %%USERS_VALID%% SET\n\t\t\t\t`userName` = :userName,\n\t\t\t\t`validationKey` = :validationKey,\n\t\t\t\t`password` = :password,\n\t\t\t\t`email` = :mailAddress,\n\t\t\t\t`date` = :timestamp,\n\t\t\t\t`ip` = :remoteAddr,\n\t\t\t\t`language` = :language,\n\t\t\t\t`universe` = :universe,\n\t\t\t\t`referralID` = :referralID,\n\t\t\t\t`externalAuthUID` = :externalAuthUID,\n\t\t\t\t`externalAuthMethod` = :externalAuthMethod;";
     $db->insert($sql, array(':userName' => $userName, ':validationKey' => $validationKey, ':password' => PlayerUtil::cryptPassword($password), ':mailAddress' => $mailAddress, ':timestamp' => TIMESTAMP, ':remoteAddr' => Session::getClientIp(), ':language' => $language, ':universe' => Universe::current(), ':referralID' => $referralID, ':externalAuthUID' => $externalAuthUID, ':externalAuthMethod' => $externalAuthMethod));
     $validationID = $db->lastInsertId();
     $verifyURL = 'index.php?page=vertify&i=' . $validationID . '&k=' . $validationKey;
     if ($config->user_valid == 0 || !empty($externalAuthUID)) {
         $this->redirectTo($verifyURL);
     } else {
         require 'includes/classes/Mail.class.php';
//.........这里部分代码省略.........
开发者ID:bergi9,项目名称:2Moons,代码行数:101,代码来源:ShowRegisterPage.class.php

示例8: show

 function show()
 {
     global $USER, $CONF, $LNG, $UNI;
     $ranki = $GLOBALS['DATABASE']->query("SELECT `id`, s.total_rank, s.build_rank, s.tech_rank FROM " . USERS . " as u INNER JOIN " . STATPOINTS . " as s ON u.id = s.id_owner WHERE onlinetime < " . (TIMESTAMP - 15 * 24 * 60 * 60) . " AND bana = '0' LIMIT  5 ;");
     $balken = $GLOBALS['DATABASE']->countquery("SELECT COUNT(*) FROM " . USERS . " WHERE universe = " . $UNI . " AND onlinetime > '" . (TIMESTAMP - 45 * 60) . "';");
     $länge2 = 365 / $CONF['users_amount'];
     $länge = $balken * $länge2;
     $RangeList = array();
     while ($StatRow = $GLOBALS['DATABASE']->fetch_array($ranki)) {
         $RangeList[] = array('id' => $StatRow['id'], 'total_rank' => $StatRow['total_rank'], 'build_rank' => $StatRow['build_rank'], 'tech_rank' => $StatRow['tech_rank']);
     }
     if ($_POST) {
         $userName = HTTP::_GP('username', '', UTF8_SUPPORT);
         $password = HTTP::_GP('password', '', true);
         $mailAddress = HTTP::_GP('email', '');
         $rulesChecked = HTTP::_GP('rules', 0);
         $id = HTTP::_GP('idc', '');
         $allowedTo = $GLOBALS['DATABASE']->query("SELECT `id`, onlinetime, authlevel FROM " . USERS . " WHERE id = " . $id . " ;");
         $allowedTo = $GLOBALS['DATABASE']->fetch_array($allowedTo);
         $errors = array();
         if (Config::get('game_disable') == 0 || Config::get('reg_closed') == 1) {
             $this->printMessage(t('registerErrorUniClosed'), NULL, array(array('label' => t('registerBack'), 'url' => 'javascript:window.history.back()')));
         }
         //Esto es para verificar si existe ya un usuario con esa ip.
         if (empty($userName)) {
             $errors[] = t('registerErrorUsernameEmpty');
         }
         if ($allowedTo['onlinetime'] > TIMESTAMP - 15 * 24 * 60 * 60) {
             $errors[] = t('youcanttakeoverthisaccount');
         }
         if ($allowedTo['authlevel'] > 0) {
             $errors[] = t('adminaccount');
         }
         if (!PlayerUtil::isNameValid($userName)) {
             $errors[] = t('registerErrorUsernameChar');
         }
         if (strlen($password) < 6) {
             $errors[] = t('registerErrorPasswordLength');
         }
         if (!PlayerUtil::isMailValid($mailAddress)) {
             $errors[] = t('registerErrorMailInvalid');
         }
         if (empty($mailAddress)) {
             $errors[] = t('registerErrorMailEmpty');
         }
         if ($rulesChecked != 1) {
             $errors[] = t('registerErrorRules');
         }
         $countUsername = $GLOBALS['DATABASE']->getFirstCell("SELECT (\n\t\t\tSELECT COUNT(*) \n\t\t\tFROM " . USERS . " \n\t\t\tWHERE universe = " . $GLOBALS['UNI'] . "\n\t\t\tAND username = '" . $GLOBALS['DATABASE']->escape($userName) . "'\n\t\t) + (\n\t\t\tSELECT COUNT(*)\n\t\t\tFROM " . USERS_VALID . "\n\t\t\tWHERE universe = " . $GLOBALS['UNI'] . "\n\t\t\tAND username = '" . $GLOBALS['DATABASE']->escape($userName) . "'\n\t\t);");
         $countMail = $GLOBALS['DATABASE']->getFirstCell("SELECT (\n\t\t\tSELECT COUNT(*)\n\t\t\tFROM " . USERS . "\n\t\t\tWHERE universe = " . $GLOBALS['UNI'] . "\n\t\t\tAND (\n\t\t\t\temail = '" . $GLOBALS['DATABASE']->escape($mailAddress) . "'\n\t\t\t\tOR email_2 = '" . $GLOBALS['DATABASE']->escape($mailAddress) . "'\n\t\t\t)\n\t\t) + (\n\t\t\tSELECT COUNT(*)\n\t\t\tFROM " . USERS_VALID . "\n\t\t\tWHERE universe = " . $GLOBALS['UNI'] . "\n\t\t\tAND email = '" . $GLOBALS['DATABASE']->escape($mailAddress) . "'\n\t\t);");
         if ($countUsername != 0) {
             $errors[] = t('registerErrorUsernameExist');
         }
         if ($countMail != 0) {
             $errors[] = t('registerErrorMailExist');
         }
         if (!empty($errors)) {
             $this->printMessage(implode("<br>\r\n", $errors), NULL, array(array('label' => t('registerBack'), 'url' => 'javascript:window.history.back()')));
         }
         $validationKey = md5(uniqid('2m'));
         $SQL = "UPDATE " . USERS . " SET\n\t\t\t\t`userName` = '" . $GLOBALS['DATABASE']->escape($userName) . "',\n\t\t\t\t`password` = '" . PlayerUtil::cryptPassword($password) . "',\n\t\t\t\t`email` = '" . $GLOBALS['DATABASE']->escape($mailAddress) . "',\n\t\t\t\t`darkmatter` = '300000',\n\t\t\t\t`ip_at_reg` = '" . $_SERVER['REMOTE_ADDR'] . "' WHERE id = '" . $id . "' ;";
         $GLOBALS['DATABASE']->query($SQL);
         $vertifyURL = 'game.php?page=overview';
         if (Config::get('user_valid') == 0 || !empty($externalAuthUID)) {
             $this->redirectTo($vertifyURL);
         } else {
             require 'includes/classes/Mail.class.php';
             $MailSubject = t('registerMailVertifyTitle');
             $MailRAW = $GLOBALS['LNG']->getTemplate('email_vaild_reg');
             $MailContent = str_replace(array('{USERNAME}', '{PASSWORD}', '{GAMENAME}', '{GAMEMAIL}'), array($userName, $password, Config::get('game_name') . ' - ' . Config::get('uni_name'), Config::get('smtp_sendmail')), $MailRAW);
             Mail::send($mailAddress, $userName, t('registerMailVertifyTitle', Config::get('game_name')), $MailContent);
             $this->printMessage(t('registerSendComplete'));
         }
     }
     $this->tplObj->assign_vars(array('RangeList' => $RangeList, 'reg_user' => $CONF['users_amount'], 'online_users' => $balken, 'balken'));
     $this->render('page.takeover.default.tpl');
 }
开发者ID:Decoder1978,项目名称:Xterium,代码行数:77,代码来源:ShowTakeOverPage.class.php

示例9: ShowCreatorPage

function ShowCreatorPage()
{
    global $LNG, $USER;
    $template = new template();
    switch ($_GET['mode']) {
        case 'user':
            $LNG->includeData(array('PUBLIC'));
            if ($_POST) {
                $UserName = HTTP::_GP('name', '', UTF8_SUPPORT);
                $UserPass = HTTP::_GP('password', '');
                $UserPass2 = HTTP::_GP('password2', '');
                $UserMail = HTTP::_GP('email', '');
                $UserMail2 = HTTP::_GP('email2', '');
                $UserAuth = HTTP::_GP('authlevel', 0);
                $Galaxy = HTTP::_GP('galaxy', 0);
                $System = HTTP::_GP('system', 0);
                $Planet = HTTP::_GP('planet', 0);
                $Language = HTTP::_GP('lang', '');
                $ExistsUser = $GLOBALS['DATABASE']->getFirstCell("SELECT (SELECT COUNT(*) FROM " . USERS . " WHERE universe = " . Universe::getEmulated() . " AND username = '" . $GLOBALS['DATABASE']->sql_escape($UserName) . "') + (SELECT COUNT(*) FROM " . USERS_VALID . " WHERE universe = " . Universe::getEmulated() . " AND username = '" . $GLOBALS['DATABASE']->sql_escape($UserName) . "')");
                $ExistsMails = $GLOBALS['DATABASE']->getFirstCell("SELECT (SELECT COUNT(*) FROM " . USERS . " WHERE universe = " . Universe::getEmulated() . " AND (email = '" . $GLOBALS['DATABASE']->sql_escape($UserMail) . "' OR email_2 = '" . $GLOBALS['DATABASE']->sql_escape($UserMail) . "')) + (SELECT COUNT(*) FROM " . USERS_VALID . " WHERE universe = " . Universe::getEmulated() . " AND email = '" . $GLOBALS['DATABASE']->sql_escape($UserMail) . "')");
                $errors = "";
                $config = Config::get(Universe::getEmulated());
                if (!PlayerUtil::isMailValid($UserMail)) {
                    $errors .= $LNG['invalid_mail_adress'];
                }
                if (empty($UserName)) {
                    $errors .= $LNG['empty_user_field'];
                }
                if (strlen($UserPass) < 6) {
                    $errors .= $LNG['password_lenght_error'];
                }
                if ($UserPass != $UserPass2) {
                    $errors .= $LNG['different_passwords'];
                }
                if ($UserMail != $UserMail2) {
                    $errors .= $LNG['different_mails'];
                }
                if (!PlayerUtil::isNameValid($UserName)) {
                    $errors .= $LNG['user_field_specialchar'];
                }
                if ($ExistsUser != 0) {
                    $errors .= $LNG['user_already_exists'];
                }
                if ($ExistsMails != 0) {
                    $errors .= $LNG['mail_already_exists'];
                }
                if (!PlayerUtil::isPositionFree(Universe::getEmulated(), $Galaxy, $System, $Planet)) {
                    $errors .= $LNG['planet_already_exists'];
                }
                if ($Galaxy > $config->max_galaxy || $System > $config->max_system || $Planet > $config->max_planets) {
                    $errors .= $LNG['po_complete_all2'];
                }
                if (!empty($errors)) {
                    $template->message($errors, '?page=create&mode=user', 10, true);
                    exit;
                }
                $Language = array_key_exists($Language, $LNG->getAllowedLangs(false)) ? $Language : $config->lang;
                PlayerUtil::createPlayer(Universe::getEmulated(), $UserName, PlayerUtil::cryptPassword($UserPass), $UserMail, $Language, $Galaxy, $System, $Planet, $LNG['fcm_planet'], $UserAuth);
                $template->message($LNG['new_user_success'], '?page=create&mode=user', 5, true);
                exit;
            }
            $AUTH = array();
            $AUTH[AUTH_USR] = $LNG['user_level'][AUTH_USR];
            if ($USER['authlevel'] >= AUTH_OPS) {
                $AUTH[AUTH_OPS] = $LNG['user_level'][AUTH_OPS];
            }
            if ($USER['authlevel'] >= AUTH_MOD) {
                $AUTH[AUTH_MOD] = $LNG['user_level'][AUTH_MOD];
            }
            if ($USER['authlevel'] >= AUTH_ADM) {
                $AUTH[AUTH_ADM] = $LNG['user_level'][AUTH_ADM];
            }
            $template->assign_vars(array('admin_auth' => $USER['authlevel'], 'new_add_user' => $LNG['new_add_user'], 'new_creator_refresh' => $LNG['new_creator_refresh'], 'new_creator_go_back' => $LNG['new_creator_go_back'], 'universe' => $LNG['mu_universe'], 'user_reg' => $LNG['user_reg'], 'pass_reg' => $LNG['pass_reg'], 'pass2_reg' => $LNG['pass2_reg'], 'email_reg' => $LNG['email_reg'], 'email2_reg' => $LNG['email2_reg'], 'new_coord' => $LNG['new_coord'], 'new_range' => $LNG['new_range'], 'lang_reg' => $LNG['lang_reg'], 'new_title' => $LNG['new_title'], 'Selector' => array('auth' => $AUTH, 'lang' => $LNG->getAllowedLangs(false))));
            $template->show('CreatePageUser.tpl');
            break;
        case 'moon':
            if ($_POST) {
                $PlanetID = HTTP::_GP('add_moon', 0);
                $MoonName = HTTP::_GP('name', '', UTF8_SUPPORT);
                $Diameter = HTTP::_GP('diameter', 0);
                $MoonPlanet = $GLOBALS['DATABASE']->getFirstRow("SELECT temp_max, temp_min, id_luna, galaxy, system, planet, planet_type, destruyed, id_owner FROM " . PLANETS . " WHERE id = '" . $PlanetID . "' AND universe = '" . Universe::getEmulated() . "' AND planet_type = '1' AND destruyed = '0';");
                if (!isset($MoonPlanet)) {
                    $template->message($LNG['mo_planet_doesnt_exist'], '?page=create&mode=moon', 3, true);
                    exit;
                }
                $moonId = PlayerUtil::createMoon(Universe::getEmulated(), $MoonPlanet['galaxy'], $MoonPlanet['system'], $MoonPlanet['planet'], $MoonPlanet['id_owner'], 20, $_POST['diameter_check'] == 'on' ? NULL : $Diameter, $MoonName);
                if ($moonId !== false) {
                    $template->message($LNG['mo_moon_added'], '?page=create&mode=moon', 3, true);
                } else {
                    $template->message($LNG['mo_moon_unavaible'], '?page=create&mode=moon', 3, true);
                }
                exit;
            }
            $template->assign_vars(array('admin_auth' => $USER['authlevel'], 'universum' => $LNG['mu_universe'], 'po_add_moon' => $LNG['po_add_moon'], 'input_id_planet' => $LNG['input_id_planet'], 'mo_moon_name' => $LNG['mo_moon_name'], 'mo_diameter' => $LNG['mo_diameter'], 'mo_temperature' => $LNG['mo_temperature'], 'mo_fields_avaibles' => $LNG['mo_fields_avaibles'], 'button_add' => $LNG['button_add'], 'new_creator_refresh' => $LNG['new_creator_refresh'], 'mo_moon' => $LNG['fcm_moon'], 'new_creator_go_back' => $LNG['new_creator_go_back']));
            $template->show('CreatePageMoon.tpl');
            break;
        case 'planet':
            if ($_POST) {
                $id = HTTP::_GP('id', 0);
                $Galaxy = HTTP::_GP('galaxy', 0);
//.........这里部分代码省略.........
开发者ID:tatarysh,项目名称:2Moons,代码行数:101,代码来源:ShowCreatorPage.php

示例10: ShowQuickEditorPage

function ShowQuickEditorPage()
{
    global $USER, $LNG, $reslist, $resource;
    $action = HTTP::_GP('action', '');
    $edit = HTTP::_GP('edit', '');
    $id = HTTP::_GP('id', 0);
    switch ($edit) {
        case 'planet':
            $DataIDs = array_merge($reslist['fleet'], $reslist['build'], $reslist['defense']);
            $SpecifyItemsPQ = "";
            foreach ($DataIDs as $ID) {
                $SpecifyItemsPQ .= "`" . $resource[$ID] . "`,";
            }
            $PlanetData = $GLOBALS['DATABASE']->getFirstRow("SELECT " . $SpecifyItemsPQ . " `name`, `id_owner`, `planet_type`, `galaxy`, `system`, `planet`, `destruyed`, `diameter`, `field_current`, `field_max`, `temp_min`, `temp_max`, `metal`, `crystal`, `deuterium` FROM " . PLANETS . " WHERE `id` = '" . $id . "';");
            if ($action == 'send') {
                $SQL = "UPDATE " . PLANETS . " SET ";
                $Fields = $PlanetData['field_current'];
                foreach ($DataIDs as $ID) {
                    $level = min(max(0, round(HTTP::_GP($resource[$ID], 0.0))), in_array($ID, $reslist['build']) ? 255 : 1.8446744073709552E+19);
                    if (in_array($ID, $reslist['allow'][$PlanetData['planet_type']])) {
                        $Fields += $level - $PlanetData[$resource[$ID]];
                    }
                    $SQL .= "`" . $resource[$ID] . "` = " . $level . ", ";
                }
                $SQL .= "`metal` = " . max(0, round(HTTP::_GP('metal', 0.0))) . ", ";
                $SQL .= "`crystal` = " . max(0, round(HTTP::_GP('crystal', 0.0))) . ", ";
                $SQL .= "`deuterium` = " . max(0, round(HTTP::_GP('deuterium', 0.0))) . ", ";
                $SQL .= "`field_current` = '" . $Fields . "', ";
                $SQL .= "`field_max` = '" . HTTP::_GP('field_max', 0) . "', ";
                $SQL .= "`name` = '" . $GLOBALS['DATABASE']->sql_escape(HTTP::_GP('name', '', UTF8_SUPPORT)) . "', ";
                $SQL .= "`eco_hash` = '' ";
                $SQL .= "WHERE `id` = '" . $id . "' AND `universe` = '" . Universe::getEmulated() . "';";
                $GLOBALS['DATABASE']->query($SQL);
                $old = array();
                $new = array();
                foreach (array_merge($DataIDs, $reslist['resstype'][1]) as $IDs) {
                    $old[$IDs] = $PlanetData[$resource[$IDs]];
                    $new[$IDs] = max(0, round(HTTP::_GP($resource[$IDs], 0.0)));
                }
                $old['field_max'] = $PlanetData['field_max'];
                $new['field_max'] = HTTP::_GP('field_max', 0);
                $LOG = new Log(2);
                $LOG->target = $id;
                $LOG->old = $old;
                $LOG->new = $new;
                $LOG->save();
                exit(sprintf($LNG['qe_edit_planet_sucess'], $PlanetData['name'], $PlanetData['galaxy'], $PlanetData['system'], $PlanetData['planet']));
            }
            $UserInfo = $GLOBALS['DATABASE']->getFirstRow("SELECT `username` FROM " . USERS . " WHERE `id` = '" . $PlanetData['id_owner'] . "' AND `universe` = '" . Universe::getEmulated() . "';");
            $build = $defense = $fleet = array();
            foreach ($reslist['allow'][$PlanetData['planet_type']] as $ID) {
                $build[] = array('type' => $resource[$ID], 'name' => $LNG['tech'][$ID], 'count' => pretty_number($PlanetData[$resource[$ID]]), 'input' => $PlanetData[$resource[$ID]]);
            }
            foreach ($reslist['fleet'] as $ID) {
                $fleet[] = array('type' => $resource[$ID], 'name' => $LNG['tech'][$ID], 'count' => pretty_number($PlanetData[$resource[$ID]]), 'input' => $PlanetData[$resource[$ID]]);
            }
            foreach ($reslist['defense'] as $ID) {
                $defense[] = array('type' => $resource[$ID], 'name' => $LNG['tech'][$ID], 'count' => pretty_number($PlanetData[$resource[$ID]]), 'input' => $PlanetData[$resource[$ID]]);
            }
            $template = new template();
            $template->assign_vars(array('build' => $build, 'fleet' => $fleet, 'defense' => $defense, 'id' => $id, 'ownerid' => $PlanetData['id_owner'], 'ownername' => $UserInfo['username'], 'name' => $PlanetData['name'], 'galaxy' => $PlanetData['galaxy'], 'system' => $PlanetData['system'], 'planet' => $PlanetData['planet'], 'field_min' => $PlanetData['field_current'], 'field_max' => $PlanetData['field_max'], 'temp_min' => $PlanetData['temp_min'], 'temp_max' => $PlanetData['temp_max'], 'metal' => floatToString($PlanetData['metal']), 'crystal' => floatToString($PlanetData['crystal']), 'deuterium' => floatToString($PlanetData['deuterium']), 'metal_c' => pretty_number($PlanetData['metal']), 'crystal_c' => pretty_number($PlanetData['crystal']), 'deuterium_c' => pretty_number($PlanetData['deuterium'])));
            $template->show('QuickEditorPlanet.tpl');
            break;
        case 'player':
            $DataIDs = array_merge($reslist['tech'], $reslist['officier']);
            $SpecifyItemsPQ = "";
            foreach ($DataIDs as $ID) {
                $SpecifyItemsPQ .= "`" . $resource[$ID] . "`,";
            }
            $UserData = $GLOBALS['DATABASE']->getFirstRow("SELECT " . $SpecifyItemsPQ . " `username`, `authlevel`, `galaxy`, `system`, `planet`, `id_planet`, `darkmatter`, `authattack`, `authlevel` FROM " . USERS . " WHERE `id` = '" . $id . "';");
            $ChangePW = $USER['id'] == ROOT_USER || $id != ROOT_USER && $USER['authlevel'] > $UserData['authlevel'];
            if ($action == 'send') {
                $SQL = "UPDATE " . USERS . " SET ";
                foreach ($DataIDs as $ID) {
                    $SQL .= "`" . $resource[$ID] . "` = " . min(abs(HTTP::_GP($resource[$ID], 0)), 255) . ", ";
                }
                $SQL .= "`darkmatter` = '" . max(HTTP::_GP('darkmatter', 0), 0) . "', ";
                if (!empty($_POST['password']) && $ChangePW) {
                    $SQL .= "`password` = '" . PlayerUtil::cryptPassword(HTTP::_GP('password', '', true)) . "', ";
                }
                $SQL .= "`username` = '" . $GLOBALS['DATABASE']->sql_escape(HTTP::_GP('name', '', UTF8_SUPPORT)) . "', ";
                $SQL .= "`authattack` = '" . ($UserData['authlevel'] != AUTH_USR && HTTP::_GP('authattack', '') == 'on' ? $UserData['authlevel'] : 0) . "' ";
                $SQL .= "WHERE `id` = '" . $id . "' AND `universe` = '" . Universe::getEmulated() . "';";
                $GLOBALS['DATABASE']->query($SQL);
                $old = array();
                $new = array();
                $multi = HTTP::_GP('multi', 0);
                foreach ($DataIDs as $IDs) {
                    $old[$IDs] = $UserData[$resource[$IDs]];
                    $new[$IDs] = abs(HTTP::_GP($resource[$IDs], 0));
                }
                $old[921] = $UserData[$resource[921]];
                $new[921] = abs(HTTP::_GP($resource[921], 0));
                $old['username'] = $UserData['username'];
                $new['username'] = $GLOBALS['DATABASE']->sql_escape(HTTP::_GP('name', '', UTF8_SUPPORT));
                $old['authattack'] = $UserData['authattack'];
                $new['authattack'] = $UserData['authlevel'] != AUTH_USR && HTTP::_GP('authattack', '') == 'on' ? $UserData['authlevel'] : 0;
                $old['multi'] = $GLOBALS['DATABASE']->getFirstCell("SELECT COUNT(*) FROM " . MULTI . " WHERE userID = " . $id . ";");
                $new['authattack'] = $multi;
                if ($old['multi'] != $multi) {
//.........这里部分代码省略.........
开发者ID:tatarysh,项目名称:2Moons,代码行数:101,代码来源:ShowQuickEditorPage.php

示例11: sendDefault

 private function sendDefault()
 {
     global $USER, $LNG, $THEME;
     $adminprotection = HTTP::_GP('adminprotection', 0);
     $username = HTTP::_GP('username', $USER['username'], UTF8_SUPPORT);
     $password = HTTP::_GP('password', '');
     $newpassword = HTTP::_GP('newpassword', '');
     $newpassword2 = HTTP::_GP('newpassword2', '');
     $email = HTTP::_GP('email', $USER['email']);
     $timezone = HTTP::_GP('timezone', '');
     $language = HTTP::_GP('language', '');
     $planetSort = HTTP::_GP('planetSort', 0);
     $planetOrder = HTTP::_GP('planetOrder', 0);
     $theme = HTTP::_GP('theme', $THEME->getThemeName());
     $queueMessages = HTTP::_GP('queueMessages', 0);
     $spyMessagesMode = HTTP::_GP('spyMessagesMode', 0);
     $spycount = HTTP::_GP('spycount', 1.0);
     $fleetactions = HTTP::_GP('fleetactions', 5);
     $galaxySpy = HTTP::_GP('galaxySpy', 0);
     $galaxyMessage = HTTP::_GP('galaxyMessage', 0);
     $galaxyBuddyList = HTTP::_GP('galaxyBuddyList', 0);
     $galaxyMissle = HTTP::_GP('galaxyMissle', 0);
     $blockPM = HTTP::_GP('blockPM', 0);
     $vacation = HTTP::_GP('vacation', 0);
     $delete = HTTP::_GP('delete', 0);
     // Vertify
     $adminprotection = $adminprotection == 1 && $USER['authlevel'] != AUTH_USR ? $USER['authlevel'] : 0;
     $spycount = min(max(round($spycount), 1), 4294967295);
     $fleetactions = min(max($fleetactions, 1), 99);
     $language = array_key_exists($language, $LNG->getAllowedLangs(false)) ? $language : $LNG->getLanguage();
     $theme = array_key_exists($theme, Theme::getAvalibleSkins()) ? $theme : $THEME->getThemeName();
     $db = Database::get();
     if (!empty($username) && $USER['username'] != $username) {
         if (PlayerUtil::isNameValid($username)) {
             $this->printMessage($LNG['op_user_name_no_alphanumeric'], array(array('label' => $LNG['sys_back'], 'url' => 'game.php?page=settings')));
         } elseif ($USER['uctime'] >= TIMESTAMP - USERNAME_CHANGETIME) {
             $this->printMessage($LNG['op_change_name_pro_week'], array(array('label' => $LNG['sys_back'], 'url' => 'game.php?page=settings')));
         } else {
             $sql = "SELECT\n\t\t\t\t\t(SELECT COUNT(*) FROM %%USERS%% WHERE universe = :universe AND username = :username) +\n\t\t\t\t\t(SELECT COUNT(*) FROM %%USERS_VALID%% WHERE universe = :universe AND username = :username)\n\t\t\t\tAS count";
             $Count = $db->selectSingle($sql, array(':universe' => Universe::current(), ':username' => $username), 'count');
             if (!empty($Count)) {
                 $this->printMessage(sprintf($LNG['op_change_name_exist'], $username), array(array('label' => $LNG['sys_back'], 'url' => 'game.php?page=settings')));
             } else {
                 $sql = "UPDATE %%USERS%% SET username = :username, uctime = :timestampt WHERE id = :userID;";
                 $db->update($sql, array(':username' => $username, ':userID' => $USER['id'], ':timestamp' => TIMESTAMP));
                 Session::load()->delete();
             }
         }
     }
     if (!empty($newpassword) && PlayerUtil::cryptPassword($password) == $USER["password"] && $newpassword == $newpassword2) {
         $newpass = PlayerUtil::cryptPassword($newpassword);
         $sql = "UPDATE %%USERS%% SET password = :newpass WHERE id = :userID;";
         $db->update($sql, array(':newpass' => $newpass, ':userID' => $USER['id']));
         Session::load()->delete();
     }
     if (!empty($email) && $email != $USER['email']) {
         if (PlayerUtil::cryptPassword($password) != $USER['password']) {
             $this->printMessage($LNG['op_need_pass_mail'], array(array('label' => $LNG['sys_back'], 'url' => 'game.php?page=settings')));
         } elseif (!ValidateAddress($email)) {
             $this->printMessage($LNG['op_not_vaild_mail'], array(array('label' => $LNG['sys_back'], 'url' => 'game.php?page=settings')));
         } else {
             $sql = "SELECT\n\t\t\t\t\t\t\t(SELECT COUNT(*) FROM %%USERS%% WHERE id != :userID AND universe = :universe AND (email = :email OR email_2 = :email)) +\n\t\t\t\t\t\t\t(SELECT COUNT(*) FROM %%USERS_VALID%% WHERE universe = :universe AND email = :email)\n\t\t\t\t\t\tas COUNT";
             $Count = $db->selectSingle($sql, array(':universe' => Universe::current(), ':userID' => $USER['id'], ':email' => $email), 'count');
             if (!empty($Count)) {
                 $this->printMessage(sprintf($LNG['op_change_mail_exist'], $email), array(array('label' => $LNG['sys_back'], 'url' => 'game.php?page=settings')));
             } else {
                 $sql = "UPDATE %%USERS%% SET email = :email, setmail = :time WHERE id = :userID;";
                 $db->update($sql, array(':email' => $email, ':time' => TIMESTAMP + 604800, ':userID' => $USER['id']));
             }
         }
     }
     if ($vacation == 1) {
         if (!$this->CheckVMode()) {
             $this->printMessage($LNG['op_cant_activate_vacation_mode'], array(array('label' => $LNG['sys_back'], 'url' => 'game.php?page=settings')));
         } else {
             $sql = "UPDATE %%USERS%% SET urlaubs_modus = '1', urlaubs_until = :time WHERE id = :userID";
             $db->update($sql, array(':userID' => $USER['id'], ':time' => TIMESTAMP + Config::get()->vmode_min_time));
             $sql = "UPDATE %%PLANETS%% SET energy_used = '0', energy = '0', metal_mine_porcent = '0', crystal_mine_porcent = '0', deuterium_sintetizer_porcent = '0', solar_plant_porcent = '0', fusion_plant_porcent = '0', solar_satelit_porcent = '0', metal_perhour = '0', crystal_perhour = '0', deuterium_perhour = '0' WHERE id_owner = :userID;";
             $db->update($sql, array(':userID' => $USER['id']));
         }
     }
     if ($delete == 1) {
         $sql = "UPDATE %%USERS%% SET db_deaktjava = :timestamp WHERE id = :userID;";
         $db->update($sql, array(':userID' => $USER['id'], ':timestamp' => TIMESTAMP));
     } else {
         $sql = "UPDATE %%USERS%% SET db_deaktjava = 0 WHERE id = :userID;";
         $db->update($sql, array(':userID' => $USER['id']));
     }
     $sql = "UPDATE %%USERS%% SET\n\t\tdpath\t\t\t\t\t= :theme,\n\t\ttimezone\t\t\t\t= :timezone,\n\t\tplanet_sort\t\t\t\t= :planetSort,\n\t\tplanet_sort_order\t\t= :planetOrder,\n\t\tspio_anz\t\t\t\t= :spyCount,\n\t\tsettings_fleetactions\t= :fleetActions,\n\t\tsettings_esp\t\t\t= :galaxySpy,\n\t\tsettings_wri\t\t\t= :galaxyMessage,\n\t\tsettings_bud\t\t\t= :galaxyBuddyList,\n\t\tsettings_mis\t\t\t= :galaxyMissle,\n\t\tsettings_blockPM\t\t= :blockPM,\n\t\tauthattack\t\t\t\t= :adminProtection,\n\t\tlang\t\t\t\t\t= :language,\n\t\thof\t\t\t\t\t\t= :queueMessages,\n\t\tspyMessagesMode\t\t\t= :spyMessagesMode\n\t\tWHERE id = :userID;";
     $db->update($sql, array(':theme' => $theme, ':timezone' => $timezone, ':planetSort' => $planetSort, ':planetOrder' => $planetOrder, ':spyCount' => $spycount, ':fleetActions' => $fleetactions, ':galaxySpy' => $galaxySpy, ':galaxyMessage' => $galaxyMessage, ':galaxyBuddyList' => $galaxyBuddyList, ':galaxyMissle' => $galaxyMissle, ':blockPM' => $blockPM, ':adminProtection' => $adminprotection, ':language' => $language, ':queueMessages' => $queueMessages, ':spyMessagesMode' => $spyMessagesMode, ':userID' => $USER['id']));
     $this->printMessage($LNG['op_options_changed'], array(array('label' => $LNG['sys_forward'], 'url' => 'game.php?page=settings')));
 }
开发者ID:sincilite,项目名称:Evermoon,代码行数:92,代码来源:ShowSettingsPage.class.php

示例12: list

                 $template->assign(array('host' => $database['host'], 'port' => $database['port'], 'user' => $database['user'], 'dbname' => $database['databasename'], 'prefix' => $database['tableprefix'], 'class' => 'fatalerror', 'message' => $LNG['step3_db_error'] . '</p><p>' . $error));
                 $template->show('ins_step4.tpl');
                 exit;
             }
             break;
         case 7:
             $template->show('ins_acc.tpl');
             break;
         case 8:
             $username = HTTP::_GP('username', '', UTF8_SUPPORT);
             $password = HTTP::_GP('password', '', true);
             $mail = HTTP::_GP('email', '');
             // Get Salt.
             require 'includes/config.php';
             require 'includes/vars.php';
             $hashPassword = PlayerUtil::cryptPassword($password);
             if (empty($username) || empty($password) || empty($mail)) {
                 $template->assign(array('message' => $LNG['step8_need_fields'], 'username' => $username, 'mail' => $mail));
                 $template->show('ins_step8error.tpl');
                 exit;
             }
             list($userId, $planetId) = PlayerUtil::createPlayer(Universe::current(), $username, $hashPassword, $mail, $LNG->getLanguage(), 1, 1, 2, NULL, AUTH_ADM);
             $session = Session::create();
             $session->userId = $userId;
             $session->adminAccess = 1;
             @unlink($enableInstallToolFile);
             $template->show('ins_step8.tpl');
             break;
     }
     break;
 default:
开发者ID:Webmaster1996,项目名称:Antarium,代码行数:31,代码来源:index.php

示例13: show

 function show()
 {
     if (empty($_POST)) {
         HTTP::redirectTo('index.php');
     }
     $username = HTTP::_GP('username', '', UTF8_SUPPORT);
     $password = HTTP::_GP('password', '', true);
     $loginData = $GLOBALS['DATABASE']->getFirstRow("SELECT id, password, intro, username, user_deleted FROM " . USERS . " WHERE universe = " . $GLOBALS['UNI'] . " AND username = '" . $GLOBALS['DATABASE']->escape($username) . "';");
     if (isset($loginData)) {
         $hashedPassword = PlayerUtil::cryptPassword($password);
         if ($loginData['password'] != $hashedPassword) {
             // Fallback pre 1.7
             if ($loginData['password'] == md5($password)) {
                 $GLOBALS['DATABASE']->query("UPDATE " . USERS . " SET password = '" . $hashedPassword . "' WHERE id = " . $loginData['id'] . ";");
             } else {
                 HTTP::redirectTo('index.php?code=1');
             }
         }
         $ip = "";
         if (!empty($_SERVER["HTTP_CLIENT_IP"])) {
             //check for ip from share internet
             $ip = $_SERVER["HTTP_CLIENT_IP"];
         } elseif (!empty($_SERVER["HTTP_X_FORWARDED_FOR"])) {
             // Check for the Proxy User
             $ip = $_SERVER["HTTP_X_FORWARDED_FOR"];
         } else {
             $ip = $_SERVER["REMOTE_ADDR"];
         }
         $ua = $this->getBrowser();
         $os = $this->GetOS();
         //$ipCheck = $GLOBALS['DATABASE']->query("SELECT COUNT(logID) as id FROM uni1_iplog WHERE userID = ".$loginData['id']." AND ipaddress = '".$ip."';");
         //$ipCheck = $GLOBALS['DATABASE']->fetch_array($ipCheck);
         //if($ipCheck['id'] == 0){
         $GLOBALS['DATABASE']->query("INSERT INTO uni1_iplog VALUES ('" . $GLOBALS['DATABASE']->GetInsertID() . "','" . TIMESTAMP . "','" . $ip . "','" . $ua['name'] . "', '" . $os . "', " . $loginData['id'] . ");");
         //}
         $ipCheck = $GLOBALS['DATABASE']->query("SELECT DISTINCT userID FROM uni1_iplog WHERE userID != " . $loginData['id'] . " AND ipaddress = '" . $ip . "';");
         Session::create($loginData['id']);
         if ($loginData['intro'] == 0) {
             HTTP::redirectTo('game.php?page=intro');
         } else {
             HTTP::redirectTo('game.php');
         }
     } else {
         Session::redirectCode(1);
     }
 }
开发者ID:fuding,项目名称:Antaris,代码行数:46,代码来源:ShowLoginPage.class.php

示例14: send

 function send()
 {
     $userName = HTTP::_GP('username', '', UTF8_SUPPORT);
     $password = HTTP::_GP('password', '', true);
     $password2 = HTTP::_GP('passwordReplay', '', true);
     $captcha = HTTP::_GP('captcha', '');
     $mailAddress = HTTP::_GP('email', '');
     $rulesChecked = HTTP::_GP('reglement', 0);
     $condition = HTTP::_GP('condition', 0);
     $id_reprise = HTTP::_GP('id_reprise', 0);
     $nom_planete = HTTP::_GP('nom_planete', '');
     $stats_sql = 'SELECT DISTINCT u.*, s.total_points, p.name, a.ally_tag, a.ally_name FROM ' . USERS . ' as u
             INNER JOIN ' . STATPOINTS . ' as s ON s.id_owner = u.id
             LEFT JOIN ' . ALLIANCE . ' as a ON a.id = u.ally_id
             LEFT JOIN ' . PLANETS . ' as p ON p.id = u.id_planet
             WHERE s.`universe` = 1 AND u.id = ' . $id_reprise . ';';
     $query = $GLOBALS['DATABASE']->query($stats_sql);
     $errors = array();
     if (Config::get('reg_closed') == 1) {
         $this->printMessage(t('registerErrorUniClosed'), NULL, array(array('label' => t('registerBack'), 'url' => 'javascript:window.history.back()')));
     }
     if ($_SESSION['code'] != $captcha) {
         $errors[] = t('registerErrorCaptchas');
     }
     while ($StatRow = $GLOBALS['DATABASE']->fetch_array($query)) {
         if ($StatRow['onlinetime'] > TIMESTAMP - 90 * 24 * 3600) {
             $errors[] = t('cannottakeover');
         }
     }
     if (empty($userName)) {
         $errors[] = t('registerErrorUsernameEmpty');
     }
     if (empty($nom_planete)) {
         $errors[] = t('registerErrorPlanetnameEmpty');
     }
     if (strlen($nom_planete) > 18) {
         $errors[] = t('registerErrorPlanetnametolong');
     }
     if (strlen($nom_planete) < 5) {
         $errors[] = t('registerErrorPlanetnametoshort');
     }
     if (!PlayerUtil::isNameValid($userName)) {
         $errors[] = t('registerErrorUsernameChar');
     }
     if (strlen($userName) < 3) {
         $errors[] = t('registerErroruserNameLength');
     }
     if (strlen($userName) > 16) {
         $errors[] = t('registerErroruserNameLength');
     }
     if (strlen($password) < 6) {
         $errors[] = t('registerErrorPasswordLength');
     }
     if (strlen($password) > 32) {
         $errors[] = t('registerErrorPasswordLength');
     }
     if ($password != $password2) {
         $errors[] = t('registerErrorPasswordSame');
     }
     if (!PlayerUtil::isMailValid($mailAddress)) {
         $errors[] = t('registerErrorMailInvalid');
     }
     if (!PlayerUtil::valid_mail($mailAddress)) {
         $errors[] = t('registerErrorMailInvalid2');
     }
     if (empty($mailAddress)) {
         $errors[] = t('registerErrorMailEmpty');
     }
     if ($rulesChecked != 1) {
         $errors[] = t('registerErrorRules');
     }
     if ($condition != 1) {
         $errors[] = t('registerErrorTerms');
     }
     $countUsername = $GLOBALS['DATABASE']->getFirstCell("SELECT (\n\t\t\tSELECT COUNT(*) \n\t\t\tFROM " . USERS . " \n\t\t\tWHERE universe = " . $GLOBALS['UNI'] . "\n\t\t\tAND username = '" . $GLOBALS['DATABASE']->escape($userName) . "'\n\t\t) + (\n\t\t\tSELECT COUNT(*)\n\t\t\tFROM " . USERS_VALID . "\n\t\t\tWHERE universe = " . $GLOBALS['UNI'] . "\n\t\t\tAND username = '" . $GLOBALS['DATABASE']->escape($userName) . "'\n\t\t);");
     $countMail = $GLOBALS['DATABASE']->getFirstCell("SELECT (\n\t\t\tSELECT COUNT(*)\n\t\t\tFROM " . USERS . "\n\t\t\tWHERE universe = " . $GLOBALS['UNI'] . "\n\t\t\tAND (\n\t\t\t\temail = '" . $GLOBALS['DATABASE']->escape($mailAddress) . "'\n\t\t\t\tOR email_2 = '" . $GLOBALS['DATABASE']->escape($mailAddress) . "'\n\t\t\t)\n\t\t) + (\n\t\t\tSELECT COUNT(*)\n\t\t\tFROM " . USERS_VALID . "\n\t\t\tWHERE universe = " . $GLOBALS['UNI'] . "\n\t\t\tAND email = '" . $GLOBALS['DATABASE']->escape($mailAddress) . "'\n\t\t);");
     if ($countUsername != 0) {
         $errors[] = t('registerErrorUsernameExist');
     }
     if ($countMail != 0) {
         $errors[] = t('registerErrorMailExist');
     }
     if (!empty($errors)) {
         $this->printMessage(implode("<br>\r\n", $errors), NULL, array(array('label' => t('registerBack'), 'url' => 'javascript:window.history.back()')));
     }
     $validationKey = md5(uniqid('2m'));
     $SQL = "UPDATE " . USERS . " SET\n\t\t\t\t`username` = '" . $GLOBALS['DATABASE']->escape($userName) . "',\n\t\t\t\t`password` = '" . PlayerUtil::cryptPassword($password) . "',\n\t\t\t\t`email` = '" . $GLOBALS['DATABASE']->escape($mailAddress) . "',\n\t\t\t\t`email_2` = '" . $GLOBALS['DATABASE']->escape($mailAddress) . "',\n\t\t\t\t`register_time` = '" . TIMESTAMP . "',\n\t\t\t\t`ip_at_reg` = '" . $_SERVER['REMOTE_ADDR'] . "',\n\t\t\t\t`validationKey` = '" . $validationKey . "',\n\t\t\t\t`lang` = 'en',\n\t\t\t\t`sexe` = '',\n\t\t\t\t`date_of_birth` = '0',\n\t\t\t\t`ref_id` = 0,\n\t\t\t\t`ref_bonus` = 0,\n\t\t\t\t`ref_bonus` = 0,\n\t\t\t\t`urlaubs_modus` = 0,\n\t\t\t\t`urlaubs_until` = 0 WHERE id = '" . $id_reprise . "';";
     $GLOBALS['DATABASE']->query($SQL);
     $validationID = $GLOBALS['DATABASE']->GetInsertID();
     $vertifyURL = 'index.php?page=vertifyr&k=' . $validationKey;
     require 'includes/classes/Mail.class.php';
     $MailSubject = t('registerMailVertifyTitle');
     $MailRAW = $GLOBALS['LNG']->getTemplate('email_vaild_reg');
     $MailContent = str_replace(array('{USERNAME}', '{PASSWORD}', '{GAMENAME}', '{VERTIFYURL}', '{GAMEMAIL}', '{EMAIL}', '{REGISTERIP}', '{PLANETNAME}'), array($userName, $password, Config::get('game_name') . ' - ' . Config::get('uni_name'), HTTP_PATH . $vertifyURL, Config::get('smtp_sendmail'), $mailAddress, $_SERVER['REMOTE_ADDR'], $nom_planete), $MailRAW);
     $headers = 'From: (EMAIL)' . "\r\n";
     $headers .= 'Reply-To: (EMAIL)' . "\r\n";
     $headers .= "MIME-Version: 1.0\r\n";
     $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
     //mail($mailAddress, t('registerMailVertifyTitle', Config::get('game_name')), $MailContent, $headers);
     Mail::send($mailAddress, $userName, t('registerMailVertifyTitle', Config::get('game_name')), $MailContent);
//.........这里部分代码省略.........
开发者ID:fuding,项目名称:Antaris,代码行数:101,代码来源:ShowResumePage.class.php

示例15: send


//.........这里部分代码省略.........
     }
     if (strlen($nom_planete) > 10) {
         $errors[] = t('registerErrorPlanetnametolong');
     }
     if (strlen($nom_planete) < 5) {
         $errors[] = t('registerErrorPlanetnametoshort');
     }
     if (!PlayerUtil::isNameValid($userName)) {
         $errors[] = t('registerErrorUsernameChar');
     }
     if (strlen($userName) < 3) {
         $errors[] = t('registerErroruserNameLength');
     }
     if (strlen($userName) > 16) {
         $errors[] = t('registerErroruserNameLength');
     }
     if (strlen($password) < 6) {
         $errors[] = t('registerErrorPasswordLength');
     }
     if (strlen($password) > 32) {
         $errors[] = t('registerErrorPasswordLength');
     }
     if ($password != $password2) {
         $errors[] = t('registerErrorPasswordSame');
     }
     if (!PlayerUtil::isMailValid($mailAddress)) {
         $errors[] = t('registerErrorMailInvalid');
     }
     if (!PlayerUtil::valid_mail($mailAddress)) {
         $errors[] = t('registerErrorMailInvalid2');
     }
     if (empty($mailAddress)) {
         $errors[] = t('registerErrorMailEmpty');
     }
     if ($rulesChecked != 1) {
         $errors[] = t('registerErrorRules');
     }
     if ($condition != 1) {
         $errors[] = t('registerErrorTerms');
     }
     $countUsername = $GLOBALS['DATABASE']->getFirstCell("SELECT (\n\t\t\tSELECT COUNT(*) \n\t\t\tFROM " . USERS . " \n\t\t\tWHERE universe = " . $universum . "\n\t\t\tAND username = '" . $GLOBALS['DATABASE']->escape($userName) . "'\n\t\t) + (\n\t\t\tSELECT COUNT(*)\n\t\t\tFROM " . USERS_VALID . "\n\t\t\tWHERE universe = " . $universum . "\n\t\t\tAND username = '" . $GLOBALS['DATABASE']->escape($userName) . "'\n\t\t);");
     $countMail = $GLOBALS['DATABASE']->getFirstCell("SELECT (\n\t\t\tSELECT COUNT(*)\n\t\t\tFROM " . USERS . "\n\t\t\tWHERE universe = " . $universum . "\n\t\t\tAND (\n\t\t\t\temail = '" . $GLOBALS['DATABASE']->escape($mailAddress) . "'\n\t\t\t\tOR email_2 = '" . $GLOBALS['DATABASE']->escape($mailAddress) . "'\n\t\t\t)\n\t\t) + (\n\t\t\tSELECT COUNT(*)\n\t\t\tFROM " . USERS_VALID . "\n\t\t\tWHERE universe = " . $universum . "\n\t\t\tAND email = '" . $GLOBALS['DATABASE']->escape($mailAddress) . "'\n\t\t);");
     if ($countUsername != 0) {
         $errors[] = t('registerErrorUsernameExist');
     }
     if ($countMail != 0) {
         $errors[] = t('registerErrorMailExist');
     }
     if (Config::get('capaktiv') === '1') {
         require_once 'includes/libs/reCAPTCHA/recaptchalib.php';
         $resp = recaptcha_check_answer(Config::get('capprivate'), $_SERVER['REMOTE_ADDR'], $_REQUEST['recaptcha_challenge_field'], $_REQUEST['recaptcha_response_field']);
         if (!$resp->is_valid) {
             $errors[] = t('registerErrorCaptcha');
         }
     }
     if (!empty($errors)) {
         $this->printMessage(implode("<br>\r\n", $errors), NULL, array(array('label' => t('registerBack'), 'url' => 'javascript:window.history.back()')));
     }
     if (!empty($externalAuth['account']) && file_exists('includes/extauth/' . $externalAuthMethod . '.class.php')) {
         require 'includes/extauth/' . $externalAuthMethod . '.class.php';
         $methodClass = ucwords($externalAuthMethod) . 'Auth';
         $authObj = new $methodClass();
         if (!$authObj->isActiveMode()) {
             $externalAuthUID = 0;
         }
         if (!$authObj->isVaild()) {
             $externalAuthUID = 0;
         }
         $externalAuthUID = $authObj->getAccount();
     }
     if (Config::get('ref_active') == 1 && !empty($referralID)) {
         $Count = $GLOBALS['DATABASE']->getFirstCell("SELECT COUNT(*) FROM " . USERS . " WHERE id = " . $referralID . " AND universe = " . $GLOBALS['UNI'] . ";");
         if ($Count == 0) {
             $referralID = 0;
         }
     } else {
         $referralID = 0;
     }
     $validationKey = md5(uniqid('2m'));
     $SQL = "INSERT INTO " . USERS_VALID . " SET\n\t\t\t\t`userName` = '" . $GLOBALS['DATABASE']->escape($userName) . "',\n\t\t\t\t`validationKey` = '" . $validationKey . "',\n\t\t\t\t`password` = '" . PlayerUtil::cryptPassword($password) . "',\n\t\t\t\t`email` = '" . $GLOBALS['DATABASE']->escape($mailAddress) . "',\n\t\t\t\t`planetName` = '" . $GLOBALS['DATABASE']->escape($nom_planete) . "',\n\t\t\t\t`date` = '" . TIMESTAMP . "',\n\t\t\t\t`ip` = '" . $_SERVER['REMOTE_ADDR'] . "',\n\t\t\t\t`language` = 'en',\n\t\t\t\t`universe` = " . $universum . ",\n\t\t\t\t`referralID` = " . $referralID . ",\n\t\t\t\t`externalAuthUID` = '" . $GLOBALS['DATABASE']->escape($externalAuthUID) . "',\n\t\t\t\t`externalAuthMethod` = '" . $externalAuthMethod . "';";
     $GLOBALS['DATABASE']->query($SQL);
     $validationID = $GLOBALS['DATABASE']->GetInsertID();
     $vertifyURL = 'index.php?page=vertify&i=' . $validationID . '&k=' . $validationKey;
     if (Config::get('user_valid') == 0 || !empty($externalAuthUID)) {
         $this->redirectTo($vertifyURL);
     } else {
         require 'includes/classes/Mail.class.php';
         $MailSubject = t('registerMailVertifyTitle');
         $MailRAW = $GLOBALS['LNG']->getTemplate('email_vaild_reg');
         $MailContent = str_replace(array('{USERNAME}', '{PASSWORD}', '{GAMENAME}', '{VERTIFYURL}', '{GAMEMAIL}', '{EMAIL}', '{REGISTERIP}', '{PLANETNAME}'), array($userName, $password, Config::get('game_name') . ' - ' . Config::get('uni_name'), HTTP_PATH . $vertifyURL, Config::get('smtp_sendmail'), $mailAddress, $_SERVER['REMOTE_ADDR'], $nom_planete), $MailRAW);
         $headers = 'From: (EMAIL)' . "\r\n";
         $headers .= 'Reply-To: (EMAIL)' . "\r\n";
         $headers .= "MIME-Version: 1.0\r\n";
         $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
         mail($mailAddress, t('registerMailVertifyTitle', Config::get('game_name')), $MailContent, $headers);
         //Mail::send($mailAddress, $userName, t('registerMailVertifyTitle', Config::get('game_name')), $MailContent);
         //Mail::send($mailAddress, $userName, $subject, $MailContent);
         $this->printMessage(t('registerSendComplete', $mailAddress));
     }
 }
开发者ID:fuding,项目名称:Antaris,代码行数:101,代码来源:ShowRegisterPage.class.php


注:本文中的PlayerUtil::cryptPassword方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。