cvs: php-gtk-web /manual add-note.php
[email protected] ("Steph Fox") Sun, 09 Jul 2006 10:03:08 -0000
| Newsgroups | php.gtk.webmaster |
|---|---|
| Message-ID | <cvssfox1152439388@cvsserver> |
sfox Sun Jul 9 10:03:08 2006 UTC
Modified files:
/php-gtk-web/manual add-note.php
Log:
All 'real' changes complete. Just fixes to come.
http://cvs.php.net/viewvc.cgi/php-gtk-web/manual/add-note.php?r1=1.20&r2=1.21&diff_format=u
Index: php-gtk-web/manual/add-note.php
diff -u php-gtk-web/manual/add-note.php:1.20 php-gtk-web/manual/add-note.php:1.21
--- php-gtk-web/manual/add-note.php:1.20 Sun Jul 9 09:20:29 2006
+++ php-gtk-web/manual/add-note.php Sun Jul 9 10:03:08 2006
@@ -39,16 +39,17 @@
}
/* hide everything while we sort it all out */
-if (file_exists($okfile) || $user = get_user()) {
+if ((file_exists($okfile) || $user = get_user()) && file_exists($notesfile)) {
if (isset($_POST['add']) || isset($_POST['preview'])) {
/* Throw out any attempt at redirection */
-/* if (substr($referrer, 0, 25) != 'http://gtk.php.net/manual' || strstr($referrer, '?')) {
+ $len = strlen($_SERVER['HTTP_HOST']) + 14;
+ if (substr($referrer, 0, $len) != 'http://'.$_SERVER['HTTP_HOST'].'/manual' || strstr($referrer, '?')) {
header("Location: $referrer");
exit;
}
-*/
+
/* set globals and initialize a bunch of vars */
$email = stripslashes(trim($_POST['email']));
$content = stripslashes(trim($_POST['note']));
@@ -107,6 +108,7 @@
}
}
+ /* check for/create the queue file */
if (!file_exists($queuefile)) {
$db = sqlite_open($queuefile);
sqlite_query($db,
@@ -123,6 +125,14 @@
);
sqlite_close($db);
}
+
+ /* 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);
+ sqlite_close($db);
+ }
}
/* ============================ PREVIEW ONLY ========================= */
@@ -252,8 +262,10 @@
$content = htmlentities($content, ENT_COMPAT, 'UTF-8');
/* Pick up id, insert note data into queue and mail out admin notification */
- if (!$lastid = file_get_contents($last_id)) {
+ if (!$setlast && !$lastid = file_get_contents($last_id)) {
die("Could not obtain note ID");
+ } else {
+ $lastid = $setlast;
}
$id = $lastid + 1;