<?php
/*
 * This file is part of Web Pro Manager.
 * 
 * Web Pro Manager is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * Web Pro Manager is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with Web Pro Manager.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * @author The Web Pro Miami, Inc. <info@thewebpro.com>
 * @copyright The Web Pro Miami, Inc. <info@thewebpro.com>, http://www.thewebpro.com/
 * @license http://www.gnu.org/licenses/gpl.html GNU GPL
 * @package WebProManager
*/

require("manage/inc/stop_cache.php");
require("inc/install.php");

$nForceMobile = (isset($_GET['m']) ? $_GET['m'] : NULL);
$nForceMobile = preg_replace("/[[:^digit:]]/", '',$nForceMobile);

// connect to mysql
require("inc/dbconnect.php");
$nPageID = nGetHomepageID();
require("inc/config.php");
require("inc/secure_page.php");

require("inc/tracker.php");
require("inc/langutil.php");
require("inc/tmplutil.php");
require("inc/resize-class.php");

$nThisPage = "index.php";

//////////// Template
if(nGetIfMobileAgent()){
	echo tmplShow("mobile");
} else {
	echo tmplShow("home");
}

function nGetHomepageID(){
	global $DBName,$Link;
	$Query = "SELECT nID FROM nPage WHERE nType='Homepage' LIMIT 1";
	mysql_select_db($DBName); $Result = mysql_query($Query,$Link);
	if($Result===FALSE){ exit("This page of your website could not be loaded.  This most likely means that your installation has failed.<BR><BR>Please run the <a href=\"./installer.php\">WPM installer</a> again, or if it does not exist, copy it again along with the 'installer' folder to the root of your website."); }
	if($Row = mysql_fetch_array($Result)) {
		$nPageID = $Row["nID"];
	}
	return $nPageID;
}

require("inc/db_close.php");
?>