<?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
global $incfunctionsdefined;
if(@$incfunctionsdefined!=TRUE && @$isadmincsv!=TRUE){
	print 'Illegal Call';
	flush();
	exit;
}
if(@$dateformatstr=='') $dateformatstr = 'm/d/Y';
$admindatestr='Y-m-d';
if(@$admindateformat=='') $admindateformat=0;
if($admindateformat==1)
	$admindatestr='m/d/Y';
elseif($admindateformat==2)
	$admindatestr='d/m/Y';
$GLOBALS['usewordpressphpmailer']=FALSE;
$alreadygotadmin=getadminsettings();
$GLOBALS['ectadminfunctionsdefined']=TRUE;
function validextension($lfn){
	if(substr($lfn, -4)=='.gif' || substr($lfn, -4)=='.jpg' || substr($lfn, -5)=='.jpeg' || substr($lfn, -4)=='.png' || substr($lfn, -5)=='.webp') // || substr($lfn, -4)=='.bmp' || substr($lfn, -4)=='.art' || substr($lfn, -4)=='.wmf' || substr($lfn, -4)=='.emf' || substr($lfn, -4)=='.mov' || substr($lfn, -4)=='.xbm' || substr($lfn, -4)=='.avi' || substr($lfn, -4)=='.mpg' || substr($lfn, -5)=='.mpeg')
		return(TRUE);
	else
		return(FALSE);
}
function validimagecontent($tf){
	if(ord($tf[0])==0xFF && ord($tf[1])==0xD8) return(TRUE); // JPEG
	if(ord($tf[0])==0x89 && ord($tf[1])==0x50 && ord($tf[2])==0x4E && ord($tf[3])==0x47) return(TRUE); // PNG
	$first6 = strtolower(substr($tf, 0, 6));
	if($first6=='gif87a' || $first6=='gif89a') return(TRUE); // GIF
	$first4 = strtolower(substr($tf, 0, 4));
	if($first4=='riff') return(TRUE); // WEBP
	return(FALSE);
}
function dodeleteimage($impath,&$errmsg){
	$retval=FALSE;
	$impath=str_replace(array($GLOBALS['storeurl'],$GLOBALS['storeurlssl']),'',$impath);
	$impathlc=strtolower($impath);
	if(!validextension($impathlc))
		$errmsg='Invalid extension';
	elseif(substr($impathlc,0,5)=='http:' || substr($impathlc,0,6)=='https:'){
		$errmsg='Cannot delete over HTTP/HTTPS';
	}else{
		$impath=str_replace('/',DIRECTORY_SEPARATOR,$impath);
		if(substr($impath,0,1)=='/' || substr($impath,0,1)=='\\')
			$thepath=$_SERVER['DOCUMENT_ROOT'].$impath;
		else
			$thepath='..' . DIRECTORY_SEPARATOR . $impath;
		if(@unlink($thepath))
			$retval=TRUE;
		else
			$errmsg='Could not delete image file.';
	}
	logevent(@$_SESSION['loginuser'],"DELETEIMAGE",$retval,@debug_backtrace()[1]['function'],$impath,$impath);
	return $retval;
}
function imageuploadscripts(){
	global $yyClsWin;
?>
<script>
<?php
	$maxuploadfiles=1;
	$maxfilesize=100*1024*1024;
	$filetypes=".bmp,.gif,.jpe,.jpeg,.jpg,.png,.tif,.tiff,.webp";
?>
var fileselectinput,ectuploadimgsrc='';
var fuajaxobj=window.XMLHttpRequest?new XMLHttpRequest():new ActiveXObject("MSXML2.XMLHTTP");
var filestoupload,hasfiletoupload,uploadedimages,dropArea,dragText,imagefield,button;
function setandchange(telem,tval){
	document.getElementById(telem).value=tval;
	document.getElementById(telem).onchange();
}
function doneimageupload(){
	var successuploads=0;
	if(fuajaxobj.readyState==4){
		imgstatus='';
		if(document.getElementById('browsebutton'))document.getElementById('browsebutton').disabled=true;
		if(document.getElementById("fileselectinput"))document.getElementById("fileselectinput").value='';
		dropArea.classList.remove("hoverwithfile");
		if(fuajaxobj.status==200){
			var restxt=fuajaxobj.responseText;
			var resarr=restxt.split(':');
			if(resarr[0]=='SUCCESS'){
				var popfields=resarr[1].split('&');
				for(var index=0;index<popfields.length;index++){
					var popval=popfields[index].split('=');
					if(popval[0].trim()!='') setandchange(popval[0],popval[1]);
					if(popval[0]=='smim0') setandchange('pImage',popval[1]);
					if(popval[0]=='lgim0') setandchange('pLargeImage',popval[1]);
					if(popval[0]=='gtim0') setandchange('pGiantImage',popval[1]);
				}
				document.getElementById('ectsoftwrapper').innerHTML='<div style="margin:100px;text-align:center">Image Uploaded Successfully.</div><div style="margin:100px;text-align:center"><input type="button" value="<?php print jsescape($yyClsWin)?>" onclick="document.getElementById(\'preloaderdiv\').style.display=\'none\'"></div>';
			}else
				document.getElementById('ectsoftwrapper').innerHTML='<div style="margin:100px;text-align:center">Error uploading image: ' + fuajaxobj.status + '<div style="margin-top:50px">' + restxt + '</div></div><div style="margin:100px;text-align:center"><input type="button" value="<?php print jsescape($yyClsWin)?>" onclick="document.getElementById(\'preloaderdiv\').style.display=\'none\'"></div>';
		}else
			document.getElementById('ectsoftwrapper').innerHTML='<div style="margin:100px;text-align:center">Error uploading image: ' + fuajaxobj.status + '<div style="margin-top:50px">' + fuajaxobj.responseText + '</div></div><div style="margin:100px;text-align:center"><input type="button" value="<?php print jsescape($yyClsWin)?>" onclick="document.getElementById(\'preloaderdiv\').style.display=\'none\'"></div>';
		uploadedimages+=successuploads;
	}
}
function progressHandler(event){
	document.getElementById("progressBar").value=Math.round((event.loaded / event.total) * 100);
}
function errorHandler(event){
	alert("Upload Failed");
}
function abortHandler(event){
	alert("Upload Aborted");
}
function dosubmitimage(){
	if(hasfiletoupload){
		var fd = new FormData();
		fd.append('myFiles', filestoupload[0]);
		fd.append('filename', filestoupload[0].name);
		fd.append('imagefield',imagefield);
		fd.append('defimagepath', '<?php print $GLOBALS['defaultprodimages'] ?>');
		for(var index=0;index<=2;index++){
			if(document.getElementById('thumbdim'+index)) fd.append('thumbdim'+index,document.getElementById('thumbdim'+index)[document.getElementById('thumbdim'+index).selectedIndex].value);
			if(document.getElementById('newdim'+index)) fd.append('newdim'+index,document.getElementById('newdim'+index).value);
			if(document.getElementById('suffix'+index)) fd.append('suffix'+index,document.getElementById('suffix'+index).value);
		}
		fuajaxobj.onreadystatechange=doneimageupload;
		fuajaxobj.upload.addEventListener("progress", progressHandler, false);
		fuajaxobj.addEventListener("error", errorHandler, false);
		fuajaxobj.addEventListener("abort", abortHandler, false);
		fuajaxobj.open("POST",'doupload.php',true);
		fuajaxobj.send(fd);
	}else
		alert('Please select a file to upload.');
}
function hasselectedimage(inputfiles){
	var reader,haserror=false,filelist='',separator='';
	if(inputfiles && inputfiles[0]){
		for(var index=0;index<inputfiles.length;index++){
			let fileType = inputfiles[index].type;
			let fileName = inputfiles[index].name;
			filelist=fileName+separator+filelist;
			separator=', ';
			let validExtensions=[<?php print '"' . strtolower(str_replace(',','","',$filetypes)) . '"'?>];
			let fileExtension='.'+fileName.split('.').pop().toLowerCase();;
			if(fileName.indexOf('.')==-1) fileExtension='xxx';
			if(!(validExtensions.includes(fileExtension))){
				alert("This is not a valid file type.");
				dropArea.classList.remove("hoverwithfile");
				dragText.textContent = "Drag & Drop Files to Upload Here";
				haserror=true;
			}else if(inputfiles[index].size><?php print $maxfilesize?>){
				alert('The file you have selected is too large to upload. (Max. <?php print ($maxfilesize/(1024*1024)).'M' ?>)');
				haserror=true;
			}else if((index+uploadedimages)>=<?php print $maxuploadfiles?>){
				alert('You can only upload a maximum of <?php print $maxuploadfiles ?> files.');
				haserror=true;
			}
		}
		if(!haserror){
			reader=new FileReader();
			reader.onload=function(e){
				filestoupload=inputfiles;
				hasfiletoupload=true;
				dragText.textContent = 'Ready to upload . . . ' + filelist;
				ectuploadimgsrc=e.target.result;
				document.getElementById("progressBar").value=0;
			}
			reader.readAsDataURL(inputfiles[0]);
		}
	}
}
</script>
<?php
}
function adminsuccessforward($turl,$tquery){
	print '<div style="text-align:center;padding:50px 0">';
		print '<div style="font-weight:bold">' . $GLOBALS['yyUpdSuc'] . '</div>';
		print '<div style="padding:50px 0">' . $GLOBALS['yyNowFrd'] . '</div>';
        print '<div style="padding:0 0 50px 0">' . $GLOBALS['yyNoAuto'] . ' <a href="' . $turl . ($tquery!=''?'?'.$tquery:'') . '">' . $GLOBALS['yyClkHer'] . '</a>.</div>';
	print "</div>\n";
}
function adminfailback($errmsg){
	print '<div style="text-align:center;padding:50px 0">';
		print '<div style="color:#FF0000;font-weight:bold">' . $GLOBALS['yyOpFai'] . '</div>';
		print '<div style="padding:50px 0">' . $errmsg . '</div>';
		print '<div style="padding:0 0 50px 0"><a href="javascript:history.go(-1)">' . $GLOBALS['yyClkBac'] . '</div>';
	print "</div>\n";
}
function updaterchecker(){
	global $yyNoNew,$yyLasChk,$yyChkMan,$yyClkHer,$yyNewRec,$yyRUSec,$yyChkNew,$disableupdatechecker,$padssfeatures,$yyWilLog,$yyCliCon,$yyFinMor,$yyClkHer,$yyContin,$yyCancel;
	//if(@$_SESSION['loginid']!=0) return;
	$sSQL='SELECT adminVersion,updLastCheck,updRecommended,updSecurity,updShouldUpd,adminStoreURL FROM admin WHERE adminID=1';
	$result=ect_query($sSQL) or ect_error();
	$rs=ect_fetch_assoc($result);
	$storeVersion=$rs['adminVersion'];
	$updLastCheck=$rs['updLastCheck'];
	$recommendedversion=$rs['updRecommended'];
	$securityrelease=$rs['updSecurity'];
	$shouldupdate=$rs['updShouldUpd'];
	$storeURL=$rs['adminStoreURL'];
	ect_free_result($result);
	if(@$disableupdatechecker){
		$checkupdates=FALSE;
	}else{
		$checkupdates=(time()-strtotime($updLastCheck))>=(3*60*60*24);

		$admindatestr='Y-m-d';
		if(@$admindateformat=='') $admindateformat=0;
		if($admindateformat==1)
			$admindatestr='m/d/Y';
		elseif($admindateformat==2)
			$admindatestr='d/m/Y';
?>
<script>
/* <![CDATA[ */
function ajaxcallback(){
	if(ajaxobj.readyState==4){
		var newtxt='';
		var xmlDoc=ajaxobj.responseXML.documentElement;
		var recver=xmlDoc.getElementsByTagName("recommendedversion")[0].childNodes[0].nodeValue;
		var shouldupdate=(xmlDoc.getElementsByTagName("shouldupdate")[0].childNodes[0].nodeValue=='true');
		var securityupdate=(xmlDoc.getElementsByTagName("securityupdate")[0].childNodes[0].nodeValue=='true');
		var haserror=(xmlDoc.getElementsByTagName("haserror")[0].childNodes[0].nodeValue=='true');
		if(haserror){
			newtxt='<span style="color:#FF0000;font-weight:bold">' + recver + '!</span><br /><?php print str_replace("'","\'",$yyChkMan)?> <a href="https://www.ecommercetemplates.com/updaters.asp" target="_blank"><?php print str_replace("'","\'",$yyClkHer)?></a><br />';
			newtxt+='To disable this function please <a href="https://www.ecommercetemplates.com/phphelp/ecommplus/parameters.asp#dissupcheck" target="_blank"><?php print str_replace("'","\'",$yyClkHer)?></a><br />';
		}else{
			if(shouldupdate) newtxt='<a href="https://www.ecommercetemplates.com/updaters.asp" target="_blank"><?php print str_replace("'","\'",$yyNewRec)?>: v' + recver + '</a><br />';
			if(securityupdate) newtxt+='<span style="color:#FF0000;font-weight:bold"><?php print str_replace("'","\'",$yyRUSec)?></span><br />';
		}
		document.getElementById("checkupdates").innerHTML=(shouldupdate?'<div class="should_update">'+newtxt+'</div>':'<div class="updates_okay"><?php print str_replace("'","\'",$yyNoNew)?></div>');
	}
}
function checkforupdates(){
	if(window.XMLHttpRequest)
		ajaxobj=new XMLHttpRequest();
	else
		ajaxobj=new ActiveXObject("MSXML2.XMLHTTP");
	ajaxobj.onreadystatechange=ajaxcallback;
	ajaxobj.open("GET", "ajaxservice.php?action=checkupdates&storever=<?php print urlencode($storeVersion)?>", true);
	ajaxobj.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	ajaxobj.send(null);
}
<?php if($checkupdates) print "checkforupdates();\r\n";
?>/* ]]> */
</script>
<?php
	} ?><div class="updatecheck">
<div class="current_version<?php if($shouldupdate)print ' old_version'?>"><?php print $storeVersion?></div>
<span id="checkupdates"><?php
	if(@$disableupdatechecker)
		print '<div class="updates_okay">Auto update feature disabled! ' . $yyChkMan . ' <a href="https://www.ecommercetemplates.com/updaters.asp" target="_blank">' . $yyClkHer . '</a></div>';
	elseif($checkupdates)
		print '<div class="updates_okay">' . $yyChkNew . '...</div>';
	else{
		if($shouldupdate){
			print '<div class="should_update'.($securityrelease?' security_update':'').'">';
			print '<a href="https://www.ecommercetemplates.com/updaters.asp" target="_blank">' . $yyNewRec . ': v' . $recommendedversion . '</a>';
			if($securityrelease) print '<br><span>' . $yyRUSec.'</span>';
			print '</div>';
		}else
			print '<div class="updates_okay">'.$yyNoNew . '<div class="last_update">'.$yyLasChk.': <span class="update_date"><a href="javascript:checkforupdates()">' . date($admindatestr, strtotime($updLastCheck)) . '</a></span></div></div>';
	} ?></span>
</div>
<?php
	if(@$padssfeatures==TRUE){ ?>
<script>
/* <![CDATA[ */
var ecttimo=0;
function dokeepalive(){
	clearTimeout(ecttimo);
	if(window.XMLHttpRequest)
		ajaxobj=new XMLHttpRequest();
	else
		ajaxobj=new ActiveXObject("MSXML2.XMLHTTP");
	ajaxobj.open("GET", "ajaxservice.php", true);
	ajaxobj.send('');
	document.getElementById('logindiv').style.display='none';
	setlotimos();
	return(false);
}
function setlotimos(){
	setTimeout("document.getElementById('logindiv').style.display='block';document.getElementById('contbutton').focus();",870000);
	ecttimo=setTimeout("document.location='logout.php';",900000);
}
if(ecttimo==0)setlotimos();
/* ]]> */
</script>
<div id="logindiv" style="display:none;position:absolute;width:100%;height:2000px;background-image:url(adminimages/opaquepixel.png);top:0px;left:0px;text-align:center;z-index:10000;">
<br /><br /><br /><br /><br /><br /><br /><br />
<table width="100%"><tr><td align="center">
<form method="post" action="admin.asp" onsubmit="return dokeepalive()">
<table width="350" cellspacing="2" cellpadding="2" bgcolor="#FFFFFF"><tr><td align="center"><br /><br /><?php print $yyWilLog?><br /><br /><?php print $yyCliCon?><br /><br />
<?php print $yyFinMor?> <a href="https://www.ecommercetemplates.com/pa-dss-compliance.asp#padss5" target="_blank"><strong><?php print $yyClkHer?></strong></a>.<br /><br />
</td></tr>
<tr><td align="center"><br /><input type="submit" id="contbutton" value="<?php print $yyContin?>" /> &nbsp; <input type="button" value="<?php print $yyCancel?>" onclick="document.getElementById('logindiv').style.display='none'" /><br /><br /></td></tr></table>
</form>
</td></tr></table>
</div>
<?php
	}
}
function adminassets(){ ?>
<meta http-equiv="Content-Type" content="text/html; charset=<?php print $GLOBALS['adminencoding'] ?>"/>
<meta http-equiv="X-UA-Compatible" content="IE=9" />
<!-- Mobile Specific Meta
================================================== -->
<meta name="robots" content="noindex,nofollow">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="adminstyle.css?ver=3">
<?php
	$setdarkmode=@$_COOKIE['darkmode']=='1';
	if(@$_POST['setdarkmode']=='1'){
		$setdarkmode=@$_POST['darkmode']=='ON';
		setacookie('darkmode',$setdarkmode?'1':'',390);
	}
	if($setdarkmode){ ?>
<style>
body{
background-color:#464646;
}
#main{
background:#333;
color:#FFF;
}
h2:not(body.printbody *){
color:#EEE;
}
.updatecheck{
background-color:#111;
color:#DDD;
border:1px solid #777;
}
h3,.home_boxes .box_title{
background-color:#111;
}
.home_boxes .new_alert, .home_boxes .new_alert h3{
background-color:#EA9219;
}
.home_boxes .box_new,tr.greenbg > td{
color:#333;
}
table.quickstats th{
border:none;
}
.admin-table-b th{
border:none;
}
.admin-table-b td{
background-color:#111;
border-bottom:1px dotted #d5d5d5;
color:#EEE;
}
a{
color:#AAA;
}
a:hover,div.ordersheadrow > div a:hover{
color:#faa21b;
}
.sta-white td{
background-color:#111;
}
.admin-table-a td{
color:#FFF;
}
div.ectsoftwrapper,div.ectcaltodaydate,td.cobhl,td.cobll,#adminfooter,div.headeradvis{
background-color:#333;
color:#FFF;
}
.admin-table-a th{
border:none;
border-bottom:1px solid;
}
input[type="text"],input[type="password"],select,textarea,div.ectcalendar{
background-color:#333;
color:#FFF;
}
input[type="text"]:focus,input[type="password"]:focus,select:focus,textarea:focus{
border:1px solid #ff921b;
background-color:#222;
color:#FFF;
}
input[type="text"]:disabled {
background-color:#988;
}
.itemsdefine{
color:#EA9219;
}
div.headeradvis{
border:1px solid #C00;
}
.ectcaldates{
color:#FFF;
}
.admin-table-a tr:hover td,.admin-table-b tr:hover td,.login_form,.login_message{
background-color:#333;
color:#FFF;
}
a.online_help:hover, a.online_help_large:hover{
color:#EA9219;
background-color:#ededed;
}
a.online_help, a.online_help_large{
background-color:#EA9219;
color:#333;
}
table.cobtbl{
background-color:#BBB;
}
.admin-table-a th{
border-bottom:1px solid #BBB;
}
.home_boxes .box_new,.home_boxes .box{
background-color:#CCC;
}
div.ordersheadrow > div {
color:#000;
background:#EEE;
}
div.ordersheadrow > div a {
color:#111;
}
.login_header{
border-bottom:1px solid #FFF;
}
</style>
<?php	}
		if(file_exists('ectadmincustom.css')) print '<link rel="stylesheet" type="text/css" href="ectadmincustom.css">' . "\n";
		if(trim_(@$_SESSION['loggedon'])!=''){ ?>
<script src="//ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.min.css">
<?php	 	if(@$GLOBALS['htmleditor']=='froala'){ ?>
<link rel="stylesheet" href="froala/css/froala_editor.min.css">
<link rel="stylesheet" href="froala/css/froala_style.min.css">
<link rel="stylesheet" href="froala/css/plugins/code_view.min.css">
<link rel="stylesheet" href="froala/css/plugins/colors.min.css">
<link rel="stylesheet" href="froala/css/plugins/fullscreen.min.css">
<link rel="stylesheet" href="froala/css/plugins/image_manager.min.css">
<link rel="stylesheet" href="froala/css/plugins/image.min.css">
<link rel="stylesheet" href="froala/css/plugins/table.min.css">
<link rel="stylesheet" href="froala/css/plugins/video.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.3.0/codemirror.min.css">

<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.3.0/codemirror.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.3.0/mode/xml/xml.min.js"></script>
<script src="froala/js/froala_editor.min.js"></script>
<script src="froala/js/plugins/align.min.js"></script>
<script src="froala/js/plugins/code_beautifier.min.js"></script>
<script src="froala/js/plugins/code_view.min.js"></script>
<script src="froala/js/plugins/colors.min.js"></script>
<script src="froala/js/plugins/draggable.min.js"></script>
<script src="froala/js/plugins/font_family.min.js"></script>
<script src="froala/js/plugins/font_size.min.js"></script>
<script src="froala/js/plugins/fullscreen.min.js"></script>
<script src="froala/js/plugins/image.min.js"></script>
<script src="froala/js/plugins/image_manager.min.js"></script>
<script src="froala/js/plugins/link.min.js"></script>
<script src="froala/js/plugins/lists.min.js"></script>
<script src="froala/js/plugins/paragraph_format.min.js"></script>
<script src="froala/js/plugins/paragraph_style.min.js"></script>
<script src="froala/js/plugins/table.min.js"></script>
<script src="froala/js/plugins/video.min.js"></script>
<script src="froala/js/plugins/url.min.js"></script>
<?php 		} ?>
<script src="assets/ectadmin.js"></script>
<?php	}
}
function displayfroalaeditor($regionid,$regionname,$extras,$initimmediate=FALSE,$displayinline=FALSE,$uploadloc=1,$wrapinfunction=FALSE){
$toobarbuttons="toolbarButtons:['fullscreen','html','undo','redo','selectAll','clearFormatting','|','bold','italic','underline','strikeThrough','superscript','insertHR','|','fontFamily', 'fontSize', 'color',	'paragraphFormat','paragraphStyle','align','formatOL','formatUL','indent','outdent','|','insertImage','insertLink','insertVideo','insertTable'],";
$htmlallowedtags="htmlAllowedTags:['a','abbr','address','area','article','aside','audio','b','base','bdi','bdo','blockquote','br','button','canvas','caption','cite','code','col','colgroup','datalist','dd','del','details','dfn','dialog','div','dl','dt','ecttab','em','embed','fieldset','figcaption','figure','font','footer','form','h1','h2','h3','h4','h5','h6','header','hgroup','hr','i','iframe','img','input','ins','kbd','keygen','label','legend','li','link','main','map','mark','menu','menuitem','meter','nav','noscript','object','ol','optgroup','option','output','p','param','pre','progress','queue','rp','rt','ruby','s','samp','script','style','section','select','small','source','span','strike','strong','sub','summary','sup','table','tbody','td','textarea','tfoot','th','thead','time','title','tr','track','u','ul','var','video','wbr'],";
$htmlallowedattrs="htmlAllowedAttrs:['accept','accept-charset','accesskey','action','align','allowfullscreen','allowtransparency','alt','async','autocomplete','autofocus','autoplay','autosave','background','bgcolor','border','charset','cellpadding','cellspacing','checked','cite','class','color','cols','colspan','content','contenteditable','contextmenu','controls','coords','data','data-.*','datetime','default','defer','dir','dirname','disabled','download','draggable','dropzone','enctype','face','for','form','formaction','frameborder','headers','height','hidden','high','href','hreflang','http-equiv','icon','id','ismap','itemprop','keytype','kind','label','lang','language','list','loading','loop','low','max','maxlength','media','method','min','mozallowfullscreen','multiple','muted','name','novalidate','onblur','onchange','onclick','ondblclick','onerror','onfocus','onload','onselect','onsubmit','onreset','onkeydown','onkeypress','onkeyup','onmouseover','onmouseout','onmousedown','onmouseup','onmousemove','onresize','onunload','open','optimum','pattern','ping','placeholder','playsinline','poster','preload','pubdate','radiogroup','readonly','rel','required','reversed','rows','rowspan','sandbox','scope','scoped','scrolling','seamless','selected','shape','size','sizes','span','src','srcdoc','srclang','srcset','start','step','summary','spellcheck','style','tabindex','target','title','type','translate','usemap','value','valign','webkitallowfullscreen','width','wrap'],";
$htmlallowedemptytags="htmlAllowedEmptyTags:['.fa','a','ecttab','iframe','label','object','style','script','textarea','video'],";
$htmlremovetags="htmlRemoveTags:[''],";
$htmldonotwraptags="htmlDoNotWrapTags:['ecttab','script','style'],";
$ectstorecss='';
if(@$GLOBALS['isectstore']){
	$ectstorecss=',"../themes/shared/css/ectstyle1.css"';
	$result=$GLOBALS['ectdatabase']->query('SELECT themeName FROM admindesign WHERE adID=1') or $GLOBALS['ectdatabase']->error;
	if($rs=$result->fetch_assoc())
		$ectstorecss.=',"./themes/'.$rs['themeName'].'/css/style.css"';
}
if(@$GLOBALS['customcsslocation']!='') $ectstorecss.=',"'.str_replace(',','","',$GLOBALS['customcsslocation']).'"';
$stylefiles='"../css/ectcart.css"';
if(@$GLOBALS['ectqbuystyle']!=0||@$GLOBALS['ectproductstyle']!=0||@$GLOBALS['ectdetailstyle']!=0){
	$stylefiles.=',"../css/ectstylebase.css"';
}
if(@$GLOBALS['ectproductstyle']!=0){
	$stylefiles.=',"../css/ectstyleproduct' . $GLOBALS['ectproductstyle'] . '.css"';
}
if(@$GLOBALS['ectqbuystyle']!=0){
	$stylefiles.=',"../css/ectstyleqbuy' . $GLOBALS['ectqbuystyle'] . '.css"';
}
if(@$GLOBALS['ectdetailstyle']!=0){
	$stylefiles.=',"../css/ectstyledetails' . $GLOBALS['ectdetailstyle'] . '.css"';
}
$stylefiles.=(realpath("../css/ectstyle.css")?',"../css/ectstyle.css"':'').(realpath("../css/style.css")?',"../css/style.css"':'').(realpath("../css/styles.css")?',"../css/styles.css"':'').@$ectstorecss;
print '<script>'.($wrapinfunction?'function dfe_'.$regionid.'(){':'').'$(\'#'.$regionid.'\').froalaEditor({iframeStyle:"body{height:auto !important;background:none !important;display:block !important;border:10px !important;margin:8px !important;}",iframeStyleFiles:[' . $stylefiles . '],iframe:true,key:"IG1A3A3A1pD1D1E1A3E1J4A14B3A7C7kWd1WDPTa1ZNRGe1OC1c1==",'.$toobarbuttons.$htmlallowedtags.$htmlallowedattrs.$htmlallowedemptytags.$htmlremovetags.$htmldonotwraptags.'placeholderText:\'Click to Edit '.jsescape($regionname).'\',language: \''.$GLOBALS['adminlang'].'\''.($initimmediate?'':',initOnClick:true').($displayinline?',toolbarInline:true':'').',imageUploadURL:\'froala/upload_image.php?loc='.$uploadloc.'\'})'.$extras.($wrapinfunction?'}':'').'</script>' . "\r\n";
}
function adminheader(){
	global $yyLmVwSt,$storeurl,$yyNewRec,$yyRUSec,$adminlogo;?>
<div id="header1">
<div class="inner_half"><p class="viewstore"><a class="topbar" href="../" target="_blank"><?php print $yyLmVwSt?></a></p></div>
<div class="inner_half aright last">
<p class="log-out"><a class="topbar" href="logout.php"><?php print $GLOBALS['yyLLLogO']?></a></p>
</div>
</div>
<div id="header">
<div class="logotop"><a href="admin.php"><img src="<?php if(@$adminlogo!='') print $adminlogo; else print 'adminimages/logo.svg'?>" alt="Ecommerce Templates" class="ectlogo"></a></div>
<div class="toplinks">
<a class="topbar" href="https://www.ecommercetemplates.com/help.asp" target="_blank"><img src="adminimages/icon-help.svg" title="<?php print $GLOBALS['yyLLHelp']?>" alt="<?php print $GLOBALS['yyLLHelp']?>"></a> 
<a href="https://www.ecommercetemplates.com/support/default.asp" target="_blank" class="topbar"><img src="adminimages/icon-forum.svg" title="<?php print $GLOBALS['yyLLForu']?>" alt="<?php print $GLOBALS['yyLLForu']?>"></a>
<a href="https://www.ecommercetemplates.com/support/search.asp" target="_blank" class="topbar"><img src="adminimages/icon-search.svg" title="<?php print $GLOBALS['yyLLForS']?>" alt="<?php print $GLOBALS['yyLLForS']?>" ></a>
<a href="https://www.ecommercetemplates.com/updaters.asp" target="_blank" class="topbar"><img src="adminimages/icon-update.svg" title="<?php print $GLOBALS['yyLLUpda']?>" alt="<?php print $GLOBALS['yyLLUpda']?>"></a>
</div>
</div>
<?php
	if(@$_SESSION['loginid']==0){
		if(getget('cleardnalert')=='true'){
			$sSQL="UPDATE admin SET adminDeviceNotifAlert='' WHERE adminID=1";
			ect_query($sSQL) or ect_error();
		}else{
			$sSQL='SELECT updRecommended,updSecurity,updShouldUpd,adminDeviceNotifAlert FROM admin WHERE adminID=1';
			$result=ect_query($sSQL) or ect_error();
			$rs=ect_fetch_assoc($result);
			$recommendedversion=$rs['updRecommended'];
			$securityrelease=$rs['updSecurity'];
			$shouldupdate=$rs['updShouldUpd'];
			ect_free_result($result);
			if(trim_($rs['adminDeviceNotifAlert'])!=''||$shouldupdate){
				print '<div class="headeradvis">';
					if(trim_($rs['adminDeviceNotifAlert'])!='') print '<div><input type="button" value="Clear" onclick="document.location=\'admin.php?cleardnalert=true\'" /> ' . $rs['adminDeviceNotifAlert'] . '</div>';
					if($shouldupdate){
						print '<div class="should_update'.($securityrelease?' security_update':'').'">';
						print '<a href="https://www.ecommercetemplates.com/updaters.asp" target="_blank">' . $yyNewRec . ': v' . $recommendedversion . '</a>';
						if($securityrelease) print '<br><span>' . $yyRUSec.'</span>';
						print '</div>';
					}
				print '</div>';
			}
		}
	}
}
function adminnavigation(){?>
<div id="admin_menu">
<div class='menu-button'>Menu</div>
<nav>
<ul id="nav" role="navigation">
<?php	if(@$_SESSION['loginid']==0 || substr(@$_SESSION['loggedonpermissions'],0,1)=='X' || substr(@$_SESSION['loggedonpermissions'],3,1)=='X' || substr(@$_SESSION['loggedonpermissions'],13,1)=='X' || substr(@$_SESSION['loggedonpermissions'],7,1)=='X' || substr(@$_SESSION['loggedonpermissions'],10,1)=='X' || substr(@$_SESSION['loggedonpermissions'],16,1)=='X'){ ?>
	<li class="top-level"><a href="admin.php"><?php print $GLOBALS['yyLMStAd']?></a>
		<ul class="sub-menu">
			<li><a href="admin.php"><?php print strtolower($GLOBALS['yyDashbd'])?></a></li>
			<li><a href="adminmain.php"><?php print $GLOBALS['yyLLMain']?></a></li>
		<?php	if(@$GLOBALS['isectstore']){ ?>	
			<li><a href="admindesign.php">store design</a></li>
			<li><a href="adminparameters.php">store parameters</a></li>
		<?php	} ?>	
			<li><a href="adminlogin.php"><?php print $GLOBALS['yyLLPass']?></a></li>
			<li><a href="adminaffil.php"><?php print $GLOBALS['yyLLAffl']?></a></li>
			<li><a href="adminemailmsgs.php"><?php print $GLOBALS['yyLMEmla']?></a></li>
			<li><a href="adminmailinglist.php"><?php print $GLOBALS['yyLMMaLi']?></a></li>
		<?php	if(!@$GLOBALS['isectstore']){ ?>	
			<li><a href="admincontent.php"><?php print strtolower($GLOBALS['yyContReg'])?></a></li>
		<?php	} ?>
			<li><a href="adminipblock.php"><?php print strtolower($GLOBALS['yyIPBlock'])?></a></li>
			<li><a href="admindbutility.php">database utility</a></li>
		</ul>
	</li>
<?php	}else{ ?>
	<li class="top-level" style="height:43px">&nbsp;</li>
<?php	}
		if(@$_SESSION['loginid']==0 || substr(@$_SESSION['loggedonpermissions'],1,1)=='X' || substr(@$_SESSION['loggedonpermissions'],2,1)=='X' || substr(@$_SESSION['loggedonpermissions'],4,1)=='X' || substr(@$_SESSION['loggedonpermissions'],7,1)=='X' || substr(@$_SESSION['loggedonpermissions'],10,1)=='X' || substr(@$_SESSION['loggedonpermissions'],14,1)=='X'){ ?>
	<li class="top-level"><a href="adminorders.php"><?php print $GLOBALS['yyOrdAdm']?></a>
		<ul class="sub-menu">
			<li><a href="adminorders.php"><?php print $GLOBALS['yyLLOrds']?></a></li>
		<?php
			if(FALSE){
				$sSQL="SELECT dnID FROM devicenotifications ORDER BY dnID";
				$result=ect_query($sSQL) or ect_error();
				if(ect_num_rows($result)>0){ ?>
			<li><a href="adminorders.php?act=dnotif" style="color:#FF7711">device notfications</a></li>
		<?php	}
				ect_free_result($result);
			} ?>
<?php		if(@$_SESSION['loginid']==0 || substr(@$_SESSION['loggedonpermissions'],2,1)=='X'){ ?>
			<li><a href="adminpayprov.php"><?php print $GLOBALS['yyLLPayP']?></a></li>
<?php		}
			if(@$_SESSION['loginid']==0 || substr(@$_SESSION['loggedonpermissions'],4,1)=='X'){ ?>
			<li><a href="adminclientlog.php"><?php print $GLOBALS['yyLLClLo']?></a></li>
<?php		}
			if(@$_SESSION['loginid']==0 || substr(@$_SESSION['loggedonpermissions'],10,1)=='X'){ ?>
			<li><a href="adminordstatus.php"><?php print $GLOBALS['yyLLOrSt']?></a></li>
<?php		}
			if(@$_SESSION['loginid']==0 || substr(@$_SESSION['loggedonpermissions'],7,1)=='X'){ ?>
			<li><a href="admingiftcert.php"><?php print $GLOBALS['yyLLGftC']?></a></li>
<?php		}
			if(@$_SESSION['loginid']==0 || substr(@$_SESSION['loggedonpermissions'],14,1)=='X'){ ?>
			<li><a href="adminstats.php">order stats</a></li>
<?php		} ?>
		</ul>
	</li>
<?php	}else{ ?>
	<li class="top-level" style="height:43px">&nbsp;</li>
<?php	}
		if(@$_SESSION['loginid']==0 || substr(@$_SESSION['loggedonpermissions'],5,1)=='X' || substr(@$_SESSION['loggedonpermissions'],6,1)=='X' || substr(@$_SESSION['loggedonpermissions'],7,1)=='X'){ ?>
	<li class="top-level"><a href="adminprods.php"><?php print $GLOBALS['yyLMPrAd']?></a>
		<ul class="sub-menu">
			<li><a href="adminprods.php"><?php print $GLOBALS['yyLLProA']?></a></li>
			<li><a href="adminprodopts.php"><?php print $GLOBALS['yyLLProO']?></a></li>
			<li><a href="admincats.php"><?php print $GLOBALS['yyLLCats']?></a></li>
			<li><a href="admindiscounts.php"><?php print $GLOBALS['yyLLDisc']?></a></li>
			<li><a href="adminsearchcriteria.php"><?php print strtolower($GLOBALS['yySeaCri'])?></a></li>
			<li><a href="adminpricebreak.php"><?php print $GLOBALS['yyLLQuan']?></a></li>
			<li><a href="adminratings.php"><?php print $GLOBALS['xxLMRaRv']?></a></li>
			<li><a href="admincsv.php"><?php print strtolower($GLOBALS['yyCSVUpl'])?></a></li>
		</ul>
	</li>
<?php	}else{ ?>
	<li class="top-level" style="height:43px">&nbsp;</li>
<?php	}
		if(@$_SESSION['loginid']==0 || substr(@$_SESSION['loggedonpermissions'],8,1)=='X' || substr(@$_SESSION['loggedonpermissions'],9,1)=='X' || substr(@$_SESSION['loggedonpermissions'],11,1)=='X'){ ?>
	<li class="top-level"><a href="adminuspsmeths.php"><?php print $GLOBALS['yyLMShAd']?></a>
		<ul class="sub-menu">
			<li><a href="adminstate.php"><?php print $GLOBALS['yyLLStat']?></a></li>
			<li><a href="admincountry.php"><?php print $GLOBALS['yyLLCoun']?></a></li>
			<li><a href="adminzones.php"><?php print $GLOBALS['yyLLZone']?></a></li>
			<li><a href="adminuspsmeths.php"><?php print $GLOBALS['yyLLShpM']?></a></li>
			<li><a href="admindropship.php"><?php print $GLOBALS['yyDrShpr']?></a></li>
		</ul>
	</li>
<?php	}else{ ?>
	<li class="top-level" style="height:43px">&nbsp;</li>
<?php	} ?>
</ul>
</nav>
</div>
<?php	if($GLOBALS['onvacation']!=0){ ?>
<div style="color:#ED2803;text-align:center;font-size:1.3em;padding-top:16px">
The Vacation Setting is Currently Active. <a href="adminmain.php#vacationmessage">To Turn This off, click here.</a>
</div>
<?php	}
	}
