<?php
/*
######################      CWB      #######################
############################################################
CWB PRO			$Name: release_version1_0_03112006 $
Revision		$Revision: 1.2 $
Author			$Author: zelteto $
Created 03/01/03        $Date: 2006/10/30 15:28:21 $
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_PATH."cls_string.php");
	include_once(INCLUDE_ADMIN_PATH."cls_pages.php");
    include_once(INCLUDE_ADMIN_PATH."cls_miniFile.php");
	 include_once(INCLUDE_ADMIN_PATH."cls_arrays.php");

	$stringutil = new String("");
	$all_url_vars = array();
	$stringutil->setIntVars("from");
	$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
	
	   $mf=new MiniFile("bd.php");
	   $data=$mf->getArray();
	   

	   
	   
	   	
		if($all_url_vars["action"]=="first")
		{
			$page = new Pages();	
			$page->setFirst($all_url_vars["page"]);;
			$page->save();
			
		}
		
		$mf=new MiniFile("bd.php");
		$data=$mf->getArray();
		
		$order_arr =
  			array(
   				array('title','a'),  
    		);

       $data = arfsort( $data, $order_arr);
		
			
	
	$i=0;
	foreach($data as $key => $value)
	{
		$idpage[$i] = $key;
		$tit[$i] = $value["title"];
		$descr[$i] = $value["description"];
		$first[$i] = $value["first"];
		$i++;
	}
	$nrproducts = $i;
	

	
	$ft = new FastTemplate(ADMIN_TEMPLATE_CONTENT_PATH);
	if ($nrproducts==0)
	{
		$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_NOPRODUCTSYET);
		$ft->assign("TEXT2", LANG_ADMIN_BACK_TO_MAINPAGE);
		$ft->assign("ACTION","index.php");
		
	}// end if
	else
	{
		$ft->define(array("main"=>"template_index.html", "content"=>"page_listpage.html"));
		
		$ft->assign("PRODUCT_URL_PATH", PRODUCT_URL_PATH);
		$ft->assign("ADMIN_URL", ADMIN_URL);
		$ft->assign("MENULEFT",$menuleft);
		$ft->assign("MENURIGHT",$menuright);
		
		$ft->assign("VERSION", VERSION );
		$ft->assign("LANG", $LANG);
		$ft->define_dynamic("row","content");
		
		$ft->assign("PHPNAME", "listpage");
		$ft->assign("OTHERID", "");
						
		$ft->assign("LANG_ADMIN_MODIFY", LANG_ADMIN_MODIFY);
		$ft->assign("LANG_ADMIN_ARE_YOU_SURE", LANG_ADMIN_ARE_YOU_SURE);
		$ft->assign("LANG_ADMIN_DELETE", LANG_ADMIN_DELETE);
		
		
		
		
		
		for ($i=0;$i<$nrproducts;$i++)
		{
			
			if(file_exists(INDEX_PATH."images/".$idpage[$i].".gif"))
			$ft->assign("TITLE_TAG_IMG", CONF_INDEX_URL."images/".$idpage[$i]);
			else
			$ft->assign("TITLE_TAG_IMG", CONF_INDEX_URL."images/spacer");
			
			 if(NONSEO==0)
			 $ft->assign("URL_TYPE", CONF_INDEX_URL."index.php?page=".$idpage[$i]);	
			 else
			 $ft->assign("URL_TYPE", CONF_INDEX_URL."index.php/".$idpage[$i]."/");
			
			
			
			
			$ft->assign("CHECKED", ($first[$i]==1?"checked":""));
			$ft->assign("TIT", $tit[$i]);
			
			$ft->assign("ID_DESCR",$idpage[$i]);
			$ft->parse("ROW",".row");
		}
	}//end ($nrtotalitems!=0)
	$ft->multiple_assign_define("LANG_");
	$ft->multiple_assign_define("CONF_");
	$ft->parse("BODY", array("content","main"));
	$ft->showDebugInfo(ERROR_DEBUG);
	$ft->FastPrint();
?>