Jump to content

Tomgis34

Members
  • Posts

    20
  • Joined

  • Last visited

Posts posted by Tomgis34

  1.  /**
        * Log the user in
        */
       public static function ProcessLogin($useridoremail, $password) {
           # Allow them to login in any manner:
           #  Email: blah@blah.com
           #  Pilot ID: VMA0001, VMA 001, etc
           #  Just ID: 001
           if (is_numeric($useridoremail)) {
               $useridoremail = $useridoremail - intval(Config::Get('PILOTID_OFFSET'));
               $sql = 'SELECT * FROM ' . TABLE_PREFIX . 'pilots
    			   WHERE pilotid=' . $useridoremail;
           } else {
               # They're logging in with an email
               if (preg_match('/^.*\@.*$/i', $useridoremail) > 0) {
                   $emailaddress = DB::escape($useridoremail);
                   $sql = 'SELECT * FROM ' . TABLE_PREFIX . 'pilots
    					WHERE email=\'' . $useridoremail . '\'';
               }
               # They're loggin in with a pilot id
               elseif (preg_match('/^([A-Za-z]*)(.*)(\d*)/', $useridoremail, $matches) > 0) {
                   $id = trim($matches[2]);
                   $id = $id - intval(Config::Get('PILOTID_OFFSET'));
    
                   $sql = 'SELECT * FROM ' . TABLE_PREFIX . 'pilots
    					WHERE pilotid=' . $id;
               }
               # No idea
               else {
                   self::$error_message = 'Invalid user ID';
                   return false;
               }
           }
    
           $password = DB::escape($password);
           $userinfo = DB::get_row($sql);
    
           if (!$userinfo) {
               self::$error_message = 'This user does not exist';
               return false;
           }
    
           /*if($userinfo->retired == 1)
                   {
                           self::$error_message = 'Votre compte est désactivé, contactez un staff pour réactiver votre compte';
                           return false;
                   }
                   if($userinfo->retired == 2)
                   {
                           self::$error_message = 'Votre compte est suspendu, veuillez contactez la direction pour avoir plus d'information';
                           return false;
                   }
                   if($userinfo->retired == 3)
                   {
                           self::$error_message = 'Votre compte est en mode absent, Contacter la Direction RH pour le remettre en activité';
                           return false;
                   }*/
    
           //ok now check it
           $hash = md5($password . $userinfo->salt);
    
           if ($hash == $userinfo->password) {
               self::$userinfo = $userinfo;
    
               self::update_session(self::$session_id, self::$userinfo->pilotid);
    
               SessionManager::Set('loggedin', 'true');
               SessionManager::Set('userinfo', $userinfo);
               SessionManager::Set('usergroups', PilotGroups::GetUserGroups($userinfo->pilotid));
    
               PilotData::updateProfile($pilotid, array('lastlogin' => 'NOW()', 'lastip' => $_SERVER['REMOTE_ADDR'], ));
    
          return true;
           } else {
               self::$error_message = 'Invalid login, please check your username and password';
               self::LogOut();
    
               return false;
           }
       }
    
       /**
        * Log them out
        */
       public static function LogOut() {
           #self::remove_sessions(SessionManager::GetValue('userinfo', 'pilotid'));
    
           # Mark them as guest
           self::update_session(self::$session_id, 0);
    
           # "Ghost" entry
           //self::start_session(self::$userinfo->pilotid); // Orphaned?
    
           SessionManager::Set('loggedin', false);
           SessionManager::Set('userinfo', '');
           SessionManager::Set('usergroups', '');
    
           # Delete cookie
           $_COOKIE[VMS_AUTH_COOKIE] = '';
           setcookie(VMS_AUTH_COOKIE, true);
    
           self::$loggedin = false;
       }
    }

    I don't see on line 285 a relation with in-active user.

  2. @Tomgis34 - Care to share what you did, so others can use it as well?

    I have just missed a part of code. But when I set Inactive/Suspended/On Leave status, user can access on the website as active user. Can you help me ?

  3. Hi,

    I want to show that in pilot list but he doesn't work can you help me :

    <td><div align="center"><?php
                   if($pilot->retired == '1')
                   {echo '<img src="'.SITE_URL.'/lib/skins/aer/images/no.png" alt="warning" /> - Inactif';}
    	else if($pilot->retired == '2')
                   {echo '<img src="'.SITE_URL.'/lib/skins/aer/images/no.png" alt="warning" /> - Suspendu';}
    	else if($pilot->retired == '3')
                   {echo '<img src="'.SITE_URL.'/lib/skins/aer/images/no.png" alt="warning" /> - En Congé';}
                   else
                   {echo '<img src="'.SITE_URL.'/lib/skins/aer/images/yes.png" alt="warning" /> - Actif';}
               ?></div></td>

  4. Yes but with old or new version, we have same problem :

    Contact.php :

    <?php
    /**
    * phpVMS - Virtual Airline Administration Software
    * Copyright (c) 2008 Nabeel Shahzad
    * For more information, visit www.phpvms.net
    *	Forums: http://www.phpvms.net/forum
    *	Documentation: http://www.phpvms.net/docs
    *
    * phpVMS is licenced under the following license:
    *   Creative Commons Attribution Non-commercial Share Alike (by-nc-sa)
    *   View license.txt in the root, or visit http://creativecommons.org/licenses/by-nc-sa/3.0/
    *
    * @author Nabeel Shahzad
    * @copyright Copyright (c) 2008, Nabeel Shahzad
    * @link http://www.phpvms.net
    * @license http://creativecommons.org/licenses/by-nc-sa/3.0/
    */
    
    class Contact extends CodonModule 
    {
    public function index()
    {
    	require_once CORE_LIB_PATH.'/recaptcha/recaptchalib.php';
    
    
    	if($this->post->submit)
    	{
    		if(Auth::LoggedIn() == false)
    		{					
    			# Make sure they entered an email address
    			if(trim($this->post->name) == '' 
    				|| trim($this->post->email) == '')
    			{
    				$this->set('message', 'You must enter a name and email!');
    				$this->render('core_error.tpl');
    				return;
    			}
    		}
    
    		$resp = recaptcha_check_answer (Config::Get('RECAPTCHA_PRIVATE_KEY'),
    			$_SERVER["REMOTE_ADDR"],
    			$_POST["recaptcha_challenge_field"],
    			$_POST["recaptcha_response_field"]);
    
    		// Check the captcha thingy
    		if(!$resp->is_valid)
    		{
    			$this->set('captcha_error', $resp->error);
    			$this->set('message', 'You failed the captcha test!');
    			$this->render('contact_form.tpl');
    			return;
    		}
    
    		if($this->post->subject == '' || trim($this->post->message) == '')
    		{
    			$this->set('message', 'You must enter a subject and message!');
    			$this->render('core_error.tpl');
    			return;
    		}
    
    		$subject = 'New message from '.$this->post->name.' - "'.$this->post->subject.'"';
    		$message = DB::escape($this->post->message) . PHP_EOL . PHP_EOL;
    
    		unset($_POST['recaptcha_challenge_field']);
    		unset($_POST['recaptcha_response_field']);
    
    		foreach($_POST as $field=>$value)
    		{
    			$message.="-$field = $value".PHP_EOL;
    		}
    
    		$message = nl2br($message);
    		$message = utf8_encode($message);
    		Util::SendEmail($this->post->recipient, $subject, $message);
    
    		$this->render('contact_sent.tpl');
    		return;
    	}		
    
    	# Just a simple addition
    	$rand1 = rand(1, 10);
    	$rand2 = rand(1, 10);
    
    	$this->set('rand1', $rand1);
    	$this->set('rand2', $rand2);		
    
    	$tot = $rand1 + $rand2;
    	//echo "total: $tot <br />";
    	SessionManager::Set('captcha_sum', $tot);
    
    	//echo 'output of $_SESSION: <br />';
    	//print_r($_SESSION);
    
    	$this->render('contact_form.tpl');
    }
    
    }

    Contact_form.tpl :

    <center><h3>Formulaire de contact</h3></center>
    <form method="post" action="<?php echo url('/contact'); ?>">
     <table width='100%' border='0'>
       <tr>
         <td><strong>Nom:</strong></td>
         <td>
    	<?php
    	if(Auth::LoggedIn())
    	{
    		echo Auth::$userinfo->firstname .' '.Auth::$userinfo->lastname;
    		echo '<input type="hidden" name="name" 
    				value="'.Auth::$userinfo->firstname 
    						.' '.Auth::$userinfo->lastname.'" />';
    	}
    	else
    	{
    	?>
    		<input type="text" name="name" value="" />
    		<?php
    	}
    	?>
         </td>
       </tr>
       <tr>
    	<td width="1%" nowrap><strong>Adresse e-mail:</strong></td>
    	<td>
    	<?php
    	if(Auth::LoggedIn())
    	{
    		echo Auth::$userinfo->email;
    		echo '<input type="hidden" name="name" 
    				value="'.Auth::$userinfo->email.'" />';
    	}
    	else
    	{
    	?>
    		<input type="text" name="email" value="" />
    		<?php
    	}
    	?>
    	</td>
    </tr>
    
       <tr>
    	<td><strong>Destinataire: </strong></td>
    	<td><select name="recipient">
           <option value="info@worldskyairline.com">Le staff</option>
    	<option value="executif@worldskyairline.com">La direction général</option>
    	<option value="rh@worldskyairline.com">La direction des ressources humaines</option>
    	<option value="thomas.nouyer@worldskyairline.com">La direction technique et des opérations</option>
           <select></td>
    
    </tr>
    
    <tr>
    	<td><strong>Objet: </strong></td>
    	<td><input type="text" name="subject" value="<?php echo $_POST['subject'];?>" /></td>
    
    </tr>
       <tr>
         <td><strong>Message:</strong></td>
         <td>
    	<textarea name="message" cols='45' rows='5'><?php echo $_POST['message'];?></textarea>
         </td>
       </tr>
    
    <tr>
    	<td width="1%" nowrap><strong>Vérification</strong></td>
    	<td>
    	<?php
    	echo recaptcha_get_html(Config::Get('RECAPTCHA_PUBLIC_KEY'), $captcha_error);
    	?>
    	</td>
    </tr>
    
    	<td>
    		<input type="hidden" name="loggedin" value="<?php echo (Auth::LoggedIn())?'true':'false'?>" />
    	</td>
    	<td>
             <input type="submit" name="submit" value='Envoyer'>
    	</td>
       </tr>
     </table>
    </form>

    Thanks in advance :)

  5. Hi,

    I have a problem with contact form. In fact, when I send a test mail via this form, it didn't receive/send.

    Code of Contact_form.tpl

    <h3>Contactez-nous</h3>
    <form method="post" action="<?php echo url('/contact'); ?>">
     <table width='100%' border='0'>
       <tr>
         <td><strong>Nom:</strong></td>
         <td>
    	<?php
    	if(Auth::LoggedIn())
    	{
    		echo Auth::$userinfo->firstname .' '.Auth::$userinfo->lastname;
    		echo '<input type="hidden" name="name" 
    				value="'.Auth::$userinfo->firstname 
    						.' '.Auth::$userinfo->lastname.'" />';
    	}
    	else
    	{
    	?>
    		<input type="text" name="name" value="" />
    		<?php
    	}
    	?>
         </td>
       </tr>
       <tr>
    	<td width="1%" nowrap><strong>Adresse e-mail:</strong></td>
    	<td>
    	<?php
    	if(Auth::LoggedIn())
    	{
    		echo Auth::$userinfo->email;
    		echo '<input type="hidden" name="name" 
    				value="'.Auth::$userinfo->email.'" />';
    	}
    	else
    	{
    	?>
    		<input type="text" name="email" value="" />
    		<?php
    	}
    	?>
    	</td>
    </tr>
    
       <tr>
    	<td><strong>Destinataire: </strong></td>
    	<td><select name="recipient">
           	<option value="info@worldskyairline.com">Le staff</option>
    	<option value="executif@worldskyairline.com">La direction général</option>
    	<option value="rh@worldskyairline.com">La direction des ressources humaines</option>
    	<option value="thomas.nouyer@worldskyairline.com">La direction technique et des opérations</option>
           <select></td>
    
    </tr>
    
    <tr>
    	<td><strong>Objet: </strong></td>
    	<td><input type="text" name="subject" value="<?php echo $_POST['subject'];?>" /></td>
    
    </tr>
       <tr>
         <td><strong>Message:</strong></td>
         <td>
    	<textarea name="message" cols='45' rows='5'><?php echo $_POST['message'];?></textarea>
         </td>
       </tr>
    
    	<td>
    		<input type="hidden" name="loggedin" value="<?php echo (Auth::LoggedIn())?'true':'false'?>" />
    	</td>
    	<td>
             <input type="submit" name="submit" value='Send Message'>
    	</td>
       </tr>
     </table>
    </form>
    

    Code of Contact.php :

    <?php
    /**
    * phpVMS - Virtual Airline Administration Software
    * Copyright (c) 2008 Nabeel Shahzad
    * For more information, visit www.phpvms.net
    *	Forums: http://www.phpvms.net/forum
    *	Documentation: http://www.phpvms.net/docs
    *
    * phpVMS is licenced under the following license:
    *   Creative Commons Attribution Non-commercial Share Alike (by-nc-sa)
    *   View license.txt in the root, or visit http://creativecommons.org/licenses/by-nc-sa/3.0/
    *
    * @author Nabeel Shahzad
    * @copyright Copyright (c) 2008, Nabeel Shahzad
    * @link http://www.phpvms.net
    * @license http://creativecommons.org/licenses/by-nc-sa/3.0/
    */
    
    class Contact extends CodonModule 
    {
    
    public function index()
    {
    	if($this->post->submit)
    	{
    		$captcha = SessionManager::Get('captcha_sum');
    
    		if($this->post->loggedin == 'false')
    		{		
    
    
    			# Make sure they entered an email address
    			if(trim($this->post->name) == '' 
    				|| trim($this->post->email) == '')
    			{
    				$this->set('message', 'You must enter a name and email!');
    				$this->render('core_error.tpl');
    				return;
    			}
    		}
    
    		if($this->post->subject == '' || trim($this->post->message) == '')
    		{
    			$this->set('message', 'You must enter a subject and message!');
    			$this->render('core_error.tpl');
    			return;
    		}
    
    		$subject = 'New message from '.$this->post->name.' - "'.$this->post->subject.'"';
    		$message = DB::escape($this->post->message) . PHP_EOL . PHP_EOL;
    
    		foreach($_POST as $field=>$value)
    		{
    			$message.="-$field = $value".PHP_EOL;
    		}
    
    		Util::SendEmail($this->post->recipient, $subject, $message);
    
    		$this->render('contact_sent.tpl');
    		return;
    	}		
    
    	# Just a simple addition
    	$rand1 = rand(1, 10);
    	$rand2 = rand(1, 10);
    
    	$this->set('rand1', $rand1);
    	$this->set('rand2', $rand2);		
    
    	$tot = $rand1 + $rand2;
    	//echo "total: $tot <br />";
    	SessionManager::Set('captcha_sum', $tot);
    
    	//echo 'output of $_SESSION: <br />';
    	//print_r($_SESSION);
    
    	$this->render('contact_form.tpl');
    }
    
    }
    

    Can you help me please ?

  6. We have still some errors :

    At login :

    Warning: Cannot modify header information - headers already sent by (output started at /home/aerogalv/domains/worldskyairline.com/public_html/web/core/app.config.php:1) in /home/aerogalv/domains/worldskyairline.com/public_html/web/core/modules/Login/Login.php on line 143

    Code :

    {
    $cookie = "{$session_id}|{$pilotid}|{$_SERVER['REMOTE_ADDR']}";
    $res = setrawcookie(VMS_AUTH_COOKIE, $cookie, time() + Config::Get('SESSION_LOGIN_TIME'), '/');
    }
    

    At Logout :

    Warning: Cannot modify header information - headers already sent by (output started at /home/aerogalv/domains/worldskyairline.com/public_html/web/core/app.config.php:1) in /home/aerogalv/domains/worldskyairline.com/public_html/web/core/common/Auth.class.php on line 301

    Code :

    # Delete cookie
           $_COOKIE[VMS_AUTH_COOKIE] = '';
           setcookie(VMS_AUTH_COOKIE, true);

    Have you got any solution ?

    Regards,

×
×
  • Create New...