source: trunk/mobile/index.php @ 5037

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

Ticket #2260 - Sincronismo do branch2.2(versão 2.2.8) do modulo mobile para 2.4

  • Property svn:executable set to *
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        $proxies = explode(',',$_SERVER['HTTP_X_FORWARDED_HOST']);
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']; 
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       
16        $fwConstruct .= $REQUEST_URI;
17       
18        if(!$GLOBALS['sessionid'])
19        {
20            if ($_SERVER['HTTPS'] != 'on')
21            {
22                $aux = 'http://';
23            }
24            else
25            {
26                $aux = 'https://';
27            }
28         
29            Header('Location: ' . $aux . $fwConstruct . "/login.php");
30                exit;
31        }
32
33        if ($GLOBALS['phpgw_info']['server']['use_https'] > 0)
34        {
35                if ($_SERVER['HTTPS'] != 'on') {
36                        Header('Location: https://' . $fwConstruct . $_SERVER['REQUEST_URI']);
37                        exit;
38                }
39        }
40
41        /*
42                This is the menuaction driver for the multi-layered design
43        */
44
45        if(isset($_REQUEST['menuaction']))
46        {
47                list($mobileapp,$class,$method) = explode('.',@$_REQUEST['menuaction']);
48                if(! $mobileapp || ! $class || ! $method)
49                {
50                        $invalid_data = True;
51                }
52        }
53        else
54        {
55                $mobileapp = 'home';
56                $invalid_data = True;
57        }
58
59       
60        $GLOBALS['phpgw_info']['flags'] = array(
61                'noheader'   => True,
62                'nonavbar'   => True,
63                'currentapp' => 'mobile',
64                'mobileapp'  => $mobileapp,
65        );
66
67        include_once('../header.inc.php');
68        include_once('./mobile_header.inc.php');
69       
70        if($mobileapp == 'home')
71        {
72                start_prefered_app();
73        }
74       
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)
78        {                                               
79                $GLOBALS['phpgw_info']['mobiletemplate'] = CreateObject("mobile.mobiletemplate");                                       
80                $GLOBALS['phpgw_info']['mobiletemplate'] -> print_page($class,$method);         
81                unset($mobileapp);
82                unset($class);
83                unset($method);
84                unset($invalid_data);
85
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();
117                }               
118                start_prefered_app();
119        }
120
121?>
Note: See TracBrowser for help on using the repository browser.