source: branches/2.2/mobile/index.php @ 5053

Revision 5053, 3.0 KB checked in by alexandrecorreia, 13 years ago (diff)

Ticket #2261 - Corrigido os varios redirecionamentos no modulo mobile

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