public function chatbox() { $webim_path = WEBIM_PATH(); $uid = $this->input('uid'); $buddies = $this->plugin->buddiesByIds($this->user->id, array($uid)); if ($buddies && isset($buddies[0])) { $buddy = $buddies[0]; } if (!$buddy) { header("HTTP/1.0 404 Not Found"); exit("User Not Found"); } header('Content-Type', 'text/html; charset=utf-8'); echo '<html><head>'; echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />'; echo '<meta content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0" name="viewport">'; echo '<title>Webim ChatBox</title>'; echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"{$webim_path}/static/webim-chatbox.css\"/>"; echo "<script type=\"text/javascript\" src=\"{$webim_path}/static/webim-chatbox.js\"></script>"; echo '</head><body>'; echo '<body id="chatbox">'; echo '<div id="header">'; echo "<img id=\"avatar\" class=\"avatar\" src=\"{$buddy->avatar}\"></img>"; echo "<h4 id=\"user\">{$buddy->nick}</h4>"; echo "</div>"; echo '<div id="notice" class="chatbox-notice ui-state-highlight" style="display: none;">'; echo '</div>'; echo '<div id="content"><div id="histories"></div></div>'; echo '<div id="footer">'; echo '<table style="width:100%"><tbody><tr><td width="100%">'; echo "<input type=\"hidden\" id=\"to\" value=\"{$buddy->id}\">"; echo '<input type="text" data-inline="true" placeholder="请这里输入消息..." name="" id="inputbox">'; echo '</td><tr><tbody></table>'; echo '</div>'; echo '<script>'; echo '(function(webim, options) { '; echo ' var path = options.path || "";'; echo ' function url(api) { return path + api; }'; echo ' webim.route({'; echo ' online: url("/index.php?action=online"),'; echo ' offline: url("/index.php?action=offline"),'; echo ' deactivate: url("/index.php?action=refresh"),'; echo ' message: url("/index.php?action=message"),'; echo ' presence: url("/index.php?action=presence"),'; echo ' status: url("/index.php?action=status"),'; echo ' setting: url("/index.php?action=setting"),'; echo ' history: url("/index.php?action=history"),'; echo ' buddies: url("/index.php?action=buddies")'; echo ' });'; echo ' var im = new webim(null, options);'; echo ' var chatbox = new webim.chatbox(im, options);'; echo ' im.online();'; echo "})(webim, {touid: '{$buddy->id}', path:'{$webim_path}/'})"; echo '</script>'; echo '</body>'; echo '</html>'; }
function WEBIM_IMAGE($img) { return WEBIM_PATH() . "static/images/{$img}"; }
/** * Boot Javascript */ function boot() { global $IMC; $fields = array('theme', 'local', 'emot', 'opacity', 'enable_room', 'discussion', 'enable_chatlink', 'enable_shortcut', 'enable_noti', 'enable_menu', 'show_unavailable', 'upload'); //from webim_plugin_discuzx $this->user->show = "unavailable"; $uid = $this->user->id; $webim_path = WEBIM_PATH(); if (substr($webim_path, strlen($webim_path) - 1) !== '/') { $webim_path .= '/'; } $scriptVar = array('version' => WEBIM_VERSION, 'product' => WEBIM_PRODUCT, 'path' => $webim_path, 'is_login' => '1', 'is_visitor' => webim_isvid($uid), 'login_options' => '', 'user' => $this->user, 'menu' => $this->plugin->menu($uid), 'setting' => $this->model->setting($uid), 'jsonp' => false, 'min' => WEBIM_DEBUG ? "" : ".min"); foreach ($fields as $f) { $scriptVar[$f] = $IMC[$f]; } header("Content-type: application/javascript"); header("Cache-Control: no-cache"); echo "var _IMC = " . json_encode($scriptVar) . ";" . PHP_EOL; $script = <<<EOF _IMC.script = window.webim ? '' : ('<link href="' + _IMC.path + 'static/webim' + _IMC.min + '.css?' + _IMC.version + '" media="all" type="text/css" rel="stylesheet"/><link href="' + _IMC.path + 'static/themes/' + _IMC.theme + '/jquery.ui.theme.css?' + _IMC.version + '" media="all" type="text/css" rel="stylesheet"/><script src="' + _IMC.path + 'static/webim' + _IMC.min + '.js?' + _IMC.version + '" type="text/javascript"></script><script src="' + _IMC.path + 'static/i18n/webim-' + _IMC.local + '.js?' + _IMC.version + '" type="text/javascript"></script>'); _IMC.script += '<script src="' + _IMC.path + 'static/webim.' + _IMC.product + '.js?vsn=' + _IMC.version + '" type="text/javascript"></script>'; document.write( _IMC.script ); EOF; exit($script); }