#if (session_status() == PHP_SESSION_NONE) {
session_start();
#}
//database
include_once('wigitadmin/class/settings.config.php');
$db= new db;
//html tags
include_once('wigitadmin/class/html-class.php');
$htm= new htm;
$CMSsize = new CMSsize;
$Utube = new Utube;
include_once('wigitadmin/class/date.php');
$swap_date = new swap_date;
include_once('wigitadmin/includes/functions.php');
// This take the url and take the space out
$path = curPageURL();
$file = basename($path); // $file is set to "index.php"
$page = basename($path, ".php"); // $file is set to "index"
$pname = str_replace ("-", " ", $page);
#print_p($path);
#print_p($pname);
#print_p($page);
if ($pname == NULL || !strpos($path, ".php") || strpos($path, "index.php")) {
$pagename = 'For Home';
$page = "index.php";
}elseif (strpos($path, "business.php") && !strpos($path, "-business.php")) {
$pagename = 'For Business';
$page = "business.php";
}
else {
$pagename = $pname;
}
#print_p($pagename);
##need to find out if category
$sql = "SELECT catid FROM catid where cat_name = '".$pagename."'";
$pagenameid = mysql_query($sql);
$pagerow = mysql_fetch_assoc($pagenameid);
##its a category#####
if(isset($pagerow['catid'])){
unset($_SESSION['current_page']);
unset($_SESSION['parentid']);
$nameid = $pagerow['catid'];
$datatable = "catid";
$pagetype = "catid";
##get banners
$pageresult = mysql_query("SELECT banner_images FROM catid where catid = '".$pagerow['catid']."'"); // Let's get the query
$row = mysql_fetch_assoc($pageresult);
$banner_images = unserialize(stripslashes(urldecode($row['banner_images'])));
$catid = $pagerow['catid'];
$sql = "SELECT * FROM bannerList WHERE `category_id` = '".$pagerow['catid']."' and enabled=1 ORDER BY `ord` ASC";
$qresult = mysql_query($sql);
#### right side banners
//displaying the page row
$rightbanner='';
$bannerlist = mysql_query("SELECT * FROM bannerList WHERE `category_id` = '".$pagerow['catid']."' and enabled=1 ORDER BY `ord` ASC");
while($banrow = mysql_fetch_array( $bannerlist )){
$bannerinfo = mysql_query("SELECT * FROM banner WHERE id = '".$banrow['banner_id']."'");
$ban = mysql_fetch_assoc($bannerinfo);
$rightbanner.= "
".$ban['content']."
";
#echo "
";
}
if($page == "business.php"){
include("template-content-category-bus.php");
}else{
include("template-content-category.php");
}
}
##its a category#####
#####PAGE SECTION#####
else{
$_SESSION['current_page'] = detect_uri();
$pagenameid2 = mysql_query("SELECT * FROM pages where lcase(page_name) = '".strtolower($pname)."'");
$pagerow2 = mysql_fetch_assoc($pagenameid2);
$nameid = $pagerow2['id'];
$datatable = "pages";
$pagetype = "id";
## save the page to a session
if(isset($pagerow2['catid'])){
if(is_numeric($pagerow2['catid'])){
$sql = "SELECT catid FROM catid where catid = ".$pagerow2['catid'];
$catid = mysql_fetch_assoc(mysql_query($sql));
if(isset($catid['catid'])) $_SESSION['parentid'] = $catid['catid'];
}
}
## CONTENT
$pageresult = mysql_query("SELECT * FROM pages where ".$pagetype." = '".$nameid."'");
$row = mysql_fetch_assoc($pageresult);
$title = $row['title'];
$topbanner = $row['banner1'];
$des = $row['col1'];
$ttemp = $row['title'];
##add expansion class
if($pname=='What Our Customers Think' || $pname=='What Our Clients Think'){
$desarr = explode("[testimonial]", $des);
$ctr=0;
$des='';
foreach ($desarr as $key => $value) {
if($ctr>0){
$des.="".$value."";
}else $des.=$value;
$ctr++;
}
}
$descrip = explode("%split%", $des);
foreach ($descrip as $key => $value) {
$descrip[$key] = html_entity_decode($value);
}
$descri2='';
if(isset($descrip[1]))$descri2 = str_replace ("../files", "files", $descrip[1]);
$descriptiontwo = $descri2;
$descriptionthree='';
if(isset($descrip[2]))$descriptionthree = $descrip[2]; // piece2
if ( $descrip[0] == '') {
$descriptionone =''.$title.'
';
}
else {
$descri1 = str_replace ("../files", "files", $descrip[0]);
if(strrpos($descri1, "[business gallery]")){
$url = siteurl."display-bus-gallery.php";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$gall = curl_exec($ch);
curl_close($ch);
$descri1 = str_replace("[business gallery]",$gall , $descri1);
}
elseif(strrpos($descri1, "[home gallery]")){
$url = siteurl."display-home-gallery.php";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$gall = curl_exec($ch);
curl_close($ch);
$descri1 = str_replace("[home gallery]",$gall , $descri1);
}
$descriptionone =''.$descri1.'';
}
$template = $row['template'];
if ($template == '3') {
$col1 = '240';
$col2 = '200';
$col3 = '100';
$col2style = 'thin2';
}
if ($template == '1') {
$col1 = '718';
$col2 = '';
$col2style = 'thin2';
}
if ($template == '2') {
$col1 = '261';
$col2 = '414';
$col2style = 'thin';
}
$rightbanner = '';
#### right side banners
$pagename = basename($_SERVER['REQUEST_URI']);
$pagestring = substr($pagename, 0, -4);
$pageoutput = str_replace("-", ' ', $pagestring);
$banner = mysql_query("SELECT * FROM pages WHERE page_name = '".$pageoutput."' ORDER BY `ord` ASC");
//displaying the page row
$bannerrow = mysql_fetch_assoc($banner);
$sql= "SELECT * FROM bannerList WHERE page_id = '".$bannerrow['id']."' and enabled=1 ORDER BY `ord` ASC";
$bannerlist = mysql_query($sql);
while($banrow = mysql_fetch_array( $bannerlist )){
$bannerinfo = mysql_query("SELECT * FROM banner WHERE id = '".$banrow['banner_id']."'");
$ban = mysql_fetch_assoc($bannerinfo);
$rightbanner.= "".$ban['content']."
";
#echo "
";
}
### right side list of pages
$treatn ="";
if(isset($pagerow2['catid'])){
//treatment
$sql = "SELECT * FROM `pages` where `catid` = '".$pagerow2['catid']."' order by ord ASC ";
$treatresult = mysql_query($sql);
while($testinfo = mysql_fetch_array($treatresult)) {
$urlname = str_replace (" ", "-", $testinfo['page_name']);
$treatn .= "- ";
} else {
$treatn .= ">".ucwords($testinfo['title'])."";
}
$treatn .= "";
$treatn .="
";
}
}
$treatn .= "
";
if(strpos($descriptionone, "[contact form]")){
define('FUNCTIONS_FOLDER', rootpath . 'functions/');
require_once(FUNCTIONS_FOLDER . 'Email.php');
require_once(FUNCTIONS_FOLDER . 'ContactEmailDatabase.php');
$email = new Email();
if ($email->isValid($_POST)) {
$email->send(Email::STD_MAIL_ADDRESS);
$email->send($email->getClientEmailAddress());
$email->saveEmailContent(ContactEmailDatabase::getInstance());
}
if ($email->isSent()) {
header('Location: '.siteurl.'Thank-You.php');
}
$styles = "";
$contactform = file_get_contents(rootpath."/contact-form.php");
$descriptionone = str_replace('[contact form]', $contactform, $descriptionone);
}
###get right template for Contact us and showroom and about us
$mn = strtolower(trim($pname));
if ($row['type'] == 'b' ) {
include("template-content-business.php");
} else{
include("template-content-home.php");
}
}
#####PAGE SECTION#####
?>