Ticket #1629: licqweb-history.patch
| File licqweb-history.patch, 16.1 kB (added by cuchac, 5 months ago) |
|---|
-
viewHistory.php
1 <? 2 /* 3 * licqweb. Copyright 2005, Philip Nelson 4 * 5 * This file is part of licqweb. 6 * 7 * licqweb is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 2 of the License, or 10 * (at your option) any later version. 11 * 12 * licqweb is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with licqweb; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 */ 21 require_once('config.php'); 22 require_once('rms.php'); 23 24 session_start(); 25 $uin = $_SESSION['uin']; 26 $password = $_SESSION['password']; 27 session_write_close(); 28 29 if (!rmsLogin("$uin\r\n", "$password\r\n")) { 30 header('Content-Type: text/xml'); 31 echo "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"; 32 echo "<response><method>loginFailed</method><result>Couldn't log in to rms plugin!</result></response>"; 33 exit; 34 } 35 36 $messagesXML=""; 37 38 $messages = rmsViewHistory($_GET['id'], $_GET['pp'], $_GET["lenght"], $_GET["offset"]); 39 foreach ($messages as $message) 40 $messagesXML .= "<message>" . xmlentities($message['msg']) . "</message><from>".$message['from']."</from><time>" . $message['time'] . "</time>"; 41 42 43 header('Content-Type: text/xml'); 44 echo "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"; 45 echo " 46 <response> 47 <method>viewHistory</method> 48 <result><id>" . $_GET['id'] . "</id><pp>" . $_GET['pp'] . "</pp><messages>$messagesXML</messages></result> 49 </response> 50 "; 51 ?> -
rms.php
Property changes on: viewHistory.php ___________________________________________________________________ Name: svn:executable + *
259 259 function xmlentities ($string) { 260 260 return str_replace (array('&', '"', "'", '<', '>'), array ('&' , '"', ''' , '<' , '>'), $string); 261 261 } 262 263 function rmsViewHistory($id, $pp, $lenght = 10, $offset = 0) { 264 global $sock; 265 $result = array(); 266 267 $cmd = "HISTORY " . $id . "." . $pp . " " . $lenght . " " . $offset . "\r\n"; 268 sendData($cmd); 269 270 $packet = socket_read($sock, 1024, PHP_NORMAL_READ); 271 if (substr($packet, 0, 3) >= 400) { 272 return false; 273 } 274 275 // kses input filtering 276 $allowed = array('b' => array(), 277 'i' => array(), 278 'a' => array('href' => 1, 'title' => 1), 279 'p' => array('align' => 1), 280 'br' => array(), 281 'font' => array('size' => 1, 'color' => 1, 'face' => 1) 282 ); 283 284 while(!preg_match("/^232 /", $packet)) { 285 286 $msg = ""; 287 $from = substr($packet, 16); 288 $packet = socket_read($sock, 1024, PHP_NORMAL_READ); 289 $snttime = substr($packet, 12); 290 291 $packet = socket_read($sock, 1024, PHP_NORMAL_READ); 292 $packet = socket_read($sock, 1024, PHP_NORMAL_READ); 293 294 while(!preg_match("/^223 /", $packet)){ 295 $msg .= (($msg!="")?"<br/>":"").$packet; 296 $packet = socket_read($sock, 1024, PHP_NORMAL_READ); 297 } 298 299 if (get_magic_quotes_gpc()) { 300 $msg = stripslashes($msg); 301 } 302 $result[] = array('msg' => kses($msg, $allowed), 'time' => trim($snttime), 'from' => trim($from)); 303 304 $packet = socket_read($sock, 1024, PHP_NORMAL_READ); 305 } 306 return $result; 307 } 308 262 309 ?> -
index.php
4 4 <title>licq</title> 5 5 <link rel="StyleSheet" type="text/css" href="licqweb.css" /> 6 6 <link rel="shortcut icon" href="images/favicon.ico"> 7 <script type="text/javascript" src="licqweb.js" /> 7 8 </head> 8 <body onload=" checkSession()">9 <body onload="init()"> 9 10 <div id="tooltip"></div> 10 <script type="text/javascript" src="licqweb.js" /> 11 11 12 <h1>licq<i><font color="#5555ff">web</font></i></h1> 12 13 <div id="login" class="loginwin"> 13 14 <div class="bar">licqweb login</div> … … 20 21 <div id="contactList" class="box" style="left:10px;top:150px;display:none;"> 21 22 <div class="bar" onmousedown="init_drag(event, 'contactList')" id="nick">licqweb</div> 22 23 <div id="contacts"></div> 23 <div id="ownerStatus"></div> 24 <div style="display:box;height:18px"> 25 <div id="ownerStatus"></div> 26 <div class="resizer" onmousedown="init_resize(event, 'contacts', 100, 100)"> 27 <img class="resizerImage" src="images/resizer.png" /> 28 </div> 29 </div> 24 30 </div> 25 31 <div id="statusMenu"></div> 26 32 <div id="windows"></div> -
licqweb.js
19 19 */ 20 20 21 21 //option vars 22 var showOffline = false;22 var showOffline = true; 23 23 var maxLogLines = 20; 24 var showHistory = true; 24 25 25 26 var xmlhttp = new XMLHttpRequest(); //for serverpush connection 26 27 xmlhttp.multipart = true; … … 116 117 var messages = response.getElementsByTagName('message'); 117 118 var times = response.getElementsByTagName('time'); 118 119 for (var i = 0; i < messages.length; ++i) { 119 txtdiv.innerHTML += '( ' + times[i].firstChild.data + ') ' + contacts[pp][id].nick + ': ' + messages[i].firstChild.data + "<br/>";120 txtdiv.innerHTML += '(<span class="msgDate">' + times[i].firstChild.data + '</span>) <span class="msgNick">' + contacts[pp][id].nick + '</span>: <span class="msgText">' + messages[i].firstChild.data + "</span><br/>"; 120 121 } 121 122 txtdiv.scrollTop = txtdiv.scrollHeight; 122 123 } … … 168 169 } else { 169 170 pp = contact.pp.toLowerCase(); 170 171 } 171 var imgsrc = "images/" + pp + "." + contact.status.toLowerCase() + ".png";172 var imgsrc = "images/" + pp + "." + contact.status.toLowerCase().replace(" ","") + ".png"; 172 173 if (parseInt(contact.nummsgs) > 0) { 173 174 uclass = "newmessage"; 174 175 imgsrc = "images/msg.png"; … … 192 193 contacts[pp][id].status = status; 193 194 contacts[pp][id].nummsgs = messages; 194 195 contacts[pp][id].nick = nick; 196 contacts[pp][id].historyShowed = false; 195 197 } else { 196 198 contacts[pp][id] = new Contact(id, pp, nick, status, messages); 197 199 var newcontact = document.createElement('div'); … … 205 207 206 208 function getWindowHtml(id, pp, nick) { 207 209 var key = id + '-' + pp; 208 return "<div class=\"window\" style=\"left:300px;top:150px\" id=\"" + key + "-w\">" +210 return "<div onClick=\"set_focus(event, '" + key + "')\" class=\"window\" style=\"left:300px;top:150px\" id=\"" + key + "-w\">" + 209 211 "<div onmousedown=\"init_drag(event, '" + key + "-w')\" class=\"bar\">" + 210 212 "<div class=\"wintitle\">" + nick + " (" + pp + ")</div>" + 211 213 "<div onclick=\"showContactWindow('" + id + "', '" + pp + "')\" class=\"close\">[close]</div>" + 212 214 "</div>" + 213 215 "<div class=\"convo\" id=\"" + key + "-txt\"></div>" + 214 "<div class=\"msginput\"><textarea id=\"" + key + "-input\" onKeyPress=\"textarea_keypress(event, '" + id + "', '" + pp + "')\" ></textarea><br>" +216 "<div class=\"msginput\"><textarea id=\"" + key + "-input\" onKeyPress=\"textarea_keypress(event, '" + id + "', '" + pp + "')\" ></textarea><br>" + 215 217 "<input type=\"submit\" class=\"button\" value=\"Send\" onclick=\"sendMessage('" + id + "', '" + pp + "'); return false\" />" + 218 "<div class=\"resizer\" onmousedown=\"init_resize(event, '" + key + "-txt', 150, 50)\"><img class=\"resizerImage\" src=\"images/resizerMsg.png\" /></div>" + 216 219 "</div>" + 217 220 "</div>"; 218 221 } … … 250 253 var message = ackMessages[uid]; 251 254 var txt = document.getElementById(message.id + '-' + message.pp + '-txt'); 252 255 if (res == "done.") { 253 txt.innerHTML += "( " + ts + ") " + nick + ": " + message.message.replace(/[\r\n]+/g, "<br/>") + "<br/>";256 txt.innerHTML += "(<span class=\"msgDate\">" + ts + "</span>) <span class=\"msgNick\">" + nick + "</span>: <span class=\"msgText\">" + message.message.replace(/[\r\n]+/g, "<br/>") + "</span><br/>"; 254 257 } else { 255 258 txt.innerHTML += "--- Message failed!<br/>"; 256 259 } … … 264 267 if (contacts[pp][id].nummsgs > 0) { 265 268 requestViewEvent(id, pp); 266 269 } 270 if(showHistory==true && contacts[pp][id].historyShowed != true){ 271 requestViewHistory(id, pp); 272 contacts[pp][id].historyShowed = true; 273 } 274 267 275 win = document.getElementById(id + '-' + pp + '-w'); 268 276 if (win.style.display == 'block') { 269 277 win.style.display = 'none'; … … 272 280 } 273 281 var txtdiv = document.getElementById(id + '-' + pp + '-txt'); 274 282 txtdiv.scrollTop = txtdiv.scrollHeight; 275 //win.style.zIndex = ++dragwin.win.style.zIndex;283 win.style.zIndex = ++dragwin.zIndex; 276 284 //dragwin.win = win; 277 285 } 278 286 … … 315 323 document.getElementById(key + '-i').src = "images/msg.png"; 316 324 } else { 317 325 document.getElementById(key + '-s').className = contacts[pp][id].status; 318 document.getElementById(key + '-i').src = "images/" + pp.toLowerCase() + "." + contacts[pp][id].status.toLowerCase() + '.png';326 document.getElementById(key + '-i').src = "images/" + pp.toLowerCase() + "." + contacts[pp][id].status.toLowerCase().replace(" ","") + '.png'; 319 327 } 320 328 } else { 321 329 } … … 340 348 function _updateOwners() { 341 349 var statushtml = ""; 342 350 for (var pp in owners) { 343 statushtml += "<img onclick=\"showSelectStatus(event, '" + owners[pp].id + "', '" + pp + "'); return false\" src=\"images/" + pp.toLowerCase() + "." + owners[pp].status.toLowerCase() + ".png\"/> ";351 statushtml += "<img onclick=\"showSelectStatus(event, '" + owners[pp].id + "', '" + pp + "'); return false\" src=\"images/" + pp.toLowerCase() + "." + owners[pp].status.toLowerCase().replace(" ","") + ".png\"/> "; 344 352 } 345 353 document.getElementById('ownerStatus').innerHTML = statushtml; 346 354 } … … 352 360 statuss["MSN"] = new Array('Online', 'Away', 'Occupied'); 353 361 var statushtml = ""; 354 362 for (var i = 0; i < statuss[pp].length; ++i) { 355 statushtml += "<div onclick=\"changeStatus('" + pp + "', '" + statuss[pp][i] + "')\"><img src=\"images/" + pp.toLowerCase() + "." + statuss[pp][i].toLowerCase() + ".png\">" + statuss[pp][i] + "</div>";363 statushtml += "<div onclick=\"changeStatus('" + pp + "', '" + statuss[pp][i] + "')\"><img src=\"images/" + pp.toLowerCase() + "." + statuss[pp][i].toLowerCase().replace(" ","") + ".png\">" + statuss[pp][i] + "</div>"; 356 364 } 357 365 statusMenu.innerHTML = statushtml; 358 366 statusMenu.style.left = e.pageX; … … 428 436 429 437 /* Tool tip stuff */ 430 438 var enabletip = false; 431 var tooltip = document.getElementById('tooltip');439 var tooltip = null; 432 440 433 441 function showToolTip(pp, id){ 434 442 tooltip.innerHTML = contacts[pp][id].id + ' (' + contacts[pp][id].pp + ')<br>' + contacts[pp][id].status + '<br>Messages: ' + contacts[pp][id].nummsgs; … … 460 468 dragwin.zIndex = 0; 461 469 462 470 function init_drag(event, id) { 463 var el;464 var x, y;465 471 466 dragwin.win = document.getElementById(id);472 dragwin.win = document.getElementById(id); 467 473 468 474 dragwin.startX = event.clientX + window.scrollX; 469 475 dragwin.startY = event.clientY + window.scrollY; … … 494 500 document.removeEventListener("mousemove", start_drag, true); 495 501 document.removeEventListener("mouseup", stop_drag, true); 496 502 } 503 504 function set_focus(event, key){ 505 win = document.getElementById(key + "-w"); 506 win.style.zIndex = ++dragwin.zIndex; 507 event.preventDefault(); 508 509 /*input = document.getElementById(key + "-input"); 510 input.focus();*/ 511 512 //stop_propagate(event); 513 } 514 515 function stop_propagate(event){ 516 if (!event) var event = window.event; 517 event.cancelBubble = true; 518 if (event.stopPropagation) event.stopPropagation(); 519 } 520 521 /* Window resizing stuff */ 522 var resizewin = new Object(); 523 524 function init_resize(event, id, minW, minH) { 525 resizewin.win = document.getElementById(id); 526 resizewin.minW = minW; 527 resizewin.minH = minH; 528 529 resizewin.startX = event.clientX + window.scrollX; 530 resizewin.startY = event.clientY + window.scrollY; 531 resizewin.startWidth = parseInt(resizewin.win.style.width, 10); 532 resizewin.startHeight = parseInt(resizewin.win.style.height, 10); 533 534 if (isNaN(resizewin.startWidth)) resizewin.startWidth = resizewin.win.offsetWidth; 535 if (isNaN(resizewin.startHeight)) resizewin.startHeight = resizewin.win.offsetHeight; 536 537 //resizewin.win.style.zIndex = ++resizewin.zIndex; 538 539 document.addEventListener("mousemove", do_resize, true); 540 document.addEventListener("mouseup", stop_resize, true); 541 event.preventDefault(); 542 } 543 544 function do_resize(event) { 545 var x, y; 546 x = event.clientX + window.scrollX; 547 y = event.clientY + window.scrollY; 548 549 550 if(resizewin.minW < (resizewin.startWidth + x - resizewin.startX)){ 551 resizewin.win.style.width = (resizewin.startWidth + x - resizewin.startX) + "px"; 552 553 /*Sorry for this hack. Mozilla does not shrink parent DIV according to the content (until redraw).*/ 554 resizewin.win.parentNode.style.width = (resizewin.startWidth + x - resizewin.startX) + "px"; 555 } 556 if(resizewin.minH < (resizewin.startHeight + y - resizewin.startY)){ 557 resizewin.win.style.height = (resizewin.startHeight + y - resizewin.startY) + "px"; 558 } 559 560 event.preventDefault(); 561 } 562 563 function stop_resize(event) { 564 document.removeEventListener("mousemove", do_resize, true); 565 document.removeEventListener("mouseup", stop_resize, true); 566 } 567 568 function init(){ 569 checkSession(); 570 571 tooltip = document.getElementById('tooltip'); //Sometimes tooltip variable was null 572 } 573 574 function requestViewHistory(id, pp) { 575 xmlhttp2 = new XMLHttpRequest(); 576 xmlhttp2.onreadystatechange = acceptResponse2; 577 xmlhttp2.open("GET", baseurl + "/viewHistory.php?id=" + id + "&pp=" + pp + "&lenght=10&offset=0", true); 578 xmlhttp2.send(null); 579 } 580 581 function viewHistory(response) { 582 var id = response.getElementsByTagName('id')[0].firstChild.data; 583 var pp = response.getElementsByTagName('pp')[0].firstChild.data; 584 var txtdiv = document.getElementById(id + '-' + pp + '-txt'); 585 var messages = response.getElementsByTagName('message'); 586 var times = response.getElementsByTagName('time'); 587 var froms = response.getElementsByTagName('from'); 588 for (var i = messages.length-1; i >=0 ; --i) { 589 txtdiv.innerHTML += '(<span class="msgDate">' + times[i].firstChild.data + '</span>) <span class="msgNick">' + froms[i].firstChild.data + '</span>: <span class="msgText">' + messages[i].firstChild.data + "</span><br/>"; 590 } 591 txtdiv.scrollTop = txtdiv.scrollHeight; 592 } 593 No newline at end of file -
licqweb.css
Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: images/resizer.png ___________________________________________________________________ Name: svn:executable + * Name: svn:mime-type + application/octet-stream Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: images/resizerMsg.png ___________________________________________________________________ Name: svn:executable + * Name: svn:mime-type + application/octet-stream
108 108 left: 300px; 109 109 } 110 110 111 #ownerStatus { 112 left:0px; 113 width:20px; 114 position:absolute; 115 } 116 117 .resizer { 118 right:0px; 119 bottom:0px; 120 width:18px; 121 height:18px; 122 position:absolute; 123 } 124 125 .resizerImage { 126 bottom:0px; 127 position:absolute; 128 right:0px; 129 } 130 111 131 .box { 112 132 background-color: #eee; 113 133 border: 1px solid #000000; … … 128 148 max-width: 350px; 129 149 overflow: hidden; 130 150 float: left; 151 cursor: Default; 131 152 } 132 153 133 154 .close { 134 155 background-color: #333355; 135 156 float: right; 136 cursor: pointer;157 cursor: pointer; 137 158 } 138 159 139 160 .content { … … 218 239 border: 1px solid #8ca8cf; 219 240 width: 100px; 220 241 } 242 243 .msgText { 244 color: #000000; 245 } 246 247 .msgDate { 248 color: #FF0000; 249 } 250 251 .msgNick { 252 color: #0000FF; 253 font-weight: bold; 254 } 255 No newline at end of file
