<?php
header("Content-type:text/html;charset=utf-8");  
session_start();
$session_admin = isset($_SESSION['admin']) ? $_SESSION['admin'] : ''; 
if ($session_admin == '') {
	die("Can not access");
}
require_once("../common.php");
checkadminrights($session_admin, 'users');

$userid = isset($_GET['userid']) ? $_GET['userid'] : '0'; 
$nickname = isset($_GET['nickname']) ? urldecode($_GET['nickname']) : '';
$searchtype = isset($_GET['searchtype']) ? $_GET['searchtype'] : '1'; 
$searchparam = isset($_GET['searchparam']) ? urldecode($_GET['searchparam']) : '';
$sex = isset($_GET['sex']) ? $_GET['sex'] : '-1'; 
$age = isset($_GET['age']) ? $_GET['age'] : '-1'; 
$online = isset($_GET['online']) ? $_GET['online'] : '-1'; 
$pageindex = isset($_GET['pageindex']) ? $_GET['pageindex'] : '1';

//subpageurlparams
$subpageurlparams = 'userid=' . $userid . '&nickname=' . urlencode($nickname) . 
	'&searchtype=' . $searchtype . '&searchparam=' . urlencode($searchparam) . 
	'&sex=' . $sex . '&age=' . $age . '&online=' . $online . '&pageindex=' . $pageindex;

$methodname = 'Admin.ForceOffline';
$requestinfo = '<?xml version="1.0" encoding="utf-8"?><request>' . 
    '<ip>' . getip() . '</ip>' . 
	'<userid>' . $userid . '</userid>' . 	
	'</request> ';
$responseinfo = '';
$responsexml = null;
$errorcode = ERRORCODE_UNKNOWN;

$cmd = new COM("OpenCom.Command");
$methodname = iconv('UTF-8', 'GBK//IGNORE', $methodname);
$requestinfo = iconv('UTF-8', 'GBK//IGNORE', $requestinfo);
if ($cmd->Execute($methodname, $requestinfo, $responseinfo, 5000)) {
	$responseinfo = iconv('GBK', 'UTF-8//IGNORE', $responseinfo);
	$responsexml = simplexml_load_string($responseinfo);
	$errorcode = $responsexml->errorcode;
}
$cmd = null;

switch($errorcode) {
	case ERRORCODE_OK: 
		header("location:   users.php?{$subpageurlparams}");
		break;
	default:
		header("location:   users.php?{$subpageurlparams}");
}//switch
?>
