Location: PHPKode > projects > JobAppr > Jobappr-1.4/admin/settings.php
<?php 
session_start();
if(!isset($_SESSION['password'])){
	header("Location: index.php");
	exit();
}
if( $_SESSION['role'] != 1 ){
	header("Location: dashboard.php");
	exit();
}
require_once('../includes/functions.php');
require_once('inc/admin-functions.php');

# VARIABLES
$user_id = $_SESSION['user_id'];
$error = null;
$show_add=false;

if(isset($_GET['delete'])) {
	$status= mysql_query("DELETE FROM ". TB_SETTINGS ." WHERE `meta`='".$_GET['delete']."'");
	if($status) {
		$success = 'The <b>'.$_GET['delete'].'</b> setting has been successfully deleted';
	} else {
		$error .= mysql_error();
	}
}

if(isset($_POST['submit'])) {
	
	if ( $_POST['new_title'] != '' && $_POST['new_value'] != '' ) {
		$title = to7bit($_POST['new_title'], "UTF-8");
    $meta = clean_url($title);
		mysql_query("INSERT INTO ". TB_SETTINGS ." VALUES ( '".urlencode(clean($meta))."', '".clean($_POST['new_value'])."', '".clean($_POST['new_title'])."', '".clean($_POST['new_desc'])."', '".clean($_POST['new_lock'])."' )");
		$error .= mysql_error();
	}
	
	unset($_POST['submit']);
	unset($_POST['new_meta']);
	unset($_POST['new_value']);
	$ct=0;
	foreach( $_POST as $update ) {
		$meta=KeyName($_POST, $ct);
		$sql="UPDATE ". TB_SETTINGS ." SET `value`='".clean($update)."'	WHERE `meta`='".$meta."'";
		#echo $sql.'<br />';
		mysql_query($sql);
		$error .= mysql_error();
		$ct++;
	}
	if (!$error) { $success = 'Site settings have been successfully updated'; }
}

?>

<?php get_template('header', 'Site Settings'); ?>

	<div id="main">
		<?php display_messages(); ?>
		
		<h1>Site Settings</h1>

		
		<form id="settings" method="post" action="<?php echo get_filename(); ?>" >
			<table id="list_of_fields" >
				<?php
					# get settings data
					$data=mysql_query("SELECT * FROM ". TB_SETTINGS." ORDER BY `title` ASC");
					while ($row = mysql_fetch_assoc($data)) {
						
						if ($row['lock'] === "Y") {
							$delete = ' &nbsp; <img src="assets/images/lock.gif" alt="Locked Field" />';
						} else {
							$delete = ' &nbsp; <a href="'. get_filename().'?delete='.$row['meta'].'" title="You are about to delete '.$row['title'].'" rel="'.$row['meta'].'" rel2="settings" class="delconfirm"><img src="assets/images/trash.gif" alt="Delete Field" /></a>';
						}
						
						echo '<tr><td class="label"><label for="'.$row['meta'].'">'.$row['title'].'</label></td><td><input class="text" name="'.$row['meta'].'" id="'.$row['meta'].'" value="'._r($_POST[$row['meta']], $row['value']).'" />'.$delete.'<em>'.$row['desc'].'</em></td></tr>';
	
					}
				?>
				<?php if($show_add) { ?>
				<tr>
					<td colspan="2" ><h4>Create a New Setting</h4></td>
				</tr>
				<tr>
					<td colspan="2" ><em>Title</em><input type="text" class="text" name="new_title" value="<?php echo $_POST['new_title']; ?>" /></td>
				</tr>
				<tr>
					<td colspan="2" ><em>Value</em><input type="text" class="text" name="new_value" value="<?php echo $_POST['new_value']; ?>" /></td>
				</tr>
				<tr>
					<td colspan="2" ><input type="checkbox" name="new_lock" value="Y" /> <em style="display:inline" >&nbsp;Protect this setting from deletion?</em></td>
				</tr>
				<tr>
					<td colspan="2" ><em>Description</em><textarea type="text" class="text short" name="new_desc" ><?php echo $_POST['new_desc']; ?></textarea></td>
				</tr>
				<?php  } ?>
				<tr>
					<td colspan="2"><input type="submit" class="submit" name="submit" value="Save Settings" /></td>
				</tr>
			</table>
		</form>
	
	</div>
	
	
<?php get_template('sidebar'); ?>

<?php get_template('footer'); ?>
Return current item: JobAppr