cvs: php-bugs-web / bug.php bugs.sql style.css util.js vote.php /gifs close.gif open.gif /include layout.inc

From: Date: Thu, 03 Jan 2002 00:22:31 +0000
Subject: cvs: php-bugs-web / bug.php bugs.sql style.css util.js vote.php /gifs close.gif open.gif /include layout.inc
Groups: php.mirrors 
Request: Send a blank email to php-mirrors+get-8031@lists.php.net to get a copy of this message
jimw Wed Jan 2 19:22:31 2002 EDT Added files: /php-bugs-web util.js vote.php /php-bugs-web/gifs close.gif open.gif Modified files: /php-bugs-web bug.php bugs.sql style.css /php-bugs-web/include layout.inc Log: bug voting.

Index: php-bugs-web/bug.php diff -u php-bugs-web/bug.php:1.6 php-bugs-web/bug.php:1.7 --- php-bugs-web/bug.php:1.6 Sat Nov 3 16:27:34 2001 +++ php-bugs-web/bug.php Wed Jan 2 19:22:31 2002 @@ -127,18 +127,93 @@ } /* DISPLAY BUG */ -if ($edit) { - echo "<form method=\"POST\" action=\"$PHP_SELF\">\n"; - echo "<input type=\"hidden\" name=\"id\" value=\"$id\">\n"; - echo "<input type=\"hidden\" name=\"edit\" value=\"$edit\">\n"; -} -if ($edit==1) - echo '<input type="hidden" name="modify" value="developer">',"\n"; -if ($edit==2) - echo '<input type="hidden" name="modify" value="user">',"\n"; ?> -<br> -<h1>Bug id #<?php echo $id?></h1> +<?php +if (!$edit) {?> +<div id="votebox"> + <div id="control"> + <div id="off"><a href="javascript:toggle_layer('votebody','votecontrol')"><img id="votecontrol" src="gifs/close.gif" border="0" width="13" height="13" alt="close" /></a></div> + <b>Voting</b> + </div> + <div id="votebody"> +<?php + $query = "SELECT COUNT(*) AS votes," + . "SUM(reproduced) AS reproduced,SUM(tried) AS tried," + . "SUM(sameos) AS sameos, SUM(samever) AS samever," + . "AVG(score) AS average,STD(score) AS deviation" + . " FROM bugdb_votes WHERE bug=$id"; + $res = @mysql_query($query); + if ($res && ($row = mysql_fetch_array($res,MYSQL_ASSOC)) && $row[votes]) { +?> + <div id="results"> + <b>Total Votes</b>: <?php echo $row['votes'];?><br /> + Reproduced: <?php printf("%d of %d (%.1f%%)",$row['reproduced'],$row['tried'],($row['reproduced']/$row['tried'])*100);?><br /> + <?php if ($row['reproduced']) {?> + Same OS: <?php printf("%d (%.1f%%)",$row['sameos'],($row['sameos']/$row['reproduced'])*100);?><br /> + Same Version: <?php printf("%d (%.1f%%)",$row['samever'],($row['samever']/$row['reproduced'])*100);?><br /> + <?php }?> + <b>Average Score</b>: <?php printf("%.1f &plusmn; %.1f", $row['average'], $row['deviation'])?><br /> + </div> +<?php + } + if (!$voted) { +?> + <form id="vote" method="POST" action="vote.php"> + <div id="reproduce"> + Have you experienced this issue?<br /> + <input type="radio" id="rep-y" name="reproduced" value="1" onclick="show('canreproduce')" /> <label for="rep-y">yes</label> + <input type="radio" id="rep-n" name="reproduced" value="0" onclick="hide('canreproduce')" /> <label for="rep-n">no</label> + <input type="radio" id="rep-d" name="reproduced" value="2" onclick="hide('canreproduce')" checked="checked" /> <label for="rep-d">don't know</label> + </div> + <div id="canreproduce" style="display: none"> + <div> + Are you using the same PHP version?<br /> + <input type="radio" id="ver-y" name="samever" value="1" /> <label for="ver-y">yes</label> + <input type="radio" id="ver-n" name="samever" value="0" checked="checked" /> <label for="ver-n">no</label> + </div> + <div> + Are you using the same operating system?<br /> + <input type="radio" id="os-y" name="sameos" value="1" /> <label for="os-y">yes</label> + <input type="radio" id="os-n" name="sameos" value="0" checked="checked" /> <label for="os-n">no</label> + </div> + </div> + <div id="score"> + Rate the importance of this bug to you:<br /> + &nbsp; <span class="score">high</span> + <input type="radio" id="score-5" name="score" value="5" /> + <input type="radio" id="score-4" name="score" value="4" /> + <input type="radio" id="score-3" name="score" value="3" checked="checked" /> + <input type="radio" id="score-2" name="score" value="2" /> + <input type="radio" id="score-1" name="score" value="1" /> + <span class="score">low</span> + </div> + <div id="submit"> + <input type="hidden" name="id" value="<?php echo $id?>" /> + <input type="submit" value="Vote" /> + </div> + </form> +<?php + } + else {?> +<div id="voted">Thanks for voting! Your vote should be reflected in the +statistics above.</div> +<?php + } +?> + </div> +</div> +<?php +} +else { /* $edit is set */ + echo "<form method=\"POST\" action=\"$PHP_SELF\">\n"; + echo "<input type=\"hidden\" name=\"id\" value=\"$id\" />\n"; + echo "<input type=\"hidden\" name=\"edit\" value=\"$edit\" />\n"; + if ($edit==1) + echo '<input type="hidden" name="modify" value="developer" />',"\n"; + if ($edit==2) + echo '<input type="hidden" name="modify" value="user" />',"\n"; +}?> +<h1>Bug #<?php echo $id?></h1> <table border="0"> <tr> <th align="right">Status:</th> @@ -253,18 +328,18 @@ /* ORIGINAL REPORT */ echo "<b><i>[$original[ts1]] $original[email]</i></b><br>\n"; -echo "<blockquote><blockquote><pre>"; +echo "<pre class=\"note\">"; echo wordwrap(addlinks($original[ldesc]),90); -echo "</pre></blockquote></blockquote>\n"; +echo "</pre>\n"; /* COMMENTS */ $query = "SELECT * FROM bugdb_comments WHERE bug=$id ORDER BY ts"; if ($comresult = mysql_query($query)) { while ($com = mysql_fetch_array($comresult)) { echo "<b><i>[$com[ts]] $com[email]</i></b><br>\n"; - echo "<blockquote><blockquote><pre>"; + echo "<pre class=\"note\">"; echo wordwrap(addlinks($com[comment]),90); - echo "</pre></blockquote></blockquote>\n"; + echo "</pre>\n"; } } Index: php-bugs-web/bugs.sql diff -u php-bugs-web/bugs.sql:1.2 php-bugs-web/bugs.sql:1.3 --- php-bugs-web/bugs.sql:1.2 Sun Sep 23 22:33:56 2001 +++ php-bugs-web/bugs.sql Wed Jan 2 19:22:31 2002 @@ -31,3 +31,14 @@ PRIMARY KEY (id), FULLTEXT (comment) ); + +CREATE TABLE bugdb_votes ( + bug int(8) NOT NULL, + ts timestamp NOT NULL, + ip int unsigned NOT NULL, + score int(3) NOT NULL, /* 1-5 */ + reproduced int(1) NOT NULL, + tried int(1) NOT NULL, + sameos int(1), + samever int(1) +); Index: php-bugs-web/style.css diff -u php-bugs-web/style.css:1.1 php-bugs-web/style.css:1.2 --- php-bugs-web/style.css:1.1 Thu Sep 20 20:59:45 2001 +++ php-bugs-web/style.css Wed Jan 2 19:22:31 2002 @@ -26,6 +26,49 @@ color: #cc0000; } +div#votebox { + float: right; + width: 200px; + font-size: smaller; +} +div#votebox div#control { + border: 1px solid #000000; + background: #cccccc; + padding: 4px; + margin-bottom: 10px; +} +div#votebox #off { + float: right; +} +div#votebox #results { + margin-bottom: 10px; + border: 1px dashed #000000; + padding: 4px; + background: #99cc99; +} +div#votebox #voted { + margin: 0px; + border: 1px dashed #000000; + padding: 4px; + background: #cc9999; +} +div#votebox form { + margin: 0px; + border: 1px dashed #000000; + padding: 4px; + background: #9999cc; +} +div#votebox form div { + margin-bottom: 5px; +} +div#votebox span.score { + font-size: smaller; +} +div#votebox #submit { + margin-top: 10px; + text-align: center; +} + .newsDate { font-size: 85%; font-style: italic; @@ -39,6 +82,10 @@ code, pre { font-family: "andale mono", "monotype.com", "courier new", monospace; font-size: 90%; +} + +pre.note { + margin-left: 20px; } h1 { Index: php-bugs-web/include/layout.inc diff -u php-bugs-web/include/layout.inc:1.6 php-bugs-web/include/layout.inc:1.7 --- php-bugs-web/include/layout.inc:1.6 Tue Oct 16 11:44:00 2001 +++ php-bugs-web/include/layout.inc Wed Jan 2 19:22:31 2002 @@ -162,6 +162,7 @@ <head> <title>PHP Bugs<?php if ($title) { echo ': '.$title; } ?></title> <link rel="stylesheet" href="style.css" /> + <script type="text/javascript" src="util.js"></script> </head> <body Index: php-bugs-web/util.js +++ php-bugs-web/util.js function show(layer) { var l = document.getElementById(layer); l.style.display = "block"; } function hide(layer) { var l = document.getElementById(layer); l.style.display = "none"; } function toggle_layer(layer,img) { var l = document.getElementById(layer); var i = document.getElementById(img); if (l.style.display == "none") { l.style.display = "block"; i.src = "gifs/close.gif"; } else { l.style.display = "none"; i.src = "gifs/open.gif"; } } Index: php-bugs-web/vote.php +++ php-bugs-web/vote.php <?php /* vim: set noet ts=4 sw=4: : */ require_once 'prepend.inc'; if (!($id = (int)$id)) { header("Location: /"); exit; } $score = (int)$score; if ($score < 1 || $score > 5) { die("invalid score: $score"); } $reproduced = (int)$reproduced; $samever = (int)$samever; $sameos = (int)$sameos; @mysql_connect("localhost","nobody","") or die("Unable to connect to SQL server."); @mysql_select_db("php3"); $ip = ip2long($HTTP_X_FORWARDED_FOR ? $HTTP_X_FORWARDED_FOR : $REMOTE_ADDR); // TODO: check if ip address has been banned. hopefully this will // never need to be implemented. // verify the bug id is real (no voting on unreported bugs! :) // add the vote $query = "INSERT INTO bugdb_votes (bug,ip,score,reproduced,tried,sameos,samever)" . " VALUES($id,$ip,$score," . ($reproduced == 1 ? "1," : "0,") . ($reproduced != 2 ? "1," : "0,") . ($reproduced ? "$sameos," : "NULL,") . ($reproduced ? "$samever" : "NULL") . ");"; mysql_query($query) or die("query <tt>$query</tt> failed: ".mysql_error()); // redirect to the bug page (which will display the success message) header("Location: bug.php?id=$id&voted=1");
« previous php.mirrors (#8031) next »