Location: PHPKode > projects > eqEpic > eqEpic0.7.8/seclist.php
<?php 
/******************************************************************************
* seclist.php                                                                 *
* Members List                                                                *
* See readme.txt for additional information                                   *
*******************************************************************************
* eqEpic - The Epic Raid Manager                                              *
* Open-Source Project By Ryan Christenson                                     *
* =========================================================================== *
* Software Version:           eqEpic 0.7.8                                    *
* Software by:                The RSWR Network (http://www.rswr.net)          *
* Copyright 2006-2007 by:     Ryan Christenson (http://www.rswr.net)          *
* Support, News, Updates at:  http://forum.rswr.net/                          *
*******************************************************************************
* This program is free software; you can redistribute it and/or modify        *
* it under the terms of the GNU General Public License as published by        *
* the Free Software Foundation; either version 2 of the License, or           *
* (at your option) any later version.                                         *
*                                                                             *
* This program is distributed in the hope that it will be useful,             *
* but WITHOUT ANY WARRANTY; without even the implied warranty of              *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               *
* GNU General Public License for more details.                                *
*                                                                             *
* You should have received a copy of the GNU General Public License           *
* along with DownloadCounter; if not, write to the Free Software              *
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   *
******************************************************************************/
session_start();
ob_start();
?>
<?php
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // Always modified
header("Cache-Control: private, no-store, no-cache, must-revalidate"); // HTTP/1.1 
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
?>
<?php include ("ewconfig.php") ?>
<?php include ("db.php") ?>
<?php include ("secinfo.php") ?>
<?php include ("advsecu.php") ?>
<?php include ("phpmkrfn.php") ?>
<?php
if (!IsLoggedIn() && (@$_COOKIE[ewCookieAutoLogin] == "autologin" && @$_COOKIE[ewCookiePassword] <> "")) {
	ob_end_clean();
	header("Location: login.php");
	exit();
}
LoadUserLevel();
$ewCurSec = (IsLoggedIn())? CurrentUserLevelPriv("sec") : GetAnonymousPriv("sec");	
if (($ewCurSec & ewAllowList) <> ewAllowList) {
	ob_end_clean();
	header("Location: login.php");
	exit();
}
if (IsLoggedIn() && CurrentUserID() == "") {
	ob_end_clean();
	header("Location: login.php");
	exit();
}
?>
<?php

// Initialize common variables
$x_id = NULL;
$ox_id = NULL;
$z_id = NULL;
$ar_x_id = NULL;
$ari_x_id = NULL;
$x_idList = NULL;
$x_idChk = NULL;
$cbo_x_id_js = NULL;
$x_user = NULL;
$ox_user = NULL;
$z_user = NULL;
$ar_x_user = NULL;
$ari_x_user = NULL;
$x_userList = NULL;
$x_userChk = NULL;
$cbo_x_user_js = NULL;
$x_pass = NULL;
$ox_pass = NULL;
$z_pass = NULL;
$ar_x_pass = NULL;
$ari_x_pass = NULL;
$x_passList = NULL;
$x_passChk = NULL;
$cbo_x_pass_js = NULL;
$x_email = NULL;
$ox_email = NULL;
$z_email = NULL;
$ar_x_email = NULL;
$ari_x_email = NULL;
$x_emailList = NULL;
$x_emailChk = NULL;
$cbo_x_email_js = NULL;
$x_UserLevel = NULL;
$ox_UserLevel = NULL;
$z_UserLevel = NULL;
$ar_x_UserLevel = NULL;
$ari_x_UserLevel = NULL;
$x_UserLevelList = NULL;
$x_UserLevelChk = NULL;
$cbo_x_UserLevel_js = NULL;
?>
<?php
$nStartRec = 0;
$nStopRec = 0;
$nTotalRecs = 0;
$nRecCount = 0;
$nRecActual = 0;
$sKeyMaster = "";
$sDbWhereMaster = "";
$sSrchAdvanced = "";
$psearch = "";
$psearchtype = "";
$sDbWhereDetail = "";
$sSrchBasic = "";
$sSrchWhere = "";
$sDbWhere = "";
$sOrderBy = "";
$sSqlMaster = "";
$sListTrJs = "";
$bEditRow = "";
$nEditRowCnt = "";
$sDeleteConfirmMsg = "";
$nDisplayRecs = "100";
$nRecRange = 10;

// Open connection to the database
$conn = phpmkr_db_connect(HOST, USER, PASS, DB, PORT);

// Handle reset command
ResetCmd();

// Set up inline edit parameters
$sAction = "";
SetUpInlineEdit($conn);

// Build filter condition
$sDbWhere = "";
if (($ewCurSec & ewAllowList) <> ewAllowList) {
	$sDbWhere = "(0=1)";
}
if ((CurrentUserID() <> "-1") And (CurrentUserID() <> "")) { // Non system admin
	if ($sDbWhere <> "") $sDbWhere .= " AND ";

	//$sDbWhere .= str_replace("#UserID", AdjustSql(CurrentUserID()), ewSqlUserIDFilter);
	$sDbWhere .= ewSqlUserIDFilter;
	$sDbWhere = str_replace("#Key", "`user`", $sDbWhere);
	$sDbWhere = str_replace("#UserID", AdjustSql(CurrentUserID()), $sDbWhere);
}
if ($sDbWhereDetail <> "") {
	if ($sDbWhere <> "") $sDbWhere .= " AND ";
	$sDbWhere .= "(" . $sDbWhereDetail . ")";
}
if ($sSrchWhere <> "") {
	if ($sDbWhere <> "") $sDbWhere .= " AND ";
	$sDbWhere .= "(" . $sSrchWhere . ")";
}

