<?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
if (@phpversion() >= '5.0.0' && (!@ini_get('register_long_arrays') || @ini_get('register_long_arrays') == '0' || strtolower(@ini_get('register_long_arrays')) == 'off')) { // PHP5 with register_long_arrays off
$HTTP_POST_VARS = &$_POST;
$HTTP_GET_VARS = &$_GET;
$HTTP_SERVER_VARS = &$_SERVER;
$HTTP_COOKIE_VARS = &$_COOKIE;
$HTTP_ENV_VARS = &$_ENV;
$HTTP_POST_FILES = &$_FILES;
if (isset($_SESSION)) $HTTP_SESSION_VARS = &$_SESSION;
}
?>
<?php include ("ewconfig.php") ?>
<?php include ("db.php") ?>
<?php include ("thematicinfo.php") ?>
<?php include ("advsecu.php") ?>
<?php include ("phpmkrfn.php") ?>
<?php include ("ewupload.php") ?>
<?php
if (!IsLoggedIn() && (@$HTTP_COOKIE_VARS[ewCookieAutoLogin] == "autologin" && @$HTTP_COOKIE_VARS[ewCookiePassword] <> "")) {
ob_end_clean();
header("Location: login.php");
exit();
}
LoadUserLevel();
$ewCurSec = (IsLoggedIn())? CurrentUserLevelPriv("thematic") : GetAnonymousPriv("thematic");
if (($ewCurSec & ewAllowAdd) <> ewAllowAdd) {
ob_end_clean();
header("Location: thematiclist.php");
exit();
}
?>
<?php
// Initialize common variables
$x_id_thematic = NULL;
$ox_id_thematic = NULL;
$z_id_thematic = NULL;
$ar_x_id_thematic = NULL;
$ari_x_id_thematic = NULL;
$x_id_thematicList = NULL;
$x_id_thematicChk = NULL;
$cbo_x_id_thematic_js = NULL;
$x_thematic = NULL;
$ox_thematic = NULL;
$z_thematic = NULL;
$ar_x_thematic = NULL;
$ari_x_thematic = NULL;
$x_thematicList = NULL;
$x_thematicChk = NULL;
$cbo_x_thematic_js = NULL;
?>
<?php
// Load key from QueryString
$bCopy = true;
$x_id_thematic = @$HTTP_GET_VARS["id_thematic"];
if (($x_id_thematic == "") || ($x_id_thematic == NULL)) $bCopy = false;
// Get action
$sAction = @$HTTP_POST_VARS["a_add"];
if (($sAction == "") || (($sAction == NULL))) {
if ($bCopy) {
$sAction = "C"; // Copy record
} else {
$sAction = "I"; // Display blank record
}
} else {
// Get fields from form
$x_id_thematic = @$HTTP_POST_VARS["x_id_thematic"];
$x_thematic = @$HTTP_POST_VARS["x_thematic"];
}
$conn = phpmkr_db_connect(HOST, USER, PASS, DB, PORT);
switch ($sAction) {
case "C": // Copy record
if (!LoadData($conn)) { // Load record
$HTTP_SESSION_VARS[ewSessionMessage] = "No records found";
phpmkr_db_close($conn);
ob_end_clean();
header("Location: thematiclist.php");
exit();
}
break;
case "A": // Add
if (AddData($conn)) { // Add new record
$HTTP_SESSION_VARS[ewSessionMessage] = "Add New Record Successful";
phpmkr_db_close($conn);
ob_end_clean();
header("Location: thematiclist.php");
exit();
}
break;
}
?>
<?php include ("header.php") ?>
<script type="text/javascript">
<!--
EW_LookupFn = "ewlookup.php"; // ewlookup file name
EW_AddOptFn = "ewaddopt.php"; // ewaddopt.php file name
EW_MultiPagePage = "Page"; // multi-page Page Text
EW_MultiPageOf = "of"; // multi-page Of Text
//-->
</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) {
return true;
}
//-->
</script>
<script type="text/javascript">
<!--
var EW_DHTMLEditors = [];
//-->
</script>
<p><span class="phpmaker">Add to TABLE: Type of Thematic<br><br><a href="thematiclist.php">Back to List</a></span></p>
<form name="fthematicadd" id="fthematicadd" action="thematicadd.php" method="post" onSubmit="return EW_checkMyForm(this);">
<p>
<input type="hidden" name="a_add" value="A">
<?php
if (@$HTTP_SESSION_VARS[ewSessionMessage] <> "") {
?>
<p><span class="ewmsg"><?php echo $HTTP_SESSION_VARS[ewSessionMessage] ?></span></p>
<?php
$HTTP_SESSION_VARS[ewSessionMessage] = ""; // Clear message
}
?>
<table class="ewTable">
<tr id="r_thematic">
<td class="ewTableHeader"><span>thematic</span></td>
<td class="ewTableAltRow"><span id="cb_x_thematic">
<input type="text" name="x_thematic" id="x_thematic" size="30" maxlength="100" value="<?php echo htmlspecialchars(@$x_thematic) ?>">
</span></td>
</tr>
</table>
<p>
<input type="submit" name="btnAction" id="btnAction" value="ADD">
</form>
<?php include ("footer.php") ?>
<?php
phpmkr_db_close($conn);
?>
<?php
//-------------------------------------------------------------------------------
// Function LoadData
// - Variables setup: field variables
function LoadData($conn)
{
global $HTTP_SESSION_VARS;
global $x_id_thematic;
$sFilter = ewSqlKeyWhere;
if (!is_numeric($x_id_thematic)) return false;
$x_id_thematic = (get_magic_quotes_gpc()) ? stripslashes($x_id_thematic) : $x_id_thematic;
$sFilter = str_replace("@id_thematic", AdjustSql($x_id_thematic), $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_thematic"] = $row["id_thematic"];
$GLOBALS["x_thematic"] = $row["thematic"];
}
phpmkr_free_result($rs);
return $bLoadData;
}
?>
<?php
//-------------------------------------------------------------------------------
// Function AddData
// - Add Data
// - Variables used: field variables
function AddData($conn)
{
global $HTTP_SESSION_VARS;
global $HTTP_POST_VARS;
global $HTTP_POST_FILES;
global $HTTP_ENV_VARS;
global $x_id_thematic;
global $x_thematic;
$sFilter = ewSqlKeyWhere;
// Check for duplicate key
$bCheckKey = true;
if ((@$x_id_thematic == "") || (@$x_id_thematic == NULL)) {
$bCheckKey = false;
} else {
$sFilter = str_replace("@id_thematic", AdjustSql($x_id_thematic), $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) {
$HTTP_SESSION_VARS[ewSessionMessage] = "Duplicate value for primary key";
phpmkr_free_result($rsChk);
return false;
}
phpmkr_free_result($rsChk);
}
if (@$x_thematic == "" || (@$x_thematic == NULL)) { // Check field with unique index
// Ignore
} else {
$sFilter = "(`thematic` = '" . AdjustSql($x_thematic) . "')";
$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) {
$HTTP_SESSION_VARS[ewSessionMessage] = "Duplicate value for index or primary key -- `thematic`, value = " . $x_thematic;
phpmkr_free_result($rsChk);
return false;
}
phpmkr_free_result($rsChk);
}
// Field thematic
$theValue = (!get_magic_quotes_gpc()) ? addslashes($GLOBALS["x_thematic"]) : $GLOBALS["x_thematic"];
$theValue = ($theValue != "") ? " '" . $theValue . "'" : "NULL";
$fieldList["`thematic`"] = $theValue;
// Insert
$sSql = "INSERT INTO `thematic` (";
$sSql .= implode(",", array_keys($fieldList));
$sSql .= ") VALUES (";
$sSql .= implode(",", array_values($fieldList));
$sSql .= ")";
// Inserting event
if (Recordset_Inserting($fieldList)) {
phpmkr_query($sSql, $conn) or die("Failed to execute query at line " . __LINE__ . ": " . phpmkr_error($conn) . '<br>SQL: ' . $sSql);
$fieldList["`id_thematic`"] = 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)
{
global $HTTP_SESSION_VARS;
global $HTTP_POST_VARS;
global $HTTP_POST_FILES;
global $HTTP_ENV_VARS;
$table = "thematic";
}
?>