source: trunk/includes/main_center.php @ 187

Revision 187, 3.0 KB checked in by Ernest0x, 3 years ago (diff)

PHP 5.x fixes (mostly fixes for warnings and notices)

Line 
1<?php
2/*
3 * WiND - Wireless Nodes Database
4 *
5 * Copyright (C) 2005 Nikolaos Nikalexis <winner@cube.gr>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 dated June, 1991.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19 *
20 */
21
22include_once(ROOT_PATH."includes/pages/".get('page')."/".get('page').".php");
23
24class center {
25
26        var $page;
27       
28        function center() {
29                $p = get('page');
30                $this->page = new $p;
31        }
32       
33        function security_check() {
34                global $main, $db;
35                if (isset($main->userdata->privileges['admin']) && $main->userdata->privileges['admin'] === TRUE) return TRUE;
36                switch (get('page')) {
37                        case 'admin':
38                                return ($main->userdata->privileges['admin'] === TRUE);
39                                break;
40                        case 'hostmaster':
41                                return ($main->userdata->privileges['hostmaster'] === TRUE);
42                                break;
43                        case 'mynodes':
44                                if ($main->userdata->logged === TRUE) {
45                                        if (get('node') == 'add') return TRUE;
46                                        if (get('node') != 'add' && get('action') == 'delete') {
47                                                if ($db->cnt('', "users_nodes", "node_id = ".intval(get('node'))." AND user_id = '".$main->userdata->user."' AND owner = 'Y'") > 0) {
48                                                        return TRUE;
49                                                } else {
50                                                        return FALSE;
51                                                }
52                                        }
53                                        if ($db->cnt('', "users_nodes", "node_id = ".get('node')." AND user_id = '".$main->userdata->user."'") > 0) return TRUE;
54                                        if (get('subpage') == 'dnszone' && 
55                                                $db->cnt('', "users_nodes, dns_zones", "dns_zones.node_id = users_nodes.node_id AND dns_zones.id = '".get('zone')."' AND users_nodes.user_id = '".$main->userdata->user."'") > 0) return TRUE;
56                                        if (get('subpage') == 'dnsnameserver' && 
57                                                $db->cnt('', "users_nodes, dns_nameservers", "dns_nameservers.node_id = users_nodes.node_id AND dns_nameservers.id = '".get('nameserver')."' AND users_nodes.user_id = '".$main->userdata->user."'") > 0) return TRUE;
58                                }
59                                break;
60                        case 'nodes':
61                        case 'startup':
62                        case 'ranges':
63                        case 'dnszones':
64                        case 'pickup':
65                        case 'gmap':
66                        case 'gearth':
67                        case 'services':
68                        case 'search':
69                                return TRUE;
70                                break;
71                        case 'users':
72                                if (get('user') == 'add') return TRUE;
73                                if ($main->userdata->logged === TRUE) {
74                                        if (get('action') == 'logout') return TRUE;
75                                        if (get('user') === $main->userdata->user) return TRUE;
76                                }
77                                if (get('action') == 'activate') return TRUE;
78                                if (get('action') == 'restore') return TRUE;
79                                break;
80                }
81                return FALSE;
82        }
83       
84        function output() {
85                global $main;
86                if (!$this->security_check()) {
87                        $main->message->set_fromlang('info', 'no_privilege');
88                        return;
89                }
90                return $this->page->output();
91        }
92       
93}
94
95?>
Note: See TracBrowser for help on using the repository browser.