// Set up sorting order
$sOrderBy = "";
SetUpSortOrder();
$sSql = ewBuildSql(ewSqlSelect, ewSqlWhere, ewSqlGroupBy, ewSqlHaving, ewSqlOrderBy, $sDbWhere, $sOrderBy);

// echo $sSql . "<br />"; // Uncomment to show SQL for debugging
?>
<?php include ("sources/header.php") ?>
<script type="text/javascript">
<!--
EW_LookupFn = "ewlookup.php"; // ewlookup file name
EW_AddOptFn = "ewaddopt.php"; // ewaddopt.php file name

//-->
</script>
<script type="text/javascript" src="ewp.js"></script>
<script type="text/javascript">
<!--
EW_dateSep = "-"; // set date separator
EW_UploadAllowedFileExt = "gif,jpg,jpeg,bmp,png,doc,xls,pdf,zip"; // allowed upload file extension

//-->
</script>
<script type="text/javascript">
<!--
function EW_checkMyForm(EW_this) {
if (EW_this.x_user && !EW_hasValue(EW_this.x_user, "TEXT")) {
	if (!EW_onError(EW_this, EW_this.x_user, "TEXT", "Please Enter & Create a Username"))
		return false;
}
if (EW_this.x_pass && !EW_hasValue(EW_this.x_pass, "TEXT")) {
	if (!EW_onError(EW_this, EW_this.x_pass, "TEXT", "Please Enter & Create a Password"))
		return false;
}
if (EW_this.x_email && !EW_hasValue(EW_this.x_email, "TEXT")) {
	if (!EW_onError(EW_this, EW_this.x_email, "TEXT", "Please Enter User's E-mail Address"))
		return false;
}
if (EW_this.x_UserLevel && !EW_hasValue(EW_this.x_UserLevel, "SELECT")) {
	if (!EW_onError(EW_this, EW_this.x_UserLevel, "SELECT", "Please Select a User Level"))
		return false;
}
return true;
}

//-->
</script>
<script type="text/javascript">
<!--
var firstrowoffset = 1; // first data row start at
var tablename = 'ewlistmain'; // table name
var lastrowoffset = 0; // footer row
var usecss = true; // use css
var rowclass = 'ewTableRow'; // row class
var rowaltclass = 'ewTableAltRow'; // row alternate class
var rowmoverclass = 'ewTableHighlightRow'; // row mouse over class
var rowselectedclass = 'ewTableSelectRow'; // row selected class
var roweditclass = 'ewTableEditRow'; // row edit class
var rowcolor = '#353353'; // row color
var rowaltcolor = '#58558A'; // row alternate color
var rowmovercolor = '#B9B8D3'; // row mouse over color
var rowselectedcolor = '#B9B8D3'; // row selected color
var roweditcolor = '#B9B8D3'; // row edit color

//-->
</script>
<script type="text/javascript">
<!--
	var EW_DHTMLEditors = [];

//-->
</script>
<?php

