Commit 16c7c6cc authored by David Morley's avatar David Morley

users can rate a pod

parent 0908c125
......@@ -19,6 +19,17 @@
for ($i = 0; $i < $numrows; $i++) {
$domain = $row[$i]['domain'];
$score = $row[$i]['score'];
//get ratings
$sqlforr = "SELECT rating FROM rating_comments WHERE domain = '$domain'";
$ratings = pg_query($dbh, $sqlforr);
if (!$ratings) {
die("Error in SQL query: " . pg_last_error());
}
var_dump($ratings);
//while ($rrow = pg_fetch_all($ratings)) {
//echo $rrow['rating'];
//}
//curl the header of pod with and without https
$chss = curl_init();
......
......@@ -34,5 +34,6 @@ CREATE TABLE rating_comments (
pod_id int,
rating int,
username text,
userurl text
userurl text,
date timestamp DEFAULT current_timestamp
);
\ No newline at end of file
<html><head>
<!script type="text/javascript" src="/js/jquery-1.6.4.min.js"></script>
<!script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js"></script>
<!link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
<!link rel="stylesheet" href="http://twitter.github.com/bootstrap/1.3.0/bootstrap.min.css">
<style type="text/css">
#slider { margin: 10px;width:250px;display:inline-block; }
#rating { height: 30px;width:30px; }
</style>
<script>
$(document).ready(function() {
$('#addrating').click(function() {
$('#commentform').show('slow'); $('#ratings').hide('slow');
});
$('#submitrating').click(function() {
<?php
echo "var domain = \"{$_GET['domain']}\";";
?>
$.ajax({
type: "POST",
url: "saverating.php",
data: "username="+$('#username').val()+"&userurl="+$('#userurl').val()+"&comment="+$('#comment').val()+"&rating="+$('#rating').val()+"&domain="+domain,
success: function(msg){
if (msg == 1) {
$("#commentform").replaceWith("<h3>Your comment was saved, Thank You!</h3>");
} else {$('#errortext').html(msg);$('#error').slideDown(633).delay(2500).slideUp(633);}
}
});
});
$("#slider").slider({ animate: true, max: 10, min: 1, step: 1, value: 10, stop: function(event, ui) {
var value = $( "#slider" ).slider( "option", "value" );
$("#rating").prop( "value", value )
......@@ -18,7 +33,7 @@ $("#rating").prop( "value", value )
</script>
</head>
<body>
<div style="height:500px;width:900px">
<div style="height:500px;width:900px;">
<?php
include('db/config.php');
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
......@@ -34,24 +49,27 @@ $("#rating").prop( "value", value )
die("Error in SQL query: " . pg_last_error());
}
$numrows = pg_num_rows($result);
echo "<h2>".$_GET["domain"]."</h2>";
echo "<h3>".$_GET["domain"]." ratings</h3><div id='ratings'><input id='addrating' class='btn primary' type='submit' value='Add a Rating'><hr>";
if (!$numrows) {echo "<b>This pod has no rating yet!</b>";}
while ($row = pg_fetch_array($result)) {
if ($row["admin"] == 1) {
echo "Poduptime Comment - User: <b>".$row["username"]."</b> Url: <a href='".$row["userurl"]."'>".$row["userurl"]."</a> Rating: <b>".$row["rating"]."</b> <br>";
echo "<i>".$row["comment"]."</i><br><br>";
echo "<i>".$row["comment"]."</i><hr><br>";
} elseif ($row["admin"] == 0) {
echo "Poduptime Comment - User: <b>".$row["username"]."</b> Url: <a href='".$row["userurl"]."'>".$row["userurl"]."</a> Rating: <b>".$row["rating"]."</b> <br>";
echo "<i>".$row["comment"]."</i><br><br>";
echo "User Comment - User: <b>".$row["username"]."</b> Url: <a href='".$row["userurl"]."'>".$row["userurl"]."</a> Rating: <b>".$row["rating"]."</b> <br>";
echo "<i>".$row["comment"]."</i><hr><br>";
}
}
echo <<<EOF
<div id="commentform">
</div>
<div id="commentform" style="display:none">
Would you like to add a comment? (diaspora login comming)<br>
Your Name (or Diaspora handle)?<br><input name="username"><br>
Comment<br><textarea name="comments"></textarea><br>
Your Name (or Diaspora handle)?<br><input id="username" name="username"><br>
Your Profile URL?<br><input id="userurl" name="userurl"><br>
Comment<br><textarea id="comment" name="comment"></textarea><br>
Rating (1-10 scale, 10 high)<br><div id="slider"></div><input class="disabled" disabled="" id="rating" name="rating" value="10">
<input class="btn primary" type="submit" value="Submit your Rating">
<input class="btn primary" id="submitrating" type="submit" value="Submit your Rating">
<div class="alert-message warning" id="error" style="display:none"><span id="errortext">Some Error</span></div>
</div>
EOF;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment