<?php
/******************************************************************************
* settings.php *
* Settings File *
* 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 ("settingsinfo.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("settings") : GetAnonymousPriv("settings");
if (($ewCurSec & ewAllowEdit) <> ewAllowEdit) {
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_header = NULL;
$ox_header = NULL;
$z_header = NULL;
$ar_x_header = NULL;
$ari_x_header = NULL;
$x_headerList = NULL;
$x_headerChk = NULL;
$cbo_x_header_js = NULL;
?>
<?php
// Load key from QueryString
$x_id = @$_GET["id"];
// Get action
$sAction = @$_POST["a_edit"];
if ($sAction == "") {
$sAction = "I"; // Display record
} else {
// Get fields from form
$x_id = @$_POST["x_id"];
$x_header = @$_POST["x_header"];
}
$conn = phpmkr_db_connect(HOST, USER, PASS, DB, PORT);
switch ($sAction) {
case "I": // Display record
if (!LoadData($conn)) { // Load record
$_SESSION[ewSessionMessage] = "No Settings Found";
phpmkr_db_close($conn);
ob_end_clean();
}
break;
case "U": // Update
if (EditData($conn)) { // Update record
$_SESSION[ewSessionMessage] = "Settings Updated";
phpmkr_db_close($conn);
ob_end_clean();
}
break;
}
?>
<?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_header && !EW_hasValue(EW_this.x_header, "RADIO")) {
if (!EW_onError(EW_this, EW_this.x_header, "RADIO", "Please enter required field - header"))
return false;
}
return true;
}
//-->
</script>
<script type="text/javascript">
<!--
var EW_DHTMLEditors = [];
//-->
</script>
<form name="fsettings" id="fsettings" action="settings.php?id=1" method="post" onsubmit="return EW_checkMyForm(this);">
<input type="hidden" name="a_edit" value="U" />
<?php
if (@$_SESSION[ewSessionMessage] <> "") {
?>
<p><div class="ewmsg"><?php echo $_SESSION[ewSessionMessage]; ?></div></p>
<?php
$_SESSION[ewSessionMessage] = ""; // Clear message
}
?>
<table align="center" class="table_other">
<tr>
<td>
<input type="hidden" id="x_id" name="x_id" value="<?php echo @$x_id; ?>" />Header Switch
</td>
<td><span id="cb_x_header">
<?php echo RenderControl(1, 0, 5, 1); ?>
<input type="radio" name="x_header"<?php if (@$x_header == "1") { ?> <?php } ?> value="<?php echo htmlspecialchars("1"); ?>"checked />
<?php echo "Text"; ?>
<?php echo RenderControl(1, 0, 5, 2); ?>
<?php echo RenderControl(1, 1, 5, 1); ?>
<input type="radio" name="x_header"<?php if (@$x_header == "2") { ?> <?php } ?> value="<?php echo htmlspecialchars("2"); ?>"checked />
<?php echo "Images"; ?>
<?php echo RenderControl(1, 1, 5, 2); ?>
</span></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" name="btnAction" id="btnAction" value="Save Settings" class="button" /></td>
</tr>
</table>
</form>
<?php include ("footer.php") ?>
<?php
phpmkr_db_close($conn);
?>
<?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
$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_header"] = $row["header"];
}
phpmkr_free_result($rs);
return $bLoadData;
}
?>
<?php
//-------------------------------------------------------------------------------
// Function EditData
// - Variables used: field variables
function EditData($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
$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_header = @$_POST["x_header"];
$theValue = (!get_magic_quotes_gpc()) ? addslashes($GLOBALS["x_header"]) : $GLOBALS["x_header"];
$theValue = ($theValue != "") ? " '" . $theValue . "'" : "NULL";
$fieldList["`header`"] = $theValue;
// Updating event
if (Recordset_Updating($fieldList, $oldrs)) {
// Update
$sSql = "UPDATE `settings` 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 = "settings";
}
?>