Accessible ASP Star Ratings Script Version 0.2
I'm sure you've seen the star ratings feature dotted about the web on sites such as Amazon and YouTube. I couldn't find a ready made ASP script for this so decided to make one myself.
The Star Ratings script uses an Access database and should run on just about any ASP enabled Windows server.
If you use this on your website please let me know, I'd love to see it in action elsewhere. I'll also add a link to your site on the demo page.
Features
- Uses AJAX if Javascript is enabled but functions identically without Javascript.
- Logs IP addresses to prevent multiple votes for the same page.
- Block custom IP ranges and/or User Agents to prevent bots and spiders voting.
- Works with dynamic URLs.
- Free for personal or commercial use.
- Quick and easy to set up.
Demonstration
Download script
Installation
Upgrading
If you're upgrading the script from an earlier version simply overwrite the existing files, making sure you don't overwrite your database with the empty one in the .zip file. You will also need to make a note of your settings in common.asp.
First time installation
Download and extract the .zip file above to a directory named "rating" in the root directory of your website.
Add the following code between the <head> tags of your page:
<script type="text/javascript" src="/rating/rating.js"></script> <link type="text/css" rel="stylesheet" href="/rating/rating.css" />
Add this code wherever you want the rating bar to appear on your page:
<!--#include virtual="/rating/rating.asp"-->
No further setup is required for this script to run "out of the box". However I can't stress strongly enough that you must upload to the "/rating/" directory to the root directory of your website. If you upload the files to anywhere else then the script won't work without further changes (see below).
Database
This script uses a Microsoft Access 2000 database, included in the .zip file. By default the database is located in the "/rating/" directory with all of the other files and as such could be downloaded by anyone. Since the database probably won't contain any sensitive data this shouldn't be a problem.
However, if you would like to store the database outside the web root then alternative connection strings are provided in common.asp.
Uploading the script to a directory other than "/rating/"
If you want to store the files in a directory other than "/rating/", for example "/scripts/rating/", you will need to edit the RATING_DIR constant in common.asp as follows:
RATING_DIR = "scripts/rating" '- DO NOT start or end with /
You will also need to edit the image paths in rating.css as follows:
#star-rating ul {
background: url(/scripts/rating/rating.gif) top left repeat-x;
}
#star-rating li.current-rating {
background: url(/scripts/rating/rating.gif) left bottom;
}
#star-rating li a:hover {
background: url(/scripts/rating/rating.gif) left center;
}
Change the path to the CSS and Javascript files between the <head> tags of your page:
<script type="text/javascript" src="/scripts/rating/rating.js"></script> <link type="text/css" rel="stylesheet" href="/scripts/rating/rating.css" />
And finally change the include path to the rating script:
<!--#include virtual="/scripts/rating/rating.asp"-->
Blocking IP Ranges
Open common.asp and scroll down to the "Blocked IP Ranges" section. To block an entire IP range use the AddBlockedIPRange subroutine as shown below and replace the lower and upper IP addresses as required:
AddBlockedIPRange "192.168.0.1", "192.168.0.10"
An excellent list of search engine IP addresses and User Agents can be found at www.IPLists.com.
Blocking User Agents
Open common.asp and scroll down to the "Blocked User Agents" section. To block a User Agent, use the AddBlockedUserAgent subroutine as shown below:
AddBlockedUserAgent "Googlebot" AddBlockedUserAgent "MSNBOT/0.1"
A list of robot and search engine User Agents can be found here at JafSoft.com.
Blocking User Agent Strings
As well as blocking specific User Agents, you can also block User Agents that contain certain strings, such as "crawler" or "spider".
Open common.asp and scroll down to the "Blocked User Agent Strings" section. To block User Agents containing a certain string, user the AddBlockedUAString as follows:
AddBlockedUAString "crawler" AddBlockedUAString "spider"
Credits
The XHTML/CSS has been taken from Creating a Star Rater using CSS written by Rogie King at Komodo Media.
The AJAX framework the script uses is the Simple/Basic AJAX Framework by Ric Hardacre at Cyclomedia. It has been tested to work with Internet Explorer 5.0, 5.5, 6.0 and 7.0, Opera 8.0 and 8.5, Netscape 7.0 and Firefox 1.5

