Update of /cvsroot/php-blog/jBlog
In directory sc8-pr-cvs1:/tmp/cvs-serv14881
Modified Files:
db.sql jBlog_admin.php jBlog_admin_overview.inc.php
jBlog_functions.inc.php
Log Message:
added multiple author support
This is currently not supported by the install script. To add authors
(including the original author) you need to
insert into {PREFIX}authors VALUES('name', 'pass');
This is all done through sessions currently. Probably could be better.
Index: db.sql
===================================================================
RCS file: /cvsroot/php-blog/jBlog/db.sql,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- db.sql 4 Mar 2003 00:43:58 -0000 1.2
+++ db.sql 4 Mar 2003 01:41:25 -0000 1.3
@@ -1,3 +1,4 @@
CREATE TABLE {PREFIX}entries (id int(10) unsigned NOT NULL auto_increment, title varchar(200) default NULL, timestamp int(10) unsigned default NULL, body text, comments int (4) unsigned default 0, extended text, exflag int(1), PRIMARY KEY (id), FULLTEXT (title,body,extended)) TYPE=MyISAM
CREATE TABLE {PREFIX}comments (id int(10) unsigned NOT NULL auto_increment, entry_id int(10) unsigned NOT NULL, timestamp int(10) unsigned default NULL, title VARCHAR(150), author VARCHAR(80), email VARCHAR(200), url VARCHAR(200), ip VARCHAR(15), body text, type enum ('TRACKBACK', 'REGULAR'), PRIMARY KEY (id), FULLTEXT (body))
CREATE TABLE {PREFIX}references ( id int(10) unsigned not null auto_increment, entry_id int(10) unsigned not null, link text, name text, PRIMARY KEY(id))
+CREATE TABLE {PREFIX}authors ( name varchar(20), password varchar(20))
Index: jBlog_admin.php
===================================================================
RCS file: /cvsroot/php-blog/jBlog/jBlog_admin.php,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- jBlog_admin.php 3 Mar 2003 19:41:49 -0000 1.3
+++ jBlog_admin.php 4 Mar 2003 01:41:25 -0000 1.4
@@ -6,21 +6,13 @@
include("jBlog_config.inc.php");
// User logs in?
-if (strtolower($jBlog["POST"]["user"]) == strtolower($jBlog["user"])
- && $jBlog["POST"]["pass"] == $jBlog["pass"]) {
+if ($_SESSION["jBlogAuthedUser"] == true) {
+ $jBlog["user"] = $_SESSION["jBlogUser"];
+}
+else if(jBlog_authenticate_author($jBlog["POST"]["user"],$jBlog["POST"]["pass"])) {
$_SESSION["jBlogAuthedUser"] = true;
-
+ $jBlog["user"] = $_SESSION["jBlogUser"] = $jBlog["POST"]["user"];
}
-
-// Does user want to set a cookie?
-/* $cookie = @explode("22121979", base64_decode($_COOKIES["jBlogUser"])); */
-/*if ($jBlog["POST"]["user"]==$jBlog["user"]
- &&$jBlog["POST"]["pass"]==$jBlog["pass"]) {
- $_COOKIES["jBlogUser"] = base64_encode($jBlog["POST"]["user"]."22121979".$jBlog["POST"]["pass"]);
- @setCookie("jBlogUser", base64_encode($jBlog["POST"]["user"]."22121979".$jBlog["POST"]["pass"]),
- time()+86400*9999);
-
-}*/
?>
<html>
<head>
Index: jBlog_admin_overview.inc.php
===================================================================
RCS file: /cvsroot/php-blog/jBlog/jBlog_admin_overview.inc.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- jBlog_admin_overview.inc.php 27 Feb 2003 16:55:35 -0000 1.1.1.1
+++ jBlog_admin_overview.inc.php 4 Mar 2003 01:41:25 -0000 1.2
@@ -10,6 +10,6 @@
##########################################################################
if (IN_JBLOG !== true) die ("Don't hack!");
-
+session_start();
?>
-This is just raw functionality, no design yet. Don't be scared :)
+Welcome back, <?= $_SESSION['jBlogUser'] ?>. Would you like to play a game?
Index: jBlog_functions.inc.php
===================================================================
RCS file: /cvsroot/php-blog/jBlog/jBlog_functions.inc.php,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- jBlog_functions.inc.php 4 Mar 2003 01:22:21 -0000 1.4
+++ jBlog_functions.inc.php 4 Mar 2003 01:41:25 -0000 1.5
@@ -182,13 +182,17 @@
}
while($row = mysql_fetch_assoc($cursor)) {
- $ret[] = array("id" => $row['id'],
+ $ret[] = $row;
+/*
+ array("id" => $row['id'],
"timestamp" => $row['timestamp'],
"comments" => $row['comments'],
"title" => $row['title'],
"body" => $row['body'],
"extended" => $row['extended'],
+ "author" => $row['author'],
"exflag" => $row['exflag']);
+*/
}
return $ret;
@@ -220,13 +224,16 @@
$querystring = "SELECT id, timestamp, comments, title, body, extended FROM ".$jBlog["dbPrefix"]."entries
WHERE MATCH (title, extended) AGAINST ('".addslashes($term)."') ORDER BY timestamp DESC";
$query = mysql_db_query($jBlog["dbName"], $querystring);
- while($row = mysql_fetch_row($query)) {
- $ret[] = array("id" => $row[0],
+ while($row = mysql_fetch_assoc($query)) {
+ $ret[] = $row;
+/*
+ array("id" => $row[0],
"timestamp" => $row[1],
"comments" => $row[2],
"title" => $row[3],
"body" => $row[4],
"extended" => $row[5]);
+*/
}
return $ret;
@@ -264,7 +271,7 @@
<?php
}
echo "<div class='jBlog_time'><br>";
- echo "<a href=\"{$jBlog['jBlogHTTPPath']}archives/e_{$entries[$x]['id']}.html\">Posted by ".$jBlog["user"]." at ";
+ echo "<a href=\"{$jBlog['jBlogHTTPPath']}archives/e_{$entries[$x]['id']}.html\">Posted by ".$entries[$x]["author"]." at ";
echo date("H:i", $entries[$x]["timestamp"]);
echo "</a>";
if ($j != 1) {
@@ -662,14 +669,15 @@
}
}
$querystring = "REPLACE INTO ".$jBlog["dbPrefix"]."entries
- (id, title, timestamp, body, extended, comments, exflag)
+ (id, title, timestamp, body, extended, comments, exflag, author)
VALUES (
".$entry["id"].",
'".mysql_escape_string($entry["title"])."',
".$entry["timestamp"].",
'".mysql_escape_string($entry["body"])."',
'".mysql_escape_string($entry["extended"])."',
- 0, $exflag)";
+ 0, $exflag,
+ '".mysql_escape_string($jBlog["user"])."')";
$query = mysql_db_query($jBlog["dbName"], $querystring);
if ($entry['id'] == "NULL") {
$newEntry = 1;
@@ -876,6 +884,23 @@
</form>
</table>
<?php
+}
+
+function jBlog_authenticate_author($username, $password) {
+ global $jBlog;
+ $query = "SELECT
+ count(1)
+ FROM
+ $jBlog[dbPrefix]authors
+ WHERE
+ username = '$username'
+ AND password = '$password'";
+ $cursor = mysql_db_query($jBlog['dbName'], $query);
+ if(!$cursor) {
+ print mysql_error();
+ }
+ $row = mysql_fetch_row($cursor);
+ return $row[0];
}
define("JBLOG_FUNCTIONS_LOADED", true);
|