1
+ <?php require_once 'engine/init.php ' ; include 'layout/overall/header.php ' ;
2
+ protect_page ();
3
+ admin_only ($ user_data );
4
+ // Encryption (if select field has $key 0, it will return false, so add $enc + $key will return 100, subtract and you get 0, not false).
5
+ $ enc = 100 ;
6
+ // Don't bother to think about cross site scripting here, since they can't access the page unless they are admin anyway.
7
+
8
+ // start
9
+ if (empty ($ _POST ) === false ) {
10
+ // BAN system!
11
+ if (!empty ($ _POST ['ban_char ' ]) && !empty ($ _POST ['ban_type ' ]) && !empty ($ _POST ['ban_action ' ]) && !empty ($ _POST ['ban_reason ' ]) && !empty ($ _POST ['ban_time ' ]) && !empty ($ _POST ['ban_comment ' ])) {
12
+ if (user_character_exist ($ _POST ['ban_char ' ])) {
13
+
14
+ // Decrypt and store values
15
+ $ charname = $ _POST ['ban_char ' ];
16
+ $ typeid = (int )$ _POST ['ban_type ' ] - $ enc ;
17
+ $ actionid = (int )$ _POST ['ban_action ' ] - $ enc ;
18
+ $ reasonid = (int )$ _POST ['ban_type ' ] - $ enc ;
19
+ $ time = (int )$ _POST ['ban_time ' ] - $ enc ;
20
+ $ comment = $ _POST ['ban_comment ' ];
21
+ //var_dump($charname, $typeid, $actionid, $reasonid, $time, $comment);
22
+
23
+ if (set_rule_violation ($ charname , $ typeid , $ actionid , $ reasonid , $ time , $ comment )) {
24
+ $ errors [] = 'Violation entry has been set for ' . $ charname .'. ' ;
25
+ } else {
26
+ $ errors [] = 'Website character name: ' . $ config ['website_char ' ] .' does not exist. Create this character name or configure another name in config.php ' ;
27
+ $ errors [] = 'Website failed to recognize a character it can represent while inserting a rule violation. ' ;
28
+ }
29
+
30
+ } else {
31
+ $ errors [] = 'Character ' . $ _POST ['ban_char ' ] .' does not exist. ' ;
32
+ }
33
+ }
34
+
35
+
36
+ // delete character:
37
+ if (empty ($ _POST ['del_name ' ]) === false ) {
38
+ if (user_character_exist ($ _POST ['del_name ' ])) {
39
+ user_delete_character (user_character_id ($ _POST ['del_name ' ]));
40
+ $ errors [] = 'Character ' . $ _POST ['del_name ' ] .' permanently deleted. ' ;
41
+ } else {
42
+ $ errors [] = 'Character ' . $ _POST ['del_name ' ] .' does not exist. ' ;
43
+ }
44
+ }
45
+
46
+ // Reset password for char name
47
+ if (empty ($ _POST ['reset_pass ' ]) === false && empty ($ _POST ['new_pass ' ]) === false ) {
48
+ // reset_pass = character name
49
+ if (user_character_exist ($ _POST ['reset_pass ' ])) {
50
+ $ acc_id = user_character_account_id ($ _POST ['reset_pass ' ]);
51
+
52
+ if ($ acc_id != $ session_user_id ) {
53
+ if ($ config ['TFSVersion ' ] == 'TFS_02 ' ) {
54
+ user_change_password ($ acc_id , $ _POST ['new_pass ' ]);
55
+ } else if ($ config ['TFSVersion ' ] == 'TFS_03 ' ) {
56
+ user_change_password03 ($ acc_id , $ _POST ['new_pass ' ]);
57
+ }
58
+ $ errors [] = 'The password to the account of character name: ' . $ _POST ['reset_pass ' ] .' has been set to: ' . $ _POST ['new_pass ' ] .'. ' ;
59
+ } else {
60
+ header ('Location: changepassword.php ' );
61
+ exit ();
62
+ }
63
+ }
64
+ }
65
+
66
+ /* Give points to character
67
+ if (empty($_POST['points_char']) === false && empty($_POST['points_value']) === false) {
68
+ // fetch account id
69
+ $char = $_POST['points_char'];
70
+ $points = $_POST['points_value'];
71
+ $accid = user_character_account_id($char);
72
+ if ($points > 0) {
73
+ if ($accid > 0) {
74
+ $new_points = $points;
75
+ $old_points = mysql_result(mysql_query("SELECT `points` FROM `znote_accounts` WHERE `account_id`='$accid';"), 0, 'points');
76
+ $new_points += $old_points;
77
+ $update_account = mysql_query("UPDATE `znote_accounts` SET `points`='$new_points' WHERE `account_id`='$accid'");
78
+ $errors[] = 'Success! Character '. $char .' has recieved '. $points .' premium points.';
79
+ } else $errors[] = 'Account id is invalid. (Did you write correct character name?)'. $accid;
80
+ } else $errors[] = 'Why the heck give a character 0 points?!';
81
+ }*/
82
+
83
+ // Give points to character
84
+ if (empty ($ _POST ['points_char ' ]) === false && empty ($ _POST ['points_value ' ]) === false ) {
85
+ $ char = sanitize ($ _POST ['points_char ' ]);
86
+ $ points = (int )$ _POST ['points_value ' ];
87
+ data_dump ($ _POST , false , "post data " );
88
+ $ account = mysql_select_single ("SELECT `account_id` FROM `players` WHERE `name`=' $ char' LIMIT 1; " );
89
+ data_dump ($ account , false , "fetching account id from players table " );
90
+ $ znote_account = mysql_select_single ("SELECT `id`, `points` FROM `znote_accounts` WHERE `account_id`=' " . $ account ['account_id ' ] ."'; " );
91
+ data_dump ($ znote_account , false , "Fetching existing points from znote_accounts " );
92
+
93
+ data_dump (
94
+ array (
95
+ 'Old: ' => $ znote_account ['points ' ],
96
+ 'New: ' => $ points ,
97
+ 'Total: ' => ($ znote_account ['points ' ] + $ points )
98
+ ),
99
+ false ,
100
+ "Points calculation: " );
101
+ $ points += $ znote_account ['points ' ];
102
+ mysql_update ("UPDATE `znote_accounts` SET `points`=' $ points' WHERE `account_id`=' " . $ account ['account_id ' ] ."'; " );
103
+ }
104
+
105
+ // Set character position
106
+ if (empty ($ _POST ['position_name ' ]) === false && empty ($ _POST ['position_type ' ]) === false ) {
107
+ if (user_character_exist ($ _POST ['position_name ' ])) {
108
+ if (array_key_exists ($ _POST ['position_type ' ], $ config ['ingame_positions ' ])) {
109
+ if ($ config ['TFSVersion ' ] == 'TFS_02 ' || $ config ['TFSVersion ' ] == 'TFS_10 ' ) {
110
+ set_ingame_position ($ _POST ['position_name ' ], $ _POST ['position_type ' ]);
111
+ } else if ($ config ['TFSVersion ' ] == 'TFS_03 ' ) {
112
+ set_ingame_position03 ($ _POST ['position_name ' ], $ _POST ['position_type ' ]);
113
+ }
114
+ $ pos = 'Undefined ' ;
115
+ foreach ($ config ['ingame_positions ' ] as $ key =>$ value ) {
116
+ if ($ key == $ _POST ['position_type ' ]) {
117
+ $ pos = $ value ;
118
+ }
119
+ }
120
+ $ errors [] = 'Character ' . $ _POST ['position_name ' ] .' recieved the ingame position: ' . $ pos .'. ' ;
121
+ }
122
+ } else {
123
+ $ errors [] = 'Character ' . $ _POST ['position_name ' ] .' does not exist. ' ;
124
+ }
125
+ }
126
+
127
+ // If empty post
128
+ }
129
+
130
+ // Display whatever output we figure out to add
131
+ if (empty ($ errors ) === false ){
132
+ echo '<font color="red"><b> ' ;
133
+ echo output_errors ($ errors );
134
+ echo '</b></font> ' ;
135
+ }
136
+ // end
137
+ ?>
138
+ <h1>Admin Page.</h1>
139
+ <p>
140
+ <?php
141
+ $ basic = user_znote_data ('version ' , 'installed ' , 'cached ' );
142
+ if ($ basic ['version ' ] !== $ version ) {
143
+ mysql_query ("UPDATE `znote` SET `version`=' $ version'; " ) or die (mysql_error ());
144
+ $ basic = user_znote_data ('version ' , 'installed ' , 'cached ' );
145
+ }
146
+ echo "Running Znote AAC Version: " . $ basic ['version ' ] .".<br> " ;
147
+ echo "Last cached on: " . getClock ($ basic ['cached ' ], true ) .".<br> " ;
148
+ ?>
149
+ </p>
150
+ <ul>
151
+ <li>
152
+ <b>Permanently Delete/erase character from database:</b>
153
+ <form type="submit" action="" method="post">
154
+ <input type="text" name="del_name" placeholder="Character name...">
155
+ </form>
156
+ </li>
157
+ <li>
158
+ <b>Ban/violate :3 character and/or his account:</b>
159
+ <form action="" method="post">
160
+ <table style="background-color:lightblue;">
161
+ <!-- row 1 -->
162
+ <tr>
163
+ <td>
164
+ <input type="text" name="ban_char" placeholder="Character name...">
165
+ </td>
166
+ </tr>
167
+
168
+ <!-- row 2 -->
169
+ <tr>
170
+ <td>
171
+ <select name="ban_type">
172
+ <?php
173
+ foreach ($ config ['ban_type ' ] as $ key =>$ value ) {
174
+ echo "<option value= \"" . ($ enc + $ key ) ."\"> " . $ value ."</option> " ;
175
+ }
176
+ ?>
177
+ </select>
178
+ <select name="ban_action">
179
+ <?php
180
+ foreach ($ config ['ban_action ' ] as $ key =>$ value ) {
181
+ echo "<option value= \"" . ($ enc + $ key ) ."\"> " . $ value ."</option> " ;
182
+ }
183
+ ?>
184
+ </select>
185
+ <select name="ban_time">
186
+ <?php
187
+ foreach ($ config ['ban_time ' ] as $ key =>$ value ) {
188
+ echo "<option value= \"" . ($ enc + $ key ) ."\"> " . $ value ."</option> " ;
189
+ }
190
+ ?>
191
+ </select>
192
+ </td>
193
+ </tr>
194
+
195
+ <!-- row 3 -->
196
+ <tr>
197
+ <td>
198
+ Ban reason:
199
+ <select name="ban_reason">
200
+ <?php
201
+ foreach ($ config ['ban_reason ' ] as $ key =>$ value ) {
202
+ echo "<option value= \"" . ($ enc + $ key ) ."\"> " . $ value ."</option> " ;
203
+ }
204
+ ?>
205
+ </select>
206
+ </td>
207
+ </tr>
208
+
209
+ <!-- row 4 -->
210
+ <tr>
211
+ <td>
212
+ Violation comment: (max 60 cols).
213
+ <input type="text" name="ban_comment" maxlength="60" placeholder="Ban for botting rotworms.">
214
+ <input type="submit" value="Set Violation">
215
+ </td>
216
+ </tr>
217
+ </table>
218
+ </form>
219
+ </li>
220
+ <li>
221
+ <b>Reset password to the account of character name:</b>
222
+ <form action="" method="post">
223
+ <input type="text" name="reset_pass" placeholder="Character name">
224
+ <input type="text" name="new_pass" placeholder="New password">
225
+ <input type="submit" value="Change Password">
226
+ </form>
227
+ </li>
228
+ <li>
229
+ <b>Set character name to position:</b>
230
+ <?php
231
+ if ($ config ['TFSVersion ' ] == 'TFS_03 ' && count ($ config ['ingame_positions ' ]) == 5 ) {
232
+ ?>
233
+ <font color="red">ERROR: You forgot to add (Senior Tutor) rank in config.php!</font>
234
+ <?php
235
+ }
236
+ ?>
237
+ <form action="" method="post">
238
+ <input type="text" name="position_name" placeholder="Character name">
239
+ <select name="position_type">
240
+ <?php
241
+ foreach ($ config ['ingame_positions ' ] as $ key =>$ value ) {
242
+ echo "<option value= \"" . $ key ."\"> " . $ value ."</option> " ;
243
+ }
244
+ ?>
245
+ </select>
246
+ <input type="submit" value="Set Position">
247
+ </form>
248
+ </li>
249
+ <li>
250
+ <b>Give shop points to character:</b>
251
+ <form action="" method="post">
252
+ <input type="text" name="points_char" placeholder="Character name">
253
+ <input type="text" name="points_value" placeholder="Points">
254
+ <input type="submit" value="Give Points">
255
+ </form>
256
+ </li>
257
+ </ul>
258
+ <div id="twitter"><?php include 'twtrNews.php ' ; ?> </div>
259
+
260
+ <?php include 'layout/overall/footer.php ' ; ?>
0 commit comments