source: branches/2.4/prototype/api/esecurity.php @ 7228

Revision 7228, 1.5 KB checked in by douglas, 12 years ago (diff)

Ticket #0000 - Copiadas as alterações do Trunk. Versão final da 2.4.2.

Line 
1<?php
2
3require_once(__DIR__.'/config.php');
4
5use prototype\api\Config as Config;
6
7class ESecurity
8{
9   public function valid()
10   {
11        if(isset($_SESSION['wallet']['security']['REMOTE_ADDR']))
12        {
13            if($_SESSION['wallet']['security']['REMOTE_ADDR'] !== $_SERVER['REMOTE_ADDR'])
14            {
15                $sql = 'SELECT config_value FROM phpgw_config WHERE config_app = \'phpgwapi\' AND config_name = \'webserver_url\'';
16                $config = Config::service('PostgreSQL' , 'config');
17
18                $rs = '';
19                $rs .= ( isset($config['host']) && $config['host'] )  ? ' host='.$config['host'] : '' ;
20                $rs .= ( isset($config['user']) && $config['user'] )  ? ' user='.$config['user'] : '' ;
21                $rs .= ( isset($config['password']) && $config['password'] )  ? ' password='.$config['password'] : '' ;
22                $rs .= ( isset($config['dbname']) && $config['dbname'] )  ? ' dbname='.$config['dbname'] : '' ;
23                $rs .= ( isset($config['port']) && $config['port'] )  ? ' port='.$config['port'] : '' ;
24
25                $con = pg_connect( $rs );
26                $rs = pg_query( $con, $sql );
27                $row = pg_fetch_assoc( $rs );
28
29                session_destroy();
30                header( 'Location: '.$row['config_value'].'/login.php' );
31                die();
32            }
33        }
34        else
35            $_SESSION['wallet']['security']['REMOTE_ADDR'] = $_SERVER['REMOTE_ADDR'];
36   }
37   
38}
39?>
Note: See TracBrowser for help on using the repository browser.