// Set up recordset
$rs = phpmkr_query($sSql, $conn) or die("Failed to execute query at line " . __LINE__ . ": " . phpmkr_error($conn) . '<br />SQL: ' . $sSql);
$nTotalRecs = phpmkr_num_rows($rs);
if ($nDisplayRecs <= 0) { // Display all records
	$nDisplayRecs = $nTotalRecs;
}
$nStartRec = 1;
SetUpStartRec(); // Set up start record position
?>
<?php if (($ewCurSec & ewAllowAdd) == ewAllowAdd) { ?>
			<div class="rollover addbut">
			<a href="secadd.php"><img src="images/but_add.gif" alt="Add Member" border="0"/></a>
			</div>
<?php } ?>
<p>&nbsp;</p>
<?php
if (@$_SESSION[ewSessionMessage] <> "") {
?>
<p><div class="ewmsg"><?php echo $_SESSION[ewSessionMessage]; ?></div></p>
<?php
	$_SESSION[ewSessionMessage] = ""; // Clear message
}
?>
<?php if ($nTotalRecs > 0)  { ?>
<form name="fseclist" id="fseclist" action="seclist.php" method="post">
<table align="center" class="ewTable" id="ewlistmain">
	<!-- Table header -->
	<tr class="ewTableHeader">
		<td valign="bottom" align="center">
	<a href="seclist.php?order=<?php echo urlencode("id"); ?>" onmousedown="ewsort(event, this.href);">
	ID<?php if (@$_SESSION[ewSessionTblSort . "_x_id"] == "ASC") { ?><img src="images/sortup.gif" width="16" height="16" border="0"><?php } elseif (@$_SESSION[ewSessionTblSort . "_x_id"] == "DESC") { ?><img src="images/sortdown.gif" width="16" height="16" border="0"><?php } ?>
	</a>		</td>
		<td valign="bottom" align="center">
	<a href="seclist.php?order=<?php echo urlencode("user"); ?>" onmousedown="ewsort(event, this.href);">
	User<?php if (@$_SESSION[ewSessionTblSort . "_x_user"] == "ASC") { ?><img src="images/sortup.gif" width="16" height="16" border="0"><?php } elseif (@$_SESSION[ewSessionTblSort . "_x_user"] == "DESC") { ?><img src="images/sortdown.gif" width="16" height="16" border="0"><?php } ?>
	</a>		</td>
		<td valign="bottom" align="center">
	<a href="seclist.php?order=<?php echo urlencode("pass"); ?>" onmousedown="ewsort(event, this.href);">
	Pass<?php if (@$_SESSION[ewSessionTblSort . "_x_pass"] == "ASC") { ?><img src="images/sortup.gif" width="16" height="16" border="0"><?php } elseif (@$_SESSION[ewSessionTblSort . "_x_pass"] == "DESC") { ?><img src="images/sortdown.gif" width="16" height="16" border="0"><?php } ?>
	</a>		</td>
		<td valign="bottom" align="center">
	<a href="seclist.php?order=<?php echo urlencode("email"); ?>" onmousedown="ewsort(event, this.href);">
	E-mail<?php if (@$_SESSION[ewSessionTblSort . "_x_email"] == "ASC") { ?><img src="images/sortup.gif" width="16" height="16" border="0"><?php } elseif (@$_SESSION[ewSessionTblSort . "_x_email"] == "DESC") { ?><img src="images/sortdown.gif" width="16" height="16" border="0"><?php } ?>
	</a>		</td>
		<td valign="bottom" align="center">
	<a href="seclist.php?order=<?php echo urlencode("UserLevel"); ?>" onmousedown="ewsort(event, this.href);">
	User Level<?php if (@$_SESSION[ewSessionTblSort . "_x_UserLevel"] == "ASC") { ?><img src="images/sortup.gif" width="16" height="16" border="0"><?php } elseif (@$_SESSION[ewSessionTblSort . "_x_UserLevel"] == "DESC") { ?><img src="images/sortdown.gif" width="16" height="16" border="0"><?php } ?>
	</a>		</td>
<?php if (($ewCurSec & ewAllowEdit) == ewAllowEdit) { ?>
<td>&nbsp;</td>
<?php } ?>
<?php if (($ewCurSec & ewAllowDelete) == ewAllowDelete) { ?>
<td>&nbsp;</td>
<?php } ?>
	</tr>
<?php

// Set the last record to display
$nStopRec = $nStartRec + $nDisplayRecs - 1;

// Move to the first record
$nRecCount = $nStartRec - 1;
if (phpmkr_num_rows($rs) > 0) {
	phpmkr_data_seek($rs, $nStartRec -1);
}
$nEditRowCnt = 0;
$nRecActual = 0;
while (($row = @phpmkr_fetch_array($rs)) && ($nRecCount < $nStopRec)) {
	$nRecCount = $nRecCount + 1;
	if ($nRecCount >= $nStartRec) {
		$nRecActual++;

		// Set row color
		$sItemRowClass = " class=\"ewTableRow\"";
		$sListTrJs = " onmouseover='ew_mouseover(this);' onmouseout='ew_mouseout(this);' onclick='ew_click(this);'";

		// Display alternate color for rows
		if ($nRecCount % 2 <> 1) {
			$sItemRowClass = " class=\"ewTableAltRow\"";
		}
		$x_id = $row["id"];
		$x_user = $row["user"];
		$x_pass = $row["pass"];
		$x_email = $row["email"];
		$x_UserLevel = $row["UserLevel"];
	$bEditRow = (($_SESSION[ewSessionTblKey ."_id"] == ((get_magic_quotes_gpc())? stripslashes($x_id) : $x_id)) && ($nEditRowCnt == 0));
	if ($bEditRow) {
		$nEditRowCnt++;
		$sItemRowClass = " class=\"ewTableEditRow\"";
		$sListTrJs = " onmouseover='this.edit=true;ew_mouseover(this);' onmouseout='ew_mouseout(this);' onclick='ew_click(this);'";
	}
?>
	<!-- Table body -->
	<tr<?php echo $sItemRowClass; ?><?php echo $sListTrJs; ?>>
		<!-- id -->
		<td>
<?php if ($bEditRow) { // Edit record ?>
<?php echo $x_id; ?><input type="hidden" id="x_id" name="x_id" value="<?php echo @$x_id; ?>" />
<?php }else{ ?>
<?php echo $x_id; ?>
<?php } ?>
</td>
		<!-- user -->
		<td>
<?php if ($bEditRow) { // Edit record ?>
<?php if (CurrentUserID() == -1) { // System admin ?>
<input type="text" name="x_user" id="x_user" size="30" maxlength="20" value="<?php echo htmlspecialchars(@$x_user) ?>" />
<?php } else { // Non system admin ?>
<?php $x_user = stripslashes($_SESSION["eqplan_status_UserID"]); ?>
<?php echo $x_user; ?>
<input type="hidden" id="x_user" name="x_user" value="<?php echo $x_user; ?>" />
<?php } ?>
<?php }else{ ?>
<?php echo $x_user; ?>
<?php } ?>
</td>
		<!-- pass -->
		<td>
<?php if ($bEditRow) { // Edit record ?>
<input type="text" name="x_pass" id="x_pass" size="30" maxlength="20" value="<?php echo htmlspecialchars(@$x_pass) ?>" />
<?php }else{ ?>
<?php echo $x_pass; ?>
<?php } ?>
</td>
		<!-- email -->
		<td>
<?php if ($bEditRow) { // Edit record ?>
<input type="text" name="x_email" id="x_email" size="30" maxlength="255" value="<?php echo htmlspecialchars(@$x_email) ?>" />
<?php }else{ ?>
<?php echo $x_email; ?>
<?php } ?>
</td>
		<!-- UserLevel -->
		<td>
<?php if ($bEditRow) { // Edit record ?>
<?php if (($ewCurSec & ewAllowAdmin) == ewAllowAdmin) { // System admin ?>
<?php
$x_UserLevelList = "<select id='x_UserLevel' name='x_UserLevel'>";
$x_UserLevelList .= "<option value=''>Please Select</option>";
	$x_UserLevelList .= "<option value=\"-1\"";
	if (@$x_UserLevel == "-1") {
		$x_UserLevelList .= " selected";
	}
	$x_UserLevelList .= ">" . "Administrator" . "</option>";
	$x_UserLevelList .= "<option value=\"0\"";
	if (@$x_UserLevel == "0") {
		$x_UserLevelList .= " selected";
	}
	$x_UserLevelList .= ">" . "Anonymous" . "</option>";
	$x_UserLevelList .= "<option value=\"1\"";
	if (@$x_UserLevel == "1") {
		$x_UserLevelList .= " selected";
	}
	$x_UserLevelList .= ">" . "Normal" . "</option>";
$x_UserLevelList .= "</select>";
echo $x_UserLevelList;
?>
<?php } else { ?>
********
<?php } ?>
<?php }else{ ?>
<?php if (($ewCurSec & ewAllowAdmin) == ewAllowAdmin) { // System admin ?>
<?php
switch ($x_UserLevel) {
	case "-1":
		$sTmp = "Administrator";
		break;
	case "0":
		$sTmp = "Anonymous";
		break;
	case "1":
		$sTmp = "Normal";
		break;
	default:
		$sTmp = "";
}
$ox_UserLevel = $x_UserLevel; // Backup original value
$x_UserLevel = $sTmp;
?>
<?php echo $x_UserLevel; ?>
<?php $x_UserLevel = $ox_UserLevel; // Restore original value ?>
<?php } else {?>
********
<?php } ?>
<?php } ?>
</td>
<?php if (($ewCurSec & ewAllowEdit) == ewAllowEdit) { ?>
<td><span class="phpmaker">
<?php if ($_SESSION[ewSessionTblKey ."_id"] == ((get_magic_quotes_gpc())? stripslashes($x_id) : $x_id)) { ?>
	<a href="" onClick="if (EW_checkMyForm(document.fseclist)) document.fseclist.submit();return false;">Update</a>&nbsp;<a href="seclist.php?a=cancel">Cancel</a>
	<input type="hidden" name="a_list" value="update" />
<?php } else { ?>
	<a href="<?php if ($x_id <> "") {echo "seclist.php?a=edit&id=" . urlencode($x_id); } else { echo "javascript:alert('Invalid Record! Key is null');";} ?>">Edit</a>
<?php } ?>
</span></td>
<?php } ?>
<?php if (($ewCurSec & ewAllowDelete) == ewAllowDelete) { ?>
<td><span class="phpmaker"><a href="<?php if ($x_id <> "") {echo "secdelete.php?id=" . urlencode($x_id); } else { echo "javascript:alert('Invalid Record! Key is null');";} ?>">Delete</a></span></td>
<?php } ?>
	</tr>
<?php
	}
}
?>
</table>
</form>
<?php if (strtolower($sAction) == "edit") { ?>
<?php } ?>
<?php 
}

