vazquezjm Posted August 20, 2012 Report Share Posted August 20, 2012 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! Quote Link to comment Share on other sites More sharing options...
Tom Posted August 20, 2012 Report Share Posted August 20, 2012 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. Quote Link to comment Share on other sites More sharing options...
vazquezjm Posted August 21, 2012 Author Report Share Posted August 21, 2012 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? Quote Link to comment Share on other sites More sharing options...
Tom Posted August 21, 2012 Report Share Posted August 21, 2012 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). Quote Link to comment Share on other sites More sharing options...
vazquezjm Posted August 21, 2012 Author Report Share Posted August 21, 2012 Ok, cool, and one last question (at least for today ). 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! Quote Link to comment Share on other sites More sharing options...
Moderators Kyle Posted August 21, 2012 Moderators Report Share Posted August 21, 2012 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. Quote Link to comment Share on other sites More sharing options...
vazquezjm Posted August 21, 2012 Author Report Share Posted August 21, 2012 Awesome! Thank you very much for your help. I'll let you know the outcome later this week Cheers Quote Link to comment Share on other sites More sharing options...
Administrators simpilot Posted August 21, 2012 Administrators Report Share Posted August 21, 2012 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); } } 1 Quote Link to comment Share on other sites More sharing options...
vazquezjm Posted August 23, 2012 Author Report Share Posted August 23, 2012 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. Quote Link to comment Share on other sites More sharing options...
vazquezjm Posted August 23, 2012 Author Report Share Posted August 23, 2012 Was not using the right connection string Thank you for your support!! Quote Link to comment Share on other sites More sharing options...
Administrators Nabeel Posted August 24, 2012 Administrators Report Share Posted August 24, 2012 http://forum.phpvms....ess-the-api-r16 http://forum.phpvms.net/page/index.html/_/developers-guides/debugging-r26 Debug logs are written to core/logs Quote Link to comment Share on other sites More sharing options...
vazquezjm Posted August 25, 2012 Author Report Share Posted August 25, 2012 http://forum.phpvms....ess-the-api-r16 http://forum.phpvms....s/debugging-r26 Debug logs are written to core/logs Gotcha. Thx! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.