$password = urldecode($_POST['password']); $db = $_POST['db']; $host = $_POST['host']; $connection = mysqli_connect($host, $username, $password, $db); if (!$connection) { $error = true; } else { $test = "SELECT 1 + 1 AS sum"; $result = mysqli_fetch_array(mysqli_query($connection, $test)); if (!$result) { $error = true; } else { if (intval($result['sum']) == 2) { $_SESSION['installer'] = 1; //initialize AES secret key. $aesKey = generateRandomKey(); $aesKeyString = "<?php\ninclude 'Aes.php';\ninclude 'AesCtr.php';\n\nfunction getSecretAESKey() {\nreturn \"{$aesKey}\";\n}\nfunction decrypt(\$input) {\nreturn AesCtr::decrypt(\$input, getSecretAESKey(), 256);\n}\nfunction encrypt(\$input) {\nreturn AesCtr::encrypt(\$input, getSecretAESKey(), 256);\n}"; $aesFile = fopen("../../aesFunc.php", "w") or die("Unable to create aesKey.php in the root folder of the panel. Please recheck the permissions and try again."); fwrite($aesFile, $aesKeyString); fclose($aesFile); include '../../aesFunc.php'; $password = encrypt($password); $configurationFile = "<?php\n\nfunction getMySQLConnection() {\n return mysqli_connect(\"{$host}\", \"{$username}\", decrypt(\"{$password}\"), \"{$db}\");\n}"; $file = fopen("../../config.php", "w") or die("Unable to create config.php file in the root folder of the panel.<br>Please check that does the default user for your HTTP engine (by default, www-data) has write access on the panel folder."); fwrite($file, $configurationFile); fclose($file); $q1 = "CREATE TABLE 1fx_serverlogs (serverlog_id INTEGER NOT NULL AUTO_INCREMENT, user_id INTEGER NOT NULL, user_ip VARCHAR(255) NOT NULL, server_id INTEGER, severity TINYINT NOT NULL, fa_icon VARCHAR(255), action TEXT NOT NULL, time INTEGER NOT NULL, PRIMARY KEY(serverlog_id))"; $q2 = "CREATE TABLE 1fx_failedlogins (failedlogin_id INTEGER NOT NULL AUTO_INCREMENT, failed_user VARCHAR(255), failed_ip VARCHAR(255), time INTEGER, PRIMARY KEY(failedlogin_id))"; $q3 = "CREATE TABLE 1fx_forgottenpsw(forgotten_id INTEGER NOT NULL AUTO_INCREMENT, user_id INTEGER, reqkey VARCHAR(50), regtime INTEGER, PRIMARY KEY(forgotten_id), CONSTRAINT can_only_request_once UNIQUE(user_id))"; $q4 = "CREATE TABLE 1fx_games (game_id INTEGER NOT NULL AUTO_INCREMENT, game_name VARCHAR(255), game_location VARCHAR(500), startscript TEXT, mod_url TEXT, PRIMARY KEY(game_id), CONSTRAINT game_name_must_be_unique UNIQUE(game_name))"; $q5 = "INSERT INTO 1fx_games (game_name, game_location, startscript, mod_url) VALUES ('SoF2 Silver', '/usr/local/games/sof2', 'export LD_LIBRARY_PATH=/usr/local/games/1fxlib;ln -s /usr/local/games/base ~/base;~/sof2ded +set dedicated 2 +set vm_game 0 +set fs_game RPM +set net_port {port} +set fs_homepath /home/{user} +exec Config.cfg', 'http://1fxmod.org/download/'), ('SoF2 Gold', '/usr/games/sof2gold', 'ln -s /usr/games/base ~/base;~/sof2ded +set dedicated 2 +set vm_game 0 +set fs_game 1fx +set net_port {port} +set fs_homepath /home/{user} +exec Config.cfg', 'http://1fxmod.org/gold/download/')";
// Generate a random session key $randomKey = ''; for ($i = 0; $i < $length; $i++) { $randomKey .= $chars[rand(0, strlen($chars) - 1)]; } // Return the random key return $randomKey; } // Get the session cookie name $sessionCookieName = Registry::getValue('client.session.cookie.name')->getValue(); // Make sure the session cookie is set if (!CookieManager::hasCookie($sessionCookieName)) { // Get the session timeout $sessionTimeout = Registry::getValue('client.session.timeout')->getValue(); // Generate a session key $sessionKey = generateRandomKey(); // Set the session CookieManager::setCookie($sessionCookieName, $sessionKey, $sessionTimeout); // Set the session key global $GLOBALS['session_key'] = $sessionKey; } /** * Get the key of the current client session. * * @return string Session key * * @throws Exception Throws if an error occurred. */ function getSessionKey() { // Return the key from the globals if set
/** * Get everything which is hashed with the old key, decrypt it. * After that, encrypt it all with the new key and write the new key file. * * Encrypted: * 1fx_serverhosts.host_password * 1fx_servers.server_password * 1fx_servers.rconpassword * 1fx_panelpreferences.name WHERE description=Mail * 1fx_panelpreferences.password WHERE description=IPB4 * @todo Everything */ function regenerateAESKey() { $newKey = generateRandomKey(); }
$status['status'] = "0"; $status['response'] = "Unsuccessful"; if (isset($_POST)) { $db = new Database(); $con = $db->connect(); $user_id = $_POST['user_id']; $posted_by = $_POST['posted_by']; $event_name = $_POST['event_name']; $event_type = $_POST['event_type']; $details = $_POST['details']; $location = $_POST['location']; $start_date = $_POST['start_date']; $end_date = $_POST['end_date']; $lattitude = $_POST['lattitude']; $longtitude = $_POST['longtitude']; $random_key = generateRandomKey(10); $str_query = "INSERT INTO events \n\t\t\t\t\t(event_name, event_type, pass_key, details, location, lattitude, longtitude, start_date, end_date, posted_date, posted_by, posted_by_type, avail_status, active_flag)\n\t\t\t\t\tVALUES \n\t\t\t\t\t('{$event_name}', '{$event_type}', '{$random_key}', '{$details}', '{$location}', '{$lattitude}', '{$longtitude}', '{$start_date}', '{$end_date}', NOW(), {$user_id}, '{$posted_by}', 'A', 'A');"; if ($result = $con->query($str_query)) { $status['status'] = "1"; $status['response'] = "Successful"; } } function generateRandomKey($length = 10) { $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $charactersLength = strlen($characters); $randomString = ''; for ($i = 0; $i < $length; $i++) { $randomString .= $characters[rand(0, $charactersLength - 1)]; } return $randomString;