function adminfooter(){?>
<div id="adminfooter">
<div class="row footer_block">
<div class="one_third footer_half">
<?php	if(@$_SESSION['loginid']==0){ ?>
<h4>Store Help</h4>
<ul>
<li><a href="https://www.ecommercetemplates.com/phphelp/ecommplus/about.asp">PHP Help Files</a></li>
<li><a href="https://www.ecommercetemplates.com/help/admin-help.asp">Admin Help Files</a></li>
<li><a href="https://www.ecommercetemplates.com/free_downloads.asp#usermanual">User manual</a></li>
<li><a href="https://www.ecommercetemplates.com/phphelp/ecommplus/parameters.asp">Store settings</a></li>
<li><a href="https://www.ecommercetemplates.com/tutorials/">Tutorials</a></li>
</ul>
<?php	} ?>
</div>
<div class="one_third footer_half">
<?php	if(@$_SESSION['loginid']==0){ ?>
<h4>Resources</h4>
<ul>
<li><a href="https://www.ecommercetemplates.com/support/">Support Forum</a></li>
<li><a href="https://www.ecommercetemplates.com/payment_processors.asp">Payment providers</a></li>
<li><a href="https://www.ecommercetemplates.com/free_downloads.asp">Store downloads</a></li>
<li><a href="https://www.ecommercetemplates.com/ecommercetools.asp">Store tools &amp; add-ons</a></li>
<li><a href="https://www.ecommercetemplates.com/newsletter/default.asp">Ecommerce Templates News</a></li>
</ul>
<?php	} ?>
</div>
<div class="one_third last">
<h4>Social media</h4>
<p>
<a href="https://www.facebook.com/EcommerceTemplates" target="_blank"><img src="adminimages/fb-icon.svg" alt="Facebook" width="32" height="32"></a>
<a href="https://x.com/etemplates/" target="_blank"><img src="adminimages/x-icon.svg" alt="X (Formerly Twitter)" width="32" height="32" ></a>
<a href="https://www.linkedin.com/in/ecommercetemplates" target="_blank"><img src="adminimages/li-icon.svg" alt="Linkedin" width="32" height="32"></a>
<a href="https://www.youtube.com/user/EcommerceTemplates" target="_blank"><img src="adminimages/yt-icon.svg" alt="YouTube" width="32" height="32"></a>
</p>
</div>
</div>
<?php updaterchecker(); ?>
</div>
<script> 
$("[role='navigation']").mainnav(); 
$('#responsive-table').stacktable({myClass:'admin-table-a-small'});
</script>
<?php }
if(@$adminlang==''){
	$result=ect_query("SELECT adminlang FROM admin WHERE adminid=1") or ect_error();
	if($rs=ect_fetch_assoc($result)){
		$adminlang=$rs['adminlang'];
		if($rs['adminlang']=='de'){
			include './inc/languageadmin_de.php';
		}elseif($rs['adminlang']=='es'){
			include './inc/languageadmin_es.php';
		}elseif($rs['adminlang']=='fr'){
			include './inc/languageadmin_fr.php';
		}elseif($rs['adminlang']=='it'){
			include './inc/languageadmin_it.php';
		}elseif($rs['adminlang']=='nl'){
			include './inc/languageadmin_nl.php';
		}
	}
	ect_free_result($result);
}
if(@$storesessionvalue=='') $storesessionvalue='virtualstore';
if(!@$donotlogin){
	if(@$forceloginonhttps && (@$_SERVER['HTTPS']!='on' && @$_SERVER['SERVER_PORT']!='443') && strpos($GLOBALS['storeurlssl'],'https:')!==FALSE){ header('Location: '.(substr($GLOBALS['storeurlssl'],0,-1)).$_SERVER['PHP_SELF'].(getget('loginkey')!=''?'?loginkey='.getget('loginkey'):'')); exit; }
	$mustchangefordate=FALSE;
	if(@$padssfeatures==TRUE){
		header('Cache-Control: no-store,no-cache');
		header('Pragma: no-cache');
	}
	if(@$_SESSION['loggedon'] != $storesessionvalue && trim_(@$_COOKIE['WRITECKL'])!='' && !@$GLOBALS['disallowlogin'] && ! (@$loginkey!='' && trim_(@$_COOKIE['loginkey'])!=@$loginkey)){
		$sSQL="SELECT adminID,adminUser,adminPWLastChange FROM admin WHERE adminPassword='" . escape_string(trim_(@$_COOKIE['WRITECKP'])) . "' AND adminID=1";
		$result=ect_query($sSQL) or ect_error();
		if($rs=ect_fetch_assoc($result)){
			if($rs['adminUser']==trim_(@$_COOKIE['WRITECKL'])){
				$_SESSION['loggedon'] = $storesessionvalue;
				$_SESSION['loggedonpermissions'] = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
				$_SESSION['loginid']=0;
				$_SESSION['loginuser']=$rs['adminUser'];
				if(time()-strtotime($rs['adminPWLastChange'])>(90*60*60*24) && @$padssfeatures==TRUE){ $_SESSION['mustchangepw']='B'; $mustchangefordate=TRUE; }
			}
		}
		ect_free_result($result);
		if(@$_SESSION['loggedon']!=$storesessionvalue){
			$sSQL="SELECT adminloginid,adminloginname,adminloginpermissions,adminLoginLastChange,dropShipper FROM adminlogin WHERE adminloginname='" . escape_string(trim_(@$_COOKIE['WRITECKL'])) . "' AND adminloginpassword='" . escape_string(trim_(@$_COOKIE['WRITECKP'])) . "'";
			$result=ect_query($sSQL) or ect_error();
			while($rs=ect_fetch_assoc($result)){
				if($rs['adminloginname']==trim_(@$_COOKIE['WRITECKL'])){
					$_SESSION['loggedon'] = $storesessionvalue;
					$_SESSION['loggedonpermissions'] = $rs['adminloginpermissions'];
					$_SESSION['loginid']=$rs['adminloginid'];
					$_SESSION['loginuser']=$rs['adminloginname'];
					$_SESSION['dropshipper']=$rs['dropShipper'];
					//if(time()-strtotime($rs['adminLoginLastChange'])>(90*60*60*24) && @$padssfeatures==TRUE){ $_SESSION['mustchangepw']='B'; $mustchangefordate=TRUE; }
				}
			}
			ect_free_result($result);
		}
		logevent(@$_COOKIE['WRITECKL'],'LOGIN',@$_SESSION['loggedon']==$storesessionvalue,'LOGIN','');
	}
	if(@$_SERVER['HTTPS']=='on' || @$_SERVER['SERVER_PORT']=='443')$prot='https://';else $prot='http://';
	if(@$_SESSION['loggedon'] != $storesessionvalue || @$GLOBALS['disallowlogin']){
		header('Location: '.$prot.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']).'/login.php'.(getget('loginkey')!=''?'?loginkey='.getget('loginkey'):''));
		exit;
	}
	if((@$_SESSION['mustchangepw']!='' || $mustchangefordate) && ! (@$thispagename=='adminlogin')){
		header('Location: '.$prot.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']).'/adminlogin.php');
		exit;
	}
}
$isprinter=FALSE;
$alreadygotadmin = getadminsettings();
?>