/** Run the actual setup process */ function DoSetup() { $lock_file_name = '../data/setup.lock'; //Check if the lock file already exists if (!file_exists($lock_file_name)) { echo GetLocalizedString('setup-creating-lock') . "\n"; //Warn if ignore_setup_lock is enabled if (ReadConfigInt('ignore_setup_lock', '0')) { echo GetLocalizedString('setup-lock-pointless') . "\n"; } //Create the lock file touch($lock_file_name); } else { //Ignore the lock file and blow away the db if (ReadConfigInt('ignore_setup_lock', '0')) { echo GetLocalizedString('setup-trampling') . "\n"; } else { die(GetLocalizedString('setup-already-run')) . "\n"; } } //If we get to this point the lock either doesn't exist or has been ignored. Start the setup process. //Run the setup queries global $g_dbconn; if (!$g_dbconn->multi_query(file_get_contents('../setup/setup.sql'))) { die(DatabaseError()); } while ($g_dbconn->more_results()) { if (!$g_dbconn->next_result()) { die(DatabaseError()); } } echo GetLocalizedString('setup-done'); }
/** @brief Set up the database connection and initialize the current session */ function SessionInit() { //connect to database global $g_dbconn; $g_dbconn = new mysqli(ReadConfigString('db_server', 'localhost'), ReadConfigString('db_user', 'penguin'), ReadConfigString('db_pass', ''), ReadConfigString('db_name', 'penguin'), ReadConfigInt('db_port', 3306)); if ($g_dbconn->connect_error) { DatabaseError(); } //create session and set up default variables session_start(); if (!isset($_SESSION['uid'])) { $_SESSION['uid'] = -1; } }