Quick Search:

View

Revision:

Diff

Diff from 978 to:

Annotations

Annotate by Age | Author | Mixed | None
/fisheye/browse/osCommerce/tags/oscommerce-3.0a3/admin/administrators.php

Annotated File View

hpdl
276
1 <?php
2 /*
3   $Id: $
4
5   osCommerce, Open Source E-Commerce Solutions
6   http://www.oscommerce.com
7
hpdl
410
8   Copyright (c) 2006 osCommerce
hpdl
276
9
10   Released under the GNU General Public License
11 */
12
13   require('includes/application_top.php');
14
15   $action = (isset($_GET['action']) ? $_GET['action'] : '');
16
17   if (!isset($_GET['page']) || (isset($_GET['page']) && !is_numeric($_GET['page']))) {
18     $_GET['page'] = 1;
19   }
20
21   if (!empty($action)) {
22     switch ($action) {
23       case 'save':
24         $id = 0;
25
26         if (isset($_GET['aID']) && is_numeric($_GET['aID'])) {
27           $Qadmin = $osC_Database->query('update :table_administrators set user_name = :user_name where id = :id');
28           $Qadmin->bindInt(':id', $_GET['aID']);
29         } else {
30           $Qadmin = $osC_Database->query('insert into :table_administrators (user_name) values (:user_name)');
31         }
32         $Qadmin->bindTable(':table_administrators', TABLE_ADMINISTRATORS);
33         $Qadmin->bindValue(':user_name', $_POST['user_name']);
34         $Qadmin->execute();
35
36         if (($osC_Database->isError() === false) && !empty($_POST['user_password'])) {
37           $id = ((isset($_GET['aID']) && is_numeric($_GET['aID'])) ? $_GET['aID'] : $osC_Database->nextID());
38
39           $Qadmin = $osC_Database->query('update :table_administrators set user_password = :user_password where id = :id');
40           $Qadmin->bindTable(':table_administrators', TABLE_ADMINISTRATORS);
hpdl
758
41           $Qadmin->bindValue(':user_password', osc_encrypt_string(trim($_POST['user_password'])));
hpdl
276
42           $Qadmin->bindInt(':id', $id);
43           $Qadmin->execute();
44         }
45
46         if ($osC_Database->isError() === false) {
47           $osC_MessageStack->add_session('header', SUCCESS_DB_ROWS_UPDATED, 'success');
48         } else {
49           $osC_MessageStack->add_session('header', ERROR_DB_ROWS_NOT_UPDATED, 'error');
50         }
51
hpdl
758
52         osc_redirect(osc_href_link_admin(FILENAME_ADMINISTRATORS, 'page=' . $_GET['page'] . '&aID=' . $id));
hpdl
276
53         break;
54       case 'deleteconfirm':
55         if (isset($_GET['aID']) && is_numeric($_GET['aID'])) {
56           $Qdel = $osC_Database->query('delete from :table_administrators where id = :id');
57           $Qdel->bindTable(':table_administrators', TABLE_ADMINISTRATORS);
58           $Qdel->bindInt(':id', $_GET['aID']);
59           $Qdel->execute();
60
61           $osC_MessageStack->add_session('header', SUCCESS_DB_ROWS_UPDATED, 'success');
62         }
63
hpdl
758
64         osc_redirect(osc_href_link_admin(FILENAME_ADMINISTRATORS, 'page=' . $_GET['page']));
hpdl
276
65         break;
66     }
67   }
68
69   $page_contents = 'administrators.php';
70
71   require('templates/default.php');
72
73   require('includes/application_bottom.php');
74 ?>