| 10 | | * @license |
|---|
| 11 | | * This program is free software; you can redistribute it and/or modify it under |
|---|
| 12 | | * the terms of the MPL General Public License as published by the Free Software |
|---|
| 13 | | * Foundation; either version 1.1 of the License, or (at your option) any later |
|---|
| 14 | | * version. |
|---|
| 15 | | * You should have received a copy of the MPL Mozilla Public License along with |
|---|
| 16 | | * this program; if not, write to the Open Source Initiative (OSI) |
|---|
| 17 | | * http://opensource.org | osi@opensource.org |
|---|
| 18 | | **/ |
|---|
| | 11 | * @license |
|---|
| | 12 | * This program is free software; you can redistribute it and/or modify it under |
|---|
| | 13 | * the terms of the MPL General Public License as published by the Free Software |
|---|
| | 14 | * Foundation; either version 1.1 of the License, or (at your option) any later |
|---|
| | 15 | * version. |
|---|
| | 16 | * You should have received a copy of the MPL Mozilla Public License along with |
|---|
| | 17 | * this program; if not, write to the Open Source Initiative (OSI) |
|---|
| | 18 | * http://opensource.org | osi@opensource.org |
|---|
| | 19 | */ |
|---|
| 32 | | $tpl -> assign( |
|---|
| 33 | | array( |
|---|
| 34 | | 'TR_ADMIN_ADD_USER_PAGE_TITLE' => tr('ispCP - Admin/Manage users/Add User'), |
|---|
| 35 | | 'THEME_COLOR_PATH' => "../themes/$theme_color", |
|---|
| 36 | | 'THEME_CHARSET' => tr('encoding'), |
|---|
| 37 | | 'ISP_LOGO' => get_logo($_SESSION['user_id']), |
|---|
| 38 | | 'ISPCP_LICENSE' => $cfg['ISPCP_LICENSE'] |
|---|
| 39 | | ) |
|---|
| 40 | | ); |
|---|
| 41 | | |
|---|
| 42 | | |
|---|
| 43 | | function add_user(&$tpl, &$sql) |
|---|
| 44 | | { |
|---|
| 45 | | |
|---|
| 46 | | if (isset($_POST['uaction']) && $_POST['uaction'] === 'add_user') { |
|---|
| 47 | | |
|---|
| 48 | | if(check_user_data()){ |
|---|
| 49 | | |
|---|
| 50 | | $upass = crypt_user_pass($_POST['pass']); |
|---|
| 51 | | |
|---|
| 52 | | $user_id = $_SESSION['user_id']; |
|---|
| 53 | | |
|---|
| 54 | | $username = clean_input($_POST['username']); |
|---|
| 55 | | $fname = clean_input($_POST['fname']); |
|---|
| 56 | | $lname = clean_input($_POST['lname']); |
|---|
| 57 | | $gender = clean_input($_POST['gender']); |
|---|
| 58 | | $firm = clean_input($_POST['firm']); |
|---|
| 59 | | $zip = clean_input($_POST['zip']); |
|---|
| 60 | | $city = clean_input($_POST['city']); |
|---|
| 61 | | $country = clean_input($_POST['country']); |
|---|
| 62 | | $email = clean_input($_POST['email']); |
|---|
| 63 | | $phone = clean_input($_POST['phone']); |
|---|
| 64 | | $fax = clean_input($_POST['fax']); |
|---|
| 65 | | $street1 = clean_input($_POST['street1']); |
|---|
| 66 | | $street2 = clean_input($_POST['street2']); |
|---|
| 67 | | |
|---|
| 68 | | if (get_gender_by_code($gender, true) === null) { |
|---|
| 69 | | $gender = ''; |
|---|
| 70 | | } |
|---|
| 71 | | |
|---|
| 72 | | $query = <<<SQL_QUERY |
|---|
| | 31 | $tpl->assign( |
|---|
| | 32 | array( |
|---|
| | 33 | 'TR_ADMIN_ADD_USER_PAGE_TITLE' => tr('ispCP - Admin/Manage users/Add User'), |
|---|
| | 34 | 'THEME_COLOR_PATH' => "../themes/$theme_color", |
|---|
| | 35 | 'THEME_CHARSET' => tr('encoding'), |
|---|
| | 36 | 'ISP_LOGO' => get_logo($_SESSION['user_id']) |
|---|
| | 37 | ) |
|---|
| | 38 | ); |
|---|
| | 39 | |
|---|
| | 40 | function add_user(&$tpl, &$sql) { |
|---|
| | 41 | if (isset($_POST['uaction']) && $_POST['uaction'] === 'add_user') { |
|---|
| | 42 | if (check_user_data()) { |
|---|
| | 43 | $upass = crypt_user_pass($_POST['pass']); |
|---|
| | 44 | |
|---|
| | 45 | $user_id = $_SESSION['user_id']; |
|---|
| | 46 | |
|---|
| | 47 | $username = clean_input($_POST['username']); |
|---|
| | 48 | $fname = clean_input($_POST['fname']); |
|---|
| | 49 | $lname = clean_input($_POST['lname']); |
|---|
| | 50 | $gender = clean_input($_POST['gender']); |
|---|
| | 51 | $firm = clean_input($_POST['firm']); |
|---|
| | 52 | $zip = clean_input($_POST['zip']); |
|---|
| | 53 | $city = clean_input($_POST['city']); |
|---|
| | 54 | $country = clean_input($_POST['country']); |
|---|
| | 55 | $email = clean_input($_POST['email']); |
|---|
| | 56 | $phone = clean_input($_POST['phone']); |
|---|
| | 57 | $fax = clean_input($_POST['fax']); |
|---|
| | 58 | $street1 = clean_input($_POST['street1']); |
|---|
| | 59 | $street2 = clean_input($_POST['street2']); |
|---|
| | 60 | |
|---|
| | 61 | if (get_gender_by_code($gender, true) === null) { |
|---|
| | 62 | $gender = ''; |
|---|
| | 63 | } |
|---|
| | 64 | |
|---|
| | 65 | $query = <<<SQL_QUERY |
|---|
| 116 | | $rs = exec_query($sql, $query, array($username, |
|---|
| 117 | | $upass, |
|---|
| 118 | | $user_id, |
|---|
| 119 | | $fname, |
|---|
| 120 | | $lname, |
|---|
| 121 | | $firm, |
|---|
| 122 | | $zip, |
|---|
| 123 | | $city, |
|---|
| 124 | | $country, |
|---|
| 125 | | $email, |
|---|
| 126 | | $phone, |
|---|
| 127 | | $fax, |
|---|
| 128 | | $street1, |
|---|
| 129 | | $street2, |
|---|
| 130 | | $gender)); |
|---|
| 131 | | |
|---|
| 132 | | $new_admin_id = $sql -> Insert_ID(); |
|---|
| 133 | | |
|---|
| 134 | | $user_logged= $_SESSION['user_logged']; |
|---|
| 135 | | |
|---|
| 136 | | write_log("$user_logged: add admin: $username"); |
|---|
| 137 | | |
|---|
| 138 | | $user_def_lang = $_SESSION['user_def_lang']; |
|---|
| 139 | | $user_theme_color = $_SESSION['user_theme']; |
|---|
| 140 | | $user_logo = 0; |
|---|
| 141 | | |
|---|
| 142 | | $query = <<<SQL_QUERY |
|---|
| | 109 | $rs = exec_query($sql, $query, array($username, |
|---|
| | 110 | $upass, |
|---|
| | 111 | $user_id, |
|---|
| | 112 | $fname, |
|---|
| | 113 | $lname, |
|---|
| | 114 | $firm, |
|---|
| | 115 | $zip, |
|---|
| | 116 | $city, |
|---|
| | 117 | $country, |
|---|
| | 118 | $email, |
|---|
| | 119 | $phone, |
|---|
| | 120 | $fax, |
|---|
| | 121 | $street1, |
|---|
| | 122 | $street2, |
|---|
| | 123 | $gender)); |
|---|
| | 124 | |
|---|
| | 125 | $new_admin_id = $sql->Insert_ID(); |
|---|
| | 126 | |
|---|
| | 127 | $user_logged = $_SESSION['user_logged']; |
|---|
| | 128 | |
|---|
| | 129 | write_log("$user_logged: add admin: $username"); |
|---|
| | 130 | |
|---|
| | 131 | $user_def_lang = $_SESSION['user_def_lang']; |
|---|
| | 132 | $user_theme_color = $_SESSION['user_theme']; |
|---|
| | 133 | $user_logo = 0; |
|---|
| | 134 | |
|---|
| | 135 | $query = <<<SQL_QUERY |
|---|
| 157 | | $rs = exec_query($sql, $query, array($new_admin_id, |
|---|
| 158 | | $user_def_lang, |
|---|
| 159 | | $user_theme_color, |
|---|
| 160 | | $user_logo)); |
|---|
| 161 | | |
|---|
| 162 | | send_add_user_auto_msg ( |
|---|
| 163 | | $user_id, |
|---|
| 164 | | clean_input($_POST['username']), |
|---|
| 165 | | clean_input($_POST['pass']), |
|---|
| 166 | | clean_input($_POST['email']), |
|---|
| 167 | | clean_input($_POST['fname']), |
|---|
| 168 | | clean_input($_POST['lname']), |
|---|
| 169 | | tr('Administrator'), |
|---|
| 170 | | $gender |
|---|
| 171 | | ); |
|---|
| 172 | | |
|---|
| 173 | | $_SESSION['user_added'] = 1; |
|---|
| 174 | | |
|---|
| 175 | | header( "Location: manage_users.php" ); |
|---|
| 176 | | die(); |
|---|
| 177 | | |
|---|
| 178 | | } //check user data |
|---|
| 179 | | else{ |
|---|
| 180 | | $tpl -> assign( |
|---|
| 181 | | array( |
|---|
| 182 | | 'EMAIL' => clean_input($_POST['email']), |
|---|
| 183 | | 'USERNAME' => clean_input($_POST['username']), |
|---|
| 184 | | 'FIRST_NAME' => clean_i |
|---|