1 | <?php
|
---|
2 | /*
|
---|
3 | * Project Name: MiniManager for Mangos Server
|
---|
4 | * Date: 17.10.2006 inital version (0.0.1a)
|
---|
5 | * Author: Q.SA
|
---|
6 | * Copyright: Q.SA
|
---|
7 | * Email: *****
|
---|
8 | * License: GNU General Public License v2(GPL)
|
---|
9 | */
|
---|
10 |
|
---|
11 | require_once("header.php");
|
---|
12 | valid_login(0);
|
---|
13 |
|
---|
14 | //##############################################################################################################
|
---|
15 | // EDIT USER
|
---|
16 | //##############################################################################################################
|
---|
17 | function edit_user() {
|
---|
18 | global $lang_edit, $lang_global, $output, $realm_db, $characters_db, $realm_id, $user_name, $user_id,
|
---|
19 | $lang_id_tab, $gm_level_arr;
|
---|
20 |
|
---|
21 | $sql = new SQL;
|
---|
22 | $sql->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']);
|
---|
23 |
|
---|
24 | $result = $sql->query("SELECT email,gmlevel,joindate,tbc FROM account WHERE username ='$user_name'");
|
---|
25 |
|
---|
26 | if ($acc = $sql->fetch_row($result)) {
|
---|
27 | require_once("scripts/id_tab.php");
|
---|
28 |
|
---|
29 | $output .= "<center>
|
---|
30 | <script type=\"text/javascript\" src=\"js/sha1.js\"></script>
|
---|
31 | <script type=\"text/javascript\">
|
---|
32 | function do_submit_data () {
|
---|
33 | document.form.pass.value = hex_sha1('".strtoupper($user_name).":'+document.form.user_pass.value.toUpperCase());
|
---|
34 | document.form.user_pass.value = '0';
|
---|
35 | do_submit();
|
---|
36 | }
|
---|
37 | </script>
|
---|
38 | <fieldset style=\"width: 550px;\">
|
---|
39 | <legend>{$lang_edit['edit_acc']}</legend>
|
---|
40 | <form method=\"post\" action=\"edit.php?action=doedit_user\" name=\"form\">
|
---|
41 | <input type=\"hidden\" name=\"pass\" value=\"\" maxlength=\"256\" />
|
---|
42 | <table class=\"flat\">
|
---|
43 | <tr>
|
---|
44 | <td>{$lang_edit['id']}</td>
|
---|
45 | <td>$user_id</td>
|
---|
46 | </tr>
|
---|
47 | <tr>
|
---|
48 | <td>{$lang_edit['username']}</td>
|
---|
49 | <td>$user_name</td>
|
---|
50 | </tr>
|
---|
51 | <tr>
|
---|
52 | <td>{$lang_edit['password']}</td>
|
---|
53 | <td><input type=\"text\" name=\"user_pass\" size=\"43\" maxlength=\"40\" value=\"******\" /></td>
|
---|
54 | </tr>
|
---|
55 | <tr>
|
---|
56 | <td>{$lang_edit['mail']}</td>
|
---|
57 | <td><input type=\"text\" name=\"mail\" size=\"43\" maxlength=\"225\" value=\"$acc[0]\" /></td>
|
---|
58 | </tr>
|
---|
59 | <tr>
|
---|
60 | <td>{$lang_edit['gm_level']}</td>
|
---|
61 | <td>".get_gm_level($acc[1])." ( $acc[1] )</td>
|
---|
62 | </tr>
|
---|
63 | <tr>
|
---|
64 | <td >{$lang_edit['client_type']}:</td>
|
---|
65 | <td>
|
---|
66 | <select name=\"tbc\">
|
---|
67 | <option value=\"1\" ";
|
---|
68 | if($acc[3]) $output .= "selected=\"selected\"";
|
---|
69 | $output .= ">{$lang_edit['expansion']}</option>
|
---|
70 | <option value=\"0\" ";
|
---|
71 | if(!$acc[3]) $output .= "selected=\"selected\"";
|
---|
72 | $output .= ">{$lang_edit['classic']}</option>
|
---|
73 | </select>
|
---|
74 | </td>
|
---|
75 | </tr>
|
---|
76 | <tr>
|
---|
77 | <td>{$lang_edit['join_date']}</td>
|
---|
78 | <td>$acc[2]</td>
|
---|
79 | </tr>";
|
---|
80 |
|
---|
81 | $result = $sql->query("SELECT SUM(numchars) FROM realmcharacters WHERE acctid = '$user_id'");
|
---|
82 | $output .= "<tr>
|
---|
83 | <td>{$lang_edit['tot_chars']}</td>
|
---|
84 | <td>".$sql->result($result, 0)."</td>
|
---|
85 | </tr>";
|
---|
86 |
|
---|
87 | $sql->connect($characters_db[$realm_id]['addr'], $characters_db[$realm_id]['user'], $characters_db[$realm_id]['pass'], $characters_db[$realm_id]['name']);
|
---|
88 | $result = $sql->query("SELECT guid,name,race,class,SUBSTRING_INDEX(SUBSTRING_INDEX(`data`, ' ', 35), ' ', -1) FROM `character` WHERE account = $user_id");
|
---|
89 |
|
---|
90 | $output .= "<tr>
|
---|
91 | <td>{$lang_edit['characters']}</td>
|
---|
92 | <td>".$sql->num_rows($result)."</td>
|
---|
93 | </tr>";
|
---|
94 |
|
---|
95 | while ($char = $sql->fetch_array($result)){
|
---|
96 | $output .= "<tr>
|
---|
97 | <td> '---></td>
|
---|
98 | <td><a href=\"char.php?id=$char[0]\">$char[1] - ".get_player_race($char[2])." ".get_player_class($char[3])." | lvl $char[4]</a></td>
|
---|
99 | </tr>";
|
---|
100 | }
|
---|
101 |
|
---|
102 | $output .= "<tr><td>";
|
---|
103 | makebutton($lang_edit['update'], "javascript:do_submit_data()",140);
|
---|
104 | $output .= "</td><td>";
|
---|
105 | makebutton($lang_edit['del_acc'], "edit.php?action=delete_user",150);
|
---|
106 | makebutton($lang_global['back'], "javascript:window.history.back()",150);
|
---|
107 | $output .= "</td></tr>
|
---|
108 | </table>
|
---|
109 | </form></fieldset>
|
---|
110 | <br />
|
---|
111 | <fieldset style=\"width: 550px;\">
|
---|
112 | <legend>{$lang_edit['cms_options']}</legend>
|
---|
113 | <table class=\"hidden\" style=\"width: 450px;\">
|
---|
114 | <tr>
|
---|
115 | <td align=\"left\">{$lang_edit['select_cms_layout_lang']} :</td>
|
---|
116 | <td align=\"right\">
|
---|
117 | <form action=\"edit.php\" method=\"get\" name=\"form1\">
|
---|
118 | <input type=\"hidden\" name=\"action\" value=\"lang_set\" />
|
---|
119 | <select name=\"lang\">
|
---|
120 | <optgroup label=\"{$lang_edit['language']}\">";
|
---|
121 | if (is_dir("./lang")){
|
---|
122 | if ($dh = opendir("./lang")){
|
---|
123 | while (($file = readdir($dh)) != false){
|
---|
124 | $lang = explode('.', $file);
|
---|
125 | if(isset($lang[1]) && $lang[1] == 'php'){
|
---|
126 | $output .= "<option value=\"{$lang[0]}\"";
|
---|
127 | if (isset($_COOKIE["lang"]) && ($_COOKIE["lang"] == $lang[0])) $output .= " selected=\"selected\" ";
|
---|
128 | $output .= ">{$lang[0]}</option>";
|
---|
129 | }
|
---|
130 | }
|
---|
131 | closedir($dh);
|
---|
132 | }
|
---|
133 | }
|
---|
134 | $output .= "</optgroup>
|
---|
135 | </select>
|
---|
136 | </form>
|
---|
137 | </td><td>";
|
---|
138 | makebutton($lang_edit['save'], "javascript:do_submit('form1',0)",100);
|
---|
139 | $output .= "</td>
|
---|
140 | </tr>
|
---|
141 | <tr>
|
---|
142 | <td align=\"left\">{$lang_edit['select_cms_template']} :</td>
|
---|
143 | <td align=\"right\">
|
---|
144 | <form action=\"edit.php\" method=\"get\" name=\"form2\">
|
---|
145 | <input type=\"hidden\" name=\"action\" value=\"template_set\" />
|
---|
146 | <select name=\"template\">
|
---|
147 | <optgroup label=\"{$lang_edit['template']}\">";
|
---|
148 | if (is_dir("./templates")){
|
---|
149 | if ($dh = opendir("./templates")){
|
---|
150 | while (($file = readdir($dh)) != false){
|
---|
151 | if (($file != '.')&&($file != '..')&&($file != '.htaccess')&&($file != 'index.html')&&($file != '.svn')){
|
---|
152 | $output .= "<option value=\"$file\"";
|
---|
153 | if (isset($_COOKIE["css_template"]) && ($_COOKIE["css_template"] == $file)) $output .= " selected=\"selected\" ";
|
---|
154 | $output .= ">$file</option>";
|
---|
155 | }
|
---|
156 | }
|
---|
157 | closedir($dh);
|
---|
158 | }
|
---|
159 | }
|
---|
160 | $output .= "</optgroup>
|
---|
161 | </select>
|
---|
162 | </form>
|
---|
163 | </td>
|
---|
164 | <td>";
|
---|
165 | makebutton($lang_edit['save'], "javascript:do_submit('form2',0)",100);
|
---|
166 | $output .= "</td></tr>
|
---|
167 | </table>
|
---|
168 | </fieldset>
|
---|
169 | <br /></center>";
|
---|
170 | } else error($lang_global['err_no_records_found']);
|
---|
171 |
|
---|
172 | $sql->close();
|
---|
173 | }
|
---|
174 |
|
---|
175 |
|
---|
176 | //#############################################################################################################
|
---|
177 | // DO EDIT USER
|
---|
178 | //#############################################################################################################
|
---|
179 | function doedit_user() {
|
---|
180 | global $realm_db, $user_name;
|
---|
181 |
|
---|
182 | if ( (!isset($_POST['pass'])||$_POST['pass'] === '') || (!isset($_POST['mail'])||$_POST['mail'] === '') ||(!isset($_POST['tbc'])||$_POST['tbc'] === '') )
|
---|
183 | redirect("edit.php?error=1");
|
---|
184 |
|
---|
185 | $sql = new SQL;
|
---|
186 | $sql->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']);
|
---|
187 |
|
---|
188 | $new_pass = ($sql->quote_smart($_POST['pass']) != sha1(strtoupper($user_name).":******")) ? "I='".$sql->quote_smart($_POST['pass'])."', " : "";
|
---|
189 | $new_mail = $sql->quote_smart(trim($_POST['mail']));
|
---|
190 | $new_tbc = $sql->quote_smart(trim($_POST['tbc']));
|
---|
191 |
|
---|
192 | //make sure the mail is valid mail format
|
---|
193 | require_once("scripts/valid_lib.php");
|
---|
194 | if ((!is_email($new_mail))||(strlen($new_mail) > 224)) redirect("edit.php?error=2");
|
---|
195 |
|
---|
196 | $sql->query("UPDATE account SET email='$new_mail', $new_pass tbc='$new_tbc' WHERE username = '$user_name'");
|
---|
197 |
|
---|
198 | if ($sql->affected_rows()) {
|
---|
199 | $sql->close();
|
---|
200 | redirect("edit.php?error=3");
|
---|
201 | } else {
|
---|
202 | $sql->close();
|
---|
203 | redirect("edit.php?error=4");
|
---|
204 | }
|
---|
205 | }
|
---|
206 |
|
---|
207 |
|
---|
208 | //###############################################################################################################
|
---|
209 | // DELETE USER
|
---|
210 | //###############################################################################################################
|
---|
211 | function delete_user() {
|
---|
212 | global $lang_edit, $lang_global, $output, $user_name;
|
---|
213 |
|
---|
214 | $output .= "<center><h1><font class=\"error\">{$lang_global['are_you_sure']}</font></h1><br />
|
---|
215 | <font class=\"bold\">{$lang_edit['username']} : '$user_name' {$lang_edit['will_be_erased']}</font><br /><br />
|
---|
216 | <table class=\"hidden\">
|
---|
217 | <tr><td>";
|
---|
218 | makebutton($lang_global['yes'], "edit.php?action=dodelete_user",120);
|
---|
219 | makebutton($lang_global['no'], "edit.php",120);
|
---|
220 | $output .= "</td></tr>
|
---|
221 | </table></center><br />";
|
---|
222 | }
|
---|
223 |
|
---|
224 |
|
---|
225 | //###############################################################################################################
|
---|
226 | // DO DELETE USER
|
---|
227 | //###############################################################################################################
|
---|
228 | function dodelete_user() {
|
---|
229 | global $realm_db, $characters_db, $realm_id, $user_id, $tab_del_user_characters, $tab_del_user_realmd;
|
---|
230 |
|
---|
231 | require_once("./scripts/del_lib.php");
|
---|
232 | list($flag,$del_char) = del_acc($user_id);
|
---|
233 |
|
---|
234 | if ($flag) include("logout.php");
|
---|
235 | else redirect("edit.php?error=5");
|
---|
236 | }
|
---|
237 |
|
---|
238 |
|
---|
239 | //###############################################################################################################
|
---|
240 | // SET DEFAULT INTERFACE LANGUAGE
|
---|
241 | //###############################################################################################################
|
---|
242 | function lang_set() {
|
---|
243 | if (empty($_GET['lang'])) redirect("edit.php?error=1");
|
---|
244 | else $lang = addslashes($_GET['lang']);
|
---|
245 |
|
---|
246 | if ($lang) {
|
---|
247 | setcookie("lang", $lang, time()+60*60*24*30*6); //six month
|
---|
248 | redirect("edit.php");
|
---|
249 | } else redirect("edit.php?error=1");
|
---|
250 | }
|
---|
251 |
|
---|
252 |
|
---|
253 | //###############################################################################################################
|
---|
254 | // SET DEFAULT INTERFACE TEMPLATE
|
---|
255 | //###############################################################################################################
|
---|
256 | function template_set() {
|
---|
257 | if (empty($_GET['template'])) redirect("edit.php?error=1");
|
---|
258 | else $tmpl = addslashes($_GET['template']);
|
---|
259 |
|
---|
260 | if ($tmpl) {
|
---|
261 | setcookie("css_template", $tmpl, time()+3600*24*30*6); //six month
|
---|
262 | redirect("edit.php");
|
---|
263 | } else redirect("edit.php?error=1");
|
---|
264 | }
|
---|
265 |
|
---|
266 | //###############################################################################################################
|
---|
267 | // MAIN
|
---|
268 | //###############################################################################################################
|
---|
269 | $err = (isset($_GET['error'])) ? $_GET['error'] : NULL;
|
---|
270 |
|
---|
271 | $output .= "<div class=\"top\">";
|
---|
272 | switch ($err) {
|
---|
273 | case 1:
|
---|
274 | $output .= "<h1><font class=\"error\">{$lang_global['empty_fields']}</font></h1>";
|
---|
275 | break;
|
---|
276 | case 2:
|
---|
277 | $output .= "<h1><font class=\"error\">{$lang_edit['use_valid_email']}</font></h1>";
|
---|
278 | break;
|
---|
279 | case 3:
|
---|
280 | $output .= "<h1><font class=\"error\">{$lang_edit['data_updated']}</font></h1>";
|
---|
281 | break;
|
---|
282 | case 4:
|
---|
283 | $output .= "<h1><font class=\"error\">{$lang_edit['error_updating']}</font></h1>";
|
---|
284 | break;
|
---|
285 | case 5:
|
---|
286 | $output .= "<h1><font class=\"error\">{$lang_edit['del_error']}</font></h1>";
|
---|
287 | break;
|
---|
288 | default: //no error
|
---|
289 | $output .= "<h1>{$lang_edit['edit_your_acc']}</h1>";
|
---|
290 | }
|
---|
291 | $output .= "</div>";
|
---|
292 |
|
---|
293 | $action = (isset($_GET['action'])) ? $_GET['action'] : NULL;
|
---|
294 |
|
---|
295 | switch ($action) {
|
---|
296 | case "doedit_user":
|
---|
297 | doedit_user();
|
---|
298 | break;
|
---|
299 | case "delete_user":
|
---|
300 | delete_user();
|
---|
301 | break;
|
---|
302 | case "dodelete_user":
|
---|
303 | dodelete_user();
|
---|
304 | break;
|
---|
305 | case "lang_set":
|
---|
306 | lang_set();
|
---|
307 | break;
|
---|
308 | case "template_set":
|
---|
309 | template_set();
|
---|
310 | break;
|
---|
311 | default:
|
---|
312 | edit_user();
|
---|
313 | }
|
---|
314 |
|
---|
315 | require_once("footer.php");
|
---|
316 | ?>
|
---|