function rmsGetlist($type = 'online') { global $sock; $packet = " "; $cmd = "LIST $type\r\n"; if ($sock == 0) return; socket_write($sock, $cmd, strlen($cmd)); $packet = socket_read($sock, 512, PHP_NORMAL_READ); $users = array(); while (!preg_match("/^206$/", $packet)) { if (preg_match("/^204\s{1}.*/", $packet)) { $user = getUserStuff($packet); array_push($users, $user); $packet = socket_read($sock, 512, PHP_NORMAL_READ); } } return $users; }
<?php session_start(); header("Content-Type: text/html; charset=utf-8"); include 'includes/config.inc.php'; include 'includes/db.tables.inc.php'; // Descrierea tabelelor din baza de date include 'includes/functions/db.functions.php'; // Functii pentru baza de date include 'includes/functions/functions.php'; include 'simplehtmldom/simple_html_dom.php'; connect(); // Conectare la baza de date //========================================================================== if (!isLogged()) { header('Location: ' . $websiteURL . 'login.php'); } $userStuffs = getUserStuff(); $user = getUser(); // Se include pagina include 'pages/dashboard.php';
$res = " <response> <method>userList</method> <result>$userstxt</result> </response>"; $message = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" . $res; push($message); } while (true) { $packet = socket_read($sock, 512, PHP_NORMAL_READ); if (!$packet) break; $code = substr($packet, 0, 3); switch ($code) { case CODE_NOTIFYxSTATUS: $user = getUserStuff($packet); $method = "updateStatus"; $txt = "<newstatus><id>" . xmlentities($user['id']) . "</id><pp>" . xmlentities($user['pp']) . "</pp><nick>" . str_replace("\n", '', xmlentities(kses($user['nick'], array()))) . "</nick><nummsgs>" . trim(xmlentities($user['newmsgs'])) . "</nummsgs><status>" . str_replace(' ', '', xmlentities($user['status'])) . "</status></newstatus>"; break; case CODE_NOTIFYxMESSAGE: list($id, $pp, $numMessages) = split(' ', substr($packet, 4), 3); $method = "newMessage"; $txt = "<newmessage><id>$id</id><pp>$pp</pp><nummsgs>$numMessages</nummsgs></newmessage>"; break; case CODE_LOG: $method = "log";