#!/usr/bin/perl use strict; use lib qw(/usr/home/web/users/a0017451/html/cgi-bin); use CGI qw(:standard escapeHTML); use AklaatDB; use AklaatUser; use AklaatDB::Session; my $ScriptLocation = "http://www.aklaat.com/cgi-bin"; my $baseurl = '../../'; my $version = '1.4.1'; my $basedir = '/usr/home/web/users/a0017451/html/'; my $usernameCookie = cookie ("aklaat_user_name"); #Include external libraries my ($count, @FileData, @temp, $name, $value, $buffer, @pairs, $pair, $allow_html, %QUERY); $count=0; if ($ENV{'REQUEST_METHOD'} eq 'POST') { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); } else { $buffer = $ENV{'QUERY_STRING'}; } @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); # Un-Webify plus signs and %-encoding $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ s///g; if ($allow_html != 1) { $value =~ s/<([^>]|\n)*>//g; } $QUERY{$name} = $value; } if($ENV{'CONTENT_LENGTH'} != 0) {GetPostData();} # if POST info was sent, put information in hash %POST ShowRecipeRate(); # Show the rating for the selected recipe ############################################################# sub ShowRecipeRate { my ($title, $submittedby, $count, $end, $line, $red, $gray, $sum, $username, $realname, $date, $comments, $ref); my $dbh = AklaatDB::connect (); $dbh->do ('SET NAMES CP1256'); $dbh->do ('SET COLLATION_CONNECTION=CP1256_GENERAL_CI'); $title = $dbh->selectrow_array ("SELECT re_title FROM recipes WHERE re_filename = '$QUERY{'filename'}'"); $submittedby = $dbh->selectrow_array ("SELECT re_submitted_by FROM recipes WHERE re_filename = '$QUERY{'filename'}'"); $end = $dbh->selectrow_array ("SELECT COUNT(*) FROM rates WHERE recipe = '$QUERY{'filename'}' GROUP BY recipe"); my $usernameCookie = AklaatDB::trim(AklaatDB::fix_quotes(cookie ("aklaat_user_name"))); my $notifyEmail = $dbh->selectrow_array ("SELECT COUNT(*) FROM notify_rates WHERE filename = '$QUERY{'filename'}' AND username = '$usernameCookie'"); my $notifyCheck; if ($notifyEmail == 0) { $notifyCheck = ""; } else { $notifyCheck = "CHECKED"; } my $sort_flag = 'false'; if ($QUERY{'asc'} eq 'true') { $sort_flag = 'false'; } elsif ($QUERY{'asc'} eq 'false') { $sort_flag = 'true'; } print "Content-type:text/html\n\n"; print< تقييم الوصفات HTMLTOP my $data_file="includes/style.htm"; open(DAT, "$basedir$data_file") || die("Could not open file!"); my @raw_data=; close(DAT); foreach $line (@raw_data) { print "$line"; } $data_file="includes/script.htm"; open(DAT, "$basedir$data_file") || die("Could not open file!"); @raw_data=; close(DAT); foreach $line (@raw_data) { print "$line"; } print< A:hover { COLOR: #cc0000; TEXT-DECORATION: underline } .recipeborder { BORDER-BOTTOM: #999933 1px solid; BORDER-LEFT: #999933 1px solid; BORDER-RIGHT: #999933 1px solid; BORDER-TOP: #999933 1px solid } .recipeborderinterior { BORDER-BOTTOM: #cccc33 1px solid; BORDER-TOP: medium none } .ratings { BORDER-BOTTOM-STYLE: none; BORDER-LEFT-STYLE: none; BORDER-RIGHT-STYLE: none; BORDER-TOP-STYLE: none; FONT-FAMILY: "Courier New", Courier, mono; FONT-SIZE: 19px; FONT-WEIGHT: bold } .ratingsT { FONT-WEIGHT: bold; FONT-SIZE: 12px; BORDER-TOP-STYLE: none; FONT-FAMILY: "Tahoma"; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BORDER-BOTTOM-STYLE: none } .arabictxt { FONT-WEIGHT: bold; FONT-SIZE: 16px; BORDER-TOP-STYLE: none; FONT-FAMILY: "Traditional Arabic"; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BORDER-BOTTOM-STYLE: none } .englishtxt { FONT-WEIGHT: bold; FONT-SIZE: 12px; BORDER-TOP-STYLE: none; FONT-FAMILY: "Tahoma"; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BORDER-BOTTOM-STYLE: none } .mnlink { COLOR: #ffffff; TEXT-DECORATION: none } .mslink { COLOR: #cc0000; TEXT-DECORATION: none } .lnlink { COLOR: #cc0000; TEXT-DECORATION: none } .lslink { COLOR: #ff3300; TEXT-DECORATION: none } .wlink { TEXT-DECORATION: none } .wslink { COLOR: #f0af21; TEXT-DECORATION: none } .wslink1 { COLOR: #cc0000; TEXT-DECORATION: none } .wnlink { COLOR: #999933; TEXT-DECORATION: none } .listhead { FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; FONT-SIZE: 11px } .A10 { FONT-FAMILY: Arial, sans-serif; FONT-SIZE: 10px } .A12 { FONT-FAMILY: Arial, Helvetica, sans-serif; FONT-SIZE: 12px } .V4 { FONT-FAMILY: 'Traditional Arabic'; FONT-SIZE: 4px } .V6 { FONT-FAMILY: 'Traditional Arabic'; FONT-SIZE: 6px } .V9 { FONT-FAMILY: 'Traditional Arabic'; FONT-SIZE: 9px } .V10pt { FONT-FAMILY: 'Traditional Arabic'; FONT-SIZE: 10px } .V10 { FONT-FAMILY: 'Tahoma'; FONT-SIZE: 11px } .V11 { FONT-FAMILY: 'Traditional Arabic'; FONT-SIZE: 11px } .V13 { FONT-FAMILY: 'Traditional Arabic'; FONT-SIZE: 13px } .V14 { FONT-FAMILY: 'Traditional Arabic'; FONT-SIZE: 14px } .V16 { FONT-FAMILY: 'Traditional Arabic'; FONT-SIZE: 16px } .V18 { FONT-FAMILY: 'Traditional Arabic'; FONT-SIZE: 18px } .V20 { FONT-FAMILY: 'Traditional Arabic'; FONT-SIZE: 20px } .V24 { FONT-FAMILY: 'Traditional Arabic'; FONT-SIZE: 24px } .F10 { FONT-SIZE: 10px } .F6 { FONT-SIZE: 6px } .INPUTTEXTNET { COLOR: #ff6600; FONT-FAMILY: 'Traditional Arabic'; FONT-SIZE: 11px; FONT-WEIGHT: bold; VERTICAL-ALIGN: middle } .INPUTTEXT { COLOR: #cc9966; FONT-FAMILY: 'Traditional Arabic'; FONT-SIZE: 11px; FONT-WEIGHT: bold; VERTICAL-ALIGN: middle } .INPUTTEXT2 { COLOR: #cc9966; FONT-FAMILY: 'Traditional Arabic'; FONT-SIZE: 11px; FONT-WEIGHT: bold } .back { BACKGROUND-COLOR: #cccc33 } .rule { BORDER-BOTTOM: #cccc33 1px solid; BORDER-LEFT: #ffffff 0px solid; BORDER-RIGHT: #ffffff 0px solid; BORDER-TOP: #ffffff 0px solid; LINE-HEIGHT: 7px; WIDTH: 100% } .ruledash { BORDER-BOTTOM: #cccc33 1px dashed; BORDER-LEFT: #ffffff 0px solid; BORDER-RIGHT: #ffffff 0px solid; BORDER-TOP: #ffffff 0px solid; LINE-HEIGHT: 7px; WIDTH: 100% } .borderside { BORDER-BOTTOM: #cccc33 0px solid; BORDER-LEFT: #cccc33 1px solid; BORDER-RIGHT: #cccc33 1px solid; BORDER-TOP: #cccc33 0px solid; PADDING-RIGHT: 6px } .highlight { BACKGROUND-COLOR: #ff3300; BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; BORDER-RIGHT: medium none; BORDER-TOP: medium none; PADDING-BOTTOM: 2px; PADDING-LEFT: 2px; PADDING-RIGHT: 2px; PADDING-TOP: 1px } HTMLTOP require "../ui/top.pl"; print<

