setCaching(Smarty::CACHING_LIFETIME_CURRENT); $smarty->setTemplateDir($cfg['site']['system_path'] . '/templates'); $smarty->setCompileDir($cfg['site']['system_path'] . '/templates_c'); $smarty->setCacheDir($cfg['site']['system_path'] . '/cache'); $smarty->setConfigDir($cfg['site']['system_path'] . '/config'); // output buffer // ob_start( 'ob_gzhandler' ); // show content if (strlen($page) != 0) { $smarty->assign('page', $page); if (strlen($module) != 0 ) { $filepath = "content/modules/" . $module . "/" . $page . ".php"; if (file_exists($filepath)) { include($filepath); } else { echo ""; } } else { $filepath = "content/" . $page . ".php"; if (file_exists($filepath)) { include($filepath); } } if ((($page == 'product') || ($page == 'product_detail')) && ($_GET['new_product' != 'y'])) { $sql = "SELECT img FROM catalog_category WHERE cat_id = $cat_id LIMIT 0,1"; if( MDB2::isError($img =& $dbconn->queryOne($sql)) ) { throw new Exception('SQL Exception : ' . $img->getMessage() . "\n" . safe($sql)); } if ($img) { $style = "style='background:url($img) no-repeat top center'"; $smarty->assign('style', $style); } } } else { $objScan = scandir($cfg['site']['system_path'] . "/upload/userfiles/image/themes/slide"); foreach ($objScan as $value) { if($value != ".." && $value != "."){ $slides[] = $value; } } $smarty->assign('page', 'main'); $smarty->assign('slides', $slides); include("content/main.php"); } // query menu $sql = "SELECT cat_id, cat_name_th FROM catalog_category ORDER BY rank, cat_id"; if( MDB2::isError($menus =& $dbconn->queryAll($sql)) ) { throw new Exception('SQL Exception : ' . $menus->getMessage() . "\n" . safe($sql)); } // query banner $sql = "SELECT id, title, detail, url, img FROM cms_banner_item WHERE published = 'Y'"; if( MDB2::isError($banners =& $dbconn->queryAll($sql)) ) { throw new Exception('SQL Exception : ' . $banners->getMessage() . "\n" . safe($sql)); } // assign template variables $smarty->assign('menus', $menus); $smarty->assign('banners', $banners); // display it $smarty->display('index.tpl'); // Clean (erase) the output buffer ob_end_flush(); // disconnect if ($dbconn) { db_disconnect(); } ?>