Jump to content

Import pilots from a custom built system [SOLVED]


Recommended Posts

Posted

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!

Posted

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.

Posted

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?

Posted

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).

Posted

Ok, cool, and one last question (at least for today :D).

I see I should use one of the methods from the RegistrationData class:

RegistrationData::AddUser($data);

How do I invoke or use the class within my PHP script?

Thank you!

  • Moderators
Posted

You can include the phpVMS Config in your script.

Example

<?php
include_once '../core/codon.config.php';
//do stuff!
?>

Be sure to change the include_once directory to where your VMS install is. ;)

  • Administrators
Posted

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
Posted

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.

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...