تقيمات وتعليقات وصفة:

$title

HTMLTOP if ($submittedby ne '') { print "

"; print "مقدمة من: $submittedby

"; } print<
معدل تقييم المشتركين
عدد المقيمين: $end
تقييم السرعة
5 نجوم = سريعة التحضير
HTMLTOP $red = 0; $gray = 0; $count = 0; $sum = 0; my $sth = $dbh->prepare ("SELECT SUM( qckrating ) AS sum, COUNT( recipe ) AS count FROM rates WHERE qckrating > 0 AND recipe = '$QUERY{'filename'}' GROUP BY recipe"); $sth->execute (); while ($ref = $sth->fetchrow_hashref ()) { $sum = $ref->{sum}; $count = $ref->{count}; } if ($count != 0) { $red = AklaatDB::round($sum / $count); } $gray = 5 - $red; print ""; for($count=0; $count<$gray; $count++) { print "*"; } print ""; print ""; for($count=0; $count<$red; $count++) { print "*"; } print ""; print<
إجمالي
5 نجوم = رائعة
HTMLTOP $red = 0; $gray = 0; $count = 0; $sum = 0; $sth = $dbh->prepare ("SELECT SUM( genrating ) AS sum, COUNT( recipe ) AS count FROM rates WHERE genrating > 0 AND recipe = '$QUERY{'filename'}' GROUP BY recipe"); $sth->execute (); while ($ref = $sth->fetchrow_hashref ()) { $sum = $ref->{sum}; $count = $ref->{count}; } if ($count != 0) { $red = AklaatDB::round($sum / $count); } $gray = 5 - $red; print ""; for($count=0; $count<$gray; $count++) { print "*"; } print ""; print ""; for($count=0; $count<$red; $count++) { print "*"; } print ""; print<
تقييم حب الأطفال لها
5 نجوم = محبوبة من الأطفال
HTMLTOP $red = 0; $gray = 0; $count = 0; $sum = 0; $sth = $dbh->prepare ("SELECT SUM( kidrating ) AS sum, COUNT( recipe ) AS count FROM rates WHERE kidrating > 0 AND recipe = '$QUERY{'filename'}' GROUP BY recipe"); $sth->execute (); while ($ref = $sth->fetchrow_hashref ()) { $sum = $ref->{sum}; $count = $ref->{count}; } if ($count != 0) { $red = AklaatDB::round($sum / $count); } $gray = 5 - $red; print ""; for($count=0; $count<$gray; $count++) { print "*"; } print ""; print ""; for($count=0; $count<$red; $count++) { print "*"; } print ""; print<
تقييم السهولة
5 نجوم = سهلة التحضير
HTMLTOP $red = 0; $gray = 0; $count = 0; $sum = 0; $sth = $dbh->prepare ("SELECT SUM( easrating ) AS sum, COUNT( recipe ) AS count FROM rates WHERE easrating > 0 AND recipe = '$QUERY{'filename'}' GROUP BY recipe"); $sth->execute (); while ($ref = $sth->fetchrow_hashref ()) { $sum = $ref->{sum}; $count = $ref->{count}; } if ($count != 0) { $red = AklaatDB::round($sum / $count); } $gray = 5 - $red; print ""; for($count=0; $count<$gray; $count++) { print "*"; } print ""; print ""; for($count=0; $count<$red; $count++) { print "*"; } print ""; print<
 
لتقييم هذه الوصفة, إضغط هنا.

إرسال تنبيه عند تعليق شخص على هذه الوصفة 
 
  إعادة ترتيب عرض التعليقات حسب:  HTMLTOP if (!defined ($QUERY{'sort'})) { print ""; } elsif (($QUERY{'sort'} eq 'date') && ($QUERY{'asc'} eq 'true')) { print ""; } elsif (($QUERY{'sort'} eq 'date') && ($QUERY{'asc'} eq 'false')) { print ""; } print< التاريخ   HTMLTOP if (($QUERY{'sort'} eq 'rate') && ($QUERY{'asc'} eq 'true')) { print ""; } elsif (($QUERY{'sort'} eq 'rate') && ($QUERY{'asc'} eq 'false')) { print ""; } print< التقيم
 
HTMLTOP my $bgColor = 0; my $comment_rate = 0; my $color = ''; my $OK_CHARS = 'a-zA-Z'; my $sort_order = 'ASC'; my $sort_order_by = 'r.date'; if ($QUERY{'asc'} eq 'true') { $sort_order = 'ASC'; } elsif ($QUERY{'asc'} eq 'false') { $sort_order = 'DESC'; } if ($QUERY{'sort'} eq 'date') { $sort_order_by = 'r.date'; } elsif ($QUERY{'sort'} eq 'rate') { $sort_order_by = 'r.genrating'; } $sth = $dbh->prepare ("SELECT r.username, u.realname, date_format(r.date, '%d/%m/%Y' ) AS Rate_Date, r.comments, r.genrating FROM rates r, users u WHERE r.username = u.username AND r.recipe = '$QUERY{'filename'}' AND r.comments != '' ORDER BY $sort_order_by $sort_order "); $sth->execute (); while ($ref = $sth->fetchrow_hashref ()) { $username = $ref->{username}; $realname = $ref->{realname}; $date = $ref->{Rate_Date}; $comments = $ref->{comments}; $comment_rate = $ref->{genrating}; if ($bgColor == 0) { $color = "#ffefd5"; $bgColor = 1; } else { $color = "#ffffff"; $bgColor = 0; } print ""; print ""; print ""; print ""; print "\n"; print ""; #align the row depending on the language my $user_data = $comments; $user_data =~ s/[^$OK_CHARS]//g; if ($user_data eq '') { print ""; print "\n"; print "\n"; } print "
"; $red = $comment_rate; $gray = 5 - $red; print ""; for($count=0; $count<$gray; $count++) { print "*"; } print ""; print ""; for($count=0; $count<$red; $count++) { print "*"; } print ""; print ""; print "اسم المقيم: $realname"; print ""; print "تاريخ التقييم: $date"; print "
"; print "$comments"; } else { print ""; print "$comments"; } print "
"; require "../ui/nav.pl"; print< HTMLTOP $data_file="includes/key_press.htm"; open(DAT, "$basedir$data_file") || die("Could not open file!"); @raw_data=; close(DAT); foreach $line (@raw_data) { print "$line"; } print ""; $sth->finish (); $dbh->disconnect (); exit(0); } ############################################################# sub GetPostData { my (@pairs, $pair, $name, $value, $buffer, %POST); read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; # Change all +'s to spaces $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; # Convert all Hex back to regular characters if($QUERY{'sub'} ne 'no') { $value =~ s/\/\>/g; $value =~ s/\|/\&\#124/g; $value =~ s/\=/\&\#61/g; $value =~ s/\r/
/g; # Replace hard returns $value =~ s/\n//g; # remove newlines $value =~ s/\cM//g; # remove ^M's } $POST{$name} = $value; } }