%option explicit%> <% ShopCheckAdmin "shopa_editdisplay.asp" '******************************* ' Version 5.00 Supports adds, deletes, updates ' Display fields in one record of one table ' setting field to keyword "NULL" sets field to empty ' Jan 5, 2003 '******************************* dim rstemp dim which dim idfield dim dbtable, AddAction, conn, updateaction dim DeleteAction Addaction=Request.form("add") Updateaction=Request.form("update") Deleteaction=request("delete") GetInputValues If DeleteAction<>"" then DeleteRecord end if 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("which") idfield=request("idfield") dbtable=request("table") 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 sqltemp="select * from " & dbtable if which <> "" then sqltemp=sqltemp & " where " & idfield & "=" & which end if 'debugwrite sqltemp set rstemp=conn.execute(sqltemp) DisplayForm rstemp.close set rstemp=nothing end Sub '**************************** Sub DisplayForm() dim keyvalue, howmanyfields, i, fieldname, fieldvalue, fieldtype, fieldtypenum howmanyfields=rstemp.fields.count -1 shopwriteheader getlang("LangEdit02") shopwriteerror sError response.write "" & getlang("LangEditSelectSetup") & " " & dbtable & "" response.write "
") AddImageupload end sub '************ ' Sub UpdateRecord dim sqltemp if 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 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 If addaction<>"" then sError= sError & "