<?php
/*
 * 注意：此文件由tpl_engine编译型模板引擎编译生成。
 * 如果您的模板要进行修改，请修改 templates/default/index.html
 * 如果您的模型要进行修改，请修改 models/index.php
 *
 * 修改完成之后需要您进入后台重新编译，才会重新生成。
 * 如果您开启了debug模式运行，那么您可以省去上面这一步，但是debug模式每次都会判断程序是否更新，debug模式只适合开发调试。
 * 如果您正式运行此程序时，请切换到service模式运行！
 * 
 * 如有您有问题请到官方论坛（http://tech.jooyea.com/bbs/）提问，谢谢您的支持。
 */
?><?php
	header("content-type:text/html;charset=utf-8");
	require("foundation/asession.php");
	require("configuration.php");
	require("includes.php");
	require("foundation/module_users.php");
	require("foundation/fcontent_format.php");
	require("foundation/fplugin.php");
	if(get_sess_userid()){
		echo '<script type="text/javascript">window.location.href="main.php";</script>';
	}
	$tg=get_args('tg');
	$onload_run_script='initform();';
	if($tg=='login'){$onload_run_script='showLogin();';}
	if($tg=='reg'){$onload_run_script='showReg();';}

	//语言包引入
	$l_langpackage=new loginlp;
	$re_langpackage=new reglp;
	$pu_langpackage=new publiclp;
	
	if($tg=='invite'){
		$index_ref="modules/invite.php";
	}elseif($tg=='search_pals'){
		$index_ref="modules/mypals/search_pals_list.php";
	}else{
		$index_ref="modules/default.php";
  	}
  	//数据表定义区
	$t_recommend = $tablePreStr."recommend";
	$t_users = $tablePreStr."users";
	$t_config = $tablePreStr."config";
	$t_plugins=$tablePreStr."plugins";
	
	$dbo = new dbex;
	//读写分离定义函数
	dbtarget('r',$dbServs);
	$rec_rs=array();
	$rec_rs0=array();
	$rec_rs1=array();
	
	if(is_null(get_sess_plugins()))$plugins="''";
		else $plugins=get_sess_plugins();
		$sql="select * from $t_plugins where plugin_id in('1','2','3') and valid=1 and name not in (".$plugins.")";
		$rows=$dbo->getRs($sql);
		$plugin_menu=array();
		$plugin_content=array();
		$plugin_floor=array();
		foreach($rows as $row)
		{
			if($row['plugin_id']==1) $plugin_menu[]=$row;
			else if($row['plugin_id']==2) $plugin_guest[]=$row;
			else if($row['plugin_id']==3) $plugin_friends[]=$row;
		}
	
	//首页会员推荐
	$sql="select * from $t_recommend order by rec_order";
	$rec_rs=$dbo->getRs($sql);
  	foreach ($rec_rs as $key=>$val){
  		if ($val['rec_class']=='0'){
  			$rec_rs0[$key]=$val;
  		}
  	}
	//首页幻灯片	
  	foreach ($rec_rs as $key=>$val){
  		if ($val['rec_class']=='1'){
  			$rec_rs1[$key]=$val;
  		}
  	}
  
  //最新会员列表
	$sql="select * from $t_users order by user_add_time desc limit 0,4";
	$user_rs=$dbo->getRs($sql);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Description" content="<?php echo $metaDesc;?>" />
<meta name="Keywords" content="<?php echo $metaKeys;?>" />
<title><?php echo $siteName;?></title>
<link rel="stylesheet" type="text/css" href="skin/<?php echo $skinUrl;?>/css/jooyea.css">
<SCRIPT language=JavaScript src="servtools/md5.js"></SCRIPT>
<script src="skin/default/js/yui-utilities.js" type=text/javascript></script>
<script src="skin/default/js/tbra.js" type=text/javascript></script>
<script src="skin/default/js/area_config_act.js" type="text/javascript"></script>
<script src="skin/default/js/jooyea.js" type="text/javascript"></script>
<SCRIPT language=JavaScript src="skin/default/js/login.js"></SCRIPT>
<SCRIPT language=JavaScript src="servtools/ajax_client/ajax.js"></SCRIPT>
<SCRIPT language=JavaScript src="skin/default/js/Dialog.js"></SCRIPT>
<SCRIPT language=JavaScript src="servtools/Common.js"></SCRIPT>
<script language=JavaScript>
function goLogin(){
	Dialog.confirm("<?php echo $pu_langpackage->pu_login;?>",function(){top.location="index.php";});
}	
    
