[Astrospaces-commits] SF.net SVN: astrospaces: [43] trunk
Brought to you by:
p3net
|
From: <p3...@us...> - 2007-07-30 20:02:40
|
Revision: 43
http://astrospaces.svn.sourceforge.net/astrospaces/?rev=43&view=rev
Author: p3net
Date: 2007-07-30 13:02:42 -0700 (Mon, 30 Jul 2007)
Log Message:
-----------
First stab at the blog. Also fix a little error on caleb's part
Modified Paths:
--------------
trunk/blog.php
trunk/develop/new-schema.sql
trunk/globals.php
trunk/profile.php
Added Paths:
-----------
trunk/template/default/blog_post_view.tpl
Modified: trunk/blog.php
===================================================================
--- trunk/blog.php 2007-07-30 19:46:37 UTC (rev 42)
+++ trunk/blog.php 2007-07-30 20:02:42 UTC (rev 43)
@@ -1,4 +1,4 @@
-<?php
+<?php
/*******************************************************
* Copyright (C) 2007 http://p3net.net
@@ -14,8 +14,82 @@
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
- @id: $Id$
-*********************************************************/
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ @id: $Id$
+*********************************************************/
+/* Todo: blog supports space privacy settings */
+include('./globals.php');
+class blog
+{
+ /* Function name: view
+ Arguments: (int) id -- Blog post ID
+ Description: view a blog post
+ */
+ function view($id)
+ {
+ /* We should add a sanitize method to the db class */
+ $id = mysql_real_escape_string($id);
+ $_query="SELECT * FROM `" . AS_TBL_BLOG . "` WHERE `blog_id`='"
+ . $id . "' LIMIT 1;";
+ $db->Execute($_query);
+ while($res = $db->FetchRow())
+ {
+ $title = $res['title'];
+ $timestamp = $user->generate_timestamp($res['blog_timestamp']);
+ $content = $res['content'];
+ $author = $user->get_username($res['author_id']);
+ }
+ $template =& new template(AS_TPL . 'blog_post_view.tpl');
+ $template->set('title', $title);
+ $template->set('date', $timestamp);
+ $template->set('content', $content);
+ $template->set('author', $author);
+
+ /* Now for the comments */
+ $_query = "SELECT * FROM `" . AS_TBL_BLOG_CMT . "` WHERE `post_id`='"
+ . $id . "' ORDER BY `post_timestamp` ASC";
+ $db->Execute($_query);
+ while($com = $db->FetchRow())
+ {
+ $blog_c[]['author'] = $user->get_username($com['author_id']);
+ $blog_c[]['comment'] = $com['commnent'];
+ $blog_c[]['time'] = $user->get_timestamp($com['post_timestamp']);
+ }
+ /* Caleb better get the array thing in template files working soon */
+ $template->set('comments', $blog_c);
+ }
+ /* Function name: post
+ Arguments:
+ Description: Write/submit a post for your blog
+ */
+ function post()
+ {
+ /* We'll do this when the schema is finalised */
+ }
+ /* Function name: comment
+ Arguments:
+ Description: Write/submit a comment for a blog post
+ */
+ function comment()
+ {
+ /* We'll do this when the schema is finalises */
+ }
+}
+$blog =& new blog();
+$mode = empty($_GET["mode"]) ? '' : $_GET["mode"];
+switch($mode)
+{
+ case 'view':
+ $blog->view($_GET["id"]);
+ break;
+
+
+ case 'post':
+ break;
+
+ case 'comment':
+ break;
+
+}
?>
\ No newline at end of file
Modified: trunk/develop/new-schema.sql
===================================================================
--- trunk/develop/new-schema.sql 2007-07-30 19:46:37 UTC (rev 42)
+++ trunk/develop/new-schema.sql 2007-07-30 20:02:42 UTC (rev 43)
@@ -20,6 +20,7 @@
DROP TABLE IF EXISTS `as_blog_comment`;
CREATE TABLE `as_blog_comment` (
`comment_id` int(10) unsigned NOT NULL auto_increment,
+ `post_id` int(10) unsigned NOT NULL,
`author_id` int(10) unsigned NOT NULL,
`comment` text NOT NULL,
`post_timestamp` int(10) unsigned NOT NULL,
Modified: trunk/globals.php
===================================================================
--- trunk/globals.php 2007-07-30 19:46:37 UTC (rev 42)
+++ trunk/globals.php 2007-07-30 20:02:42 UTC (rev 43)
@@ -19,7 +19,7 @@
@id: $Id$
*********************************************************/
/* Include our larger functions */
-require('config.php'); /* Do not put 'AS_LOC_DIRECT' before this one */
+require('./config.php'); //We can't include using a constant defined in the file we're including
require(AS_LOC_DIRECT.'functions/template.php');
$template =& new template();
require(AS_LOC_DIRECT.'functions/session.php');
Modified: trunk/profile.php
===================================================================
--- trunk/profile.php 2007-07-30 19:46:37 UTC (rev 42)
+++ trunk/profile.php 2007-07-30 20:02:42 UTC (rev 43)
@@ -35,9 +35,9 @@
}
else if($step == 2)
{
- $_query = 'INSERT INTO '.AS_TBL_USER.' (display_name, password, join, time_offset ';
+ $_query = 'INSERT INTO '.AS_TBL_USER.' (display_name, password, join, time_offset) ';
$_query .= 'VALUES('.$db->qstr($vars["display_name"],get_magic_quotes_gpc()).',';
- $_qeury .= $db->qstr(md5($vars["password"]),get_magic_quotes_gpc()).',';
+ $_query .= $db->qstr(md5($vars["password"]),get_magic_quotes_gpc()).',';
$_query .= time().','.qstr($vars["offset"],get_magic_quotes_gpc()).')';
if ($db->Execute($_query) === false)
Added: trunk/template/default/blog_post_view.tpl
===================================================================
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|