function send($path) { global $config; $msg = $_POST['msg']; $omsg = $msg; $current_channel = DB::get()->val('SELECT name FROM channels WHERE active = 1 AND user_id = :user_id', array('user_id' => Auth::user_id())); $post_chan = $_POST['chan']; $user = Auth::user(); // Aliases $aliases = DB::get()->assoc("SELECT name, value FROM options WHERE grouping = 'Alias' ORDER BY coalesce(room,'') = :room ASC, user_id = :user_id DESC, isnull(room) DESC, name", array('user_id' => Auth::user_id(), 'room' => $post_chan)); foreach ($aliases as $from => $to) { if (preg_match($from, $msg)) { $msg = preg_replace($from, $to, $msg); break; } } $command = trim(substr($msg, 1)); $commands = explode(' ', $command); $cmds = $this->_get_cmds(); $entities = false; $smartstatus = false; $params = array('smartstatus' => false); foreach ($cmds as $cmdname => $cmd) { if ($cmd[2] == CMD_FORWARD && !$entities) { $msg = htmlspecialchars($msg); $msg = nl2br($msg); $entities = true; } if (preg_match($cmd[0], strip_tags($msg), $matches)) { //Immediate::ok('cmd:' . $cmdname, $user); $params = array_merge($params, array('path' => $path, 'msg' => $msg, 'command' => $command, 'matches' => $matches, 'channel' => $current_channel, 'user' => $user, 'commands' => $commands, 'cmd' => $cmd, 'omsg' => $omsg, 'presence' => $this)); $params = array_merge($params, $matches); switch ($cmd[2]) { case CMD_LAST: error_log('using ' . $commandname); //var_dump($cmdname, $user);if($cmdname =='externals') die('zz'); $result = call_user_func($cmd[1], &$params); if ($result) { break 2; } break; case CMD_FORWARD: $msg = call_user_func($cmd[1], $msg, &$params); break; case CMD_CONTINUE: $result = call_user_func($cmd[1], &$params); break; } $smartstatus = $smartstatus | $params['smartstatus']; } } Plugin::call('send_done', $params); Immediate::set_status(); $laststatus = Immediate::get_status(); if ($smartstatus) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://' . $_SERVER['HTTP_HOST'] . '/presence/dosmartstatus?status=' . $laststatus); curl_setopt($ch, CURLOPT_MAXREDIRS, 0); // Maximum number of redirections to follow. curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 300); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 1); curl_setopt($ch, CURLOPT_CRLF, true); // Convert UNIX newlines to \r\n $response = curl_exec($ch); curl_close($ch); } Immediate::output(); }