Location: PHPKode > projects > phpCAMALEO > common/private/Config.php
<?php
/***************************************************************************
 *	Config.php
 *
 *	begin		: August 2006
 *	version		: 10 October 2006
 *	copyright	: (C) 2006 grandolini.net
 *
 *	Editing of the site config varialbles
 *
 ***************************************************************************/
include('../../Session.php');
check_access($USER_ID,$USER_PW,90);
#
if(!isset($_SESSION[misc][SITECODE]) || $_SESSION[misc][SITECODE]=='')
{
	$_SESSION[misc][SITE]=$_SESSION[misc][skin];
	$_SESSION[misc][SITECODE]=$_SESSION[misc][skin];
}
?>
<html>
<head>
	<title><?=$_SESSION[misc][SITE]?>: Configuration <?=$_SESSION[misc][server_name_title]?></title>
	<link rel="stylesheet" href="../../skins/<?=$_SESSION[misc][skin]?>/MAIN.CSS" type="text/css" />
	<?php
	switch($_SESSION[browser])
	{
		case 'FF': ?><link rel="stylesheet" href="../../skins/<?=$_SESSION[misc][skin]?>/MAIN_FF.CSS" type="text/css" /><?php break;
		case 'IE': ?><link rel="stylesheet" href="../../skins/<?=$_SESSION[misc][skin]?>/MAIN_IE.CSS" type="text/css" /><?php break;
	}
 	echo "\n\n";
	?>
</head>
<body style="margin:10px 10 10 10;">
	<form method="post" action="<?=$_SERVER[PHP_SELF]?>">
		<table class="form_table" cellpadding="3" border="0">
			<tr>
				<td align="right"><img src="../../img/camaleos/camaleo.h50dk.gif" /></td>
				<td colspan="2"><h3><a href="../../LoadPage.php?page=siteadmin"><?=$_SESSION[misc][SITE]?></a>: Configuration</h3></td>
			</tr>
			<tr><td colspan="3"><hr id="line"></td></tr>
			<th align="left">Key</th>
			<th align="left">Value</th>
			<th align="left">Help</th>
			<tr><td colspan="3"><hr id="line"></td></tr>
			<?php
			#=====================
			#	load screen vars
			#=====================
			if(!isset($_SESSION[screen][t]) || $_SESSION[screen][t]=='' || $_POST[submit]=='reload')
			{
				#	from table
				#
				$args='SELECT * FROM site_settings WHERE site=\'*hlp\' ';
				if($_SESSION[misc][SITECODE]=='phpCAMALEO') { $args.=' AND code!=\'*site\' ';}
				$sth=db_query($args.'ORDER BY code');
				$help=db_fetch($sth[0]);
				$t=$sth[1];
				for($i=0;$i<$t;$i++)
				{
					$_SESSION[screen][$i][help]=$help[$i][value];
					$sth=db_query('SELECT * FROM site_settings WHERE site=\''.$_SESSION[misc][SITECODE].'\' AND code=\''.$help[$i][code].'\'');
					$row=db_fetch($sth[0]);
					$_SESSION[screen][$i][code]=$help[$i][code];
					$_SESSION[screen][$i][value]=$row[0][value];
				}
				$_SESSION[screen][t]=$t;
			}
			else
			{
				#	from screen
				#
				for($i=0;$i<$_SESSION[screen][t];$i++)
				{
					$_SESSION[screen][$i][value]=$_POST['param_'.$i]; 
				}
			}
			#=====================
			#	button handling
			#=====================
			switch($_POST[submit])
			{
				case 'save':
					for($i=0;$i<$_SESSION[screen][t];$i++)
					{
						$key=$_SESSION[screen][$i][code];
						$val=$_SESSION[screen][$i][value];
						$sth=db_query("SELECT * FROM site_settings WHERE code='$key' AND site='".$_SESSION[misc][SITECODE].'\'');
						if($sth[1]>0)
						{
							$sth=db_query("UPDATE site_settings SET value='$val' WHERE code='$key' AND site='".$_SESSION[misc][SITECODE].'\'');
						}
						else
						{
							$sth=db_query("INSERT INTO site_settings SET site='".$_SESSION[misc][SITECODE]."', code='$key', value='$val'");
						}
						if($key=='*SITE') { $key='SITE'; }
						$_SESSION[misc][$key]=$val;
					}
					?><tr><td colspan="3"><h3>Configuration updated!</h3><a href="../../LoadPage.php?page=siteadmin">Click here</a> to return to the ADMIN HOME page</td></tr><?php
					break;
			}
			#=====================
			#	drawing screen
			#=====================
			for($i=0;$i<$_SESSION[screen][t];$i++)
			{
				?><tr>
					<td id="color1" align="left"><font id="sml"><?=$_SESSION[screen][$i][code]?></font></td>
					<td id="color1" align="left"><input class="form" size="32" name="param_<?=$i?>" value="<?=$_SESSION[screen][$i][value]?>"></td>
					<td id="color1" align="left" width="90%"><?=$_SESSION[screen][$i][help]?></td>
				</tr><tr><td colspan="3"><hr id="lineref"></td></tr><?php
			}
			?>
			<tr>
				<td colspan="3" align="center"><hr id="line"><h3 style="color:#fffc00; background:#ff0000;"><br />WARNING! No checks are performed, you change this data at your own risk...<br /><br /></td>
			</tr>
			<tr>
				<td colspan="3" align="center"><hr id="line">
					<a href="../../LoadPage.php?page=siteadmin">Click here</a> to return to the ADMIN HOME page&nbsp;&nbsp;@&gt;&nbsp;&nbsp;<input class="button_red" type="submit" name="submit" value="save">&nbsp;<input class="button" type="submit" name="submit" value="reload">
				</td>
			</tr>
		</table>
	</form>
<script>document.forms[0].param_0.focus();</script>
<div align="center"><br /><font style="font-size:75%;">Copyright &copy; 2006 grandolini.net - All Rights Reserved.</font></div>
</body>
</html>
Return current item: phpCAMALEO