PageRenderTime 53ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/kloxo/httpdocs/live/main.php

https://bitbucket.org/Nemcio/kloxo-mr
PHP | 576 lines | 469 code | 60 blank | 47 comment | 82 complexity | 55cba5e4b753c76679bef8cc4c389fcd MD5 | raw file
  1. <?php
  2. if (preg_match("/Mozilla\/\d.+Compatible; MSIE/i", $_SERVER['HTTP_USER_AGENT']) && !preg_match("/Opera/i", $_SERVER['HTTP_USER_AGENT'])) {
  3. header('Expires: 0');
  4. header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  5. header('Pragma: public');
  6. } else {
  7. header('Expires: 0');
  8. header('Pragma: no-cache');
  9. }
  10. include("common.php");
  11. include("ircfunc.php");
  12. $gl_never_responded = 1;
  13. $gl_client_started = 0;
  14. $livetrfp = null;
  15. if ($g_login) {
  16. $livetrfp = lfopen("__path_program_etc/livetranscript.txt", "a");
  17. }
  18. /*
  19. $channel = $_GET['channel'];
  20. echo "$channel <br>";
  21. if (!$channel) {
  22. $channel = $channels[0];
  23. }
  24. */
  25. if ($redirect)
  26. $channel = "{$chanbase}-command";
  27. else
  28. $channel = $chanbase;
  29. $licid = $_GET['licid'];
  30. $user = $_GET['username'];
  31. $id = $_GET['id'];
  32. $base_nick = $_GET['username'];
  33. //$nick = "hello";
  34. //$serv_addr = "127.0.0.1";
  35. //$serv_port = 6667;
  36. echo <<<EOF
  37. <html>
  38. <head>
  39. <title>PHP IRC Chat output page</title>
  40. $css
  41. </head>
  42. <body bgcolor="$chan_bg" text="$chan_fg">
  43. EOF;
  44. flush();
  45. $smily_code = array("/:-?\)/",
  46. "/;b/",
  47. "/:-?P/i",
  48. "/;-?\)/i",
  49. "/:-?\(/",
  50. "/:-?D/i",
  51. "/:-?\|/i",
  52. "/\(y\)/i",
  53. "/:-?S/i");
  54. $smily_repl = array("<img src='pics/sm-smile.gif' width=15 height=15>",
  55. "<img src='pics/sm-bsmile.gif' width=15 height=15>",
  56. "<img src='pics/sm-psmile.gif' width=15 height=15>",
  57. "<img src='pics/sm-wink.gif' width=15 height=15>",
  58. "<img src='pics/sm-sad1.gif' width=15 height=15>",
  59. "<img src='pics/sm-dsmile.gif' width=15 height=15>",
  60. "<img src='pics/sm-amazed.gif' width=15 height=15>",
  61. "<img src='pics/sm-thumbsup.gif' width=15 height=15>",
  62. "<img src='pics/sm-sad2.gif' width=15 height=15>");
  63. @set_time_limit(3600); // ten minutes execution time, when user says or does something, this is reset with 10 min.
  64. /* ** ** set_time_limit() doesn't seem to have any effect whatsoever... ** ** */
  65. register_shutdown_function("einde");
  66. echo <<<EOF
  67. <script language="JavaScript"><!--; parent.scrl(1); //--></script>
  68. EOF;
  69. $socket = irc_open($serv_addr, $serv_port, $errno, $errstr);
  70. if ($socket < 0) { echo "failed... $errno: $errstr"; return; }
  71. else { echo "Connecting to Lxlabs Live. Please Wait....<br> "; }
  72. $max_per_personnel = $_REQUEST['max_per_personnel'];
  73. $max_number_personnel = $_REQUEST['max_number_personnel'];
  74. $per_personnel = 1;
  75. $number_personnel = 1;
  76. if ($redirect) {
  77. $nick = "{$base_nick}_{$number_personnel}-{$per_personnel}";
  78. } else {
  79. $nick = $base_nick;
  80. }
  81. echo "<br>";
  82. echo "<script language='JavaScript'>\n<!--;\n parent.scrl(1);\n //-->\n</script>";
  83. flush(); //output this;
  84. $out = "";
  85. $login_flag = 0;
  86. $loggedin = false;
  87. $nickcount = 0;
  88. $inchan = false;
  89. $nicktry = 0;
  90. $signontime = time();
  91. function einde() {
  92. global $link, $user, $id;
  93. global $socket,$signontime;
  94. if ($socket) {
  95. irc_write($socket, "QUIT :lxlabs \r\n");
  96. irc_close($socket);
  97. }
  98. sqlite_query($link, "DELETE FROM phpchat WHERE username = '$user' AND id = '$id'");
  99. $signofftime = time();
  100. $onlinetime = $signofftime-$signontime;
  101. $d1 = (floor($onlinetime/3600) < 10) ? "0".floor($onlinetime/3600) : floor($onlinetime/3600);
  102. $rest = $onlinetime%3600;
  103. $d1 .= (floor($rest/60) < 10) ? ":0".floor($rest/60) : ":".floor($rest/60);;
  104. $rest = $rest%60;
  105. $d1 .= ($rest < 10) ? ":0".$rest : ":".$rest;
  106. echo "Signed on at: " . date("H:i:s d-m-Y", $signontime) . ", Signed off at: " . date("H:i:s d-m-Y", $signofftime) . "<br>";
  107. echo "Online time: $d1 ($onlinetime seconds)";
  108. }
  109. function retn_color($fg, $bg) {
  110. global $ircColors;
  111. if ($bg != -1) {
  112. return "<font style='color: ".$ircColors[$fg]."; background-color: ".$ircColors[$bg].";'>";
  113. } else {
  114. return "<font style='color: ".$ircColors[$fg].";'>";
  115. }
  116. }
  117. function smile_repl($string) {
  118. return $string;
  119. global $smily_code, $smily_repl, $ircColors, $page_bg, $page_fg;
  120. $string = preg_replace("/\003(\d+),(\d+)/e", "retn_color($1,$2)", $string);
  121. $string = preg_replace("/\003(\d+)/e", "retn_color($1, -1)", $string);
  122. $string = preg_replace("/\003/", "<font style='color: $page_fg; background-color: $page_bg;'>", $string);
  123. for ($a = 0; $a < substr_count($string, "<font"); $a++) {
  124. $string .= "</font>";
  125. }
  126. return preg_replace($smily_code, $smily_repl, $string);
  127. }
  128. $link = lsqlite_open($g_db_file);
  129. $fully_logged_in = 0;
  130. $timetoping = 10; // every tenth loop ask a ping reply
  131. $gl_timer = 0;
  132. $gl_nonavailable_printed = false;
  133. while($socket > 0) {
  134. $read = null;
  135. $read[0] = $socket;
  136. $writea = null;
  137. $excpta = null;
  138. /*
  139. foreach((array) $client as $c) {
  140. $read[] = $c['sock'];
  141. }
  142. */
  143. //dprint("Before: ");
  144. //dprintr($read);
  145. // Set up a blocking call to stream_select()
  146. $ready = stream_select($read, $writea, $excpta, 1);
  147. //dprint("After: $ready");
  148. //dprintr($read);
  149. // This means that sock - which is our main master socket - is ready for reading, which in turn signifies that a NEW connection has arrived. The other members of the read array
  150. $full = null;
  151. if ($ready) {
  152. if (in_array($socket, $read)) {
  153. $full = irc_read($socket, 4096);
  154. }
  155. }
  156. $full = rtrim($full);
  157. $timeout = 30;
  158. if ($gl_never_responded && $gl_client_started) {
  159. $gl_timer++;
  160. if ($gl_timer == $timeout) {
  161. irc_write($socket, "PRIVMSG $channel :lxclmsg2 No response for 50 sec\r\n");
  162. //print($gl_timer);
  163. }
  164. if ($gl_timer % (2 * $timeout) == 0) {
  165. //print($gl_timer);
  166. irc_write($socket, "PRIVMSG $channel :lxclmsg3 No response for $gl_timer/20 sec\r\n");
  167. }
  168. if ($gl_timer % (6 * $timeout) == 0) {
  169. //print($gl_timer);
  170. irc_write($socket, "PRIVMSG $channel :lxclmsg3 No response for $gl_timer/20 sec\r\n");
  171. if (!$gl_nonavailable_printed) {
  172. print("It appears there's no one in the channel. Please leave your message here, or please contact lxhelp@lxlabs.com. We apologize for the inconvenience <br> \n");
  173. $gl_nonavailable_printed = true;
  174. } else {
  175. print("...");
  176. }
  177. }
  178. }
  179. $list = explode("\n", $full);
  180. foreach($list as $out) {
  181. if (strlen($out) > 1) {
  182. //print($out . "<br> ");
  183. if (preg_match("/PING (.+)/", $out, $matches)) {
  184. irc_write($socket, "PONG $matches[1]\r\n");
  185. //echo "ping-pong<br>";
  186. } elseif (preg_match("/:([^\s]+) NOTICE ([^\s]+) :(.+)/", $out, $matches)) {
  187. if (preg_match("/$nick/i", $matches[3])) {
  188. $matches[1] = "<b>$matches[1]</b>";
  189. }
  190. $src = $matches[1];
  191. $text = smile_repl(htmlspecialchars($matches[3]));
  192. if (preg_match("/([^!]+)!.+/", $src, $matches)) {
  193. $src = $matches[1];
  194. }
  195. //echo "<font color='$ircColors[5]'>-$src- $text</font><br>";
  196. } elseif (preg_match("/:[^ ]* (\d+) ([^\s]+) (.+)/i", $out, $matches)) {
  197. if ($matches[1] == "006" || $matches[1] == "001") {
  198. if ($redirect) {
  199. $cmdchan = "{$chanbase}_{$number_personnel}-command" ;
  200. $realchan = $chanbase . "_" . $number_personnel . "-" . $per_personnel ;
  201. irc_write($socket, "JOIN #$cmdchan\r\n");
  202. irc_write($socket, "PRIVMSG #$cmdchan :lxcommand channel #$realchan\r\n");
  203. irc_write($socket, "PART #$cmdchan\r\n");
  204. //print($realchan);
  205. irc_write($socket, "JOIN #$realchan\r\n");
  206. } else {
  207. irc_write($socket, "JOIN #$chanbase\r\n");
  208. }
  209. //print("gotcha<br> \n");
  210. }
  211. if ($matches[1] == "PONG") {
  212. }
  213. if ($matches[1] == "376") {
  214. /*end of motd*/ $loggedin = true;
  215. }
  216. elseif($matches[1] == "433") {
  217. //print($out);
  218. if ($redirect) {
  219. if ($number_personnel == $max_number_personnel) {
  220. $number_personnel = 1;
  221. if ($per_personnel == $max_per_personnel) {
  222. $per_personnel = 1;
  223. $number_personnel = 1;
  224. print("All Personnel currently busy. Will try after 30 seconds.... <br> \n");
  225. flush();
  226. sleep(30);
  227. } else {
  228. $per_personnel++;
  229. }
  230. } else {
  231. $number_personnel++;
  232. }
  233. $nick = "{$base_nick}_{$number_personnel}-{$per_personnel}";
  234. } else {
  235. $nickcount++;
  236. $nick = $base_nick . "$nickcount";
  237. }
  238. //echo "<font color='$ircColors[7]'>Nick already in use, changing to: $nick</font><br>\n";
  239. irc_write($socket, "NICK :$nick\r\n");
  240. }
  241. elseif ($matches[1] == "422") {
  242. /* no motd, but logged in */ $loggedin = true;
  243. }
  244. elseif ($matches[1] == "353") { //names
  245. if (preg_match("/= (\#[^\s]+) :(.+)/", $matches[3], $match)) {
  246. $namen = $match[2];
  247. //$namen = str_replace("@", "", $match[2]);
  248. //$namen = str_replace("%", "", $namen);
  249. //$namen = str_replace("+", "", $namen);
  250. $names = preg_split("/\s+/", $namen);
  251. natcasesort($names);
  252. if (!isset($nicklist["$match[1]"])) {
  253. $nicklist["$match[1]"] = "";
  254. }
  255. foreach($names as $name) {
  256. //echo "$name, ";
  257. $name = str_replace("@", "", $name);
  258. if ($redirect) {
  259. if ($name == $nick) {
  260. $name = "Myself";
  261. }
  262. }
  263. $nicklist["$match[1]"] .= "$name:";
  264. }
  265. }
  266. } elseif ($matches[1] == "366") { // endofnames
  267. if (preg_match("/(#[^\s]+)/", $matches[3], $match)) {
  268. if (isset($nicklist[$match[1]])) {
  269. $namelist = $nicklist[$match[1]];
  270. echo "\n<script language='JavaScript'>\n<!--;\n\nparent.nixreload(':$namelist');\n\n//-->\n</script>\n\n";
  271. }
  272. $nicklist[$match[1]] = "";
  273. $_tnlist = explode(":", $namelist);
  274. echo "</font>";
  275. if (!$fully_logged_in) {
  276. if ($licid !== 'nobody') {
  277. echo "Hello $licid, ";
  278. }
  279. echo "please type your message to start the conference <br> \n";
  280. $fully_logged_in = 1;
  281. }
  282. flush();
  283. }
  284. } elseif ($matches[1] == "332") {
  285. if (preg_match("/(#[^\s]+) :(.+)/", $matches[3], $match)) {
  286. //echo "<font color='$ircColors[7]'>--- Topic for $match[1] is: $match[2]</font><br>";
  287. }
  288. } elseif (($matches[1] == "372" || $matches[1] == "375") && $hide_motd) {
  289. // do nothing, the motd doesn't have to be displayed...
  290. } elseif ($matches[1] == "317") {
  291. // whois idle time and signon time
  292. if (preg_match("/([^\s]+)\s+(\d+)\s+(\d+)\s+:.+/", $matches[3], $match)) {
  293. $d1 = (floor($match[2]/3600) < 10) ? "0".floor($match[2]/3600) : floor($match[2]/3600);
  294. $rest = $match[2]%3600;
  295. $d1 .= (floor($rest/60) < 10) ? ":0".floor($rest/60) : ":".floor($rest/60);;
  296. $rest = $rest%60;
  297. $d1 .= ($rest < 10) ? ":0".$rest : ":".$rest;
  298. $d2 = date("Y-m-d H:i:s", $match[3]);
  299. //echo "<font color='$ircColors[12]'>-$serv_name- $match[1] idle: $d1, signon: $d2</font><br>";
  300. }
  301. } else {
  302. //echo "<font color='$ircColors[12]'>-$serv_name- $matches[3]</font><br>";
  303. }
  304. } elseif (preg_match("/Closing Link(.*)/i", $out, $matches)) {
  305. //echo "<font color='$ircColors[4]'>Disconnected$matches[1]...</font><br>\n";
  306. irc_close($socket);
  307. sleep(60);
  308. $socket = irc_open($serv_addr, $serv_port, $errno, $errstr);
  309. if ($socket < 0) { echo "failed... $errno: $errstr"; return; }
  310. else { echo "Connecting Again....<br> "; }
  311. $login_flag = 0;
  312. $loggedin = false;
  313. $inchan = false;
  314. $nicktry = 0;
  315. flush();
  316. continue;
  317. } elseif (preg_match("/:([^!]+)![^\s]+ PRIVMSG ([^\s]+) :(.+)/", $out, $matches)) {
  318. if (preg_match("/$nick/i", $matches[3])) { $matches[1] = "<b>$matches[1]</b>"; }
  319. $matches[3] = smile_repl(htmlspecialchars($matches[3]));
  320. if (preg_match("/\001(\w+)(.*)/i", $matches[3], $match)) { // CTCP's
  321. if ($match[1] == "VERSION") {
  322. irc_write($socket, "NOTICE $matches[1] :\001VERSION \r\n");
  323. } elseif ($match[1] == "PING") {
  324. irc_write($socket, "NOTICE $matches[1] :\001PING$match[2]\r\n");
  325. } elseif ($match[1] == "CLIENTINFO") {
  326. irc_write($socket, "NOTICE $matches[1] :\001CLIENTINFO ip: {$_SERVER['REMOTE_ADDR']} ; {$HTTP_SERVER_VARS['REMOTE_HOST']}\001\r\n");
  327. irc_write($socket, "NOTICE $matches[1] :\001CLIENTINFO useragent: {$_SERVER['HTTP_USER_AGENT']}\001\r\n");
  328. } elseif ($match[1] == "ACTION") {
  329. $matches[3] = substr($matches[3],7);
  330. echo "<font color='$ircColors[6]'>* $matches[1] $matches[3]</font><br>";
  331. } elseif ($match[1] == "DCC") {
  332. preg_match("/^[\W]*(\w+)\s+([^\s]+)\s+\d+\s+\d+[\s\d]*/", "$match[2]", $blaat);
  333. //echo "<font color='$ircColors[5]'>-- Ignored DCC from $matches[1] ($blaat[1] $blaat[2])</font><br>";
  334. //irc_write($socket, "NOTICE $matches[1] :Sorry, but my client (PHPWebchat) doesn't support DCC transfers.\r\n");
  335. } else {
  336. echo "CTCP: $matches[3]<br>";
  337. }
  338. } elseif (!preg_match("/^#.+/", $matches[2])) {
  339. echo "&lt;<font color='$ircColors[7]'>$matches[1]-&gt;$nick</font>&gt; $matches[3]<br>";
  340. } else {
  341. $msg = preg_replace("/\s+/", " ", $matches[3]);
  342. $msglist = explode(" ", $msg);
  343. if ($msglist[0] == "lxbuzz")
  344. continue;
  345. $msg = "";
  346. if (isset($msglist[0]) && $msglist[0] == "lxquit") {
  347. einde();
  348. exit(0);
  349. }
  350. foreach($msglist as $m) {
  351. $msg .= " " . $m;
  352. }
  353. if ($matches[1] == $nick) {
  354. print("<font color=blue>&lt;$matches[1]&gt; </font> ");
  355. } else {
  356. print("<font color=black>&lt;$matches[1]&gt; </font> ");
  357. }
  358. print(" $msg<br>");
  359. if ($livetrfp) {
  360. fwrite($livetrfp, "$matches[1]: $msg\n");
  361. }
  362. $gl_never_responded = 0;
  363. }
  364. } elseif (preg_match("/:([^!]+)![^\s]+ NICK :(.+)/", $out, $matches)) {
  365. if ($nick == $matches[1]) {
  366. echo "<font color='$ircColors[3]'>-=- You are now known as $matches[2]</font><br>";
  367. } else {
  368. echo "<font color='$ircColors[3]'>-=- $matches[1] is now known as $matches[2]</font><br>";
  369. }
  370. irc_write($socket, "NAMES $matches[2]\r\n");
  371. } elseif (preg_match("/:([^!]+)![^\s]+ JOIN :(.+)/", $out, $matches)) {
  372. //echo "<font color='$ircColors[3]'>--&gt; $matches[1] has joined the channel</font><br>";
  373. $channel = $matches[2];
  374. $res = sqlite_query($link, "delete from channel where user = '$user' and id = '$id';");
  375. $res = sqlite_query($link, "insert into channel (user, id, channel) values ('$user', '$id', '$channel');");
  376. $inchan = true;
  377. /*
  378. if ($matches[1] != $nick) {
  379. irc_write($socket, "NAMES $matches[2]\r\n");
  380. }
  381. */
  382. irc_write($socket, "NAMES $matches[2]\r\n");
  383. } elseif (preg_match("/:([^!]+)![^\s]+ PART (.+)/", $out, $matches)) {
  384. if (preg_match("/(#[^\s]+) :(.+)/", $matches[2], $match)) {
  385. //echo "<font color='$ircColors[3]'>&lt;-- $matches[1] has left $match[1] ($match[2])</font><br>";
  386. } else {
  387. //echo "<font color='$ircColors[3]'>&lt;-- $matches[1] has left $matches[2]</font><br>";
  388. }
  389. irc_write($socket, "NAMES $matches[2]\r\n");
  390. } elseif (preg_match("/:([^!]+)![^\s]+ QUIT :(.*)/", $out, $matches)) {
  391. //echo "<font color='$ircColors[3]'>&lt;-- $matches[1] has left</font><br>";
  392. irc_write($socket, "NAMES #$channel\r\n");
  393. } elseif (preg_match("/:([^!]+)![^\s]+ TOPIC (#[^\s]+) :(.*)/", $out, $matches)) {
  394. //echo "<font color='$ircColors[7]'>--- $matches[1] changed the topic for $matches[2] to: $matches[3]</font><br>";
  395. } elseif (preg_match("/:([^!]+)![^\s]+ MODE (#[^\s]+) ([^\s]+) (.+)/", $out, $matches)) {
  396. //echo "<font color='$ircColors[7]'>--- $matches[1] sets mode $matches[3] on $matches[4]</font><br>";
  397. irc_write($socket, "NAMES $matches[2]\r\n");
  398. } elseif (preg_match("/:([^\s]+) MODE ([^\s]+) :(.+)/", $out, $matches)) {
  399. //echo "<font color='$ircColors[7]'>--- $matches[1] sets mode $matches[3] on $matches[2]</font><br>";
  400. } else {
  401. //echo "$out<br>";
  402. }
  403. echo "\n";
  404. }
  405. }
  406. /**********************************************************************************************/
  407. $result = sqlite_query("SELECT * FROM phpchat WHERE username = '$user' AND id = '$id' ORDER BY tijd", $link);
  408. $a = 0;
  409. while ($rij = sqlite_fetch_array($result, SQLITE_ASSOC)) {
  410. $a++;
  411. $var = "DELETE FROM phpchat WHERE username = '$user' AND id = '$id' AND tijd = '{$rij['tijd']}'";
  412. sqlite_query($link, $var);
  413. if (preg_match("/(PRIVMSG) ([^\s]+) :(.+)/i", $rij['commando'], $match) || preg_match("/(NOTICE) ([^\s]+) :(.+)/i", $rij['commando'], $match)) {
  414. $match[3] = smile_repl($match[3]);
  415. if ($match[1] == "PRIVMSG") {
  416. if (preg_match("/\001ACTION ([^\001]+)\001/i", $match[3], $mat)) {
  417. echo "<font color='$ircColors[6]'>* $nick $mat[1]</font><br>";
  418. } elseif (preg_match("/\001(.+)\001/", $match[3], $mat)) { // CTCPs
  419. echo "<font color='$ircColors[5]'>CTCP $match[2] $mat[1]</font><br>";
  420. } elseif (preg_match("/^#.+/", $match[2])) { // The main client conversation
  421. if ($redirect) {
  422. echo "<font color=blue>&lt;Myself&gt; $match[3] </font> <br>";
  423. if ($livetrfp) {
  424. fwrite($livetrfp, "Myself: $match[3]\n");
  425. }
  426. } else {
  427. echo "<font color=blue>&lt;$nick&gt; $match[3] </font> <br>";
  428. }
  429. if (!$gl_client_started) {
  430. $gl_client_started = 1;
  431. irc_write($socket, "PRIVMSG $channel :lxclmsg1 Client $licid has started talking \r\n");
  432. print("Connecting to the chat personnel... Please wait <br> \n");
  433. }
  434. } else {
  435. echo "&lt;<font color='$ircColors[7]'>$nick-&gt;$match[2]</font>&gt; $match[3]<br>";
  436. }
  437. } elseif ($match[1] == "NOTICE") {
  438. echo "<font color='$ircColors[5]'>&gt;$match[2]&lt; $match[3]</font><br>";
  439. } else {
  440. echo "<font color=blue>&lt;Myself&gt; $match[2] </font> <br>";
  441. }
  442. }
  443. if (preg_match("/^NICK (.+)/i", $rij['commando'], $match)) {
  444. $nick = $match[1];
  445. irc_write($socket, "NAMES $channel\r\n");
  446. flush();
  447. }
  448. irc_write($socket, "{$rij['commando']}\r\n");
  449. if (preg_match("/^QUIT.*/", $rij['commando'])) {
  450. echo "<font color='$ircColors[4]'>Disconnected...</font><br>";
  451. break 2;
  452. break 2;
  453. }
  454. echo "\n";
  455. }
  456. if ($a > 0) { @set_time_limit(3600); /* ten minutes extra to say sth */ }
  457. /**********************************************************************************************/
  458. if ($login_flag == 0) {
  459. $name = $_SERVER['REMOTE_ADDR'];
  460. irc_write($socket, "USER phpchat {$_SERVER['REMOTE_ADDR']} $name :$name \r\nNICK :".$nick."\r\n");
  461. $login_flag = 1;
  462. }
  463. if (connection_aborted()) {
  464. echo "<font color='$ircColors[4]'>Disconnected...</font><br>";
  465. break 2;
  466. }
  467. echo "<!-- -->"; // keep connection alive
  468. $timetoping--;
  469. if ($timetoping < 0) {
  470. $timetoping = 10;
  471. irc_write($socket, "PING LAG".time() . "\r\n");
  472. }
  473. flush_server_buffer();
  474. flush(); //output all...
  475. // sleep(1); // ony sleep() works on windoze apache :/
  476. }
  477. einde();
  478. function getGreeter($nicklist, $nick)
  479. {
  480. foreach($nicklist as $n) {
  481. $n = trim($n);
  482. if (!$n) {
  483. continue;
  484. }
  485. if ($n === $nick) {
  486. continue;
  487. }
  488. if ($n === 'Myself') {
  489. continue;
  490. }
  491. if (cse($n, "|aw")) {
  492. continue;
  493. }
  494. return "Connected...<br><br> &lt;&gt; Type your message to start the conference. <br>";
  495. }
  496. return "Connected...<br><br> &lt;Leave Message&gt; I am not available now. Please leave a message. <br>";
  497. }
  498. ?>
  499. </body>
  500. </html>