1 | <?php
|
---|
2 |
|
---|
3 |
|
---|
4 | require_once 'header.php';
|
---|
5 | require_once 'libs/telnet_lib.php';
|
---|
6 | valid_login($action_permission['insert']);
|
---|
7 |
|
---|
8 | function main()
|
---|
9 | {
|
---|
10 | global $output, $lang_global, $lang_message;
|
---|
11 |
|
---|
12 | $output .= '
|
---|
13 | <div class="top"><h1>'.$lang_message['main'].'</h1></div>
|
---|
14 | <center>
|
---|
15 | <form action="message.php?action=send" method="post" name="form">
|
---|
16 | <table class="top_hidden">
|
---|
17 | <tr>
|
---|
18 | <td align="center">
|
---|
19 | Send :
|
---|
20 | <select name="type">
|
---|
21 | <option value="1" selected="selected">'.$lang_message['announcement'].'</option>
|
---|
22 | <option value="2">'.$lang_message['notification'].'</option>
|
---|
23 | <option value="3">'.$lang_message['both'].'</option>
|
---|
24 | </select>
|
---|
25 | </td>
|
---|
26 | </tr>
|
---|
27 | <tr>
|
---|
28 | <td colspan="2" align="center">
|
---|
29 | <textarea id="msg" name="msg" rows="26" cols="80"></textarea>
|
---|
30 | </td>
|
---|
31 | </tr>
|
---|
32 | <tr>
|
---|
33 | <td align="center">
|
---|
34 | <table align="center" class="hidden">
|
---|
35 | <tr>
|
---|
36 | <td>';
|
---|
37 | makebutton($lang_message['send'], 'javascript:do_submit()" type="wrn', 130);
|
---|
38 | $output .= '
|
---|
39 | </td>
|
---|
40 | <td>';
|
---|
41 | makebutton($lang_global['back'], 'javascript:window.history.back()" type="def', 130);
|
---|
42 | $output .= '
|
---|
43 | </td>
|
---|
44 | </tr>
|
---|
45 | </table>
|
---|
46 | </td>
|
---|
47 | </tr>
|
---|
48 | </table>
|
---|
49 | </form>
|
---|
50 | </center>';
|
---|
51 | }
|
---|
52 |
|
---|
53 |
|
---|
54 | function check()
|
---|
55 | {
|
---|
56 | global $output, $lang_telnet,
|
---|
57 | $realm_id, $server;
|
---|
58 |
|
---|
59 | $telnet = new telnet_lib();
|
---|
60 | $result = $telnet->Connect($server[$realm_id]['addr'], $server[$realm_id]['telnet_port'], $server[$realm_id]['telnet_user'], $server[$realm_id]['telnet_pass']);
|
---|
61 | if (0 == $result)
|
---|
62 | {
|
---|
63 | $telnet->Disconnect();
|
---|
64 | redirect('message.php?action=main');
|
---|
65 | }
|
---|
66 | elseif (1 == $result)
|
---|
67 | $mess_str = $lang_telnet['unable'];
|
---|
68 | elseif (2 == $result)
|
---|
69 | $mess_str = $lang_telnet['unknown_host'];
|
---|
70 | elseif (3 == $result)
|
---|
71 | $mess_str = $lang_telnet['login_failed'];
|
---|
72 | elseif (4 == $result)
|
---|
73 | $mess_str = $lang_telnet['not_supported'];
|
---|
74 |
|
---|
75 | unset($result);
|
---|
76 | unset($telnet);
|
---|
77 |
|
---|
78 | redirect('message.php?action=result&mess='.$mess_str.'');
|
---|
79 | }
|
---|
80 |
|
---|
81 |
|
---|
82 | function send(&$sqlc)
|
---|
83 | {
|
---|
84 | global $lang_telnet, $lang_message,
|
---|
85 | $realm_id, $server;
|
---|
86 |
|
---|
87 | if (empty($_POST['msg'])) redirect('message.php?action=result&mess='.$lang_message['empty_fields'].'');
|
---|
88 |
|
---|
89 | $type = (isset($_POST['type'])) ? $sqlc->quote_smart($_POST['type']) : 3;
|
---|
90 | if (is_numeric($type)); else $type = 3;
|
---|
91 |
|
---|
92 | $msg = $sqlc->quote_smart($_POST['msg']);
|
---|
93 | if (4096 < strlen($msg))
|
---|
94 | redirect('message.php?action=result&mess='.$lang_message['message_too_long'].'');
|
---|
95 |
|
---|
96 | $telnet = new telnet_lib();
|
---|
97 | $result = $telnet->Connect($server[$realm_id]['addr'], $server[$realm_id]['telnet_port'], $server[$realm_id]['telnet_user'], $server[$realm_id]['telnet_pass']);
|
---|
98 | if (0 == $result)
|
---|
99 | {
|
---|
100 | $mess_str = '';
|
---|
101 | if ( 2 == $type);
|
---|
102 | else
|
---|
103 | {
|
---|
104 | $telnet->DoCommand('announce '.$msg, $result);
|
---|
105 | $mess_str .= ''.$lang_message['system_message'].': "'.$msg.'" '.$lang_message['sent'].'.';
|
---|
106 | }
|
---|
107 | if ( 3 == $type)
|
---|
108 | $mess_str .= '<br /><br />';
|
---|
109 | if ( 1 == $type);
|
---|
110 | else
|
---|
111 | {
|
---|
112 | $telnet->DoCommand('notify '.$msg, $result);
|
---|
113 | $mess_str .= ''.$lang_message['global_notify'].': "'.$msg.'" '.$lang_message['sent'].'.';
|
---|
114 | }
|
---|
115 | $telnet->Disconnect();
|
---|
116 | }
|
---|
117 | elseif (1 == $result)
|
---|
118 | $mess_str = $lang_telnet['unable'];
|
---|
119 | elseif (2 == $result)
|
---|
120 | $mess_str = $lang_telnet['unknown_host'];
|
---|
121 | elseif (3 == $result)
|
---|
122 | $mess_str = $lang_telnet['login_failed'];
|
---|
123 | elseif (4 == $result)
|
---|
124 | $mess_str = $lang_telnet['not_supported'];
|
---|
125 |
|
---|
126 | unset($result);
|
---|
127 | unset($telnet);
|
---|
128 | unset($type);
|
---|
129 | unset($msg);
|
---|
130 |
|
---|
131 | redirect('message.php?action=result&mess='.$mess_str.'');
|
---|
132 | }
|
---|
133 |
|
---|
134 |
|
---|
135 | function result()
|
---|
136 | {
|
---|
137 | global $output, $lang_global, $lang_message;
|
---|
138 |
|
---|
139 | $mess = (isset($_GET['mess'])) ? $_GET['mess'] : NULL;
|
---|
140 |
|
---|
141 | $output .= '
|
---|
142 | <div class="top"><h1>'.$lang_message['message_result'].'</h1></div>
|
---|
143 | <center>
|
---|
144 | <table class="top_hidden" width="400">
|
---|
145 | <tr>
|
---|
146 | <td align="center">
|
---|
147 | <br />'.$mess.'<br /><br />';
|
---|
148 | unset($mess);
|
---|
149 | $output .= '
|
---|
150 | </td>
|
---|
151 | </tr>
|
---|
152 | <tr>
|
---|
153 | <td align="center">
|
---|
154 | <table align="center" class="hidden">
|
---|
155 | <tr>
|
---|
156 | <td>';
|
---|
157 | makebutton($lang_global['back'], 'javascript:window.history.back()', 130);
|
---|
158 | $output .= '
|
---|
159 | </td>
|
---|
160 | </tr>
|
---|
161 | </table>
|
---|
162 | </td>
|
---|
163 | </tr>
|
---|
164 | </table>
|
---|
165 | </center>';
|
---|
166 | }
|
---|
167 |
|
---|
168 | $action = (isset($_GET['action'])) ? $_GET['action'] : NULL;
|
---|
169 |
|
---|
170 | $lang_message = lang_message();
|
---|
171 | $lang_telnet = lang_telnet();
|
---|
172 |
|
---|
173 | if ('send' === $action)
|
---|
174 | send($sqlc);
|
---|
175 | elseif ('result' === $action)
|
---|
176 | result();
|
---|
177 | elseif ('main' === $action)
|
---|
178 | main();
|
---|
179 | else
|
---|
180 | check();
|
---|
181 |
|
---|
182 | unset($action);
|
---|
183 | unset($action_permission);
|
---|
184 | unset($lang_telnet);
|
---|
185 | unset($lang_message);
|
---|
186 |
|
---|
187 | require_once 'footer.php';
|
---|
188 |
|
---|
189 |
|
---|
190 | ?>
|
---|