<%@ LANGUAGE="VBSCRIPT" %> <% PageStrings = "359, 401, 402, 532, 549, 550, 551, 579, 580, 581, 582, 583, 584, 585, 586, 587, 588, 864, 1235" strThisBackPage = "products" %> <% '=============================================== ' CactuShop ASP Shopping Cart ' ©1999-2004 Cactusoft Ltd. www.cactusoft.com '=============================================== ' All rights reserved. ' Use of this code is covered by the terms and ' conditions in the license agreement. No ' unauthorized duplication or distribution is ' permitted. Cactusoft's copyright notices must ' remain in the ASP sections of the code. '=============================================== '----------------------------------------------- 'IMPORTANT NOTE: This page handles forms 'differently. The form is multipart encoded to 'allow file upload. Therefore we need to use the 'Upload Object. This requires VBScript5 support 'on server (get from Microsoft or Install IE5 on 'the server). '----------------------------------------------- '----------------------------------------------- 'UPDATE VERSION 'This page updates the version of a product with 'the details specified in the modify_verson.asp 'form. '----------------------------------------------- '----------------------------------------------- 'FUNCTION: CHECK IF VERSION CODE IS ALREADY IN 'USE '----------------------------------------------- Function CheckVersionCode(numVersionCode, numVersion) strQuery = "SELECT V_ID FROM tblCactuShopVersions WHERE V_CodeNumber = '" & sqlsafe(numVersionCode) & "' AND NOT V_ID = " & numVersion Call ExecuteSQL(strQuery, numCursorType, objRecordSet) If objRecordSet.RecordCount < 1 Then CheckVersionCode = "OK" Else CheckVersionCode = objRecordSet(0) End If objRecordSet.Close End Function Dim Uploader, File Set Uploader = New FileUploader Uploader.Upload() '----------------------------------------------- 'COLLECT VALUES FROM FORM '----------------------------------------------- PT_ID = Uploader.Form("PT_ID") strCallMode = Uploader.Form("strCallMode") V_DeleteImage = Uploader.Form("V_DeleteImage") V_DeleteImage_Large = Uploader.Form("V_DeleteImage_Large") V_DeleteFile = Uploader.Form("V_DeleteFile") V_ID = Uploader.Form("V_ID") V_Live = Uploader.Form("V_Live") V_CodeNumber = Uploader.Form("V_CodeNumber") V_Price = Uploader.Form("V_Price") V_RRP = Uploader.Form("V_RRP") V_Tax = Uploader.Form("V_Tax") V_Weight = Uploader.Form("V_Weight") V_DownLoadInfo = Uploader.Form("V_DownLoadInfo") V_OrderByValue = Uploader.Form("V_OrderByValue") V_FreeShipping = Uploader.Form("V_FreeShipping") If Not IsNumeric(V_OrderByValue) then V_OrderByValue = 0 strDownloadExtension = Uploader.Form("strDownloadExtension") strRandomFileName = Uploader.Form("strRandomFileName") if V_Weight = "" then V_Weight=0 V_DeliveryTime = Uploader.Form("V_DeliveryTime") if V_DeliveryTime = "" then V_DeliveryTime=0 V_Quantity = Uploader.Form("V_Quantity") if V_Quantity = "" then V_Quantity=0 V_QuantityWarnLevel = Uploader.Form("V_QuantityWarnLevel") if V_QuantityWarnLevel = "" then V_QuantityWarnLevel= 0 V_Product = Uploader.Form("V_Product") Dim V_Name(), V_Desc() Redim V_Name(numTotalLanguages) Redim V_Desc(numTotalLanguages) For numCounter = 1 to numTotalLanguages V_Name(numCounter) = Uploader.Form("V_Name" & CStr(numCounter)) V_Desc(numCounter) = Uploader.Form("V_Desc" & CStr(numCounter)) next If strCallMode = "Delete" Then 'User wants to delete this Version Set objFileSystem = Server.CreateObject("Scripting.FileSystemObject") DeleteVersion V_ID, objFileSystem, Server.MapPath("default.asp"), Split(Application(LICENSENUMBER & "allowedimages"), ",") Set objFileSystem = Nothing strErrorText = "" Else '------------------------------------------- 'CHECK FILE UPLOAD METHOD '------------------------------------------- 'If a file was selected in the upload box If Uploader.Files.Exists("V_DownloadInfoUpload") Then 'Get the upload name strFileUploadName = Uploader.Files("V_DownloadInfoUpload").FileName 'If the name isn't blank, then get ready to upload the file If Not strFileUploadName = "" Then aryFileUploadName = Split(strFileUploadName, ".") strFileType = LCase(aryFileUploadName(Ubound(aryFileUploadName))) strRandomFileName = GetRandomString(8) strUploadFileType = strFileType V_DownloadInfo = strFileType & "|" & strRandomFileName V_DownloadType = "u" 'Otherwise, scrap all uploading plans Else V_DownloadType = "n" V_DownloadInfo = "" End If 'No file was selected for upload. Else 'If a file was previously uploaded If strDownloadExtension <> "" then 'If it was decided to delete it If V_DeleteFile = "y" then 'Change to link mode V_DownloadType = "l" 'We're not deleting the file. Else 'Decide whether to go link mode or 'stick with uploading If V_DownloadInfo <> "" then V_DownloadType = "l" Else V_DownloadType = "u" V_DownloadInfo = strDownloadExtension & "|" & strRandomFileName End If End If 'No file was previously uploaded Else 'Go to link mode V_DownloadType = "l" end if End If 'If we're in linking mode but no link was entered, 'go to 'nothing' mode If V_DownloadType = "l" and V_DownloadInfo = "" then V_DownloadType = "n" end if 'If we're currently got an 'n' for downloadtype, check 'to see if the freeshipping is checked. If it is, then 'set downloadtype to f If V_DownloadType = "n" and V_FreeShipping = "y" then V_DownloadType = "f" 'Check images for acceptable file types If Uploader.Files.Exists("V_Image") Then strFileUploadName = Uploader.Files("V_Image").FileName If Not strFileUploadName = "" Then aryFileUploadName = Split(strFileUploadName, ".") strFileType = LCase(aryFileUploadName(Ubound(aryFileUploadName))) End If If InStr("," & Application(LICENSENUMBER & "allowedimages") & ",", "," & strFileType & ",") < 1 Then numErrorNo = numErrorNo + 1 strErrorText = strErrorText + "" + CStr(numErrorNo) + ". " + GetString("ContentText_ErrorChkUploadFileType") & replace(Application(LICENSENUMBER & "allowedimages"),",",", ") & ".
" End If End If If Uploader.Files.Exists("V_Image_Large") Then strFileUploadName = Uploader.Files("V_Image_Large").FileName If Not strFileUploadName = "" Then aryFileUploadName = Split(strFileUploadName, ".") strFileType_Large = LCase(aryFileUploadName(Ubound(aryFileUploadName))) End If If InStr("," & Application(LICENSENUMBER & "allowedimages") & ",", "," & strFileType_Large & ",") < 1 Then numErrorNo = numErrorNo + 1 strErrorText = strErrorText + "" + CStr(numErrorNo) + ". " + GetString("ContentText_ErrorChkUploadFileType") & replace(Application(LICENSENUMBER & "allowedimages"),",",", ") & ".
" End If End If '------------------------------------------- 'PERFORM REST OF ERROR CHECKING '------------------------------------------- strDownloadExtension = strDownloadExtension Dim aryDownloadExtension(0) aryDownloadExtension(0) = strDownloadExtension AllNamesBlank = true For numCounter = 1 to numTotalLanguages 'If it's live on the front, then it can't be blank If aryLangLiveFront(numCounter) = "y" then AllNamesBlank = AllNamesBlank and V_Name(numCounter) = "" end if 'check them all for length strErrorText = ErrorcheckLength(strErrorText, numErrorNo, GetString("FormLabel_VersionName") & " " & cstr(numCounter), V_Name(numCounter), Application(LICENSENUMBER & "V_Name_AL")) strErrorText = ErrorcheckLength(strErrorText, numErrorNo, GetString("FormLabel_Description") & " " & cstr(numCounter), V_Desc(numCounter), Application(LICENSENUMBER & "V_Desc_AL")) next If AllNamesBlank then strErrorText = CheckNotBlank(strErrorText, numErrorNo, GetString("FormLabel_VersionName"), "") strErrorText = CheckNotBlank(strErrorText, numErrorNo, GetString("FormLabel_CodeNumer"), V_CodeNumber) strErrorText = CheckNotBlank(strErrorText, numErrorNo, GetString("FormLabel_Product"), V_Product) strErrorText = CheckNotBlank(strErrorText, numErrorNo, GetString("FormLabel_Price"), V_Price) strErrorText = ErrorcheckLength(strErrorText, numErrorNo, GetString("FormLabel_CodeNumer"), V_CodeNumber, Application(LICENSENUMBER & "V_CodeNumber_AL")) strErrorText = ErrorcheckLength(strErrorText, numErrorNo, GetString("FormLabel_DownLoadURL"), V_DownloadURL, Application(LICENSENUMBER & "V_DownloadURL_AL")) If Not IsNumeric(V_Price) Then numErrorNo = numErrorNo + 1 strErrorText = strErrorText + "" + Cstr(numErrorNo) + ". " + GetString("ContentText_ErrorChkPriceIsNumeric") & "
" End if IF V_RRP = "" then V_RRP = 0 If Not IsNumeric(V_RRP) Then numErrorNo = numErrorNo + 1 strErrorText = strErrorText + "" + Cstr(numErrorNo) + ". " + GetString("ContentText_ErrorChkRRPIsNumeric") & "
" End if If Not IsNumeric(V_Weight) Then numErrorNo = numErrorNo + 1 strErrorText = strErrorText + "" + Cstr(numErrorNo) + ". " + GetString("ContentText_ErrorChkWeightIsNumeric") & "
" End if If Not IsNumeric(V_DeliveryTime) Then numErrorNo = numErrorNo + 1 strErrorText = strErrorText + "" + Cstr(numErrorNo) + ". " + GetString("ContentText_ErrorChkDeliveryTimeIsNumeric") & "
" End if If Not IsNumeric(V_Quantity) Then numErrorNo = numErrorNo + 1 strErrorText = strErrorText + "" + Cstr(numErrorNo) + ". " + GetString("ContentText_ErrorChkQuantityIsNumeric") & "
" End if If Not IsNumeric(V_QuantityWarnLevel) Then numErrorNo = numErrorNo + 1 strErrorText = strErrorText + "" + Cstr(numErrorNo) + ". " + GetString("ContentText_ErrorChkQuantityWarnLevelIsNumeric") & "
" End if strVersionCode = CheckVersionCode(V_CodeNumber, V_ID) If Not strVersionCode = "OK" Then numErrorNo = numErrorNo + 1 strErrorText = strErrorText + "" + Cstr(numErrorNo) + ". " + GetString("ContentText_ErrorChkVIDCodeNumer") & " (" & V_CodeNumber & ") " & GetString("ContentText_ErrorChkVIDAlreadyInUse") & " " & strVersionCode & ".

" & GetString("ContentText_ErrorChkVIDViewThatVersion") & "
" End if 'Error Checking Complete If strErrorText = "" Then 'No problem with doing the database stuff '----------------------------------------------- 'NEW VERSION 'If V_ID is zero then it is a new version, in 'this case we insert a new record into the DB '----------------------------------------------- If V_ID = 0 Then strQuery = "INSERT INTO tblCactuShopVersions (" For numCounter = 1 to numTotalLanguages If aryLangLiveBack(numCounter) = "y" then strQuery = strQuery & "V_Name" & CStr(numCounter) & ", V_Desc" & CStr(numCounter) & ", " next strQuery = strQuery & "V_CodeNumber, V_Price, V_Tax, V_Weight, V_Quantity, V_QuantityWarnLevel, V_DeliveryTime, V_DownloadInfo, V_DownloadType, V_Product, V_Live, V_OrderByValue, V_RRP) VALUES(" For numCounter = 1 to numTotalLanguages If aryLangLiveBack(numCounter) = "y" then strQuery = strQuery & "'" & sqlsafe(V_Name(numCounter)) & "', '" & sqlsafe(V_Desc(numCounter)) & "', " next strQuery = strQuery & "'" &_ sqlsafe(V_CodeNumber) & "'," &_ V_Price & "," &_ V_Tax & ", " &_ V_Weight & "," &_ V_Quantity & "," &_ V_QuantityWarnLevel & "," &_ V_DeliveryTime & ",'" &_ sqlsafe(V_DownloadInfo) & "','" &_ sqlsafe(V_DownloadType) & "'," &_ V_Product & ",'" &_ V_Live & "'," &_ V_OrderByValue & "," &_ V_RRP & ")" Call ExecuteSQL(strQuery, numCursorType, objRecordSet) '-------------------------------------------------- 'FIND ID OF NEW VERSION '-------------------------------------------------- V_ID = objDataConn.Execute("SELECT V_ID FROM tblCactuShopVersions WHERE V_CodeNumber = '" & SQLSafe(V_CodeNumber) & "'")("V_ID") '----------------------------------------------- 'UPDATE VERSION 'Otherwise, update the version. '----------------------------------------------- Else strQuery="UPDATE tblCactuShopVersions SET " for numCounter = 1 to numTotalLanguages If arylangliveback(numCounter) = "y" then strQuery = strQuery & "V_Name" & CStr(numCounter) & "='" & sqlsafe(V_Name(numCounter)) & "',V_Desc" & CStr(numCounter) & "='" & sqlsafe(V_Desc(numCounter)) & "'," next strQuery = strQuery &_ "V_CodeNumber='" & sqlsafe(V_CodeNumber) & "'," &_ "V_Price=" & V_Price & "," &_ "V_Tax=" & V_Tax & "," &_ "V_Weight=" & V_Weight & "," &_ "V_DeliveryTime=" & V_DeliveryTime & "," &_ "V_Quantity=" & V_Quantity & "," &_ "V_QuantityWarnLevel=" & V_QuantityWarnLevel & "," &_ "V_DownLoadInfo='" & sqlsafe(V_DownLoadInfo) & "'," &_ "V_DownLoadType='" & sqlsafe(V_DownLoadType) & "'," &_ "V_Live='" & V_Live & "'," &_ "V_Product=" & V_Product & ", " &_ "V_OrderByValue=" & V_OrderByValue & ", " &_ "V_RRP=" & V_RRP & " WHERE V_ID=" & V_ID Call ExecuteSQL(strQuery, numCursorType, objRecordSet) End If 'Do the image management, if needed 'Use Version ID + File Extension for name to avoid overwriting pre-existing images. Set objFileSystem = Server.CreateObject("Scripting.FileSystemObject") If V_DeleteImage = "y" Or Uploader.Files.Exists("V_Image") Then DeleteFile Server.MapPath(Application(LICENSENUMBER & "uploadsfolder") & "images_versions/" & V_ID), Split(Application(LICENSENUMBER & "allowedimages"), ","), objFileSystem If V_DeleteImage_Large = "y" Or Uploader.Files.Exists("V_Image_Large") Then DeleteFile Server.MapPath(Application(LICENSENUMBER & "uploadsfolder") & "images_versions_large/" & V_ID), Split(Application(LICENSENUMBER & "allowedimages"), ","), objFileSystem If V_DeleteFile = "y" Or V_DownloadType <> "u" Or Uploader.Files.Exists("V_DownloadInfoUpload") Then DeleteFile Server.MapPath(Application(LICENSENUMBER & "uploadsfolder") & "files_versions/" & V_ID & "_" & strRandomFileName), aryDownloadExtension, objFileSystem Set objFileSystem = Nothing If Uploader.Files.Exists("V_DownloadInfoUpload") Then Uploader.Files("V_DownloadInfoUpload").FileName = V_ID & "_" & strRandomFileName & "." & strUploadFileType Uploader.Files("V_DownloadInfoUpload").SaveToDisk Server.MapPath(Application(LICENSENUMBER & "uploadsfolder") & "files_versions/") End If If Uploader.Files.Exists("V_Image") Then Uploader.Files("V_Image").FileName = V_ID & "." & strFileType Uploader.Files("V_Image").SaveToDisk Server.MapPath(Application(LICENSENUMBER & "uploadsfolder") & "images_versions/") End If If Uploader.Files.Exists("V_Image_Large") Then Uploader.Files("V_Image_Large").FileName = V_ID & "." & strFileType_Large Uploader.Files("V_Image_Large").SaveToDisk Server.MapPath(Application(LICENSENUMBER & "uploadsfolder") & "images_versions_large/") End If End If End If '----------------------------------------------- 'DECIDE WHERE TO FORWARD TO 'If this script was called from an existing 'version then forward back to that prodtype page 'otherwise go back to the back end home page. '----------------------------------------------- If strErrorText = "" Then If Not PT_ID = "" Then Response.Redirect("_prodtype_back.asp?PT_ID=" & PT_ID) Else Response.Redirect("_default.asp") Else 'Errors Occurred. Tell the user. %> <% =GetString("Config_headtitle") %>
<% WriteString("PageTitle_Problems") %>
<% WriteString("ContentText_PleaseGoBackAndCorrect") %>
<% =strErrorText %>


<< <% WriteString("ContentText_BackLink") %>
<% End If %>