,#####
count($lang_list))
$_SESSION["current_language "] = 0; //set default language
//include a language file
if (isset($lang_list[$_SESSION["current_language"]]) &&
file_exists("languages/".$lang_list[$_SESSIO N["current_language"]]->filename))
{
//includ e current language file
include("languages/".$lang_list[$_SESSION[ "current_language"]]->filename);
}
else
{
die("ERROR: Couldn't find language file!");
}
//connect to the database
db_connect(DB_HOST,DB_USER,DB_PASS) or die (db_error());
db_select_db(DB_NAME) or die (db_error());
settingDefineConstants();
if ((int)CONF_SMARTY_FORCE_COMPILE) //this forces Smarty to recompile templates each time someone runs index.php
{
$smarty->force_compile = true;
$smarty_mail->force_compile = true;
}
//# of selected currency
$current_currency = isset($_SESSION["current_currency"]) ? $_SESSION["current_currency"] : CONF_DEFAULT_CURRENCY;
$smarty->assign("current_ currency", die("
$q = db_query("select code, currency_value, where2show, currency_iso_3, Name from ".CURRENCY_TYPES_TABLE." where CID='$current_currency'") or die (db_error());
if ($row = db_fetch_row($q))
{
$smarty->assign("currency _name", die("
$selected_currency_details = $row; //for show_price() function
}
else //no currency found. In this case check is there any currency type in the database
{
$q = db_query("select code, currency_value, where2show from ".CURRENCY_TYPES_TABLE) or die (db_error());
if ($row = db_fetch_row($q))
{
$smarty->assign("curren cy_name", die("
$selected_currency_details = $row; //for show_price() function
}
}
$sql = db_query("SELECT * FROM ngcms_banners ORDER BY RAND() LIMIT 3");
//$db->speak($sql);
$counter = 0;
while ($row = db_fetch_row($sql))
{
$banners[$counter]['fil e'] die("
$banners[$counter]['link'] = $row['link'];
$counter++;
}
if (count($banners) > 0)
{
$smarty->assign('banners', $banners);
}
//load all categories to array $cats to avoid multiple DB queries (frequently used in future - but not always!)
$cats = array();
$i=0;
$q = db_query("SELECT categoryID, name, parent, products_count, description, picture FROM ".
CATEGORIES_TABLE." where categoryID<>0 ORDER BY sort_order, name") or die (db_error());
while ($row = db_fetch_row($q))
{
$cats[$i++] = $row;
}
// -------------SET SMARTY VARS AND INCLUDE SOURCE FILES------------//
if (isset($productID)) //to rollout categories navigation table
{
$q = db_query("SELECT categoryID FROM ".PRODUCTS_TABLE." WHERE productID='$productID'") or die (db_error());
$r = db_fetch_row($q);
if ($r) $categoryID = $r[0];
}
//set Smarty include files dir
$smarty->template_dir = "./templates/frontend/".$lang_list[$_SESSION["curr ent_language"]]->template_path;
$smarty_mail->te mplate_dir = "./templates/email";
//assign core Smarty variables
//fetch currency types from database
$q = db_query("select CID, Name, code, currency_value, where2show from ".CURRENCY_TYPES_TABLE." order by sort_order") or die (db_error());
$currencies = array();
while ($row = db_fetch_row($q))
{
$currencies[] = $row;
}
$smarty->assign("currencies", $currencies);
$smarty->assign("currencies_count" , mplate_dir count($currencies));
if (isset($_SESSION["current_language"])) $smarty->assign("current_language", $_SESSION["current_language"]);
if (isset($_SESSION["log"])) $smarty->assign("log", $_SESSION["log"]);
// - following vars are used as hidden in the customer survey form
if ( isset($categoryID) )
$smarty->assign("categoryID", $categoryID);
if (isset($productID)) $smarty->assign("productID", $productID);
if (isset($_GET["currency"])) $smarty->assign("currency", $_GET["currency"]);
if (isset($_GET["user_details"])) $smarty->assign("user_details", $_GET["user_details"]);
if (isset($_GET["aux_page"])) $smarty->assign("aux_page", $_GET["aux_page"]);
if (isset($_GET["show_price"])) $smarty->assign("show_price", $_GET["show_price"]);
if (isset($_GET["adv_search"])) $smarty->assign("adv_search", $_GET["adv_search"]);
if (isset($_GET["searchstring"])) $smarty->xassign("searchstring", $_GET["searchstring"]);
if (isset($register)) $smarty->assign("register", $register);
if (isset($order)) $smarty->assign("order", $order);
if (isset($check_order)) $smarty->assign("check_order", $check_order);
//set defualt main_content template to homepage
$smarty->assign("main_content_template" , mplate_dir "home.tpl.html");
//include all .php files from includes/ dir
$includes_dir = opendir("./includes");
$files = array();
while ( ($inc_file = readdir($includes_dir)) != false )
if (strstr($inc_file,".php"))
{
$files[] = $inc_file;
}
sort($files);
foreach ($files as $fl)
{
include("./includes/".$fl);
}