Comments (68)
if you had a "helpfull or not" style example I bet that would be popular also.
keep up the great work.
Wayne
One query though.... is it possible to rate several different products on one page independently using this script? Or can this script only be used once on each page????
The next version I'm working on will make this change more straightforward, but for now I'd recommend re-uploading the original files to the /rating/ directory in the web root.
By the way, thanks a TON for this script. Yesterday my boss wanted a new voting system and I hate that we use an ASP server because I only know PHP. I thought I was going to have to settle for something crappy just because I don't know ASP. The fact that you made this days before I needed it is amazing. Thanks!
http://www.coe.unt.edu/gal/rating/
should be...
http://www.coe.unt.edu/rating/
good idea, but this querystring logic is blech!
The querystring is now taken into account and pages with different querystrings are rated seperately.
I also noticed that Googlebot had been spidering the links and throwing the results off. You can now block voting by IP range, User Agent or by a specific string contained in the User Agent.
You can also set the script to round ratings to the nearest half number by setting the NEAREST_HALF constant in common.asp to True.
The script now uses Ric Hardacre's Simple/Basic AJAX framework.
Click here to download
Now I'm having a problem including multiple rating.asp's. Everything works fine if you've only got one thing on the page to vote for, but I have several.
Did you figure this out? If so can you pass it along.
Thanks
Now I'm having a problem including multiple rating.asp's. Everything works fine if you've only got one thing on the page to vote for, but I have several.
implemented it and was up and running in 2 minutes flat! I even modified the locations of the database and what not in a heart beat!
Seriously Well done ... Couldn't be any simpler ... I am soooooo excited about it.
This little devil gave my site a face-lift in 2 minutes!! WOW!
A+ man ... A+
Now, were can we submit ideas for improvements? Like for example, modify to use SQL server, or specify the kind of info to be logged (instead of the query string) ...etc
I use dynamic URLs, and was able to use the script flawlessly!
You can check out the script running on any profile page... or use my site's slideshow feature to rate members in a "slideshow" manner.
http://www.exercisefriends.com/slideShow.aspx
COOL SCRIPT... easy to use and was easy to update / modify for my needs.
Thanks,
Ken Collins
Co-Founder www.eXerciseFriends.com
PS.
I love that you gave the tips about changing your database names and paths to folders. As an experienced designer I would have figured it out and done that myself... but cut and clear directions were REALLY appreciated.
Seriously... it only takes a couple of minutes to add this script to your site.
Here's a tip:
Use Iframes!
Create an Iframe that will actually be the page that the script runs on. Then embed the iframe in the appropriate location, and pass all URL and querystring data down to the Iframe page that runs the script.
Note: when passing your querystring and url to the iframe, do not include the "?" in your querystring and you will be fine.
If you look at my profile on exerciseFriends.com, you will see the that my ratings follow me on other pages (i do this by using the same iframe with the same url passed into it).
This makes the code ULTRA PORTABLE and able to handle dynamic URLS.
Check out my page @
http://www.exercisefriends.com/view_profile.aspx?member_id=1
Don't forget to give me good ratings ;)
I hope this helps,
Ken Collins
Co-Founder www.eXerciseFriends.com
First of all thanx for this very usefull script :)
I'm developing a website including this ratingscript of yours..
So far so good, but when i want to show ONLY the voted results on a pacific page (Score: 5 out of 5) i'm clueles :S
On the rating.asp page it is the code that says: <%=iRatingAverage%>
I have unpacked the entire .rar pack in to a map that is located in the root of my website (name of the map where i stored the pack in the root = rating).
Can you please help me with this "little problem" of mine?
P.S: Sorry for my bad English, but i'm working on it :D
Cheers!
Has anybody else had a similar problem...I'm afraid I'm well out of my depth when it comes to Ajax.
I dont have a problem writing ASP code to do a generic rating system, but what I like about this script of yours is the image/hover thing.... Currently your script gets the current url via a Server Request for the URL... what I would like to do is record the ImageID of the image the user rates to the DB instead ... all images are retrieved from a DB in any case... how do I pass the ImagID to the DB instead of the page URL - i tried changing this as below
sRatingURL = sRatingURL & "?" & sQueryString & "&ImageID=" & timageid
but to no effect - any ID on how to do this?
Awsome mod, but cant get it to work on my site (www.lotusclub.org), but would love to.
From reading above looks like it doesnt work with mySQL....
Best regards.
CS1010: Newline in constant
The line in question is the first (commented) line of common.asp!
Hmm ... clues please? A cursory web search revealed very little.
The UI shows up just fine! However, the RPC bails out (and yes, the 200 is up top - not shown here):
Microsoft JET Database Engine error '80040e09'
Cannot update. Database or object is read-only.
/rating/common.asp, line 122
The .ldb file has to be created during any updates, so I made sure the directory and files had appropriate permissions (IUSR_ and IWAM_):
http://databases.aspfaq.com/database/how-do-i-solve-operation-must-use-an-updateable-query-errors.html
Still no luck! So I moved the database file to C:\Inetpub\db\ (and tried as-is and with permission changes). No suck luck.
Clues (still) welcome ... :-o
i am using this script to install star rating, but finding dificult to handle. I tell you how I am doing this.
First i copied the directory rating into root then gone to my folder ayurveda where i copied the coding for js and css into the page with proper change in path. I changed the path for common.asp also. But how can i connect my file with mdb. is there any code left.
pls help me this regard
The onlY question I have is that is it possible to reduce te size of the stars.
I tried to modify the gif size, but it doesnt work! I realized that the I should modify the CSS, But I dont' what to do.
Coul you give me any advice?
PS You shoud install a CAPTCHA in this form
i want to download accessible-star-ratings scrit but ur website download link is not working so is any other web from where i download it or somone do me favor that please email me the zip file on my email : fainaqvi@hotmail.com Please i search all scripts website but i did'nt found.
waiting for a positive reply..
Thanks
bYe
My server supports ASP scripts. Please let me know how to make it work.
I have to put the files to the "/httpdocs" folder. So I modified the files u mentioned also. Still things are not working. Can't wait to impliment the script. Thanks for your help in advance!
Debasish Upadhyey
Great script!
One question. Is it possible that this script would only rate a complete site?
Example: If i rate a default.asp page and then go to lets say product.asp page, it shows me no voting.
I would like, if some1 has rated my site, then he/she can't rate it again even if he/she went to product.asp or any other page.
I hope u know what i mean :)...
thanks,
http://www.rating-system.com
your script rocks, but somehow i am not able to fix it up. can u pls. help me dood .. i hav it up on this test link, can u come to my rescue
http://partners.shailesshvalia.com/rating/testing.asp
thanx in advance. cheers and have a rocking news year !!
Awesome utility! Had it running in minutes, had it moved to a secure folder minutes later, and have it reading from the SQL 2K5 server now, too. (struggling with my meager SQL skills to figure out how to allow write, but that's on-me.) I'm investigating the IFrame solution to allow voting on the page that manages the display of multiple scripts/functions on my site. Should have it functioning soon - just need more play time.
Sam -
Looks like it's installed correctly - did you allow WRITE permission for the IUSR_MachineName account on the Ratings folder? Seems to be the most common issue when the stars display but you can't vote. The IUSR account already has READ perms to the web strucutre. I added WRITE access directly to the MDB file and had no problems, but saw comments elsewhere that the directory where DB files are kept should be writable as well. That would be true if temp or backup files needed to be created, but don't think it applies here to the Ratings db. My rule is to only relax security as much as needed ,nothing more.
Glenn
Any help you can give would be greatly appreciated!
Thanks
I have implemented your excellent star rating script, and managed to put multiple id on any page, I have also re-drawn the star so it has a transparent background. I have however run into a slight problem and that is making the whole star bar smaller, obviously I understand that the image needed to be reduced and the css in suit with that, butwhatever I do I cannot get the rollovers to re-act correctly with my new image.
Is there any way you could amend your css for me based on the image but a third smaller ???
I would be hugely grateful If you could have a look for me. Or point me in the right direction.
Cheers
Richard
Any ideas?
http://www.petcaregroup.com/everyone/50ways.asp
can you please help me
i have put them in the right directory.
i have put the code on my page for the rating system to be on my page.
i actually use dreamweaver to do this.
but when i put the "<scripttype="text/javascript"src="/rating/rating.js"></script>
<link type="text/css" rel="stylesheet" href="/rating/rating.css" />"
what do you mean by between the head tags of your page.. can you show me an example because i think that is my problem.
www.chipoyun.com
Its seems to happen when:
• There is no Read/Write permission on the rating folder or the folder where the data base is
• If you installed the script in a different folder than /script and then don’t reference it in the correct form on the code
• Observe that wrong referencing in the commom.asp File
At Line:
30 Const RATING_DIR = "lojan/rating"
Can still makes everything appears to be fine , but in fact it will screw up the path used to reference the rpc.asp file on the OnClick event
To find out if the correct path is being passed to the function variable is the corret one, do the following:
Open the Page where the Star Rating System is being displayed on your browser.
Click The View Code option
Find Out where is the code is the Star Rating Tags , find the LIST tags, that will look like this:
<ul>
<li class="current-rating" style="width:0px;">Currently 0/5 Stars.</li>
<li><a href="/everyone/50ways.asp?rating=1#star-rating" onclick="fAJAXRequest('star-rating','/everyone/rating/rpc.asp?rating=1&url=/everyone/50ways.asp','nocache','',''); return false;" title="Rate this 1 stars out of 5" class="star-1">1</a></li>
<li><a href="/everyone/50ways.asp?rating=2#star-rating" onclick="fAJAXRequest('star-rating','/everyone/rating/rpc.asp?rating=2&url=/everyone/50ways.asp','nocache','',''); return false;" title="Rate this 2 stars out of 5" class="star-2">2</a></li>
<li><a href="/everyone/50ways.asp?rating=3#star-rating" onclick="fAJAXRequest('star-rating','/everyone/rating/rpc.asp?rating=3&url=/everyone/50ways.asp','nocache','',''); return false;" title="Rate this 3 stars out of 5" class="star-3">3</a></li>
<li><a href="/everyone/50ways.asp?rating=4#star-rating" onclick="fAJAXRequest('star-rating','/everyone/rating/rpc.asp?rating=4&url=/everyone/50ways.asp','nocache','',''); return false;" title="Rate this 4 stars out of 5" class="star-4">4</a></li>
<li><a href="/everyone/50ways.asp?rating=5#star-rating" onclick="fAJAXRequest('star-rating','/everyone/rating/rpc.asp?rating=5&url=/everyone/50ways.asp','nocache','',''); return false;" title="Rate this 5 stars out of 5" class="star-5">5</a></li>
</ul>
Now, look close at the parameters being passed to the the fAJAXRequest() Function
The first one seems to be the 'star-rating' string . OK this is Default
The Second One Seems to have on its first part Before the Semicolon a Reference to the .rfc file. Look if these files are being referenced in the proper manner.
Mine was wrong because I messed with the RATING_DIR = "mysitesubfolder/ rating" Declaration on Common.asp
Looking at the source code will help you identify if the URL references are correct or NOT.
I Hope I could help.
="everyone/50ways/rating"
You have made a great and successful effort. Thanks for taking so much pain in developing this script and most high allowing anyone to use it and FREELY. I also like to use this script of yours if you allow me too. But without any reply from you, I've downloaded it and start to use it. I sorry for that. But Im getting some problem. Please visit here http://go2bollywood.tv/kajol/testRating.asp
You will see yourself that the "star" image is not visible. Also if i click star, with the help of tooltip, voting doesnt done. Ive installed the script as per the instruction, in "rating" directory, and also didnt made any changes but still it is not giving right output. Please help me in this because I want to use it in my site. You can check it http://go2bollywood.tv/kajol/index.asp.
Moreover, I want to know about Blocking IP, User Agents and User Agent Strings. Could you just tell something more about it. Hope Im not bothering you!!!!
Trust to have a positive and early reply from you side.
Thanks for all and ever,
Javed Iqbal.
Thanks,
Cathy
[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'URLID= and UserIP='81.141.34.999'.
/common.asp, line 146
getting the above error, but when i refresh the page it has in fact worked?
thanks in advanced
I have tried almost everything! Thanks in advance!!!
Can I change the directory where the script resides?
Can I use SQL or mySQL server instead of Access?
Can I change the graphic to airplanes/rockets/cars/my logo/etc?
Can I change the size of the rating graphic?
Can I rate more than one object on a page?
Can I change the position of the rating images?
For detailed answers, see the FAQ at www.innotechcg.com/forestblog - published in the scripting section on 7/3/08. Hope you find it helpful.
Glenn
<a href="http://www.bayrakline.com">bayrak</a>
<a href="http://www.aybayrak-tr.com">türk bayrağı</a>
<a href="http://www.aybayrak-tr.com">bayrakçı</a>
Erreur d'exécution Microsoft VBScript erreur '800a000d'
Type incompatible: 'GetRating'
/tee-shops/rating/rating.asp, ligne 33
Erreur de compilation Microsoft VBScript erreur '800a03ea'
Erreur de syntaxe
/rating/common.asp, ligne 74
Sub RatingConnOpen
^
http://www.izmirnews.com/haberic.asp?id=454
It works corectly on IE6 and Firefox. The script breaks fAJAXRequest() Function.
Thank you for your help.
Just wondered if you have any helpfiles so that the script can be adapted and used for dynamic urls, using more than once instance on a page and grabbing a unique ID rather than the URL?
If you have links to this solution it would be appreciated. I can see from the comments on your website that this question has already been raised but i cannot seem to locate the solution.
Your help will be appreciated.
All teh best, good looking script ;-)