ona  18.1.1
About: OpenNetAdmin provides a database managed inventory of your IP network (with Web and CLI interface).
  Fossies Dox: ona-18.1.1.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

app_user_info.inc.php
Go to the documentation of this file.
1 <?php
2 
3 $window['title'] = "User Info";
4 
5 $window['js'] .= <<<EOL
6  /* Put a minimize icon in the title bar */
7  el('{$window_name}_title_r').innerHTML =
8  '&nbsp;<a onClick="toggle_window(\'{$window_name}\');" title="Minimize window" style="cursor: pointer;"><img src="{$images}/icon_minimize.gif" border="0" /></a>' +
9  el('{$window_name}_title_r').innerHTML;
10 
11  /* Put a help icon in the title bar */
12  el('{$window_name}_title_r').innerHTML =
13  '&nbsp;<a href="{$_ENV['help_url']}{$window_name}" target="null" title="Help" style="cursor: pointer;"><img src="{$images}/silk/help.png" border="0" /></a>' +
14  el('{$window_name}_title_r').innerHTML;
15 
17 
18 global $conf, $self;
19 
20 $output['ona_username'] = $_SESSION['ona']['auth']['user']['username'];
21 $output['ona_user_level'] = $_SESSION['ona']['auth']['user']['level'];
22 $groups = array_keys($_SESSION['ona']['auth']['user']['grps']); sort($groups);
23 $output['ona_groups'] = implode("\n", $groups);
24 $permissions = array_keys($_SESSION['ona']['auth']['perms']); sort($permissions);
25 $output['ona_permissions'] = implode("\n", $permissions);
26 
27 
28 // Escape data for display in html
29 foreach(array_keys($output) as $key) { $output[$key] = nl2br(htmlentities($output[$key], ENT_QUOTES, $conf['php_charset'])); }
30 
31 
32 $window['html'] .= <<<EOL
33 
34  <!-- Window Content -->
35  <table style="background-color: {$color['window_content_bg']}; padding-left: 25px; padding-right: 25px;" width="100%" cellspacing="0" border="0" cellpadding="0">
36 
37  <tr>
38  <td colspan="2" align="center" class="padding" style="font-weight: bold;">
39  <u>ONA User Auth Info</u>
40  </td>
41  </td>
42 
43  <tr>
44  <td align="right" valign="top" class="padding" style="font-weight: bold;">
45  Username:
46  </td>
47  <td align="left" class="padding">
48  <div style="float: left;">{$output['ona_username']}</div>
49  </td>
50  <td align="left" rowspan="2" class="padding">
51  <div title="Detailed info about network managment" style="float: right;"><a target="null" href="http://www.homestarrunner.com/sbemail152.html"><img src="{$images}/strongbad.gif" hspace="0" vspace="0" align="left" border="0"></a></div>
52  </td>
53  </td>
54 
55  <tr>
56  <td align="right" valign="top" class="padding" style="font-weight: bold;">
57  Groups:
58  </td>
59  <td align="left" class="padding">
60  {$output['ona_groups']}&nbsp;
61  </td>
62  </td>
63 
64  <tr>
65  <td align="right" valign="top" class="padding" style="font-weight: bold;">
67  </td>
68  <td align="left" class="padding">
69  {$output['ona_permissions']}&nbsp;
70  </td>
71  </td>
72 
73 
74 
75  <!-- commented out for now till LDAP stuff is usefull
76  <tr>
77  <td colspan="2" align="center" class="padding" style="font-weight: bold;">
78  <u>Domain Info</u>
79  </td>
80  </td>
81 
82  <tr>
83  <td align="right" valign="top" class="padding" style="font-weight: bold;">
84  Username:
85  </td>
86  <td align="left" class="padding">
87  {$output['domain']} \ {$output['username']}
88  </td>
89  </td>
90 
91  <tr>
92  <td align="right" valign="top" class="padding" style="font-weight: bold;">
93  Full Name:
94  </td>
95  <td align="left" class="padding">
96  {$output['fullname']}
97  </td>
98  </td>
99 
100  <tr>
101  <td align="right" valign="top" class="padding" style="font-weight: bold;">
102  Groups:
103  </td>
104  <td align="left" class="padding">
105  {$output['groups']}
106  </td>
107  </td>
108  -->
109 
110  <tr>
111  <td class="padding">
113  </td>
114  <td class="padding">
115  <input id="changebutton" type="button" name="change_pass" value="Change Password"
116  onclick="el('passchange_container').style.display = (el('passchange_container').style.display == 'none') ? '' : 'none';
117  el('changebutton').style.display = 'none';"
118  >
119  </td>
120  </td>
121 
122  </table>
123 
124 
125  <!-- PASSWORD CHANGE CONTAINER -->
126  <span id="passchange_container" style="display:none;">
127  <form id="passchange_form">
128  <input id="old" name="old" type="hidden" value="">
129  <input id="new1" name="new1" type="hidden" value="">
130  <input id="new2" name="new2" type="hidden" value="">
131  <table style="background-color: {$color['window_content_bg']}; padding-left: 25px; padding-right: 25px;" width="100%" cellspacing="0" border="0" cellpadding="0">
132  <tr>
133  <td align="right" nowrap="true" class="padding" style="font-weight: bold;">
134  Old password:
135  </td>
136  <td class="padding" align="left" width="100%">
137  <input
138  id="old_pass"
139  name="old_pass"
140  value=""
141  class="edit"
142  type="password"
143  size="10" maxlength="20"
144  />
145  </td>
146  </tr>
147 
148  <tr>
149  <td align="right" nowrap="true" class="padding" style="font-weight: bold;">
150  New password:
151  </td>
152  <td class="padding" align="left" width="100%">
153  <input
154  id="new1_pass"
155  name="new1_pass"
156  value=""
157  class="edit"
158  type="password"
159  size="10" maxlength="20"
160  />
161  </td>
162  </tr>
163 
164  <tr>
165  <td align="right" nowrap="true" class="padding" style="font-weight: bold;">
166  Confirm:
167  </td>
168  <td class="padding" align="left" width="100%">
169  <input
170  id="new2_pass"
171  name="new2_pass"
172  value=""
173  class="edit"
174  type="password"
175  size="10" maxlength="20"
176  />
177  </td>
178  </tr>
179 
180  <tr>
181  <td colspan="2" align="center" nowrap="true" class="padding">
182  <span style="color: red;" id="passchangemsg"></span>
183  </td>
184  </tr>
185 
186 
187  <tr>
188  <td class="padding">
189  &nbsp;
190  </td>
191  <td class="padding">
192  <input id="changego" type="button" name="changego" value="Change"
193  onclick="el('old').value = make_md5(el('old_pass').value);
194  el('new1').value = make_md5(el('new1_pass').value);
195  el('new2').value = make_md5(el('new2_pass').value);
196  xajax_window_submit('{$window_name}', xajax.getFormValues('passchange_form'), 'change_user_password');"
197  >
198  </td>
199  </td>
200  </table>
201  </form>
202  </span>
203 
204  <div style="background-color: {$color['window_content_bg']};">
205  <table style="padding: 25px;" cellspacing="0" border="0" cellpadding="0">
206  <tr><td class="padding" style="font-weight: bold;" align="center" colspan="3"><u>Current DB connection info</u></td></tr>
207  <tr><td class="padding" style="font-weight: bold;">Database Host</td><td class="padding">{$self['db_host']}</td></tr>
208  <tr><td class="padding" style="font-weight: bold;">Database Type</td><td class="padding">{$self['db_type']}</td></tr>
209  <tr><td class="padding" style="font-weight: bold;">Database Name</td><td class="padding">{$self['db_database']}</td></tr>
210  <tr><td class="padding" style="font-weight: bold;">Database User</td><td class="padding">{$self['db_login']}</td></tr>
211  <tr><td class="padding" style="font-weight: bold;">Database Context</td><td class="padding">{$self['context_name']}</td></tr>
212  <tr><td class="padding" style="font-weight: bold;">Database Context Desc</td><td class="padding">{$self['context_desc']}</td></tr>
213  <tr><td class="padding" style="font-weight: bold;">Database Context Color</td><td class="padding" style="background-color: {$self['context_color']}">{$self['context_color']}</td></tr>
214  </table>
215  </div>
216 
217 
218 EOL;
219 
220 
221 function ws_change_user_password($window_name, $form) {
222  global $conf, $self, $onadb;
223 
224 
225 
226  $username = $_SESSION['ona']['auth']['user']['username'];
227  // Instantiate the xajaxResponse object
228  $response = new xajaxResponse();
229  $js = "el('passchangemsg').innerHTML = '<span style=\"color: green;\">Changed!</span>'";
230  $exit_status = 0;
231 
232  // Validate the userid was passed and is "clean"
233  if (!preg_match('/^[A-Za-z0-9.\-_]+$/', $username)) {
234  $js = "el('passchangemsg').innerHTML = 'Invalid username format';";
235  $response->addScript($js);
236  return($response->getXML());
237  }
238 
239  list($status, $rows, $user) = db_get_record($onadb, 'users', "username LIKE '{$username}'");
240 
241  if (!$rows) {
242  $js = "el('passchangemsg').innerHTML = 'Unknown user';";
243  // Return some javascript to the browser
244  $response->addScript($js);
245  return($response->getXML());
246  }
247 
248 
249  if ($user['password'] != $form['old']) {
250  $js = "el('passchangemsg').innerHTML = 'Password incorrect (old)';";
251  // Return some javascript to the browser
252  $response->addScript($js);
253  return($response->getXML());
254  }
255 
256  if ($form['new1'] != $form['new2']) {
257  $js = "el('passchangemsg').innerHTML = 'New passwords dont match.';";
258  // Return some javascript to the browser
259  $response->addScript($js);
260  return($response->getXML());
261  }
262 
263  list ($status, $rows) = db_update_record(
264  $onadb,
265  'users',
266  array(
267  'username' => $username
268  ),
269  array(
270  'password' => $form['new2']
271  )
272  );
273 
274 
275  // If the module returned an error code display a popup warning
276  if ($status) {
277  $js = "alert('Save failed: " . trim($self['error']) . "');";
278  }
279 
280 
281  if ($js) { $response->addScript($js); }
282  return($response->getXML());
283 
284 }
285 
286 
287 
288 
289 ?>
$conf
global $conf
Definition: app_user_info.inc.php:18
onclick
_button onclick
Definition: app_advanced_search.inc.php:50
$window
$window['title']
Definition: app_user_info.inc.php:3
Name
Full Name
Definition: app_user_info.inc.php:101
Permissions
</td ></td >< tr >< td align="right" valign="top" class="padding" style="font-weight: bold;"> Permissions
Definition: app_user_info.inc.php:69
$status
$status
Definition: install.php:12
$onadb
global $onadb
Definition: 2-to-3.php:15
$username
$username
Definition: collate-convert.php:16
$permissions
$permissions
Definition: app_user_info.inc.php:24
password
</td >< td class="padding">< input id="changebutton" type="button" name="change_pass" value="Change Password" onclick="el('passchange_container').style.display = (el('passchange_container').style.display == 'none') ? '' : 'none'; el('changebutton').style.display = 'none';" ></td ></td ></table ><!-- PASSWORD CHANGE CONTAINER -->< span id="passchange_container" style="display:none;">< form id="passchange_form">< input id="old" name="old" type="hidden" value="">< input id="new1" name="new1" type="hidden" value="">< input id="new2" name="new2" type="hidden" value="">< table style="background-color: {$color['window_content_bg']}; padding-left: 25px; padding-right: 25px;" width="100%" cellspacing="0" border="0" cellpadding="0">< tr >< td align="right" nowrap="true" class="padding" style="font-weight: bold;"> Old password
Definition: app_user_info.inc.php:149
$self
global $self
Definition: app_user_info.inc.php:18
EOL
EOL
Definition: app_user_info.inc.php:16
db_update_record
db_update_record($dbh=0, $table="", $where="", $insert="")
Definition: functions_db.inc.php:474
ws_change_user_password
</td >< td class="padding">< input id="changego" type="button" name="changego" value="Change" onclick="el('old').value = make_md5(el('old_pass').value); el('new1').value = make_md5(el('new1_pass').value); el('new2').value = make_md5(el('new2_pass').value); xajax_window_submit('{$window_name}', xajax.getFormValues('passchange_form'), 'change_user_password');" ></td ></td ></table ></form ></span >< div style="background-color: {$color['window_content_bg']};">< table style="padding: 25px;" cellspacing="0" border="0" cellpadding="0">< tr >< td class="padding" style="font-weight: bold;" align="center" colspan="3">< u > Current DB connection info</u ></td ></tr >< tr >< td class="padding" style="font-weight: bold;"> Database Host</td >< td class="padding"> ws_change_user_password($window_name, $form)
Definition: app_user_info.inc.php:221
Username
</td ></td ><!-- commented out for now till LDAP stuff is usefull< tr >< td colspan="2" align="center" class="padding" style="font-weight: bold;">< u > Domain Info</u ></td ></td >< tr >< td align="right" valign="top" class="padding" style="font-weight: bold;"> Username
Definition: app_user_info.inc.php:92
$_SESSION
$_SESSION['ona']['auth']
Definition: login.php:14
xajaxResponse
Definition: xajaxResponse.inc.php:68
nbsp
& nbsp
Definition: install.php:36
$output
$output['ona_username']
Definition: app_user_info.inc.php:20
$groups
$groups
Definition: app_user_info.inc.php:22
db_get_record
db_get_record($dbh=0, $table="", $where="", $order="")
Definition: functions_db.inc.php:708
DB
Definition: adodb-pear.inc.php:99