Jump to content

Import pilots from a custom built system [SOLVED]


vazquezjm

Recommended Posts

Hi there!

I'm creating a PHP script to export pilots from a custom built VA Admin System I did a few years ago.

I opened RegistrationDataClass.php and found out that the AddUser method receives the following array as parameter:

$data = array(
'firstname' => '',
'lastname' => '',
'email' => '',
'password' => '',
'code' => '',
'location' => '',
'hub' => '',
'confirm' => false);

I can fill most of those fields with legacy data, but not sure how to create a pre-defined password and salt (?) and have pilots change their passwords once the logon for the first time into the system. Also, are those the only required fields to create an entry in the pilots table?

TIA!

Link to comment
Share on other sites

The password you enter there has to be plain text, so you could do something like import them all as $data['firstname'].time() and send them an email (using Util::SendEmail) telling them their password and how to change it, for example.

I'm planning to do raw inserts into the table, but not sure how to generate the password using MD5.. something like:

$pass = md5("NewPass*123");

and then:

INSERT INTO pilots (pilotid, firstname, password) VALUES ($pilotid, $firstname, $pass);

will suffice?

Then, when the pilot logs in, he will enter his email and "NewPass*123" (in this example) and he will be logged in?

Link to comment
Share on other sites

For the sake of ensuring everything that's required to be created when a pilot registered is created, I would just do:

$data = array(
'firstname' => '',
'lastname' => '',
'email' => '',
'password' => 'New123',
'code' => '',
'location' => '',
'hub' => '',
'confirm' => false);
RegistrationData::AddUser($data);

(Obviously filling in the rest appropriately).

Link to comment
Share on other sites

  • Administrators

If you still need it, below is part of the code I use to convert IPS sites over to phpVMS, I also have scripts for VABase conversions. I build the functions right into the phpVMS system as a module, combine the two databases and then do my conversions, and then delete the tables from the other system. You may have to adjust some of the fields depending on what you are converting from.

First I run this part to bring the pilot data over from the old system into the phpvms database. You will need to match the airline code and hub.

function pilots() {

 $sql = "SELECT * FROM ".TABLE_PREFIX."ips_users";
 $users = DB::get_results($sql);

 foreach($users as $user)
 {
	 $name = explode(' ', $user->Name);

	 $joindate = date('Y-m-d H:i:s');

	 $insert = "INSERT INTO ".TABLE_PREFIX."pilots
		 (pilotid, firstname, lastname, email, code, location, hub, password, salt, transferhours, confirmed, joindate)
		 VALUES('$user->ID', '$name[0]', '$name[1]', '$user->Email', 'SPG', '$user->Country',
			 'KIAD', '$user->Pass', '$user->Salt', '$user->TransferHours', '1', '$joindate')";

	 DB::query($insert);

 }

}

Then I run this code to reset everyones password and email them the new one when I am ready for them to styart using the site.

function new_passwords(){

 set_time_limit(0);

 $sql = "SELECT * FROM ".TABLE_PREFIX."pilots";
 $pilots = DB::get_results($sql);

 foreach($pilots as $pilot) {

	 $newpw = substr(md5(date('mdYhs')), 0, 6);

	 RegistrationData::ChangePassword($pilot->pilotid, $newpw);


	 $sub = 'New Site Details';
	 $message = 'Your password has been reset for the new system.<br />';
	 $message .= 'Your new login password is - '.$newpw;

	 Util::SendEmail($pilot->email, $sub, $message);
 }
}

  • Like 1
Link to comment
Share on other sites

For the sake of ensuring everything that's required to be created when a pilot registered is created, I would just do:

$data = array(
'firstname' => '',
'lastname' => '',
'email' => '',
'password' => 'New123',
'code' => '',
'location' => '',
'hub' => '',
'confirm' => false);
RegistrationData::AddUser($data);

(Obviously filling in the rest appropriately).

Ok, I did this and nothing happened. No pilots were inserted :(

API calls work. I tried with a couple of classes and methods so I know the codon.config.php is being included properly.

Is there any way I can debug, read a log or something like that? I set Config::Set('DEBUG_MODE', true); in the local.config.php and nothing was shown during the execution of the script.

Thank you.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...