[Astrospaces-commits] SF.net SVN: astrospaces: [5] trunk
Brought to you by:
p3net
From: <p3...@us...> - 2007-03-11 15:53:13
|
Revision: 5 http://astrospaces.svn.sourceforge.net/astrospaces/?rev=5&view=rev Author: p3net Date: 2007-03-11 08:53:11 -0700 (Sun, 11 Mar 2007) Log Message: ----------- -Get a temporary homepage setup -Basic Profile Functions --Register -Add thankyou() function for all the thank you's we have to use Modified Paths: -------------- trunk/common.php trunk/includes/db.php trunk/includes/template.php trunk/index.php trunk/styles/default/outer.tpl Added Paths: ----------- trunk/includes/profile.php trunk/profile.php trunk/styles/default/index_body.tpl trunk/styles/default/register.tpl trunk/styles/default/thankyou.tpl Modified: trunk/common.php =================================================================== --- trunk/common.php 2007-03-11 07:15:18 UTC (rev 4) +++ trunk/common.php 2007-03-11 15:53:11 UTC (rev 5) @@ -1,29 +1,29 @@ <?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$ * +* 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 @@ -107,10 +107,59 @@ } $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('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); +} ?> \ No newline at end of file Modified: trunk/includes/db.php =================================================================== --- trunk/includes/db.php 2007-03-11 07:15:18 UTC (rev 4) +++ trunk/includes/db.php 2007-03-11 15:53:11 UTC (rev 5) @@ -1,28 +1,28 @@ <?php /****************************************************************************** -* includes/db.php * -* AstroSPACES 2 * -* * -* Description: db.php handles database abstraction, making AstroSPACES * -* compatible with multiple db engines. It also handles connecting to the db, * -* running queries, etc. * -* * -* 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:$ * +* includes/db.php +* AstroSPACES 2 +* +* Description: db.php handles database abstraction, making AstroSPACES +* compatible with multiple db engines. It also handles connecting to the db, +* running queries, etc. +* +* 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 Added: trunk/includes/profile.php =================================================================== --- trunk/includes/profile.php (rev 0) +++ trunk/includes/profile.php 2007-03-11 15:53:11 UTC (rev 5) @@ -0,0 +1,67 @@ +<?php +/****************************************************************************** +* includes/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$ +******************************************************************************/ +class profile() +{ + function register() + { + //Redirect the user to their space if they are logged in + if(login_check) + { + header('location: space.php'); + } + + //Otherwise, display the registration form + $form =& new template('register.tpl'); + $outer =& new template('outer.tpl'); + $outer->set('content', $form); + } + function regsub($var) + { + //Sanitize our formvars + foreach($var as $clean) + { + $clean=sanitize($clean); + } + if($password != $password2) + { + $form =& new template('register.tpl'); + $outer =& new template('outer.tpl'); + $outer->set('content', $form); + $outer->set('message', "Your passwords did not match"); + } + //Time to insert... + $_query="INSERT INTO " . DB_USERS . " VALUES('', '" . $var["username"] . "', '" . md5($var["password"]) . + "', '" . $var["email"] . "', '" . $var["aim"] . "', '" . $var["msn"] . "', '" . $var["irc"] . + "', '" . $var["icq"] . "', '" . $var["yahoo"] . "', '" . $var["website"] ."');"; + + //Run the query + $db->query($_query); + + //Display a thankyou + thankyou("registering", "login", "profile.php?mode=login"); + } +} +?> \ No newline at end of file Modified: trunk/includes/template.php =================================================================== --- trunk/includes/template.php 2007-03-11 07:15:18 UTC (rev 4) +++ trunk/includes/template.php 2007-03-11 15:53:11 UTC (rev 5) @@ -1,30 +1,30 @@ <?php /****************************************************************************** -* includes/template.php * -* AstroSPACES 2 * -* * -* Description: template.php is the templating engine for AstroSPACES. While * -* not very complex, it gets the job done... * -* * -* Code borrowed shamelessly from * -* http://www.massassi.com/php/articles/template_engines/ * -* * -* 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$ * +* includes/template.php +* AstroSPACES 2 +* +* Description: template.php is the templating engine for AstroSPACES. While +* not very complex, it gets the job done... +* +* Code borrowed shamelessly from +* http://www.massassi.com/php/articles/template_engines/ +* +* 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$ ******************************************************************************/ /****************************************************************************** Modified: trunk/index.php =================================================================== --- trunk/index.php 2007-03-11 07:15:18 UTC (rev 4) +++ trunk/index.php 2007-03-11 15:53:11 UTC (rev 5) @@ -1 +1,38 @@ - +<?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 Added: trunk/profile.php =================================================================== --- trunk/profile.php (rev 0) +++ trunk/profile.php 2007-03-11 15:53:11 UTC (rev 5) @@ -0,0 +1,54 @@ +<?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; +} +?> \ No newline at end of file Added: trunk/styles/default/index_body.tpl =================================================================== --- trunk/styles/default/index_body.tpl (rev 0) +++ trunk/styles/default/index_body.tpl 2007-03-11 15:53:11 UTC (rev 5) @@ -0,0 +1,2 @@ + +Welcome to AstroSPACES. Click a link to get started. \ No newline at end of file Modified: trunk/styles/default/outer.tpl =================================================================== --- trunk/styles/default/outer.tpl 2007-03-11 07:15:18 UTC (rev 4) +++ trunk/styles/default/outer.tpl 2007-03-11 15:53:11 UTC (rev 5) @@ -22,6 +22,7 @@ <?php } ?> <!--/Admin--> <!--/Menu--> + <?php echo "<b>" . $message . "</b><br>"; ?> <?php echo $contents; ?> </body> </html> \ No newline at end of file Added: trunk/styles/default/register.tpl =================================================================== --- trunk/styles/default/register.tpl (rev 0) +++ trunk/styles/default/register.tpl 2007-03-11 15:53:11 UTC (rev 5) @@ -0,0 +1,12 @@ +<form action="profile.php?mode=process" method="post"> +Username: <input type="text" name="username"> +Password: <input type="password" name="password"> +Password [Confirm]: <input type="password" name="password2"> +Email Address: <input type="text" name="email"> +AIM: <input type="text" name="aim"> +MSN: <input type="text" name="msn"> +IRC: <input type="text" name="irc"> +ICQ: <input type="text" name="icq"> +Yahoo!: <input type="text" name="yahoo"> +Website: <input type="text" name="website"> +</form> \ No newline at end of file Added: trunk/styles/default/thankyou.tpl =================================================================== --- trunk/styles/default/thankyou.tpl (rev 0) +++ trunk/styles/default/thankyou.tpl 2007-03-11 15:53:11 UTC (rev 5) @@ -0,0 +1,6 @@ +Thank you for <?php echo $action; ?>.<br><br> +<?php if(!(empty($link1)) { ?> +Click <a href="<?php echo $link1; ?>">here</a> to <?php echo $to1; ?>.<br><br> +<?php } if(!(empty($link2)) { ?> +Click <a href="<?php echo $link2; ?>">here</a> to <?php echo $to2; ?>.<br><br> +<?php } ?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |