<?php
/******************************************************************************
* playerslist.php *
* List of Players *
* 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 ("playersinfo.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("players") : GetAnonymousPriv("players");
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_name = NULL;
$ox_name = NULL;
$z_name = NULL;
$ar_x_name = NULL;
$ari_x_name = NULL;
$x_nameList = NULL;
$x_nameChk = NULL;
$cbo_x_name_js = NULL;
$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_steps = NULL;
$ox_steps = NULL;
$z_steps = NULL;
$ar_x_steps = NULL;
$ari_x_steps = NULL;
$x_stepsList = NULL;
$x_stepsChk = NULL;
$cbo_x_steps_js = NULL;
$x_level = NULL;
$ox_level = NULL;
$z_level = NULL;
$ar_x_level = NULL;
$ari_x_level = NULL;
$x_levelList = NULL;
$x_levelChk = NULL;
$cbo_x_level_js = NULL;
$x_orb = NULL;
$ox_orb = NULL;
$z_orb = NULL;
$ar_x_orb = NULL;
$ari_x_orb = NULL;
$x_orbList = NULL;
$x_orbChk = NULL;
$cbo_x_orb_js = NULL;
$x_scheduled = NULL;
$ox_scheduled = NULL;
$z_scheduled = NULL;
$ar_x_scheduled = NULL;
$ari_x_scheduled = NULL;
$x_scheduledList = NULL;
$x_scheduledChk = NULL;
$cbo_x_scheduled_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 ";
}
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
//-->
</script>
<script type="text/javascript">
<!--
function EW_checkMyForm(EW_this) {
if (EW_this.x_name && !EW_hasValue(EW_this.x_name, "TEXT")) {
if (!EW_onError(EW_this, EW_this.x_name, "TEXT", "Please Enter Character Name"))
return false;
}
if (EW_this.x_class && !EW_hasValue(EW_this.x_class, "SELECT")) {
if (!EW_onError(EW_this, EW_this.x_class, "SELECT", "Please Choose the Character's Class"))
return false;
}
if (EW_this.x_steps && !EW_hasValue(EW_this.x_steps, "SELECT")) {
if (!EW_onError(EW_this, EW_this.x_steps, "SELECT", "Please Choose the Epic Step this Character is ready for"))
return false;
}
if (EW_this.x_level && !EW_hasValue(EW_this.x_level, "TEXT")) {
if (!EW_onError(EW_this, EW_this.x_level, "TEXT", "Please Enter the Character's Level"))
return false;
}
if (EW_this.x_level && !EW_checkinteger(EW_this.x_level.value)) {
if (!EW_onError(EW_this, EW_this.x_level, "TEXT", "Please Enter the Character's Level."))
return false;
}
if (EW_this.x_orb && !EW_hasValue(EW_this.x_orb, "SELECT")) {
if (!EW_onError(EW_this, EW_this.x_orb, "SELECT", "Please Select Yes or No to the Question, Has Anguish Orb?"))
return false;
}
if (!EW_checkusdate(EW_this.x_scheduled.value)) {
if (!EW_onError(EW_this, EW_this.x_scheduled, "TEXT", "Incorrect date, format = mm-dd-yyyy"))
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>
<script type="text/javascript" src="calendar/calendar.js"></script>
<script type="text/javascript" src="calendar/lang/calendar-en.js"></script>
<script type="text/javascript" src="calendar/calendar-setup.js"></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="playersadd.php"><img src="images/but_add.gif" alt="Add Player" 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="fplayerslist" id="fplayerslist" action="playerslist.php" method="post">
<table align="center" class="ewTable" id="ewlistmain">
<!-- Table header -->
<tr class="ewTableHeader">
<td valign="bottom" align="center">
<a href="playerslist.php?order=<?php echo urlencode("name"); ?>" onmousedown="ewsort(event, this.href);">
Name<?php if (@$_SESSION[ewSessionTblSort . "_x_name"] == "ASC") { ?><img src="images/sortup.gif" width="16" height="16" border="0"><?php } elseif (@$_SESSION[ewSessionTblSort . "_x_name"] == "DESC") { ?><img src="images/sortdown.gif" width="16" height="16" border="0"><?php } ?>
</a> </td>
<td valign="bottom" align="center">
<a href="playerslist.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">Currently Ready For</td>
<td align="center" valign="bottom">
<a href="playerslist.php?order=<?php echo urlencode("level"); ?>" onmousedown="ewsort(event, this.href);">
Level<?php if (@$_SESSION[ewSessionTblSort . "_x_level"] == "ASC") { ?><img src="images/sortup.gif" width="16" height="16" border="0"><?php } elseif (@$_SESSION[ewSessionTblSort . "_x_level"] == "DESC") { ?><img src="images/sortdown.gif" width="16" height="16" border="0"><?php } ?>
</a> </td>
<td width="100" align="center" valign="bottom">
<a href="playerslist.php?order=<?php echo urlencode("orb"); ?>" onmousedown="ewsort(event, this.href);">
Has Anguish Orb?<?php if (@$_SESSION[ewSessionTblSort . "_x_orb"] == "ASC") { ?><img src="images/sortup.gif" width="16" height="16" border="0"><?php } elseif (@$_SESSION[ewSessionTblSort . "_x_orb"] == "DESC") { ?><img src="images/sortdown.gif" width="16" height="16" border="0"><?php } ?>
</a> </td>
<td align="center" valign="bottom">
<a href="playerslist.php?order=<?php echo urlencode("scheduled"); ?>" onmousedown="ewsort(event, this.href);">
Scheduled For<?php if (@$_SESSION[ewSessionTblSort . "_x_scheduled"] == "ASC") { ?><img src="images/sortup.gif" width="16" height="16" border="0"><?php } elseif (@$_SESSION[ewSessionTblSort . "_x_scheduled"] == "DESC") { ?><img src="images/sortdown.gif" width="16" height="16" border="0"><?php } ?>
</a> </td>
<?php if (CurrentUserID() == -1) { // System admin ?>
<td> </td>
<?php } ?>
<?php if (($ewCurSec & ewAllowDelete) == ewAllowDelete) { ?>
<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_name = $row["name"];
$x_class = $row["class"];
$x_steps = $row["steps"];
$x_level = $row["level"];
$x_orb = $row["orb"];
$x_scheduled = $row["scheduled"];
$bEditRow = (($_SESSION[ewSessionTblKey ."_name"] == ((get_magic_quotes_gpc())? stripslashes($x_name) : $x_name)) && ($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; ?>>
<!-- name -->
<td>
<?php if ($bEditRow) { // Edit record ?>
<?php if (CurrentUserID() == -1) { // System admin ?>
<input type="text" name="x_name" id="x_name" size="30" maxlength="30" value="<?php echo htmlspecialchars(@$x_name) ?>" />
<?php } else { // Non system admin ?>
<?php $x_name = stripslashes($_SESSION["eqplan_status_UserID"]); ?>
<?php echo $x_name; ?>
<input type="hidden" id="x_name" name="x_name" value="<?php echo $x_name; ?>" />
<?php } ?>
<?php }else{ ?>
<?php echo $x_name; ?>
<?php } ?>
</td>
<!-- class -->
<td>
<?php if ($bEditRow) { // Edit record ?>
<?php
$x_classList = "<select id='x_class' name='x_class' onChange='EW_updatecombo(this.form.x_steps, ar_x_steps, this.options[this.selectedIndex].value);'>";
$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>
<!-- steps -->
<td>
<?php if ($bEditRow) { // Edit record ?>
<?php
$x_stepsList = "<select id='x_steps' name='x_steps'>";
$x_stepsList .= "<option value=''>Please Select</option>";
$cbo_x_steps_js = ""; // Init
$sSqlWrk = "SELECT `id`, `step`, `class` FROM `steps`";
$sSqlWrk .= " ORDER BY `step` 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_stepsList .= "<option value=\"" . htmlspecialchars($datawrk[0]) . "\"";
if ($datawrk["id"] == @$x_steps) {
$x_stepsList .= " selected";
}
$x_stepsList .= ">" . $datawrk["step"] . "</option>";
$cbo_x_steps_js .= "ar_x_steps[" . ($rowcntwrk*4) . "] = '" . str_replace("'","\\'",$datawrk["id"]) . "';"; // Value
$cbo_x_steps_js .= "ar_x_steps[" . ($rowcntwrk*4+1) . "] = '" . str_replace("'","\\'",$datawrk["step"]) . "';"; // Display field 1
$cbo_x_steps_js .= "ar_x_steps[" . ($rowcntwrk*4+2) . "] = '';";
$cbo_x_steps_js .= "ar_x_steps[" . ($rowcntwrk*4+3) . "] = '" . str_replace("'","\\'",$datawrk["class"]) . "';"; // Filter field
$rowcntwrk++;
}
}
@phpmkr_free_result($rswrk);
$x_stepsList .= "</select>";
echo $x_stepsList;
?>
<script type="text/javascript">
<!--
var ar_x_steps = new Array();
<?php echo $cbo_x_steps_js; ?>
//-->
</script>
<?php }else{ ?>
<?php
if ((!is_null($x_steps)) && ($x_steps <> "")) {
$sSqlWrk = "SELECT `step` FROM `steps`";
$sTmp = $x_steps;
$sTmp = addslashes($sTmp);
$sSqlWrk .= " WHERE `id` = " . $sTmp . "";
$sSqlWrk .= " ORDER BY `step` 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["step"];
}
@phpmkr_free_result($rswrk);
} else {
$sTmp = "";
}
$ox_steps = $x_steps; // Backup original value
$x_steps = $sTmp;
$bsteps = urlencode($x_steps);
?>
<a href="#" onclick="overlib(
'<div class=\'fgtip\' id=\'ajaxexa1\'> Loading . . .</div>',
TEXTPADDING,0, CAPTIONPADDING,4, CAPTION, '<?php echo $x_class; ?> - <?php echo $x_steps; ?>',
WRAP, BORDER,2, STICKY, DRAGGABLE, CLOSECLICK, SCROLL,
MIDX,0, RELY,90, FILTER,
CAPTIONFONTCLASS,'texttip', CLOSEFONTCLASS, 'textip', BGCLASS, 'bgtip', CGCOLOR, 'bgtip',
STATUS,'(<?php echo $bsteps; ?>');
OLgetAJAX('steps_tooltip.php?step=<?php echo $bsteps; ?>',
function(){OLgetRef('ajaxexa1').innerHTML= OLresponseAJAX ;});
return false;""><?php echo $x_steps; ?></a>
<?php $x_steps = $ox_steps; // Restore original value ?>
<?php } ?>
</td>
<!-- level -->
<td align="center">
<?php if ($bEditRow) { // Edit record ?>
<input type="text" name="x_level" id="x_level" size="30" value="<?php echo htmlspecialchars(@$x_level) ?>" />
<?php }else{ ?>
<?php echo $x_level; ?>
<?php } ?></td>
<!-- orb -->
<td align="center">
<?php if ($bEditRow) { // Edit record ?>
<?php
$x_orbList = "<select id='x_orb' name='x_orb'>";
$x_orbList .= "<option value=''>Please Select</option>";
$x_orbList .= "<option value=\"Yes\"";
if (@$x_orb == "Yes") {
$x_orbList .= " selected";
}
$x_orbList .= ">" . "Yes" . "</option>";
$x_orbList .= "<option value=\"No\"";
if (@$x_orb == "No") {
$x_orbList .= " selected";
}
$x_orbList .= ">" . "No" . "</option>";
$x_orbList .= "</select>";
echo $x_orbList;
?>
<?php }else{ ?>
<?php
switch ($x_orb) {
case "Yes":
echo "<img src='images/check-trans.png' border='0' width='32' height='32' alt='Has Orb' />";
break;
case "No":
echo "<img src='images/uncheck-trans.png' border='0' width='32' height='32' alt='No Orb' />";
break;
}
?>
<?php } ?></td>
<!-- scheduled -->
<td align="center">
<?php if ($bEditRow) { // Edit record ?>
<?php if (CurrentUserID() == -1) { // System admin ?>
<input type="text" name="x_scheduled" id="x_scheduled" value="<?php echo FormatDateTime(@$x_scheduled,6); ?>" />
<img src="images/ew_calendar.png" width='24' height='24' id="cx_scheduled" alt="Pick a Date" style="cursor:pointer;cursor:hand;">
<script type="text/javascript">
Calendar.setup(
{
inputField : "x_scheduled", // ID of the input field
ifFormat : "%m-%d-%Y", // the date format
button : "cx_scheduled" // ID of the button
}
);
</script>
<?php } else { // Non system admin ?>
<?php echo FormatDateTime($x_scheduled,6); ?>
<?php } ?>
<?php }else{ ?>
<?php echo FormatDateTime($x_scheduled,6); ?>
<?php } ?></td>
<?php if (CurrentUserID() == -1) { // System admin ?>
<?php if (($ewCurSec & ewAllowEdit) == ewAllowEdit) { ?>
<td width="1" align="center"><span class="phpmaker">
<?php if ($_SESSION[ewSessionTblKey ."_name"] == ((get_magic_quotes_gpc())? stripslashes($x_name) : $x_name)) { ?>
<a href="" onClick="if (EW_checkMyForm(document.fplayerslist)) document.fplayerslist.submit();return false;">Update</a> <a href="playerslist.php?a=cancel">Cancel</a>
<input type="hidden" name="a_list" value="update" />
<?php } else { ?>
<a href="<?php if ($x_name <> "") {echo "playerslist.php?a=edit&name=" . urlencode($x_name); } else { echo "javascript:alert('Invalid Record! Key is null');";} ?>">Edit</a>
<?php } ?>
</span></td>
<?php } ?>
<?php if (($ewCurSec & ewAllowDelete) == ewAllowDelete) { ?>
<td width="1" align="center"><span class="phpmaker"><a href="<?php if ($x_name <> "") {echo "playersdelete.php?name=" . urlencode($x_name); } else { echo "javascript:alert('Invalid Record! Key is null');";} ?>">Delete</a></span></td>
<?php } ?>
<?php } ?>
</tr>
<?php
}
}
?>
</table>
</form>
<?php if (strtolower($sAction) == "edit") { ?>
<script language="JavaScript">
<!--
var f = document.fplayerslist;
EW_updatecombo(f.x_steps, ar_x_steps, f.x_class.options?f.x_class.options[f.x_class.selectedIndex].value:f.x_class.value);
//-->
</script>
<?php } ?>
<?php
}
// Close recordset and connection
phpmkr_free_result($rs);
phpmkr_db_close($conn);
?>
<form action="playerslist.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="playerslist.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="playerslist.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="playerslist.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="playerslist.php?start=<?php echo $x; ?>"><b><?php echo $y; ?></b></a>
<?php } else { ?>
<a href="playerslist.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="playerslist.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; } ?>
Players <?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 Players 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_name;
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["name"]) > 0) {
$x_name = $_GET["name"];
} else {
$bInlineEdit = false;
}
if ($bInlineEdit) {
if (LoadData($conn)) {
$_SESSION[ewSessionTblKey . "_name"] = $x_name; // Set up Inline Edit key
}
}
} elseif (strtolower($sAction) == "cancel") { // Switch out of Inline Edit Mode
$_SESSION[ewSessionTblKey . "_name"] = ""; // Clear Inline Edit key
}
} else {
$sAction = @$_POST["a_list"];
if (strtolower($sAction) == "update") { // Update Record
// Get fields from form
$GLOBALS["x_name"] = @$_POST["x_name"];
$GLOBALS["x_class"] = @$_POST["x_class"];
$GLOBALS["x_steps"] = @$_POST["x_steps"];
$GLOBALS["x_level"] = @$_POST["x_level"];
$GLOBALS["x_orb"] = @$_POST["x_orb"];
$GLOBALS["x_scheduled"] = @$_POST["x_scheduled"];
if ($_SESSION[ewSessionTblKey ."_name"] == ((get_magic_quotes_gpc())? stripslashes($x_name) : $x_name)) {
if (InlineEditData($conn)) {
$_SESSION[ewSessionMessage] = "Player Update Successfully";
}
}
}
$_SESSION[ewSessionTblKey . "_name"] = ""; // Clear Inline Edit key
}
}
//-------------------------------------------------------------------------------
// 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 `name`
if ($sOrder == "name") {
$sSortField = "`name`";
$sLastSort = @$_SESSION[ewSessionTblSort . "_x_name"];
$sThisSort = ($sLastSort == "ASC") ? "DESC" : "ASC";
$_SESSION[ewSessionTblSort . "_x_name"] = $sThisSort;
} else {
if (!($bCtrl) && @$_SESSION[ewSessionTblSort . "_x_name"] <> "") { $_SESSION[ewSessionTblSort . "_x_name"] = "" ; }
}
// 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 `steps`
if ($sOrder == "steps") {
$sSortField = "`steps`";
$sLastSort = @$_SESSION[ewSessionTblSort . "_x_steps"];
$sThisSort = ($sLastSort == "ASC") ? "DESC" : "ASC";
$_SESSION[ewSessionTblSort . "_x_steps"] = $sThisSort;
} else {
if (!($bCtrl) && @$_SESSION[ewSessionTblSort . "_x_steps"] <> "") { $_SESSION[ewSessionTblSort . "_x_steps"] = "" ; }
}
// Field `level`
if ($sOrder == "level") {
$sSortField = "`level`";
$sLastSort = @$_SESSION[ewSessionTblSort . "_x_level"];
$sThisSort = ($sLastSort == "ASC") ? "DESC" : "ASC";
$_SESSION[ewSessionTblSort . "_x_level"] = $sThisSort;
} else {
if (!($bCtrl) && @$_SESSION[ewSessionTblSort . "_x_level"] <> "") { $_SESSION[ewSessionTblSort . "_x_level"] = "" ; }
}
// Field `orb`
if ($sOrder == "orb") {
$sSortField = "`orb`";
$sLastSort = @$_SESSION[ewSessionTblSort . "_x_orb"];
$sThisSort = ($sLastSort == "ASC") ? "DESC" : "ASC";
$_SESSION[ewSessionTblSort . "_x_orb"] = $sThisSort;
} else {
if (!($bCtrl) && @$_SESSION[ewSessionTblSort . "_x_orb"] <> "") { $_SESSION[ewSessionTblSort . "_x_orb"] = "" ; }
}
// Field `scheduled`
if ($sOrder == "scheduled") {
$sSortField = "`scheduled`";
$sLastSort = @$_SESSION[ewSessionTblSort . "_x_scheduled"];
$sThisSort = ($sLastSort == "ASC") ? "DESC" : "ASC";
$_SESSION[ewSessionTblSort . "_x_scheduled"] = $sThisSort;
} else {
if (!($bCtrl) && @$_SESSION[ewSessionTblSort . "_x_scheduled"] <> "") { $_SESSION[ewSessionTblSort . "_x_scheduled"] = "" ; }
}
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) == "resetsort") { // Reset sort criteria
$sOrderBy = "";
$_SESSION[ewSessionTblOrderBy] = $sOrderBy;
if (@$_SESSION[ewSessionTblSort . "_x_name"] <> "") { $_SESSION[ewSessionTblSort . "_x_name"] = ""; }
if (@$_SESSION[ewSessionTblSort . "_x_class"] <> "") { $_SESSION[ewSessionTblSort . "_x_class"] = ""; }
if (@$_SESSION[ewSessionTblSort . "_x_steps"] <> "") { $_SESSION[ewSessionTblSort . "_x_steps"] = ""; }
if (@$_SESSION[ewSessionTblSort . "_x_level"] <> "") { $_SESSION[ewSessionTblSort . "_x_level"] = ""; }
if (@$_SESSION[ewSessionTblSort . "_x_orb"] <> "") { $_SESSION[ewSessionTblSort . "_x_orb"] = ""; }
if (@$_SESSION[ewSessionTblSort . "_x_scheduled"] <> "") { $_SESSION[ewSessionTblSort . "_x_scheduled"] = ""; }
}
// Reset start position (Reset command)
$nStartRec = 1;
$_SESSION[ewSessionTblStartRec] = $nStartRec;
}
}
?>
<?php
//-------------------------------------------------------------------------------
// Function LoadData
// - Variables setup: field variables
function LoadData($conn)
{
global $x_name;
$sFilter = ewSqlKeyWhere;
$x_name = (get_magic_quotes_gpc()) ? stripslashes($x_name) : $x_name;
$sFilter = str_replace("@name", AdjustSql($x_name), $sFilter); // Replace key value
if ((CurrentUserID() <> "-1") && (CurrentUserID() <> "")) {
//$sFilter .= " AND " . str_replace("#UserID", AdjustSql(CurrentuserID()), ewSqlUserIDFilter);
$sFilter .= " AND " . ewSqlUserIDFilter;
$sFilter = str_replace("#Key", "`name`", $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_name"] = $row["name"];
$GLOBALS["x_class"] = $row["class"];
$GLOBALS["x_steps"] = $row["steps"];
$GLOBALS["x_level"] = $row["level"];
$GLOBALS["x_orb"] = $row["orb"];
$GLOBALS["x_scheduled"] = $row["scheduled"];
}
phpmkr_free_result($rs);
return $bLoadData;
}
?>
<?php
//-------------------------------------------------------------------------------
// Function EditData
// - Variables used: field variables
function InlineEditData($conn)
{
global $x_name;
$sFilter = ewSqlKeyWhere;
$sTmp = (get_magic_quotes_gpc()) ? stripslashes($x_name) : $x_name;
$sFilter = str_replace("@name", 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", "`name`", $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_name = @$_POST["x_name"];
$x_class = @$_POST["x_class"];
$x_steps = @$_POST["x_steps"];
$x_level = @$_POST["x_level"];
$x_orb = @$_POST["x_orb"];
$x_scheduled = @$_POST["x_scheduled"];
$theValue = (!get_magic_quotes_gpc()) ? addslashes($GLOBALS["x_name"]) : $GLOBALS["x_name"];
$theValue = ($theValue != "") ? " '" . $theValue . "'" : "NULL";
$fieldList["`name`"] = $theValue;
$theValue = ($GLOBALS["x_class"] != "") ? intval($GLOBALS["x_class"]) : "NULL";
$fieldList["`class`"] = $theValue;
$theValue = ($GLOBALS["x_steps"] != "") ? intval($GLOBALS["x_steps"]) : "NULL";
$fieldList["`steps`"] = $theValue;
$theValue = ($GLOBALS["x_level"] != "") ? intval($GLOBALS["x_level"]) : "NULL";
$fieldList["`level`"] = $theValue;
$theValue = (!get_magic_quotes_gpc()) ? addslashes($GLOBALS["x_orb"]) : $GLOBALS["x_orb"];
$theValue = ($theValue != "") ? " '" . $theValue . "'" : "NULL";
$fieldList["`orb`"] = $theValue;
$theValue = ($GLOBALS["x_scheduled"] != "") ? " '" . ConvertDateToMysqlFormat($GLOBALS["x_scheduled"]) . "'" : "Null";
$fieldList["`scheduled`"] = $theValue;
// Updating event
if (Recordset_Updating($fieldList, $oldrs)) {
// Update
$sSql = "UPDATE `players` 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 = "players";
}
?>