<?php
//This code is copyright (c) ViciSoft SL, all rights reserved.
//The contents of this file are protected under law as the intellectual property
//of ViciSoft SL. Any use, reproduction, disclosure or copying
//of any kind without the express and written permission of ViciSoft SL is forbidden.
//Author: Vince Reid, vincereid@gmail.com
function lfect_database_error(){
	print '<div style="max-width:700px;border:1px solid lightgrey;margin:2em auto;font-family:sans-serif;border-radius:10px"><h1 style="border-bottom:1px solid #dadada;color:#444;font-size:24px;margin:30px">ECT Database Error</h1>';
	print '<div style="margin:30px">It seems that the ECT createdb.php script has not been executed to create the database tables.</div>';
	print '<div style="margin:30px"><a href="createdb.php">Please click here to run the script</a>.</div>';
	print '<div style="margin:30px;font-size:13px"><h1 style="border-bottom:1px solid #dadada;color:#444;margin-top:60px;font-size:16px">Error Message for Support</h1>' . (@$GLOBALS['ectdatabase']?$GLOBALS['ectdatabase']->error:mysql_error()) . '</div></div>';
	exit();
}
if(@$GLOBALS['abslanguagefileinclude']!=''){
	include $GLOBALS['abslanguagefileinclude'];
}else{
	if(@$_SESSION['languageid']!='') $GLOBALS['languageid']=$_SESSION['languageid']; elseif(@$GLOBALS['languageid']=='') $GLOBALS['languageid']=1;
	function lfect_query($ectsql){
		return(@$GLOBALS['ectdatabase']?$GLOBALS['ectdatabase']->query($ectsql):mysql_query($ectsql));
	}
	function lfect_fetch_assoc($ectres){
		return(@$GLOBALS['ectdatabase']?$ectres->fetch_assoc():mysql_fetch_assoc($ectres));
	}
	function lfect_free_result($ectres){
		@$GLOBALS['ectdatabase']?$ectres->free_result():mysql_free_result($ectres);
	}
	if(@$orstorelang!='')
		$storelang=$orstorelang;
	else{
		try {
			if(($result=lfect_query("SELECT storelang FROM admin WHERE adminid=1"))===FALSE){
				lfect_database_error();
			}
		} catch(Exception $e) {
			lfect_database_error();
		}
		if($rs=lfect_fetch_assoc($result)){
			$storelangarr=explode('|',is_null($rs['storelang']) ? '' : trim($rs['storelang']));
			$storelang=@$storelangarr[$GLOBALS['languageid']-1];
		}
		lfect_free_result($result);
	}
	if(@$GLOBALS['isvsadmindir']) $dirpath=''; else $dirpath='/vsadmin';
	if(@$storelang=='') $storelang='en'; // de dk en es fr it nl pt
	if(@$GLOBALS['iswordpress'])
		include ABSPATH . (@$GLOBALS['isvsadmindir']?'':'/vsadmin') . '/inc/languagefile_'.$storelang.'.php';
	else
		@include '.' . $dirpath . '/inc/languagefile_'.$storelang.'.php';
}
?>