function getVerCode()
{
  document.getElementById("verCodePic").src="servtools/veriCodes.php?vc="+Math.random();
}

function getEnt(){
	document.onkeydown = function (e){
		var theEvent = window.event || e;
		var code = theEvent.keyCode || theEvent.which;
		if(code == 13){
			  login();
		}
	}
}

function inputTxt(obj,act)
{
  var str="<?php echo $re_langpackage->re_empty_val;?>";
  if(obj.value==''&&act=='set')
  {  
     obj.value=str;
     obj.style.color='gray';
  }
  
  if(obj.value==str&&act=='clean')
  {  
     obj.value='';
     obj.style.color='gray';
  }
}
     
//ajax
function xmlchange()
{
      var argb_div=document.getElementById("operate");
    if(xmlhttp.readyState==4&&xmlhttp.status==200)
 		{
 			var check=/\.php/;
 			var	return_text=trim(xmlhttp.responseText);
 		    if(check.test(return_text)){
 		         if(document.getElementById("tmpiId").checked){
 		            saveTmpEmail(1);
 		         }else{
 		         	  saveTmpEmail(0);
 		         }
 		         window.location.href=return_text;
 		    }else{
            argb_div.style.display="block";
	 		argb_div.innerHTML='<img src="skin/<?php echo $skinUrl;?>/images/icon_err.gif" align="top" style="margin-right:2px">'+return_text;
	    }
 		}else{
 	    argb_div.innerHTML="<span style='color:#838383'><img src='skin/<?php echo $skinUrl;?>/images/login_loading.gif' align='top' style='margin-right:2px'><?php echo $l_langpackage->l_loading;?></span>";
 	}
}

function saveTmpEmail(para){
   var Then=new Date();
   var uemailStr=document.getElementById("login_email").value;
   Then.setTime(Then.getTime() +3600*1000*24*300 );
   if(para==1){
     document.cookie='UserIId='+uemailStr+';expires='+ Then.toGMTString();
   }else{
     document.cookie="IsReged=Y;expires="+ Then.toGMTString();
   }
}

function login()
{
	 u_email=document.getElementById('login_email').value;
	 u_pws=document.getElementById('login_pws').value;
	 if(u_pws!=''){
	 	u_pws=MD5(u_pws);
	}
	 u_hidden=0;
	 if(document.getElementById('hidden').checked){
	    u_hidden=1;
	 }
	 xmlhttp=InitAjax();
	 xmlhttp.open("POST","do.php?act=login",true);
	 xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	 xmlhttp.onreadystatechange=xmlchange;
	 xmlhttp.send("u_email="+u_email+"&u_pws="+u_pws+"&hidden="+u_hidden);
 }
     