// Close recordset and connection
phpmkr_free_result($rs);
phpmkr_db_close($conn);
?>
<form action="seclist.php" name="ewpagerform" id="ewpagerform">
<table align="center" class="ewTable">
	<tr>
		<td>
		<span class="phpmaker">
<?php

// Display page numbers
if ($nTotalRecs > 0) {
	$rsEof = ($nTotalRecs < ($nStartRec + $nDisplayRecs));
	if ($nTotalRecs > $nDisplayRecs) {

		// Find out if there should be Prev/Next links
		if ($nStartRec == 1) {
			$isPrev = False;
		} else {
			$isPrev = True;
			$PrevStart = $nStartRec - $nDisplayRecs;
			if ($PrevStart < 1) { $PrevStart = 1; } ?>
		<a href="seclist.php?start=<?php echo $PrevStart; ?>"><b>Prev</b></a>
		<?php
		}
		if ($isPrev || (!$rsEof)) {
			$x = 1;
			$y = 1;
			$dx1 = intval(($nStartRec-1)/($nDisplayRecs*$nRecRange))*$nDisplayRecs*$nRecRange+1;
			$dy1 = intval(($nStartRec-1)/($nDisplayRecs*$nRecRange))*$nRecRange+1;
			if (($dx1+$nDisplayRecs*$nRecRange-1) > $nTotalRecs) {
				$dx2 = intval($nTotalRecs/$nDisplayRecs)*$nDisplayRecs+1;
				$dy2 = intval($nTotalRecs/$nDisplayRecs)+1;
			} else {
				$dx2 = $dx1+$nDisplayRecs*$nRecRange-1;
				$dy2 = $dy1+$nRecRange-1;
			}
			while ($x <= $nTotalRecs) {
				if (($x >= $dx1) && ($x <= $dx2)) {
					if ($nStartRec == $x) { ?>
		<b><?php echo $y; ?></b>
					<?php } else { ?>
		<a href="seclist.php?start=<?php echo $x; ?>"><b><?php echo $y; ?></b></a>
					<?php }
					$x += $nDisplayRecs;
					$y += 1;
				} elseif (($x >= ($dx1-$nDisplayRecs*$nRecRange)) && ($x <= ($dx2+$nDisplayRecs*$nRecRange))) {
					if ($x+$nRecRange*$nDisplayRecs < $nTotalRecs) { ?>
		<a href="seclist.php?start=<?php echo $x; ?>"><b><?php echo $y; ?>-<?php echo ($y+$nRecRange-1);?></b></a>
					<?php } else {
						$ny=intval(($nTotalRecs-1)/$nDisplayRecs)+1;
							if ($ny == $y) { ?>
		<a href="seclist.php?start=<?php echo $x; ?>"><b><?php echo $y; ?></b></a>
							<?php } else { ?>
		<a href="seclist.php?start=<?php echo $x; ?>"><b><?php echo $y; ?>-<?php echo $ny; ?></b></a>
							<?php }
					}
					$x += $nRecRange*$nDisplayRecs;
					$y += $nRecRange;
				} else {
					$x += $nRecRange*$nDisplayRecs;
					$y += $nRecRange;
				}
			}
		}

		// Next link
		if (!$rsEof) {
			$NextStart = $nStartRec + $nDisplayRecs;
			$isMore = True;  ?>
		<a href="seclist.php?start=<?php echo $NextStart; ?>"><b>Next</b></a>
		<?php } else {
			$isMore = False;
		} ?>
		<br />
<?php	}
	if ($nStartRec > $nTotalRecs) { $nStartRec = $nTotalRecs; }
	$nStopRec = $nStartRec + $nDisplayRecs - 1;
	$nRecCount = $nTotalRecs - 1;
	if ($rsEof) { $nRecCount = $nTotalRecs; }
	if ($nStopRec > $nRecCount) { $nStopRec = $nRecCount; } ?>
	Users <?php echo  $nStartRec;  ?> to <?php  echo $nStopRec; ?> of <?php echo  $nTotalRecs; ?>
<?php } else { ?>
	<?php if (($ewCurSec & ewAllowList) == ewAllowList) { ?>
	<?php if ($sSrchWhere == "0=101") {?>
	<?php } else { ?>
	No Users Found
	<?php } ?>
	<?php } else { ?>
	You do not have the correct permissions to view this page
	<?php } ?>
<?php }?>
		</span>
		</td>
	</tr>
