<?php
define('REAL_PATH_ISHOP',realpath('.')."/");
require_once(REAL_PATH_ISHOP.'/include/function.php');

	if(!CheckConnectDb()){ echo ReplaceHTMLCode_Database("{MYSQL_ERROR}"); exit; }
	if($_GET['p'] == "404" or ($_GET['p'] == "admin" and !is_admin())){
		echo ReplaceHTMLCode_Database(includeFileContent(REAL_PATH_ISHOP.'include/page/error.php'));
		exit;
	}	
	if($_POST['selectedPid']){
		UpdateSelectChar($_POST['selectedPid']);	
	}
		if(isset($_GET['pid']) && isset($_GET['sas'])){
			if(AutoLoginiShop($_GET['pid'],$_GET['sas'])){
				header("Location: ./");
			}else{
				if(IsConnect()){
					$PAGE = includeFileContent(REAL_PATH_ISHOP.'include/page/index.php');
				}else{
					echo ReplaceHTMLCode_Database(includeFileContent(REAL_PATH_ISHOP.'include/page/error.php'));
					exit;
				}
			}
		}else{
			if(IsConnect()){
				$PAGE = includeFileContent(REAL_PATH_ISHOP.'include/page/index.php');
			}else{
				echo ReplaceHTMLCode_Database(includeFileContent(REAL_PATH_ISHOP.'include/page/error.php'));
				exit;
			}	
		}
		if(ISHOP_MAINTENANCE == 1 && !is_admin()){
			$PAGE = includeFileContent(REAL_PATH_ISHOP.'include/page/error.php');
		}
	echo ReplaceHTMLCode_Database($PAGE);
