cvs: phpweb /manual add-note.php
| From: | jim winstead | Date: | Sat, 08 Dec 2001 21:41:42 +0000 |
| Subject: | cvs: phpweb /manual add-note.php | ||
| Groups: | php.mirrors | ||
| Request: | Send a blank email to php-mirrors+get-7722@lists.php.net to get a copy of this message | ||
jimw Sat Dec 8 16:41:42 2001 EDT
Modified files:
/phpweb/manual add-note.php
Log:
clean up a bit, and prevent really short entries and entries with non-breakable text that is too
long (screws up the layout)
Index: phpweb/manual/add-note.php
diff -u phpweb/manual/add-note.php:1.28 phpweb/manual/add-note.php:1.29
--- phpweb/manual/add-note.php:1.28 Wed Oct 3 16:24:02 2001
+++ phpweb/manual/add-note.php Sat Dec 8 16:41:42 2001
@@ -1,8 +1,8 @@
-<?
+<?php
require_once 'prepend.inc';
require_once 'posttohost.inc';
+require_once 'shared-manual.inc';
-require("shared-manual.inc");
commonHeader("Manual Notes");
/* clean off leading and trailing whitespace */
@@ -14,15 +14,25 @@
$user = "";
}
-if ($note == "") {
- unset ($note);
+$error = '';
+
+if ($note && strlen($note) >= 4096) {
+ $error = "Your note is too long. You'll have to make it shorter before you can post it.
Keep in mind that this is not the place for long code examples!";
}
-if (isset($note) && strlen($note) >= 4096) {
- echo "<p>Your note is too long. You'll have to make it shorter before you can
post it.</p>";
+if ($note && strlen($note) < 32) {
+ $error = "Your note is too short. Trying to test the notes system? Save us the trouble of
deleting your test, and don't. It works.";
+}
+
+if ($note) {
+ foreach (preg_split("/\\s+/",$note) as $chunk) {
+ if (strlen($chunk) > 70) {
+ $error = "Your note contains a bit of text that will result in a line that is too long,
even after using wordwrap().";
+ }
+ }
}
-if (isset($note) && isset($action) && strlen($note) < 4096 &&
strtolower($action) != "preview"):
+if ($note && !$error && $action && strtolower($action) !=
"preview") {
$result = posttohost("http://master.php.net/entry/user-note.php",
array(
"user" => stripslashes($user),
"note" => stripslashes($note),
@@ -32,7 +42,7 @@
if ($result) {
echo "<!-- $result -->";
- echo "<p>There was an error processing your submission. It has been automatically
e-mailed to the developers, who will process the note manually.</p>";
+ echo "<p class=\"error\">There was an error processing your submission. It
has been automatically e-mailed to the developers, who will process the note
manually.</p>";
}
else {?>
<p>Your submission was successful -- thanks for contributing! Note that it will
@@ -43,15 +53,20 @@
}
?>
<p>You can <a href="<?php echo $redirect?>">go back</a> from
whence you came.</p>
-<?else:
- if (isset($note)):?>
+<?php
+}
+else {
+ if ($note) {
+ if ($error) echo "<p class=\"error\">$error</p>\n";
+?>
<p>This is what your entry will look like, roughly:</p>
-<?
- echo '<table border="0" cellpadding="0"
cellspacing="0" width="100%">';
- makeEntry(time(),stripslashes($user),stripslashes($note));
- echo "</table>";
- else:?>
-<P>You can contribute to the PHP manual from the comfort of your browser!
+<?php
+ echo '<table border="0" cellpadding="0" cellspacing="0"
width="100%">';
+ makeEntry(time(),stripslashes($user),stripslashes($note));
+ echo "</table>";
+ }
+ else {?>
+<p>You can contribute to the PHP manual from the comfort of your browser!
Just add your comment in the big field below, and, optionally, your email
address in the little one (usual anti-spam practices are OK, e.g.
johnNOSPAM@doe.NO_SPAM.com).</p>
@@ -64,11 +79,11 @@
<p>Read carefully the following note. If your post falls into one of the
categories mentioned there, it will be rejected by one of the editors.</p>
-<P><B>Note:</B> If you are trying to <A href="http://bugs.php.net/">report a
+<P><b>Note:</b> If you are trying to <A href="http://bugs.php.net/">report a
bug</A>, or <a href="http://bugs.php.net/">request a new fature or language
change</a> you're in the wrong place. If you are just commenting on the fact
-that something is not documented, save your breath. This is where <B>you</B>
-add to the documentation, not where you ask <B>us</B> to add the
+that something is not documented, save your breath. This is where <b>you</b>
+add to the documentation, not where you ask <b>us</b> to add the
documentation. This is also not the correct place to <A
href="/support.php">ask questions</A> (even if you see others have done that
before, we are editing the notes slowly but surely). If you post a note in
@@ -81,40 +96,49 @@
if you post a question/bug/feature/complaint, it will be removed. (But once you
get an answer/bug solution/function documentation, feel free to come back
and add it here!)</p>
-<p>
-<a href="/support.php">Click here to go to the support pages.</a><br>
-<a href="http://bugs.php.net/">Click here
to submit a bug report.</a><br>
-<a href="http://bugs.php.net/">Click here
to request a feature.</a>
-</p>
-<? endif;
- if (!$user) $user = "user@example.com";
- if (!isset($sect)):?>
+<?php
+ }
+
+ if (!$user) $user = "user@example.com";
+ if (!isset($sect)) {?>
<p><b>To add a note, you must click on the 'Add Note' button
on the bottom of a manual page so we know where to add the note!</b></p>
-<? else:?>
+<?php
+ }
+ else {?>
<form method="post" action="<?php echo $PHP_SELF;?>">
-<input type="hidden" name="sect" value="<?echo $sect;?>"
/>
-<input type="hidden" name="redirect" value="<?echo
$redirect;?>" />
-<input type="hidden" name="lang" value="<?echo $lang;?>"
/>
+<input type="hidden" name="sect" value="<?php echo
clean($sect);?>" />
+<input type="hidden" name="redirect" value="<?php echo
clean($redirect);?>" />
+<input type="hidden" name="lang" value="<?php echo
clean($lang);?>" />
<table border="0" cellpadding="5" cellspacing="0"
bgcolor="#d0d0d0">
+<tr>
+ <td colspan="2">
+<b>
+<a href="/support.php">Click here to go to the support pages.</a><br>
+<a href="http://bugs.php.net/">Click here
to submit a bug report.</a><br>
+<a href="http://bugs.php.net/">Click here
to request a feature.</a>
+</b>
+ </td>
+</tr>
+<tr valign="top">
+<td><b>Your email address:</b></td>
+<td><input type="text" name="user" size="40"
maxlength="40" value="<?php echo clean($user)?>"></td>
+</tr>
<tr valign="top">
-<TD><B>Your email address:</B></TD>
-<td><input type="text" name="user" size="40"
maxlength="40" value="<?echo
htmlspecialchars(stripslashes($user))?>"></td>
-</TR>
-<TR VALIGN=top>
-<TD><B>Your notes:</B></TD>
-<td><textarea name="note" rows="6" cols="40"
wrap="virtual"><?echo
htmlspecialchars(stripslashes($note))?></textarea><br>
-</TD>
-</TR>
-<TR>
+<td><b>Your notes:</b></td>
+<td><textarea name="note" rows="6" cols="40"
wrap="virtual"><?php echo clean($note)?></textarea><br>
+</td>
+</tr>
+<tr>
<td colspan="2" align="right">
<input type="submit" name="action" value="Preview">
<input type="submit" name="action" value="Add Note">
</td>
</tr>
-</TABLE>
-</FORM>
-<? endif;
-endif;
+</table>
+</form>
+<?php
+ }
+}
commonFooter();
?>