<?php
/*
######################      CWB      #######################
############################################################
CWB PRO			$Name: release_version1_0_03112006 $
Revision		$Revision: 1.2 $
Author			$Author: zelteto $
Created 03/01/03        $Date: 2006/10/26 13:41:55 $
Writed by               GraFX (webmaster@grafxsoftware.com)
Scripts Home:           http://www.grafxsoftware.com
############################################################
*/
	include_once("../config.inc.php");
	include_once(INDEX_PATH."cls_fast_template.php");
	include_once(INCLUDE_LANGUAGE_PATH.$LANG.".inc.php");
	include_once(INCLUDE_LANGUAGE_PATH.$LANG.".admin.inc.php");
	include_once(INCLUDE_ADMIN_PATH."authenticate.php");
	include_once(INCLUDE_ADMIN_PATH."menuleft.inc.php");
	include_once(INCLUDE_ADMIN_PATH."menuright.inc.php");
	include_once(INCLUDE_ADMIN_PATH."cls_string.php");
	include_once(INCLUDE_ADMIN_PATH."cls_pages.php");
    include_once(INCLUDE_ADMIN_PATH."cls_miniFile.php");
	
	$stringutil = new String("nope");
	$all_url_vars = array();
	$all_url_vars = $stringutil->parse_all();
	// begin authenticate part
	if(AUTH_TYPE == 1)
	{
		if (!$AUTHENTICATE)
		{
			 header( "WWW-Authenticate: Basic realm=\"ADMIN ".CONF_SITE_NAME."\"");
			 header( "HTTP/1.0 401 Unauthorized");
			 $ft = new FastTemplate(ADMIN_TEMPLATE_CONTENT_PATH);
			 $ft->define(array("main"=>"template_firstpage.html", "content"=>"authentication_failed.html"));
			 $ft->assign("ADMIN_URL", ADMIN_URL);
			 $ft->assign("VERSION", VERSION );
			 $ft->assign("ADDON","<br /><br />");
			 $ft->multiple_assign_define("LANG_");
			 $ft->multiple_assign_define("CONF_");
			 $ft->parse("BODY", array("content","main"));
			 $ft->showDebugInfo(ERROR_DEBUG);
			 $ft->FastPrint();
			 exit;
		}
	}
	else if(AUTH_TYPE == 2)
	{
		include_once(INCLUDE_PATH.'cls_session.php');
		$sess = new MYSession();
		//session_regenerate_id();
		if (!$sess->get(SESSION_ID))
		{
			$sess->set('session_url_before',$_SERVER['REQUEST_URI']);
			header("Location: login.php");
			exit;
		}
	}// end authenticate part
	if ($all_url_vars['action']=="form")
	{
		$ft = new FastTemplate(ADMIN_TEMPLATE_CONTENT_PATH);
		$ft->define(array("main"=>"template_index.html", "content"=>"page_addpage.html"));
		$ft->assign("ADMIN_URL", ADMIN_URL);
		$ft->assign("MENULEFT",$menuleft);
		$ft->assign("MENURIGHT",$menuright);
		
		if(!strstr(PHP_OS, 'WIN'))
			{
				if (!is_writable(REPOSITORY_PATH."bd.php")) $ft->assign("ERROR", LANG_CONF_ERROR_NOBD);
   			        
					
			}
			else $ft->assign("ERROR", "");
		
		
		
		$ft->assign("VERSION", VERSION );
		$ft->multiple_assign_define("LANG_");
		$ft->multiple_assign_define("CONF_");
		$ft->parse("BODY", array("content","main"));
		$ft->showDebugInfo(ERROR_DEBUG);
		$ft->FastPrint();
	}
	
	else
	if ($all_url_vars['action']=="add")
	{
		$page = new Pages($stringutil->CleanLink(($all_url_vars['title'])));	
		$page->setTitle(htmlspecialchars($all_url_vars['title']));
		$page->setDescription($all_url_vars['description']);
		$page->setKeyword($all_url_vars['keyword']);
		$page->save();						 
		$ft = new FastTemplate(ADMIN_TEMPLATE_CONTENT_PATH);
		$ft->define(array("main"=>"template_index.html", "content"=>"page_confirm.html"));		
		$ft->assign("ADMIN_URL", ADMIN_URL);
		$ft->assign("MENULEFT",$menuleft);
		$ft->assign("MENURIGHT",$menuright);
		$ft->assign("VERSION", VERSION );
		$ft->assign("TEXT1", LANG_ADMIN_PAGE_MSG_ADDED_SUCCESSFULLY);
		$ft->assign("TEXT2",LANG_ADMIN_CAT_MESSAGE_CAT_ADDMORE."<br />");
		$ft->assign("ACTION","addpage.php?action=form");
		$ft->multiple_assign_define("LANG_");
		$ft->multiple_assign_define("CONF_");
		$ft->parse("BODY", array("content","main"));
		$ft->showDebugInfo(ERROR_DEBUG);
		$ft->FastPrint();
	}//end if ($all_url_vars['action']==add)
?>