<?php
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 ("stepsinfo.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("steps") : GetAnonymousPriv("steps");
if (($ewCurSec & ewAllowList) <> ewAllowList) {
ob_end_clean();
header("Location: login.php");
exit();
}
?>
<?php
// Initialize common variables
$x_class = NULL;
$ox_class = NULL;
$z_class = NULL;
$ar_x_class = NULL;
$ari_x_class = NULL;
$x_classList = NULL;
$x_classChk = NULL;
$cbo_x_class_js = NULL;
$x_step = NULL;
$ox_step = NULL;
$z_step = NULL;
$ar_x_step = NULL;
$ari_x_step = NULL;
$x_stepList = NULL;
$x_stepChk = NULL;
$cbo_x_step_js = NULL;
$x_descrip = NULL;
$ox_descrip = NULL;
$z_descrip = NULL;
$ar_x_descrip = NULL;
$ari_x_descrip = NULL;
$x_descripList = NULL;
$x_descripChk = NULL;
$cbo_x_descrip_js = NULL;
$x_num_grp = NULL;
$ox_num_grp = NULL;
$z_num_grp = NULL;
$ar_x_num_grp = NULL;
$ari_x_num_grp = NULL;
$x_num_grpList = NULL;
$x_num_grpChk = NULL;
$cbo_x_num_grp_js = NULL;
$x_zone = NULL;
$ox_zone = NULL;
$z_zone = NULL;
$ar_x_zone = NULL;
$ari_x_zone = NULL;
$x_zoneList = NULL;
$x_zoneChk = NULL;
$cbo_x_zone_js = NULL;
$x_chest = NULL;
$ox_chest = NULL;
$z_chest = NULL;
$ar_x_chest = NULL;
$ari_x_chest = NULL;
$x_chestList = NULL;
$x_chestChk = NULL;
$cbo_x_chest_js = NULL;
$x_mob_url = NULL;
$ox_mob_url = NULL;
$z_mob_url = NULL;
$ar_x_mob_url = NULL;
$ari_x_mob_url = NULL;
$x_mob_urlList = NULL;
$x_mob_urlChk = NULL;
$cbo_x_mob_url_js = NULL;
$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;
?>
<?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 ($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_class && !EW_hasValue(EW_this.x_class, "SELECT")) {
if (!EW_onError(EW_this, EW_this.x_class, "SELECT", "Please Choose a Class"))
return false;
}
if (EW_this.x_step && !EW_hasValue(EW_this.x_step, "TEXT")) {
if (!EW_onError(EW_this, EW_this.x_step, "TEXT", "Please Edit the current Step with Information"))
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="stepsadd.php"><img src="images/but_add.gif" alt="Add Member" border="0"/></a>
</div>
<?php } ?>
<p> </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="fstepslist" id="fstepslist" action="stepslist.php" method="post">
<table align="center" class="ewTable" id="ewlistmain">
<!-- Table header -->
<tr class="ewTableHeader">
<td valign="bottom" align="center">
<a href="stepslist.php?order=<?php echo urlencode("class"); ?>" onmousedown="ewsort(event, this.href);">
Class<?php if (@$_SESSION[ewSessionTblSort . "_x_class"] == "ASC") { ?><img src="images/sortup.gif" width="16" height="16" border="0"><?php } elseif (@$_SESSION[ewSessionTblSort . "_x_class"] == "DESC") { ?><img src="images/sortdown.gif" width="16" height="16" border="0"><?php } ?>
</a> </td>
<td valign="bottom" align="center">
<a href="stepslist.php?order=<?php echo urlencode("step"); ?>" onmousedown="ewsort(event, this.href);">
Step<?php if (@$_SESSION[ewSessionTblSort . "_x_step"] == "ASC") { ?><img src="images/sortup.gif" width="16" height="16" border="0"><?php } elseif (@$_SESSION[ewSessionTblSort . "_x_step"] == "DESC") { ?><img src="images/sortdown.gif" width="16" height="16" border="0"><?php } ?>
</a> </td>
<td valign="bottom" align="center">
<a href="stepslist.php?order=<?php echo urlencode("num_grp"); ?>" onmousedown="ewsort(event, this.href);">
Number of Groups<?php if (@$_SESSION[ewSessionTblSort . "_x_num_grp"] == "ASC") { ?><img src="images/sortup.gif" width="16" height="16" border="0"><?php } elseif (@$_SESSION[ewSessionTblSort . "_x_num_grp"] == "DESC") { ?><img src="images/sortdown.gif" width="16" height="16" border="0"><?php } ?>
</a> </td>
<td valign="bottom" align="center">
<a href="stepslist.php?order=<?php echo urlencode("zone"); ?>" onmousedown="ewsort(event, this.href);">
Zone<?php if (@$_SESSION[ewSessionTblSort . "_x_zone"] == "ASC") { ?><img src="images/sortup.gif" width="16" height="16" border="0"><?php } elseif (@$_SESSION[ewSessionTblSort . "_x_zone"] == "DESC") { ?><img src="images/sortdown.gif" width="16" height="16" border="0"><?php } ?>
</a> </td>
<td valign="bottom" align="center">
<a href="stepslist.php?order=<?php echo urlencode("chest"); ?>" onmousedown="ewsort(event, this.href);">
Chest<?php if (@$_SESSION[ewSessionTblSort . "_x_chest"] == "ASC") { ?><img src="images/sortup.gif" width="16" height="16" border="0"><?php } elseif (@$_SESSION[ewSessionTblSort . "_x_chest"] == "DESC") { ?><img src="images/sortdown.gif" width="16" height="16" border="0"><?php } ?>
</a> </td>
<?php if (($ewCurSec & ewAllowEdit) == ewAllowEdit) { ?>
<td> </td>
<?php } ?>
<?php if (($ewCurSec & ewAllowEdit) == ewAllowEdit) { ?>
<td> </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_class = $row["class"];
$x_step = $row["step"];
$x_descrip = $row["descrip"];
$x_num_grp = $row["num_grp"];
$x_zone = $row["zone"];
$x_chest = $row["chest"];
$x_mob_url = $row["mob_url"];
$x_id = $row["id"];
$bEditRow = (($_SESSION[ewSessionTblKey ."_step"] == ((get_magic_quotes_gpc())? stripslashes($x_step) : $x_step)) && ($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; ?>>
<!-- class -->
<td>
<?php if ($bEditRow) { // Edit record ?>
<?php
$x_classList = "<select id='x_class' name='x_class'>";
$x_classList .= "<option value=''>Please Select</option>";
$sSqlWrk = "SELECT `id`, `class` FROM `class`";
$sSqlWrk .= " ORDER BY `class` Asc";
$rswrk = phpmkr_query($sSqlWrk,$conn) or die("Failed to execute query at line " . __LINE__ . ": " . phpmkr_error($conn) . '<br />SQL:' . $sSqlWrk);
if ($rswrk) {
$rowcntwrk = 0;
while ($datawrk = phpmkr_fetch_array($rswrk)) {
$x_classList .= "<option value=\"" . htmlspecialchars($datawrk[0]) . "\"";
if ($datawrk["id"] == @$x_class) {
$x_classList .= " selected";
}
$x_classList .= ">" . $datawrk["class"] . "</option>";
$rowcntwrk++;
}
}
@phpmkr_free_result($rswrk);
$x_classList .= "</select>";
echo $x_classList;
?>
<?php }else{ ?>
<?php
if ((!is_null($x_class)) && ($x_class <> "")) {
$sSqlWrk = "SELECT `class` FROM `class`";
$sTmp = $x_class;
$sTmp = addslashes($sTmp);
$sSqlWrk .= " WHERE `id` = " . $sTmp . "";
$sSqlWrk .= " ORDER BY `class` Asc";
$rswrk = phpmkr_query($sSqlWrk,$conn) or die("Failed to execute query at line " . __LINE__ . ": " . phpmkr_error($conn) . '<br />SQL:' . $sSqlWrk);
if ($rswrk && $rowwrk = phpmkr_fetch_array($rswrk)) {
$sTmp = $rowwrk["class"];
}
@phpmkr_free_result($rswrk);
} else {
$sTmp = "";
}
$ox_class = $x_class; // Backup original value
$x_class = $sTmp;
?>
<?php echo $x_class; ?>
<?php $x_class = $ox_class; // Restore original value ?>
<?php } ?>
</td>
<!-- step -->
<td>
<?php if ($bEditRow) { // Edit record ?>
<?php echo $x_step; ?><input type="hidden" id="x_step" name="x_step" value="<?php echo @$x_step; ?>" />
<?php }else{ ?>
<a href="#" onclick="overlib(
'<div class=\'fgtip\' id=\'ajaxexa1\'> Loading . . .</div>',
TEXTPADDING,0, CAPTIONPADDING,4, CAPTION, '<?php echo $x_class; ?> - <?php echo $x_step; ?>',
WRAP, BORDER,2, STICKY, DRAGGABLE, CLOSECLICK, SCROLL,
MIDX,0, RELY,90, FILTER,
CAPTIONFONTCLASS,'texttip', CLOSEFONTCLASS, 'textip', BGCLASS, 'bgtip', CGCOLOR, 'bgtip',
STATUS,'(<?php echo $x_step; ?>');
OLgetAJAX('steps_tooltip.php?step=<?php echo $x_step; ?>',
function(){OLgetRef('ajaxexa1').innerHTML= OLresponseAJAX ;});
return false;""><?php echo $x_step; ?></a>
<?php } ?></td>
<!-- num_grp -->
<td>
<?php if ($bEditRow) { // Edit record ?>
<input type="text" name="x_num_grp" id="x_num_grp" size="30" maxlength="255" value="<?php echo htmlspecialchars(@$x_num_grp) ?>" />
<?php }else{ ?>
<?php if (is_null($x_num_grp)) { ?>
N/A
<?php } else { ?>
<?php echo $x_num_grp; ?>
<?php } ?>
<?php } ?>
</td>
<!-- zone -->
<td>
<?php if ($bEditRow) { // Edit record ?>
<input type="text" name="x_zone" id="x_zone" size="30" maxlength="255" value="<?php echo htmlspecialchars(@$x_zone) ?>" />
<?php }else{ ?>
<?php if (is_null($x_zone)) { ?>
N/A
<?php } else { ?>
<?php echo $x_zone; ?>
<?php } ?>
<?php } ?>
</td>
<!-- chest -->
<td align="center">
<?php if ($bEditRow) { // Edit record ?>
<?php
$x_chestList = "<select id='x_chest' name='x_chest'>";
$x_chestList .= "<option value=''>Please Select</option>";
$x_chestList .= "<option value=\"Yes\"";
if (@$x_chest == "Yes") {
$x_chestList .= " selected";
}
$x_chestList .= ">" . "Yes" . "</option>";
$x_chestList .= "<option value=\"No\"";
if (@$x_chest == "No") {
$x_chestList .= " selected";
}
$x_chestList .= ">" . "No" . "</option>";
$x_chestList .= "<option value=\"?\"";
if (@$x_chest == "?") {
$x_chestList .= " selected";
}
$x_chestList .= ">" . "?" . "</option>";
$x_chestList .= "</select>";
echo $x_chestList;
?>
<?php }else{ ?>
<?php if (is_null($x_chest)) { ?>
N/A
<?php } else { ?>
<?php
switch ($x_chest) {
case "Yes":
echo "<img src='images/check-trans.png' border='0' width='32' height='32' alt='Chest on Success' />";
break;
case "No":
echo "<img src='images/uncheck-trans.png' border='0' width='32' height='32' alt='No Chest' />";
break;
case "?":
echo "<img src='images/question-trans.png' border='0' width='32' height='32' alt='No Chest' />";
break;
}
?>
<?php } ?>
<?php } ?></td>
<?php if (($ewCurSec & ewAllowEdit) == ewAllowEdit) { ?>
<td width="65" align="center"><span class="phpmaker">
<?php if ($_SESSION[ewSessionTblKey ."_step"] == ((get_magic_quotes_gpc())? stripslashes($x_step) : $x_step)) { ?>
<a href="" onClick="if (EW_checkMyForm(document.fstepslist)) document.fstepslist.submit();return false;">Update</a> <a href="stepslist.php?a=cancel">Cancel</a>
<input type="hidden" name="a_list" value="update" />
<?php } else { ?>
<a href="<?php if ($x_step <> "") {echo "stepslist.php?a=edit&step=" . urlencode($x_step); } else { echo "javascript:alert('Invalid Record! Key is null');";} ?>">Quick Edit</a>
<?php } ?></td>
<?php if (($ewCurSec & ewAllowEdit) == ewAllowEdit) { ?>
<td><span class="phpmaker"><a href="<?php if ($x_step <> "") {echo "stepsedit.php?step=" . urlencode($x_step); } else { echo "javascript:alert('Invalid Record! Key is null');";} ?>">Edit</a></span></td>
<?php } ?>
<?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="stepslist.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="stepslist.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="stepslist.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="stepslist.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="stepslist.php?start=<?php echo $x; ?>"><b><?php echo $y; ?></b></a>
<?php } else { ?>
<a href="stepslist.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="stepslist.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; } ?>
Steps <?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 Steps 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_step;
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["step"]) > 0) {
$x_step = $_GET["step"];
} else {
$bInlineEdit = false;
}
if ($bInlineEdit) {
if (LoadData($conn)) {
$_SESSION[ewSessionTblKey . "_step"] = $x_step; // Set up Inline Edit key
}
}
} elseif (strtolower($sAction) == "cancel") { // Switch out of Inline Edit Mode
$_SESSION[ewSessionTblKey . "_step"] = ""; // Clear Inline Edit key
}
} else {
$sAction = @$_POST["a_list"];
if (strtolower($sAction) == "update") { // Update Record
// Get fields from form
$GLOBALS["x_class"] = @$_POST["x_class"];
$GLOBALS["x_step"] = @$_POST["x_step"];
$GLOBALS["x_descrip"] = @$_POST["x_descrip"];
$GLOBALS["x_num_grp"] = @$_POST["x_num_grp"];
$GLOBALS["x_zone"] = @$_POST["x_zone"];
$GLOBALS["x_chest"] = @$_POST["x_chest"];
$GLOBALS["x_mob_url"] = @$_POST["x_mob_url"];
$GLOBALS["x_id"] = @$_POST["x_id"];
if ($_SESSION[ewSessionTblKey ."_step"] == ((get_magic_quotes_gpc())? stripslashes($x_step) : $x_step)) {
if (InlineEditData($conn)) {
$_SESSION[ewSessionMessage] = "Updated Step Successfully";
}
}
}
$_SESSION[ewSessionTblKey . "_step"] = ""; // 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_class"] = "";
$_SESSION[ewSessionTblAdvSrch . "_x_step"] = "";
$_SESSION[ewSessionTblAdvSrch . "_x_descrip"] = "";
$_SESSION[ewSessionTblAdvSrch . "_x_num_grp"] = "";
$_SESSION[ewSessionTblAdvSrch . "_x_zone"] = "";
$_SESSION[ewSessionTblAdvSrch . "_x_chest"] = "";
$_SESSION[ewSessionTblAdvSrch . "_x_mob_url"] = "";
$_SESSION[ewSessionTblAdvSrch . "_x_id"] = "";
$_SESSION[ewSessionTblBasicSrch] = "";
$_SESSION[ewSessionTblBasicSrchType] = "";
}
//-------------------------------------------------------------------------------
// Function RestoreSearch
// - Restore all search parameters
//
function RestoreSearch()
{
// Restore advanced search settings
$GLOBALS["x_class"] = @$_SESSION[ewSessionTblAdvSrch . "_x_class"];
$GLOBALS["x_step"] = @$_SESSION[ewSessionTblAdvSrch . "_x_step"];
$GLOBALS["x_descrip"] = @$_SESSION[ewSessionTblAdvSrch . "_x_descrip"];
$GLOBALS["x_num_grp"] = @$_SESSION[ewSessionTblAdvSrch . "_x_num_grp"];
$GLOBALS["x_zone"] = @$_SESSION[ewSessionTblAdvSrch . "_x_zone"];
$GLOBALS["x_chest"] = @$_SESSION[ewSessionTblAdvSrch . "_x_chest"];
$GLOBALS["x_mob_url"] = @$_SESSION[ewSessionTblAdvSrch . "_x_mob_url"];
$GLOBALS["x_id"] = @$_SESSION[ewSessionTblAdvSrch . "_x_id"];
$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 `class`
if ($sOrder == "class") {
$sSortField = "`class`";
$sLastSort = @$_SESSION[ewSessionTblSort . "_x_class"];
$sThisSort = ($sLastSort == "ASC") ? "DESC" : "ASC";
$_SESSION[ewSessionTblSort . "_x_class"] = $sThisSort;
} else {
if (!($bCtrl) && @$_SESSION[ewSessionTblSort . "_x_class"] <> "") { $_SESSION[ewSessionTblSort . "_x_class"] = "" ; }
}
// Field `step`
if ($sOrder == "step") {
$sSortField = "`step`";
$sLastSort = @$_SESSION[ewSessionTblSort . "_x_step"];
$sThisSort = ($sLastSort == "ASC") ? "DESC" : "ASC";
$_SESSION[ewSessionTblSort . "_x_step"] = $sThisSort;
} else {
if (!($bCtrl) && @$_SESSION[ewSessionTblSort . "_x_step"] <> "") { $_SESSION[ewSessionTblSort . "_x_step"] = "" ; }
}
// Field `num_grp`
if ($sOrder == "num_grp") {
$sSortField = "`num_grp`";
$sLastSort = @$_SESSION[ewSessionTblSort . "_x_num_grp"];
$sThisSort = ($sLastSort == "ASC") ? "DESC" : "ASC";
$_SESSION[ewSessionTblSort . "_x_num_grp"] = $sThisSort;
} else {
if (!($bCtrl) && @$_SESSION[ewSessionTblSort . "_x_num_grp"] <> "") { $_SESSION[ewSessionTblSort . "_x_num_grp"] = "" ; }
}
// Field `zone`
if ($sOrder == "zone") {
$sSortField = "`zone`";
$sLastSort = @$_SESSION[ewSessionTblSort . "_x_zone"];
$sThisSort = ($sLastSort == "ASC") ? "DESC" : "ASC";
$_SESSION[ewSessionTblSort . "_x_zone"] = $sThisSort;
} else {
if (!($bCtrl) && @$_SESSION[ewSessionTblSort . "_x_zone"] <> "") { $_SESSION[ewSessionTblSort . "_x_zone"] = "" ; }
}
// Field `chest`
if ($sOrder == "chest") {
$sSortField = "`chest`";
$sLastSort = @$_SESSION[ewSessionTblSort . "_x_chest"];
$sThisSort = ($sLastSort == "ASC") ? "DESC" : "ASC";
$_SESSION[ewSessionTblSort . "_x_chest"] = $sThisSort;
} else {
if (!($bCtrl) && @$_SESSION[ewSessionTblSort . "_x_chest"] <> "") { $_SESSION[ewSessionTblSort . "_x_chest"] = "" ; }
}
// Field `mob_url`
if ($sOrder == "mob_url") {
$sSortField = "`mob_url`";
$sLastSort = @$_SESSION[ewSessionTblSort . "_x_mob_url"];
$sThisSort = ($sLastSort == "ASC") ? "DESC" : "ASC";
$_SESSION[ewSessionTblSort . "_x_mob_url"] = $sThisSort;
} else {
if (!($bCtrl) && @$_SESSION[ewSessionTblSort . "_x_mob_url"] <> "") { $_SESSION[ewSessionTblSort . "_x_mob_url"] = "" ; }
}
// 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"] = "" ; }
}
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_class"] <> "") { $_SESSION[ewSessionTblSort . "_x_class"] = ""; }
if (@$_SESSION[ewSessionTblSort . "_x_step"] <> "") { $_SESSION[ewSessionTblSort . "_x_step"] = ""; }
if (@$_SESSION[ewSessionTblSort . "_x_num_grp"] <> "") { $_SESSION[ewSessionTblSort . "_x_num_grp"] = ""; }
if (@$_SESSION[ewSessionTblSort . "_x_zone"] <> "") { $_SESSION[ewSessionTblSort . "_x_zone"] = ""; }
if (@$_SESSION[ewSessionTblSort . "_x_chest"] <> "") { $_SESSION[ewSessionTblSort . "_x_chest"] = ""; }
if (@$_SESSION[ewSessionTblSort . "_x_mob_url"] <> "") { $_SESSION[ewSessionTblSort . "_x_mob_url"] = ""; }
if (@$_SESSION[ewSessionTblSort . "_x_id"] <> "") { $_SESSION[ewSessionTblSort . "_x_id"] = ""; }
}
// Reset start position (Reset command)
$nStartRec = 1;
$_SESSION[ewSessionTblStartRec] = $nStartRec;
}
}
?>
<?php
//-------------------------------------------------------------------------------
// Function LoadData
// - Variables setup: field variables
function LoadData($conn)
{
global $x_step;
$sFilter = ewSqlKeyWhere;
$x_step = (get_magic_quotes_gpc()) ? stripslashes($x_step) : $x_step;
$sFilter = str_replace("@step", AdjustSql($x_step), $sFilter); // Replace key value
$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_class"] = $row["class"];
$GLOBALS["x_step"] = $row["step"];
$GLOBALS["x_descrip"] = $row["descrip"];
$GLOBALS["x_num_grp"] = $row["num_grp"];
$GLOBALS["x_zone"] = $row["zone"];
$GLOBALS["x_chest"] = $row["chest"];
$GLOBALS["x_mob_url"] = $row["mob_url"];
$GLOBALS["x_id"] = $row["id"];
}
phpmkr_free_result($rs);
return $bLoadData;
}
?>
<?php
//-------------------------------------------------------------------------------
// Function EditData
// - Variables used: field variables
function InlineEditData($conn)
{
global $x_step;
$sFilter = ewSqlKeyWhere;
$sTmp = (get_magic_quotes_gpc()) ? stripslashes($x_step) : $x_step;
$sFilter = str_replace("@step", AdjustSql($sTmp), $sFilter); // Replace key value
$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_class = @$_POST["x_class"];
$x_step = @$_POST["x_step"];
$x_num_grp = @$_POST["x_num_grp"];
$x_zone = @$_POST["x_zone"];
$x_chest = @$_POST["x_chest"];
$x_mob_url = @$_POST["x_mob_url"];
$theValue = (!get_magic_quotes_gpc()) ? addslashes($GLOBALS["x_class"]) : $GLOBALS["x_class"];
$theValue = ($theValue != "") ? " '" . $theValue . "'" : "NULL";
$fieldList["`class`"] = $theValue;
$theValue = (!get_magic_quotes_gpc()) ? addslashes($GLOBALS["x_step"]) : $GLOBALS["x_step"];
$theValue = ($theValue != "") ? " '" . $theValue . "'" : "NULL";
$fieldList["`step`"] = $theValue;
$theValue = (!get_magic_quotes_gpc()) ? addslashes($GLOBALS["x_num_grp"]) : $GLOBALS["x_num_grp"];
$theValue = ($theValue != "") ? " '" . $theValue . "'" : "NULL";
$fieldList["`num_grp`"] = $theValue;
$theValue = (!get_magic_quotes_gpc()) ? addslashes($GLOBALS["x_zone"]) : $GLOBALS["x_zone"];
$theValue = ($theValue != "") ? " '" . $theValue . "'" : "NULL";
$fieldList["`zone`"] = $theValue;
$theValue = (!get_magic_quotes_gpc()) ? addslashes($GLOBALS["x_chest"]) : $GLOBALS["x_chest"];
$theValue = ($theValue != "") ? " '" . $theValue . "'" : "NULL";
$fieldList["`chest`"] = $theValue;
$theValue = (!get_magic_quotes_gpc()) ? addslashes($GLOBALS["x_mob_url"]) : $GLOBALS["x_mob_url"];
$theValue = ($theValue != "") ? " '" . $theValue . "'" : "NULL";
$fieldList["`mob_url`"] = $theValue;
// Updating event
if (Recordset_Updating($fieldList, $oldrs)) {
// Update
$sSql = "UPDATE `steps` 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 = "steps";
}
?>