includes/sessions.php
changeset 372 5bd429428101
parent 371 dc6026376919
child 375 8d0e3a5a6990
equal deleted inserted replaced
371:dc6026376919 372:5bd429428101
   558     {
   558     {
   559       $this->theme = 'printable';
   559       $this->theme = 'printable';
   560       $this->style = 'default';
   560       $this->style = 'default';
   561     }
   561     }
   562     
   562     
       
   563     profiler_log('Sessions started');
   563   }
   564   }
   564   
   565   
   565   # Logins
   566   # Logins
   566   
   567   
   567   /**
   568   /**
   676     
   677     
   677       if ( $policy != 'disable' && !defined('IN_ENANO_INSTALL') )
   678       if ( $policy != 'disable' && !defined('IN_ENANO_INSTALL') )
   678       {
   679       {
   679         $ipaddr = $db->escape($_SERVER['REMOTE_ADDR']);
   680         $ipaddr = $db->escape($_SERVER['REMOTE_ADDR']);
   680         // increment fail count
   681         // increment fail count
   681         $this->sql('INSERT INTO '.table_prefix.'lockout(ipaddr, timestamp, action) VALUES(\'' . $ipaddr . '\', UNIX_TIMESTAMP(), \'credential\');');
   682         $this->sql('INSERT INTO '.table_prefix.'lockout(ipaddr, timestamp, action) VALUES(\'' . $ipaddr . '\', ' . time() . ', \'credential\');');
   682         $fails++;
   683         $fails++;
   683         // ooh boy, somebody's in trouble ;-)
   684         // ooh boy, somebody's in trouble ;-)
   684         return array(
   685         return array(
   685             'success' => false,
   686             'success' => false,
   686             'error' => ( $fails >= $threshold ) ? 'locked_out' : 'invalid_credentials',
   687             'error' => ( $fails >= $threshold ) ? 'locked_out' : 'invalid_credentials',
   789       // Do we also need to increment the lockout countdown?
   790       // Do we also need to increment the lockout countdown?
   790       if ( $policy != 'disable' && !defined('IN_ENANO_INSTALL') )
   791       if ( $policy != 'disable' && !defined('IN_ENANO_INSTALL') )
   791       {
   792       {
   792         $ipaddr = $db->escape($_SERVER['REMOTE_ADDR']);
   793         $ipaddr = $db->escape($_SERVER['REMOTE_ADDR']);
   793         // increment fail count
   794         // increment fail count
   794         $this->sql('INSERT INTO '.table_prefix.'lockout(ipaddr, timestamp, action) VALUES(\'' . $ipaddr . '\', UNIX_TIMESTAMP(), \'credential\');');
   795         $this->sql('INSERT INTO '.table_prefix.'lockout(ipaddr, timestamp, action) VALUES(\'' . $ipaddr . '\', ' . time() . ', \'credential\');');
   795         $fails++;
   796         $fails++;
   796         return array(
   797         return array(
   797             'success' => false,
   798             'success' => false,
   798             'error' => ( $fails >= $threshold ) ? 'locked_out' : 'invalid_credentials',
   799             'error' => ( $fails >= $threshold ) ? 'locked_out' : 'invalid_credentials',
   799             'lockout_threshold' => $threshold,
   800             'lockout_threshold' => $threshold,
   895       // Do we also need to increment the lockout countdown?
   896       // Do we also need to increment the lockout countdown?
   896       if ( $policy != 'disable' && !defined('IN_ENANO_INSTALL') )
   897       if ( $policy != 'disable' && !defined('IN_ENANO_INSTALL') )
   897       {
   898       {
   898         $ipaddr = $db->escape($_SERVER['REMOTE_ADDR']);
   899         $ipaddr = $db->escape($_SERVER['REMOTE_ADDR']);
   899         // increment fail count
   900         // increment fail count
   900         $this->sql('INSERT INTO '.table_prefix.'lockout(ipaddr, timestamp, action) VALUES(\'' . $ipaddr . '\', UNIX_TIMESTAMP(), \'credential\');');
   901         $this->sql('INSERT INTO '.table_prefix.'lockout(ipaddr, timestamp, action) VALUES(\'' . $ipaddr . '\', ' . time() . ', \'credential\');');
   901         $fails++;
   902         $fails++;
   902         return array(
   903         return array(
   903             'success' => false,
   904             'success' => false,
   904             'error' => ( $fails >= $threshold ) ? 'locked_out' : 'invalid_credentials',
   905             'error' => ( $fails >= $threshold ) ? 'locked_out' : 'invalid_credentials',
   905             'lockout_threshold' => $threshold,
   906             'lockout_threshold' => $threshold,
  1000       // Do we also need to increment the lockout countdown?
  1001       // Do we also need to increment the lockout countdown?
  1001       if ( $policy != 'disable' && !defined('IN_ENANO_INSTALL') )
  1002       if ( $policy != 'disable' && !defined('IN_ENANO_INSTALL') )
  1002       {
  1003       {
  1003         $ipaddr = $db->escape($_SERVER['REMOTE_ADDR']);
  1004         $ipaddr = $db->escape($_SERVER['REMOTE_ADDR']);
  1004         // increment fail count
  1005         // increment fail count
  1005         $this->sql('INSERT INTO '.table_prefix.'lockout(ipaddr, timestamp, action) VALUES(\'' . $ipaddr . '\', UNIX_TIMESTAMP(), \'credential\');');
  1006         $this->sql('INSERT INTO '.table_prefix.'lockout(ipaddr, timestamp, action) VALUES(\'' . $ipaddr . '\', ' . time() . ', \'credential\');');
  1006         $fails++;
  1007         $fails++;
  1007         return array(
  1008         return array(
  1008             'success' => false,
  1009             'success' => false,
  1009             'error' => ( $fails >= $threshold ) ? 'locked_out' : 'invalid_credentials',
  1010             'error' => ( $fails >= $threshold ) ? 'locked_out' : 'invalid_credentials',
  1010             'lockout_threshold' => $threshold,
  1011             'lockout_threshold' => $threshold,