</table>
</form>
<?php include ("footer.php") ?>
<?php

//-------------------------------------------------------------------------------
// Function SetUpInlineEdit
// - Set up Inline Edit parameters based on querystring parameters a & key
// - Variables setup: sAction, sKey, Session(TblKeyName)

function SetUpInlineEdit($conn)
{
	global $x_id;
	global $bInlineEdit;
	global $sAction;
	global $ewCurSec;

	// Get the keys for master table
	if (strlen(@$_GET["a"]) > 0) {
		$sAction = @$_GET["a"];
		if (strtolower($sAction) == "edit") { // Change to Inline Edit Mode
			if(($ewCurSec & ewAllowEdit) <> ewAllowEdit) {
			ob_end_clean();
			header("Location: login.php");
			exit();
			}
			$bInlineEdit = true;
			if (strlen(@$_GET["id"]) > 0) {
				$x_id = $_GET["id"];
			} else {
				$bInlineEdit = false;
			}
			if ($bInlineEdit) {
				if (LoadData($conn)) {
					$_SESSION[ewSessionTblKey . "_id"] = $x_id; // Set up Inline Edit key
				}
			}
		} elseif (strtolower($sAction) == "cancel") { // Switch out of Inline Edit Mode
			$_SESSION[ewSessionTblKey . "_id"] = ""; // Clear Inline Edit key
		}
	} else {
		$sAction = @$_POST["a_list"];
		if (strtolower($sAction) == "update") { // Update Record

			// Get fields from form
			$GLOBALS["x_id"] = @$_POST["x_id"];
			$GLOBALS["x_user"] = @$_POST["x_user"];
			$GLOBALS["x_pass"] = @$_POST["x_pass"];
			$GLOBALS["x_email"] = @$_POST["x_email"];
			$GLOBALS["x_UserLevel"] = @$_POST["x_UserLevel"];
			if ($_SESSION[ewSessionTblKey ."_id"] == ((get_magic_quotes_gpc())? stripslashes($x_id) : $x_id)) {
				if (InlineEditData($conn)) {
					$_SESSION[ewSessionMessage] = "Updated Member Successfully";
				}
			}
		}
		$_SESSION[ewSessionTblKey . "_id"] = ""; // Clear Inline Edit key
	}
}

//-------------------------------------------------------------------------------
// Function ResetSearch
// - Clear all search parameters

