/** * Installer::SiteSetup() * * @return */ public static function SiteSetup() { /*$_POST['SITE_NAME'] == '' || $_POST['firstname'] == '' || $_POST['lastname'] == '' || $_POST['email'] == '' || $_POST['password'] == '' || $_POST['vaname'] == '' || $_POST['vacode'] == ''*/ // first add the airline $_POST['vacode'] = strtoupper($_POST['vacode']); if (!OperationsData::addAirline($_POST['vacode'], $_POST['vaname'])) { self::$error = __FILE__ . ' ' . __LINE__ . ' ' . DB::$error; return false; } // Add the user $data = array('firstname' => $_POST['firstname'], 'lastname' => $_POST['lastname'], 'email' => $_POST['email'], l, 'password' => $_POST['password'], 'code' => $_POST['vacode'], 'location' => 'US', 'hub' => 'KJFK', 'confirm' => true); if (!RegistrationData::addUser($data)) { self::$error = __FILE__ . ' ' . __LINE__ . ' ' . DB::$error; return false; } RanksData::calculatePilotRanks(); # Add to admin group $pilotdata = PilotData::getPilotByEmail($_POST['email']); if (!PilotGroups::addUsertoGroup($pilotdata->pilotid, 'Administrators')) { self::$error = __FILE__ . ' ' . __LINE__ . ' ' . DB::$error; return false; } # Add the final settings in SettingsData::SaveSetting('SITE_NAME', $_POST['SITE_NAME']); SettingsData::SaveSetting('ADMIN_EMAIL', $_POST['email']); SettingsData::SaveSetting('GOOGLE_KEY', $_POST['googlekey']); return true; }
/** * Add a User * * $data = array( * 'firstname' => '', * 'lastname' => '', * 'email' => '', * 'password' => '', * 'code' => '', * 'location' => '', * 'hub' => '', * 'confirm' => false); */ public static function addUser($data) { /*$data = array( 'firstname' => '', 'lastname' => '', 'email' => '', 'password' => '', 'code' => '', 'location' => '', 'hub' => '', 'confirm' => false);*/ $exists = self::CheckUserEmail($data['email']); if (is_object($exists)) { self::$error = 'Email already exists'; return false; } //Set the password, add some salt $salt = md5(date('His')); $password = md5($data['password'] . $salt); //Stuff it into here, the confirmation email will use it. self::$salt = $salt; $code = DB::escape(strtoupper($data['code'])); $firstname = DB::escape(ucwords($data['firstname'])); $lastname = DB::escape(ucwords($data['lastname'])); $location = DB::escape(strtoupper($data['location'])); //Add this stuff in if ($data['confirm'] === true) { $confirm = 1; } else { $confirm = 0; } $sql = "INSERT INTO " . TABLE_PREFIX . "pilots (firstname, lastname, email,\n\t\t\t\t\tcode, location, hub, password, salt, confirmed, joindate, lastip)\n\t\t\t\t VALUES ('{$firstname}', '{$lastname}', '{$data['email']}', '{$code}',\n\t\t\t\t\t\t\t'{$location}', '{$data['hub']}', '{$password}', '{$salt}', {$confirm}, NOW(), '{$_SERVER['REMOTE_ADDR']}')"; $res = DB::query($sql); if (DB::errno() != 0) { if (DB::errno() == 1062) { self::$error = 'This email address is already registered'; return false; } self::$error = DB::error(); return false; } //Grab the new pilotid, we need it to insert those "custom fields" $pilotid = DB::$insert_id; RanksData::CalculateUpdatePilotRank($pilotid); PilotData::GenerateSignature($pilotid); /* Add them to the default group */ $defaultGroup = SettingsData::getSettingValue('DEFAULT_GROUP'); PilotGroups::addUsertoGroup($pilotid, $defaultGroup); // For later self::$pilotid = $pilotid; //Get customs fields $fields = self::GetCustomFields(); if (!$fields) { return true; } foreach ($fields as $field) { $value = Vars::POST($field->fieldname); $value = DB::escape($value); if ($value != '') { $sql = "INSERT INTO " . TABLE_PREFIX . "fieldvalues (fieldid, pilotid, value)\n\t\t\t\t\t\t\tVALUES ({$field->fieldid}, {$pilotid}, '{$value}')"; DB::query($sql); } } return true; }
/** * Update a pilot, $params is an array of column_name=>value * * @param mixed $pilotid This is a description * @param mixed $params This is a description * @return mixed This is the return value description * */ public static function updateProfile($pilotid, $params) { /*$params = array( 'pilotid' => '', 'code' => '', 'email' => '', 'location' => '', 'hub' => '', 'bgimage' => '', 'retired' => false, ); */ if (empty($pilotid)) { return false; } if (!is_array($params)) { return false; } /* Cleanup any specific parameters */ if (isset($params['location'])) { $params['location'] = strtoupper($params['location']); } if (isset($params['pilotid'])) { unset($params['pilotid']); } $sql = "UPDATE " . TABLE_PREFIX . "pilots SET "; $sql .= DB::build_update($params); $sql .= " WHERE `pilotid`={$pilotid}"; $res = DB::query($sql); if (DB::errno() != 0) { return false; } # Auto groups? $groups = Config::get('PILOT_STATUS_TYPES'); if (isset($params['retired'])) { $info = $groups[$params['retired']]; # Automatically add into these groups if (is_array($info['group_add']) && count($info['group_add']) > 0) { foreach ($info['group_add'] as $group) { PilotGroups::addUsertoGroup($pilotid, $group); } } if (is_array($info['group_remove']) && count($info['group_remove']) > 0) { foreach ($info['group_remove'] as $group) { PilotGroups::removeUserFromGroup($pilotid, $group); } } } return true; }
echo "<br /><br />" . DB::error(); echo '</div>'; } } OperationsData::updateAircraftRankLevels(); /* Add them to the default group */ $status_type_list = Config::get('PILOT_STATUS_TYPES'); $pilot_list = PilotData::getAllPilots(); foreach ($pilot_list as $pilot) { echo "Fixing settings for " . $pilot->firstname . " " . $pilot->lastname . "<br>"; PilotData::resetLedgerforPilot($pilot->pilotid); PilotGroups::addUsertoGroup($pilot->pilotid, DEFAULT_GROUP); # Reset the default groups $status = $status_type_list[$pilot->retired]; foreach ($status['group_add'] as $group) { PilotGroups::addUsertoGroup($pilot->pilotid, $group); } foreach ($status['group_remove'] as $group) { PilotGroups::removeUserFromGroup($pilot->pilotid, $group); } } SettingsData::saveSetting('PHPVMS_VERSION', $FULL_VERSION_STRING); # Don't count forced updates if (!isset($_GET['force'])) { Installer::RegisterInstall($FULL_VERSION_STRING); } echo '<p><strong>Update completed!</strong></p> <hr> <p >If there were any errors, you may have to manually run the SQL update, or correct the errors, and click the following to re-run the update: <br /> <a href="update.php?force">Click here to force the update to run again</a></p>