Gossamer Forum
Home : General : Perl Programming :

Looking for a script...

Quote Reply
Looking for a script...
I figured someone here might know of something that might fit my needs...

I'm looking for a script to handle reviews and possibly ratings for various products. In other words I have 10 product reviews set up and would like to allow users to give their opinions about the product and rate it. Similar to what Amazon.com has set up but it can be much simpler.

Does anyone know of anything I could use?
Quote Reply
Re: Looking for a script... In reply to
DBMAN could be your answer. It allows you to set up a database and then end users or users can add data to the database file.

Check out DBMAN at this web site.

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: Looking for a script... In reply to
To make DBMAN do what I need it to do would take a lot more code hacking than I am willing to do. Smile

I was thinking more along the lines of a guestbook or something that I can include on the page using SSI...

Thanks though. Smile
Quote Reply
Re: Looking for a script... In reply to
While Review It,
www.baywooddesign.com/Links/Internet/Scripts/Review_It/
is a mod for links it can be used as a freestanding script and could have the inclusion of a simple rating scheme. You might look in The CGI Resource Index
www.cgi-resources.com/Programs_and_Scripts/Perl/


[This message has been edited by Dave (edited July 09, 1999).]
Quote Reply
Re: Looking for a script... In reply to
Dave,

That is exactly what I was looking for!

I got it working but ran into some problems when modifying it to match the overall look of the site.

Currently there is a seperate sub for adding a review to an existing HTML page. This is great except that it uses the splice function to insert element into the middle of a list.

Quote:
foreach $file (@file) {
if ($file=~ /$in{'id'}/i) {
# if xxx.html is in $IdFile we open the existing review to add to it
#### Adding review to xxx.html ####
open (html, "<$reviews/$in{'id'}.html") or &error("Unable to open $in{'id'}.html, pleas delete the reference in $IdFile");
if ($flock eq "y") {flock html, 2;
}
@html=<html>;
close (html);

$line=0;
foreach $html (@html) {$line++;
if ($html=~ /<!--$in{'id'}.html-->/i) {$line--;
if (!$in{'email'}) {$by="$in{'name'}";
}
else {$by="<a href=\"mailto:$in{'email'}\">$in{'name'}</a>";
}
# we add the following LONG LINE HERE
@reply="\n<!--start-->\n<tr><td>$by </td>\n<td><small>$date at $time</small></td></tr>\n<tr><td><!--IP: $ENV{'REMOTE_HOST'}--></td>\n<td>$in{'review'}<hr></td></tr>\n<!--end-->\n<!--$in{'id'}.html--> \n";

splice (@html, $line, 1, @reply);

open (whtml, ">$reviews/$in{'id'}.html") or &error("Unable to write to $in{'id'}.html, chmod it 766.");
if ($flock eq "y") {flock whtml, 2;
}
print whtml @html;
close (whtml);
} # end if
} # end foreach

where this conflicts with what i need it to do...

Instead of having each review as part of the same table I have them set up as individual tables. When this splices the elements into the existing page it is merely adding more TDs and TRs to an existing TABLE.
I've changed the output in the other subs but when I try and change this one odd things happen, like it doesn't print /TABLEs properly.

So what I'd like to do is get rid of the splice (I think that would work) and merely print the output the same way it was printed when it prints a new HTML page.

Did that make any sense? Cause I'm lost myself...

-Norm
Quote Reply
Re: Looking for a script... In reply to
Not sure exactly what you are doing but if you want each post to be a separate table do the following.

swap lines 311 and 312 so /table is before the $in{'id'}.html html comment. This will put the first post in its own table, future posts will now get inserted between /table and $in{'id'}.html.

To be consistent put table before the start comment and /table after the end comment on line 254, @reply (to put each reply in a table).

Quote Reply
Re: Looking for a script... In reply to
In the script the layout orginally had each review posted as part of one table. But I neede to addome things to it and I wanted ach on to have its own table for my own sanity and to follow the layout of the site. Smile

I'll go give this a shot. thanks for your assistance i really appreciate it.
Quote Reply
Re: Looking for a script... In reply to
A lot could be done, e.g.background colors. Right now things are as simple as you can get. To preserve the consistency of separate tables fixed widths +/or %'s need to be added. To make it easier to read/work with you could change the code to:
Code:
@reply=("
<!--start-->
<table>
<tr><td>$by </td><td><small>$date at $time</small></td></tr>
<tr><td><!--IP: $ENV{'REMOTE_HOST'}--></td>\n<td>$in{'review'}<hr></td></tr>
</table>
<!--end-->

<!--$in{'id'}.html-->\n)";

I like consistent indenting of code but the html above must be at the margin or it will not be at the margin when written to the file (there's got to be another way). This is not a problem with the current version but will be in the next version which includes an admin delete function.
Quote Reply
Re: Looking for a script... In reply to
I got it working perfcetly, though not implmented yet it should be fine. I removed the printed headers and the footers so that when it is starting a new page there will only be the tables because I am using SSI to call and include the page outputted by the script into another page. Very configurable script! Smile

You know you should publish this one. I searche all over cgi-resources.com and scriptsearch.com and a whole bunch of others and there is nothing like this at all. it can be really useful.

Thanks again for your help.

-Norm