function ResetSearch() 
{

	// Clear search where
	$sSrchWhere = "";
	$_SESSION[ewSessionTblSearchWhere] = $sSrchWhere;

	// Clear advanced search parameters
	$_SESSION[ewSessionTblAdvSrch . "_x_id"] = "";
	$_SESSION[ewSessionTblAdvSrch . "_x_user"] = "";
	$_SESSION[ewSessionTblAdvSrch . "_x_pass"] = "";
	$_SESSION[ewSessionTblAdvSrch . "_x_email"] = "";
	$_SESSION[ewSessionTblAdvSrch . "_x_UserLevel"] = "";
	$_SESSION[ewSessionTblBasicSrch] = "";
	$_SESSION[ewSessionTblBasicSrchType] = "";
}

//-------------------------------------------------------------------------------
// Function RestoreSearch
// - Restore all search parameters
//

function RestoreSearch()
{

	// Restore advanced search settings
	$GLOBALS["x_id"] = @$_SESSION[ewSessionTblAdvSrch . "_x_id"];
	$GLOBALS["x_user"] = @$_SESSION[ewSessionTblAdvSrch . "_x_user"];
	$GLOBALS["x_pass"] = @$_SESSION[ewSessionTblAdvSrch . "_x_pass"];
	$GLOBALS["x_email"] = @$_SESSION[ewSessionTblAdvSrch . "_x_email"];
	$GLOBALS["x_UserLevel"] = @$_SESSION[ewSessionTblAdvSrch . "_x_UserLevel"];
	$GLOBALS["psearch"] = @$_SESSION[ewSessionTblBasicSrch];
	$GLOBALS["psearchtype"] = @$_SESSION[ewSessionTblBasicSrchType];
}

//-------------------------------------------------------------------------------
// Function SetUpSortOrder
// - Set up Sort parameters based on Sort Links clicked
// - Variables setup: sOrderBy, Session(TblOrderBy), Session(Tbl_Field_Sort)

function SetUpSortOrder()
{
	global $sOrderBy;
	global $sDefaultOrderBy;

	// Check for Ctrl pressed
	if (strlen(@$_GET["ctrl"]) > 0) {
		$bCtrl = true;
	} else {
		$bCtrl = false;
	}

	// Check for an Order parameter
	if (strlen(@$_GET["order"]) > 0) {
		$sOrder = @$_GET["order"];

		// Field `id`
		if ($sOrder == "id") {
			$sSortField = "`id`";
			$sLastSort = @$_SESSION[ewSessionTblSort . "_x_id"];
			$sThisSort = ($sLastSort == "ASC") ? "DESC" : "ASC";
			$_SESSION[ewSessionTblSort . "_x_id"] = $sThisSort;
		} else {
			if (!($bCtrl) && @$_SESSION[ewSessionTblSort . "_x_id"] <> "") { $_SESSION[ewSessionTblSort . "_x_id"] = "" ; }
		}

		// Field `user`
		if ($sOrder == "user") {
			$sSortField = "`user`";
			$sLastSort = @$_SESSION[ewSessionTblSort . "_x_user"];
			$sThisSort = ($sLastSort == "ASC") ? "DESC" : "ASC";
			$_SESSION[ewSessionTblSort . "_x_user"] = $sThisSort;
		} else {
			if (!($bCtrl) && @$_SESSION[ewSessionTblSort . "_x_user"] <> "") { $_SESSION[ewSessionTblSort . "_x_user"] = "" ; }
		}

		// Field `pass`
		if ($sOrder == "pass") {
			$sSortField = "`pass`";
			$sLastSort = @$_SESSION[ewSessionTblSort . "_x_pass"];
			$sThisSort = ($sLastSort == "ASC") ? "DESC" : "ASC";
			$_SESSION[ewSessionTblSort . "_x_pass"] = $sThisSort;
		} else {
			if (!($bCtrl) && @$_SESSION[ewSessionTblSort . "_x_pass"] <> "") { $_SESSION[ewSessionTblSort . "_x_pass"] = "" ; }
		}

		// Field `email`
		if ($sOrder == "email") {
			$sSortField = "`email`";
			$sLastSort = @$_SESSION[ewSessionTblSort . "_x_email"];
			$sThisSort = ($sLastSort == "ASC") ? "DESC" : "ASC";
			$_SESSION[ewSessionTblSort . "_x_email"] = $sThisSort;
		} else {
			if (!($bCtrl) && @$_SESSION[ewSessionTblSort . "_x_email"] <> "") { $_SESSION[ewSessionTblSort . "_x_email"] = "" ; }
		}

		// Field `UserLevel`
		if ($sOrder == "UserLevel") {
			$sSortField = "`UserLevel`";
			$sLastSort = @$_SESSION[ewSessionTblSort . "_x_UserLevel"];
			$sThisSort = ($sLastSort == "ASC") ? "DESC" : "ASC";
			$_SESSION[ewSessionTblSort . "_x_UserLevel"] = $sThisSort;
		} else {
			if (!($bCtrl) && @$_SESSION[ewSessionTblSort . "_x_UserLevel"] <> "") { $_SESSION[ewSessionTblSort . "_x_UserLevel"] = "" ; }
		}
		if ($bCtrl) {
			$sOrderBy = @$_SESSION[ewSessionTblOrderBy];
			$pos = strpos($sOrderBy, $sSortField . " " . $sLastSort);
			if ($pos === false) {
				if ($sOrderBy <> "") { $sOrderBy .= ", "; }
				$sOrderBy .= $sSortField . " " . $sThisSort;
			} else {
				$sOrderBy = str_replace($sSortField . " " . $sLastSort, $sSortField . " " . $sThisSort, $sOrderBy);
			}
			$_SESSION[ewSessionTblOrderBy] = $sOrderBy;
		} else {
			$_SESSION[ewSessionTblOrderBy] = $sSortField . " " . $sThisSort;
		}
		$_SESSION[ewSessionTblStartRec] = 1;
	}
	$sOrderBy = @$_SESSION[ewSessionTblOrderBy];
	if ($sOrderBy == "") {
		if (ewSqlOrderBy <> "" && ewSqlOrderBySessions <> "") {
			$sOrderBy = ewSqlOrderBy;
			@$_SESSION[ewSessionTblOrderBy] = $sOrderBy;
			$arOrderBy = explode(",", ewSqlOrderBySessions);
			for($i=0; $i<count($arOrderBy); $i+=2) {
				@$_SESSION[ewSessionTblSort . "_" . $arOrderBy[$i]] = $arOrderBy[$i+1];
			}
		}
	}
}

