[Astrospaces-commits] SF.net SVN: astrospaces: [7] trunk
Brought to you by:
p3net
|
From: <p3...@us...> - 2007-03-13 02:09:19
|
Revision: 7
http://astrospaces.svn.sourceforge.net/astrospaces/?rev=7&view=rev
Author: p3net
Date: 2007-03-12 19:09:20 -0700 (Mon, 12 Mar 2007)
Log Message:
-----------
-Add the brains of the operating (space.php)
-Modify the header on the top of includes/template.php, includes/profile.php, includes/db.php, install/install.php, profile.php, index.php, and common.php so hopefully it appears right.
-Add a few functions to common.php (get_username_by_id() and get_icon_by_id())
-Add a few more columns to the users table (install/install.php)
-Update includes/profile.php to respect the above change
Modified Paths:
--------------
trunk/common.php
trunk/includes/db.php
trunk/includes/profile.php
trunk/includes/template.php
trunk/index.php
trunk/install/install.php
trunk/profile.php
Added Paths:
-----------
trunk/space.php
Modified: trunk/common.php
===================================================================
--- trunk/common.php 2007-03-11 18:12:54 UTC (rev 6)
+++ trunk/common.php 2007-03-13 02:09:20 UTC (rev 7)
@@ -22,7 +22,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
-* ID: $Id$
+* ID: $Id: $
* Author: $Author$
******************************************************************************/
@@ -163,4 +163,22 @@
$outer =& new template('outer.tpl');
$outer->set('content', $thnx);
}
+function redirect($to)
+{
+ header('location: ' . $to);
+}
+function get_username_by_id($id)
+{
+ $_query="SELECT `username` FROM " . DB_USERS . " WHERE `id`='" . $id . "'";
+ $_query=$db->query($_query);
+ $_query=$db->array($_query);
+ return $_query["username"];
+}
+function get_icon_by_id($id)
+{
+ $_query="SELECT `icon` FROM " . DB_USERS . "WHERE `id`='" . $id . "'";
+ $_query=$db->query($_query);
+ $_query=$db->array($_query);
+ return $_query["icon"];
+}
?>
\ No newline at end of file
Modified: trunk/includes/db.php
===================================================================
--- trunk/includes/db.php 2007-03-11 18:12:54 UTC (rev 6)
+++ trunk/includes/db.php 2007-03-13 02:09:20 UTC (rev 7)
@@ -21,7 +21,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
-* ID: $Id:$
+* ID: $Id: $
* Author: $Author:$
******************************************************************************/
Modified: trunk/includes/profile.php
===================================================================
--- trunk/includes/profile.php 2007-03-11 18:12:54 UTC (rev 6)
+++ trunk/includes/profile.php 2007-03-13 02:09:20 UTC (rev 7)
@@ -20,7 +20,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
-* ID: $Id$
+* ID: ID: $Id: $
* Author: $Author$
******************************************************************************/
class profile()
@@ -54,15 +54,15 @@
}
//Time to insert...
$_query="INSERT INTO " . DB_USERS . " VALUES('', '1', '" . $var["username"] . "', '" . md5($var["password"]) .
- "', '" . $var["email"] . "', '" . $var["aim"] . "', '" . $var["msn"] . "', '" . $var["irc"] .
- "', '" . $var["icq"] . "', '" . $var["yahoo"] . "', '" . $var["website"] .", '" . time() . "');";
+ "', '" . $var["email"] . "', '../default.gif', '" . $var["aim"] . "', '" . $var["msn"] . "', '" . $var["irc"] .
+ "', '" . $var["icq"] . "', '" . $var["yahoo"] . "', '" . $var["website"] .", 'default', '" . time() . "');";
//Run the query
$db->query($_query);
//Put some default information into his space
$_defspace="INSERT INTO `" . DB_SPACE . "` VALUES('', 'Welcome to AstroSPACES!', 'You can edit " .
- "these areas and more in your edit profile page!');
+ "these areas and more in your edit profile page!");
$db->query($_defspace);
Modified: trunk/includes/template.php
===================================================================
--- trunk/includes/template.php 2007-03-11 18:12:54 UTC (rev 6)
+++ trunk/includes/template.php 2007-03-13 02:09:20 UTC (rev 7)
@@ -23,7 +23,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
-* ID: $Id$
+* ID: $Id: $
* Author: $Author$
******************************************************************************/
Modified: trunk/index.php
===================================================================
--- trunk/index.php 2007-03-11 18:12:54 UTC (rev 6)
+++ trunk/index.php 2007-03-13 02:09:20 UTC (rev 7)
@@ -21,7 +21,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
-* ID: $Id$
+* ID: $Id: $
* Author: $Author$
******************************************************************************/
Modified: trunk/install/install.php
===================================================================
--- trunk/install/install.php 2007-03-11 18:12:54 UTC (rev 6)
+++ trunk/install/install.php 2007-03-13 02:09:20 UTC (rev 7)
@@ -76,23 +76,25 @@
`username` text NOT NULL,
`password` text NOT NULL,
`email` varchar(25) NOT NULL,
+ `icon` varchar(25) NOT NULL,
`aim` text,
`msn` text,
`irc` text,
`irc` text,
`yahoo` text,
`website` text,
+ `theme` text,
`last_login` int(15) NOT NULL default 0,
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=1 ;";
$_comment="CREATE TABLE IF NOT EXISTS `" . DB_COMMENT . "` (
- `id` int(11) NOT NULL auto_increment,
+ `comm_id` int(11) NOT NULL auto_increment,
`time` int(15) NOT NULL default 0,
- `from` int(11) NOT NULL,
- `to` int(11) NOT NULL,
- `content` TEXT NOT NULL,
- PRIMARY KEY (`id`)
+ `comm_from` int(11) NOT NULL,
+ `comm_to` int(11) NOT NULL,
+ `comm_content` TEXT NOT NULL,
+ PRIMARY KEY (`comm_id`)
) TYPE=MyISAM AUTO_INCREMENT=1 ;";
$_friends="CREATE TABLE IF NOT EXISTS `" . DB_FRIENDS . "` (
@@ -155,7 +157,7 @@
//Put some default information into his space
$_defspace="INSERT INTO `" . DB_SPACE . "` VALUES('', 'Welcome to AstroSPACES!', 'You can edit " .
- "these areas and more in your edit profile page!');
+ "these areas and more in your edit profile page!");
$db->query($_defspace);
Modified: trunk/profile.php
===================================================================
--- trunk/profile.php 2007-03-11 18:12:54 UTC (rev 6)
+++ trunk/profile.php 2007-03-13 02:09:20 UTC (rev 7)
@@ -20,7 +20,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
-* ID: $Id$
+* ID: $Id: $
* Author: $Author$
******************************************************************************/
//Setup everything we need
Added: trunk/space.php
===================================================================
--- trunk/space.php (rev 0)
+++ trunk/space.php 2007-03-13 02:09:20 UTC (rev 7)
@@ -0,0 +1,158 @@
+<?php
+/******************************************************************************
+* space.php
+* AstroSPACES 2
+*
+* Description: space.php is essentially the brains of the operation. It handles
+* the display of a users space... and really, that's about it.
+* However, this being the script that it is, that's fairly
+* important.
+*
+*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 2 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* 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: $
+* Author: $Author$
+******************************************************************************/
+
+//The things we need on everything!
+define('IN_ASTRO', 1);
+require('common.php');
+construct();
+
+//What's our ID?
+$id = $_REQUEST["id"];
+
+//Let's see if it's empty
+if(empty($_REQUEST["id"]))
+{
+ //It is. Let's see if we're logged in...
+ if(login_check)
+ {
+ //We are, so set the ID to our session ID!
+ $id = SESSION_ID;
+ }
+ else
+ {
+ //We're not, so redirect to login
+ redirect('profile.php?mode=login');
+ }
+}
+//Get all of our info from the users, friends, and space table, etc.
+//This is going to be a big JOIN query. Let's hope it works...
+$_query="SELECT " . DB_USERS . ".id, " . DB_USERS . ".username, " .
+ DB_USERS . ".theme, " . DB_USERS . ".icon" .
+ " DB_USERS . ".last_login, " .
+ DB_SPACE . ".left, " . DB_SPACE . ".right , " .
+ DB_FRIENDS . ".to, " . DB_FRIENDS . ".from , ".
+ DB_FRIENDS . ".approved, " " . DB_COMMENTS .
+ ".comm_id, " . DB_COMMENTS . ".time, " . DB_COMMENTS .
+ ".to, " . DB_COMMENTS . ".comm_from, " . DB_COMMENTS .
+ ".comm_to, " . DB_COMMENTS . ".comm_content FROM " . DB_USERS .
+ " JOIN " . DB_SPACE . " ON " . DB_USERS . ".id = " . DB_SPACE .
+ ".id JOIN " . DB_FRIENDS . " ON " . DB_SPACE .
+ ".id = " . DB_FRIENDS . ".to OR " . DB_SPACE .
+ ".id = " . DB_FRIENDS . ".from AND " .
+ DB_FRIENDS . ".approved = 1 LIMIT 10 JOIN " . DB_COMMENTS .
+ " ON DB_USERS . ".id = " . DB_COMMENTS . ".to ORDER BY " .
+ DB_COMMENTS . ".id DESC;";
+//Wow, I can't believe I just wrote that. Anyway, time to run it
+$_query=$db->query($_query); //If this doesn't error out I will be amazed
+
+//NEIL PEART'S GHOST! IT WORKED! (Wait, he isn't dead yet...)
+//Note: Bonus points to the first user who knows who Neil Peart is
+
+//Initialize our template so we can assign stuff in the next loop
+$space =& new template('space.tpl');
+//OK, now it's time to sort through that mess...
+
+$i=0;
+$j=0;
+while($array=$db->array($_query))
+{
+ //First, we're going to get a few things that won't change
+ //Make sure we only do this once to conserve resources
+ if($i==0)
+ {
+ $space->set('id', $array["id"]);
+ $space->set('username', $array["username"]);
+ $space->set('theme' , $array["theme"]);
+ $space->set('last_login', $array["last_login"]);
+ $space->set('space_left', $array["left"]);
+ $space->set('space_right', $array["right"]);
+ $space->set('icon', $array["icon"]);
+
+ //Finally, increment the value of $i so we don't do this
+ //again
+ $i++;
+ }
+ //Whoo... OK... time to get our hands dirty!
+
+ //First: Friends, Second: Comments
+ if($array["to"] == $id)
+ {
+ $friends_id[$j]=$array["to"];
+ }
+ else
+ {
+ $friends_id[$j]=$array["from"];
+ }
+
+ //Next: Comments (these will be fun...)
+ $comments_from[$j]=$array["comm_from"];
+ $comments_content[$j]=$array["comm_content"];
+ $comm_time[$j]=$array["time"];
+
+ //Now we need to do some lookup stuff (ie, put a username to these ID's)
+ $comments_from_username[$j]=get_username_by_id($comments_from[$j]);
+ $friends_username[$j]=get_username_by_id($friends_id[$j]);
+ $comments_from_icon[$j]=get_icon_by_id($comments_from[$j]);
+ $friends_icon[$j]=get_icon_by_id($friends_id[$j]);
+ $j++;
+}
+//Now we need to look up some permission stuff (ie, if a user is our friend)
+if(login_check) //Why can't I remember the name of this function?
+{
+ //See if this is your space
+ if($id=SESSION_ID)
+ {
+ $space->set('owner', 1);
+ }
+ //Are you a friend?
+ foreach($friends_id as $friend)
+ {
+ if($friend == SESSION_ID)
+ {
+ $space->set('friend', 1);
+ }
+ }
+}
+//Now it's time to assign some of our vars from up above
+$space->set('from_username', $comments_from_username); //Comment author
+$space->set('from_id', $comments_from); //Comment author ID
+$space->set('from_icon', $comments_from_icon); //Comment author icon
+$space->set('friend', $friends_username); //Friend's Username
+$space->set('friend_id', $friends_id); //Friend's ID
+$space->set('friend_icon', $friends_icon); //Friend's Icon
+
+//Now it's time to finish the template
+$outer =& new template('outer.tpl');
+$outer->set('content', $space);
+
+//
+///That's all, folks!
+// $Id :$
+?>
+?>
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|