Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 123 lines (97 sloc) 2.741 kb
bc05119 @MightyGorgon Some bugs fixed and a new feature coded for Marcel :-p
authored
1 <?php
2 /**
3 *
4 * @package Icy Phoenix
5 * @version $Id$
6 * @copyright (c) 2008 Icy Phoenix
7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
8 *
9 */
10
11 if (!defined('IN_ICYPHOENIX'))
12 {
13 die('Hacking attempt');
14 }
15
e3f2a29 @MightyGorgon Another milestone added... AJAX CMS should now work fine, still some cod...
authored
16 class cms_auth
bc05119 @MightyGorgon Some bugs fixed and a new feature coded for Marcel :-p
authored
17 {
18 var $acl = array();
19 var $acl_options = array();
20
21 function acl()
22 {
23 global $db, $user;
24
25 $role_data = $this->get_role_data();
26 $option_array = $this->get_options_array();
27
28 if ($role_data['ID'] && $role_data['TARGET'])
29 {
30 $sql = "SELECT * FROM " . ACL_ROLES_DATA_TABLE . " WHERE role_id = '" . $role_data['ID'] . "'";
31 $result = $db->sql_query($sql);
32
33 while ($row = $db->sql_fetchrow($result))
34 {
35 $this->acl_options[$role_data['TARGET']][$option_array[$row['auth_option_id']]] = $row['auth_setting'];
36 }
37
38 $db->sql_freeresult($result);
39 }
40 else
41 {
42 $sql = 'SELECT o.*, u.*
43 FROM ' . ACL_OPTIONS_TABLE . ' as o, ' . ACL_USERS_TABLE. ' as u
44 WHERE u.user_id = ' . $user->data['user_id'] . ' AND o.auth_option_id = u.auth_option_id';
45 $result = $db->sql_query($sql);
46
47 while ($row = $db->sql_fetchrow($result))
48 {
49 $this->acl_options[$row['forum_id']][$row['auth_option']] = $row['auth_setting'];
50 }
51 $db->sql_freeresult($result);
52 }
53
54 return;
55 }
56
57 function acl_get($opt, $target = 0)
58 {
59 global $user;
60 return ($user->data['user_level'] == ADMIN) ? true : $this->acl_options[$target][$opt];
61 }
62
63 function get_role_data()
64 {
65 global $db, $user;
66
67 $sql = "SELECT auth_role_id, forum_id FROM " . ACL_USERS_TABLE . " WHERE user_id = '" . $user->data['user_id'] . "'";
68
69 $result = $db->sql_query($sql);
70 $row = $db->sql_fetchrow($result);
71 $db->sql_freeresult($result);
72
73 $role['ID'] = (!empty($row['auth_role_id'])) ? intval($row['auth_role_id']) : false;
74 $role['TARGET'] = (!empty($row['forum_id'])) ? intval($row['forum_id']) : false;
75
76 return $role;
77 }
78
79 function get_options_array()
80 {
81 global $db;
82
83 $option_array = array();
84
85 $sql = "SELECT * FROM " . ACL_OPTIONS_TABLE;
86 $result = $db->sql_query($sql);
87
88 while ($row = $db->sql_fetchrow($result))
89 {
90 $option_array[$row['auth_option_id']] = $row['auth_option'];
91 }
92
93 return $option_array;
94 }
95
96 function auth_langs($prefix)
97 {
98 global $db, $lang;
99
100 $sql = "SELECT auth_option_id, auth_option FROM " . ACL_OPTIONS_TABLE . "
101 WHERE auth_option LIKE '" . $prefix . "%' ORDER BY auth_option_id";
102 $result = $db->sql_query($sql);
103 $rows = $db->sql_fetchrowset($result);
104 $db->sql_freeresult($result);
105
106 $auth_lang = array();
107
108 if (!empty($rows))
109 {
110 foreach($rows as $data)
111 {
112 if (!empty($lang['AUTH'][$data['auth_option']]))
113 {
114 $auth_langs[$data['auth_option_id']] = $lang['AUTH'][$data['auth_option']];
115 }
116 }
117 }
118
119 return $auth_langs;
120 }
121 }
122
123 ?>
Something went wrong with that request. Please try again.