<?php
/******************************************************************************
* register.php *
* Registration Page *
* 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
// Initialize common variables
$x_id = NULL;
$ox_id = NULL;
$x_user = NULL;
$ox_user = NULL;
$x_pass = NULL;
$ox_pass = NULL;
$c_pass = NULL; // Initialize password confirmation field
$x_email = NULL;
$ox_email = NULL;
$x_UserLevel = NULL;
$ox_UserLevel = NULL;
// Get action
$sAction = @$_POST["a_register"];
if (($sAction == "") || ((is_null($sAction)))) {
$sAction = "I"; // Display blank record
} else {
// Get fields from form
$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"];
}
// Open connection to the database
$conn = phpmkr_db_connect(HOST, USER, PASS, DB, PORT);
$bUserExists = false;
switch ($sAction)
{
case "A": // Add
// Check for duplicated User ID
$sFilter = "(`user` = '" . AdjustSql($x_user) . "')";
$sUserSql = ewBuildSql(ewSqlSelect, ewSqlWhere, ewSqlGroupBy, ewSqlHaving, ewSqlOrderBy, $sFilter, "");
$rs = phpmkr_query($sUserSql,$conn) or die("Failed to execute query at line " . __LINE__ . ": " . phpmkr_error($conn) . '<br />SQL: ' . $sUserSql);
$bUserExists = (phpmkr_num_rows($rs) > 0);
if ($bUserExists) $_SESSION[ewSessionMessage] = "Username Already in Use, please choose a different Username.";
phpmkr_free_result($rs);
if (!$bUserExists) {
if (AddData($conn)) { // Add new record
// Load user email address
$sEmail = $x_email;
// Load email content
if ($sEmail <> "") {
LoadEmail("register.txt");
$sEmailFrom = str_replace("<!--\$From-->", "$Email_Name",$sEmailFrom); // Replace Sender
$sEmailTo = str_replace("<!--\$To-->", $sEmail, $sEmailTo); // Replace Receiver
$sEmailCc = str_replace("<!--\$Cc-->", "$Email_Name",$sEmailCc); // Replace Sender
$sEmailSubject = "eqEpic Registration Information";
$Tmp = (!get_magic_quotes_gpc()) ? $x_user : stripslashes($x_user);
$sEmailContent = str_replace("<!--user-->", $Tmp, $sEmailContent);
$Tmp = (!get_magic_quotes_gpc()) ? $x_pass : stripslashes($x_pass);
$sEmailContent = str_replace("<!--pass-->", $Tmp, $sEmailContent);
$Tmp = (!get_magic_quotes_gpc()) ? $x_email : stripslashes($x_email);
$sEmailContent = str_replace("<!--email-->", $Tmp, $sEmailContent);
// Send email
Send_Email($sEmailFrom, $sEmailTo, $sEmailCc, $sEmailBcc, $sEmailSubject, $sEmailContent, $sEmailFormat);
}
$_SESSION[ewSessionMessage] = "Registration Successful";
phpmkr_db_close($conn);
ob_end_clean();
header("Location: login.php");
exit();
}
}
}
?>
<?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_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.c_pass.value != EW_this.x_pass.value) {
if (!EW_onError(EW_this, EW_this.c_pass, "TEXT", "Password's Don't Match"))
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 Your E-mail Address"))
return false;
}
return true;
}
//-->
</script>
<script type="text/javascript">
<!--
var EW_DHTMLEditors = [];
//-->
</script>
<?php
if (@$_SESSION[ewSessionMessage] <> "") {
?>
<p><div class="ewmsg"><?php echo $_SESSION[ewSessionMessage]; ?></div></p>
<?php
$_SESSION[ewSessionMessage] = ""; // Clear message
}
?>
<center>
<form name="fsecregister" id="fsecregister" action="register.php" method="post" onsubmit="return EW_checkMyForm(this);">
<input type="hidden" name="a_register" value="A" />
<p><span class="phpmaker">Required Fields Are Marked With (<span class='ewmsg'> *</span>)</span></p>
<p><span class="phpmaker"><span class='ewmsg'>Username should be your game charachter's name</span></span></p>
<table class="table_other">
<tr>
<td>Username<span class='ewmsg'> *</span></td>
<td><span id="cb_x_user">
<input type="text" name="x_user" id="x_user" size="30" maxlength="20" value="<?php echo htmlspecialchars(@$x_user) ?>" class="text" />
</span></td>
</tr>
<tr>
<td>Pass</td>
<td><span id="cb_x_pass">
<input type="password" name="x_pass" id="x_pass" size="30" maxlength="20" value="<?php echo htmlspecialchars(@$x_pass) ?>" class="text" />
</span></td>
</tr>
<tr>
<td>Confirm Pass<span class='ewmsg'> *</span></td>
<td>
<input type="password" name="c_pass" id="c_pass" size="30" maxlength="20" value="<?php echo htmlspecialchars(@$c_pass) ?>" class="text" />
</td>
</tr>
<tr>
<td>E-mail<span class='ewmsg'> *</span></td>
<td><span id="cb_x_email">
<input type="text" name="x_email" id="x_email" size="30" maxlength="255" value="<?php echo htmlspecialchars(@$x_email) ?>" class="text" />
</span></td>
</tr>
</table>
<p>
<input type="submit" name="btnAction" id="btnAction" value="Register" class="button" />
</p>
</form>
</center>
<?php include ("footer.php") ?>
<?php
//-------------------------------------------------------------------------------
// Function AddData
// - Add Data
// - Variables used: field variables
function AddData($conn)
{
global $x_id;
global $x_user;
global $x_email;
$sFilter = ewSqlKeyWhere;
// Check for duplicate key
$bCheckKey = true;
if ((@$x_id == "") || (is_null(@$x_id))) {
$bCheckKey = false;
} else {
$sFilter = str_replace("@id", AdjustSql($x_id), $sFilter); // Replace key value
}
if ($bCheckKey) {
$sSqlChk = ewBuildSql(ewSqlSelect, ewSqlWhere, ewSqlGroupBy, ewSqlHaving, ewSqlOrderBy, $sFilter, "");
$rsChk = phpmkr_query($sSqlChk, $conn) or die("Failed to execute query at line " . __LINE__ . ": " . phpmkr_error($conn) . '<br />SQL: ' . $sSqlChk);
if (phpmkr_num_rows($rsChk) > 0) {
$_SESSION[ewSessionMessage] = "Duplicate value for primary key";
phpmkr_free_result($rsChk);
return false;
}
phpmkr_free_result($rsChk);
}
if (@$x_user == "" || (is_null(@$x_user))) { // Check field with unique index
// Ignore
} else {
$sFilter = "(`user` = '" . AdjustSql($x_user) . "')";
$sSqlChk = ewBuildSql(ewSqlSelect, ewSqlWhere, ewSqlGroupBy, ewSqlHaving, ewSqlOrderBy, $sFilter, "");
$rsChk = phpmkr_query($sSqlChk, $conn) or die("Failed to execute query at line " . __LINE__ . ": " . phpmkr_error($conn) . '<br />SQL: ' . $sSqlChk);
if (phpmkr_num_rows($rsChk) > 0) {
$_SESSION[ewSessionMessage] = "This Username is already in use: " . $x_user;
phpmkr_free_result($rsChk);
return false;
}
phpmkr_free_result($rsChk);
}
if (@$x_email == "" || (is_null(@$x_email))) { // Check field with unique index
// Ignore
} else {
$sFilter = "(`email` = '" . AdjustSql($x_email) . "')";
$sSqlChk = ewBuildSql(ewSqlSelect, ewSqlWhere, ewSqlGroupBy, ewSqlHaving, ewSqlOrderBy, $sFilter, "");
$rsChk = phpmkr_query($sSqlChk, $conn) or die("Failed to execute query at line " . __LINE__ . ": " . phpmkr_error($conn) . '<br />SQL: ' . $sSqlChk);
if (phpmkr_num_rows($rsChk) > 0) {
$_SESSION[ewSessionMessage] = "This E-mail address is already in use: " . $x_email;
phpmkr_free_result($rsChk);
return false;
}
phpmkr_free_result($rsChk);
}
// Field user
$theValue = (!get_magic_quotes_gpc()) ? addslashes($GLOBALS["x_user"]) : $GLOBALS["x_user"];
$theValue = ($theValue != "") ? " '" . $theValue . "'" : "NULL";
$fieldList["`user`"] = $theValue;
// Field pass
$theValue = (!get_magic_quotes_gpc()) ? addslashes($GLOBALS["x_pass"]) : $GLOBALS["x_pass"];
$theValue = ($theValue != "") ? " '" . $theValue . "'" : "NULL";
$fieldList["`pass`"] = $theValue;
// Field email
$theValue = (!get_magic_quotes_gpc()) ? addslashes($GLOBALS["x_email"]) : $GLOBALS["x_email"];
$theValue = ($theValue != "") ? " '" . $theValue . "'" : "NULL";
$fieldList["`email`"] = $theValue;
$fieldList["`UserLevel`"] = 1;
// User ID field
if ((CurrentUserID() <> -1) && (CurrentUserID() <> "")) { // Non system admin
$fieldList["`user`"] = "'" . CurrentUserID() . "'";
}
// Inserting event
if (Recordset_Inserting($fieldList)) {
// Insert
$sSql = "INSERT INTO `sec` (";
$sSql .= implode(",", array_keys($fieldList));
$sSql .= ") VALUES (";
$sSql .= implode(",", array_values($fieldList));
$sSql .= ")";
phpmkr_query($sSql, $conn) or die("Failed to execute query at line " . __LINE__ . ": " . phpmkr_error($conn) . '<br />SQL: ' . $sSql);
$fieldList["`id`"] = phpmkr_insert_id($conn);
$result = (phpmkr_affected_rows($conn) > 0);
// Inserted event
if ($result) Recordset_Inserted($fieldList);
} else {
$result = false;
}
return $result;
}
// Inserting event
function Recordset_Inserting(&$newrs)
{
// Enter your customized codes here
return true;
}
// Inserted event
function Recordset_Inserted($newrs)
{
$table = "sec";
}
?>