<?php if(!defined('ROOT')) die('Access denied.');

class c_online extends Admin{

	public function __construct($path){
		parent::__construct($path);

	}


	public function index(){
		$smilies = ''; //表情图标
		for($i = 0; $i < 24; $i++){
			$smilies .= '<img src="' . SYSDIR . 'public/smilies/' . $i . '.png" onclick="insertSmilie(' . $i . ', 4040);">';
		}

		$waves = ''; //波形图
		for($i = 1; $i < 11; $i++){
			$waves .= '<div class="vw vw' . $i . '"></div>';
		}

		$aid = $this->admin['aid'];

		$phrases_cn = ''; //中文快捷回复
		$phrases_en = ''; //英文快捷回复

		$getphrases = APP::$DB->getAll("SELECT pid, lang, msg FROM " . TABLE_PREFIX . "phrase WHERE aid = '$aid' AND activated =1 ORDER BY sort ASC");
		foreach($getphrases AS $k => $phrase){
			$str = '<li onclick="insertPhrase(this);">' . $phrase['msg'] . '<b onclick="deletePhrase(this, \'' . $phrase['pid'] . '\')"></b></li>';

			if($phrase['lang']){
				$phrases_cn .= $str;
			}else{
				$phrases_en .= $str;
			}
		}

		if(!$phrases_cn) $phrases_cn = '<div>暂未添加快捷回复</div>';
		if(!$phrases_en) $phrases_en = '<div>No common phrases added</div>';


		echo '<div class="sp_main">
<div class="sp_left">
	<div class="sp_left_top" id="guest_div">访客 (<b class="online_guests">0</b>)</div>
	<div class="sp_left_mid scroll" id="g88"></div>
</div>
<div class="sp_center">
	<div id="guest_history" class="guest_history scroll"></div>
	<div class="chatbox_bot">
		<div class="guest_tools">
			<div class="tools_div">
				<a class="t_smilies" title="表情符号" onclick="return false;"></a>
				<a class="t_upload" title="图片或文件" onclick="doUpload();return false;"></a>
				<a class="t_auth" title="授权访客上传文件" onclick="return false;"></a>
				<a class="t_profile" title="记录访客信息" onclick="getProfile(this);return false;"></a>
				<a class="t_microphone" title="麦克风" onclick="setMicrophone(this);return false;"></a>
			</div>
			<div class="clock inactive" id="welive_clock"><span>0:00:00</span></div>
		</div>
		<div class="guest_enter">
			<div class="left"><textarea id="guest_msg" class="guest_msg scroll" placeholder="Ctrl + Enter: 发送"></textarea></div>
			<div class="right btn" id="guest_send" onselectstart="return false;">发 送</div>
			<div class="link-btn" id="send_mod_btn">^</div>
			<div style="display:none;" id="send_mod_div">
				<div onclick="setSendMod(0, this);" class="send_mod_0">Ctrl + Enter : 发送</div>
				<div onclick="setSendMod(1, this);" class="send_mod_1">Enter : 发送</div>
			</div>
		</div>
		<div class="copyright" id="welive_copyright"></div>
	</div>
	<div class="waver_container"><div class="voice_waver"><div class="wave">' . $waves . '</div><div class="wave down">' . $waves . '</div></div></div>
	<div id="guest_profile" class="g_profile" style="display:none;">
		<div class="t">访客信息</div>
		<form onsubmit="return false;">
		<li>
			<b>来源:</b><u><a href="" target="_blank" class="fromurl"></a></u>
		</li>
		<li><b>地区:</b><u class="ipzone"></u></li>
		<li class="f">
			<b>意向:</b>
			<input type="radio" value="1" name="grade" id="g-g-1"><label for="g-g-1">1分</label>
			<input type="radio" value="2" name="grade" id="g-g-2"><label for="g-g-2">2分</label>
			<input type="radio" value="3" name="grade" id="g-g-3"><label for="g-g-3">3分</label>
			<input type="radio" value="4" name="grade" id="g-g-4"><label for="g-g-4">4分</label>
			<input type="radio" value="5" name="grade" id="g-g-5"><label for="g-g-5">5分</label>
		</li>
		<li><b>姓名:</b><input name="fullname" type="text" class="s"></li>
		<li><b>备注:</b><textarea name="remark"></textarea></li>
		<li class="bt">
			<input class="cancel" type="submit" value="保存更新" onclick="saveGuest(this);return false;">&nbsp;&nbsp;&nbsp;&nbsp;
			<input class="cancel" type="submit" value=" 取消 " onclick="return closeProfile();">
		</li>
		</form>
	</div>
	<div id="video_container" onclick="toggleVideoSize(this);"><video id="remoteVideo" autoplay muted></video><div class="shut_btn" onclick="xGuestCamera();">X</div></div>
</div>
<div class="sp_right">
	<ul class="sp_right_tab">
		<li class="toggle_btn curr" for="1">客服 (<b id="sp_num">0</b>)<b id="s_chat_num">0</b><span class="line"></span></li>
		<li class="toggle_btn" for="2">快捷回复<span class="line"></span></li>
	</ul>
	<div class="sp_right_div" id="div_for_btn1">
		<div class="sp_mid">
			<div id="sp_history" class="scroll loading3">
				<div class="i"><b></b>服务器连接中 ...</div>
			</div>
			<div id="sp_list" class="scroll"></div>
		</div>
		<div class="sp_face"></div>
		<div class="sp_bott">
			<div class="left"><textarea id="sp_msg" placeholder="Ctrl + Enter: 发送" class="sp_msg scroll"></textarea></div>
			<div class="right btn" id="sp_send" onselectstart="return false;">发 送</div>
		</div>
	</div>
	<div class="sp_right_div scroll" style="display:none;" id="div_for_btn2">
		<div class="sp_mid">
			<div id="sp_phrases_cn" onselectstart="return false;" class="scroll">' . $phrases_cn . '</div>
			<div id="sp_phrases_en" onselectstart="return false;" style="display:none;" class="scroll">' . $phrases_en . '</div>
		</div>
		<div class="sp_bott">
			<div class="left"><textarea id="sp_phrase_msg" placeholder="添加快捷回复" class="sp_msg scroll"></textarea></div>
			<div class="right btn" onselectstart="return false;" onclick="addPhrase();">添 加</div>
		</div>
	</div>
</div>
</div>
<input type="file" name="file" id="upload_file" style="width:1px;height:1px;display:none;overflow:hidden;">
<div class="smilies_div" style="display:none"><div class="smilies_wrap">' . $smilies . '</div></div>
<div style="width:1px;height:1px;overflow:hidden;display:none;"><audio id="voice_player"></audio></div>
<div id="wl_sounder" style="width:1px;height:1px;visibility:hidden;overflow:hidden;"></div>';
	}



