public static function Login($username, $password) { $password = crypt($password, $username); //Хорошо бы на SHA-2 заменить $userData = DB::Get()->Select('SELECT * FROM User WHERE email=:email AND `password`=:password', array('email' => $username, 'password' => $password)); // echo $username.$password; if (isset($userData[0])) { Session::CreateSession($userData[0]['id']); return User::Create($userData[0]); } return false; }
$SQL .= "`deuterium_perhour` = '0', "; $SQL .= "`deuterium_max` = '1000000';"; $SQL .= "INSERT INTO " . STATPOINTS . " (`id_owner`, `id_ally`, `stat_type`, `tech_rank`, `tech_old_rank`, `tech_points`, `tech_count`, `build_rank`, `build_old_rank`, `build_points`, `build_count`, `defs_rank`, `defs_old_rank`, `defs_points`, `defs_count`, `fleet_rank`, `fleet_old_rank`, `fleet_points`, `fleet_count`, `total_rank`, `total_old_rank`, `total_points`, `total_count`) VALUES ('1', '0', '1', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0');"; $SQL .= "UPDATE " . CONFIG . " SET `lang` = '" . $LANG->GetUser() . "';"; $db->multi_query($SQL); ini_set('session.save_path', ROOT_PATH . 'cache/sessions'); ini_set('upload_tmp_dir', ROOT_PATH . 'cache/sessions'); ini_set('session.use_cookies', '1'); ini_set('session.use_only_cookies', '1'); session_set_cookie_params(SESSION_LIFETIME, '/'); session_cache_limiter('nocache'); session_name($dbsettings["secretword"]); ini_set('session.use_trans_sid', 0); ini_set('session.auto_start', '0'); ini_set('session.serialize_handler', 'php'); ini_set('session.gc_maxlifetime', SESSION_LIFETIME); ini_set('session.gc_probability', '1'); ini_set('session.gc_divisor', '1000'); ini_set('session.bug_compat_warn', '0'); ini_set('session.bug_compat_42', '0'); ini_set('session.cookie_httponly', true); require_once ROOT_PATH . 'includes/classes/class.Session.php'; session_start(); $SESSION = new Session(); $SESSION->CreateSession(1, $adm_user, 1, 1, 3); $_SESSION['admin_login'] = $md5pass; redirectTo('admin.php'); break; } break; }
<?php define('MODE', 'LOGIN'); define('ROOT_PATH', str_replace('\\', '/', dirname(__FILE__)) . '/'); set_include_path(ROOT_PATH); require 'includes/common.php'; $LNG->includeData(array('L18N', 'INGAME', 'ADMIN')); if (isset($_REQUEST['admin_pw'])) { $login = $GLOBALS['DATABASE']->getFirstRow("SELECT `id`, `username`, `dpath`, `authlevel`, `id_planet` FROM " . USERS . " WHERE `id` = '1' AND `password` = '" . cryptPassword($_REQUEST['admin_pw']) . "';"); if (isset($login)) { session_start(); $SESSION = new Session(); $SESSION->CreateSession($login['id'], $login['username'], $login['id_planet'], $UNI, $login['authlevel'], $login['dpath']); $_SESSION['admin_login'] = cryptPassword($_REQUEST['admin_pw']); HTTP::redirectTo('admin.php'); } } $template = new template(); $tplDir = $template->getTemplateDir(); $template->setTemplateDir($tplDir[0] . 'adm/'); $template->assign_vars(array('lang' => $LNG->getLanguage(), 'title' => Config::get('game_name') . ' - ' . $LNG['adm_cp_title'], 'REV' => substr(Config::get('VERSION'), -4), 'date' => explode("|", date('Y\\|n\\|j\\|G\\|i\\|s\\|Z', TIMESTAMP)), 'Offset' => 0, 'VERSION' => Config::get('VERSION'), 'dpath' => 'gow', 'bodyclass' => 'popup', 'username' => 'root')); $template->show('LoginPage.tpl');
$SQL .= "password\t\t= '" . $GLOBALS['DATABASE']->sql_escape($md5Password) . "', "; $SQL .= "email\t\t\t= '" . $GLOBALS['DATABASE']->sql_escape($AdminMail) . "', "; $SQL .= "email_2\t\t= '" . $GLOBALS['DATABASE']->sql_escape($AdminMail) . "', "; $SQL .= "ip_at_reg\t\t= '" . $_SERVER['REMOTE_ADDR'] . "', "; $SQL .= "lang\t\t\t= '" . $LNG->getLanguage() . "', "; $SQL .= "authlevel\t\t= " . AUTH_ADM . ", "; $SQL .= "dpath \t\t\t= '" . DEFAULT_THEME . "', "; $SQL .= "rights\t\t\t= '', "; $SQL .= "id_planet\t\t= 1, "; $SQL .= "universe\t\t= 1, "; $SQL .= "galaxy\t\t\t= 1, "; $SQL .= "system\t\t\t= 1, "; $SQL .= "planet\t\t\t= 2, "; $SQL .= "register_time\t= " . TIMESTAMP . ";"; $GLOBALS['DATABASE']->query($SQL); require_once 'includes/functions/CreateOnePlanetRecord.php'; $PlanetID = CreateOnePlanetRecord(1, 1, 1, 1, 1, '', true, AUTH_ADM); $SESSION = new Session(); $SESSION->DestroySession(); $SESSION->CreateSession(1, $AdminUsername, $PlanetID, 1, 3, DEFAULT_THEME); $_SESSION['admin_login'] = $md5Password; @unlink($enableInstallToolFile); $template->show('ins_step8.tpl'); break; } break; default: $template->assign(array('intro_text' => $LNG['intro_text'], 'intro_welcome' => $LNG['intro_welcome'], 'intro_install' => $LNG['intro_install'])); $template->show('ins_intro.tpl'); break; }