<?php
class QqloginAction extends Action {
	public function log(){
		echo 'document.write(\'';
		if(empty($_SESSION['uid'])){
			$qqlogin = C('qqlogin');
			$tweibologin = C('tweibologin');
			echo '<div class="logout">';
			if($qqlogin || $tweibologin){	
				echo '<script type="text/javascript">';
				if(!empty($_SESSION['login'])){
					echo 'window.location="'.U('User/Index/qqlogin').'";';
				}
				echo ' var childWindow;';
				echo 'var timer;';
				echo 'function toQzoneLogin(){';
				echo '    childWindow = window.open("'.C('URL').'/qq/oauth/qq_login.php","TencentLogin","width=450,height=320,menubar=0,scrollbars=1, resizable=1,status=1,titlebar=0,toolbar=0,location=1");';
				echo '	  timer = setInterval("childWin()", 1000);';
				echo ' } ';
				echo 'function toQweiboLogin(){';
				echo '	  childWindow = window.open("/tweibo/tweibo.php","TencentWeiboLogin","width=800,height=620,menubar=0,scrollbars=1, resizable=1,status=1,titlebar=0,toolbar=0,location=1");';
				echo '    timer = setInterval("childWin()", 1000);';
				echo ' } ';
				echo 'function childWin(){';
				echo     'if(childWindow.closed== true){';
				echo       'clearInterval(timer);';
				echo       'location.reload();';
				echo     '}';
				echo '}';
				echo '</script>';
				if($qqlogin){
					echo '<a href="#" onclick="toQzoneLogin()" style="color:blue"><img src="'.C('URL').'/Public/source/tqzone.png" style="vertical-align: middle;"></a> &nbsp;';
				}
				if($tweibologin){
					echo '<a href="#" onclick="toQweiboLogin()" style="color:blue"><img src="/Public/source/tweibo.png" style="vertical-align: middle;"></a> &nbsp;';
				}
			}	
			echo '<a href="'.U('User/Index/login').'">登录</a> ';
			echo '<a href="'.U('User/Index/reg').'">注册</a>';
			echo '</div>';
		}else{
			echo '<div class="login" style="display:block">';
			echo '<a href="/user" class="username">'.$_SESSION['uname'].'</a> ';
			echo '<a href="'.U('User/Index/logout').'" class="exit">退出</a> ';
			echo '<a href="'.U('User/Index/msg').'" class="message" id="tip-message" title="小纸条"><span class="bti"></span></a> ';
			echo '<a href="'.U('User/Index/code').'" class="code" id="tip-code" title="邀请码"><span class="bti"></span></a>';
			echo '</div>';
		}
		echo '\')';
	}
}
?>