root/trunk/rms-web/message.php

Revision 4570, 3.7 kB (checked in by erijo, 2 years ago)

Undo r4567 since rms-web has not been replaced by licqweb.
Also fixed most of the images (they were broken) by copying them from
licqweb.

  • Property svn:eol-style set to native
Line 
1<?php
2include "check_session.php";
3include "config.php";
4include "rms.php";
5include "kses.php";
6
7function rmsHandleCommand($cmd, $id = "", $pp = "")
8{
9  switch ($cmd)
10  {
11    case "MSG":
12      rmsInputMessage($id, $pp);
13      break;
14    case "VIEW":
15      rmsViewMessage($id, $pp);
16      break;
17    case "frmMsg":
18      rmsSendMessage();
19  }
20}
21
22function rmsInputMessage($id, $pp)
23{
24?>
25  <SCRIPT type="text/javascript">
26  function clearMsg()
27  {
28    document.location = "message.php"
29  }
30 
31  //-->
32  </SCRIPT>
33 
34  <CENTER><BR><BR>
35  <FORM method="POST">
36    <TABLE border=1>
37    <TR>
38      <TD>
39        To <INPUT type="text" size="40" name="send_id" value="<?php echo $id ?>">
40      </TD>
41    </TR>
42    <TR>
43      <TD>
44        <TEXTAREA name="message" cols="48" rows="4"></TEXTAREA>
45      </TD>
46    </TR>
47    <TR>
48      <TD>
49        <INPUT type="submit" name="submit" value="Send">
50        <INPUT type="button" onClick="clearMsg()" value="Cancel">
51      </TD>
52    </TR>
53    <INPUT type="hidden" name="cmd" value="frmMsg">
54    <INPUT type="hidden" name="pp" value="<?php echo $pp ?>">
55    </TABLE>
56  </FORM>
57
58<?php
59}
60
61function rmsViewMessage($id, $pp)
62{
63  global $username, $password, $sock;
64 
65  rmsLogin($username, $password);
66 
67  $cmd = "VIEW " . $id . "." . $pp . "\r\n";
68  sendData($cmd);
69 
70  $packet = socket_read($sock, 1024, PHP_NORMAL_READ);
71  $event = substr($packet, 4);
72 
73  $packet = socket_read($sock, 1024, PHP_NORMAL_READ);
74  $snttime = substr($packet, 12);
75 
76  $packet = socket_read($sock, 1024, PHP_NORMAL_READ);
77  $packet = socket_read($sock, 1024, PHP_BINARY_READ);
78 
79  $msg = str_replace("\r\n", "<BR>", $packet);
80  $msg = str_replace("\n", "<BR>", $msg);
81 
82  preg_match("/^(.*)<BR>223 Message Complete<BR>$/", $msg, $matches);
83  $msg = $matches[1];
84
85  // kses input filtering
86  $allowed = array('b' => array(),
87                   'i' => array(),
88                   'a' => array('href' => 1, 'title' => 1),
89                   'p' => array('align' => 1),
90                   'br' => array());
91
92  if (get_magic_quotes_gpc())
93    $msg = stripslashes($msg);
94  $msg = kses($msg, $allowed);
95  // --
96 
97  $location = "message.php?command=MSG&id=" . $id . "&pp=" . $pp;
98?>
99
100  <SCRIPT type="text/javascript">
101  <!--
102  function reply()
103  {
104    document.location = "<?php echo $location ?>"
105  }
106 
107  function clearMsg()
108  {
109    document.location = "message.php"
110  }
111 
112  //-->
113  </SCRIPT>
114
115  <CENTER>
116  <BR><BR>
117  <TABLE border=1>
118    <TR>
119      <TD>
120        <?php echo $event; ?>
121        at <?php echo $snttime; ?>
122      </TD>
123    </TR>
124    <TR>
125      <TD>
126        <?php echo $msg; ?>
127      </TD>
128    </TR>
129    <TR>
130      <TD>
131        <FORM>
132          <INPUT type="button" onClick="reply()" value="Reply">
133          <INPUT type="button" onClick="clearMsg()" value="Clear">
134        </FORM>
135      </TD>
136    </TR>
137  </TABLE>
138  </CENTER>
139 
140<?php
141
142}
143
144function rmsSendMessage()
145{
146  global $username, $password, $sock;
147  $id = $_POST["send_id"];
148  $msg = $_POST["message"];
149  $pp = $_POST["pp"];
150 
151  rmsLogin($username, $password);
152 
153  $cmd = "MESSAGE " . $id . "." . $pp . "\r\n";
154  sendData($cmd);
155 
156  $packet = socket_read($sock, 1024, PHP_NORMAL_READ);
157  if (!preg_match("/^302\s{1}.*/", $packet))
158  {
159    echo "<BR><B>Invalid response (" . $packet . ")</B><BR>\n";
160    return;
161  }
162 
163  $msgcontent = $msg . "\r\n.\r\n";
164  sendData($msgcontent);
165
166  header('Location: message.php');
167}
168
169//----------------------------------------
170// Here is where we start the HTML coding
171//----------------------------------------
172
173  $cmd = $_POST["cmd"];
174  $id = $_GET["id"];
175  $pp = $_GET["pp"];
176  $command = $_GET["command"];
177
178  if (!empty($cmd))
179  {
180    rmsHandleCommand($cmd);
181  }
182  else if (!empty($command))
183  {
184    rmsHandleCommand($command, $id, $pp);
185  }
186
187?>
Note: See TracBrowser for help on using the browser.