File: D:/web/homefly/inc/incfunctions.asp
<%
'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
Dim gasaReferer,gasaThisSite,datedelim
if Trim(request.querystring("PARTNER"))<>"" then
if expireaffiliate = "" then expireaffiliate=30
response.write "<script src='vsadmin/savecookie.asp?PARTNER="&Trim(request.querystring("PARTNER"))&"&EXPIRES="&expireaffiliate&"'></script>"
end if
if sqlserver=true then
datedelim = "'"
else
datedelim = "#"
end if
codestr="2952710692840328509902143349209039553396765"
function upsencode(thestr)
newstr=""
for index=1 to Len(thestr)
thechar = Mid(thestr,index,1)
newstr=newstr & Chr(asc(thechar)+Int(Mid(codestr,index,1)))
next
upsencode=newstr
end function
function upsdecode(thestr)
if IsNull(thestr) then
upsdecode=""
else
newstr=""
for index=1 to Len(thestr)
thechar = Mid(thestr,index,1)
newstr=newstr & Chr(asc(thechar)-Int(Mid(codestr,index,1)))
next
upsdecode=newstr
end if
end function
function VSUSDate(thedate)
VSUSDate = DatePart("m",thedate) & "/" & DatePart("d",thedate) & "/" & DatePart("yyyy",thedate)
end function
function FormatEuroCurrency(amount)
if overridecurrency=true then
if orcpreamount=true then
FormatEuroCurrency = orcsymbol & FormatNumber(amount,orcdecplaces)
else
FormatEuroCurrency = FormatNumber(amount,orcdecplaces) & orcsymbol
end if
else
if useEuro then
FormatEuroCurrency = FormatNumber(amount,2) & " €"
else
FormatEuroCurrency = FormatCurrency(amount,-1,-2,0,-2)
end if
end if
end function
function FormatEmailEuroCurrency(amount)
if overridecurrency=true then
if orcpreamount=true then
FormatEmailEuroCurrency = orcemailsymbol & FormatNumber(amount,orcdecplaces)
else
FormatEmailEuroCurrency = FormatNumber(amount,orcdecplaces) & orcemailsymbol
end if
else
if useEuro then
FormatEmailEuroCurrency = FormatNumber(amount,2) & " Euro"
else
FormatEmailEuroCurrency = FormatCurrency(amount,-1,-2,0,-2)
end if
end if
end function
Sub do_stock_management(smOrdId)
if stockManage <> 0 then
sSQL="SELECT cartProdID, cartQuantity FROM cart WHERE cartCompleted=0 AND cartOrderID=" & smOrdId
rs.Open sSQL,cnn,0,1
do while NOT rs.EOF
sSQL = "UPDATE products SET pInStock=pInStock-"&rs("cartQuantity")&" WHERE pID='"&rs("cartProdID")&"'"
cnn.Execute(sSQL)
rs.MoveNext
loop
rs.Close
end if
End Sub
Sub productdisplayscript(doaddprodoptions) %>
<script Language="JavaScript">
<!--
var aPC = new Array();
var aPI = new Array();
var isW3 = (document.getElementById&&true);
var tax=<%=countryTax %>;
<%
if doaddprodoptions then
Session.LCID = 1033
sSQL = "SELECT optID,optPriceDiff FROM options ORDER BY optID"
rs2.Open sSQL,cnn,0,1
if NOT rs2.EOF then prodoptions=rs2.getrows
rs2.Close
if IsArray(prodoptions) then
for rowcounter=0 to UBOUND(prodoptions,2)
response.write "aPC["&rowcounter&"]="&prodoptions(1,rowcounter)&";"
response.write "aPI["&rowcounter&"]="&prodoptions(0,rowcounter)&";"&vbCrLf
next
end if
Session.LCID = saveLCID
end if
%>
function pricechecker(i){
for(var index=0;index<aPC.length;index++){
if(aPI[index]==i)
return(aPC[index]);
}
return(0);
}
function enterValue(theObj){
alert('<%=xxPrdEnt%>');
theObj.focus();
return(false);
}
function chooseOption(theObj){
alert('<%=xxPrdChs%>');
theObj.focus();
return(false);
}
function dataLimit(theObj){
alert('<%=xxPrd255%>');
theObj.focus();
return(false);
}
function formatprice(i, currcode){
<% tempStr = FormatEuroCurrency(0)
tempStr2 = FormatNumber(0,2)
response.write "var pTemplate='" & tempStr & "';" & vbCrLf
response.write "if(currcode!='') pTemplate=' " & tempStr2 & "' + (currcode!=' '?'<b>'+currcode+'</b>':'');" & vbCrLf
if InStr(tempStr,",")<>0 OR InStr(tempStr,".")<>0 then %>
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();
<% end if
response.write "pTemplate = pTemplate.toString().replace(/\d[,.]*\d*/,i.toString());"
if InStr(tempStr,",")<>0 then
response.write "return(pTemplate.replace(/\./,','));"
else
response.write "return(pTemplate);"
end if
%>
}
//-->
</script><%
End Sub
Sub updatepricescript(doaddprodoptions) %>
<script Language="JavaScript">
<!--
function formvalidator<%=Count%>(theForm)
{
<%
prodoptions=""
if doaddprodoptions then
sSQL = "SELECT poOptionGroup,optType FROM prodOptions INNER JOIN optionGroup ON optionGroup.optGrpID=prodOptions.poOptionGroup WHERE poProdID='"&rs("pID")&"' ORDER BY poID"
rs2.Open sSQL,cnn,0,1
if NOT rs2.EOF then prodoptions=rs2.getrows
rs2.Close
if IsArray(prodoptions) then
for rowcounter=0 to UBOUND(prodoptions,2)
if Int(prodoptions(1,rowcounter))=3 then
response.write "if(theForm.voptn"&rowcounter&".value=='')return(enterValue(theForm.voptn"&rowcounter&"));"&vbCrLf
response.write "if(theForm.voptn"&rowcounter&".value.length>255)return(dataLimit(theForm.voptn"&rowcounter&"));"&vbCrLf
elseif Int(prodoptions(1,rowcounter))=2 then
response.write "if(theForm.optn"&rowcounter&".selectedIndex==0)return(chooseOption(theForm.optn"&rowcounter&"));"&vbCrLf
end if
next
end if
end if
%>
return (true);
}
function updateprice<%=Count%>(){
<% if noprice<>true AND NOT (rs("pPrice")=0 AND pricezeromessage<>"") then %>
var totAdd=<%
saveLCID = Session.LCID
Session.LCID = 1033
response.write rs("pPrice")
Session.LCID = saveLCID
%>;
if(!isW3) return;
var pDiv = document.getElementById('pricediv<%=Count%>');
<%
if IsArray(prodoptions) then
for rowcounter=0 to UBOUND(prodoptions,2)
if Abs(Int(prodoptions(1,rowcounter)))<>3 then response.write "totAdd=totAdd+pricechecker(document.forms.tForm"&Count&".optn"&rowcounter&".options[document.forms.tForm"&Count&".optn"&rowcounter&".selectedIndex].value);"&vbCrLf
next
end if
response.write "pDiv.innerHTML=formatprice(Math.round(totAdd*100.0)/100.0, '');"
if showtaxinclusive=true then response.write "document.getElementById('pricedivti" & Count & "').innerHTML=formatprice(Math.round((totAdd+(totAdd*tax/100.0))*100.0)/100.0, '');" & vbCrLf
if currRate1<>0 AND currSymbol1<>"" then response.write "document.getElementById('pricediv1c" & Count & "').innerHTML=formatprice(Math.round((totAdd*"&currRate1&")*100.0)/100.0, ' " & currSymbol1 & "');" & vbCrLf
if currRate2<>0 AND currSymbol2<>"" then response.write "document.getElementById('pricediv2c" & Count & "').innerHTML=formatprice(Math.round((totAdd*"&currRate2&")*100.0)/100.0, ' " & currSymbol2 & "');" & vbCrLf
if currRate3<>0 AND currSymbol3<>"" then response.write "document.getElementById('pricediv3c" & Count & "').innerHTML=formatprice(Math.round((totAdd*"&currRate3&")*100.0)/100.0, ' " & currSymbol3 & "');" & vbCrLf
end if
%>
}
function openEFWindow(id) {
popupWin = window.open('emailfriend.asp?id='+id,'email_friend','menubar=no, scrollbars=no, width=400, height=400, directories=no,location=no,resizable=yes,status=no,toolbar=no')
}
//-->
</script><%
End Sub
function checkDPs(currcode)
if currcode="JPY" then checkDPs=0 else checkDPs=2
end function
Sub checkCurrencyRates(currConvUser,currConvPw,currLastUpdate,byRef currRate1,currSymbol1,byRef currRate2,currSymbol2,byRef currRate3,currSymbol3)
ccsuccess = true
if currConvUser<>"" AND currConvPw<>"" AND currLastUpdate < Now()-1 then
str = ""
if currSymbol1<>"" then str = str & "&curr=" & currSymbol1
if currSymbol2<>"" then str = str & "&curr=" & currSymbol2
if currSymbol3<>"" then str = str & "&curr=" & currSymbol3
if str="" then
cnn.Execute("UPDATE admin SET currLastUpdate="&datedelim&Now()&datedelim)
exit sub
end if
str = "?source=" & countryCurrency & "&user=" & currConvUser & "&pw=" & currConvPw & str
set objHttp = Server.CreateObject("Msxml2.ServerXMLHTTP")
objHttp.open "POST", "http://www.ecommercetemplates.com/currencyxml.asp" & str, false
objHttp.Send "X"
if (objHttp.status <> 200 ) then
' HTTP error handling
else
Set xmlDoc = objHttp.responseXML
Set t2 = xmlDoc.getElementsByTagName("currencyRates").Item(0)
for j = 0 to t2.childNodes.length - 1
Set n = t2.childNodes.Item(j)
if n.nodename="currError" then
response.write n.firstChild.nodeValue
ccsuccess = false
elseif n.nodename="selectedCurrency" then
currRate = 0
for i = 0 To n.childNodes.length - 1
Set e = n.childNodes.Item(i)
if e.nodeName="currSymbol" then
currSymbol = e.firstChild.nodeValue
elseif e.nodeName="currRate" then
currRate = e.firstChild.nodeValue
end if
next
if currSymbol1 = currSymbol then
currRate1 = currRate
cnn.Execute("UPDATE admin SET currRate1="&currRate&" WHERE adminID=1")
end if
if currSymbol2 = currSymbol then
currRate2 = currRate
cnn.Execute("UPDATE admin SET currRate2="&currRate&" WHERE adminID=1")
end if
if currSymbol3 = currSymbol then
currRate3 = currRate
cnn.Execute("UPDATE admin SET currRate3="&currRate&" WHERE adminID=1")
end if
end if
next
if ccsuccess then cnn.Execute("UPDATE admin SET currLastUpdate="&datedelim&VSUSDate(Now())&datedelim)
end if
end if
End Sub
%>