cvs: php-gtk-web /manual add-note.php admin-notes.php browse-notes.php
[email protected] ("Steph Fox") Sun, 09 Jul 2006 15:21:55 -0000
| Newsgroups | php.gtk.webmaster |
|---|---|
| Message-ID | <cvssfox1152458515@cvsserver> |
sfox Sun Jul 9 15:21:55 2006 UTC
Modified files:
/php-gtk-web/manual add-note.php admin-notes.php browse-notes.php
Log:
Tidy up and add a mail switch; provide some means of initializing id
http://cvs.php.net/viewvc.cgi/php-gtk-web/manual/add-note.php?r1=1.21&r2=1.22&diff_format=u
Index: php-gtk-web/manual/add-note.php
diff -u php-gtk-web/manual/add-note.php:1.21 php-gtk-web/manual/add-note.php:1.22
--- php-gtk-web/manual/add-note.php:1.21 Sun Jul 9 10:03:08 2006
+++ php-gtk-web/manual/add-note.php Sun Jul 9 15:21:55 2006
@@ -44,8 +44,8 @@
if (isset($_POST['add']) || isset($_POST['preview'])) {
/* Throw out any attempt at redirection */
- $len = strlen($_SERVER['HTTP_HOST']) + 14;
- if (substr($referrer, 0, $len) != 'http://'.$_SERVER['HTTP_HOST'].'/manual' || strstr($referrer, '?')) {
+ $len = strlen($_SERVER['HTTP_HOST']) + 7;
+ if (substr($referrer, 0, $len) != 'http://'.$_SERVER['HTTP_HOST'] || strstr($referrer, '?')) {
header("Location: $referrer");
exit;
}
@@ -129,8 +129,14 @@
/* check for/create the last_id file while we're at it */
if (!file_exists($last_id)) {
$db = sqlite_open($notesfile);
- $setlast = sqlite_last_insert_rowid($db);
- file_put_contents($last_id, $setlast);
+ $estimate = sqlite_single_query($db, "SELECT COUNT(*) FROM notes");
+ $setid = sqlite_query($db, "SELECT id FROM notes WHERE id > '$estimate'", SQLITE_ASSOC);
+ if (sqlite_fetch_single($setid) !== false)
+ while (sqlite_valid($setid))
+ $rowid = sqlite_fetch_single($setid);
+ else
+ $rowid = $estimate;
+ file_put_contents($last_id, $rowid);
sqlite_close($db);
}
}
@@ -262,10 +268,8 @@
$content = htmlentities($content, ENT_COMPAT, 'UTF-8');
/* Pick up id, insert note data into queue and mail out admin notification */
- if (!$setlast && !$lastid = file_get_contents($last_id)) {
+ if (!$lastid = file_get_contents($last_id)) {
die("Could not obtain note ID");
- } else {
- $lastid = $setlast;
}
$id = $lastid + 1;
@@ -288,9 +292,8 @@
$printmsg .= ", and you will be notified by email when it goes live";
}
$printmsg .= ".</p>";
- print stretchPage(22);
+ print stretchPage(20);
print $printmsg;
- print $db_string;
print "<p><a href = '$referrer'>Back</a></p>";
commonFooter();
@@ -299,14 +302,14 @@
file_put_contents($stats, "GTK_ERROR:$errmsg Backup is in $id.txt\n", FILE_APPEND);
$bytes = file_put_contents(DB_DIR."/$id.txt", $id."\n".$page."\n".$lang."\n".$date."\n".$email."\n".$display."\n".$content."\n\n".$ip);
$msg = "page: $page\n\n$content\n\n$display - ".date('d-M-Y H:i', $date);
- mail($mailto, "queue system failed: note $id was backed up ($bytes bytes)", $msg, "From: $mailfrom");
+ if ($mail) mail($mailto, "queue system failed: note $id was backed up ($bytes bytes)", $msg, "From: $mailfrom");
commonFooter();
exit;
}
/* Mail success notification to the list */
$msg = "page: <a href='$referrer'>$page</a>\n\n$content\n\n$display - ".date('d-M-Y H:i', $date);
- mail($mailto, "note $id has been queued", $msg, "From: $mailfrom");
+ if ($mail) mail($mailto, "note $id has been queued", $msg, "From: $mailfrom");
/*
* We can't check for the current id without holding up the page for a whole
* unacceptable minute - so we keep the current entry in the queue and
@@ -387,7 +390,7 @@
if (($errcode != 'GTK_888' && !strstr($last['email'], "GTK_000")) || isset($_COOKIE[$user])) {
$msg = "Hi\n\nThis is to confirm that your PHP-GTK manual note reached the top of the queue and will be available for viewing shortly at <a href='$referrer'>$referrer</a>.\n\nThank you again for your contribution!\n\nRegards,\nThe PHP-GTK Documentation Group";
if (isset($_COOKIE[$user])) $lastemail = $_COOKIE[$user];
- mail($lastemail, "PHP-GTK Manual Note $lastid added", $msg, "From: $mailfrom");
+ if ($mail) mail($lastemail, "PHP-GTK Manual Note $lastid added", $msg, "From: $mailfrom");
}
if (!$errcode) {
@@ -403,7 +406,7 @@
/* We're being attacked and they've managed to screw up at least one db */
/* use GTK_999 but preserve the original combo so we know where to look */
$msg = "page: <a href='$referrer'>$page</a>\n\n$content\n\n$display - ".date('d-M-Y H:i', $date);
- mail($mailto, "GTK_999 notification", $msg, "From: $mailfrom");
+ if ($mail) mail($mailto, "GTK_999 notification", $msg, "From: $mailfrom");
exit;
}
http://cvs.php.net/viewvc.cgi/php-gtk-web/manual/admin-notes.php?r1=1.35&r2=1.36&diff_format=u
Index: php-gtk-web/manual/admin-notes.php
diff -u php-gtk-web/manual/admin-notes.php:1.35 php-gtk-web/manual/admin-notes.php:1.36
--- php-gtk-web/manual/admin-notes.php:1.35 Sun Jul 9 09:26:25 2006
+++ php-gtk-web/manual/admin-notes.php Sun Jul 9 15:21:55 2006
@@ -46,6 +46,17 @@
setcookie($user, $adminmail, time()+(3600*24), '/');
}
+ } elseif (array_key_exists('m', $_GET)) {
+
+ /* switch outgoing mail on/off */
+ if (in_array($user, $systems)) {
+ if (file_exists($mailfile)) {
+ unlink($mailfile);
+ } else {
+ file_put_contents($mailfile, 'OK');
+ }
+ }
+
} else {
/* switch public viewing of manual notes on/off */
http://cvs.php.net/viewvc.cgi/php-gtk-web/manual/browse-notes.php?r1=1.14&r2=1.15&diff_format=u
Index: php-gtk-web/manual/browse-notes.php
diff -u php-gtk-web/manual/browse-notes.php:1.14 php-gtk-web/manual/browse-notes.php:1.15
--- php-gtk-web/manual/browse-notes.php:1.14 Sun Jul 9 09:09:22 2006
+++ php-gtk-web/manual/browse-notes.php Sun Jul 9 15:21:55 2006
@@ -65,13 +65,13 @@
if (!isset($_COOKIE[$user])) { /* but only if we're not in test mode */
$mailto = $row['email'];
}
- mail($mailto, "note {$row['id']} rejected: {$row['page']}", $reject_text."----- Copy of your note below -----\n\n".stripslashes($row['comment']), "From: [email protected]");
+ if ($mail) mail($mailto, "note {$row['id']} rejected: {$row['page']}", $reject_text."----- Copy of your note below -----\n\n".stripslashes($row['comment']), "From: [email protected]");
}
$actioned = 'rejected';
} else {
$actioned = 'deleted';
}
- mail($mailto, "note $id $actioned: {$row['page']}", "Content of note:\n\n".stripslashes($row['comment']), "From: [email protected]");
+ if ($mail) mail($mailto, "note $id $actioned: {$row['page']}", "Content of note:\n\n".stripslashes($row['comment']), "From: [email protected]");
print "<p><b>Note $id deleted successfully</b></p>";
} else {
print "<p><b>Unable to delete note $id</b></p>";
@@ -125,7 +125,7 @@
$query .= " comment='$note' WHERE id='{$row['id']}'";
if (sqlite_exec($db, $query)) {
echo "<p><b>Record {$row['id']} modified successfully</b></p>";
- mail($mailto, "note {$row['id']} modified: {$row['page']}", $note.$add_url, "From: [email protected]");
+ if ($mail) mail($mailto, "note {$row['id']} modified: {$row['page']}", $note.$add_url, "From: [email protected]");
} else {
echo "<p><b>Record {$row['id']} not modified (query failed)</b></p>";
}