/[scire]/scire/DBInterface.php
Gentoo

Contents of /scire/DBInterface.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 77 - (show annotations) (download)
Mon May 22 02:44:28 2006 UTC (11 years, 9 months ago) by blackace
File size: 4007 byte(s)
convert to using DB.php methods
1 <?php
2
3 function get_scire_modules() {
4 global $db;
5 $result = $db->select('*', 'modules');
6 if ($result && count($result) > 0) {
7 return $result;
8 } else {
9 return array();
10 }
11 }
12
13 function get_scire_module_list() {
14 global $db;
15 $result = $db->select(array('main_content', 'name'), 'modules');
16 if ($result && count($result) > 0) {
17 return $result;
18 } else {
19 return array();
20 }
21 }
22
23 function get_profile_list() {
24 global $db;
25 $result = $db->select('profile_name', 'profiles');
26 if ($result && count($result) > 0) {
27 return $result;
28 } else {
29 return array();
30 }
31 }
32
33 function get_group_clients($group) {
34 global $db;
35 $result = $db->select('*', 'clients', '`profile` = \'' . $group . '\'');
36 if ($result && count($result) > 0) {
37 return $result;
38 } else {
39 return array();
40 }
41 }
42
43 function get_all_clients() {
44 global $db;
45 $result = $db->select('*', 'clients');
46 if ($result && count($result) > 0) {
47 return $result;
48 } else {
49 return array();
50 }
51 }
52
53 function get_scire_client($client_id) {
54 global $db;
55 $result = $db->select('*', 'clients', '`client_id` = \'' . $client_id . '\'');
56 if ($result && count($result) > 0) {
57 return $result[0];
58 } else {
59 return false;
60 }
61 }
62
63 function scire_add_client($hostname, $mac, $ip, $profile, $distribution, $admin, $status) {
64 global $db;
65 $result = $db->insert('clients', array('hostname' => $hostname, 'mac' => $mac, 'ip' => $ip, 'profile' => $profile, 'distribution' => $distribution, 'administrator' => $admin, 'status' => $status));
66 if ($result) {
67 return true;
68 } else {
69 return $db->error;
70 }
71 }
72
73 function scire_edit_client($client_id, $fields) {
74 global $db;
75 $result = $db->update('clients', $fields, '`client_id` = \'' . $client_id . '\'');
76 if ($result) {
77 return true;
78 } else {
79 return $db->error;
80 }
81 }
82
83 function scire_del_client($client_id) {
84 global $db;
85 $result = $db->delete('clients', '`client_id` = \'' . $client_id . '\'');
86 if ($result) {
87 return true;
88 } else {
89 return $db->error;
90 }
91 }
92
93 function get_scire_users() {
94 #we don't want to store the password for security reasons. <- ???
95 global $db;
96 $result = $db->select(array('username', 'comment', 'real_name'), 'users');
97 if ($result && count($result) > 0) {
98 return $result;
99 } else {
100 return array();
101 }
102 }
103
104 function get_scire_user($username) {
105 global $db;
106 $result = $db->select('*', 'users', '`username` = \'' . $username . '\'');
107 if ($result && count($result) > 0) {
108 return $result[0];
109 } else {
110 return false;
111 }
112 }
113
114 function scire_add_user($username, $password, $real_name, $comment) {
115 global $db;
116 $result = $db->insert('users', array('username' => $username, 'password' => crypt($password, 447470567), 'comment' => $comment, 'real_name' => $real_name));
117 if ($result) {
118 return true;
119 } else {
120 return $db->error;
121 }
122 }
123
124 function scire_del_user($username) {
125 global $db;
126 $result = $db->delete('users', '`username` = \'' . $username . '\'');
127 if ($result) {
128 return true;
129 } else {
130 return $db->error;
131 }
132 }
133
134 function scire_add_permission($perm_name, $desc, $created_by) {
135 global $db;
136 $result = $db->insert('permissions', array('perm_name' => $perm_name, 'description' => $desc, 'creator' => $created_by));
137 if ($result) {
138 return true;
139 } else {
140 return $db->error;
141 }
142 }
143
144 function scire_edit_permission($perm_name, $desc) {
145 global $db;
146 $result = $db->update('permissions', array('description' => $desc), '`perm_name` = \'' . $perm_name . '\'');
147 if ($result) {
148 return true;
149 } else {
150 return $db->error;
151 }
152 }
153
154 function scire_del_permission($perm_name) {
155 global $db;
156 $result = $db->delete('permissions', '`perm_name` = \'' . $perm_name . '\'');
157 if ($result) {
158 return true;
159 } else {
160 return $db->error;
161 }
162 }
163
164 function get_scire_permissions() {
165 global $db;
166 $result = $db->select('*', 'permissions');
167 if ($result && count($result) > 0) {
168 return $result;
169 } else {
170 return array();
171 }
172 }
173
174 ?>

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.20