private function onPost($nickname, $target, $message) { # Validate the crap! if (false !== ($error = GWF_ChatValidator::validate_yournick($this->module, $nickname))) { return $error; } if (false !== ($error = GWF_ChatValidator::validate_target($this->module, $target))) { $error; } if (false !== ($error = GWF_ChatValidator::validate_message($this->module, $message))) { return $error; } # Post it! $oldnick = $this->module->getNickname(); $sender = Common::getPost('yournick', $oldnick); $target = trim($target); $message = str_replace("\n", '<br/>', Common::getPost('message')); if ($oldnick === false) { $sender = $this->module->getGuestPrefixed($sender); $this->module->setGuestNick($sender); } else { $sender = $oldnick; } if (false === GWF_ChatMsg::newMessage($sender, $target, $message)) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } return '1'; }
private function onPost() { $form = $this->getForm(); if (false !== ($error = $form->validate($this->module))) { return $error; } $oldnick = $this->module->getNickname(); $sender = $form->getVar('yournick', $oldnick); $target = $form->getVar('target'); $message = $form->getVar('message'); if ($oldnick === false) { $sender = $this->module->getGuestPrefixed($sender); $this->module->setGuestNick($sender); } else { $sender = $oldnick; } if (false === GWF_ChatMsg::newMessage($sender, $target, $message)) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } $_POST['message'] = ''; return $this->module->message('msg_posted'); }
public function getHistoryMessages($channel, $page) { $msgs = new GWF_ChatMsg(false); // $channel = $msgs->escape($channel); $ipp = $this->getHistmsgPerPage(); $from = GWF_PageMenu::getFrom($page, $ipp); $conditions = $this->getHistoryCondition($channel); return $msgs->selectAll('*', $conditions, 'chatmsg_time ASC', NULL, $ipp, $from, GDO::ARRAY_O); }
private function startStream() { #GWF_ChatOnline::setSessOnline(); GWF_Javascript::streamHeader(); $times = array(time(), time(), time(), time()); $i = 0; while ($i < 10) { echo '+Foo' . PHP_EOL; flush(); // GWF_Javascript::flush(); sleep(2); $i++; continue; $stuff_sent = false; # Get Kick Messages $kicked = GWF_ChatOnline::getKicked($times[0]); if (count($kicked) > 0) { $stuff_sent = true; $this->streamMessageJoin('-', $kicked); $times[0] = time(); } # Get Join Messages $joined = GWF_ChatOnline::getJoined($times[1]); if (count($joined) > 0) { $stuff_sent = true; $this->streamMessageJoin('+', $joined); $times[1] = time(); } # Get Public Channel Messages $msgs = new GWF_ChatMsg(false); $channel = ''; $last = $times[2]; $pubmsg = $msgs->selectAll('*', "chatmsg_to='{$channel}' AND chatmsg_time>{$last}", 'chatmsg_time ASC'); if (count($pubmsg) > 0) { $stuff_sent = true; $this->echoMessages($pubmsg, false); $times[2] = time(); } # Get Private Messages if (false !== ($nick = $this->module->getNickname())) { $last = $times[3]; $privmsg = $msgs->selectAll('*', "(chatmsg_to='{$nick}' OR (chatmsg_from='{$nick}' AND chatmsg_to!='')) AND chatmsg_time>{$last}", 'chatmsg_time ASC'); if (count($privmsg) > 0) { $stuff_sent = true; $this->echoMessages($privmsg, true); $times[3] = time(); } } // if (!$stuff_sent) // { // usleep(1000000); GWF_ChatOnline::setSessOnline($this->module); // } // else // { // } // echo '+Foo'.PHP_EOL; echo '+Foo' . PHP_EOL; // flush(); GWF_Javascript::flush(); // flush(); sleep(1); } GWF_ChatOnline::setSessOffline($this->module); die; }