Ejemplo n.º 1
0
 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 = DB::$error;
         return false;
     }
     // Add an initial airport/hub, because I love KJFK so much
     $data = array('icao' => 'KJFK', 'name' => 'Kennedy International', 'country' => 'USA', 'lat' => '40.6398', 'lng' => '-73.7787', 'hub' => false, 'fuelprice' => 0);
     $ret = OperationsData::AddAirport($data);
     // 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 = DB::$error;
         return false;
     }
     // Add a rank
     RanksData::updateRank(1, 'New Hire', 0, fileurl('/lib/images/ranks/newhire.jpg'), 18.0);
     # Add to admin group
     $pilotdata = PilotData::GetPilotByEmail($_POST['email']);
     if (!PilotGroups::AddUsertoGroup($pilotdata->pilotid, 'Administrators')) {
         self::$error = 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;
 }
Ejemplo n.º 2
0
    }
    echo "Pilots have a total of <strong>{$total} hours</strong><br /><br />";
    echo "<strong>Updating PIREPS  Hours</strong><br />";
    StatsData::UpdateTotalHours();
    echo 'Found ' . StatsData::TotalHours() . ' total hours, updated<br />';
}
if ($version < 20854) {
    Installer::add_to_config('USERS_ONLINE_TIME', 20, 'The StatsData::UserOnline() function - how many minutes to check');
    Installer::sql_file_update(SITE_ROOT . '/install/update_854.sql');
}
Installer::sql_file_update(SITE_ROOT . '/install/update.sql');
OperationsData::updateAircraftRankLevels();
/* Add them to the default group */
$allpilots = PilotData::GetAllPilots();
foreach ($allpilots as $pilot) {
    PilotGroups::AddUsertoGroup($pilot->pilotid, DEFAULT_GROUP);
}
/* Update expenses */
//FinanceData::updateAllExpenses();
/* Manually specify a revenue value for all PIREPs */
/*$allpireps = PIREPData::findPIREPS(array());
	if(is_array($allpireps))
	{
		foreach($allpireps as $pirep)
		{	
			$data = array(
				'price' => $pirep->price,
				'load' => $pirep->load,
				'fuelprice' => $pirep->fuelprice,
				'pilotpay' => $pirep->pilotpay,
				'flighttime' => $pirep->flighttime,
Ejemplo n.º 3
0
 protected function AddPilotToGroup()
 {
     if (PilotGroups::CheckUserInGroup($this->post->pilotid, $this->post->groupname)) {
         $this->set('message', Lang::gs('group.pilot.already.in'));
         $this->render('core_error.tpl');
         return;
     }
     $ret = PilotGroups::AddUsertoGroup($this->post->pilotid, $this->post->groupname);
     if (DB::errno() != 0) {
         $this->set('message', Lang::gs('group.add.error'));
         $this->render('core_error.tpl');
     } else {
         LogData::addLog(Auth::$userinfo->pilotid, 'Added pilot #' . $this->post->pilotid . ' to group "' . $this->post->groupname . '"');
     }
 }
Ejemplo n.º 4
0
 /**
 * 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 */
     PilotGroups::AddUsertoGroup($pilotid, DEFAULT_GROUP);
     // 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;
 }