% Option Explicit %> <% '**************************************************************************************** '** Copyright Notice '** '** Copyright 2002 Drew Gauderman All Rights Reserved. '** '** This program is free software; you can redistribute it and/or modify '** it under the terms of the GNU General Public License as published by '** the Free Software Foundation; either version 2 of the License, or '** any later version. '** '** All copyright notices must remain intacked in the scripts and the '** outputted HTML. '** '** You may not pass the whole or any part of this application off as your own work. '** '** All links to www.maddogs-asp.com must remain in place and the powered by '** link or image must remain visiable when the pages are viewed. '** '** This program is distributed in the hope that it will be useful, '** but WITHOUT ANY WARRANTY; without even the implied warranty of '** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the '** GNU General Public License for more details. '** '** You should have received a copy of the GNU General Public License '** along with this program; if not, write to the Free Software '** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA '** '** No official support is available for this program but you may post support questions at: - '** http://www.maddogs-asp.com/ '** '** Support questions are NOT answered by e-mail ever! '** '** For correspondence or non support questions contact: - '** webmaster@maddogs-asp.com '** '**************************************************************************************** Response.Buffer = True 'Dimension variables Dim rsLinks Dim strWebsite Dim intSiteID Dim lngTotalRateAmount Dim lngNoOfRatings Dim intRating Dim intNewRating Dim blnSavedRating 'Initialise varibles blnSavedRating = False 'Read in the site ID number intSiteID = CInt(Request.QueryString("SiteID")) If isEmpty(Request.QueryString("Rating")) = False Or isNumeric(Request.QueryString("Rating")) = False Then intRating = CInt(Request.QueryString("Rating")) Else intRating = -1 End If 'Craete a recorset object Set rsLinks = Server.CreateObject("ADODB.Recordset") 'Initalise the read in the link details from the database strSQL = "SELECT tblLinks.* " strSQL = strSQL & "FROM tblLinks " strSQL = strSQL & "WHERE tblLinks.ID = " & intSiteID & ";" 'Set the cursor type property of the record set to Dynamic so we can navigate through the record set rsLinks.CursorType = 2 'Set the Lock Type for the records so that the record set is only locked when it is updated rsLinks.LockType = 3 'Query the database rsLinks.Open strSQL, strLinksCon 'Read in the Website Title If NOT rsLinks.EOF Then strWebsite = rsLinks("Link") 'If the user has selected a star rating workout the new rating and save to DB If intRating >= 0 AND intRating <= 5 AND NOT rsLinks.EOF AND NOT Request.Cookies("RateSite")("Site" & intSiteID) = "True" Then 'Read in the amount from the database lngNoOfRatings = CLng(rsLinks("No_of_ratings")) lngTotalRateAmount = CLng(rsLinks("Total_rate_amount")) 'Add 1 to the number of ratings lngNoOfRatings = lngNoOfRatings + 1 'Add the new rating amount to the number of ratings lngTotalRateAmount = lngTotalRateAmount + intRating 'Get the new average of ratings by dividing the total amount rate by the number of ratings intNewRating = (lngTotalRateAmount / lngNoOfRatings) 'Update the recordset rsLinks.Fields("No_of_ratings") = lngNoOfRatings rsLinks.Fields("Total_rate_amount") = lngTotalRateAmount rsLinks.Fields("Rating") = intNewRating 'Update the database rsLinks.Update 'Set a cookie to stop repeated votes Response.Cookies("RateSite")("Site" & intSiteID) = "True" Response.Cookies("RateSite").Expires = Now() + 7 'Set the saved rating boolen to true blnSavedRating = True End If 'Reset server variables Set adoCon = Nothing Set strLinksCon = Nothing rsLinks.Close Set rsLinks = Nothing %>