source: sandbox/2.4.1-1/login.php @ 5926

Revision 5926, 6.0 KB checked in by cristiano, 12 years ago (diff)

Ticket #2615 - Corrigido carregamento session com https ativo

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1<?php
2        /**************************************************************************\
3        * eGroupWare login                                                         *
4        * http://www.egroupware.org                                                *
5        * Originaly written by Dan Kuykendall <seek3r@phpgroupware.org>            *
6        *                      Joseph Engo    <jengo@phpgroupware.org>             *
7        * Updated by Nilton Emilio Buhrer Neto <niltonneto@celepar.pr.gov.br>      *
8        *  This program is free software; you can redistribute it and/or modify it *
9        *  under the terms of the GNU General Public License as published by the   *
10        *  Free Software Foundation; either version 2 of the License, or (at your  *
11        *  option) any later version.                                              *
12        \**************************************************************************/
13       
14        $phpgw_info = array();
15        $submit = False;                        // set to some initial value
16
17        $GLOBALS['phpgw_info']['flags'] = array(
18                'disable_Template_class' => True,
19                'login'                  => True,
20                'currentapp'             => 'login',
21                'noheader'               => True
22        );
23
24        if(file_exists('./header.inc.php'))
25        {
26                include('./header.inc.php');
27                // Force location to home, while logged in.
28                $GLOBALS['sessionid'] = @$_GET['sessionid'] ? $_GET['sessionid'] : @$_COOKIE['sessionid'];
29               
30                if(isset($GLOBALS['sessionid']) && $_GET['cd'] != 10)
31                {
32                        if( $_GET['cd'] != '66' )
33                        {
34                                $GLOBALS['phpgw']->redirect_link('/home.php');
35                        }
36                }
37               
38                if ($GLOBALS['phpgw_info']['server']['use_https'] > 0)
39                {
40                        if ($_SERVER['HTTPS'] != 'on')
41                        {
42                        Header('Location: https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
43                                exit;
44                        }
45                }
46                       
47                $GLOBALS['phpgw']->session = CreateObject('phpgwapi.sessions');
48               
49        }
50        else
51        {
52                Header('Location: setup/index.php');
53                exit;
54        }
55               
56        if($_POST)
57        {
58            $accountInfo = $GLOBALS['phpgw']->accounts->read_repository();
59            session_id( $_COOKIE[ 'sessionid' ] );
60            session_start();
61           
62            //Carregando na sessão configurações do usuario usado na nova API. 
63            $_SESSION['wallet']['user']['uid']            =  $accountInfo['account_lid'];
64            $_SESSION['wallet']['user']['uidNumber']      =  $accountInfo['account_id'];
65            $_SESSION['wallet']['user']['password']       =  $_POST['passwd'];
66            $_SESSION['wallet']['user']['cn']             =  $accountInfo['firstname'].' '.$accountInfo['lastname'];
67            $_SESSION['wallet']['user']['mail']           =  $accountInfo['email'];
68
69            $_SESSION['wallet']['Sieve']['user']          =  $accountInfo['account_lid'];
70            $_SESSION['wallet']['Sieve']['password']      =  $_POST['passwd'];
71
72            $_SESSION['wallet']['Cyrus']['user']          =  $accountInfo['account_lid'];
73            $_SESSION['wallet']['Cyrus']['password']      =  $_POST['passwd'];
74
75        }
76       
77        //detect if the user has a compatible browser, if don't have send him to expresso mini
78        $ifMobile = false;
79        $browser = CreateObject('phpgwapi.browser');
80        switch ( $browser->get_platform() )
81        {
82                case browser::PLATFORM_IPHONE:
83                case browser::PLATFORM_IPOD:
84                case browser::PLATFORM_IPAD:
85                case browser::PLATFORM_BLACKBERRY:
86                case browser::PLATFORM_NOKIA:
87                case browser::PLATFORM_ANDROID:
88                        $ifMobile = true;                                               
89                        break;
90        }
91
92        if( $ifMobile && $_GET['dont_redirect_if_moble'] != 1 )
93        {
94                $GLOBALS['phpgw_info']['user']['preferences']['common']['lang'] = preg_replace("/\,.*/","",$GLOBALS['_SERVER']['HTTP_ACCEPT_LANGUAGE']);
95                if( $_GET['cd'] == '66' )
96                        $GLOBALS['phpgw']->redirect_link('/mobile/login.php?cd=66');
97                else
98                        $GLOBALS['phpgw']->redirect_link('/mobile/login.php');
99        }
100        else
101        {
102                $GLOBALS['phpgw_info']['server']['template_dir'] = PHPGW_SERVER_ROOT . '/phpgwapi/templates/' . $GLOBALS['phpgw_info']['login_template_set'];
103                $tmpl = CreateObject('phpgwapi.Template', $GLOBALS['phpgw_info']['server']['template_dir']);
104       
105                // read the images from the login-template-set, not the (maybe not even set) users template-set
106                $GLOBALS['phpgw_info']['user']['preferences']['common']['template_set'] = $GLOBALS['phpgw_info']['login_template_set'];
107       
108                // This is used for system downtime, to prevent new logins.
109                if($GLOBALS['phpgw_info']['server']['deny_all_logins'])
110                {
111                        $deny_msg=lang('Oops! You caught us in the middle of system maintainance.<br/>
112                        Please, check back with us shortly.');
113       
114                        $tmpl->set_file(array('login_form' => 'login_denylogin.tpl'));
115       
116                        $tmpl->set_var('template_set','default');
117                        $tmpl->set_var('deny_msg',$deny_msg);
118                        $tmpl->pfp('loginout','login_form');
119                        exit;
120                }
121                $tmpl->set_file(array('login_form' => 'login.tpl'));
122       
123                $tmpl->set_var('template',$GLOBALS['phpgw_info']['login_template_set']);
124                $tmpl->set_var('lang',$_GET['lang']?$_GET['lang']:preg_replace("/\,.*/","",$GLOBALS['_SERVER']['HTTP_ACCEPT_LANGUAGE']));
125       
126                if (count($GLOBALS['phpgw_info']['server']['login_logo_file']) > 0)
127                        $tmpl->set_var('logo_config',$GLOBALS['phpgw_info']['server']['login_logo_file']);
128                else
129                        $tmpl->set_var('logo_config','<a title="Governo do Paran&aacute" href="http://www.pr.gov.br" target="_blank"><img src="phpgwapi/templates/'.$GLOBALS['phpgw_info']['login_template_set'].'/images/logo_governo.gif" border="0"></a></td>
130                        <td><div align="center"><font color="#9a9a9a" face="Verdana, Arial, Helvetica, sans-serif" size="1">
131        <a title="Celepar Inform&aacute;tica do Paran&aacute;" target="_blank" href="http://www.celepar.pr.gov.br/">
132        <img src="phpgwapi/templates/'.$GLOBALS['phpgw_info']['login_template_set'].'/images/logo_celepar.gif" border="0"></a>');
133                // !! NOTE !!
134                // Do NOT and I repeat, do NOT touch ANYTHING to do with lang in this file.
135                // If there is a problem, tell me and I will fix it. (jengo)
136       
137                // whoooo scaring
138       
139                // ServerID => Identify the Apache Frontend.
140                if($GLOBALS['phpgw_info']['server']['usecookies'] == True && $GLOBALS['phpgw_info']['server']['use_frontend_id'])
141                {
142                        $GLOBALS['phpgw']->session->phpgw_setcookie('serverID', $GLOBALS['phpgw_info']['server']['use_frontend_id']);
143                }
144                if($GLOBALS['phpgw_info']['server']['captcha']==1)
145                {
146                        session_start();
147                }
148                                               
149                include(personalize_include_path('phpgwapi','login'));
150        }   
151           
152?>
Note: See TracBrowser for help on using the repository browser.