Location: PHPKode > projects > phpCAMALEO > common/private/FAQ_mngr.php
<?php
/***************************************************************************
 *	Session.php
 *
 *	begin		: August 2006
 *	version		: 9 October 2006
 *	copyright	: (C) 2006 grandolini.net
 *
 *	FAQ Manager
 *
 ***************************************************************************/
include('../../Session.php');
check_access($USER_ID,$USER_PW,90);
#
if(file_exists($_SESSION[skinf].'def/'.$_SESSION[sitelanguage].'/faq_mngr_defs.php'))
{
	include($_SESSION[skinf].'def/'.$_SESSION[sitelanguage].'/faq_mngr_defs.php');
}
else
{
	include($_SERVER[DOCUMENT_ROOT].$_SESSION[misc][folder].'skins/phpCAMALEO/def/'.$_SESSION[sitelanguage].'/faq_mngr_defs.php');
}
switch($_GET[optype])
{
	case 'cadd': $title=ADMIN_FAQ.': '.ADD.' '.FAQ_CAT; $focus='category'; break;
	case 'cmod': $title=ADMIN_FAQ.': '.EDIT.' '.FAQ_CAT; $focus='category'; $_SESSION[catid]=$_GET[catid]; $category=$_GET[catname]; break;
	case 'cdel': $title=ADMIN_FAQ.': '.DELETE.' '.FAQ_CAT; $_SESSION[catid]=$_GET[catid]; $category=$_GET[catname]; break;
	#
	case 'flist':	$_SESSION[catid]=$_GET[catid];
					$_SESSION[category]=$_GET[catname];
					$title=ADMIN_FAQ.': '.$_SESSION[category];
					$_SESSION[faqed]='@';
					break;
	#
	case 'fadd':	$title=ADMIN_FAQ.': '.ADD.' '.FAQ_FAQ; $focus='question'; $_SESSION[faqed]='@'; break;
	#
	case 'fmod':	$_SESSION[catid]=$_GET[catid];
					$_SESSION[faqid]=$_GET[faqid];
					$sth=db_query("SELECT * FROM faqs WHERE id='$_SESSION[faqid]'"); $row=db_fetch($sth[0]);
					$question=$row[0][question];
					$answer=$row[0][answer];
					$title=ADMIN_FAQ.': '.EDIT.' '.FAQ_FAQ; $focus='question'; 
					break;
	#
	case 'fdel':	$_SESSION[faqid]=$_GET[faqid];
					$sth=db_query("SELECT * FROM faqs WHERE id='$_SESSION[faqid]'"); $row=db_fetch($sth[0]);
					$question=$row[0][question];
					$answer=$row[0][answer];
					$title=ADMIN_FAQ.': '.DELETE.' '.FAQ_FAQ;
					break;
	#
	default: $title=ADMIN_FAQ; unset($_SESSION[faqed]);
}
#
if($_POST[category]!='') { $category=$_POST[category]; }
#
if(isset($_POST[submit]))
{
	switch($_POST[submit])
	{
		case ADD_FAQC:	$sth=db_query('INSERT INTO faqcategories SET siteid=\''.$_SESSION[misc][skin]."',category='$category'"); break;
		case UPD_FAQC:	$sth=db_query("UPDATE faqcategories SET category='$_POST[category]',siteid='".$_SESSION[misc][skin]."' WHERE id='$_POST[id]'"); break;
		case DEL_FAQC:	$sth=db_query('DELETE FROM faqs WHERE category_id=\''.$_SESSION[catid].'\' AND siteid=\''.$_SESSION[misc][skin].'\'');
						$sth=db_query('DELETE FROM faqcategories WHERE id=\''.$_SESSION[catid].'\' AND siteid=\''.$_SESSION[misc][skin].'\''); break;
		#
		case ADD_FAQ:	$sth=db_query("INSERT INTO faqs SET category_id='$_POST[catid]',question='$question',answer='$answer',siteid='".$_SESSION[misc][skin].'\'');
						header('Location: '.$_SERVER[PHP_SELF].'?optype=flist&catid='.$_SESSION[catid].'&catname='.$_SESSION[category]); die;
						break;
		case UPD_FAQ:	$sth=db_query("UPDATE faqs SET question='$_POST[question]',answer='$_POST[answer]' WHERE id='$_POST[id]'");
						header('Location: '.$_SERVER[PHP_SELF].'?optype=flist&catid='.$_SESSION[catid].'&catname='.$_SESSION[category]); die;
						break;
		case DEL_FAQ:	$sth=db_query("DELETE FROM faqs WHERE id='$_POST[id]' AND siteid='".$_SESSION[misc][skin].'\'');
						header('Location: '.$_SERVER[PHP_SELF].'?optype=flist&catid='.$_SESSION[catid].'&catname='.$_SESSION[category]); die;
						break;
	}
}
include($_SESSION[common].'contents/FAQ_mngr.tpl');
?>
Return current item: phpCAMALEO