/application/views/partials/admin/functions.php
PHP | 2039 lines | 1815 code | 72 blank | 152 comment | 397 complexity | a6830724aef4ffb2fbf63333bedfbd80 MD5 | raw file
Large files files are truncated, but you can click here to view the full file
- <?php
- //This code is copyright (c) Internet Business Solutions SL, all rights reserved.
- //The contents of this file are protect under law as the intellectual property of Internet
- //Business Solutions SL. Any use, reproduction, disclosure or copying of any kind
- //without the express and written permission of Internet Business Solutions SL is forbidden.
- //Author: Vince Reid, vince@virtualred.net
- $incfunctionsdefined=TRUE;
- @set_magic_quotes_runtime(0);
- $magicq = (get_magic_quotes_gpc()==1);
- if(@$emailencoding=="") $emailencoding="iso-8859-1";
- if(@$adminencoding=="") $adminencoding="iso-8859-1";
- if(@$_SESSION["languageid"] != "") $languageid=$_SESSION["languageid"];
- function getadminsettings(){
- global $alreadygotadmin,$splitUSZones,$adminLocale,$countryCurrency,$orcurrencyisosymbol,$useEuro,$storeurl,$stockManage,$useStockManagement,$adminProdsPerPage,$countryTax,$delAfter,$delccafter,$handling,$adminCanPostUser,$packtogether,$origZip,$shipType,$origCountry,$origCountryCode,$uspsUser,$uspsPw,$upsUser,$upsPw,$upsAccess,$adminUnits,$emailAddr,$sendEmail,$adminTweaks,$adminlanguages,$adminlangsettings,$currRate1,$currSymbol1,$currRate2,$currSymbol2,$currRate3,$currSymbol3,$currConvUser,$currConvPw,$currLastUpdate;
- if(! @$alreadygotadmin){
- $sSQL = "SELECT adminEmail,adminEmailConfirm,adminTweaks,adminProdsPerPage,adminStoreURL,adminHandling,adminPacking,adminDelUncompleted,adminDelCC,adminUSZones,adminStockManage,adminShipping,adminCanPostUser,adminZipCode,adminUnits,adminUSPSUser,adminUSPSpw,adminUPSUser,adminUPSpw,adminUPSAccess,adminlanguages,adminlangsettings,currRate1,currSymbol1,currRate2,currSymbol2,currRate3,currSymbol3,currConvUser,currConvPw,currLastUpdate,countryLCID,countryCurrency,countryName,countryCode,countryTax FROM admin LEFT JOIN countries ON admin.adminCountry=countries.countryID WHERE adminID=1";
- $result = mysql_query($sSQL) or print(mysql_error());
- $rs = mysql_fetch_array($result);
- $splitUSZones = ((int)$rs["adminUSZones"]==1);
- $adminLocale = $rs["countryLCID"];
- $countryCurrency = $rs["countryCurrency"];
- if(@$orcurrencyisosymbol != "") $countryCurrency=$orcurrencyisosymbol;
- $useEuro = ($rs["countryCurrency"]=="EUR");
- $storeurl = $rs["adminStoreURL"];
- $stockManage = (int)$rs["adminStockManage"];
- $useStockManagement = ($stockManage != 0);
- $adminProdsPerPage = $rs["adminProdsPerPage"];
- $countryTax=(double)$rs["countryTax"];
- $delAfter = (int)$rs["adminDelUncompleted"];
- $delccafter = (int)$rs["adminDelCC"];
- $handling=(double)$rs["adminHandling"];
- $adminCanPostUser=trim($rs["adminCanPostUser"]);
- $packtogether = ((int)$rs["adminPacking"]==1);
- $origZip = $rs["adminZipCode"];
- $shipType=(int)$rs["adminShipping"];
- $origCountry = $rs["countryName"];
- $origCountryCode = $rs["countryCode"];
- $uspsUser = $rs["adminUSPSUser"];
- $uspsPw = $rs["adminUSPSpw"];
- $upsUser = upsdecode($rs["adminUPSUser"], "");
- $upsPw = upsdecode($rs["adminUPSpw"], "");
- $upsAccess = $rs["adminUPSAccess"];
- if((int)$rs["adminUnits"]==0) $adminUnits="KGS"; else $adminUnits="LBS";
- $emailAddr = $rs["adminEmail"];
- $sendEmail = ((int)$rs["adminEmailConfirm"]==1);
- $adminTweaks = (int)$rs["adminTweaks"];
- $adminlanguages = (int)$rs["adminlanguages"];
- $adminlangsettings = (int)$rs["adminlangsettings"];
- $currRate1=(double)$rs["currRate1"];
- $currSymbol1=trim($rs["currSymbol1"]);
- $currRate2=(double)$rs["currRate2"];
- $currSymbol2=trim($rs["currSymbol2"]);
- $currRate3=(double)$rs["currRate3"];
- $currSymbol3=trim($rs["currSymbol3"]);
- $currConvUser=$rs["currConvUser"];
- $currConvPw=$rs["currConvPw"];
- $currLastUpdate=$rs["currLastUpdate"];
- mysql_free_result($result);
- }
- // Overrides
- global $orstoreurl,$oremailaddr;
- if(@$orstoreurl != "") $storeurl=$orstoreurl;
- if((substr(strtolower($storeurl),0,7) != "http://") && (substr(strtolower($storeurl),0,8) != "https://"))
- $storeurl = "http://" . $storeurl;
- if(substr($storeurl,-1) != "/") $storeurl .= "/";
- if(@$oremailaddr != "") $emailAddr=$oremailaddr;
- return(TRUE);
- }
- function cleanforurl($surl){
- $surl = str_replace(' ','_',strtolower(strip_tags($surl)));
- return(preg_replace('/[^a-z_0-9]/','',$surl));
- }
- function getlangid($col, $bfield){
- global $languageid, $adminlangsettings;
- if(@$languageid=="" || @$languageid==1){
- return($col);
- }else{
- if(($adminlangsettings & $bfield) != $bfield) return($col);
- }
- return($col . $languageid);
- }
- function xmlencodecharref($xmlstr){
- $xmlstr = str_replace(array('®','&','<','>','®'),array('','&','<','>',''),$xmlstr);
- $tmp_str="";
- for($i=0; $i < strlen($xmlstr); $i++){
- $ch_code=ord(substr($xmlstr,$i,1));
- if($ch_code<=130) $tmp_str .= substr($xmlstr,$i,1);
- }
- return($tmp_str);
- }
- function CalcHmacSha1($data, $key){
- $blocksize = 64;
- $hashfunc = 'sha1';
- if (strlen($key) > $blocksize){
- $key = pack('H*', $hashfunc($key));
- }
- $key = str_pad($key, $blocksize, chr(0x00));
- $ipad = str_repeat(chr(0x36), $blocksize);
- $opad = str_repeat(chr(0x5c), $blocksize);
- $hmac = pack('H*', $hashfunc(($key^$opad).pack('H*', $hashfunc(($key^$ipad).$data))));
- return $hmac;
- }
- function parsedate($tdat){
- global $admindateformat;
- if($admindateformat==0)
- list($year, $month, $day) = sscanf($tdat, "%d-%d-%d");
- elseif($admindateformat==1)
- list($month, $day, $year) = sscanf($tdat, "%d/%d/%d");
- elseif($admindateformat==2)
- list($day, $month, $year) = sscanf($tdat, "%d/%d/%d");
- if(! is_numeric($year))
- $year = date("Y");
- elseif((int)$year < 39)
- $year = (int)$year + 2000;
- elseif((int)$year < 100)
- $year = (int)$year + 1900;
- if($year < 1970 || $year > 2038) $year = date("Y");
- if(! is_numeric($month))
- $month = date("m");
- if(! is_numeric($day))
- $day = date("d");
- return(mktime(0, 0, 0, $month, $day, $year));
- }
- function unstripslashes($slashedText){
- global $magicq;
- if($magicq)
- return stripslashes($slashedText);
- else
- return $slashedText;
- }
- function getattributes($attlist,$attid){
- $pos = strpos($attlist, $attid.'=');
- if($pos === false)
- return '';
- $pos += strlen($attid) + 1;
- $quote = $attlist[$pos];
- $pos2 = strpos($attlist, $quote, $pos + 1);
- $retstr = substr($attlist, $pos + 1, $pos2 - ($pos + 1));
- return($retstr);
- }
- class vrNodeList{
- var $length;
- var $childNodes;
- var $nodeName;
- var $nodeValue;
- var $attributes;
- function createNodeList($xmlStr){
- $xLen = strlen($xmlStr);
- for($i=0; $i < $xLen; $i++){
- if(substr($xmlStr, $i, 1)=="<" && substr($xmlStr, $i+1, 1) != "/" && substr($xmlStr, $i+1, 1) != "?"){ // Got a tag
- $j = strpos($xmlStr,">",$i);
- $l = strpos($xmlStr," ",$i);
- if(is_integer($l) && $l < $j){
- $this->nodeName[$this->length]=substr($xmlStr,$i+1,$l-($i+1));
- $this->attributes[$this->length] = substr($xmlStr,$l+1,($j-$l)-1);
- }else
- $this->nodeName[$this->length]=substr($xmlStr,$i+1,$j-($i+1));
- // print "Got Node: " . $this->nodeName[$this->length] . "<br />\n";
- $k = $i+1;
- $nodeNameLen=strlen($this->nodeName[$this->length]);
- $currLev=0;
- while($k < $xLen && $currLev >= 0){
- if(substr($xmlStr, $k, 2)=="</"){
- if($currLev==0 && substr($xmlStr, $k+2, $nodeNameLen)==$this->nodeName[$this->length])
- break;
- $currLev--;
- }elseif(substr($xmlStr, $k, 1)=="<")
- $currLev++;
- elseif(substr($xmlStr, $k, 2)=="/>")
- $currLev--;
- $k++;
- }
- $this->nodeValue[$this->length]=substr($xmlStr,$j+1,$k-($j+1));
- // print "Got Value: xxx" . str_replace("<","<br /><",$this->nodeValue[$this->length]) . "xxx<br />\n";
- $this->childNodes[$this->length] = new vrNodeList($this->nodeValue[$this->length]);
- $this->length++;
- $i = $k;
- }
- }
- }
- function vrNodeList($xmlStr){
- $this->length=0;
- $this->childNodes="";
- $this->createNodeList($xmlStr);
- }
- function getValueByTagName($tagname){
- for($i=0; $i < $this->length; $i++){
- //print "name: " . $this->nodeName[$i] . ", " . $this->nodeValue[$i] . "<br>";
- if($this->nodeName[$i]==$tagname){
- return($this->nodeValue[$i]);
- }else{
- if($this->childNodes!=''){
- if(($retval = $this->childNodes[$i]->getValueByTagName($tagname)) != NULL)
- return($retval);
- }
- }
- }
- return NULL;
- }
- function getAttributeByTagName($tagname, $attrib){
- for($i=0; $i < $this->length; $i++){
- if($this->nodeName[$i]==$tagname){
- return(getattributes($this->attributes[$i], $attrib));
- }else{
- if($this->childNodes!=''){
- if(($retval = $this->childNodes[$i]->getAttributeByTagName($tagname, $attrib)) != NULL)
- return($retval);
- }
- }
- }
- return NULL;
- }
- }
- class vrXMLDoc{
- var $tXMLStr;
- var $nodeList;
- function vrXMLDoc($xmlStr){
- $this->tXMLStr = $xmlStr;
- $this->nodeList = new vrNodeList($xmlStr);
- }
- function getElementsByTagName($tagname){
- $currlevel=0;
- $taglen = strlen($tagname);
- }
- }
- $netnav = TRUE;
- if(strstr(@$HTTP_SERVER_VARS["HTTP_USER_AGENT"], "compatible") || strstr(@$HTTP_SERVER_VARS["HTTP_USER_AGENT"], "Gecko")) $netnav = FALSE;
- function atb($size){
- global $netnav;
- if($netnav)
- return round($size / 2 + 1);
- else
- return $size;
- }
- $codestr="2952710692840328509902143349209039553396765";
- function upsencode($thestr, $propcodestr){
- global $codestr;
- if($propcodestr=="") $localcodestr=$codestr; else $localcodestr=$propcodestr;
- $newstr="";
- for($index=0; $index < strlen($localcodestr); $index++){
- $thechar = substr($localcodestr,$index,1);
- if(! is_numeric($thechar)){
- $thechar = ord($thechar) % 10;
- }
- $newstr .= $thechar;
- }
- $localcodestr = $newstr;
- while(strlen($localcodestr) < 40)
- $localcodestr .= $localcodestr;
- $newstr="";
- for($index=0; $index < strlen($thestr); $index++){
- $thechar = substr($thestr,$index,1);
- $newstr .= chr(ord($thechar)+(int)substr($localcodestr,$index,1));
- }
- return $newstr;
- }
- function upsdecode($thestr, $propcodestr){
- global $codestr;
- if($propcodestr=="") $localcodestr=$codestr; else $localcodestr=$propcodestr;
- $newstr="";
- for($index=0; $index < strlen($localcodestr); $index++){
- $thechar = substr($localcodestr,$index,1);
- if(! is_numeric($thechar)){
- $thechar = ord($thechar) % 10;
- }
- $newstr .= $thechar;
- }
- $localcodestr = $newstr;
- while(strlen($localcodestr) < 40)
- $localcodestr .= $localcodestr;
- if(is_null($thestr)){
- return "";
- }else{
- $newstr="";
- for($index=0; $index < strlen($thestr); $index++){
- $thechar = substr($thestr,$index,1);
- $newstr .= chr(ord($thechar)-(int)substr($localcodestr,$index,1));
- }
- return($newstr);
- }
- }
- $locale_info = "";
- function FormatEuroCurrency($amount){
- global $useEuro, $adminLocale, $locale_info, $overridecurrency, $orcsymbol, $orcdecplaces, $orcdecimals, $orcthousands, $orcpreamount;
- if(@$overridecurrency==TRUE){
- if($orcpreamount)
- return $orcsymbol . number_format($amount,$orcdecplaces,$orcdecimals,$orcthousands);
- else
- return number_format($amount,$orcdecplaces,$orcdecimals,$orcthousands) . $orcsymbol;
- }else{
- if(! is_array($locale_info)){
- setlocale(LC_MONETARY,$adminLocale);
- $locale_info = localeconv();
- setlocale(LC_MONETARY,"en_US");
- }
- if($useEuro)
- return number_format($amount,2,$locale_info["decimal_point"],$locale_info["thousands_sep"]) . " €";
- else
- return $locale_info["currency_symbol"] . number_format($amount,2,$locale_info["decimal_point"],$locale_info["thousands_sep"]);
- }
- }
- function FormatEmailEuroCurrency($amount){
- global $useEuro, $adminLocale, $locale_info, $overridecurrency, $orcemailsymbol, $orcdecplaces, $orcdecimals, $orcthousands, $orcpreamount;
- if(@$overridecurrency==TRUE){
- if($orcpreamount)
- return $orcemailsymbol . number_format($amount,$orcdecplaces,$orcdecimals,$orcthousands);
- else
- return number_format($amount,$orcdecplaces,$orcdecimals,$orcthousands) . $orcemailsymbol;
- }else{
- if(! is_array($locale_info)){
- setlocale(LC_ALL,$adminLocale);
- $locale_info = localeconv();
- setlocale(LC_ALL,"en_US");
- }
- if($useEuro)
- return number_format($amount,2,$locale_info["decimal_point"],$locale_info["thousands_sep"]) . " Euro";
- else
- return $locale_info["currency_symbol"] . number_format($amount,2,$locale_info["decimal_point"],$locale_info["thousands_sep"]);
- }
- }
- //AFFILIATE
- /*if(trim(@$_GET["PARTNER"]) != "" || trim(@$_GET["REFERER"]) != ""){
- if(@$expireaffiliate == "") $expireaffiliate=30;
- if(trim(@$_GET["PARTNER"])!="") $thereferer=trim(@$_GET["PARTNER"]); else $thereferer=trim(@$_GET["REFERER"]);
- print "<script src='/admin/savecookie.php?PARTNER=" . $thereferer . "&EXPIRES=" . $expireaffiliate . "'></script>";
- }*/
- //share a sale and commission junction affilates
- if(trim(@$_GET["ifrogz_affiliate"]) != "" || trim(@$_GET["ifrogz_affiliate"]) != ""){
- if(@$expireaffiliate == "") $expireaffiliate=30;
- if(trim(@$_GET["ifrogz_affiliate"])!="") $thereferer=trim(@$_GET["ifrogz_affiliate"]); else $thereferer=trim(@$_GET["REFERER"]);
- print "<script src='/admin/savecookie.php?ifrogz_affiliate=" . $thereferer . "&EXPIRES=" . $expireaffiliate . "'></script>";
- }
- //GET COUPON CODE FROM EMAIL
- /*if($_GET['utm_campaign'] == 'Free_Shipping_Dec_20_2007') {
- $_SESSION['os'] = 'freeshipping1220';
- }*/
- //echo '$_SESSION[os]='.$_SESSION['os'];
- //end sas and cj
- //$stockManage=0;
- function do_stock_management($smOrdId){
- global $stockManage;
- if($stockManage != 0){
- $sSQL="SELECT cartID,cartProdID,cartQuantity,pSell, pInStock FROM cart INNER JOIN products ON cart.cartProdID=products.pID WHERE pDropship=0 AND (cartCompleted=0 OR cartCompleted=2) AND cartOrderID='" . mysql_real_escape_string(unstripslashes($smOrdId)) . "'";
- $result1 = mysql_query($sSQL) or print(mysql_error());
- while($rs1 = mysql_fetch_array($result1)){
- if(($rs1["pSell"] & 2) == 2){
- $sSQL = "SELECT coOptID, optStyleID, optStock, coOptGroup FROM cartoptions INNER JOIN options ON cartoptions.coOptID=options.optID INNER JOIN optiongroup ON options.optGroup=optiongroup.optGrpID WHERE (optType=2 OR optType=-2) AND coCartID=" . $rs1["cartID"];
- $result2 = mysql_query($sSQL) or print(mysql_error());
- while($rs2 = mysql_fetch_array($result2)){
- $newQty = $rs1["cartQuantity"];
- // If this option is a Custom Hype Rim, then make quantity double. (They are ordered as pairs, but inventory is kept individually)
- // * Remember to change this in other places too ( release_stock(), getOnOrderStock(), and printpackingslips.php line 151 )
- if ($rs1['cartProdID'] == 'customhype' && strstr($rs2['coOptGroup'],'Rim')) {
- $newQty = $rs1["cartQuantity"] * 2;
- }
- $sSQL = "UPDATE options SET optStock=optStock-" . $newQty . " WHERE optID=" . $rs2["coOptID"];
- mysql_query($sSQL) or print(mysql_error());
-
- //record change
- $empID = $_SESSION['employee']['id'];
- if (empty($empID)) {
- $empID = 81;
- }
-
- $sql="INSERT INTO inv_adjustments (iaOptID, iaProdStyle, iaAmt, iaDate, iaReason, iaEmpID, iaOldValue, iaNewValue, iaNotes)
- VALUES ('".$rs2["coOptID"]."','".$rs1["cartProdID"]."-".$rs2["optStyleID"]."','-".$newQty."','".date('Y-m-d H:i:s')."','7','".$empID."',".$rs2["optStock"].",".($rs2["optStock"]-$rs1["cartQuantity"]).", 'ordID: $smOrdId')";
- //mail("chadsaun@gmail.com", "iFrogz Inv Test: Stock Manage", $sql);
- mysql_query($sql) or mail("chadsaun@gmail.com", "iFrogz Inv Test Error: Stock Manage", $sql);
- }
- mysql_free_result($result2);
- }else{
- $sSQL = "UPDATE products SET pInStock=pInStock-" . $rs1["cartQuantity"] . " WHERE pID='" . $rs1["cartProdID"] . "'";
- mysql_query($sSQL) or print(mysql_error());
-
- //record change
- $empID = $_SESSION['employee']['id'];
- if (empty($empID)) {
- $empID = 81;
- }
-
- $sql="INSERT INTO inv_adjustments (iaOptID,iaProdID,iaAmt,iaDate,iaReason,iaEmpID,iaOldValue,iaNewValue, iaNotes)
- VALUES ('0','".$rs1["cartProdID"]."','-".$rs1["cartQuantity"]."','".date('Y-m-d H:i:s')."','7','".$empID."',".$rs1["pInStock"].",".($rs1["pInStock"]-$rs1["cartQuantity"]).", 'ordID: $smOrdId')";
- //mail("chadsaun@gmail.com", "iFrogz Inv Test: Stock Manage", $sql);
- mysql_query($sql) or mail("chadsaun@gmail.com", "iFrogz Inv Test Error: Stock Manage", $sql);
- }
- }
- mysql_free_result($result1);
- }
- }
- function release_stock($smOrdId) {
- global $stockManage;
- if($stockManage != 0){
- $sSQL="SELECT cartID,cartProdID,cartQuantity,pSell,pDownload,p_iscert, pInStock FROM cart INNER JOIN products ON cart.cartProdID=products.pID WHERE products.pDropship=0 AND cartCompleted=1 AND cartOrderID=" . $smOrdId;
- $result = mysql_query($sSQL) or print(mysql_error());
- while($rs = mysql_fetch_array($result)){
- if((($rs["pSell"] & 2) == 2)){
- $sSQL = "SELECT coOptID, coCartOption, optStyleID, optStock, coOptGroup FROM cartoptions INNER JOIN options ON cartoptions.coOptID=options.optID INNER JOIN optiongroup ON options.optGroup=optiongroup.optGrpID WHERE (optType=2 OR optType=-2) AND coCartID=" . $rs["cartID"];
- $result2 = mysql_query($sSQL) or print(mysql_error());
- while($rs2 = mysql_fetch_array($result2)){
- $newQty = $rs["cartQuantity"];
- // If this option is a Custom Hype Rim, then make quantity double. (They are ordered as pairs, but inventory is kept individually)
- // * Remember to change this in other places too ( do_stock_management(), getOnOrderStock(), and printpackingslips.php line 151 )
- if ($rs['cartProdID'] == 'customhype' && strstr($rs2['coOptGroup'],'Rim')) {
- $newQty = $rs["cartQuantity"] * 2;
- }
- if (empty($newQty)) {
- $newQty = 0;
- }
- $sSQL = "UPDATE options SET optStock=optStock+" . $newQty . " WHERE optID=" . $rs2["coOptID"];
- mysql_query($sSQL) or print(mysql_error().$sSQL);
-
- //record change
- $empID = $_SESSION['employee']['id'];
- if (empty($empID)) {
- $empID = 81;
- }
-
- $sql="INSERT INTO inv_adjustments (iaOptID, iaProdStyle, iaAmt, iaDate, iaReason, iaEmpID, iaOldValue, iaNewValue, iaNotes)
- VALUES ('".$rs2["coOptID"]."', '".$rs["cartProdID"]."-".$rs2["optStyleID"]."', '".$newQty."', '".date('Y-m-d H:i:s')."', '6', '".$empID."', ".$rs2["optStock"].", ".($rs2["optStock"]+$rs["cartQuantity"]).", 'ordID: $smOrdId')";
- //mail("chadsaun@gmail.com", "iFrogz Inv Test: Release Stock", $sql);
- mysql_query($sql) or mail("chadsaun@gmail.com", "iFrogz Inv Test Error: Release Stock", $sql);
- }
- mysql_free_result($result2);
- }else{
- $sSQL = "UPDATE products SET pInStock=pInStock+" . $rs["cartQuantity"] . " WHERE pID='" . $rs["cartProdID"] . "'";
- mysql_query($sSQL) or print(mysql_error());
-
- //record change
- $empID = $_SESSION['employee']['id'];
- if (empty($empID)) {
- $empID = 81;
- }
-
- $sql="INSERT INTO inv_adjustments (iaOptID,iaProdID,iaAmt,iaDate,iaReason,iaEmpID,iaOldValue,iaNewValue, iaNotes)
- VALUES ('0','".$rs["cartProdID"]."','".$rs["cartQuantity"]."','".date('Y-m-d H:i:s')."','6','".$empID."',".$rs["pInStock"].",".($rs["pInStock"]+$rs["cartQuantity"]).", 'ordID: $smOrdId')";
- //mail("chadsaun@gmail.com", "iFrogz Inv Test: Release Stock", $sql);
- mysql_query($sql) or mail("chadsaun@gmail.com", "iFrogz Inv Test Error: Release Stock", $sql);
- }
- }
- mysql_free_result($result);
- }
- }
- //END
- function productdisplayscript($doaddprodoptions){
- global $prodoptions, $countryTax, $xxPrdEnt, $xxPrdChs, $xxPrd255, $xxOptOOS, $useStockManagement, $prodlist, $OWSP;
- global $currSymbol1,$currFormat1,$currSymbol2,$currFormat2,$currSymbol3,$currFormat3;
- if($currSymbol1!="" && $currFormat1=="") $currFormat1='%s <strong>' . $currSymbol1 . '</strong>';
- if($currSymbol2!="" && $currFormat2=="") $currFormat2='%s <strong>' . $currSymbol2 . '</strong>';
- if($currSymbol3!="" && $currFormat3=="") $currFormat3='%s <strong>' . $currSymbol3 . '</strong>';
- ?>
- <script language="JavaScript" type="text/javascript">
- <!--
- var aPC = new Array();<?php
- if($useStockManagement){ ?>
- var aPS = new Array();
- checkStock=function(x, i){
- if(i!='' && aPS[i] > 0)return(true);
- alert('<?php print str_replace("'","\'",$xxOptOOS)?>');
- x.focus();return(false);
- }<?php } ?>
- var isW3 = (document.getElementById&&true);
- var tax=<?php print $countryTax ?>;
- dummyfunc=function(){};
- <?php
- $prodoptions="";
- if($doaddprodoptions && $prodlist != ""){
- $sSQL = "SELECT DISTINCT optID," . $OWSP . "optPriceDiff,optStock,optDisplay_point FROM options INNER JOIN prodoptions ON options.optGroup=prodoptions.poOptionGroup WHERE prodoptions.poProdID IN (" . $prodlist . ")";
- $result = mysql_query($sSQL) or print(mysql_error());
- $rowcounter=0;
- while($row = mysql_fetch_array($result)){
- if($useStockManagement) print 'aPS[' . $row["optID"] . ']=' . ($row["optStock"]) . ';';
- print "aPC[". $row["optID"] . "]=" . $row["optPriceDiff"] . ";";
- if(($rowcounter % 10)==9) print "\r\n";
- $rowcounter++;
- }
- print "\r\n";
- }
- ?>
- pricechecker=function(i){
- if(i!='')return(aPC[i]);return(0);}
- enterValue=function(x){
- alert('<?php print str_replace("'","\'",$xxPrdEnt)?>');
- x.focus();return(false);}
- chooseOption=function(x){
- alert('<?php print str_replace("'","\'",$xxPrdChs)?>');
- x.focus();return(false);}
- dataLimit=function(x){
- alert('<?php print str_replace("'","\'",$xxPrd255)?>');
- x.focus();return(false);}
- formatprice=function(i, currcode, currformat){
- <?php
- $tempStr = FormatEuroCurrency(0);
- $tempStr2 = number_format(0,2,".",",");
- print "var pTemplate='" . $tempStr . "';\n";
- print "if(currcode!='') pTemplate=' " . $tempStr2 . "' + (currcode!=' '?'<strong>'+currcode+'<\/strong>':'');";
- if(strstr($tempStr,",") || strstr($tempStr,".")){ ?>
- if(currcode==' JPY')i = Math.round(i).toString();
- else if(i==Math.round(i))i=i.toString()+".00";
- else if(i*10.0==Math.round(i*10.0))i=i.toString()+"0";
- else if(i*100.0==Math.round(i*100.0))i=i.toString();
- <?php }
- print 'if(currcode!="")pTemplate = currformat.toString().replace(/%s/,i.toString());';
- print 'else pTemplate = pTemplate.toString().replace(/\d[,.]*\d*/,i.toString());';
- if(strstr($tempStr,","))
- print "return(pTemplate.replace(/\./,','));";
- else
- print "return(pTemplate);";
- ?>}
- openEFWindow= function(id) {
- window.open('/emailfriend.php?utm_source=emailfriend&id='+id,'email_friend','menubar=no, scrollbars=no, width=400, height=460, directories=no,location=no,resizable=yes,status=no,toolbar=no')
- }
- //-->
- </script><?php
- }
- function updatepricescript($doaddprodoptions){
- global $prodoptions,$Count,$rs,$WSP,$noprice,$pricezeromessage,$showtaxinclusive,$currRate1,$currRate2,$currRate3,$currSymbol1,$currSymbol2,$currSymbol3,$currFormat1,$currFormat2,$currFormat3,$useStockManagement,$currencyseparator;
- $pPrice_adj=1;
- if(!empty($WSP)) $pPrice_adj=getPricingAdj($_SESSION['custID'],1,$rs["pPricing_group"]);
- ?>
- <script language="JavaScript" type="text/javascript">
- <!--
- formvalidator<?php print $Count?>= function(theForm){
- <?php
- $prodoptions="";
- $hasonepriceoption=FALSE;
- if($doaddprodoptions){
- $sSQL = "SELECT poOptionGroup,optType,optFlags FROM prodoptions LEFT JOIN optiongroup ON optiongroup.optGrpID=prodoptions.poOptionGroup WHERE poProdID='" . $rs["pId"] . "' ORDER BY poID";
- $result = mysql_query($sSQL) or print(mysql_error());
- for($rowcounter=0;$rowcounter<mysql_num_rows($result);$rowcounter++){
- $prodoptions[$rowcounter] = mysql_fetch_array($result);
- }
- if(is_array($prodoptions)){
- foreach($prodoptions as $rowcounter => $theopt){
- if($theopt["optType"]==3){
- print "if(theForm.voptn" . $rowcounter . ".value=='')return(enterValue(theForm.voptn" . $rowcounter . "));\n";
- print "if(theForm.voptn" . $rowcounter . ".value.length>255)return(dataLimit(theForm.voptn" . $rowcounter . "));\n";
- }elseif(abs($theopt["optType"])==2){
- $hasonepriceoption=TRUE;
- if($theopt["optType"]==2)
- print 'if(theForm.optn' . $rowcounter . '.selectedIndex==0)return(chooseOption(theForm.optn' . $rowcounter . "));\n";
- if($useStockManagement && (($rs["pSell"] & 2) == 2)) print 'if(!checkStock(theForm.optn' . $rowcounter . ',theForm.optn' . $rowcounter . '.options[theForm.optn' . $rowcounter . '.selectedIndex].value))return(false);' . "\r\n";
- }
- }
- }
- }
- if(@$customvalidator != "") print $customvalidator;
- ?>return (true);
- }
- <?php
- if(@$noprice!=TRUE && ! ($rs["pPrice"]==0 && @$pricezeromessage != "") && $hasonepriceoption){
- print 'updateprice' . $Count . "= function(){\r\n";
- print 'var totAdd=' . ($rs["pPrice"]*$pPrice_adj) . ";\r\n";
- print 'if(!isW3) return;';
- foreach($prodoptions as $rowcounter => $theopt){
- if(abs($theopt["optType"])!=3){
- if(($theopt["optFlags"]&1)==1)
- print 'totAdd=totAdd+((' . ($rs["pPrice"]*$pPrice_adj) . "*pricechecker(document.forms.tForm" . $Count . ".optn" . $rowcounter . ".options[document.forms.tForm" . $Count . ".optn" . $rowcounter . ".selectedIndex].value))/100.0);\n";
- else
- print 'totAdd=totAdd+pricechecker(document.forms.tForm' . $Count . ".optn" . $rowcounter . ".options[document.forms.tForm" . $Count . ".optn" . $rowcounter . ".selectedIndex].value);\n";
- }
- }
- print "document.getElementById('pricediv" . $Count . "').innerHTML=formatprice(Math.round(totAdd*100.0)/100.0, '', '');\r\n";
- if(@$showtaxinclusive && ($rs["pExemptions"] & 2)!=2) print "document.getElementById('pricedivti" . $Count . "').innerHTML=formatprice(Math.round((totAdd+(totAdd*tax/100.0))*100.0)/100.0, '', '');\n";
- $extracurr = "";
- if($currRate1!=0 && $currSymbol1!="") $extracurr = "+formatprice(Math.round((totAdd*" . $currRate1 . ")*100.0)/100.0, ' " . $currSymbol1 . "','" . str_replace("'","\'",$currFormat1) . "')+'".str_replace("'","\'",$currencyseparator)."'\n";
- if($currRate2!=0 && $currSymbol2!="") $extracurr .= "+formatprice(Math.round((totAdd*" . $currRate2 . ")*100.0)/100.0, ' " . $currSymbol2 . "','" . str_replace("'","\'",$currFormat2) . "')+'".str_replace("'","\'",$currencyseparator)."'\n";
- if($currRate3!=0 && $currSymbol3!="") $extracurr .= "+formatprice(Math.round((totAdd*" . $currRate3 . ")*100.0)/100.0, ' " . $currSymbol3 . "','" . str_replace("'","\'",$currFormat3) . "');\n";
- if($extracurr!="") print "document.getElementById('pricedivec" . $Count . "').innerHTML=''" . $extracurr . "\r\n";
- print "}";
- }
- ?>//-->
- </script><?php
- }
- //////////////
- //// added by blake for auto add products
- function productdisplayscript2($doaddprodoptions){
- global $prodoptions, $countryTax, $xxPrdEnt, $xxPrdChs, $xxPrd255, $xxOptOOS, $useStockManagement, $prodlist, $OWSP;
- global $currSymbol1,$currFormat1,$currSymbol2,$currFormat2,$currSymbol3,$currFormat3;
- if($currSymbol1!="" && $currFormat1=="") $currFormat1='%s <strong>' . $currSymbol1 . '</strong>';
- if($currSymbol2!="" && $currFormat2=="") $currFormat2='%s <strong>' . $currSymbol2 . '</strong>';
- if($currSymbol3!="" && $currFormat3=="") $currFormat3='%s <strong>' . $currSymbol3 . '</strong>';
- ?>
- <script language="JavaScript" type="text/javascript">
- var taPC = new Array();<?php
- if($useStockManagement){ ?>
- var taPS = new Array();
- tcheckStock=function(x, i){
- if(i!='' && taPS[i] > 0)return(true);
- alert('<?php print str_replace("'","\'",$xxOptOOS)?>');
- x.focus();return(false);
- }<?php } ?>
- tisW3 = (document.getElementById&&true);
- //alert(tisW3);
- var ttax=<?php print $countryTax ?>;
- tdummyfunc=function(){};
- <?php
- $prodoptions="";
- if($doaddprodoptions && $prodlist != ""){
- $sSQL = "SELECT DISTINCT optID," . $OWSP . "optPriceDiff,optStock,optDisplay_point
- FROM options INNER JOIN prodoptions ON options.optGroup=prodoptions.poOptionGroup
- WHERE prodoptions.poProdID IN (" . $prodlist . ")";
- $result = mysql_query($sSQL) or print(mysql_error());
- $rowcounter=0;
- while($row = mysql_fetch_array($result)){
- if ($useStockManagement) {
- print 'taPS[' . $row["optID"] . ']=' . ($row["optStock"]) . ';';
- }
- print "taPC[". $row["optID"] . "]=" . $row["optPriceDiff"] . ";";
- if(($rowcounter % 10)==9) print "\r\n";
- $rowcounter++;
- }
- print "\r\n";
- }
- ?>
- tpricechecker=function(i){
- if(i!='')return(taPC[i]);return(0);}
- tenterValue=function(x){
- alert('<?php print str_replace("'","\'",$xxPrdEnt)?>');
- x.focus();return(false);}
- tchooseOption=function(x){
- alert('<?php print str_replace("'","\'",$xxPrdChs)?>');
- x.focus();return(false);}
- tdataLimit=function(x){
- alert('<?php print str_replace("'","\'",$xxPrd255)?>');
- x.focus();return(false);}
- tformatprice=function(i, currcode, currformat){
- <?php
- $tempStr = FormatEuroCurrency(0);
- $tempStr2 = number_format(0,2,".",",");
- print "var pTemplate='" . $tempStr . "';\n";
- print "if(currcode!='') pTemplate=' " . $tempStr2 . "' + (currcode!=' '?'<strong>'+currcode+'<\/strong>':'');";
- if(strstr($tempStr,",") || strstr($tempStr,".")){ ?>
- if(currcode==' JPY')i = Math.round(i).toString();
- else if(i==Math.round(i))i=i.toString()+".00";
- else if(i*10.0==Math.round(i*10.0))i=i.toString()+"0";
- else if(i*100.0==Math.round(i*100.0))i=i.toString();
- <?php }
- print 'if(currcode!="")pTemplate = currformat.toString().replace(/%s/,i.toString());';
- print 'else pTemplate = pTemplate.toString().replace(/\d[,.]*\d*/,i.toString());';
- if(strstr($tempStr,","))
- print "return(pTemplate.replace(/\./,','));";
- else
- print "return(pTemplate);";
- ?>}
- topenEFWindow= function(id) {
- window.open('/emailfriend.php?utm_source=emailfriend&id='+id,'email_friend','menubar=no, scrollbars=no, width=400, height=460, directories=no,location=no,resizable=yes,status=no,toolbar=no')
- }
- </script><?php
- }
- function updatepricescript2($doaddprodoptions){
- global $prodoptions,$Count,$rs,$WSP,$noprice,$pricezeromessage,$showtaxinclusive,$currRate1,$currRate2,$currRate3,$currSymbol1,$currSymbol2,$currSymbol3,$currFormat1,$currFormat2,$currFormat3,$useStockManagement,$currencyseparator;
- $pPrice_adj=1;
- if(!empty($WSP)) $pPrice_adj=getPricingAdj($_SESSION['custID'],1,$rs["pPricing_group"]);
- ?>
- <script language="JavaScript" type="text/javascript">
- tformvalidator<?php print $Count?>= function(theForm){
- <?php
- $prodoptions="";
- $hasonepriceoption=FALSE;
- if($doaddprodoptions){
- $sSQL = "SELECT poOptionGroup,optType,optFlags FROM prodoptions LEFT JOIN optiongroup ON optiongroup.optGrpID=prodoptions.poOptionGroup WHERE poProdID='" . $rs["pId"] . "' ORDER BY poID";
-
- $result = mysql_query($sSQL) or print(mysql_error());
- for($rowcounter=0;$rowcounter<mysql_num_rows($result);$rowcounter++){
- $prodoptions[$rowcounter] = mysql_fetch_array($result);
- }
- if(is_array($prodoptions)){
- foreach($prodoptions as $rowcounter => $theopt){
- if($theopt["optType"]==3){
- print "if(theForm.voptn" . $rowcounter . ".value=='')return(tenterValue(theForm.voptn" . $rowcounter . "));\n";
- print "if(theForm.voptn" . $rowcounter . ".value.length>255)return(tdataLimit(theForm.voptn" . $rowcounter . "));\n";
- }elseif(abs($theopt["optType"])==2){
- $hasonepriceoption=TRUE;
- if($theopt["optType"]==2)
- print 'if(theForm.optn_' .$Count. '_' . $rowcounter . '.selectedIndex==0)return(tchooseOption(theForm.optn_' .$Count. '_' . $rowcounter . "));\n";
- if($useStockManagement && (($rs["pSell"] & 2) == 2)) print 'if(!tcheckStock(theForm.optn_' .$Count. '_' . $rowcounter . ',theForm.optn_' .$Count. '_' . $rowcounter . '.options[theForm.optn_' .$Count. '_' . $rowcounter . '.selectedIndex].value))return(false);' . "\r\n";
- }
- }
- }
- }
- if(@$customvalidator != "") print $customvalidator;
- ?>return (true);
- }
- <?php
- if(@$noprice!=TRUE && ! ($rs["pPrice"]==0 && @$pricezeromessage != "") && $hasonepriceoption){
- print 'tupdateprice' . $Count . "= function(){\r\n";
- print 'var totAdd=' . ($rs["pPrice"]*$pPrice_adj) . ";\r\n";
- print 'if(!tisW3) return;';
- foreach($prodoptions as $rowcounter => $theopt){
- if(abs($theopt["optType"])!=3){
- if(($theopt["optFlags"]&1)==1)
- print 'totAdd=totAdd+((' . ($rs["pPrice"]*$pPrice_adj) . "*tpricechecker(document.forms.tForm" . $Count . ".optn_" .$Count. "_" . $rowcounter . ".options[document.forms.tForm" . $Count . ".optn_" .$Count. "_" . $rowcounter . ".selectedIndex].value))/100.0);\n";
- else
- print 'totAdd=totAdd+tpricechecker(document.forms.tForm' . $Count . ".optn_" .$Count. "_" . $rowcounter . ".options[document.forms.tForm" . $Count . ".optn_" .$Count. "_" . $rowcounter . ".selectedIndex].value);\n";
- }
- }
- print "document.getElementById('pricediv" . $Count . "').innerHTML=tformatprice(Math.round(totAdd*100.0)/100.0, '', '');\r\n";
- if(@$showtaxinclusive && ($rs["pExemptions"] & 2)!=2) print "document.getElementById('pricedivti" . $Count . "').innerHTML=tformatprice(Math.round((totAdd+(totAdd*tax/100.0))*100.0)/100.0, '', '');\n";
- $extracurr = "";
- if($currRate1!=0 && $currSymbol1!="") $extracurr = "+tformatprice(Math.round((totAdd*" . $currRate1 . ")*100.0)/100.0, ' " . $currSymbol1 . "','" . str_replace("'","\'",$currFormat1) . "')+'".str_replace("'","\'",$currencyseparator)."'\n";
- if($currRate2!=0 && $currSymbol2!="") $extracurr .= "+tformatprice(Math.round((totAdd*" . $currRate2 . ")*100.0)/100.0, ' " . $currSymbol2 . "','" . str_replace("'","\'",$currFormat2) . "')+'".str_replace("'","\'",$currencyseparator)."'\n";
- if($currRate3!=0 && $currSymbol3!="") $extracurr .= "+tformatprice(Math.round((totAdd*" . $currRate3 . ")*100.0)/100.0, ' " . $currSymbol3 . "','" . str_replace("'","\'",$currFormat3) . "');\n";
- if($extracurr!="") print "document.getElementById('pricedivec" . $Count . "').innerHTML=''" . $extracurr . "\r\n";
- print "}";
- }
- ?>
- </script><?php
- }
- function checkRelatedDiscounts(){
- global $WSP;
- $newprice="";
- $sSQL = "SELECT cartID,cartProdID,cartAltPrice,cartProdPrice,cartQuantity FROM cart WHERE cartCompleted=0 AND cartSessionID='" . session_id() . "'";
- $total_in_cart=0;
- $result = mysql_query($sSQL) or print(mysql_error());
- $i=0;
- while($rs=mysql_fetch_assoc($result)){
- $reldisc[$i]=$rs;
- $reldisc[$i][$rs['cartProdID']]['rel_disc']+=$rs['cartQuantity'];
-
- $i++;
- }
- $total_in_cart=calculateTotal();
- //echo "<br />Total=".$total_in_cart;
- $cnt=count($reldisc);
- for($j=0;$j<$cnt;$j++){
-
- $sql_mini="SELECT *
- FROM related_discounts rd
- LEFT JOIN products p ON rd.relProd=p.pID
- WHERE relProd='".$reldisc[$j]['cartProdID']."'
- AND IF(relBegin != '0000-00-00 00:00:00', relBegin <= '" . date('Y-m-d H:i:s') . "', 1=1) AND IF(relEnd != '0000-00-00 00:00:00', relEnd > '" . date('Y-m-d H:i:s') . "', 1=1)";
- //$sql_mini.= " AND relCartTotal+pPrice<=".$total_in_cart;
- //echo $sql_mini;
- $result_mini=mysql_query($sql_mini);
- $num_rows=mysql_num_rows($result_mini);
- if($num_rows>0) {
- $rs_mini=mysql_fetch_assoc($result_mini);
- //echo $rs_mini['relCartTotal'].'<='.($total_in_cart.' - '.$reldisc[$j]['cartProdPrice']);
- if ($rs_mini['relPrice']>-1) {
- if (($rs_mini['relCartTotal']<=$total_in_cart-$reldisc[$j]['cartProdPrice']) && $rs_mini['relNumber']>=($reldisc[$j][$rs_mini['relProd']]['rel_disc']+$prodcnt[$rs_mini['relProd']])){
- //echo "<br />".'Test'.$rs_mini['relNumber'].'<'.$reldisc[$j][$reldisc[$j]['cartProdID']]['rel_disc']."<br />";
- $theprice = $rs_mini['relPrice'];
- $cartAltPrice = $rs_mini['relPrice'];
- //echo '$rs_mini[relPrice]='.$rs_mini['relPrice'];
- //echo '$prodcnt[$rs_mini[relProd]]='.$prodcnt[$reldisc[$j]['cartProdID']]."<br />";
- $prodcnt[$rs_mini['relProd']]++;
- } else {
- $sql_p = "SELECT pPrice FROM products WHERE pID='".$reldisc[$j]['cartProdID']."'";
- $result = mysql_query($sql_p);
- $rs_p = mysql_fetch_assoc($result);
- //if($reldisc[$i]['cartProdPrice']!=$rs_p['pPrice'])$theprice=$reldisc[$j]['cartProdPrice'];
- //else
- $theprice = $rs_p['pPrice'];
- $cartAltPrice = -1;
- }
- //echo "<br />".$reldisc[$j]['cartProdID'].'-'.$theprice."-".$reldisc[$j]['cartQuantity']."<br />";
-
- $sSQL = "UPDATE cart SET cartProdPrice='".$theprice."', cartAltPrice='".$cartAltPrice."' WHERE cartCompleted=0 AND cartSessionID='" . session_id() . "' AND cartID='".mysql_real_escape_string($reldisc[$j]['cartID'])."'";
- //echo $sSQL;
- mysql_query($sSQL) or print(mysql_error().$sSQL);
- }
- }
- }
- }
- function calculateTotal(){
- //global $totaldiscounts;
- $sSQL = "SELECT SUM(cartProdPrice*cartQuantity) AS totalPrice FROM cart c LEFT JOIN products p ON c.cartProdID=p.pID WHERE cartCompleted=0 AND cartSessionID='" . session_id() . "'";
- $result = mysql_query($sSQL) or print(mysql_error());
- if($rs=mysql_fetch_assoc($result)){
- //echo "<br />======".$rs['totalPrice'].'-'.$_SESSION["discounts"]."<br />";
- return $rs['totalPrice']-$_SESSION["discounts"];
- }
- }
- ///// end auto add ////
- function checkDPs($currcode){
- if($currcode=="JPY") return(0); else return(2);
- }
- function checkCurrencyRates($currConvUser,$currConvPw,$currLastUpdate,&$currRate1,$currSymbol1,&$currRate2,$currSymbol2,&$currRate3,$currSymbol3){
- global $countryCurrency,$usecurlforfsock,$pathtocurl,$curlproxy;
- $ccsuccess = true;
- if($currConvUser!="" && $currConvPw!="" && (strtotime($currLastUpdate) < time()-(60*60*24))){
- $str = "";
- if($currSymbol1!="") $str .= "&curr=" . $currSymbol1;
- if($currSymbol2!="") $str .= "&curr=" . $currSymbol2;
- if($currSymbol3!="") $str .= "&curr=" . $currSymbol3;
- if($str==""){
- mysql_query("UPDATE admin SET currLastUpdate='" . date("Y-m-d H:i:s", time()) . "'") or print(mysql_error());
- return;
- }
- $str = "?source=" . $countryCurrency . "&user=" . $currConvUser . "&pw=" . $currConvPw . $str;
- if(@$usecurlforfsock){
- if(@$pathtocurl != ""){
- exec($pathtocurl . ' --data-binary \'' . str_replace("'","\'","X") . '\' http://www.ecommercetemplates.com/currencyxml.asp' . $str, $res, $retvar);
- $sXML = implode("\n",$res);
- }else{
- if (!$ch = curl_init()) {
- $success = false;
- $errormsg = "cURL package not installed in PHP";
- $ccsuccess = FALSE;
- }else{
- curl_setopt($ch, CURLOPT_URL,'http://www.ecommercetemplates.com/currencyxml.asp' . $str);
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_HEADER, 0);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
- curl_setopt($ch, CURLOPT_POSTFIELDS, "X");
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- if(@$curlproxy!=''){
- curl_setopt($ch, CURLOPT_PROXY, $curlproxy);
- }
- $sXML = curl_exec($ch);
- if(curl_error($ch) != "") print "Error with cURL installation: " . curl_error($ch) . "<br />";
- curl_close($ch);
- }
- }
- }else{
- $header = "POST /currencyxml.asp" . $str . " HTTP/1.0\r\n";
- $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
- $header .= "Content-Length: 1\r\n\r\n";
- $fp = fsockopen ('www.ecommercetemplates.com', 80, $errno, $errstr, 30);
- if (!$fp){
- echo "$errstr ($errno)"; // HTTP error handling
- $ccsuccess = FALSE;
- }else{
- fputs ($fp, $header . "X");
- $sXML="";
- while (!feof($fp))
- $sXML .= fgets ($fp, 1024);
- }
- }
- if($ccsuccess){
- // print str_replace("<","<br /><",$sXML) . "<br />\n";
- $xmlDoc = new vrXMLDoc($sXML);
- $nodeList = $xmlDoc->nodeList->childNodes[0];
- for($j = 0; $j < $nodeList->length; $j++){
- if($nodeList->nodeName[$j]=="currError"){
- print $nodeList->nodeValue[$j];
- $ccsuccess = false;
- }elseif($nodeList->nodeName[$j]=="selectedCurrency"){
- $e = $nodeList->childNodes[$j];
- $currRate = 0;
- for($i = 0; $i < $e->length; $i++){
- if($e->nodeName[$i]=="currSymbol")
- $currSymbol = $e->nodeValue[$i];
- elseif($e->nodeName[$i]=="currRate")
- $currRate = $e->nodeValue[$i];
- }
- if($currSymbol1 == $currSymbol){
- $currRate1 = $currRate;
- mysql_query("UPDATE admin SET currRate1=" . $currRate . " WHERE adminID=1") or print(mysql_error());
- }
- if($currSymbol2 == $currSymbol){
- $currRate2 = $currRate;
- mysql_query("UPDATE admin SET currRate2=" . $currRate . " WHERE adminID=1") or print(mysql_error());
- }
- if($currSymbol3 == $currSymbol){
- $currRate3 = $currRate;
- mysql_query("UPDATE admin SET currRate3=" . $currRate . " WHERE adminID=1") or print(mysql_error());
- }
- }
- }
- if($ccsuccess) mysql_query("UPDATE admin SET currLastUpdate='" . date("Y-m-d H:i:s", time()) . "'");
- }
- }
- }
- function getsectionids($thesecid, $delsections){
- $secid = $thesecid;
- $iterations = 0;
- $iteratemore = TRUE;
- if(@$_SESSION["clientLoginLevel"] != "") $minloglevel=$_SESSION["clientLoginLevel"]; else $minloglevel=0;
- if($delsections) $nodel = ""; else $nodel = 'sectionDisabled<=' . $minloglevel . ' AND ';
- while($iteratemore && $iterations<10){
- $sSQL2 = "SELECT DISTINCT sectionID,rootSection FROM sections WHERE " . $nodel . "(topSection IN (" . $secid . ") OR (sectionID IN (" . $secid . ") AND rootSection=1))";
- $secid = "";
- $iteratemore = FALSE;
- $result2 = mysql_query($sSQL2) or print(mysql_error());
- $addcomma = "";
- while($rs2 = mysql_fetch_assoc($result2)){
- if($rs2["rootSection"]==0) $iteratemore = TRUE;
- $secid .= $addcomma . $rs2["sectionID"];
- $addcomma = ",";
- }
- $iterations++;
- }
- if($secid=="") $secid = "0";
- return($secid);
- }
- function getpayprovdetails($ppid,&$ppdata1,&$ppdata2,&$ppdata3,&$ppdemo,&$ppmethod){
- $sSQL = "SELECT payProvData1,payProvData2,payProvData3,payProvDemo,payProvMethod FROM payprovider WHERE payProvEnabled=1 AND payProvID='" . mysql_real_escape_string($ppid) . "'";
- $result = mysql_query($sSQL) or print(mysql_error());
- if($rs = mysql_fetch_assoc($result)){
- $ppdata1 = trim($rs['payProvData1']);
- $ppdata2 = trim($rs['payProvData2']);
- $ppdata3 = trim($rs['payProvData3']);
- $ppdemo = ((int)$rs['payProvDemo']==1);
- $ppmethod = (int)$rs['payProvMethod'];
- }else
- return(FALSE);
- return(TRUE);
- }
- function callcurlfunction($cfurl, $cfxml, &$cfres, &$cfcert, &$cferrmsg, $settimeouts){
- global $curlproxy,$pathtocurl;
- $cfsuccess=TRUE;
- //print str_replace("<","<br /><",str_replace("</","</",$cfxml)) . "<br />\n";
- if(@$pathtocurl != ""){
- exec($pathtocurl . ($cfcert != '' ? ' -E \'' . $cfcert . '\'' : '') . ' --data-binary \'' . str_replace("'","\'",$cfxml) . '\' ' . $cfurl, $cfres, $retvar);
- $cfres = implode("\n",$cfres);
- }else{
- if (!$ch = curl_init()) {
- $cferrmsg = "cURL package not installed in PHP. Set \$pathtocurl parameter.";
- $cfsuccess=FALSE;
- }else{
- curl_setopt($ch, CURLOPT_URL, $cfurl);
- if($cfcert != '') curl_setopt($ch, CURLOPT_SSLCERT, $cfcert);
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_HEADER, 0);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $cfxml);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- if($settimeouts) curl_setopt($ch, CURLOPT_TIMEOUT, 120);
- if(@$curlproxy!=''){
- curl_setopt($ch, CURLOPT_PROXY, $curlproxy);
- }
- $cfres = curl_exec($ch);
- //print str_replace("<","<br /><",str_replace("</","</",$cfres)) . "<br />\n";
- if(curl_error($ch) != ""){
- if($cfcert != '' && ! file_exists($cfcert)){
- $cferrmsg='Certificate file not found: ' . $cfcert . '<br />';
- }else
- $cferrmsg='cURL error: ' . curl_error($ch) . '<br />';
- $cfsuccess=FALSE;
- }else{
- curl_close($ch);
- }
- }
- }
- return($cfsuccess);
- }
- function writehiddenvar($hvname,$hvval){
- print '<input type="hidden" name="' . $hvname . '" id="' . $hvname . '" value="' . str_replace('"','"',$hvval) . '" />' . "\r\n";
- }
- function ppsoapheader($username, $password){
- return '<?xml version="1.0" encoding="utf-8"?>' .
- '<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">' .
- ' <soap:Header>' .
- ' <RequesterCredentials xmlns="urn:ebay:api:PayPalAPI">' .
- ' <Credentials xmlns="urn:ebay:apis:eBLBaseComponents">' .
- ' <Username>' . $username . '</Username>' .
- ' <ebl:Password xmlns:ebl="urn:ebay:apis:eBLBaseComponents">' . $password . '</ebl:Password>' .
- ' </Credentials>' .
- ' </RequesterCredentials>' .
- ' </soap:Header>';
- }
- if(@$enableclientlogin==TRUE){
- if(@$_SESSION["clientUser"] != ""){
- }elseif(@$_POST["checktmplogin"]=="1" && @$_POST["sessionid"] != ""){
- $sSQL = "SELECT tmploginname FROM tmplogin WHERE tmploginid='" . trim(@$_POST["sessionid"]) . "'";
- $result = mysql_query($sSQL) or print(mysql_error());
- if($rs = mysql_fetch_array($result)){
- $_SESSION["clientUser"]=$rs["tmploginname"];
- mysql_free_result($result);
- mysql_query("DELETE FROM tmplogin WHERE tmploginid='" . trim(@$_POST["sessionid"]) . "'") or print(mysql_error());
- $sSQL = "SELECT clientActions,clientLoginLevel,clientPercentDiscount FROM clientlogin WHERE clientUser='" . $_SESSION["clientUser"] . "'";
- $result = mysql_query($sSQL) or print(mysql_error());
- if($rs = mysql_fetch_array($result)){
- $_SESSION["clientActions"]=$rs["clientActions"];
- $_SESSION["clientLoginLevel"]=$rs["clientLoginLevel"];
- $_SESSION["clientPercentDiscount"]=(100.0-(double)$rs["clientPercentDiscount"])/100.0;
- }
- }
- mysql_free_result($result);
- }elseif(@$_COOKIE["WRITECLL"] != ""){
- $sSQL = "SELECT clientUser,clientActions,clientLoginLevel,clientPercentDiscount FROM clientlogin WHERE clientUser='" . trim($_COOKIE["WRITECLL"]) . "' AND clientPW='" . trim($_COOKIE["WRITECLP"]) . "'";
- $result = mysql_query($sSQL) or print(mysql_error());
- if($rs = mysql_fetch_array($result)){
- $_SESSION["clientUser"]=$rs["clientUser"];
- $_SESSION["clientActions"]=$rs["clientActions"];
- $_SESSION["clientLoginLevel"]=$rs["clientLoginLevel"];
- $_SESSION["clientPercentDiscount"]=(100.0-(double)$rs["clientPercentDiscount"])/100.0;
- }
- mysql_free_result($result);
- }
- if(@$requiredloginlevel != ""){
- if((int)$requiredloginlevel > @$_SESSION["clientLoginLevel"]){
- ob_end_clean();
- if(@$_SERVER["HTTPS"] == "on" || @$_SERVER["SERVER_PORT"] == "443")$prot='https://';else $prot='http://';
- header('Location: /admin/clientlogin.php?refurl=' . urlencode(@$_SERVER["PHP_SELF"] . (@$_SERVER["QUERY_STRING"] !="" ? "?" . @$_SERVER["QUERY_STRING"] : "")));
- exit();
- }
- }
- }
- function isPermitted($permission = 'all') {
- global $_SESSION;
- $mappings = array(
- 'accounting' => 'i_f_t',
- 'admin' => 'i_f_a',
- 'all' => 'all',
- 'customer service' => 'i_f_c',
- 'customer service admin' => 'i_f_ca', // deprecated
- 'hong kong' => 'i_f_h',
- 'inventory' => 'i_f_v',
- 'it' => 'i_f_i',
- 'management' => 'i_f_m',
- 'nadal' => 'i_f_n', // deprecated
- 'product' => 'i_f_p',
- 'quality control' => 'i_f_qc',
- 'reports_retail' => 'i_f_rr',
- 'sales' => 'i_f_sa',
- 'shieldzone' => 'i_f_z', // deprecated
- 'shipping' => 'i_f_s',
- );
- $permission = strtolower($permission);
- if (isset($mappings[$permission])) {
- $permission = $mappings[$permission];
- }
- if (isset($_SESSION['employee']['permissions'])) {
- $roles = preg_split('/,+/', $_SESSION['employee']['permissions']);
- $length = count($roles);
- for ($i = 0; $i < $length; $i++) {
- $roles[$i] = trim($roles[$i]);
- if (!empty($roles[$i]) && ($roles[$i] == $permission)) {
- return TRUE;
- }
- }
- }
- return FALSE;
- }
- function showarray($array)
- {
- echo '<ul>';
- foreach($array as $k=>$v)
- {
- if(is_array($v))
- {
- echo '<li>K:'.$k.'</li>';
- showarray($v);
- }
- else
- {
- echo '<li>'.$k.'='.$v.'</li>';
- }
- }
- echo '</ul>';
- }
- // END ADDED
- // ADDED by Chad (Mar30,06) set new location
- // + location = INT
- // + ordID = INT
- function setNewLocation($location,$ordID,$type='Automatic',$reason='') {
- global $_SESSION;
-
- if(empty($ordID)) {
- return false;
- }
-
- $qry = "SELECT statPrivate FROM orderstatus WHERE statID = $location";
- if(!$res = mysql_query($qry)) {
- echo '1';
- return false;
- }
- if(!$row = mysql_fetch_assoc($res)) {
- echo '2';
- return false;
- }
- $locName = $row['statPrivate'];
- mysql_free_result($res);
-
- $qry = "INSERT INTO location ( ordID , employeeID , stamp , statNum , location , locType , locTypeReason )
- VALUES ( $ordID , '".$_SESSION["employee"]["id"]."' , '".date("Y-m-d H:i:s")."' , '".$location."' ,
- '$locName' , '$type' , '$reason' )";
- if(!$res = mysql_query($qry)) {
- echo '3-'.mysql_error().'<br />'.$qry;
- return false;
- }
-
- return true;
- }
- // END ADDED
- // ADDED by Chad (Apr10,06) check for additional notes
- function isAddInfo($ordID) {
- $qry = "SELECT ordAddInfo FROM orders WHERE ordID = '$ordID'";
- $res = mysql_query($qry) or print(mysql_error());
- if(mysql_num_rows($res) > 0) {
- $row = mysql_fetch_assoc($res);
- }
- if(!empty($row['ordAddInfo'])) {
- return true;
- }
-
- return false;
- }
- // END ADDED
- // ADDED by Shane (may24,06) for "how get" wholesale pricing
- function getPricingStructure($id=1) {
- $query = 'select * from pricing_struct where id="'.$id.'"';
- $result = mysql_query($query);
- $rv = mysql_fetch_assoc($result);
- $query = 'select * from pricing_tier where pricing_struct_id="'.$id.'" order by quantity_start';
- $result = mysql_query($query);
- for($i=0;$row=mysql_fetch_assoc($result);$i++)
- $rv[tiers][$i] = $row;
- return $rv;
- }
- // END ADDED
- // ADDED by Chad (July 3,06)
- function getCustPricingStructures($custID,$current_struct='') {
- //$qry = "SELECT * FROM pricing_cust WHERE customer_id = " . $custID;
- $next_month=date('Y-m-d',mktime(0,0,0,date('m')+1,1,date('Y')));
- $qry = "SELECT pc.id as pcid,pc.*,ps.*
- FROM pricing_cust pc, pricing_struct ps
- WHERE pc.pricing_struct_id = ps.id
- AND customer_id =$custID";
- if($current_struct) $qry.=" AND date_start<'$next_month'";
- else $qry.=" AND date_start>='$next_month'";
- $qry.=" ORDER BY ps.pricing_group, pc.date_start";
- if($current_struct) $qry.=" DESC";
- $res = mysql_query($qry) or print(mysql_error());
- $aPrc = array();
- $i=0;
- $pricing_group='';
- while($row = mysql_fetch_assoc($res)) {
- if($row['pricing_group']!=$pricing_group){
- $aStructure = getPricingStructure($row['pricing_struct_id']);
- $aPrc[$i]=$aStructure;
- $aPrc[$i]['date_start']=$row['date_start'];
- $aPrc[$i]['custID']=$row['customer_id'];
- $aPrc[$i]['psID']=$row['pcid'];
- $aPrc[$i]['pricing_struct_id']=$row['pricing_struct_id'];
- if($current_struct) $pricing_group=$row['pricing_group'];
- $i++;
- }
- }
- return $aPrc;
- }
- // END ADDED
- // ADDED by Shane (may24,06) for "how get" wholesale pricing
- function getPricin…
Large files files are truncated, but you can click here to view the full file