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 | require_once("scripts/bbcode_lib.php");
|
---|
13 | valid_login(1);
|
---|
14 |
|
---|
15 | //#####################################################################################################
|
---|
16 | // ADD MOTD
|
---|
17 | //#####################################################################################################
|
---|
18 | function add_motd(){
|
---|
19 | global $lang_motd, $lang_global, $output;
|
---|
20 |
|
---|
21 | $output .= "<center>
|
---|
22 | <form action=\"motd.php?action=do_add_motd\" method=\"post\" name=\"form\">
|
---|
23 | <table class=\"top_hidden\">
|
---|
24 | <tr><td colspan=\"4\">";
|
---|
25 | add_bbcode_editor();
|
---|
26 | $output .= " </td></tr>
|
---|
27 | <tr><td colspan=\"4\">
|
---|
28 | <textarea id=\"msg\" name=\"msg\" rows=\"10\" cols=\"93\"></textarea>
|
---|
29 | </td></tr>
|
---|
30 | <tr>
|
---|
31 | <td>{$lang_motd['post_rules']}</td>
|
---|
32 | <td>";
|
---|
33 | makebutton($lang_motd['post_motd'], "javascript:do_submit()",220);
|
---|
34 | $output .= " <td/><td>";
|
---|
35 | makebutton($lang_global['back'], "javascript:window.history.back()",220);
|
---|
36 | $output .= " </td>
|
---|
37 | </tr>
|
---|
38 | </table>
|
---|
39 | </form>
|
---|
40 | <br /><br />
|
---|
41 | </center>";
|
---|
42 | }
|
---|
43 |
|
---|
44 |
|
---|
45 | //#####################################################################################################
|
---|
46 | // DO ADD MOTD
|
---|
47 | //#####################################################################################################
|
---|
48 | function do_add_motd(){
|
---|
49 | global $lang_global, $mangos_db, $realm_id, $user_name;
|
---|
50 |
|
---|
51 | if (empty($_POST['msg'])) redirect("motd.php?error=1");
|
---|
52 |
|
---|
53 | $sql = new SQL;
|
---|
54 | $sql->connect($mangos_db[$realm_id]['addr'], $mangos_db[$realm_id]['user'], $mangos_db[$realm_id]['pass'], $mangos_db[$realm_id]['name']);
|
---|
55 |
|
---|
56 | $msg = $sql->quote_smart($_POST['msg']);
|
---|
57 |
|
---|
58 | if (strlen($msg) > 4096){
|
---|
59 | $sql->close();
|
---|
60 | redirect("motd.php?error=2");
|
---|
61 | }
|
---|
62 |
|
---|
63 | $by = date("m/d/y H:i:s")." Posted by: $user_name";
|
---|
64 |
|
---|
65 | $sql->query("INSERT INTO bugreport (type, content) VALUES ('$by','$msg')");
|
---|
66 | $sql->close();
|
---|
67 |
|
---|
68 | redirect("index.php");
|
---|
69 | }
|
---|
70 |
|
---|
71 | //#####################################################################################################
|
---|
72 | // EDIT MOTD
|
---|
73 | //#####################################################################################################
|
---|
74 | function edit_motd(){
|
---|
75 | global $lang_motd,$lang_global, $output, $mangos_db, $realm_id;
|
---|
76 |
|
---|
77 | $sql = new SQL;
|
---|
78 | $sql->connect($mangos_db[$realm_id]['addr'], $mangos_db[$realm_id]['user'], $mangos_db[$realm_id]['pass'], $mangos_db[$realm_id]['name']);
|
---|
79 |
|
---|
80 | if(isset($_GET['id'])) $id = $sql->quote_smart($_GET['id']);
|
---|
81 | else redirect("motd.php?error=1");
|
---|
82 |
|
---|
83 | $result = $sql->query("SELECT content FROM bugreport WHERE id = '$id'");
|
---|
84 | $msg = $sql->result($result, 0);
|
---|
85 | $sql->close();
|
---|
86 |
|
---|
87 | $output .= "<center>
|
---|
88 | <form action=\"motd.php?action=do_edit_motd\" method=\"post\" name=\"form\">
|
---|
89 | <input type=\"hidden\" name=\"id\" value=\"$id\" />
|
---|
90 | <table class=\"top_hidden\">
|
---|
91 | <tr><td colspan=\"4\">";
|
---|
92 | add_bbcode_editor();
|
---|
93 | $output .= "</td></tr>
|
---|
94 | <tr>
|
---|
95 | <td colspan=\"4\">
|
---|
96 | <textarea id=\"msg\" name=\"msg\" rows=\"10\" cols=\"93\">$msg</textarea>
|
---|
97 | </td>
|
---|
98 | </tr>
|
---|
99 | <tr>
|
---|
100 | <td>{$lang_motd['post_rules']}</td>
|
---|
101 | <td>";
|
---|
102 | makebutton($lang_motd['post_motd'], "javascript:do_submit()",220);
|
---|
103 | $output .= " <td/><td>";
|
---|
104 | makebutton($lang_global['back'], "javascript:window.history.back()",220);
|
---|
105 | $output .= "</td>
|
---|
106 | </tr>
|
---|
107 | </table>
|
---|
108 | </form>
|
---|
109 | <br /><br />
|
---|
110 | </center>";
|
---|
111 | }
|
---|
112 |
|
---|
113 |
|
---|
114 | //#####################################################################################################
|
---|
115 | // DO EDIT MOTD
|
---|
116 | //#####################################################################################################
|
---|
117 | function do_edit_motd(){
|
---|
118 | global $lang_global, $mangos_db, $realm_id, $user_name;
|
---|
119 |
|
---|
120 | if (empty($_POST['msg']) || empty($_POST['id'])) redirect("motd.php?error=1");
|
---|
121 |
|
---|
122 | $sql = new SQL;
|
---|
123 | $sql->connect($mangos_db[$realm_id]['addr'], $mangos_db[$realm_id]['user'], $mangos_db[$realm_id]['pass'], $mangos_db[$realm_id]['name']);
|
---|
124 |
|
---|
125 | $msg = $sql->quote_smart($_POST['msg']);
|
---|
126 | $id = $sql->quote_smart($_POST['id']);
|
---|
127 |
|
---|
128 | $by = $sql->result($sql->query("SELECT type FROM bugreport WHERE id = '$id'"), 0, 'type');
|
---|
129 |
|
---|
130 | if (strlen($msg) > 4096){
|
---|
131 | $sql->close();
|
---|
132 | redirect("motd.php?error=2");
|
---|
133 | }
|
---|
134 |
|
---|
135 | $by = split("<br />", $by, 2);
|
---|
136 | $by = "{$by[0]}<br />".date("m/d/y H:i:s")." Edited by: $user_name";
|
---|
137 |
|
---|
138 | $sql->query("UPDATE bugreport SET type = '$by', content = '$msg' WHERE id = '$id'");
|
---|
139 | $sql->close();
|
---|
140 |
|
---|
141 | redirect("index.php");
|
---|
142 | }
|
---|
143 |
|
---|
144 |
|
---|
145 | //#####################################################################################################
|
---|
146 | // DELETE MOTD
|
---|
147 | //#####################################################################################################
|
---|
148 | function delete_motd(){
|
---|
149 | global $lang_global, $mangos_db, $realm_id;
|
---|
150 |
|
---|
151 | if (empty($_GET['id'])) redirect("index.php");
|
---|
152 |
|
---|
153 | $sql = new SQL;
|
---|
154 | $sql->connect($mangos_db[$realm_id]['addr'], $mangos_db[$realm_id]['user'], $mangos_db[$realm_id]['pass'], $mangos_db[$realm_id]['name']);
|
---|
155 |
|
---|
156 | $id = $sql->quote_smart($_GET['id']);
|
---|
157 |
|
---|
158 | $query = $sql->query("DELETE FROM bugreport WHERE id ='$id'");
|
---|
159 |
|
---|
160 | $sql->close();
|
---|
161 | redirect("index.php");
|
---|
162 | }
|
---|
163 |
|
---|
164 |
|
---|
165 | //########################################################################################################################
|
---|
166 | // MAIN
|
---|
167 | //########################################################################################################################
|
---|
168 | $err = (isset($_GET['error'])) ? $_GET['error'] : NULL;
|
---|
169 |
|
---|
170 | $output .= "<div class=\"top\">";
|
---|
171 | switch ($err) {
|
---|
172 | case 1:
|
---|
173 | $output .= "<h1><font class=\"error\">{$lang_global['empty_fields']}</font></h1>";
|
---|
174 | break;
|
---|
175 | case 2:
|
---|
176 | $output .= "<h1><font class=\"error\">{$lang_motd['err_max_len']}</font></h1>";
|
---|
177 | break;
|
---|
178 | default: //no error
|
---|
179 | $output .= "<h1>{$lang_motd['add_motd']}</h1>";
|
---|
180 | }
|
---|
181 | $output .= "</div>";
|
---|
182 |
|
---|
183 | $action = (isset($_GET['action'])) ? $_GET['action'] : NULL;
|
---|
184 |
|
---|
185 | switch ($action) {
|
---|
186 | case "delete_motd":
|
---|
187 | delete_motd();
|
---|
188 | break;
|
---|
189 | case "add_motd":
|
---|
190 | add_motd();
|
---|
191 | break;
|
---|
192 | case "do_add_motd":
|
---|
193 | do_add_motd();
|
---|
194 | break;
|
---|
195 | case "edit_motd":
|
---|
196 | edit_motd();
|
---|
197 | break;
|
---|
198 | case "do_edit_motd":
|
---|
199 | do_edit_motd();
|
---|
200 | break;
|
---|
201 | default:
|
---|
202 | add_motd();
|
---|
203 | }
|
---|
204 |
|
---|
205 | require_once("footer.php");
|
---|
206 | ?>
|
---|