//-------------------------------------------------------------------------------
// Function SetUpStartRec
//- Set up Starting Record parameters based on Pager Navigation
// - Variables setup: nStartRec

function SetUpStartRec()
{

	// Check for a START parameter
	global $nStartRec;
	global $nDisplayRecs;
	global $nTotalRecs;
	if (strlen(@$_GET[ewTblStartRec]) > 0) {
		$nStartRec = @$_GET[ewTblStartRec];
		$_SESSION[ewSessionTblStartRec] = $nStartRec;
	} elseif (strlen(@$_GET["pageno"]) > 0) {
		$nPageNo = @$_GET["pageno"];
		if (is_numeric($nPageNo)) {
			$nStartRec = ($nPageNo-1)*$nDisplayRecs+1;
			if ($nStartRec <= 0) {
				$nStartRec = 1;
			} elseif ($nStartRec >= intval(($nTotalRecs-1)/$nDisplayRecs)*$nDisplayRecs+1) {
				$nStartRec = intval(($nTotalRecs-1)/$nDisplayRecs)*$nDisplayRecs+1;
			}
			$_SESSION[ewSessionTblStartRec] = $nStartRec;
		} else {
			$nStartRec = @$_SESSION[ewSessionTblStartRec];
		}
	} else {
		$nStartRec = @$_SESSION[ewSessionTblStartRec];
	}

	// Check if correct start record counter
	if (!(is_numeric($nStartRec)) || ($nStartRec == "")) { // Avoid invalid start record counter
		$nStartRec = 1; // Reset start record counter
		$_SESSION[ewSessionTblStartRec] = $nStartRec;
	} elseif ($nStartRec > $nTotalRecs) { // Avoid starting record > total records
		$nStartRec = intval(($nTotalRecs-1)/$nDisplayRecs)*$nDisplayRecs+1; // Point to last page first record
		$_SESSION[ewSessionTblStartRec] = $nStartRec;
	}
}

//-------------------------------------------------------------------------------
// Function ResetCmd
// - Clear list page parameters
// - RESET: reset search parameters
// - RESETALL: reset search & master/detail parameters
// - RESETSORT: reset sort parameters

function ResetCmd()
{

	// Get Reset command
	if (strlen(@$_GET["cmd"]) > 0) {
		$sCmd = @$_GET["cmd"];
		if (strtolower($sCmd) == "reset") { // Reset search criteria
			ResetSearch();
		} elseif (strtolower($sCmd) == "resetall") { // Reset search criteria and session vars
			ResetSearch();
		} elseif (strtolower($sCmd) == "resetsort") { // Reset sort criteria
			$sOrderBy = "";
			$_SESSION[ewSessionTblOrderBy] = $sOrderBy;
			if (@$_SESSION[ewSessionTblSort . "_x_id"] <> "") { $_SESSION[ewSessionTblSort . "_x_id"] = ""; }
			if (@$_SESSION[ewSessionTblSort . "_x_user"] <> "") { $_SESSION[ewSessionTblSort . "_x_user"] = ""; }
			if (@$_SESSION[ewSessionTblSort . "_x_pass"] <> "") { $_SESSION[ewSessionTblSort . "_x_pass"] = ""; }
			if (@$_SESSION[ewSessionTblSort . "_x_email"] <> "") { $_SESSION[ewSessionTblSort . "_x_email"] = ""; }
			if (@$_SESSION[ewSessionTblSort . "_x_UserLevel"] <> "") { $_SESSION[ewSessionTblSort . "_x_UserLevel"] = ""; }
		}

		// Reset start position (Reset command)
		$nStartRec = 1;
		$_SESSION[ewSessionTblStartRec] = $nStartRec;
	}
}
?>
<?php

//-------------------------------------------------------------------------------
// Function LoadData
// - Variables setup: field variables