	public function __destruct(){
		//重载父类析构函数
		global $sys_starttime;

		$mtime = explode(' ', microtime());
		$sys_runtime = number_format(($mtime[1] + $mtime[0] - $sys_starttime), 3);

		echo '<script type="text/javascript">
function sysinfo_tip(me){
	layer.tips("<div style=\"font-size:14px;\" onmouseout=\"layer.close(layer.index);\">1. 用QQ等软件截图后, 在访客输入框中粘贴即可发送截图(不支持IE)<br>2. 在快捷回复区, 鼠标左右滑动可快速切换中英文快捷回复列表<br>3. 组长或管理员发送all, admin, guest, robot查询运行数据</div>", me, {tips: [1, "#585858"], area: ["460px", "auto"], time: 16000});
}

$(function(){
	$("#welive_copyright").html(\'<div class="sysinfo">'.date("Y").' &copy; '.APP_NAME.' '.APP_VERSION.' <a href="'.APP_URL.'" target="_blank" onmouseover="sysinfo_tip(this);">为因软件 weensoft.cn</a> Done in '.$sys_runtime.' second(s), '.APP::$DB->query_nums.' queries, GMT' .APP::$_CFG['Timezone'].' ' .DisplayDate('', '', 1).'</div>\');
});
</script>
</body>
</html>';
	}
}


?>