Modificare il file:
\iwgallery\admin\inc_cat_listing.asp
<% If LCase(Request.Cookies("IWGalleryAccess")) <> "amministratore" Then Response.Redirect("logout.asp?reason=Accesso negato") %> <!--#include virtual="/iwgallery/Connections/connIWGallery.asp" --> <% ' *** Edit Operations: declare variables Dim MM_editAction Dim MM_abortEdit Dim MM_editQuery Dim MM_editCmd Dim MM_editConnection Dim MM_editTable Dim MM_editRedirectUrl Dim MM_editColumn Dim MM_recordId Dim MM_fieldsStr Dim MM_columnsStr Dim MM_fields Dim MM_columns Dim MM_typeArray Dim MM_formVal Dim MM_delim Dim MM_altVal Dim MM_emptyVal Dim MM_i MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME")) If (Request.QueryString <> "") Then MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString) End If ' boolean to abort record edit MM_abortEdit = false ' query string to execute MM_editQuery = "" %> <% ' *** Insert Record: set variables If (CStr(Request("MM_insert")) = "formNew") Then MM_editConnection = MM_connIWGallery_STRING MM_editTable = "CATEGORIES" MM_editRedirectUrl = "cat_listing.asp" MM_fieldsStr = "CAT_NAME|value|CAT_DESCRIPTION|value|CAT_PARENT|value" MM_columnsStr = "CAT_NAME|',none,''|CAT_DESCRIPTION|',none,''|CAT_PARENT|none,none,NULL" ' create the MM_fields and MM_columns arrays MM_fields = Split(MM_fieldsStr, "|") MM_columns = Split(MM_columnsStr, "|") ' set the form values For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2 MM_fields(MM_i+1) = CStr(Request.Form(MM_fields(MM_i))) Next ' append the query string to the redirect URL If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString Else MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString End If End If End If %> <% ' *** Delete Record: declare variables if (CStr(Request("MM_delete")) = "formDelete" And CStr(Request("MM_recordId")) <> "") Then MM_editConnection = MM_connIWGallery_STRING MM_editTable = "CATEGORIES" MM_editColumn = "CAT_ID" MM_recordId = "" + Request.Form("MM_recordId") + "" MM_editRedirectUrl = "cat_listing.asp" ' append the query string to the redirect URL If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString Else MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString End If End If End If %> <% ' *** Insert Record: construct a sql insert statement and execute it Dim MM_tableValues Dim MM_dbValues If (CStr(Request("MM_insert")) <> "") Then ' create the sql insert statement MM_tableValues = "" MM_dbValues = "" For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2 MM_formVal = MM_fields(MM_i+1) MM_typeArray = Split(MM_columns(MM_i+1),",") MM_delim = MM_typeArray(0) If (MM_delim = "none") Then MM_delim = "" MM_altVal = MM_typeArray(1) If (MM_altVal = "none") Then MM_altVal = "" MM_emptyVal = MM_typeArray(2) If (MM_emptyVal = "none") Then MM_emptyVal = "" If (MM_formVal = "") Then MM_formVal = MM_emptyVal Else If (MM_altVal <> "") Then MM_formVal = MM_altVal ElseIf (MM_delim = "'") Then ' escape quotes MM_formVal = "'" & Replace(MM_formVal,"'","''") & "'" Else MM_formVal = MM_delim + MM_formVal + MM_delim End If End If If (MM_i <> LBound(MM_fields)) Then MM_tableValues = MM_tableValues & "," MM_dbValues = MM_dbValues & "," End If MM_tableValues = MM_tableValues & MM_columns(MM_i) MM_dbValues = MM_dbValues & MM_formVal Next MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues & ") values (" & MM_dbValues & ")" If (Not MM_abortEdit) Then ' execute the insert Set MM_editCmd = Server.CreateObject("ADODB.Command") MM_editCmd.ActiveConnection = MM_editConnection MM_editCmd.CommandText = MM_editQuery MM_editCmd.Execute MM_editCmd.ActiveConnection.Close If (MM_editRedirectUrl <> "") Then Response.Redirect(MM_editRedirectUrl) End If End If End If %> <% ' *** Delete Record: construct a sql delete statement and execute it If (CStr(Request("MM_delete")) <> "" And CStr(Request("MM_recordId")) <> "") Then ' create the sql delete statement MM_editQuery = "delete from " & MM_editTable & " where " & MM_editColumn & " = " & MM_recordId If (Not MM_abortEdit) Then ' execute the delete Set MM_editCmd = Server.CreateObject("ADODB.Command") MM_editCmd.ActiveConnection = MM_editConnection MM_editCmd.CommandText = MM_editQuery MM_editCmd.Execute MM_editCmd.ActiveConnection.Close If (MM_editRedirectUrl <> "") Then Response.Redirect(MM_editRedirectUrl) End If End If End If %> <% Dim iCat iCat = 0 'If Request.QueryString("iCat") > 0 Then If Request.QueryString("iCat") <> "" Then iCat = Request.QueryString("iCat") End If %> <% Set rsCat = Server.CreateObject("ADODB.Recordset") rsCat.ActiveConnection = MM_connIWGallery_STRING rsCat.Source = "SELECT * FROM CATEGORIES WHERE CAT_PARENT = " & iCat & " ORDER BY CAT_NAME ASC" rsCat.CursorType = 0 rsCat.CursorLocation = 2 rsCat.LockType = 1 rsCat.Open() %> <% Set rsSub = Server.CreateObject("ADODB.Recordset") rsSub.ActiveConnection = MM_connIWGallery_STRING rsSub.Source = "SELECT * FROM CATEGORIES ORDER BY CAT_NAME ASC" rsSub.CursorType = 0 rsSub.CursorLocation = 2 rsSub.LockType = 1 rsSub.Open() %> <% Dim HLooper1__numRows HLooper1__numRows = -2 Dim HLooper1__index HLooper1__index = 0 rsCat_numRows = rsCat_numRows + HLooper1__numRows %> <script language="JavaScript" type="text/JavaScript"> <!-- function WAtrimIt(theString,leaveLeft,leaveRight) { if (!leaveLeft) { while (theString.charAt(0) == " ") theString = theString.substring(1); } if (!leaveRight) { while (theString.charAt(theString.length-1) == " ") theString = theString.substring(0,theString.length-1); } return theString; } function WAAddError(formElement,errorMsg,focusIt,stopIt) { if (document.WAFV_Error) { document.WAFV_Error += "\n" + errorMsg; } else { document.WAFV_Error = errorMsg; } if (!document.WAFV_InvalidArray) { document.WAFV_InvalidArray = new Array(); } document.WAFV_InvalidArray[document.WAFV_InvalidArray.length] = formElement; if (focusIt && !document.WAFV_Focus) { document.WAFV_Focus = focusIt; } if (stopIt == 1) { document.WAFV_Stop = true; } else if (stopIt == 2) { formElement.WAFV_Continue = true; } else if (stopIt == 3) { formElement.WAFV_Stop = true; formElement.WAFV_Continue = false; } } function WAValidateRQ(formElement,errorMsg,focusIt,stopIt,trimWhite,inputType) { var isValid = true; if (!document.WAFV_Stop && !formElement.WAFV_Stop) { if (inputType == "select") { if (formElement.selectedIndex == -1) { isValid = false; } else if (!formElement.options[formElement.selectedIndex].value || formElement.options[formElement.selectedIndex].value == "") { isValid = false; } } else if (inputType == "checkbox") { if (formElement.length) { isValid = false; for (var x=0; x<formElement.length ; x++) { if (formElement[x].checked && formElement[x].value!="") { isValid = true; break; } } } else if (!formElement.checked) isValid = false; } else if (inputType == "radio") { isValid = false; if (formElement.checked) isValid = true; } else if (inputType == "radiogroup") { isValid = false; for (var x=0; x<formElement.length; x++) { if (formElement[x].checked && formElement[x].value!="") { isValid = true; break; } } formElement = formElement[0]; } else { var value = formElement.value; if (trimWhite) { value = WAtrimIt(value); } if (value == "") { isValid = false; } } } if (!isValid) { WAAddError(formElement,errorMsg,focusIt,stopIt); } } function WAAlertErrors(errorHead,errorFoot,setFocus,submitForm) { if (!document.WAFV_StopAlert) { document.WAFV_StopAlert = true; if (document.WAFV_InvalidArray) { document.WAFV_Stop = true; var errorMsg = document.WAFV_Error; if (errorHead!="") errorMsg = errorHead + "\n" + errorMsg; if (errorFoot!="") errorMsg += "\n" + errorFoot; document.MM_returnValue = false; if (document.WAFV_Error!="") alert(errorMsg.replace(/"/g,'"')); else if (submitForm) submitForm.submit(); if (setFocus && document.WAFV_Focus) { document.tempFocus = document.WAFV_Focus; setTimeout("document.tempFocus.focus();setTimeout('document.WAFV_Stop = false;document.WAFV_StopAlert = false;',1)",1); } else { document.WAFV_Stop = false; document.WAFV_StopAlert = false; } for (var x=0; x<document.WAFV_InvalidArray.length; x++) { document.WAFV_InvalidArray[x].WAFV_Stop = false; } } else { document.WAFV_Stop = false; document.WAFV_StopAlert = false; if (submitForm) { submitForm.submit(); } document.MM_returnValue = true; } document.WAFV_Focus = false; document.WAFV_Error = false; document.WAFV_InvalidArray = false; } } //--> </script> <table width="100%" border="0" cellpadding="0" cellspacing="0" class="box"> <tr> <td align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="1" align="left" class="box-header"><img src="../themes/<%= strTheme %>/box-header-left.jpg" alt="Box Left"></td> <td width="100%" class="box-header">Categorie</td> <td width="1" align="right" class="box-header"><img src="../themes/<%= strTheme %>/box-header-right.jpg" alt="Box Right"></td> </tr> </table></td> </tr> <tr> <td align="left" valign="top" class="box-main"><% If Not rsCat.EOF Or Not rsCat.BOF Then %> <table width="100%" border="0" cellspacing="1" cellpadding="0" class="content"> <tr> <td>Seleziona una categoria parent per aggiungere una nuova categoria </td> </tr> </table> <% End If ' end Not rsCat.EOF Or NOT rsCat.BOF %> <table width="100%"> <% startrw = 0 endrw = HLooper1__index numberColumns = 2 numrows = -1 while((numrows <> 0) AND (Not rsCat.EOF)) startrw = endrw + 1 endrw = endrw + numberColumns %> <tr valign="top"> <% While ((startrw <= endrw) AND (Not rsCat.EOF)) strCatId = rsCat.Fields.Item("CAT_ID").Value strTable = Request.QueryString("nChannel") strField = Left(strTable,3) sqlParent = "" set rsCatCount = Server.CreateObject("ADODB.Recordset") rsCatCount.ActiveConnection = MM_connIWGallery_STRING rsCatCount.Source = "SELECT COUNT(*) AS PIC_COUNT FROM PICTURES WHERE PIC_LISTING LIKE '%." & strCatId & ".%'" & sqlParent rsCatCount.CursorType = 0 rsCatCount.CursorLocation = 2 rsCatCount.LockType = 3 rsCatCount.Open() rsCatCount_numRows = 0 strCatCount = rsCatCount.Fields.Item("PIC_COUNT").Value rsCatCount.Close() Set rsCatCount = Nothing %> <td align="left" valign="top" width="50%"><table border="0" cellspacing="1" cellpadding="0" class="content"> <tr> <td width="1" valign="baseline"><img src="../images/icon_folder.gif" alt="Categoria" border="0"></td> <td valign="top"><a href="cat_listing.asp?iCat=<%=(rsCat.Fields.Item("CAT_ID").Value)%>"><strong><%=(rsCat.Fields.Item("CAT_NAME").Value)%></strong></a> (<%= strCatCount %>) <a href="cat_edit.asp?iData=<%=(rsCat.Fields.Item("CAT_ID").Value)%>&iCat=<%=Request.QueryString("iCat")%>"><img src="../images/icon_edit.gif" alt="Edit" title="Edit" border="0" align="absmiddle"></a><br> <% Dim rsSub__numRows rsSub__numRows = 3 Dim rsSub__index rsSub__index = 0 rsSub_numRows = rsSub_numRows + rsSub__numRows varCat = rsCat.Fields.Item("CAT_ID").Value rsSub.Filter = "CAT_PARENT = " & varCat %> <% If (rsSub.EOF) And strCatCount = 0 Then %> <form ACTION="<%=MM_editAction%>" method="POST" name="formDelete" id="formDelete"> <input class = "button" type="submit" name="Submit" value="Cancella"> <input type="hidden" name="MM_delete" value="formDelete"> <input type="hidden" name="MM_recordId" value="<%= rsCat.Fields.Item("CAT_ID").Value %>"> </form> <% End If %> <% While ((rsSub__numRows <> 0) AND (NOT rsSub.EOF)) %> <%=(rsSub.Fields.Item("CAT_NAME").Value)%> <% If rsSub__index - 1 > 0 Then Response.Write("...") Else Response.Write(", ") End If %> <% rsSub__index=rsSub__index+1 rsSub__numRows=rsSub__numRows-1 rsSub.MoveNext() Wend %> </td> </tr> </table></td> <% startrw = startrw + 1 rsCat.MoveNext() Wend %> <% ' Fix per HLooperMX ' Mettere prima di </tr> While startrw <= endrw Response.Write("<td> </td>") startrw = startrw + 1 Wend %> </tr> <% numrows=numrows-1 Wend %> </table> <br> <form action="<%=MM_editAction%>" method="POST" name="formNew" id="formNew" onSubmit="WAValidateRQ(document.formNew.CAT_NAME,'* Il campo Nome è obbligatorio',document.formNew.CAT_NAME,0,true,'text');WAAlertErrors('','',true,false);return document.MM_returnValue"> <table border="0" align="center" cellpadding="0" cellspacing="1" class="content"> <tr valign="baseline"> <td nowrap align="right"> Parent: </td> <td><a href="cat_listing.asp"><strong>Root</strong></a> › <% FillArray For i = UBound(arrayId) to 0 Step - 1 If NOT arrayId(i) = "" then Response.Write "<a href=""cat_listing.asp?iCat=" & arrayId(i) & """><strong>"& arrayName(i) & "</strong></a> › " End If Next %> </td> </tr> <tr valign="baseline"> <td nowrap align="right">*Nome:</td> <td><input type="text" name="CAT_NAME" value="" size="32"> </td> </tr> <tr valign="baseline"> <td align="right" valign="top" nowrap>Descrizione:</td> <td><textarea name="CAT_DESCRIPTION" cols="32" rows="4" id="CAT_DESCRIPTION"></textarea> </td> </tr> <tr valign="baseline"> <td nowrap align="right"> </td> <td><input name="Submit2" type="submit" id="Submit2" value="Aggiungi Categoria" class="button"> </td> </tr> </table> <input type="hidden" name="CAT_PARENT" value="<%= iCat %>" size="32"> <input type="hidden" name="MM_insert" value="formNew"> </form></td> </tr> <tr> <td align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="1" align="left" class="box-bottom"><img src="../themes/<%= strTheme %>/box-bottom-left.jpg"></td> <td width="100%" class="box-bottom"><img src="../images/shim.gif" width="1" height="1"></td> <td width="1" align="right" class="box-bottom"><img src="../themes/<%= strTheme %>/box-bottom-right.jpg"></td> </tr> </table></td> </tr> </table> <% rsCat.Close() Set rsCat = Nothing %> <% rsSub.Close() Set rsSub = Nothing %>
[
Íàçàä
]