function LoadData($conn)
{
	global $x_id;
	$sFilter = ewSqlKeyWhere;
	if (!is_numeric($x_id)) return false;
	$x_id =  (get_magic_quotes_gpc()) ? stripslashes($x_id) : $x_id;
	$sFilter = str_replace("@id", AdjustSql($x_id), $sFilter); // Replace key value
	if ((CurrentUserID() <> "-1") && (CurrentUserID() <> "")) {

	//$sFilter .= " AND " . str_replace("#UserID", AdjustSql(CurrentuserID()), ewSqlUserIDFilter);
	$sFilter .= " AND " . ewSqlUserIDFilter;
	$sFilter = str_replace("#Key", "`user`", $sFilter);
	$sFilter = str_replace("#UserID", AdjustSql(CurrentUserID()), $sFilter);
	}
	$sSql = ewBuildSql(ewSqlSelect, ewSqlWhere, ewSqlGroupBy, ewSqlHaving, ewSqlOrderBy, $sFilter, "");
	$rs = phpmkr_query($sSql,$conn) or die("Failed to execute query at line " . __LINE__ . ": " . phpmkr_error($conn) . '<br />SQL: ' . $sSql);
	if (phpmkr_num_rows($rs) == 0) {
		$bLoadData = false;
	} else {
		$bLoadData = true;
		$row = phpmkr_fetch_array($rs);

		// Get the field contents
		$GLOBALS["x_id"] = $row["id"];
		$GLOBALS["x_user"] = $row["user"];
		$GLOBALS["x_pass"] = $row["pass"];
		$GLOBALS["x_email"] = $row["email"];
		$GLOBALS["x_UserLevel"] = $row["UserLevel"];
	}
	phpmkr_free_result($rs);
	return $bLoadData;
}
?>
<?php

//-------------------------------------------------------------------------------
// Function EditData
// - Variables used: field variables

function InlineEditData($conn)
{
	global $x_id;
	$sFilter = ewSqlKeyWhere;
	if (!is_numeric($x_id)) return false;
	$sTmp =  (get_magic_quotes_gpc()) ? stripslashes($x_id) : $x_id;
	$sFilter = str_replace("@id", AdjustSql($sTmp), $sFilter); // Replace key value
	if ((CurrentUserID() <> "-1") && (CurrentUserID() <> "")) { // Non system admin

	//$sFilter .= " AND " . str_replace("#UserID", AdjustSql(CurrentUserID()), ewSqlUserIDFilter);
	$sFilter .= " AND " . ewSqlUserIDFilter;
	$sFilter = str_replace("#Key", "`user`", $sFilter);
	$sFilter = str_replace("#UserID", AdjustSql(CurrentUserID()), $sFilter);
	}
	$sSql = ewBuildSql(ewSqlSelect, ewSqlWhere, ewSqlGroupBy, ewSqlHaving, ewSqlOrderBy, $sFilter, "");
	$rs = phpmkr_query($sSql,$conn) or die("Failed to execute query at line " . __LINE__ . ": " . phpmkr_error($conn) . '<br />SQL: ' . $sSql);

	// Get old recordset
	$oldrs = phpmkr_fetch_array($rs);
	if (phpmkr_num_rows($rs) == 0) {
		return false; // Update Failed
	} else {
		$x_id = @$_POST["x_id"];
		$x_user = @$_POST["x_user"];
		$x_pass = @$_POST["x_pass"];
		$x_email = @$_POST["x_email"];
		$x_UserLevel = @$_POST["x_UserLevel"];
		$theValue = (!get_magic_quotes_gpc()) ? addslashes($GLOBALS["x_user"]) : $GLOBALS["x_user"]; 
		$theValue = ($theValue != "") ? " '" . $theValue . "'" : "NULL";
		$fieldList["`user`"] = $theValue;
		$theValue = (!get_magic_quotes_gpc()) ? addslashes($GLOBALS["x_pass"]) : $GLOBALS["x_pass"]; 
		$theValue = ($theValue != "") ? " '" . $theValue . "'" : "NULL";
		$fieldList["`pass`"] = $theValue;
		$theValue = (!get_magic_quotes_gpc()) ? addslashes($GLOBALS["x_email"]) : $GLOBALS["x_email"]; 
		$theValue = ($theValue != "") ? " '" . $theValue . "'" : "NULL";
		$fieldList["`email`"] = $theValue;
		$theValue = ($GLOBALS["x_UserLevel"] != "") ? intval($GLOBALS["x_UserLevel"]) : "NULL";
		$fieldList["`UserLevel`"] = $theValue;

		// Updating event
		if (Recordset_Updating($fieldList, $oldrs)) {

			// Update
			$sSql = "UPDATE `sec` SET ";
			foreach ($fieldList as $key=>$temp) {
				$sSql .= "$key = $temp, ";
			}
			if (substr($sSql, -2) == ", ") {
				$sSql = substr($sSql, 0, strlen($sSql)-2);
			}
			$sSql .= " WHERE " . $sFilter;
			phpmkr_query($sSql,$conn) or die("Failed to execute query at line " . __LINE__ . ": " . phpmkr_error($conn) . '<br />SQL: ' . $sSql);
			$result = (phpmkr_affected_rows($conn) >= 0);

			// Updated event
			if ($result) Recordset_Updated($fieldList, $oldrs);
		} else {
			$result = false; // Update Failed
		}
	}
	return $result;
}

// Updating Event
function Recordset_Updating(&$newrs, $oldrs)
{

	// Enter your customized codes here
	return true;
}

// Updated event
function Recordset_Updated($newrs, $oldrs)
{
	$table = "sec";
}
?>
Return current item: eqEpic