function check_form(){
	var email=/^([a-zA-Z0-9._-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/;	
	var veriCode=trim(document.getElementById("veriCode").value);
	var u_pws=trim(document.getElementById("u_pws").value);
	var reu_pws=trim(document.getElementById("reu_pws").value);
	document.getElementById('u_pws').value=u_pws;
	document.getElementById('reu_pws').value=reu_pws;
	var u_name=trim(document.getElementById("u_name").value);
	var u_email=trim(document.getElementById("u_email").value);
  var regerr_div=document.getElementById("regerrmsg");
        
  if(u_name==""){
   errshow(regerr_div,"<?php echo $re_langpackage->re_right_name;?>");
   return false;
	}
	
	if(u_email==""){
   errshow(regerr_div,"<?php echo $l_langpackage->l_empty_mail;?>");
   return false;
	}
	
	if(!email.test(u_email)){
		errshow(regerr_div,"<?php echo $re_langpackage->re_right_email;?>");
		return false;
	}
    
  if(u_pws==""){
	  errshow(regerr_div,"<?php echo $l_langpackage->l_empty_pass;?>");
		return false;
	}
	
	if(reu_pws==""){
	  errshow(regerr_div,"<?php echo $l_langpackage->l_empty_repa;?>");
		return false;
	}
	
	if(u_pws.length<6){
	  errshow(regerr_div,"<?php echo $re_langpackage->re_pass_limit;?>");
		return false;
	}
    
  if(u_pws!=reu_pws){
		errshow(regerr_div,"<?php echo $re_langpackage->re_dif_pass;?>");
		return false;
	}
    
	if(veriCode==("<?php echo $re_langpackage->re_empty_val;?>"||"")){
    errshow(regerr_div,"<?php echo $re_langpackage->re_empty_val;?>");
    return false;
	}else{
		document.getElementById("u_pws").value=MD5(u_pws);
		document.getElementById("reu_pws").value=MD5(reu_pws);
	}
}

function errshow(obj,err_text){
	obj.style.display="block";
	obj.innerHTML='<img src="skin/<?php echo $skinUrl;?>/images/icon_err.gif" align="top" style="margin-right:2px">'+err_text;
}

function ser_item(){
	document.getElementById("screen_div").style.display='';
	document.getElementById("screen_div").style.top=0;
	document.getElementById("screen_div").style.left=0;
	document.getElementById("screen_div").style.width=window.document.body.clientWidth+"px";
	document.getElementById("screen_div").style.height=window.document.body.clientHeight+"px";
	document.getElementById("ser_window").style.display='';
	document.getElementById("ser_window").style.top=window.document.body.clientHeight/2-200+"px";
	document.getElementById("ser_window").style.left=window.document.body.clientWidth/2-250+"px";
	var xmlhttp=InitAjax();
	xmlhttp.open("get","do.php?act=get_ser_item");
	xmlhttp.onreadystatechange=function(){
		if(xmlhttp.readyState==4&&xmlhttp.status==200){
			var return_str=xmlhttp.responseText;
			var	return_text=return_str.replace(/&lt;/g,"<");
			var	return_text=return_text.replace(/&gt;/g,">");
			document.getElementById("ser_content").innerHTML=return_text;
			}
		}
		xmlhttp.send(null);
	}

function close_ser_item(){
	document.getElementById("screen_div").style.display='none';
	document.getElementById("ser_window").style.display='none';
}
</script>
</head>
<body onLoad="<?php echo $onload_run_script;?>" >
<div id='ser_window' style='display:none;width:500px;height:350px;' class='ajax_window'>
	<div id='ser_content' style='height:330px'></div>
	<div><input type='button' class='top_button' onclick='close_ser_item()' value='<?php echo $l_langpackage->l_close;?>' /></div>
</div>
<div id='screen_div' style='background-color:gray;filter:alpha(opacity=70);opacity: 0.7;display:none;position:absolute;z-index:1;'></div>	
<div class="wrapper">
<?php include("uiparts/guestheader.php");?>
  <div class="main top10">
    <div class="main_l left">
    <!--login star-->
      <div class="login" >
        <div class="c_t">
          <div class="c_t_l left"></div>
          <div class="c_t_r right"></div>
        </div>
        <div class="c_m" id="loginform" >
         <form name="login_form" method="post" onsubmit='return false'>
          <h2><?php echo $l_langpackage->l_momber_login;?></h2>
          <div id='operate' style='display:none;color:red'></div>
          <p>
            <label><?php echo $l_langpackage->l_email;?>：</label></p>
            <p><input type="text" class="txt" name="login_email" id='login_email' maxlength="39" value="">
          </p>
          <p>
            <label><?php echo $l_langpackage->l_pass;?>：</label>
          </p>
          <p>
            <input type="password"  class="txt" name="login_email" id="login_pws"  maxlength="18"  value="" onkeydown='if(this.value.length>3){getEnt();}'>
          </p>
          <div class="top10"></div>
          <p>
            <input type="button" onClick="login();" class='btn'  name=loginsubm id=loginsubm value=" <?php echo $l_langpackage->l_login;?> ">
          </p>
          <div class="item">
            <div class="chkbox">
            <input name="hidden" class="chk" id="hidden" type="checkbox" value="1" onKeyDown="getEnt();"></div>
            <div class="cookie" style="margin-right:8px;"><?php echo $l_langpackage->l_hid;?></div>
            <div class="chkbox">
              <input name="tmpiId" class="chk" id="tmpiId" type="checkbox" value="save" checked onKeyDown="getEnt();">
            </div>
            <div class="cookie"><?php echo $l_langpackage->l_save_aco;?></div>
            
          </div></form>
        </div>
        <div class="c_m" id="regform" style="display:none" >
          <form name="reg_form" method="post" action="do.php?act=reg" onsubmit='return check_form()'>
          <h2 class="regh2"><?php echo $l_langpackage->l_momber_register;?></h2>
          <div id='regerrmsg' style='display:none;color:red'></div>
          <p><label><?php echo $re_langpackage->re_name;?>：</label></p>
          <p><input type="text" class="txt" name="u_name" id="u_name" value="" maxlength="20" autocomplete='off'></p>
          <p><label><?php echo $l_langpackage->l_email;?>：</label></p>
          <p><input type="text" class="txt" name="u_email" maxlength="50" id="u_email" value=""></p>
          <p><label><?php echo $l_langpackage->l_pass;?>：</label></p>
          <p><input type="password" class="txt" maxlength="18" name="u_pws" id="u_pws" value=""></p>
          <p><label><?php echo $l_langpackage->l_repass;?>：</label></p>
          <p><input type="password" class="txt" maxlength="18" name="reu_pws" id="reu_pws" value=""></p>
          <div class="item"><input name="u_sex" type="radio" value="0" checked>
				              <label><?php echo $pu_langpackage->pu_woman;?></label>&nbsp;
			
				            <input name="u_sex" type="radio" value="1">    
				              <label><?php echo $pu_langpackage->pu_man;?></label></div>
          <div class="item"><img border="0" src="servtools/veriCodes.php" height=20 id="verCodePic"><img border="0" src="skin/<?php echo $skinUrl;?>/images/veri_reload.gif" width="20" height="20" title="<?php echo $re_langpackage->re_cha_photo;?>" class="hand" style="margin-left:3"  onclick='getVerCode();'></div><p><input type="text" class="txt" style="width:100px; color:#777;" name="veriCode" id="veriCode" maxlength="5" value="<?php echo $re_langpackage->re_empty_val;?>" onFocus="inputTxt(this,'clean');" onBlur="inputTxt(this,'set');"></p>
          <div class="item"><div class="chkbox"><input name="agreed" class="chk" type="checkbox" value="ON" onClick="if(this.checked==true){document.getElementById('regsubmit').disabled=null;}else{document.getElementById('regsubmit').disabled=true;}" checked></div><div class="cookie"><?php echo $re_langpackage->re_agree;?><a href="javascript:ser_item();" class="user_menu_a"><?php echo $re_langpackage->re_ser_item;?></a>
						   <onClick="if(document.getElementById('regsubmit').disabled==true){alert('<?php echo $re_langpackage->re_must_agree;?>');}" ></div></div>
               <p><input type="submit" class='btn' id="regsubmit" value=" <?php echo $re_langpackage->re_reg;?> ">
						        
						        <input type="button" class='btn' value=" <?php echo $re_langpackage->re_re_login;?> " onClick="showLogin();"></p>
          </form>
          <div class="clear top10"></div>
        </div>
        <div class="c_bt">
          <div class="c_bt_l left"></div>
          <div class="c_bt_r right"></div>
        </div>
      </div>
      <!-- login end -->
      <div class="register top10">
        <div class="c_t">
          <div class="c_t_l left"></div>
          <div class="c_t_r right"></div>
        </div>
        <div class="c_m">
          <h3><a href="javascript:showReg();"><?php echo $l_langpackage->l_30s_register;?></a></h3>
          <p><?php echo $siteName;?><?php echo $l_langpackage->l_wel_insert;?></p>
        <!-- plugins !-->  
        <div id="plugin_menu">
        	<?php echo show_plugins($plugin_menu);?>
        </div>
        <!-- plugins !-->           
        </div>
        <div class="c_bt">
          <div class="c_bt_l left"></div>
          <div class="c_bt_r right"></div>
        </div>
      </div>
      <!-- register end -->
    </div>
 <!-- main_l end -->
<?php if($tg=='search_pals'){?>
<div class="main_r left10" >
  <div id="maincontent">
    <div class="c_t">
      <div class="c_t_l left"></div>
      <div class="c_t_r right"></div>
    </div>
    <div class="c_m">
		<div id="search_star">
			<div class="top">
				<h2><?php echo $l_langpackage->l_search_result;?></h2>
			</div>
			
<?php }?>
   <?php include($index_ref);?>
<?php if($tg=='search_pals'){?>
			</div>
		</div>
    
<div class="c_bt">
  <div class="c_bt_l left"></div>
  <div class="c_bt_r right"></div>
</div>
</div>
</div>
<?php }?>
        <!-- main end -->
      
<div class="clear"></div>
        <!-- plugins !-->  
        <div id="plugin_floor">
        	<?php echo show_plugins($plugin_floor);?>
        </div>
        <!-- plugins !-->
<?php include("uiparts/footor.php");?>
</div>
</body>
</html>