function send()
 {
     $userName = HTTP::_GP('username', '', UTF8_SUPPORT);
     $password = HTTP::_GP('password', '', true);
     $mailAddress = HTTP::_GP('email', '');
     $language = HTTP::_GP('lang', '');
     $universum = HTTP::_GP('uni', 1);
     $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 (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()')));
     }
     if (empty($userName)) {
         $errors[] = t('registerErrorUsernameEmpty');
     }
     if (!PlayerUtil::isNameValid($userName)) {
         $errors[] = t('registerErrorUsernameChar');
     }
     if (strlen($password) < 6) {
         $errors[] = t('registerErrorPasswordLength');
     }
     if (!PlayerUtil::isMailValid($mailAddress)) {
         $errors[] = t('registerErrorMailInvalid');
     }
     if (!PlayerUtil::valid_mail($mailAddress)) {
         $errors[] = t('registerErrorMailInvalid2');
     }
     if (empty($mailAddress)) {
         $errors[] = t('registerErrorMailEmpty');
     }
     $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 = '******'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 = '******'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` = '" . md5($password) . "',\n\t\t\t\t`email` = '" . $GLOBALS['DATABASE']->escape($mailAddress) . "',\n\t\t\t\t`date` = '" . TIMESTAMP . "',\n\t\t\t\t`ip` = '" . $_SERVER['REMOTE_ADDR'] . "',\n\t\t\t\t`language` = '" . $GLOBALS['DATABASE']->escape($language) . "',\n\t\t\t\t`universe` = " . $GLOBALS['UNI'] . ",\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}'), array($mailAddress, $password, Config::get('game_name') . ' - ' . Config::get('uni_name'), HTTP_PATH . $vertifyURL, Config::get('smtp_sendmail')), $MailRAW);
         Mail::send($mailAddress, $userName, t('registerMailVertifyTitle', Config::get('game_name')), $MailContent);
         $this->printMessage(t('registerSendComplete'));
     }
 }
예제 #2
0
 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 = '******'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 = '******'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);
     $this->printMessage(t('registerSendComplete'));
 }