%
option explicit
Response.Buffer = true
if session("company_id") <> "" then
dim conn
dim rs
dim ssql
dim objUpload
dim sCompany_Name
dim sCompany_Register_Number
dim sCompany_Address
dim sCompany_Phone
dim sCompany_Fax
dim sCompany_Email
dim sCompany_Password
dim sCompany_Currency_Format
dim sCompany_Details
dim sOld_Company_Logo
dim sNew_Company_Logo
dim sOld_Company_Image
dim sNew_Company_Image
dim FileControler
dim myfile
dim fsize
dim return_page
dim item
dim value
dim file
%>
<%
set FileControler = server.CreateObject("Scripting.FileSystemObject")
Set objUpload = Server.CreateObject("aspSmartUpload.SmartUpload")
objUpload.Upload
'For each file In objUpload.Files
'sNew_Company_Logo = file.FileName
'Next
sNew_Company_Logo = objUpload.Files.Item(1).FileName
sNew_Company_Image = objUpload.Files.Item(2).FileName
'Select each item in form
'************************
For each item In objUpload.Form
'Select each value of the current item
'*************************************
For each value In objUpload.Form(item)
'get information
if item = "company_name" then
sCompany_Name = value
end if
if item = "company_register_number" then
sCompany_Register_Number = value
end if
if item = "company_address" then
sCompany_Address = value
end if
if item = "company_phone" then
sCompany_Phone = value
end if
if item = "company_fax" then
sCompany_Fax = value
end if
if item = "company_email" then
sCompany_Email = value
end if
if item = "company_password" then
sCompany_Password = value
end if
if item = "company_currency_format" then
sCompany_Currency_Format = value
end if
if item = "company_details" then
sCompany_Details = value
end if
if item = "old_company_logo" then
sOld_Company_Logo = value
end if
if item = "old_company_image" then
sOld_Company_Image = value
end if
Next
Next
If Len(sNew_Company_Logo) > 0 Then
sNew_Company_Logo = lcase(sNew_Company_Logo)
objUpload.Save server.MapPath("../../../../../member/" & Request.Cookies("storename") & "/images/")
set myfile = FileControler.GetFile(server.MapPath("../../../../../member/" & Request.Cookies("storename") & "/images/") & "/" & sNew_Company_Logo)
fsize = myfile.size
else
fsize = 1
End If
if fsize >= session("company_logo_file_size") then
FileControler.DeleteFile server.MapPath("../../../../../member/" & Request.Cookies("storename") & "/images/") & "/" & sNew_Company_Logo
Response.Write "
"
Response.Write "Sorry, images size are limited at " & session("display_company_logo_file_size")
Response.Write "
click here to modify..."
else
If Len(sNew_Company_Image) > 0 Then
sNew_Company_Image = lcase(sNew_Company_Image)
objUpload.Save server.MapPath("../../../../../member/" & Request.Cookies("storename") & "/images/")
set myfile = FileControler.GetFile(server.MapPath("../../../../../member/" & Request.Cookies("storename") & "/images/") & "/" & sNew_Company_Image)
fsize = myfile.size
else
fsize = 1
End If
if fsize >= session("company_image_file_size") then
FileControler.DeleteFile server.MapPath("../../../../../member/" & Request.Cookies("storename") & "/images/") & "/" & sNew_Company_Image
Response.Write ""
Response.Write "Sorry, images size are limited at " & session("display_company_image_file_size")
Response.Write "
click here to modify..."
else
if sNew_Company_Logo = "" then
sNew_Company_Logo = sOld_Company_Logo
else
if sNew_Company_Logo <> sOld_Company_Logo then
if len(sOld_Company_Logo) > 0 then
if FileControler.FileExists(session("images_folder") & "/" & sOld_Company_Logo) = true then
FileControler.DeleteFile session("images_folder") & "/" & sOld_Company_Logo
end if
end if
end if
end if
if sNew_Company_Image = "" then
sNew_Company_Image = sOld_Company_Image
else
if sNew_Company_Image <> sOld_Company_Image then
if len(sOld_Company_Image) > 0 then
if FileControler.FileExists(session("images_folder") & "/" & sOld_Company_Image) = true then
FileControler.DeleteFile session("images_folder") & "/" & sOld_Company_Image
end if
end if
end if
end if
'replace vbCrLf to
if len(sCompany_Address) > 0 then
sCompany_Address = replace(sCompany_Address, vbcrlf, "
", 1, -1, 1)
end if
if len(sCompany_Details) > 0 then
sCompany_Details = replace(sCompany_Details, vbcrlf, "
", 1, -1, 1)
end if
'update data
ssql = "select * from tbl_company where company_id = '" & session("company_id") & "'"
set rs = server.CreateObject("adodb.recordset")
rs.Open ssql,conn,3,3
rs.Fields("company_name") = sCompany_Name
rs.Fields("company_register_number") = sCompany_Register_Number
rs.Fields("company_address") = sCompany_Address
rs.Fields("company_phone") = sCompany_Phone
rs.Fields("company_fax") = sCompany_Fax
rs.Fields("company_email") = sCompany_Email
rs.Fields("company_password") = lcase(sCompany_Password)
rs.Fields("company_currency_format") = sCompany_Currency_Format
rs.Fields("company_details") = sCompany_Details
rs.Fields("company_logo") = sNew_Company_Logo
rs.Fields("company_image") = sNew_Company_Image
rs.Update
rs.Close
conn.Close
set rs = nothing
set conn = nothing
session("company_currency_format") = sCompany_Currency_Format
session("company_email") = sCompany_Email
return_page = ""
Response.Write return_page
end if
end if
set FileControler = nothing
else
Response.Redirect "../../index.asp"
end if
%>