<?php
session_start();
require_once("../common/init.php");

$openid = $_GET['openid'];

if($openid != ''){
   $sql = "select * from users where QQ_openid='$openid'";
   $UInfo = $db->getdata($sql);
   if($UInfo ){
	   if($UInfo['iStatus']==1){
		  $sql = "update users set dtLogin=now() where QQ_openid='$openid'";
		  $db->query($sql);
		  $db->close();
		  $_SESSION['User_S'] = $UInfo['UserName'];
		  $_SESSION['iLevel_S'] = $UInfo['iLevel'];
		  header("Location: index.php");
		  exit;
	   }else{
	      $mess = "<span>您的会员帐号被禁用,请与我们联系</span>";
	   }
   }else{
      //QQ zuce
header("Location: reg.php?openid=$openid"); 
//确保重定向后，后续代码不会被执行 
exit;
	  echo "<script> window.open(\"reg.php?openid=$openid\"); </script>"; 
   }
}
$db->close();
?>