cvs: php-bugs-web / bug.php logout.php report.php style.css util.js vote.php /include functions.inc

From: Date: Wed, 09 Jan 2002 01:02:10 +0000
Subject: cvs: php-bugs-web / bug.php logout.php report.php style.css util.js vote.php /include functions.inc
Groups: php.mirrors 
Request: Send a blank email to php-mirrors+get-8148@lists.php.net to get a copy of this message
jimw Tue Jan 8 20:02:10 2002 EDT Added files: /php-bugs-web logout.php Modified files: /php-bugs-web bug.php report.php style.css util.js vote.php /php-bugs-web/include functions.inc Log: new bug viewing/editing form. some accompanying changes to the bug reporting page to deal with new operation of the form validation function.

Index: php-bugs-web/bug.php diff -u php-bugs-web/bug.php:1.16 php-bugs-web/bug.php:1.17 --- php-bugs-web/bug.php:1.16 Fri Jan 4 03:57:50 2002 +++ php-bugs-web/bug.php Tue Jan 8 20:02:08 2002 @@ -4,28 +4,29 @@ header("Location: /"); exit; } +$edit = (int)$edit; require_once 'prepend.inc'; require_once 'cvs-auth.inc'; if (isset($save) && isset($pw)) { # non-developers don't have $user set - setcookie("MAGIC_COOKIE",base64_encode("$user:$pw"),time()+3600*24*12,'/'); + setcookie("MAGIC_COOKIE", + base64_encode("$user:$pw"), + time()+3600*24*12, + '/','.php.net'); } if (isset($MAGIC_COOKIE) && !isset($user) && !isset($pw)) { list($user,$pw) = explode(":", base64_decode($MAGIC_COOKIE)); } -$mail_bugs_to = "php-dev@lists.php.net"; - -commonHeader("Bug Reporting"); - @mysql_connect("localhost","nobody","") or die("Unable to connect to SQL server."); @mysql_select_db("php3"); -# fetch info about the bug into $original +# fetch info about the bug into $bug $query = "SELECT id,bug_type,email,passwd,sdesc,ldesc," . "php_version,php_os,status,ts1,ts2,dev_id,assign," + . "UNIX_TIMESTAMP(ts1) AS submitted, UNIX_TIMESTAMP(ts2) AS modified," . "COUNT(bug=id) AS votes," . "SUM(reproduced) AS reproduced,SUM(tried) AS tried," . "SUM(sameos) AS sameos, SUM(samever) AS samever," @@ -35,314 +36,477 @@ $res = mysql_query($query); -if ($res) $original = mysql_fetch_array($res); -if (!$res || !$original) { +if ($res) $bug = mysql_fetch_array($res,MYSQL_ASSOC); +if (!$res || !$bug) { + commonHeader("No such bug."); echo "<h1 class=\"error\">No such bug #$id!</h1>"; commonFooter(); exit; } # handle any updates, displaying errors if there were any -$success = 0; +$success = !isset($in); +$errors = array(); + +if ($in && $edit == 3) { + if (!preg_match("/[.\\w+-]+@[.\\w-]+\\.\\w{2,}/i",$in['email'])) { + $errors[] = "You must provide a valid email address."; + } -if ($modify == "user") { - if (!$original[passwd] || $original[passwd] != stripslashes($pw)) { - echo "<h2 class=\"error\">The password you supplied was incorrect.</h2>\n"; + $ncomment = trim($ncomment); + if (!$ncomment) { + $errors[] = "You must provide a comment."; + } + + if (!$errors) { + $query = "INSERT INTO bugdb_comments (bug,email,ts,comment) VALUES" + . " ('$id','$in[email]',NOW(),'$ncomment')"; + $success = @mysql_query($query); + } + $from = stripslashes($in['email']); +} +elseif ($in && $edit == 2) { + if (!$bug[passwd] || $bug[passwd] != stripslashes($pw)) { + $errors[] = "The password you supplied was incorrect."; } - elseif (incoming_details_are_valid()) { + elseif (!($errors = incoming_details_are_valid($in))) { /* update bug record */ - $success = @mysql_query("UPDATE bugdb SET status='$status', bug_type='$bug_type', php_version='$php_version', php_os='$php_os', ts2=NOW(), email='$email' WHERE id=$id"); + $query = "UPDATE bugdb SET status='$in[status]', bug_type='$in[bug_type]', php_version='$in[php_version]', php_os='$in[php_os]', ts2=NOW(), email='$in[email]' WHERE id=$id"; + $success = @mysql_query($query); /* add comment */ if ($success && !empty($ncomment)) { - $success = @mysql_query("INSERT INTO bugdb_comments (bug, email, ts, comment) VALUES ($id,'$email',NOW(),'$ncomment')"); + $query = "INSERT INTO bugdb_comments (bug, email, ts, comment) VALUES ($id,'$in[email]',NOW(),'$ncomment')"; + $success = @mysql_query($query); } } - $from = $email; + $from = stripslashes($in['email']); } -elseif ($modify == "developer") { +elseif ($in && $edit == 1) { if (!verify_password($user,stripslashes($pw))) { - echo "<h2 class=\"error\">The username or password you supplied was incorrect.</h2>\n"; + $errors[] = "The username or password you supplied was incorrect."; } - elseif (incoming_details_are_valid()) { - $success = @mysql_query("UPDATE bugdb SET sdesc='$sdesc',status='$status', bug_type='$bug_type', assign='$assign', dev_id='$user', php_version='$php_version', php_os='$php_os', ts2=NOW() WHERE id=$id"); + elseif (!($errors = incoming_details_are_valid($in))) { + $query = "UPDATE bugdb SET sdesc='$in[sdesc]',status='$in[status]', bug_type='$in[bug_type]', assign='$in[assign]', dev_id='$in[user]', php_version='$in[php_version]', php_os='$in[php_os]', ts2=NOW() WHERE id=$id"; + $success = @mysql_query($query); if ($success && !empty($ncomment)) { - $success = @mysql_query("INSERT INTO bugdb_comments (bug, email, ts, comment) VALUES ($id,'$user@php.net',NOW(),'$ncomment')"); + $query = "INSERT INTO bugdb_comments (bug, email, ts, comment) VALUES ($id,'$user@php.net',NOW(),'$ncomment')"; + $success = @mysql_query($query); } } $from = "$user@php.net"; } -if ($modify && $success) { - # mail out the updated bug - $text = "ID: $id\n"; - if ($modify == "developer") { - $text .= "Updated by: $user\n"; - } - else { - $text .= "User updated by: $email\n"; - } - - $text.= "Reported By: $original[email]\n"; - - if (stripslashes($sdesc) != $original[sdesc]) - $text .= "Old Summary: $original[sdesc]\n"; - - if ($status!=$original[status]) - $text .= "Old Status: $original[status]\n"; - $text.= "Status: $status\n"; +if ($in && !$errors && $success) { + $text = array(); - if ($bug_type != $original[bug_type]) - $text .= "Old Bug Type: $original[bug_type]\n"; - $text.= "Bug Type: $bug_type\n"; + $text[] = "ID: $id"; - if ($php_os != $original[php_os]) - $text .= "Old Operating System: $original[php_os]\n"; - $text.= "Operating System: $php_os\n"; + switch ($edit) { + case 3: + $text[] = "Comment by: ".rinse($in['email']); + break; + case 2: + $text[] = "User updated by: ".txfield('email'); + break; + default: + $text[] = "Updated by: $user"; + } - if ($php_version != $original[php_version]) - $text .= "Old PHP Version: $original[php_version]\n"; - $text.= "PHP Version: $php_version\n"; + if (changed('sdesc')) + $text[] = "Old Summary: $bug[sdesc]"; - if ($assign != $original[assign]) - $text .= "Old Assigned To: $original[assign]\n"; - if ($assign || $original[assign]) - $text.= "Assigned To: $assign\n"; + $fields = array( + 'email' => 'Reported By', + 'status' => 'Status', + 'bug_type' => 'Bug Type', + 'php_os' => 'Operating System', + 'php_version' => 'PHP Version', + 'assign' => 'Assigned To', + ); + + foreach ($fields as $name => $desc) { + if (changed($name)) { + $text[] = "Old $desc: $bug[$name]"; + } + /* only fields that are set get added. */ + if ($f = txfield($name)) + $text[] = "$desc: $f"; + } if ($ncomment) - $text .= "New Comment:\n\n".stripslashes($ncomment); + $text[] = "New Comment:\n\n".stripslashes($ncomment); - $text.= get_old_comments($id); + $text[] = get_old_comments($id); - $user_text = "\n\nATTENTION! Do NOT reply to this email!\n"; - $user_text.= "To reply, use the web interface found at http://bugs.php.net/?id=$id&edit=2\n\n\n$text"; + $user_text = "ATTENTION! Do NOT reply to this email!\n"; + $user_text .= "To reply, use the web interface found at http://bugs.php.net/?id=$id&edit=2\n\n\n"; + $user_text .= join("\n",$text); - $dev_text .= $text . "\n\nEdit this bug report at http://bugs.php.net/?id=$id&edit=1\n"; - - list($mailto,$mailfrom) = get_bugtype_mail($bug_type); + $dev_text = join("\n",$text) + . "\n\nEdit this bug report at http://bugs.php.net/?id=$id&edit=1\n"; /* format mail so it looks nice */ $user_text = wordwrap($user_text, 72); /* use 72 to make piners happy */ - $dev_text = wordwrap($dev_text, 72); + $dev_text = wordwrap($dev_text, 72); + + list($mailto,$mailfrom) = get_bugtype_mail($bug_type); /* send mail if status was changed or there is a comment */ - if ($status != $original[status] || $ncomment != "") { - @mail($original[email], "Bug #$id Updated: ".stripslashes($sdesc), $user_text, "From: Bug Database <$mailfrom>\nX-PHP-Bug: $id\nIn-Reply-To: <bug-$id@bugs.php.net>"); - @mail($mailto, "Bug #$id Updated: ".stripslashes($sdesc), $dev_text, "From: $from\nX-PHP-Bug: $id\nIn-Reply-To: <bug-$id@bugs.php.net>"); + if ($status != $bug[status] || $ncomment != "") { + @mail($bug[email], + "Bug #$id Updated: ".txfield('sdesc'), + $user_text, + "From: Bug Database <$mailfrom>\n". + "X-PHP-Bug: $id\n". + "In-Reply-To: <bug-$id@bugs.php.net>"); + @mail($mailto, + "Bug #$id Updated: ".txfield('sdesc'), + $dev_text, + "From: $from\n". + "X-PHP-Bug: $id\n". + "In-Reply-To: <bug-$id@bugs.php.net>"); } - # display a happy success message - echo "<h2>Bug #$id updated successfully.</h2>\n"; - - unset($ncomment); -} -elseif ($modify && !$success) { - echo "<h2 class=\"error\">Something went wrong updating the database.</h2>"; + header("Location: $PHP_SELF?id=$id&thanks=$edit"); + exit; } +commonHeader("#$id: ".htmlspecialchars($bug['sdesc'])); + /* DISPLAY BUG */ -?> -<div id="votebox"> - <div id="control"> - <div id="off"><a href="javascript:toggle_layer('votebody','votecontrol')"><img id="votecontrol" src="gifs/<?php echo $edit ? "open" : "close"?>.gif" border="0" width="13" height="13" alt="close" /></a></div> - <b>Voting</b> - </div> - <div id="votebody"<?php if ($edit) echo ' style="display:none"';?>> +if ($thanks == 1 || $thanks == 2) { + echo '<div class="thanks">The bug was updated successfully.</div>'; +} +elseif ($thanks == 3) { + echo '<div class="thanks">Your comment was added to the bug successfully.</div>'; +} +elseif ($thanks == 4) {?> +<div class="thanks"> +Thank you for your help! If the status of the bug report you submitted changes, +you will be notified. You may return here and check on the status or update +your report at any time. That URL for your bug report is: <a +href="http://bugs.php.net/<?php echo $id?>">http://bugs.php.net/<?php echo +$id?></a>. +</div> +<?php +} +elseif ($thanks == 6) {?> +<div class="thanks"> +Thanks for voting! Your vote should be reflected in the +statistics below. +</div> <?php - if ($original['votes']) { +} ?> - <div id="results"> - <b>Total Votes</b>: <?php echo $original['votes'];?><br /> - Reproduced: <?php printf("%d of %d (%.1f%%)",$original['reproduced'],$original['tried'],$original['$tried']?(($original['reproduced']/$original['tried'])*100):0);?><br /> - <?php if ($original['reproduced']) {?> - Same OS: <?php printf("%d (%.1f%%)",$original['sameos'],($original['sameos']/$original['reproduced'])*100);?><br /> - Same Version: <?php printf("%d (%.1f%%)",$original['samever'],($original['samever']/$original['reproduced'])*100);?><br /> - <?php }?> - <b>Average Score</b>: <?php printf("%.1f &plusmn; %.1f", $original['average'], $original['deviation'])?><br /> - </div> + +<div id="bugheader"> + <table id="details"> + <tr id="title"> + <th id="number">Bug&nbsp;#<?php echo $id?></th> + <td id="summary" colspan="5"><?php echo htmlspecialchars($bug['sdesc'])?></td> + </tr> + <tr id="submission"> + <th>Submitted:</th><td><?php echo format_date($bug['submitted'])?></td> +<?php if ($bug['modified']) {?> + <th>Modified:</th><td> <?php echo format_date($bug['modified'])?></td> +<?php }?> + </tr> + <tr id="submitter"> + <th>From:</th><td><?php echo htmlspecialchars($bug['email'])?></td> + </tr> + <tr id="categorization"> + <th>Status:</th><td><?php echo htmlspecialchars($bug['status'])?></td> +<?php/* <th>Type:</th><td><?php echo htmlspecialchars($bug['type'])?></td> */?> + <th>Category:</th><td colspan="3"><?php echo htmlspecialchars($bug['bug_type'])?></td> + </tr> + <tr id="situation"> + <th>Version:</th><td><?php echo htmlspecialchars($bug['php_version'])?></td> + <th>OS:</th><td colspan="3"><?php echo htmlspecialchars($bug['php_os'])?></td> + </tr> + +<?php if ($bug['votes']) {?> + <tr id="votes"> + <th>Votes:</th><td><?php echo $bug['votes'];?></td> + <th>Avg. Score:</th><td><?php printf("%.1f &plusmn; %.1f", $bug['average'], $bug['deviation'])?></td> + <th>Reproduced:</th><td><?php printf("%d of %d (%.1f%%)",$bug['reproduced'],$bug['tried'],$bug['tried']?($bug['reproduced']/$bug['tried'])*100:0);?></td> + </tr> +<?php if ($bug['reproduced']) {?> + <tr id="reproduced"> + <td colspan="2"></td> + <th>Same Version:</th><td><?php printf("%d (%.1f%%)",$bug['samever'],($bug['samever']/$bug['reproduced'])*100);?></td> + <th>Same OS:</th><td><?php printf("%d (%.1f%%)",$bug['sameos'],($bug['sameos']/$bug['reproduced'])*100);?></td> + </tr> +<?php }?> +<?php }?> +</table> + + </div> +</div> + +<div id="controls"> <?php - } - if (!$voted) { +function control($num,$desc) { + $active = ($GLOBALS['edit'] == $num); + echo "<span id=\"control_$num\" class=\"control", ($active ? ' active' : ''), "\">", + !$active ? "<a href=\"$PHP_SELF?id=$GLOBALS[id]".($num ? "&amp;edit=$num" : "")."\">" : "", + $desc, !$active ? "</a>" : "", "</span> "; +} + +control(0,'View/Vote'); +control(3,'Add Comment'); +control(1,'Developer'); +control(2,'Edit Submission'); ?> - <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="2" /> - <input type="radio" id="score-4" name="score" value="1" /> - <input type="radio" id="score-3" name="score" value="0" checked="checked" /> - <input type="radio" id="score-2" name="score" value="-1" /> - <input type="radio" id="score-1" name="score" value="-2" /> - <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> +</div> +<br clear="all" /> + <?php - } - else {?> -<div id="voted">Thanks for voting! Your vote should be reflected in the -statistics above.</div> +if ($errors) { + echo '<div class="errors">'; + if (count($errors) > 1) { + echo "You need to do the following before your submission will be accepted:<ul>"; + foreach ($errors as $error) { + echo "<li>$error</li>\n"; + } + echo "</ul>"; + } + else { + echo $errors[0]; + } + echo '</div>'; +} +if (!$errors && !$success) {?> +<div class="errors"> +Some sort of database error has happened. Maybe this will be illuminating: +<?php echo mysql_error();?> This was the last query attempted: <tt><?php echo htmlspecialchars($query)?></tt> +</div> <?php - } +} ?> - </div> + +<?php if ($edit == 1 || $edit == 2) {?> +<form id="update" action="<?php echo $PHP_SELF?>" method="post"> +<?php +if ($edit == 2) { + if (!$in && $pw && $bug['passwd'] && stripslashes($pw)==$bug['passwd']) {?> +<div class="explain"> +Welcome back! Since you opted to store your bug's password in a cookie, you can +just go ahead and add more information to this bug or edit the other fields. </div> <?php -if ($edit) { /* $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> -<?php if ($edit) {?> -<td><select name="status"><?php show_state_options($status,$edit,$original[status])?></select> -<?php if ($edit == 1) {?> -<b>Assign To:</b> <input type="text" name="assign" size="10" maxlength="16" value="<?php echo $assign ? htmlspecialchars(stripslashes($assign)) : htmlspecialchars($original[assign])?>"> <input type="submit" value="Submit Changes"></td> - <small><a href="<?php echo "$PHP_SELF?id=$id";?>&amp;edit=2"><tt>User Modify</tt></a></small></td> -<?php } else { ?> - <small><a href="<?php echo "$PHP_SELF?id=$id";?>&amp;edit=1"><tt>Dev Modify</tt></a></small></td> -<?php }?> -<?php } else { ?> -<td><?php echo $original[status]?></td> -<td><td><small><a href="<?php echo "$PHP_SELF?id=$id";?>&amp;edit=2"><tt>User Modify</tt></a><br /> - <a href="<?php echo "$PHP_SELF?id=$id";?>&amp;edit=1"><tt>Dev Modify</tt></a></small></td> -<?php }?> -</tr> -<tr> -<th align="right">From:</th> -<?php if ($edit) {?> -<td><input type="text" name="email" size="20" maxlength="40" value="<?php echo $email ? htmlspecialchars(stripslashes($email)) : htmlspecialchars($original[email])?>"></td> -<?php } else { ?> -<td><?php echo $original[email]?></td> -<?php }?> -</tr> -<tr> -<th align="right">Reported:</th> -<td><?php echo $original[ts1]?></td> -</tr> -<tr> -<th align="right">Type:</th> -<?php if ($edit) {?> -<td><select name="bug_type"><?php show_types($bug_type,0,$original[bug_type])?></select></td> -<?php } else { ?> -<td><?php echo $original[bug_type]?></td> + } + else {?> +<div class="explain"> +<?php if (!$in) {?> +Welcome back! If you're the original bug submitter, here's where you can edit +the bug or add additional notes. If this is not your bug, you can <a +href="<?php echo "$PHP_SELF?id=$id&amp;edit=3"?>">add a comment by following +this link</a> or the box above that says 'Add Comment'. If this is your bug, +but you forgot your password, <a href="bug-pwd-finder.php">you can retrieve +your password here</a>. <?php }?> -</tr> -<tr> -<th align="right">OS:</th> -<?php if ($edit) {?> -<td><input type="text" name="php_os" size="20" maxlength="32" value="<?php echo $php_os ? htmlspecialchars(stripslashes($php_os)) : htmlspecialchars($original[php_os])?>"></td> -<?php } else { ?> -<td><?php echo $original[php_os]?></td> +<table> + <tr> + <th>Password:</th> + <td><input type="password" name="pw" value="<?php echo clean($pw)?>" size="10" maxlength="20" /></td> + <th> + <label for="save">Check to remember your password for next time:</label> + </th> + <td> + <input type="checkbox" id="save" name="save"<?php if ($save) echo ' checked="checked"'?> /> + </td> + </tr> +</table> +</div> +<?php + } +} +else { + if ($user && $pw && verify_password($user,stripslashes($pw))) { + if (!$in) {?> +<div class="explain"> +Welcome back, <?php echo $user?>! (Not <?php echo $user?>? <a href="logout.php">Log out.</a>) +</div> +<?php + } + } + else {?> +<div class="explain"> +<?php if (!$in) {?> +Welcome! If you don't have a CVS account, you can't do anything here. You can +<a href="<?php echo "$PHP_SELF?id=$id&amp;edit=3"?>">add a comment by following +this link</a> or if you reported this bug, you can <a href="<?php echo +"$PHP_SELF?id=$id&amp;edit=2"?>">edit this bug over here</a>. <?php }?> -</tr> -<tr> -<th align="right">PHP Version:</th> -<?php if ($edit) {?> -<td><input type="text" name="php_version" size="20" maxlength="100" value="<?php echo $php_version ? htmlspecialchars(stripslashes($php_version)) : htmlspecialchars($original[php_version])?>"></td> -<?php } else { ?> -<td><?php echo $original[php_version]?></td> +<table> + <tr> + <th>CVS Username:</th> + <td><input type="text" name="user" value="<?php echo clean($user)?>" size="10" maxlength="20" /></td> + <th>CVS Password:</th> + <td><input type="password" name="pw" value="<?php echo clean($pw)?>" size="10" maxlength="20" /></td> + <th> + <label for="save">Remember:</label> + </th> + <td> + <input type="checkbox" id="save" name="save"<?php if ($save) echo ' checked="checked"'?> /> + </td> + </tr> +</table> +</div> +<?php + } +} +?> +<table> + <tr> + <th>Status:</th> + <td><select name="in[status]"><?php show_state_options($in['status'],$edit,$bug['status'])?></select></td> +<?php if ($edit ==1) {?> + <th>Assign to:</th> + <td><input type="text" size="10" maxlength="16" name="in[assign]" value="<?php echo field('assign')?>" /></td> <?php }?> -</tr> -<?php if ($original[assign] && !$edit) {?> -<tr> -<th align="right">Assigned To:</th> -<td><?php echo $original[assign]?></td> -</tr> + <td><input type="hidden" name="id" value="<?php echo $id?>" /><input type="hidden" name="edit" value="<?php echo $edit?>" /><input type="submit" value="Submit" /></td> + </tr> + <tr> + <th>Category:</th> + <td colspan="3"><select name="in[bug_type]"><?php show_types($in['bug_type'],0,$bug['bug_type'])?></select></td> +<?php /* severity goes here. */ ?> + </tr> + <tr> + <th>Summary:</th> + <td colspan="5"><input type="text" size="60" maxlength="80" name="in[sdesc]" value="<?php echo field('sdesc')?>" /></td> + </tr> + <tr> + <th>From:</th> + <td colspan="5"><input type="text" size="40" maxlength="40" name="in[email]" value="<?php echo field('email')?>" /></td> + </tr> + <tr> + <th>Version:</th> + <td><input type="text" size="20" maxlength="32" name="in[php_version]" value="<?php echo field('php_version')?>" /></td> + <th>OS:</th> + <td colspan="3"><input type="text" size="20" maxlength="100" name="in[php_os]" value="<?php echo field('php_os')?>" /></td> + </tr> +</table> +<b>New Comment:</b><br /> +<textarea cols="60" rows="8" name="ncomment" wrap="physical"><?php echo clean($ncomment)?></textarea> +<br /><input type="submit" value="Submit" /> +</form> <?php }?> -<tr> -<th align="right">Summary:</th> -<?php if ($edit) {?> -<td><input type="text" name="sdesc" size="40" maxlength="80" value="<?php echo $sdesc ? htmlspecialchars(stripslashes($sdesc)) : htmlspecialchars($original[sdesc])?>"></td> -<?php } else { ?> -<td><?php echo $original[sdesc]?></td> +<?php if ($edit == 3) {?> +<form id="comment" action="<?php echo $PHP_SELF?>" method="post"> +<?php if (!$in) {?> +<div class="explain"> +Anyone can comment on a bug. Have a simpler test case? Does it work for you on +a different platform? Let us know! Just going to say 'Me too!'? Don't clutter +the database with that &mdash; but make sure to <a href="<?php echo "$PHP_SELF?id=$id"?>">vote on the bug</a>! +</div> <?php }?> -</tr> -</table> -<?php if ($edit) {?> -<b>New Comment:</b> -<textarea name="ncomment" wrap="physical" cols="60" rows="15"><?php echo htmlspecialchars(stripslashes($ncomment));?></textarea> <table> -<?php if ($edit == 1) { /* developer */?> -<tr> -<th align="right">CVS Username:</th> -<td> -<input type="text" name="user" size="10" maxlength="20" value="<?php echo htmlspecialchars(stripslashes($user));?>"> -</td> -</tr> -<?php }?> -<tr> -<th align="right">Password:</th> -<td> -<input type="password" name="pw" size="10" maxlength="20" value="<?php echo htmlspecialchars(stripslashes($pw));?>"> -<?php if ($edit == 2) {?> -[<a href="bug-pwd-finder.php">Lost your password?</a>] -<?php }?> -</td> -</tr> -<tr> -<th align="right">Remember me:</th> -<td> -<input type="checkbox" name="save"> -(Check here to remember your password for next time.) -</td> -</tr> -<tr> -<td colspan="2"> -&nbsp; &nbsp; &nbsp; -<input type="submit" value="Submit Changes"> -</td> -</tr> + <tr> + <th>Your email address:</th> + <td><input type="text" size="40" maxlength="40" name="in[email]" value="<?php echo clean($in['email'])?>" /></td> + <td><input type="hidden" name="id" value="<?php echo $id?>" /><input type="hidden" name="edit" value="<?php echo $edit?>" /><input type="submit" value="Submit" /></td> + </tr> </table> +<div> + <textarea cols="60" rows="10" name="ncomment" wrap="physical"><?php echo clean($ncomment);?></textarea> + <br /><input type="submit" value="Submit" /> +</div> +</form> <?php }?> -<?php -if ($edit) echo "</form>\n"; - -echo hdelim(); +<?php if (!$edit && $thanks != 6 && $bug['status'] != "Closed" && $bug['status'] != "Bogus" && $bug['status'] != 'Duplicate') {?> + <form id="vote" method="post" action="vote.php"> + <div> + <fieldset> + <legend>Have you experienced this issue?</legend> + <div> + <input type="radio" id="rep-y" name="reproduced" value="1" onchange="show('canreproduce')" /> <label for="rep-y">yes</label> + <input type="radio" id="rep-n" name="reproduced" value="0" onchange="hide('canreproduce')" /> <label for="rep-n">no</label> + <input type="radio" id="rep-d" name="reproduced" value="2" onchange="hide('canreproduce')" checked="checked" /> <label for="rep-d">don't know</label> + </div> + </fieldset> + <fieldset> + <legend>Rate the importance of this bug to you:</legend> + <div> + <label for="score-5">high</label> + <input type="radio" id="score-5" name="score" value="2" /> + <input type="radio" id="score-4" name="score" value="1" /> + <input type="radio" id="score-3" name="score" value="0" checked="checked" /> + <input type="radio" id="score-2" name="score" value="-1" /> + <input type="radio" id="score-1" name="score" value="-2" /> + <label for="score-1">low</label> + </div> + </fieldset> + </div> + <div id="canreproduce" style="display: none"> + <fieldset> + <legend>Are you using the same PHP version?</legend> + <div> + <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> + </fieldset> + <fieldset> + <legend>Are you using the same operating system?</legend> + <div> + <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> + </fieldset> + </div> + <div id="submit"> + <input type="hidden" name="id" value="<?php echo $id?>" /> + <input type="submit" value="Vote" /> + </div> + </form> + <br clear="all" /> +<?php } /* ORIGINAL REPORT */ -echo "<b><i>[$original[ts1]] $original[email]</i></b><br>\n"; -echo "<pre class=\"note\">"; -echo wordwrap(addlinks($original[ldesc]),90); -echo "</pre>\n"; +if ($bug['ldesc']) + output_note($bug['submitted'], $bug['email'], $bug['ldesc']); /* 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 "<pre class=\"note\">"; - echo wordwrap(addlinks($com[comment]),90); - echo "</pre>\n"; +$query = "SELECT email,comment,UNIX_TIMESTAMP(ts) AS added" + . " FROM bugdb_comments WHERE bug=$id ORDER BY ts"; +$res = @mysql_query($query); +if ($res) { + while ($row = mysql_fetch_array($res,MYSQL_ASSOC)) { + output_note($row['added'], $row['email'], $row['comment']); } } commonFooter(); + +function changed($n) { + return $GLOBALS['in'][$n] + && trim($GLOBALS['in'][$n]) != trim($GLOBALS['bug'][$n]); +} + +function field($n) { + return oneof(clean($GLOBALS['in'][$n]), + htmlspecialchars($GLOBALS['bug'][$n])); +} + +function txfield($n) { + return oneof(rinse($GLOBALS['in'][$n]), + $GLOBALS['bug'][$n]); +} + +function format_date($date) { + if (date("Y") != date("Y", $date)) { + return date("j M Y g:ia", $date); + } + return date("j M g:ia", $date); +} + +function output_note($ts,$email,$comment) { + echo "<div class=\"comment\">"; + echo "<b>[",format_date($ts),"] ",htmlspecialchars($email), + "</b>\n"; + echo "<pre class=\"note\">"; + echo addlinks(preg_replace("/(\r?\n){3,}/","\n\n",wordwrap($comment,72,"\n",1))); + echo "</pre>\n"; + echo "</div>"; +} Index: php-bugs-web/report.php diff -u php-bugs-web/report.php:1.6 php-bugs-web/report.php:1.7 --- php-bugs-web/report.php:1.6 Mon Oct 22 17:12:55 2001 +++ php-bugs-web/report.php Tue Jan 8 20:02:09 2002 @@ -17,31 +17,36 @@ or die("Unable to connect to SQL server."); @mysql_select_db("php3"); -if ($cmd == "send") { - if (incoming_details_are_valid(1,1)) { - $ret = mysql_query("INSERT INTO bugdb (bug_type,email,sdesc,ldesc,php_version,php_os,status,ts1,passwd) VALUES ('$bug_type','$email','$sdesc','$ldesc','$php_version','$php_os','Open',NOW(),'$passwd')"); +$errors = array(); +if ($in) { + if (!($errors = incoming_details_are_valid($in,1))) { + $query = "INSERT INTO bugdb (bug_type,email,sdesc,ldesc,php_version,php_os,status,ts1,passwd) VALUES ('$in[bug_type]','$in[email]','$in[sdesc]','$in[ldesc]','$in[php_version]','$in[php_os]','Open',NOW(),'$in[passwd]')"; + $ret = mysql_query($query); $cid = mysql_insert_id(); $report = ""; - $report .= "From: $email\n"; - $report .= "Operating system: $php_os\n"; - $report .= "PHP version: $php_version\n"; - $report .= "PHP Bug Type: $bug_type\n"; + $report .= "From: ".stripslashes($in['email'])."\n"; + $report .= "Operating system: ".stripslashes($in['php_os'])."\n"; + $report .= "PHP version: ".stripslashes($in['php_version'])."\n"; + $report .= "PHP Bug Type: $in[bug_type]\n"; $report .= "Bug description: "; - $ldesc = stripslashes($ldesc); - $sdesc = stripslashes($sdesc); + $ldesc = stripslashes($in['ldesc']); + $sdesc = stripslashes($in['sdesc']); $ascii_report = "$report$sdesc\n\n".wordwrap($ldesc); $ascii_report.= "\n-- \nEdit bug report at: http://bugs.php.net/?id=$cid&edit="; - list($mailto,$mailfrom) = get_bugtype_mail($bug_type); + list($mailto,$mailfrom) = get_bugtype_mail($in['bug_type']); + + $email = stripslashes($in['email']); if (mail($mailto, "Bug #$cid: $sdesc", $ascii_report."1\n", "From: $email\nX-PHP-Bug: $cid\nMessage-ID: <bug-$cid@bugs.php.net>")) { @mail($email, "Bug #$cid: $sdesc", $ascii_report."2\n", "From: PHP Bug Database <$mailfrom>\nX-PHP-Bug: $cid\nMessage-ID: <bug-$cid@bugs.php.net>"); - header("Location: report.php?cmd=thankyou&cid=$cid&mailto=".urlencode($mailto)); + header("Location: bug.php?id=$cid&thanks=4"); + exit; } else { @@ -62,18 +67,11 @@ "<a href=\"mailto:$mailto\">$mailto</a> manually.</p>\n"; } } -} elseif ($cmd == 'thankyou') { - commonHeader("Report - Thank you"); - - echo "<p><h2>Mail sent to $mailto...</h2></p>\n"; - echo "<p>Thank you for your help!</p>"; - echo "If the status of the bug report you submitted\n"; - echo "changes, you will be notified. You may return here and check on the status\n"; - echo "or update your report at any time. The URL for your bug report is: <a href=\"http://bugs.php.net/?id=$cid\">"; - echo "http://bugs.php.net/?id=$cid</a></p>\n"; + commonHeader("Report - Problems"); +} -} elseif (!isset($cmd)) { +if (!isset($in)) { commonHeader("Report - New"); ?> @@ -89,39 +87,53 @@ <?php } + +if ($errors) { + echo '<div class="errors">'; + if (count($errors) > 1) { + echo "You need to do the following before your submission will be accepted:<ul>"; + foreach ($errors as $error) { + echo "<li>$error</li>\n"; + } + echo "</ul>"; + } + else { + echo $errors[0]; + } + echo '</div>'; +} ?> -<form method="POST" action="<?php echo $PHP_SELF;?>"> -<input type="hidden" name="cmd" value="send" /> +<form method="post" action="<?php echo $PHP_SELF;?>"> <table> <tr> <th align="right">Your email address:</th> <td colspan="2"> - <input type="text" size="20" maxlength="40" name="email" value="<?php echo htmlspecialchars(stripslashes($email));?>" /> + <input type="text" size="20" maxlength="40" name="in[email]" value="<?php echo clean($in['email']);?>" /> </td> </tr><tr> <th align="right">PHP version:</th> <td> - <select name="php_version"><?php show_version_options($php_version);?></select> + <select name="in[php_version]"><?php show_version_options($in['php_version']);?></select> </td> </tr><tr> <th align="right">Type of bug:</th> <td colspan="2"> - <select name="bug_type"><?php show_types($bug_type,0);?></select> + <select name="in[bug_type]"><?php show_types($in['bug_type'],0);?></select> </td> </tr><tr> <th align="right">Operating system:</th> <td colspan="2"> - <input type="text" size="20" maxlength="32" name="php_os" value="<?php echo htmlspecialchars(stripslashes($php_os));?>" /> + <input type="text" size="20" maxlength="32" name="in[php_os]" value="<?php echo clean($in['php_os']);?>" /> </td> </tr><tr> <th align="right">Summary:</th> <td colspan="2"> - <input type="text" size="40" maxlength="79" name="sdesc" value="<?php echo htmlspecialchars(stripslashes($sdesc));?>" /> + <input type="text" size="40" maxlength="79" name="in[sdesc]" value="<?php echo clean($in['sdesc']);?>" /> </td></tr> </tr><tr> <th align="right">Password:</th> <td> - <input type="text" size="20" maxlength="20" name="passwd" value="<?php echo htmlspecialchars(stripslashes($passwd));?>" /> + <input type="text" size="20" maxlength="20" name="in[passwd]" value="<?php echo clean($in['passwd']);?>" /> </td> <td><font size="-2"> You may enter any password here. This password allows you to come back and @@ -146,7 +158,7 @@ <div align="center"><input type="submit" value="Send bug report" /></div> </td> <td> - <textarea cols="60" rows="15" name="ldesc" wrap="physical"><?php echo htmlspecialchars(stripslashes($ldesc));?></textarea> + <textarea cols="60" rows="15" name="in[ldesc]" wrap="physical"><?php echo clean($in['ldesc']);?></textarea> </td> </tr> </table> Index: php-bugs-web/style.css diff -u php-bugs-web/style.css:1.2 php-bugs-web/style.css:1.3 --- php-bugs-web/style.css:1.2 Wed Jan 2 19:22:31 2002 +++ php-bugs-web/style.css Tue Jan 8 20:02:09 2002 @@ -26,49 +26,6 @@ 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; @@ -150,7 +107,6 @@ color: #FFFFFF; } - input { font-family: arial,helvetica,sans-serif; } @@ -167,4 +123,94 @@ textarea.small { font-family: "andale mono", "monotype.com", "courier new", monospace; font-size: 75%; +} + +div.errors { + border: 1px dashed #660000; + color: #660000; + margin: 4px; + padding: 6px; +} +div.explain { + border: 1px dashed #000066; + color: #000066; + margin: 4px; + padding: 6px; +} +div.thanks { + border: 1px dashed #006600; + color: #006600; + margin: 4px; + padding: 6px; +} + +/* these are redundant with things below, to try and make the + * bug forms look a smidge better on netscape 4 (ugh). */ +span.control { + font-weight: bold; +} + +td#summary { + font-weight: bold; +} +th { + text-align: right; +} + +div#bugheader { + border-bottom: 2px solid #666666; +} + +div#bugheader { + border-bottom: 2px solid #666666; +} + +div#bugheader table#details th { + text-align: right; + color: #666666; +} +div#bugheader table#details th#number { + color: #000066; + font-size: larger; +} +div#bugheader table#details td#summary { + font-weight: bold; +} + +div#controls span { + float: left; + border: 1px solid #000000; + border-top: 0px; + font-weight: bold; + background: #ddddff; + padding: 4px 8px; + margin-right: 10px; + margin-left: 0px; +} +div#controls span.active { + position: relative; + top: -2px; + background: #ffffff; + padding-top: 6px; +} +div#controls a { + text-decoration: none; +} +div#controls a:hover { + text-decoration: underline; +} + +form#vote { + font-size: smaller; +} +form#vote > div { + float: left; +} +form#vote fieldset { + border: 1px solid #000000; +} +form#vote div#submit { + margin-top: 24px; + margin-left: 10px; + text-align: center; } Index: php-bugs-web/util.js diff -u php-bugs-web/util.js:1.1 php-bugs-web/util.js:1.2 --- php-bugs-web/util.js:1.1 Wed Jan 2 19:22:31 2002 +++ php-bugs-web/util.js Tue Jan 8 20:02:09 2002 @@ -6,16 +6,3 @@ 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 diff -u php-bugs-web/vote.php:1.3 php-bugs-web/vote.php:1.4 --- php-bugs-web/vote.php:1.3 Wed Jan 2 19:41:31 2002 +++ php-bugs-web/vote.php Tue Jan 8 20:02:09 2002 @@ -41,4 +41,4 @@ // redirect to the bug page (which will display the success message) -header("Location: bug.php?id=$id&voted=1"); +header("Location: bug.php?id=$id&thanks=6"); Index: php-bugs-web/include/functions.inc diff -u php-bugs-web/include/functions.inc:1.7 php-bugs-web/include/functions.inc:1.8 --- php-bugs-web/include/functions.inc:1.7 Fri Jan 4 22:13:15 2002 +++ php-bugs-web/include/functions.inc Tue Jan 8 20:02:10 2002 @@ -1,5 +1,24 @@ <?php /* vim: set noet ts=4 sw=4 ft=php3: : */ +/* scrub user input so it can be re-output */ +function clean($in) +{ + return htmlspecialchars(get_magic_quotes_gpc()?stripslashes($in):$in); +} +/* just rinse out any slashes. :) */ +function rinse($in) +{ + return get_magic_quotes_gpc()?stripslashes($in):$in; +} + +/* handy function for when you're dealing with user input or a default. */ +function oneof() +{ + foreach (func_get_args() as $arg) { + if ($arg) return $arg; + } +} + function show_byage_options($current) { $opts = array( @@ -86,7 +105,7 @@ include 'bugtypes.inc'; if (!$current && !$default && !$show_any) { - echo "<option value=\"Unknown/Other Function\">--Please Select--</option>\n"; + echo "<option value=\"none\">--Please Select--</option>\n"; } elseif (!$current && $show_any) { $current = "Any"; @@ -151,42 +170,34 @@ } /* validate an incoming bug report */ -function incoming_details_are_valid($require_ldesc=0,$require_passwd=0) +function incoming_details_are_valid($in,$initial=0) { - global $email,$bug_type,$php_version,$sdesc,$ldesc,$passwd; - - $valid = 1; - if(!preg_match("/[.\\w+-]+@[.\\w-]+\\.\\w{2,}/i",$email)) { - echo "<h2 class=\"error\">Please provide a valid email address.</h2>"; - $valid = 0; + $errors = array(); + if(!preg_match("/[.\\w+-]+@[.\\w-]+\\.\\w{2,}/i",$in['email'])) { + $errors[] = "Please provide a valid email address."; } - if ($bug_type=="none") { - echo "<h2 class=\"error\">Please select an appropriate bug type.</h2>"; - $valid = 0; + if ($in['bug_type'] == "none") { + $errors[] = "Please select an appropriate bug type."; } - if ($php_version=='earlier') { - echo "<h2 class=\"error\">Please select a valid PHP version. If your PHP version is too old, please upgrade first and see if the problem has not already been fixed.</h2>"; - $valid = 0; + if ($in['php_version'] == 'earlier') { + $errors[] = "Please select a valid PHP version. If your PHP version is too old, please upgrade first and see if the problem has not already been fixed."; } - if (!$sdesc) { - echo "<h2 class=\"error\">You must supply a short description of the bug you are reporting.</h2>"; - $valid = 0; + if (!$in['sdesc']) { + $errors[] = "You must supply a short description of the bug you are reporting."; } - if ($require_ldesc && !$ldesc) { - echo "<h2 class=\"error\">You must supply a long description of the bug you are reporting.</h2>"; - $valid = 0; + if ($initial && !$in['ldesc']) { + $errors[] = "You must supply a long description of the bug you are reporting."; } - if ($require_passwd && empty($passwd)) { - echo "<h2 class=\"error\">You must supply a password for this bug report.</h2>"; - $valid = 0; + if ($initial && !$in['passwd']) { + $errors[] = "You must supply a password for this bug report."; } - return $valid; + return $errors; } function get_bugtype_mail($bug_type) Index: php-bugs-web/logout.php +++ php-bugs-web/logout.php <?php require 'prepend.inc'; setcookie("MAGIC_COOKIE","",time()-3600,'/','.php.net'); setcookie("MAGIC_COOKIE","",time()-3600,'/'); commonHeader("Logout"); ?> <p>You've been logged out.</p> <?php commonFooter();
« previous php.mirrors (#8148) next »