[Astrospaces-commits] SF.net SVN: astrospaces: [16] trunk
Brought to you by:
p3net
From: <p3...@us...> - 2007-07-28 17:20:51
|
Revision: 16 http://astrospaces.svn.sourceforge.net/astrospaces/?rev=16&view=rev Author: p3net Date: 2007-07-28 10:20:52 -0700 (Sat, 28 Jul 2007) Log Message: ----------- We are gathered here today to mourn the passing of the old files. They hath served us well. Removed Paths: ------------- trunk/TODO.txt trunk/admin/ trunk/common.php trunk/config.php trunk/doc/ trunk/includes/ trunk/index.php trunk/install/ trunk/lang/ trunk/profile.php trunk/space.php trunk/styles/ trunk/uploads/ Deleted: trunk/TODO.txt =================================================================== --- trunk/TODO.txt 2007-03-18 17:42:04 UTC (rev 15) +++ trunk/TODO.txt 2007-07-28 17:20:52 UTC (rev 16) @@ -1,4 +0,0 @@ -TODO: - ---Edit space.tpl after we have all of our functions done (send PM, etc) ---PM function \ No newline at end of file Deleted: trunk/common.php =================================================================== --- trunk/common.php 2007-03-18 17:42:04 UTC (rev 15) +++ trunk/common.php 2007-07-28 17:20:52 UTC (rev 16) @@ -1,207 +0,0 @@ -<?php -/****************************************************************************** -* common.php -* AstroSPACES 2 -* -* Description: common.php is included by every script in the AstroSPACES -* package. It sets up things we need for every page, like sessions, -* database abstraction, etc. It also includes things in the includes -* directory that we may need on a regular basis -* -* 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$ -******************************************************************************/ - -//Die if this file was accessed directly -if(!(defined('IN_ASTRO'))) -{ - die("Hacking Attempt"); -} - -//Manage creation of error message -function general_error($msg) -{ - //For the time being, just die() -- After template engine is implemented, - //we can make it look nice - die("<b>General Error</b><br /><b><u>Debug Mode</u></b><br /><br />" . $msg); -} - -//Manage our sessions -function session() -{ - //Start our session - session_start(); - - //Perform a check to make sure session vars are working well - $_SESSION["test"]="check"; - if($_SESSION["test"]!="check") - { - general_error("Could not instantiate session"); - } - - //If we made it out of our if statement, we're good to go. - //Now let's get rid of that un-needed $_SESSION value - $_SESSION["test"]=null; - - //Put important parts of the session array into defined values - - /******************* - VALUES IN ARRAY - id - User ID - level - 0 is normal, 1 is admin - ********************/ - $id=!(empty($_SESSION["id"])) ? $_SESSION["id"] : "-1"; //-1 represents an unauth'd user - $level=!(empty($_SESSION["level"])) ? $_SESSION["level"] : "-1" //-1, once again, represents unauth'd user - - define('SESSION_ID', $id); - define('SESSION_LEVEL', $level); - - //Unload the two vars we just used as temps - unset($id); - unset($level); -} - -//Construct and include everything needed on every page. -//This must be called on EVERY page -function construct() -{ - //Include everything we need for DB - require_once('includes/db.php'); - - //Templating engine - require_once('includes/template.php'); - - //Instantiate a few classes - $db =& new db(); - - //Connect to the database - $db->connect(); - - //Start our session - session(); - - //Get all of our db schema constants - $db->schema(); - - //OK, now let's get all of the information in the config table - $query="SELECT * FROM " . DB_CONFIG; - $query=$db->query($query); - while($temp=$db->array($query)) - { - //Put it in a lovely 'define' variable... - define(strtoupper("CONFIG_" . $temp["config_name"]), $temp["config_value"]); - } - $temp=null; //Unload the $temp var -} - -//Our page parsing object (for templateS) -function parse_page($content) -{ - $head =& new template('outer.tpl'); - $head->set('level', SESSION_LEVEL); - $head->set('name', CONFIG_SITE_NAME); - $head->set('content', $content); -} - -//Check to see if we are logged in -function login_check() -{ - if(SESSION_LEVEL > -1) - { - return true; - } - else - { - return false; - } -} -function sanitize($tag) -{ - //Strip out HTML - $tag=strip_tags($tag); - - //Make safe for MySQL - if($dbms == "mysql") - { - $tag=mysql_real_escape_string($tag); - } - //...and for PostgreSQL - else if($dmbs == "pgsql") - { - $tag=pg_escape_string($tag); - } - - return $tag; -} - -//Because we do a lot of thank-you type things -//We're going to write a function to output -//all of them... -function thankyou($for,$link1="",$to1="",$link2="",$to2="") -{ - $thnx =& new template('thankyou.tpl'); - $thnx->set('action',$for); - $thnx->set('link1', $link1); - $thnx->set('link2', $link2); - $thnx->set('to1', $to1); - $thnx->set('to2', $to2); - - $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"]; -} -function is_friend($id) -{ - if(!logged_in()) - { - return 0; - } - else - { - $_query="SELECT `id` FROM " . DB_FRIENDS . " WHERE `from`='" . SESSION_ID . - "' AND `to`='" . $id . "' OR `to`='" . SESSION_ID . "' AND `from`='" . - $id . "'"; - - $_query=$db->array($db->query($_query)); - if(count($_query)>0) - { - return 1; - } - else - { - return 0; - } - } -} -?> \ No newline at end of file Deleted: trunk/config.php =================================================================== --- trunk/config.php 2007-03-18 17:42:04 UTC (rev 15) +++ trunk/config.php 2007-07-28 17:20:52 UTC (rev 16) @@ -1 +0,0 @@ - Deleted: trunk/index.php =================================================================== --- trunk/index.php 2007-03-18 17:42:04 UTC (rev 15) +++ trunk/index.php 2007-07-28 17:20:52 UTC (rev 16) @@ -1,38 +0,0 @@ -<?php -/****************************************************************************** -* index.php -* AstroSPACES 2 -* -* Description: index.php simply shows our home page. It is going to be -* short and sweet, as pretty much everything is handled by profile.php, -* space.php, or comment.php. -* -* 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$ -******************************************************************************/ - -//Setup everything we need -define('IN_ASTRO', 1); -require('common.php'); -construct(); - -//Eventually, we'll get our 3 most recent users and provide a -//login box. Until then, we'll just display the page. - -$index =& new Template('index_body.tpl'); -parse_page($index); -?> \ No newline at end of file Deleted: trunk/profile.php =================================================================== --- trunk/profile.php 2007-03-18 17:42:04 UTC (rev 15) +++ trunk/profile.php 2007-07-28 17:20:52 UTC (rev 16) @@ -1,84 +0,0 @@ -<?php -/****************************************************************************** -* profile.php -* AstroSPACES 2 -* -* Description: profile.php handles all user related functions: login, logout, -* friend requests, and registrations. -* -* 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$ -******************************************************************************/ -//Setup everything we need -define('IN_ASTRO', 1); -require('common.php'); -construct(); - -//Try to get our mode -$mode=$_REQUEST["mode"]; - -//If we don't have one, error out -if(empty($mode)) -{ - general_error("No mode specified."); -} - -//Setup our profiler -require('includes/profile.php'); -$profile =& new profile(); - -//Our template switch -switch($mode) -{ - case 'register': - $profile->register(); - break; - case 'process': - $profile->regsub($_POST); - break; - case 'login': - $profile->login(); - break; - case 'loginpro': - $profile->loginGo($_POST); - break; - case 'logout': - $profile->logout(); - break; - case 'edit': - $profile->edit(); - break; - case 'update': - $profile->update($_POST, $_FILES); - break; - case 'friend_request': - $profile->request($_GET["id"]); - break; - case 'request_list': - $profile->request_list(); - break; - case 'approve': - $profile->approve($_GET["id"]); - break; - case 'comment': - $profile->comment($_GET["to"]); - break; - case 'comm_proc': - $profile->comment_proccess($_POST); - break; -} -?> \ No newline at end of file Deleted: trunk/space.php =================================================================== --- trunk/space.php 2007-03-18 17:42:04 UTC (rev 15) +++ trunk/space.php 2007-07-28 17:20:52 UTC (rev 16) @@ -1,158 +0,0 @@ -<?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_USERS . ".headline, " . - 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"]); - $space->set('headline', $array["headline"]); - - //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) -//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('comm_content', $comments_content); //Comment content -$space->set('time', date($comm_time)); //Comment time -$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 - -//Few more things - -//Owner of the space? -$me= (SESSION_ID == $id) ? '1' : '0'; - -//Friend? -$friend= (is_friend($id)) ? '1' : '0'; - -//Number of friend requests -$_query="SELECT `from` FROM " . DB_FRIENDS . " WHERE `approved`='0'"; -$space->set('friend_req', count($db->array($db->query($_query))); -$space->set('me', $me); -$space->set('friend', $friend); -$space->set('level', SESSION_LEVEL); -//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. |