source: trunk/mobile/index.php @ 1851

Revision 1851, 2.9 KB checked in by rafaelraymundo, 14 years ago (diff)

Ticket #827 - login do mobile passa verificar acesso via proxy.

Line 
1<?php
2        //TODO: Aplicar o conceito de subapp (mobileapp)
3
4        $phpgw_info = array();
5        $GLOBALS['sessionid'] = isset($_GET['sessionid']) ? $_GET['sessionid'] : @$_COOKIE['sessionid'];
6
7        $_SESSION['phpgw_info']['user']['preferences']['contactcenter']['cellShow'] = true;
8
9        $proxies=explode(',',$_SERVER['HTTP_X_FORWARDED_HOST']);
10        $fwConstruct = isset($_SERVER['HTTP_X_FORWARDED_HOST']) ? $proxies[0] : $_SERVER['HTTP_HOST'];
11
12        if(!$GLOBALS['sessionid'])
13        {
14                //$location = 'Location: ' . $fwConstruct . 'login.php';
15                if ($_SERVER['HTTPS'] != 'on')
16                    {
17                        $aux = 'http://';
18                    }
19                else
20                    {
21                         $aux = 'https://';
22                    }
23                Header('Location: ' . $aux . $fwConstruct . '/mobile/login.php');
24                exit;
25        }
26
27        if ($GLOBALS['phpgw_info']['server']['use_https'] > 0)  {
28                if ($_SERVER['HTTPS'] != 'on') {
29                        Header('Location: https://' . $fwConstruct . '/' . $_SERVER['REQUEST_URI']);
30                        exit;
31                }
32        }
33
34        /*
35                This is the menuaction driver for the multi-layered design
36        */
37
38        if(isset($_GET['menuaction']))
39        {
40                list($mobileapp,$class,$method) = explode('.',@$_GET['menuaction']);
41                if(! $mobileapp || ! $class || ! $method)
42                {
43                        $invalid_data = True;
44                }
45        }
46        else
47        {
48                $mobileapp = 'home';
49                $invalid_data = True;
50        }
51
52
53        $GLOBALS['phpgw_info']['flags'] = array(
54                'noheader'   => True,
55                'nonavbar'   => True,
56                'currentapp' => 'mobile',
57                'mobileapp'  => $mobileapp,
58        );
59
60        include('../header.inc.php');
61        include('./mobile_header.inc.php');
62
63        if($mobileapp == 'home')
64        {
65                start_prefered_app();
66        }
67
68        $GLOBALS[$class] = CreateObject(sprintf('%s.%s','mobile',$class));
69        $public_functions = $GLOBALS[$class]->public_functions;
70        if((is_array($GLOBALS[$class]->public_functions) && $GLOBALS[$class]->public_functions[$method]) && ! $invalid_data)
71        {
72                $GLOBALS['phpgw_info']['mobiletemplate'] = CreateObject("mobile.mobiletemplate");
73                $GLOBALS['phpgw_info']['mobiletemplate'] -> print_page($class,$method);
74                unset($mobileapp);
75                unset($class);
76                unset($method);
77                unset($invalid_data);
78
79        }
80        else
81        {
82                if(!$mobileapp || !$class || !$method)
83                {
84                        if(@is_object($GLOBALS['phpgw']->log))
85                        {
86                                $GLOBALS['phpgw']->log->message(array(
87                                        'text' => 'W-BadmenuactionVariable, menuaction missing or corrupt: %1',
88                                        'p1'   => $menuaction,
89                                        'line' => __LINE__,
90                                        'file' => __FILE__
91                                ));
92                        }
93                }
94
95                if(!is_array($GLOBALS[$class]->public_functions) || ! $GLOBALS[$class]->public_functions[$method] && $method)
96                {
97                        if(@is_object($GLOBALS['phpgw']->log))
98                        {
99                                $GLOBALS['phpgw']->log->message(array(
100                                        'text' => 'W-BadmenuactionVariable, attempted to access private method: %1',
101                                        'p1'   => $method,
102                                        'line' => __LINE__,
103                                        'file' => __FILE__
104                                ));
105                        }
106                }
107                if(@is_object($GLOBALS['phpgw']->log))
108                {
109                        $GLOBALS['phpgw']->log->commit();
110                }
111                start_prefered_app();
112        }
113
114?>
Note: See TracBrowser for help on using the repository browser.