| 1 | <?php
|
| 2 |
|
| 3 | /*
|
| 4 |
|
| 5 | Copyright (C) 2009, All Rights Reserved.
|
| 6 |
|
| 7 | This file is part of RPInventory.
|
| 8 |
|
| 9 | RPInventory is free software: you can redistribute it and/or modify
|
| 10 | it under the terms of the GNU General Public License as published by
|
| 11 | the Free Software Foundation, either version 3 of the License, or
|
| 12 | (at your option) any later version.
|
| 13 |
|
| 14 | RPInventory is distributed in the hope that it will be useful,
|
| 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 17 | GNU General Public License for more details.
|
| 18 |
|
| 19 | You should have received a copy of the GNU General Public License
|
| 20 | along with RPInventory. If not, see <http://www.gnu.org/licenses/>.
|
| 21 |
|
| 22 | */
|
| 23 |
|
| 24 | require_once("lib/auth.lib.php"); //Session
|
| 25 | require_once('lib/users.lib.php');
|
| 26 | require_once('class/database.class.php');
|
| 27 |
|
| 28 | // Connect
|
| 29 | $db = new database();
|
| 30 |
|
| 31 | //Authenticate
|
| 32 | $auth = GetAuthority();
|
| 33 | if($auth < 2)
|
| 34 | die("You dont have permission to access this page");
|
| 35 |
|
| 36 | //Username
|
| 37 | $username = $_POST["username"];
|
| 38 | if(strlen($username) == 0)
|
| 39 | die("Must have a description");
|
| 40 |
|
| 41 | //Password
|
| 42 | $password = $_POST["password"];
|
| 43 |
|
| 44 |
|
| 45 | //Access level
|
| 46 | $access = (int)$_POST["access_level"];
|
| 47 | if($access > 2 || $access < 2)
|
| 48 | die("Invalid access level");
|
| 49 |
|
| 50 |
|
| 51 | //email
|
| 52 | $email = $_POST["email"];
|
| 53 | if(strlen($email) == 0)
|
| 54 | die("Must have a email");
|
| 55 |
|
| 56 | //id
|
| 57 | $id = (int)$_POST["id"];
|
| 58 | if($id == 0)
|
| 59 | die("Invalid ID");
|
| 60 |
|
| 61 | if (strlen($password) == 0)
|
| 62 | {
|
| 63 | $user = getUser($id, $db);
|
| 64 | $password = $user->password;
|
| 65 | }
|
| 66 | else
|
| 67 | {
|
| 68 | $password = md5($password);
|
| 69 | }
|
| 70 |
|
| 71 | updateUser($id, $username, $email, $password, $db);
|
| 72 |
|
| 73 | $db->close();
|
| 74 |
|
| 75 | header('Location: manageUsers.php');
|
| 76 |
|
| 77 | ?>
|
| 78 | |