<?php
include(dirname(__FILE__)."/require.php");
if($ppurview[19]!=1)
{
  Header("Location: jump.php?id=25&jump=main.php");
  exit();
}
$phpcolor->table=$core_mysql_prefix."user";
$phpcolor->where="id = '".$_GET['id']."'";
if(isset($_GET['action']) and isset($_GET['id']) and $_GET['action']=="on")
{
  $phpcolor->field="state='1'";
  $phpcolor->upgrade();
  Header("Location: jump.php?id=24&jump=user.php");
}
elseif(isset($_GET['action']) and isset($_GET['id']) and $_GET['action']=="off")
{
  $phpcolor->field="state='0'";
  $phpcolor->upgrade();
  Header("Location: jump.php?id=24&jump=user.php");
}
elseif(isset($_GET['action']) and isset($_GET['id']) and $_GET['action'] == "editdo")
{
  if ($_POST['passwd']!="" and (strlen($_POST['passwd'])<$core_pwdshort or strlen($_POST['passwd'])>$core_pwdlong))
	Header("Location: jump.php?id=8&jump=user.php?action=edit=and=id=".$_GET['id']);
  else
  {
    if($_POST['passwd']!="")
    {
      $user_passwd = md5($_POST['passwd']);
	  $phpcolor->field="passwd='".$user_passwd."', email='".$_POST['email']."', safemail='".$_POST['safemail']."', question='".$_POST['question']."', answer='".$_POST['answer']."', picture='".$_POST['picture']."', userfrom='".$_POST['userfrom']."', sex='".$_POST['sex']."', age='".$_POST['age']."', birthday='".$_POST['birthday']."', zodiac='".$_POST['zodiac']."', constellation='".$_POST['constellation']."', blood='".$_POST['blood']."', school='".$_POST['school']."', profession='".$_POST['profession']."', qq='".$_POST['qq']."', mobile='".$_POST['mobile']."', phone='".$_POST['phone']."', signature='".$_POST['signature']."', introduction='".$_POST['introduction']."', state='".$_POST['state']."'";
      $phpcolor->upgrade();
    }
    else
    {
	  $phpcolor->field="email='".$_POST['email']."', safemail='".$_POST['safemail']."', question='".$_POST['question']."', answer='".$_POST['answer']."', picture='".$_POST['picture']."', userfrom='".$_POST['userfrom']."', sex='".$_POST['sex']."', age='".$_POST['age']."', birthday='".$_POST['birthday']."', zodiac='".$_POST['zodiac']."', constellation='".$_POST['constellation']."', blood='".$_POST['blood']."', school='".$_POST['school']."', profession='".$_POST['profession']."', qq='".$_POST['qq']."', mobile='".$_POST['mobile']."', phone='".$_POST['phone']."', signature='".$_POST['signature']."', introduction='".$_POST['introduction']."', state='".$_POST['state']."'";
      $phpcolor->upgrade();
    }
    Header("Location: jump.php?id=24&jump=user.php");
  }
}
elseif(isset($_GET['action']) and isset($_GET['id']) and $_GET['action'] == "edit")
{
  $phpcolor->field="*";
  $user = $phpcolor->exist(1);
  $tpl -> assign("user", $user);
  $tpl -> display("user_edit.htm");
}
else
{
  if(!isset($_GET['page']))
    $_GET['page']=0;
  $phpcolor->field="*";
  if(isset($_GET['username']))
  {
    $phpcolor->where="username like '%".$_GET['username']."%'";
    $count = $phpcolor->exist(2);
    $phpcolor->where="username like '%".$_GET['username']."%' order by registered desc limit ".($_GET['page']*20).",20";
    $page=pages($count,20,$_GET['page'],'user','&username=',$_GET['username'],'0');
  }
  else
  {
    $phpcolor->where="1=1";
    $count = $phpcolor->exist(2);
    $phpcolor->where="1=1 order by registered desc limit ".($_GET['page']*20).",20";
    $page=pages($count,20,$_GET['page'],'user','','','0');
  }
  $user = $phpcolor->assignment();
  $tpl -> assign("user", $user);
  $tpl -> assign("page", $page);
  $tpl -> display("user.htm");
}
?>