<%option explicit%> <% ShopCheckAdmin "shopa_editdisplay.asp" '******************************* ' Version 6.50 ' Display fields in one record of one table ' setting field to keyword "NULL" sets field to empty ' April 20, 2003 '******************************* dim Addaction,Updateaction, Deleteaction dim rstemp dim which dim idfield dim dbtable, conn dim tempid, template, templatename setsess "currenturl","shopa_edittempplate.asp" Addaction=Request.form("add") Updateaction=Request.form("update") Deleteaction=request("delete") GetInputValues If DeleteAction<>"" then DeleteRecord end if sError="" EditOpenDatabase conn, database,dbtable If Addaction = "" and Updateaction = "" Then AdminPageHeader GenerateForm AdminPageTrailer Else AdminPageHeader UpdateRecord GenerateForm AdminPageTrailer end if Shopclosedatabase conn '************************ Sub GetInputValues ' ID, allows editing a record which=request.querystring("which") 'VP-ASP 6.09 - Precautionary Security Fix if which > "" then If not isnumeric(which) then shoperror "ID must be numeric" end if end if idfield=request.querystring("idfield") If idfield="" then idfield="id" dbtable= request.querystring("table") if dbtable="" then dbtable="templates" database=request.querystring("database") ValidateTable End Sub ' Sub ValidateTable '******************************************** 'See if user has access to this table Dim UserTables, i dim tablecount if getconfig("XRestrictAdminTables")<>"Yes" then exit sub UserTables=GetSess("UserTables") If Isnull(UserTables) then exit sub end if if UserTables="" then exit Sub else UserTables=split(GetSess("UserTables"),",",-1,1) end if tablecount=ubound(UserTables) for i = 0 to tablecount if ucase(dbtable)=ucase(Usertables(i)) then exit sub end if next dbtable="" end sub Sub GenerateForm dim sqltemp if which <> "" then sqltemp="select * from " & dbtable sqltemp=sqltemp & " where " & idfield & "=" & which 'Debugwrite sqltemp set rstemp=conn.execute(sqltemp) end if DisplayForm if which <> "" then rstemp.close set rstemp=nothing end if end Sub '**************************** Sub DisplayForm() if which <> "" then template=rstemp("template") tempid=rstemp("id") templatename=rstemp("templatename") end if %>
<%shopwriteheader "Template Setup"%> <% if which<>"" then response.write "" end if response.write "" if which <> "" then response.write "" end if response.write "" %>
" & getlang("langadminadvanced") & " " & getlang("LangCommonEdit") & "Back To " & ucase(left(dbtable, 1)) & right(dbtable, len(dbtable) - 1) & "
<%shopwriteerror sError%>
<% response.write "
" 'VP-ASP 6.09 - remove editor as it was reformatting html 'AddEditor "editform" GenerateDisplayHeader "Template Information" GenerateDisplayBodyHeader response.write "
" If which<>"" then 'VP-ASP 6.09 - remove editor as it was reformatting html ''VPASP 600 - HTMLEDITOR 'If getconfig("xhtmleditor")="Yes" then ' Response.Write("    ") ' Response.Write("") 'else Response.Write("    ") Response.Write("") 'end if Response.Write("

") response.write "

" else 'VP-ASP 6.09 - remove editor as it was reformatting html ''VPASP 600 - HTMLEDITOR 'If getconfig("xhtmleditor")="Yes" then ' Response.Write("") 'else Response.Write("") 'end if end if Response.Write("
") response.write "

" FormatEditRow getlang("LangProductTemplate"),"templatename",templatename PCreateRowText "Template", "template", template,25,"template" Response.Write(TableDefEnd & "

") response.write "
" If which<>"" then 'VP-ASP 6.09 - remove editor as it was reformatting html ''VPASP 600 - HTMLEDITOR 'If getconfig("xhtmleditor")="Yes" then ' Response.Write("    ") ' Response.Write("") 'else Response.Write("    ") Response.Write("") 'end if Response.Write("

") response.write "

" else 'VP-ASP 6.09 - remove editor as it was reformatting html ''VPASP 600 - HTMLEDITOR 'If getconfig("xhtmleditor")="Yes" then ' Response.Write("") 'else Response.Write("") 'end if end if Response.Write("
") GenerateDisplayBodyFooter gethelp "templates" end sub '************ ' Sub UpdateRecord dim sqltemp 'VP-ASP 6.50 - broadened defintion of IF statement to cover cases where xmysql hasn't been set if ucase(xdatabasetype) = "MYSQL" OR ucase(xdatabasetype) = "MYSQL351" OR getconfig("xMYSQL")="Yes" then MYSQLProcessrecord updateaction, conn, dbtable, idfield, which exit sub end if If updateaction<>"" then sqltemp="select * from " & dbtable sqltemp= sqltemp & " where " & idfield & "=" & which Set rstemp = Server.CreateObject("ADODB.Recordset") rstemp.open sqltemp, conn, 1, 3 rstemp.Update else Set rstemp = Server.CreateObject("ADODB.Recordset") rstemp.open dbtable, conn, adOpenKeyset, adLockOptimistic rstemp.AddNew end if GenerateUpdateSQL which = rstemp(idfield) rstemp.close set rstemp=nothing sError= sError & "
" & getlang("LangEdit03") & "" end sub ' ******** general Sql Sub GenerateUpdateSQL() Dim howmanyfields dim fieldname, fieldvalue, fieldtype dim i howmanyfields=rstemp.fields.count -1 rstemp.update for i=1 to howmanyfields fieldname = rstemp(i).name fieldtype=rstemp(i).type fieldvalue = request.form(fieldname) EUpdatefield fieldname,fieldvalue next rstemp.update end sub Sub EUpdateField (fieldname, fieldvalue) on error resume next 'Debugwrite fieldname & "value=" & fieldvalue if fieldvalue="" then rstemp(Fieldname)=NULL exit sub end if if ucase(fieldvalue)="NULL" then rstemp(Fieldname)=NULL else rstemp(Fieldname)=fieldvalue end if end sub Sub DeleteRecord dim myconn EditOpenDatabase myconn, database,dbtable dim sql, url sql="delete from " & dbtable & " where " & idfield & "=" & which myconn.execute(sql) shopclosedatabase myconn url="shopa_editdisplay.asp?table=" & dbtable responseredirect url end sub Sub PCreateRowText (caption, fieldname, fieldvalue, rows, realname) dim url, htmlurl, linkurl url="shopa_edittemplate.asp?which=" & which htmlurl="shopa_htmledit.asp?which=" & which & "&idfield=id&table=templates&fieldname=" & realname htmlurl=htmlurl & "&url=" & server.urlencode(url) Linkurl="" & "HTML edit" & "" Response.write tablerow & tablecolumn & caption response.write tablecolumnend & tablecolumn 'VP-ASP 6.09 - remove editor as it was reformatting html ''VPASP 600 - ADD HTML EDITOR 'If getconfig("xhtmleditor")="Yes" then ' addHTMLEditor fieldname, fieldvalue, "editform" 'else response.write "" 'end if response.write "" end sub %>