Location: PHPKode > projects > WB News > admin/user.php
<?php

/*========================================================*\
||########################################################||
||#                                                      #||
||#     WB News v2.0.0                                   #||
||# ---------------------------------------------------- #||
||#     Copyright (c) 2004-2007                          #||
||#     Created: 24th August 2005                        #||
||#     Filename: user.php                               #||
||#                                                      #||
||########################################################||
/*========================================================*/

/**
 *  @author $Author: pmcilwaine $
 *	@version $Id: user.php,v 1.2.2.5.2.1 2008/07/14 11:04:08 pmcilwaine Exp $
 */

require_once( "global.php" );
$auth->login_if( !$auth->has_perm( "adduser" ) );

$_SESSION["return_page"] = make_url( array("ajax"=>FALSE) );

$page = new PageTemplateEngine( BuildPath("admin/main-page.ihtml") );
$tmpl->SetFilename( USE_AJAX ? BuildPath("admin/ajax/user.ixml") : BuildPath("admin/user.ihtml") );

$params = array(
	"entry" => "\t<li>%s</li>\n\t",
	"separator" => FALSE,
	"class_open" => "open",
	"links" => toolbarmenu()
	);
$toolbar = include( INCDIR . "/page-menu.php" );

$page->AddParam( "toolbar", $toolbar );
$page->AddParam( "userinfo", $userinfo );

/** filter stuff **/
$params = array(
	"caption" => "Search Users",
	"index" => "user",
	"fields" => array(
		"username" => array(
			"heading" => "Username",
			"type" => "text"
			)
		)
	);
$filter = include( INCDIR . "/filter.php" );
$tmpl->AddParam( "filter", $filter );

$rows =& $tmpl->AddParam( "rows", array() );

$offset = isset($_REQUEST["offset"]) ? intval( $_REQUEST["offset"] ) : 0 ;

$fields = array(
	"userid",
	"username",
	"postname",
	"email"
	);

$cond = array();

if ( isset($sess_filter["user"]) )
{
	$filter = $sess_filter["user"];
	if ( isset($filter["username"]) )
	{
		$username = addslashes(str_replace("*", "%", $filter["username"]));
		$like = strpos( $username, "%" ) === FALSE ? "=" : "LIKE";
		$cond[] = "username $like '$username'";
	}
}

$cond = join( " AND ", $cond );

$offset = isset($_REQUEST["offset"]) ? intval( $_REQUEST["offset"] ) : 0 ;
$ids = $DB->ListBy( TBL_USERS, $cond, $fields, "username DESC", 10, $offset );
$count_ids = $DB->CountBy( TBL_USERS, $cond, NULL, NULL, "userid" );

if ( is_array($ids) && count($ids) != 0 )
{
	foreach ( $ids as $id )
	{
		$rows[$id["userid"]] = array(
			"username" => $id["username"],
			"email" => $id["email"],
			"postname" => $id["postname"],
			"edit-link" => make_url_html( array("id"=>$id["userid"]), MAIN_SERVER . "/admin/edit-user" )
			);
	}
}

$pagemenu =& $tmpl->AddParam( "pagemenu", array() );

$pagemenu =& $tmpl->AddParam( "pagemenu", array() );
$page->BindParam( "pagemenu", $tmpl );

$params = array(
	"entry" => "\t<li>%s</li>\n\t",
	"separator" => "\t<li>|</li>\n\t",
	"links" => buildmenu( $theme_info["pagemenu_build"] )
	);
$params = array_merge( $params, $theme_info["pagemenu"] );
$pagemenu = include( INCDIR . "/page-menu.php" );

$tmpl->Pagination( $count_ids, $offset, 10 );

if ( USE_AJAX )
{
	header( "Content-Type: text/xml" );
	echo $tmpl->GetHTML();
	return;
}

$page->ParseContent( $tmpl->GetHTML() );
$page->ShowPage();

?>
Return current item: WB News