astrospaces-commits Mailing List for AstroSPACES (Page 3)
Brought to you by:
p3net
You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
(13) |
Apr
|
May
|
Jun
|
Jul
(65) |
Aug
(21) |
Sep
(3) |
Oct
|
Nov
|
Dec
|
---|
From: <cal...@us...> - 2007-07-31 00:51:00
|
Revision: 54 http://astrospaces.svn.sourceforge.net/astrospaces/?rev=54&view=rev Author: caleb870 Date: 2007-07-30 17:51:01 -0700 (Mon, 30 Jul 2007) Log Message: ----------- Moved remotely Added Paths: ----------- trunk/functions/adodb/lang/ Removed Paths: ------------- trunk/functions/lang/ Copied: trunk/functions/adodb/lang (from rev 53, trunk/functions/lang) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cal...@us...> - 2007-07-31 00:50:35
|
Revision: 53 http://astrospaces.svn.sourceforge.net/astrospaces/?rev=53&view=rev Author: caleb870 Date: 2007-07-30 17:50:38 -0700 (Mon, 30 Jul 2007) Log Message: ----------- Moved remotely Added Paths: ----------- trunk/functions/adodb/generic_modules/ Removed Paths: ------------- trunk/functions/generic_modules/ Copied: trunk/functions/adodb/generic_modules (from rev 52, trunk/functions/generic_modules) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cal...@us...> - 2007-07-31 00:50:23
|
Revision: 52 http://astrospaces.svn.sourceforge.net/astrospaces/?rev=52&view=rev Author: caleb870 Date: 2007-07-30 17:50:23 -0700 (Mon, 30 Jul 2007) Log Message: ----------- Moved remotely Added Paths: ----------- trunk/functions/adodb/documentation/ Removed Paths: ------------- trunk/functions/documentation/ Copied: trunk/functions/adodb/documentation (from rev 51, trunk/functions/documentation) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cal...@us...> - 2007-07-31 00:49:58
|
Revision: 51 http://astrospaces.svn.sourceforge.net/astrospaces/?rev=51&view=rev Author: caleb870 Date: 2007-07-30 17:50:00 -0700 (Mon, 30 Jul 2007) Log Message: ----------- Moved remotely Added Paths: ----------- trunk/functions/adodb/adodbSQL_drivers/ Removed Paths: ------------- trunk/functions/adodbSQL_drivers/ Copied: trunk/functions/adodb/adodbSQL_drivers (from rev 50, trunk/functions/adodbSQL_drivers) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cal...@us...> - 2007-07-31 00:47:53
|
Revision: 50 http://astrospaces.svn.sourceforge.net/astrospaces/?rev=50&view=rev Author: caleb870 Date: 2007-07-30 17:47:55 -0700 (Mon, 30 Jul 2007) Log Message: ----------- Created folder remotely Added Paths: ----------- trunk/functions/adodb/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <p3...@us...> - 2007-07-31 00:07:54
|
Revision: 49 http://astrospaces.svn.sourceforge.net/astrospaces/?rev=49&view=rev Author: p3net Date: 2007-07-30 17:07:55 -0700 (Mon, 30 Jul 2007) Log Message: ----------- Beginnings of language engine. Includes a sample language file. Note that the actual language files will most likely have to be made during theme development by caleb Added Paths: ----------- trunk/lang/ trunk/lang/en/ trunk/lang/en/lang_main.php Added: trunk/lang/en/lang_main.php =================================================================== --- trunk/lang/en/lang_main.php (rev 0) +++ trunk/lang/en/lang_main.php 2007-07-31 00:07:55 UTC (rev 49) @@ -0,0 +1,40 @@ +<?php +/******************************************************* + * Copyright (C) 2007 http://p3net.net + + 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$ +*********************************************************/ +$lang = array(); +$main=array( + 'BLOG_AUTHOR' => 'Author', + 'BLOG_TIME' => 'Posted at', + 'BLOG_COMMENT' => 'This post has 1 comment', + 'BLOG_COMMENTS' => 'This post has %s comments', + 'BLOG_LEAVE_COMMENT' => 'Click %s to leave a comment on this post', + 'BLOG_POST' => 'New blog post', + 'BLOG_COMMENT_SUBMITTED' => 'Your comment has been submitted', + 'BLOG_POST_SUBMITTED' => 'Your post has been submitted', + 'GALLERY_VIEWS' => '%s views', + 'GALLERY_OWNER' => 'Uploaded by', + 'GALLERY_COMMENT' => 'This image has 1 comment', + 'GALLERY_COMMENTS' => 'This image has %s comments', + 'GALLERY_LEAVE_COMMEMNT' => 'Click %s to leave a comment on this image', + 'GLOBAL_HERE' => 'here', + 'ERROR_MUST_BE_LOGGEDIN' => 'You must be logged in to access this page' +) +$lang=array_merge($lang, $main); +?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cal...@us...> - 2007-07-30 23:20:49
|
Revision: 48 http://astrospaces.svn.sourceforge.net/astrospaces/?rev=48&view=rev Author: caleb870 Date: 2007-07-30 16:20:51 -0700 (Mon, 30 Jul 2007) Log Message: ----------- Finally completed converting to ADOdb, fixed a few syntax errors along the way as well. Modified Paths: -------------- trunk/config.php trunk/functions/session.php trunk/gallery.php Modified: trunk/config.php =================================================================== --- trunk/config.php 2007-07-30 22:04:51 UTC (rev 47) +++ trunk/config.php 2007-07-30 23:20:51 UTC (rev 48) @@ -1,7 +1,7 @@ <?php /* These settings are autogenerated by AstroSPACES - do not change them unless you know what you are - doing! + do not change them unless if you have instructions + stating that these values should be changed. */ define('AS_DB_TYPE', 'mysql'); define('AS_DB_PREFIX', 'as_'); @@ -17,8 +17,7 @@ define('AS_LOC_DIRECT', 'C:/path/to/astrospaces/'); /* These settings are constants and must NOT - be altered. Doing so will prevent AstroSPACES - from functioning. + be altered unless if you understand what you are doing. */ define('AS_TBL_USER', AS_DB_PREFIX.'user'); define('AS_TBL_BLOG', AS_DB_PREFIX.'blog'); @@ -30,6 +29,8 @@ define('AS_TBL_CMT', AS_DB_PREFIX.'comments'); define('AS_TBL_SESSION', AS_DB_PREFIX.'sessions'); define('AS_TBL_PM', AS_DB_PREFIX.'private_messages'); +define('AS_TBL_GRP', AS_DB_PREFIX.'groups'); +define('AS_TBL_GRP_RES', AS_DB_PREFIX.'group_resolver'); define('AS_DIR_TPL', 'template/'); define('AS_TPL', AS_LOC_URL.AS_DIR_TPL.'default/'); Modified: trunk/functions/session.php =================================================================== --- trunk/functions/session.php 2007-07-30 22:04:51 UTC (rev 47) +++ trunk/functions/session.php 2007-07-30 23:20:51 UTC (rev 48) @@ -211,6 +211,7 @@ $error->general('Invalid actionID', "Invalid actionID = Possible hack! Input value: \"".$action."\" User Hostname: ".$_SERVER['REMOTE_ADDR']); return false; } + if (!is_numeric($who) and $who != null) { $error->general('Invalid whoID', "Invalid whoID = Possible hack! Input value: \"".$who."\" User Hostname: ".$_SERVER['REMOTE_ADDR']); @@ -239,7 +240,7 @@ { if (!is_numeric($id) and $id != null) { - $error->general('Invalid friendID', "Invalid friendID = Possible hack! Input value: \"".$action."\" User Hostname: ".$_SERVER['REMOTE_ADDR']); + $error->general('Invalid friendID', "Invalid friendID = Possible hack! Input value: \"".$id."\" User Hostname: ".$_SERVER['REMOTE_ADDR']); return false; } @@ -280,6 +281,7 @@ $message->thank("adding this user as your friend. You will be alerted when they accept you as a friend.", "to go back", "javascript:history.go(-1)"); } } + } } } /* @@ -291,7 +293,7 @@ { if (!is_numeric($id) and $id != null) { - $error->general('Invalid friendID', "Invalid friendID = Possible hack! Input value: \"".$action."\" User Hostname: ".$_SERVER['REMOTE_ADDR']); + $error->general('Invalid friendID', "Invalid friendID = Possible hack! Input value: \"".$id."\" User Hostname: ".$_SERVER['REMOTE_ADDR']); return false; } $_query= 'UPDATE '.AS_TBL_FRIEND.' SET accepted = 1 WHERE party_2 = '.$data->user['user_id'].' AND party_1 = '.$id.' LIMIT 1'; @@ -307,23 +309,23 @@ { if (!is_numeric($id) and $id != null) { - $error->general('Invalid friendID', "Invalid friendID = Possible hack! Input value: \"".$action."\" User Hostname: ".$_SERVER['REMOTE_ADDR']); + $error->general('Invalid friendID', "Invalid friendID = Possible hack! Input value: \"".$id."\" User Hostname: ".$_SERVER['REMOTE_ADDR']); return false; } /*We're simply checking whether or not we have the permissions to view this space */ /*First we need to figure out what the space privacy setting is*/ $_query = 'SELECT privacy FROM '.AS_TBL_USER.' WHERE id = ' . $id . ' LIMIT 1'; $_query = $db->Execute($_query); - $_query=$db->fetch_array($_query); - $res=$_query['privacy']; + $_query = $db->GetArray($_query); + $res = $_query[0]['privacy']; if($res == '0') { - /*All users can view this space*/ + /* All users can view this space */ return true; } else { - /*We need to check if we're they're friend*/ + /* We need to check if we're they're friend */ if($session->is_friend($id)) { return true; @@ -341,17 +343,22 @@ */ function add_comment($id) { + if (!is_numeric($id) and $id != null) + { + $error->general('Invalid userID', "Invalid userD = Possible hack! Input value: \"".$id."\" User Hostname: ".$_SERVER['REMOTE_ADDR']); + return false; + } if($session->is_friend($id)) { - /*Okay, we have permission to leave this comment*/ - foreach($_POST as $key => $value) - { - $var[$key] = mysql_real_escape_string($value); - } - $_query="INSERT INTO `comments` VALUES('', '" . time() . "', '" . $user->data['user_id'] . "', '" . $id . "', '" . $var['body'] . - "'"; - $db->query($_query); - $session->action('2', $id); + /* Okay, we have permission to leave this comment */ + $_query = 'INSERT INTO '.AS_TBL_CMT.' (comment_timestamp, poster_id, recipient_id, comment) VALUES(' . + time() . ',' . $user->data['user_id'] . ',' . $id . ',' . $db->qstr($_POST['body']).')'; + if ($db->Execute($_query) === false) + { + $error->general('<b>DB Error!</b>', 'session.php - add_comment(): '.$db->ErrorMsg()); + return false; + } + $session->action('2', $id); } } /* @@ -361,10 +368,15 @@ */ function get_username($id) { - $_query="SELECT `display_name` FROM `users` WHERE `id`='" . $id . "'"; - $_query=$db->query($_query); - $res=$db->fetch_array($_query); - return $res['display_name']; + if (!is_numeric($id) and $id != null) + { + $error->general('Invalid userID', "Invalid userID = Possible hack! Input value: \"".$id."\" User Hostname: ".$_SERVER['REMOTE_ADDR']); + return false; + } + $_query = 'SELECT display_name FROM '.AS_TBL_USER.' WHERE id = ' . $id; + $_query = $db->Execute($_query); + $res = $db->GetArray($_query); + return $res[0]['display_name']; } /* Function Name: add_image_comment @@ -373,19 +385,25 @@ */ function add_image_comment($id) { - $owner = "SELECT `owner` FROM `images` WHERE `id`='" . $id . "'"; + if (!is_numeric($id) and $id != null) + { + $error->general('Invalid imageID', "Invalid imageID = Possible hack! Input value: \"".$id."\" User Hostname: ".$_SERVER['REMOTE_ADDR']); + return false; + } + + $owner = 'SELECT owner_id FROM '.AS_TBL_IMG.' WHERE id = ' . $id; $owner = $db->query($owner); $owner = $db->fetch_array($owner); $owner = $owner['owner']; - if($session->is_friend($owner)) + if ($session->is_friend($owner)) { - foreach($_POST as $key => $value) - { - $var[$key] = mysql_real_escape_string($value); - } - $_query="INSERT INTO `image_comments` VALUES('', '" . $id . "', '" . time() . "', '" . $user->data['user_id'] . "', '" . $var['comment'] . "'"; - $db->query($_query); - } + $_query = 'INSERT INTO '.AS_TBL_IMG_CMT.' (image_id, post_timestamp, author, comment) VALUES('. $id . ',' . time() . ',' . $user->data['user_id'] . ',' . $db->qstr($_POST['comment'],get_magic_quotes_gpc()) . ')'; + if ($db->Execute($_query) === false) + { + $error->general('<b>DB Error!</b>', 'session.php - add_img_comment(): '.$db->ErrorMsg()); + return false; + } + } } /* Function Name: generate_timestamp @@ -394,14 +412,20 @@ */ function generate_timestamp($time) { + if (!is_numeric($time) and $time != null) + { + $error->general('Invalid timestamp', "Invalid timestamp = Possible hack! Input value: \"".$time."\" User Hostname: ".$_SERVER['REMOTE_ADDR']); + return false; + } + if($session->logged_in()) { - $_query="SELECT `time_offset` FROM `users` WHERE `id`='" . $user->data['user_id'] . "'"; - $_query=$db->query($_query); - $_query=$db->fetch_array($_query); - $offset=$_query['time_offset']; - - $diff = $offset * 60 * 60; + $_query = 'SELECT time_offset FROM '.AS_TBL_USER.' WHERE id = ' . $user->data['user_id']; + $_query = $db->Execute($_query); + $_query = $query->GetArray($_query); + $offset = $_query[0]['time_offset']; + + $diff = $offset * 60 * 60; } $time = $time + $diff; return date('m/d/Y G:i:s', $time); Modified: trunk/gallery.php =================================================================== --- trunk/gallery.php 2007-07-30 22:04:51 UTC (rev 47) +++ trunk/gallery.php 2007-07-30 23:20:51 UTC (rev 48) @@ -66,17 +66,17 @@ $img_com = $db->Execute( $_query ); $count = $img_com->RecordCount(); - for ($i = 0; $i < $count; $i++) /* What? */ + $array = $img_com->GetArray(); + foreach($array[0] as $key_name => $key_value) { - foreach($value as $key_name => $key_value) - { - if ($key_value == 'author') - { - $key_value = $session->get_username($key_value); - } - $com[$key_name] = $key_value; - } - $img_con->MoveNext(); + if (!is_numeric($key_name)) + { + if ($key_value == 'author') + { + $key_value = $session->get_username($key_value); + } + $com[$key_name] = $key_value; + } } $img_com->Close(); $img = $img->GetArray(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <p3...@us...> - 2007-07-30 22:04:54
|
Revision: 47 http://astrospaces.svn.sourceforge.net/astrospaces/?rev=47&view=rev Author: p3net Date: 2007-07-30 15:04:51 -0700 (Mon, 30 Jul 2007) Log Message: ----------- Add basic COPPA support Modified Paths: -------------- trunk/template/default/forms/register.tpl Modified: trunk/template/default/forms/register.tpl =================================================================== --- trunk/template/default/forms/register.tpl 2007-07-30 20:52:43 UTC (rev 46) +++ trunk/template/default/forms/register.tpl 2007-07-30 22:04:51 UTC (rev 47) @@ -0,0 +1,2 @@ +<form action="" method="post"> +<input type="submit" name="submit" value="I Agree to These Terms and Am No Younger than 13 Years of Age"></form> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <del...@us...> - 2007-07-30 20:52:42
|
Revision: 46 http://astrospaces.svn.sourceforge.net/astrospaces/?rev=46&view=rev Author: deltalabs Date: 2007-07-30 13:52:43 -0700 (Mon, 30 Jul 2007) Log Message: ----------- I *think* I got everything switched to the new schema. If anyone notices anything that didn't get changed, let me know. Modified Paths: -------------- trunk/gallery.php trunk/group.php trunk/images.php trunk/index.php trunk/profile.php trunk/viewspace.php Modified: trunk/gallery.php =================================================================== --- trunk/gallery.php 2007-07-30 20:32:28 UTC (rev 45) +++ trunk/gallery.php 2007-07-30 20:52:43 UTC (rev 46) @@ -36,7 +36,7 @@ { if($session->is_friend($id)) { - $_query = 'SELECT id FROM '.AS_TBL_IMG.' WHERE owner = '.$db->qstr($id,get_magic_quotes_gpc()); + $_query = 'SELECT img_id FROM '.AS_TBL_IMG.' WHERE owner_id = '.$db->qstr($id,get_magic_quotes_gpc()); $_query = $db->Execute($_query); $_query = $db->GetArray($_query); $gallery = new template(AS_DIR_TPL.'gallery.tpl'); @@ -59,10 +59,10 @@ { if( $session->is_friend($owner) ) { - $_query = 'SELECT * FROM '.AS_TBL_IMG.' WHERE id = '.$db->qstr($img_id,get_magic_quotes_gpc()); + $_query = 'SELECT * FROM '.AS_TBL_IMG.' WHERE img_id = '.$db->qstr($img_id,get_magic_quotes_gpc()); $img = $db->Execute( $_query ); - $_query = 'SELECT * FROM '.AS_TBL_IMG_CMT.' WHERE image = '.$db->qstr($img_id,get_magic_quotes_gpc()); + $_query = 'SELECT * FROM '.AS_TBL_IMG_CMT.' WHERE image_id = '.$db->qstr($img_id,get_magic_quotes_gpc()); $img_com = $db->Execute( $_query ); $count = $img_com->RecordCount(); @@ -84,7 +84,7 @@ if ( isset($user->data['user_id']) and $user->data['user_id'] != $img['owner'] ) { $img['views']++; - $_query = 'UPDATE '.AS_TBL_IMG." SET views = '" . $views . "' WHERE id = '" . $img_id . "'"; + $_query = 'UPDATE '.AS_TBL_IMG." SET views = '" . $views . "' WHERE img_id = '" . $img_id . "'"; $db->query($_query); } $drill = new template(AS_TPL.'drill.tpl'); Modified: trunk/group.php =================================================================== --- trunk/group.php 2007-07-30 20:32:28 UTC (rev 45) +++ trunk/group.php 2007-07-30 20:52:43 UTC (rev 46) @@ -1,21 +1,21 @@ -<?php -/******************************************************* - * Copyright (C) 2007 http://p3net.net - - 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$ -*********************************************************/ +<?php +/******************************************************* + * Copyright (C) 2007 http://p3net.net + + 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$ +*********************************************************/ ?> \ No newline at end of file Modified: trunk/images.php =================================================================== --- trunk/images.php 2007-07-30 20:32:28 UTC (rev 45) +++ trunk/images.php 2007-07-30 20:52:43 UTC (rev 46) @@ -33,7 +33,7 @@ { $error->general("Invalid ID specified", "Not an (int)"); } - $_query = 'SELECT * FROM '.AS_TBL_IMG.' WHERE id = '.$db->qstr($id,get_magic_quotes_gpc()); + $_query = 'SELECT * FROM '.AS_TBL_IMG.' WHERE img_id = '.$db->qstr($id,get_magic_quotes_gpc()); $img = $db->Execute($_query); $img = $img->GetArray(); @@ -53,7 +53,7 @@ { $error->general("Invalid ID specified", "Not an (int)"); } - $_query = 'SELECT * FROM '.AS_TBL_IMG.' WHERE id = '.$db->qstr($id,get_magic_quotes_gpc()); + $_query = 'SELECT * FROM '.AS_TBL_IMG.' WHERE img_id = '.$db->qstr($id,get_magic_quotes_gpc()); $_query = $db->Execute($_query); $img = $db->GetArray($_query); Modified: trunk/index.php =================================================================== --- trunk/index.php 2007-07-30 20:32:28 UTC (rev 45) +++ trunk/index.php 2007-07-30 20:52:43 UTC (rev 46) @@ -20,12 +20,12 @@ *********************************************************/ include('globals.php'); /* 5 most recent users should be enough. We can fill the rest with ads or something */ -$_query = 'SELECT id, display_name, user_image FROM '.AS_TBL_USER.' SORT BY id DESC LIMIT 5'; +$_query = 'SELECT user_id, display_name, user_image FROM '.AS_TBL_USER.' SORT BY user_id DESC LIMIT 5'; $_query = $db->Execute($_query); while($user = $_query->FetchRow()) { $userdetail[$user['display_name']] = array( - 'id' => $user['id'], + 'id' => $user['user_id'], 'icon' => $user['user_image'] ); } Modified: trunk/profile.php =================================================================== --- trunk/profile.php 2007-07-30 20:32:28 UTC (rev 45) +++ trunk/profile.php 2007-07-30 20:52:43 UTC (rev 46) @@ -35,10 +35,10 @@ } 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_date, time_offset) '; $_query .= 'VALUES('.$db->qstr($vars["display_name"],get_magic_quotes_gpc()).','; $_query .= $db->qstr(md5($vars["password"]),get_magic_quotes_gpc()).','; - $_query .= time().','.qstr($vars["offset"],get_magic_quotes_gpc()).')'; + $_query .= mktime().','.qstr($vars["offset"],get_magic_quotes_gpc()).')'; if ($db->Execute($_query) === false) { @@ -102,7 +102,7 @@ $content = addslashes($content); fclose($fp); - $_query = 'INSERT INTO '.AS_TBL_IMG.' (owner, content, mime_type, desc, width, height, name, views)' + $_query = 'INSERT INTO '.AS_TBL_IMG.' (owner_id, content, mime_type, desc, width, height, name, views)' .'VALUES('. $user->data["user_id"] . ',' . $db->qstr($content) . ',' . $db->qstr($file_type) . "', ''" .$db->qstr(htmlspecialchars($_POST["desc"]),get_magic_quotes_gpc()).','.$width.','.$height.','.$db->qstr($file_name,get_magic_quotes_gpc()).", '0')"; if ($db->Execute($_query) === false) @@ -133,13 +133,13 @@ { $var[$key] = $db->qstr(htmlspecialchars($value),get_magic_quotes_gpc()); } - $_query = 'SELECT id FROM '.AS_TBL_USER.' WHERE email = ' . $var['email'] . ' AND password = ' . qstr(md5($var['password'])); + $_query = 'SELECT user_id FROM '.AS_TBL_USER.' WHERE email = ' . $var['email'] . ' AND password = ' . qstr(md5($var['password'])); $_query = $db->Execute($_query); $num = $_query->RecordCount(); if($num > 0) { $id = $_query->GetArray(); - $session->login($id[0]['id']); + $session->login($id[0]['user_id']); $message->thank('logging in', 'to return to the index', 'index.php'); } else @@ -155,15 +155,18 @@ */ function inbox() { - $_query = 'SELECT id, from, date, subject, read FROM '.AS_TBL_PM.' ORDER BY id DESC'; + $_uid_query = 'SELECT user_id FROM '.AS_TBL_USER.' WHERE email = ' . $var['email'] . ' AND password = ' . qstr(md5($var['password'])); + $_uid_query = $db->Execute($_query); + $uid = $_query->GetArray(); + $_query = 'SELECT message_id, sender_id, send_date, subject, read FROM '.AS_TBL_PM.' WHERE recipient_id = '.$uid[0]['user_id'].' ORDER BY id DESC'; $_query = $db->Execute($_query); $count = $_query->RecordCount(); for ($i = 0; $i < $count; $i++) { $pm[$i] = array( - 'id' => $_query->Fields('id'), - 'from' => $session->get_username($_query->Fields('from')), - 'date' => $session->generate_timestamp($_query->Fields('date')), + 'id' => $_query->Fields('message_id'), + 'from' => $session->get_username($_query->Fields('sender_id')), + 'date' => $session->generate_timestamp($_query->Fields('send_date')), 'subject' => $_query->Fields('subject'), 'read' => $_query->Fields('read') ); @@ -184,12 +187,12 @@ $error->general('Invalid userID', "Invalid userID = Possible hack! Input value: \"".$id."\" User Hostname: ".$_SERVER['REMOTE_ADDR']); return false; } - $_query = 'SELECT * FROM '.AS_TBL_PM.' WHERE id = ' . $id; + $_query = 'SELECT * FROM '.AS_TBL_PM.' WHERE message_id = ' . $id; $_query = $db->Execute($_query); $array = $db->GetArray($_query); $read =& new template(AS_TPL.'read.tpl'); - $read->set_var('from', $session->get_username($array[0]["from"])); - $read->set_var('date', $session->generate_timestamp($array[0]["date"])); + $read->set_var('from', $session->get_username($array[0]["sender_id"])); + $read->set_var('date', $session->generate_timestamp($array[0]["send_date"])); $read->set_var('subject', $array[0]["subject"]); $read->set_var('message', $array[0]["message"]); if($array[0]['read'] != '1') Modified: trunk/viewspace.php =================================================================== --- trunk/viewspace.php 2007-07-30 20:32:28 UTC (rev 45) +++ trunk/viewspace.php 2007-07-30 20:52:43 UTC (rev 46) @@ -1,23 +1,23 @@ -<?php -/******************************************************* - * Copyright (C) 2007 http://p3net.net - - 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$ -*********************************************************/ -/* Todo: If no id is set or id is yours, show you owner view instead - Alternatively, actual view will be shown if &view=real is appended*/ +<?php +/******************************************************* + * Copyright (C) 2007 http://p3net.net + + 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$ +*********************************************************/ +/* Todo: If no id is set or id is yours, show you owner view instead + Alternatively, actual view will be shown if &view=real is appended*/ ?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <del...@us...> - 2007-07-30 20:32:28
|
Revision: 45 http://astrospaces.svn.sourceforge.net/astrospaces/?rev=45&view=rev Author: deltalabs Date: 2007-07-30 13:32:28 -0700 (Mon, 30 Jul 2007) Log Message: ----------- Added mime-type to as_images Modified Paths: -------------- trunk/develop/new-schema.sql Modified: trunk/develop/new-schema.sql =================================================================== --- trunk/develop/new-schema.sql 2007-07-30 20:16:14 UTC (rev 44) +++ trunk/develop/new-schema.sql 2007-07-30 20:32:28 UTC (rev 45) @@ -84,6 +84,7 @@ `height` int(4) unsigned NOT NULL, `name` text NOT NULL, `views` int(6) unsigned NOT NULL, + `mime_type` varchar(20) NOT NULL, PRIMARY KEY (`img_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cal...@us...> - 2007-07-30 20:16:11
|
Revision: 44 http://astrospaces.svn.sourceforge.net/astrospaces/?rev=44&view=rev Author: caleb870 Date: 2007-07-30 13:16:14 -0700 (Mon, 30 Jul 2007) Log Message: ----------- A small fix for an error I made in the configuration file, which was that I put the prefix for the DB tables as a prefix for the directory declarations accidentally. Modified Paths: -------------- trunk/config.php Modified: trunk/config.php =================================================================== --- trunk/config.php 2007-07-30 20:02:42 UTC (rev 43) +++ trunk/config.php 2007-07-30 20:16:14 UTC (rev 44) @@ -13,8 +13,8 @@ define('AS_EXT', '.php'); define('AS_LANG', 'en-us'); -define('AS_LOC_URL', AS_DB_PREFIX.'http://localhost/'); -define('AS_LOC_DIRECT', AS_DB_PREFIX.'C:/path/to/astrospaces/'); +define('AS_LOC_URL', 'http://localhost/'); +define('AS_LOC_DIRECT', 'C:/path/to/astrospaces/'); /* These settings are constants and must NOT be altered. Doing so will prevent AstroSPACES This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
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. |
From: <cal...@us...> - 2007-07-30 19:46:38
|
Revision: 42 http://astrospaces.svn.sourceforge.net/astrospaces/?rev=42&view=rev Author: caleb870 Date: 2007-07-30 12:46:37 -0700 (Mon, 30 Jul 2007) Log Message: ----------- Just fixed a minor bug with loading config.php since it's calling a constant that is defined in config.php before its actually defined. Modified Paths: -------------- trunk/globals.php Modified: trunk/globals.php =================================================================== --- trunk/globals.php 2007-07-30 19:40:16 UTC (rev 41) +++ trunk/globals.php 2007-07-30 19:46:37 UTC (rev 42) @@ -19,7 +19,7 @@ @id: $Id$ *********************************************************/ /* Include our larger functions */ -require(AS_LOC_DIRECT.'config.php'); +require('config.php'); /* Do not put 'AS_LOC_DIRECT' before this one */ require(AS_LOC_DIRECT.'functions/template.php'); $template =& new template(); require(AS_LOC_DIRECT.'functions/session.php'); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <p3...@us...> - 2007-07-30 19:40:18
|
Revision: 41 http://astrospaces.svn.sourceforge.net/astrospaces/?rev=41&view=rev Author: p3net Date: 2007-07-30 12:40:16 -0700 (Mon, 30 Jul 2007) Log Message: ----------- We're storing images as blobs. It's nicer that way. Modified Paths: -------------- trunk/config.php trunk/develop/new-schema.sql trunk/functions/template.php Removed Paths: ------------- branches/ tags/ Modified: trunk/config.php =================================================================== --- trunk/config.php 2007-07-30 19:29:45 UTC (rev 40) +++ trunk/config.php 2007-07-30 19:40:16 UTC (rev 41) @@ -1,15 +1,8 @@ <?php -/* Old-style -$db_info = array( - 'user' => '', - 'pass' => '', - 'host' => '', - 'name' => '' - ); +/* These settings are autogenerated by AstroSPACES + do not change them unless you know what you are + doing! */ -define('AS_EXT', '.php'); -define('AS_LANG', 'en-us'); - define('AS_DB_TYPE', 'mysql'); define('AS_DB_PREFIX', 'as_'); define('AS_DB_HOST', 'localhost'); @@ -17,9 +10,16 @@ define('AS_DB_USER', 'user'); define('AS_DB_PASS', 'pass'); +define('AS_EXT', '.php'); +define('AS_LANG', 'en-us'); + define('AS_LOC_URL', AS_DB_PREFIX.'http://localhost/'); define('AS_LOC_DIRECT', AS_DB_PREFIX.'C:/path/to/astrospaces/'); +/* These settings are constants and must NOT + be altered. Doing so will prevent AstroSPACES + from functioning. +*/ define('AS_TBL_USER', AS_DB_PREFIX.'user'); define('AS_TBL_BLOG', AS_DB_PREFIX.'blog'); define('AS_TBL_BLOG_CMT', AS_DB_PREFIX.'blog_comments'); Modified: trunk/develop/new-schema.sql =================================================================== --- trunk/develop/new-schema.sql 2007-07-30 19:29:45 UTC (rev 40) +++ trunk/develop/new-schema.sql 2007-07-30 19:40:16 UTC (rev 41) @@ -77,7 +77,7 @@ CREATE TABLE `as_images` ( `img_id` int(10) unsigned NOT NULL auto_increment, `owner_id` int(10) unsigned NOT NULL, - `content` varchar(45) NOT NULL COMMENT 'path to image on server', + `content` blob NOT NULL COMMENT 'binary image', `desc` text NOT NULL, `width` int(4) unsigned NOT NULL, `height` int(4) unsigned NOT NULL, Modified: trunk/functions/template.php =================================================================== --- trunk/functions/template.php 2007-07-30 19:29:45 UTC (rev 40) +++ trunk/functions/template.php 2007-07-30 19:40:16 UTC (rev 41) @@ -16,7 +16,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$ *********************************************************/ class template { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <del...@us...> - 2007-07-30 19:29:51
|
Revision: 40 http://astrospaces.svn.sourceforge.net/astrospaces/?rev=40&view=rev Author: deltalabs Date: 2007-07-30 12:29:45 -0700 (Mon, 30 Jul 2007) Log Message: ----------- Added Paths: ----------- trunk/develop/new-schema.sql Added: trunk/develop/new-schema.sql =================================================================== --- trunk/develop/new-schema.sql (rev 0) +++ trunk/develop/new-schema.sql 2007-07-30 19:29:45 UTC (rev 40) @@ -0,0 +1,130 @@ +DROP TABLE IF EXISTS `as_actions`; +CREATE TABLE `as_actions` ( + `action_id` int(10) unsigned NOT NULL auto_increment, + `action_timestamp` int(10) unsigned NOT NULL, + `action` int(2) unsigned NOT NULL, + `for` int(11) unsigned NOT NULL, + PRIMARY KEY (`action_id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +DROP TABLE IF EXISTS `as_blog`; +CREATE TABLE `as_blog` ( + `blog_id` int(10) unsigned NOT NULL auto_increment, + `title` varchar(45) NOT NULL, + `blog_timestamp` int(10) unsigned NOT NULL, + `content` text NOT NULL, + `author_id` int(11) unsigned NOT NULL, + PRIMARY KEY (`blog_id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +DROP TABLE IF EXISTS `as_blog_comment`; +CREATE TABLE `as_blog_comment` ( + `comment_id` int(10) unsigned NOT NULL auto_increment, + `author_id` int(10) unsigned NOT NULL, + `comment` text NOT NULL, + `post_timestamp` int(10) unsigned NOT NULL, + PRIMARY KEY (`comment_id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +DROP TABLE IF EXISTS `as_comments`; +CREATE TABLE `as_comments` ( + `comment_id` int(10) unsigned NOT NULL auto_increment, + `comment_timestamp` int(10) unsigned NOT NULL, + `poster_id` int(11) unsigned NOT NULL, + `recipient_id` int(11) unsigned NOT NULL, + `comment` text NOT NULL, + PRIMARY KEY (`comment_id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC; + +DROP TABLE IF EXISTS `as_friends`; +CREATE TABLE `as_friends` ( + `couple_id` int(10) unsigned NOT NULL auto_increment, + `user1_id` int(10) unsigned NOT NULL, + `user2_id` int(10) unsigned NOT NULL, + `accepted` tinyint(1) unsigned NOT NULL, + PRIMARY KEY (`couple_id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC; + +DROP TABLE IF EXISTS `as_group_resolver`; +CREATE TABLE `as_group_resolver` ( + `pair_id` int(10) unsigned NOT NULL auto_increment, + `user_id` int(10) unsigned NOT NULL, + `group_id` int(10) unsigned NOT NULL, + `join_date` int(10) unsigned NOT NULL COMMENT 'Unix timestamp', + PRIMARY KEY (`pair_id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC; + +DROP TABLE IF EXISTS `as_groups`; +CREATE TABLE `as_groups` ( + `group_id` int(10) unsigned NOT NULL auto_increment, + `name` varchar(45) NOT NULL, + `founder` int(11) unsigned NOT NULL, + `create_timestamp` int(10) unsigned NOT NULL, + PRIMARY KEY (`group_id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC; + +DROP TABLE IF EXISTS `as_image_comments`; +CREATE TABLE `as_image_comments` ( + `comment_id` int(10) unsigned NOT NULL auto_increment, + `image_id` int(11) unsigned NOT NULL, + `post_timestamp` int(10) unsigned NOT NULL, + `author` int(11) unsigned NOT NULL, + `comment` text NOT NULL, + PRIMARY KEY (`comment_id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +DROP TABLE IF EXISTS `as_images`; +CREATE TABLE `as_images` ( + `img_id` int(10) unsigned NOT NULL auto_increment, + `owner_id` int(10) unsigned NOT NULL, + `content` varchar(45) NOT NULL COMMENT 'path to image on server', + `desc` text NOT NULL, + `width` int(4) unsigned NOT NULL, + `height` int(4) unsigned NOT NULL, + `name` text NOT NULL, + `views` int(6) unsigned NOT NULL, + PRIMARY KEY (`img_id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +DROP TABLE IF EXISTS `as_private_messages`; +CREATE TABLE `as_private_messages` ( + `message_id` int(10) unsigned NOT NULL auto_increment, + `sender_id` int(11) unsigned NOT NULL, + `recipient_id` int(11) unsigned NOT NULL, + `send_date` int(10) unsigned NOT NULL, + `subject` varchar(80) NOT NULL, + `message` text NOT NULL, + `read` tinyint(1) unsigned NOT NULL default '0', + PRIMARY KEY (`message_id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +DROP TABLE IF EXISTS `as_sessions`; +CREATE TABLE `as_sessions` ( + `session_id` int(10) unsigned NOT NULL auto_increment, + `user_id` int(11) unsigned NOT NULL, + `ip` varchar(12) NOT NULL, + `last_update` int(10) unsigned NOT NULL, + PRIMARY KEY (`session_id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC; + +DROP TABLE IF EXISTS `as_users`; +CREATE TABLE `as_users` ( + `user_id` int(10) unsigned NOT NULL auto_increment, + `display_name` varchar(45) NOT NULL, + `password` varchar(16) NOT NULL, + `join_date` int(10) unsigned NOT NULL COMMENT 'Unix timestamp', + `last_login` int(10) unsigned NOT NULL COMMENT 'Unix timestamp', + `time_offset` tinyint(3) unsigned NOT NULL, + `blurb` text NOT NULL, + `email` varchar(60) NOT NULL, + `aim` varchar(45) NOT NULL, + `yim` varchar(45) NOT NULL, + `jabber` varchar(45) NOT NULL, + `irc` varchar(45) NOT NULL, + `icq` varchar(45) NOT NULL, + `msn` varchar(45) NOT NULL, + `user_image` int(11) unsigned NOT NULL, + `clean_url` varchar(45) NOT NULL, + `privacy` tinyint(1) unsigned NOT NULL default '0', + PRIMARY KEY (`user_id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cal...@us...> - 2007-07-30 17:26:19
|
Revision: 39 http://astrospaces.svn.sourceforge.net/astrospaces/?rev=39&view=rev Author: caleb870 Date: 2007-07-30 10:26:15 -0700 (Mon, 30 Jul 2007) Log Message: ----------- Major revision: Changed all calls to the database through ADOdb. Also fixed over 40 typos, syntax errors, and bugs in the process, and changed calls to the template system (still needs work). Modified Paths: -------------- trunk/config.php trunk/functions/session.php trunk/gallery.php trunk/globals.php trunk/images.php trunk/index.php trunk/profile.php Modified: trunk/config.php =================================================================== --- trunk/config.php 2007-07-30 04:57:52 UTC (rev 38) +++ trunk/config.php 2007-07-30 17:26:15 UTC (rev 39) @@ -23,14 +23,16 @@ define('AS_TBL_USER', AS_DB_PREFIX.'user'); define('AS_TBL_BLOG', AS_DB_PREFIX.'blog'); define('AS_TBL_BLOG_CMT', AS_DB_PREFIX.'blog_comments'); -define('AS_TBL_FRIEND', AS_DB_PREFIX.'friend'); +define('AS_TBL_FRIEND', AS_DB_PREFIX.'friends'); define('AS_TBL_IMG', AS_DB_PREFIX.'images'); define('AS_TBL_IMG_CMT', AS_DB_PREFIX.'image_comments'); define('AS_TBL_ACTION', AS_DB_PREFIX.'actions'); define('AS_TBL_CMT', AS_DB_PREFIX.'comments'); define('AS_TBL_SESSION', AS_DB_PREFIX.'sessions'); -define('AS_TBL_PM', AS_DB_PREFIX.'pm'); +define('AS_TBL_PM', AS_DB_PREFIX.'private_messages'); define('AS_DIR_TPL', 'template/'); -define('AS_TPL', AS_LOC_URL.AS_DIR_TPL); +define('AS_TPL', AS_LOC_URL.AS_DIR_TPL.'default/'); + + ?> \ No newline at end of file Modified: trunk/functions/session.php =================================================================== --- trunk/functions/session.php 2007-07-30 04:57:52 UTC (rev 38) +++ trunk/functions/session.php 2007-07-30 17:26:15 UTC (rev 39) @@ -36,9 +36,13 @@ /* We don't have a session and aren't logged in. Let's create it */ $id = md5(time() . rand(1,1000)); /* Check to make sure it's unique */ - $_query="INSERT INTO `sessions` VALUES('" . $id . "', '-1', '" . $REMOTE_ADDR . "', '" . time() . "')"; - $db->query($_query); - $_COOKIE["session_id"] = $id; + $_query = 'INSERT INTO '.AS_TBL_SESSION.' (id, user_id, ip, last_update) VALUES(' . $id . ','.$db->qstr('-1').',' . $db->qstr($_SERVER['REMOTE_ADDR']) . ',' . time() . ')'; + if ($db->Execute($_query) === false) + { + $error->general('<b>DB Error!</b>', 'session.php - create(): '.$db->ErrorMsg()); + return false; + } + $_COOKIE['session_id'] = $id; } /* Function Name: check @@ -49,35 +53,48 @@ { /* We need to check if a session exists by looking for the session cookie. If that's not there, then we return false (since the user isn't logged in). We also match the IP */ - $ip = $REMOTE_ADDR; - $_query = "SELECT * FROM `sessions` WHERE `ip` = '" . $ip . "'"; - $res = $db->query($_query); - if(mysql_num_rows($res) == 0) + $ip = $_SERVER['REMOTE_ADDR']; + $_query = 'SELECT * FROM '.AS_TBL_SESSION.' WHERE ip = ' . $db->qstr($ip); + $res = $db->Execute($_query); + $count = $res->RecordCount(); + if($count == 0) { - $session->create(); + $session->create(); } else { - /* Get an array of our session info */ - $res = $db->fetch_array($res); - if($res['id'] != $_COOKIE["session_id"]) - { - $session->create(); - } - else - { - foreach($res as $key => $value) - { - $user->data[$key] = $value; - } - /* Update our updated time */ - $_query="UPDATE `sessions` SET `last_update` = '" . time() . "' WHERE `id` = '" . $user->data['id'] . "' LIMIT 1"; - $db->query($_query); - } - } + /* Get an array of our session info */ + $res = $res->GetArray(); + if($res[0]['id'] != $_COOKIE['session_id']) + { + $session->create(); + } + else + { + $array = $res->GetArray(); + foreach($array[0] as $key => $value) + { + if (!is_numeric($key)) + { + $user->data[$key] = $value; + } + } + /* Update our updated time */ + $_query = 'UPDATE '.AS_TBL_SESSION.' SET last_update = ' . time() . ' WHERE id = ' . $user->data['id'] . ' LIMIT 1'; + if ($db->Execute($_query) === false) + { + $error->general('<b>DB Error!</b>', 'session.php - check(): '.$db->ErrorMsg()); + return false; + } + } + } /* We also need to get rid of users who haven't done anything in the last half-hour */ - $_query = "DELETE * FROM `sessions` WHERE `last_update` < " . (time() - (60*30)); - $db->query($_query); + $_query = 'DELETE FROM '.AS_TBL_SESSION.' WHERE last_update < ' . (time() - (60*30)); + if ($db->Execute($_query) === false) + { + $error->general('<b>DB Error!</b>', 'session.php - check(): '.$db->ErrorMsg()); + return false; + } } /* Function Name: logged_in @@ -102,18 +119,27 @@ */ function login($user_id) { + if (!is_numeric($user_id) and $user_id != null) + { + $error->general('Invalid userID', "Invalid userID = Possible hack! Input value: \"".$user_id."\" User Hostname: ".$_SERVER['REMOTE_ADDR']); + return false; + } $session->check(); if($session->logged_in()) { - /* Wait - what? */ - $error->general("Already logged in", "Session already populated"); + /* Wait - what? */ + $error->general("Already logged in", "Session already populated"); } else { - $_query = "UPDATE `sessions` SET `user_id` = '" . $user_id . "' WHERE `id` = '" . $_COOKIE["session_id"] . " LIMIT 1"; - $db->query($_query); - /* Run the session check again. It'll make the row and populate $user->data */ - $session->check(); + $_query = 'UPDATE '.AS_TBL_SESSION.' SET user_id = ' . $user_id . ' WHERE id = ' . $db->qstr($_COOKIE["session_id"]) . ' LIMIT 1'; + if ($db->Execute($_query) === false) + { + $error->general('<b>DB Error!</b>', 'session.php - login(): '.$db->ErrorMsg()); + return false; + } + /* Run the session check again. It'll make the row and populate $user->data */ + $session->check(); } } /* @@ -125,13 +151,13 @@ { if($session->logged_in()) { - $_query = "UPDATE `sessions` SET `user_id` = '-1' WHERE `id` = '" . $user->data['id'] . "' AND `ip` = '" . $user->data['ip'] . "' LIMIT 1"; - $db->query($_query); - $user->data = null; + $_query = 'UPDATE '.AS_TBL_SESSION.' SET user_id = '.$db->qstr('-1').' WHERE id = ' . $user->data['id'] . ' AND ip = ' . $db->qstr($user->data['ip']) . ' LIMIT 1'; + $db->query($_query); + $user->data = null; } else { - $error->general('Not logged in', 'User ID = -1'); + $error->general('Not logged in', 'User ID = -1'); } } /* @@ -141,31 +167,36 @@ */ function is_friend($id) { + if (!is_numeric($id)) + { + $error->general('Invalid userID', "Invalid userID = Possible hack! Input value: \"".$id."\" User Hostname: ".$_SERVER['REMOTE_ADDR']); + return false; + } if(!$user->logged_in()) { - return false; + return false; } else { - $_query = "SELECT * FROM `friends` WHERE `party_1` = '" . $user->data['user_id'] . "' AND AND `party_2`='" . $id . "' AND `accepted`='1'"; - $_query = $db->query($_query); - if(mysql_num_rows($_query) > 0) + $_query = 'SELECT count(*) FROM '.AS_TBL_FRIEND.' WHERE party_1 = ' . $user->data['user_id'] . ' AND party_2 = ' . $id . ' AND accepted = 1'; + $_query = $db->Execute($_query); + if($_query->fields[0] > 0) + { + return true; + } + else + { + $_query = 'SELECT count(*) FROM '.AS_TBL_FRIEND.' WHERE party_2 = ' . $user->data['user_id'] . ' AND party_1 = ' . $id . ' AND accepted = 1'; + $_query = $db->Execute($_query); + if($_query->fields[0] > 0) { - return true; + return true; } else { - $_query = "SELECT * FROM `friends` WHERE `party_2` = '" . $user->data['user_id'] . "' AND `party_1`='" . $id . "' AND `accepted`='1'"; - $_query = $db->query($_query); - if(mysql_num_rows($_query) > 0) - { - return true; - } - else - { - return false; - } + return false; } + } } } /* @@ -173,8 +204,18 @@ Arguments: (int) action -- Add action to action table; (int) who -- ID of friend action is made towards. If unspecified, applies to all Purpose: */ - function action($action, $who="") + function action($action, $who = null) { + if (!is_numeric($action) and $action != null) + { + $error->general('Invalid actionID', "Invalid actionID = Possible hack! Input value: \"".$action."\" User Hostname: ".$_SERVER['REMOTE_ADDR']); + return false; + } + if (!is_numeric($who) and $who != null) + { + $error->general('Invalid whoID', "Invalid whoID = Possible hack! Input value: \"".$who."\" User Hostname: ".$_SERVER['REMOTE_ADDR']); + return false; + } /*List of actions: 1. Updated Space 2. Left you a comment @@ -185,7 +226,7 @@ 7. Left you a comment on a blog post 8. Joined a group 9. Created a group */ - $_query="INSERT INTO `actions` VALUES('" . time() . "', '" . $user->data['user_id'] . "', '" . $action . "', '" . $who . "')"; + $_query = 'INSERT INTO '.AS_TBL_ACTION.' (time, who, action, for) VALUES(' . time() . ',' . $user->data['user_id'] . ', ' . $action . ', ' . $who . ')'; $db->query($_query); return true; } @@ -196,39 +237,48 @@ */ function add_friend($id) { + if (!is_numeric($id) and $id != null) + { + $error->general('Invalid friendID', "Invalid friendID = Possible hack! Input value: \"".$action."\" User Hostname: ".$_SERVER['REMOTE_ADDR']); + return false; + } + if(!$user->logged_in()) { - $error->general("Not logged in", "Add as friend"); + $error->general("Not logged in", "Add as friend"); } else { - if($user->is_friend($id)) + if($user->is_friend($id)) + { + $error->general("Already friend", "Add as friend"); + } + else + { + $_query = 'SELECT count(*) FROM '.AS_TBL_FRIEND.' WHERE (party_1 = ' . $user->data['user_id'] . ' AND party_2 = ' . $id; + $_query = $db->query($_query); + if ($_query->fields[0] > 0) { - $error->general("Already friend", "Add as friend"); - } + $error->general("Already added as friend, awaiting acception", "Add as friend"); + } else { - $_query = "SELECT * FROM `friends` WHERE `party_1`='" . $user->data['user_id'] . " AND `party_2`='" . $id . "'"; - $_query=$db->query($_query); - if(mysql_num_rows($_query) > 0) - { - $error->general("Already added as friend, awaiting acception", "Add as friend"); - } - else - { - $_query = "SELECT * FROM `friends` WHERE `party_2`='" . $user->data['user_id'] . " AND `party_1`='" . $id . "'"; - $_query=$db->query($_query); - if(mysql_num_rows($_query) > 0) - { - $error->general("User has already added you as a friend. Accept them in your friend control panel.", "Add as friend"); - } - else - { - $_query="INSERT INTO `friends` VALUES('" . $user->data['user_id'] . "', '" . $id . "', '0'"; - $db->query($_query); - $message->thank("adding this user as your friend. You will be alerted when they accept you as a friend.", "to go back", "javascript:history.go(-1)"); - } - } + $_query = 'SELECT count(*) FROM '.AS_TBL_FRIEND.' WHERE party_2 = ' . $user->data['user_id'] . ' AND party_1 = ' . $id; + $_query = $db->Execute($_query); + if ($_query->fields[0] > 0) + { + $error->general("User has already added you as a friend. Accept them in your friend control panel.", "Add as friend"); + } + else + { + $_query='INSERT INTO '.AS_TBL_FRIEND.' VALUES(' . $user->data['user_id'] . ',' . $id . ',0)'; + if ($db->Execute($_query) === false) + { + $error->general('<b>DB Error!</b>', 'session.php - add_friend(): '.$db->ErrorMsg()); + return false; + } + $message->thank("adding this user as your friend. You will be alerted when they accept you as a friend.", "to go back", "javascript:history.go(-1)"); + } } } } @@ -239,7 +289,12 @@ */ function accept_friend($id) { - $_query="UPDATE `friends` SET `accepted`='1' WHERE `party_2`='" . $data->user['user_id'] . "' AND `party_1='" . $id . "' LIMIT 1"; + if (!is_numeric($id) and $id != null) + { + $error->general('Invalid friendID', "Invalid friendID = Possible hack! Input value: \"".$action."\" User Hostname: ".$_SERVER['REMOTE_ADDR']); + return false; + } + $_query= 'UPDATE '.AS_TBL_FRIEND.' SET accepted = 1 WHERE party_2 = '.$data->user['user_id'].' AND party_1 = '.$id.' LIMIT 1'; $db->query($_query); $user->action(5, $id); } @@ -250,10 +305,15 @@ */ function can_view($id) { + if (!is_numeric($id) and $id != null) + { + $error->general('Invalid friendID', "Invalid friendID = Possible hack! Input value: \"".$action."\" User Hostname: ".$_SERVER['REMOTE_ADDR']); + return false; + } /*We're simply checking whether or not we have the permissions to view this space */ /*First we need to figure out what the space privacy setting is*/ - $_query="SELECT `privacy` FROM `users` WHERE `id`='" . $id . "' LIMIT 1"; - $_query=$db->query($_query); + $_query = 'SELECT privacy FROM '.AS_TBL_USER.' WHERE id = ' . $id . ' LIMIT 1'; + $_query = $db->Execute($_query); $_query=$db->fetch_array($_query); $res=$_query['privacy']; if($res == '0') Modified: trunk/gallery.php =================================================================== --- trunk/gallery.php 2007-07-30 04:57:52 UTC (rev 38) +++ trunk/gallery.php 2007-07-30 17:26:15 UTC (rev 39) @@ -18,6 +18,7 @@ @id: $Id$ *********************************************************/ + class gallery { /* @@ -35,11 +36,11 @@ { if($session->is_friend($id)) { - $_query="SELECT `id` FROM `images` WHERE `owner`='" . $id . "'"; - $_query=$db->query($_query); - $_query=$db->fetch_array($_query); - $gallery =& new template('gallery.tpl'); - $gallery->set('gallery', $_query); + $_query = 'SELECT id FROM '.AS_TBL_IMG.' WHERE owner = '.$db->qstr($id,get_magic_quotes_gpc()); + $_query = $db->Execute($_query); + $_query = $db->GetArray($_query); + $gallery = new template(AS_DIR_TPL.'gallery.tpl'); + $gallery->set_var('gallery', $_query); } } } @@ -48,46 +49,50 @@ Arguments: (int) img_id -- ID of image to view; (int) owner -- ID of image uploader Purpose: View fullsize image/comments of specific image */ - function drill($img_id, $owner) + function drill( $img_id, $owner ) { - if(empty($img_id)) + if( empty( $img_id ) ) { $error->general('An image must be specified', 'Tried to access drill without specifying image id'); } else { - if($session->is_friend($owner)) + if( $session->is_friend($owner) ) { - $_query = "SELECT * FROM `images` WHERE `id`='" . $img_id . "'"; - $img = $db->query($_query); + $_query = 'SELECT * FROM '.AS_TBL_IMG.' WHERE id = '.$db->qstr($img_id,get_magic_quotes_gpc()); + $img = $db->Execute( $_query ); - $_query = "SELECT * FROM `images_comments` WHERE `image`='" . $img_id . "'"; - $img_com = $db->query($_query); + $_query = 'SELECT * FROM '.AS_TBL_IMG_CMT.' WHERE image = '.$db->qstr($img_id,get_magic_quotes_gpc()); + $img_com = $db->Execute( $_query ); - foreach($db->fetch_array($img_com) as $key => $value) + $count = $img_com->RecordCount(); + for ($i = 0; $i < $count; $i++) /* What? */ { foreach($value as $key_name => $key_value) { - if($key_value == 'author') + if ($key_value == 'author') { $key_value = $session->get_username($key_value); } $com[$key_name] = $key_value; } + $img_con->MoveNext(); } - $img=$db->fetch_array($img); - if(isset($user->data['user_id'] && $user->data['user_id'] != $img['owner']) + $img_com->Close(); + $img = $img->GetArray(); + + if ( isset($user->data['user_id']) and $user->data['user_id'] != $img['owner'] ) { $img['views']++; - $_query="UPDATE `images` SET `views`='" . $views . "' WHERE `id`='" . $img_id . "'"; + $_query = 'UPDATE '.AS_TBL_IMG." SET views = '" . $views . "' WHERE id = '" . $img_id . "'"; $db->query($_query); } - $drill =& new template('drill.tpl'); - $drill->set('id', $img_id); - $drill->set('comments', $com); - $drill->set('views', $img['views']); - $drill->set('desc', $img['desc']); - $drill->set('name', $img['name']); + $drill = new template(AS_TPL.'drill.tpl'); + $drill->set_var('id', $img_id); + $drill->set_var('comments', $com); + $drill->set_var('views', $img['views']); + $drill->set_var('desc', $img['desc']); + $drill->set_var('name', $img['name']); } } } @@ -100,7 +105,7 @@ { if($session->is_friend($owner)) { - $form =& new template('forms/gallery_comment.tpl'); + $form = new template(AS_TPL.'forms/gallery_comment.tpl'); } } /* @@ -110,14 +115,16 @@ */ function comment_process() { - $img_id=$_POST["id"]; + $img_id = $_POST['id']; $session->add_image_comment($img_id); } } -$gallery =& new gallery; + +include('globals.php'); +$gallery =& new gallery(); $mode = empty($_GET["mode"]) ? 'view' : $_GET["mode"]; $id = empty($_GET["id"]) ? ($session->logged_in() ? $user->data['user_id'] : 0) : mysql_real_escape_string($_GET["id"]); -switch $mode +switch ($mode) { case 'view': $gallery->view($id); Modified: trunk/globals.php =================================================================== --- trunk/globals.php 2007-07-30 04:57:52 UTC (rev 38) +++ trunk/globals.php 2007-07-30 17:26:15 UTC (rev 39) @@ -19,10 +19,12 @@ @id: $Id$ *********************************************************/ /* Include our larger functions */ -require_once('./functions/template.php'); -$template =& new template; -require_once('./functions/session.php'); +require(AS_LOC_DIRECT.'config.php'); +require(AS_LOC_DIRECT.'functions/template.php'); +$template =& new template(); +require(AS_LOC_DIRECT.'functions/session.php'); $user =& new session(); +require(AS_LOC_DIRECT.'functions/adodb/adodb.inc.php'); /*The smaller ones*/ class error @@ -34,7 +36,7 @@ */ function general($err, $verbose) { - $error =& new template('messages/error.tpl'); + $error =& new template(AS_TPL.'messages/error.tpl'); $error->set('err', $err); $handle = fopen('logs/errors.txt', 'w'); if($handle) @@ -59,19 +61,19 @@ */ function thank($message, $go1, $res1, $go2="", $res2="") { - $message =& new template('message/thank.tpl'); - $message->set('go1', $go1); - $message->set('go2', $go2); - $message->set('res1', $res1); - $message->set('res2', $res2); - $message->set('message', $message); + $message =& new template(AS_TPL.'message/thank.tpl'); + $message->set_var('go1', $go1); + $message->set_var('go2', $go2); + $message->set_var('res1', $res1); + $message->set_var('res2', $res2); + $message->set_var('message', $message); } } -/* To satisfy ZDE */ -require_once('./functions/db.php'); -$db =& new db; /* Our functions living in globals.php */ $error =& new error; $message =& new message(); + +$db =& new ADOConnection(AS_DB_TYPE); +$db->Connect(AS_DB_HOST, AS_DB_USER, AS_DB_PASS, AS_DB_SCHEMA); ?> \ No newline at end of file Modified: trunk/images.php =================================================================== --- trunk/images.php 2007-07-30 04:57:52 UTC (rev 38) +++ trunk/images.php 2007-07-30 17:26:15 UTC (rev 39) @@ -33,12 +33,13 @@ { $error->general("Invalid ID specified", "Not an (int)"); } - $_query = "SELECT * FROM `images` WHERE `id`='" . $id . "'"; - $img=$db->fetch_array($db->query($_query)); + $_query = 'SELECT * FROM '.AS_TBL_IMG.' WHERE id = '.$db->qstr($id,get_magic_quotes_gpc()); + $img = $db->Execute($_query); + $img = $img->GetArray(); - header('Content-type: ' . $img['mine_type']); - header('Content-Disposition: attachment; filename=' . $img['name']); - echo $img['content']; + header('Content-Type: ' . $img[0]['mime_type']); + header('Content-Disposition: attachment; filename=' . $img[0]['name']); + echo $img[0]['content']; } /* Function Name: thumb @@ -48,30 +49,31 @@ function thumb($id) { $id = is_numeric($_GET["id"]) ? $_GET["id"] : null; - if(empty($id)) + if(!empty($id)) { $error->general("Invalid ID specified", "Not an (int)"); } - $_query = "SELECT * FROM `images` WHERE `id`='" . $id . "'"; - $img=$db->fetch_array($db->query($_query)); + $_query = 'SELECT * FROM '.AS_TBL_IMG.' WHERE id = '.$db->qstr($id,get_magic_quotes_gpc()); + $_query = $db->Execute($_query); + $img = $db->GetArray($_query); /* We're going to resize the larger dimension to 150px */ - if($img['width'] > $img['height']) + if($img[0]['width'] > $img[0]['height']) { - $scale_percentage = $img['width'] / 150; + $scale_percentage = $img[0]['width'] / 150; } else { - $scale_percentage = $img['height'] / 150; + $scale_percentage = $img[0]['height'] / 150; } $new_dimensions = array( - 'width' => ($scale_percentage < 1) ? $img['width'] * $scale_percentage : $img['width'], - 'height' => ($scale_percentage < 1) ? $img['height'] * $scale_percentage : $img['height'] + 'width' => ($scale_percentage < 1) ? $img[0]['width'] * $scale_percentage : $img[0]['width'], + 'height' => ($scale_percentage < 1) ? $img[0]['height'] * $scale_percentage : $img[0]['height'] ); - header('Content-type: ' . $img['mine_type']); - header('Content-Disposition: attachment; filename=' . $img['name']); + header('Content-Type: ' . $img[0]['mime_type']); + header('Content-Disposition: attachment; filename=' . $img[0]['name']); - $type = explode("/", $img['mine_type']); + $type = explode("/", $img[0]['mine_type']); $type = $type[1]; switch($type) { @@ -86,7 +88,7 @@ break; } $res = imagecreatetruecolor($new_dimensions['width'], $new_dimensions['height']); - imagecopyresized($res, $new_image, 0, 0, 0, 0, $new_dimensions['width'], $new_dimensions['height'], $img['width'], $img['height']); + imagecopyresized($res, $new_image, 0, 0, 0, 0, $new_dimensions['width'], $new_dimensions['height'], $img[0]['width'], $img[0]['height']); switch($type) { @@ -104,7 +106,7 @@ } /* Actually handle the data here */ -$mode=empty($_GET["mode"]) ? '' : $_GET["mode"]; +$mode = empty($_GET["mode"]) ? '' : $_GET["mode"]; switch($mode) { case 'view': Modified: trunk/index.php =================================================================== --- trunk/index.php 2007-07-30 04:57:52 UTC (rev 38) +++ trunk/index.php 2007-07-30 17:26:15 UTC (rev 39) @@ -1,34 +1,34 @@ -<?php -/******************************************************* - * Copyright (C) 2007 http://p3net.net - - 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$ -*********************************************************/ -include('globals.php'); -/* 5 most recent users should be enough. We can fill the rest with ads or something */ -$_query = "SELECT `id`, `display_name`, `user_image` FROM `users` SORT BY `id` DESC LIMIT 5"; -$res = ($db->query($_query); -while($user = $db->fetch_array($_query)) -{ - $userdetail[$user['display_name']] = array( - 'id' => $user['id'], - `icon` => $user['user_image'] - ); -} -$index =& new template('home.tpl'); -$index->set('userdetail', $userdetail); +<?php +/******************************************************* + * Copyright (C) 2007 http://p3net.net + + 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$ +*********************************************************/ +include('globals.php'); +/* 5 most recent users should be enough. We can fill the rest with ads or something */ +$_query = 'SELECT id, display_name, user_image FROM '.AS_TBL_USER.' SORT BY id DESC LIMIT 5'; +$_query = $db->Execute($_query); +while($user = $_query->FetchRow()) +{ + $userdetail[$user['display_name']] = array( + 'id' => $user['id'], + 'icon' => $user['user_image'] + ); +} +$index = template(AS_TPL.'home.tpl'); +$index->set_var('userdetail', $userdetail); ?> \ No newline at end of file Modified: trunk/profile.php =================================================================== --- trunk/profile.php 2007-07-30 04:57:52 UTC (rev 38) +++ trunk/profile.php 2007-07-30 17:26:15 UTC (rev 39) @@ -31,18 +31,22 @@ $step = empty($_GET["step"]) ? '1' : $_GET["step"]; if($step == 1) { - $form =& new template('forms/register.tpl'); + $form =& new template(AS_TPL.'forms/register.tpl'); } else if($step == 2) { - foreach($_POST as $key => $value) - { - $vars[$key] = mysql_real_escape_string($value); - } - $_query = "INSERT INTO users (`id`, `display_name`, `password`, `join`, `time_offset` VALUES('', '" . $vars["display_name"] . "', '" . - md5($vars["password"] . "', '" . time() . "', '" . $vars["offset"] . "')"; - $db->query($_query); - $message->thank('for registering.', 'to proceed to the login page.', 'profile.php?mode=login'); + $_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 .= time().','.qstr($vars["offset"],get_magic_quotes_gpc()).')'; + + if ($db->Execute($_query) === false) + { + $error->general("<b>DB Error!</b>", $db->ErrorMsg()); + return false; + } else { + $message->thank('for registering.', 'to proceed to the login page.', 'profile.php?mode=login'); + } } } /* @@ -78,7 +82,7 @@ $step = empty($_GET["step"]) ? '1' : $_GET["step"]; if($step == 1) { - $form =& new template('forms/upload_pic.tpl'); + $form =& new template(AS_TPL.'forms/upload_pic.tpl'); } else { @@ -98,9 +102,14 @@ $content = addslashes($content); fclose($fp); - $_query="INSERT INTO `images` VALUES('', '" . $user->data["user_id"] . "', '" . $content . "', '" . $file_type . "', ''" - . mysql_real_escape_string(htmlspecialchars($_POST["desc"])) "', '" . $width . "', '" . $height . ",'" . $file_name . "', '0');"; - $db->query($_query); + $_query = 'INSERT INTO '.AS_TBL_IMG.' (owner, content, mime_type, desc, width, height, name, views)' + .'VALUES('. $user->data["user_id"] . ',' . $db->qstr($content) . ',' . $db->qstr($file_type) . "', ''" + .$db->qstr(htmlspecialchars($_POST["desc"]),get_magic_quotes_gpc()).','.$width.','.$height.','.$db->qstr($file_name,get_magic_quotes_gpc()).", '0')"; + if ($db->Execute($_query) === false) + { + $error->general("<b>DB Error!</b>", $db->ErrorMsg()); + return false; + } $user->action(4, ''); $message->thank('for uploading an image', 'go back to the previous page', 'javascript:history.go(\'-2\')'); @@ -116,21 +125,21 @@ $step = empty($_GET["step"]) ? '1' : $_GET["step"]; if($step == 1) { - $form =& new template('forms/login.tpl'); + $form =& new template(AS_TPL.'forms/login.tpl'); } else { foreach($_POST as $key => $value) { - $var[$key] = mysql_real_escape_string(htmlspecialchars($value)); + $var[$key] = $db->qstr(htmlspecialchars($value),get_magic_quotes_gpc()); } - $_query = "SELECT `id` FROM `users` WHERE `email` = '" . $var['email'] . "' AND `password` = '" . md5($var['password']) . "'"; - $_query = $db->query($_query); - $num = mysql_num_rows($_query); + $_query = 'SELECT id FROM '.AS_TBL_USER.' WHERE email = ' . $var['email'] . ' AND password = ' . qstr(md5($var['password'])); + $_query = $db->Execute($_query); + $num = $_query->RecordCount(); if($num > 0) { - $id = $db->fetch_array($_query); - $session->login($id['id']); + $id = $_query->GetArray(); + $session->login($id[0]['id']); $message->thank('logging in', 'to return to the index', 'index.php'); } else @@ -146,42 +155,51 @@ */ function inbox() { - $_query="SELECT `id`, `from`, `date`, `subject`, `read` FROM `private_messages` ORDER BY `id` DESC"; - $_query=$db->query($_query); - $i=0; - while($temp=$db->fetch_array($_query)) - { - $pm[$i] = array( - 'id' => $temp['id'], - 'from' => $session->get_username($temp['from']), - 'date' => $session->generate_timestamp($temp['date']), - 'subject' => $temp['subject'], - 'read' => $temp['read'] - ); - $i++; - } - $template =& new template('inbox.tpl'); - $template->set('pm', $pm); + $_query = 'SELECT id, from, date, subject, read FROM '.AS_TBL_PM.' ORDER BY id DESC'; + $_query = $db->Execute($_query); + $count = $_query->RecordCount(); + for ($i = 0; $i < $count; $i++) + { + $pm[$i] = array( + 'id' => $_query->Fields('id'), + 'from' => $session->get_username($_query->Fields('from')), + 'date' => $session->generate_timestamp($_query->Fields('date')), + 'subject' => $_query->Fields('subject'), + 'read' => $_query->Fields('read') + ); + $_query->MoveNext(); + } + $template =& new template(AS_TPL.'inbox.tpl'); + $template->set_var('pm', $pm); } /* Function Name: message Arguments: (int) id -- Private message ID Purpose: Display a private message */ - function message(mysql_real_escape_string($id)) + function message($id) { - $_query="SELECT * FROM `private_messages` WHERE `id`='" . $id . "'"; - $_query=$db->query($_query); - $arr=$db->fetch_array($_query); - $read =& new template('read.tpl'); - $read->set('from', $session->get_username($arr["from"])); - $read->set('date', $session->generate_timestamp($arr["date"])); - $read->set('subject', $arr["subject"]); - $read->set('message', $arr["message"]); - if($arr["read"] != '1') + if (!is_numeric($id)) + { + $error->general('Invalid userID', "Invalid userID = Possible hack! Input value: \"".$id."\" User Hostname: ".$_SERVER['REMOTE_ADDR']); + return false; + } + $_query = 'SELECT * FROM '.AS_TBL_PM.' WHERE id = ' . $id; + $_query = $db->Execute($_query); + $array = $db->GetArray($_query); + $read =& new template(AS_TPL.'read.tpl'); + $read->set_var('from', $session->get_username($array[0]["from"])); + $read->set_var('date', $session->generate_timestamp($array[0]["date"])); + $read->set_var('subject', $array[0]["subject"]); + $read->set_var('message', $array[0]["message"]); + if($array[0]['read'] != '1') { - $_query="UPDATE `private_messages` SET `read`='1' WHERE `id`='" . $id . "'"; - $db->query($_query); + $_query = 'UPDATE '.AS_TBL_PM.' SET read = 1 WHERE id = ' . $id; + if ($db->Execute($_query) === false) + { + $error->general('<b>DB Error!</b>', $db->ErrorMsg()); + return false; + } } } /* @@ -191,7 +209,7 @@ */ function send() { - $template =& new template('send.tpl'); + $template =& new template(AS_TPL.'send.tpl'); } /* Function Name: send_process @@ -203,7 +221,7 @@ } } $profile =& new profile; -switch $_GET["mode"] +switch ($_GET["mode"]) { case 'register': $profile->register(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cal...@us...> - 2007-07-30 04:57:49
|
Revision: 38 http://astrospaces.svn.sourceforge.net/astrospaces/?rev=38&view=rev Author: caleb870 Date: 2007-07-29 21:57:52 -0700 (Sun, 29 Jul 2007) Log Message: ----------- Adding ADOdb lite. Added Paths: ----------- trunk/functions/adodb-datadict.inc.php trunk/functions/adodb-error.inc.php trunk/functions/adodb-errorhandler.inc.php trunk/functions/adodb-errorpear.inc.php trunk/functions/adodb-exceptions.inc.php trunk/functions/adodb-perf-module.inc.php trunk/functions/adodb-perf.inc.php trunk/functions/adodb-time.inc.php trunk/functions/adodb-xmlschema.inc.php trunk/functions/adodb.config.php trunk/functions/adodb.inc.php trunk/functions/adodbSQL_drivers/ trunk/functions/adodbSQL_drivers/fbsql/ trunk/functions/adodbSQL_drivers/fbsql/fbsql_datadict.inc trunk/functions/adodbSQL_drivers/fbsql/fbsql_date_module.inc trunk/functions/adodbSQL_drivers/fbsql/fbsql_driver.inc trunk/functions/adodbSQL_drivers/fbsql/fbsql_extend_module.inc trunk/functions/adodbSQL_drivers/fbsql/fbsql_meta_module.inc trunk/functions/adodbSQL_drivers/fbsql/fbsql_transaction_module.inc trunk/functions/adodbSQL_drivers/gladius/ trunk/functions/adodbSQL_drivers/gladius/gladius_datadict.inc trunk/functions/adodbSQL_drivers/gladius/gladius_date_module.inc trunk/functions/adodbSQL_drivers/gladius/gladius_driver.inc trunk/functions/adodbSQL_drivers/gladius/gladius_extend_module.inc trunk/functions/adodbSQL_drivers/gladius/gladius_meta_module.inc trunk/functions/adodbSQL_drivers/gladius/gladius_transaction_module.inc trunk/functions/adodbSQL_drivers/maxdb/ trunk/functions/adodbSQL_drivers/maxdb/maxdb_datadict.inc trunk/functions/adodbSQL_drivers/maxdb/maxdb_date_module.inc trunk/functions/adodbSQL_drivers/maxdb/maxdb_driver.inc trunk/functions/adodbSQL_drivers/maxdb/maxdb_extend_module.inc trunk/functions/adodbSQL_drivers/maxdb/maxdb_meta_module.inc trunk/functions/adodbSQL_drivers/maxdb/maxdb_transaction_module.inc trunk/functions/adodbSQL_drivers/msql/ trunk/functions/adodbSQL_drivers/msql/msql_datadict.inc trunk/functions/adodbSQL_drivers/msql/msql_date_module.inc trunk/functions/adodbSQL_drivers/msql/msql_driver.inc trunk/functions/adodbSQL_drivers/msql/msql_extend_module.inc trunk/functions/adodbSQL_drivers/msql/msql_meta_module.inc trunk/functions/adodbSQL_drivers/msql/msql_transaction_module.inc trunk/functions/adodbSQL_drivers/mssql/ trunk/functions/adodbSQL_drivers/mssql/mssql_datadict.inc trunk/functions/adodbSQL_drivers/mssql/mssql_date_module.inc trunk/functions/adodbSQL_drivers/mssql/mssql_driver.inc trunk/functions/adodbSQL_drivers/mssql/mssql_extend_module.inc trunk/functions/adodbSQL_drivers/mssql/mssql_meta_module.inc trunk/functions/adodbSQL_drivers/mssql/mssql_transaction_module.inc trunk/functions/adodbSQL_drivers/mssqlpo/ trunk/functions/adodbSQL_drivers/mssqlpo/mssqlpo_datadict.inc trunk/functions/adodbSQL_drivers/mssqlpo/mssqlpo_date_module.inc trunk/functions/adodbSQL_drivers/mssqlpo/mssqlpo_driver.inc trunk/functions/adodbSQL_drivers/mssqlpo/mssqlpo_extend_module.inc trunk/functions/adodbSQL_drivers/mssqlpo/mssqlpo_meta_module.inc trunk/functions/adodbSQL_drivers/mssqlpo/mssqlpo_transaction_module.inc trunk/functions/adodbSQL_drivers/mysql/ trunk/functions/adodbSQL_drivers/mysql/mysql_datadict.inc trunk/functions/adodbSQL_drivers/mysql/mysql_date_module.inc trunk/functions/adodbSQL_drivers/mysql/mysql_driver.inc trunk/functions/adodbSQL_drivers/mysql/mysql_extend_module.inc trunk/functions/adodbSQL_drivers/mysql/mysql_meta_module.inc trunk/functions/adodbSQL_drivers/mysql/mysql_perfmon_module.inc trunk/functions/adodbSQL_drivers/mysql/mysql_transaction_module.inc trunk/functions/adodbSQL_drivers/mysqli/ trunk/functions/adodbSQL_drivers/mysqli/mysqli_datadict.inc trunk/functions/adodbSQL_drivers/mysqli/mysqli_date_module.inc trunk/functions/adodbSQL_drivers/mysqli/mysqli_driver.inc trunk/functions/adodbSQL_drivers/mysqli/mysqli_extend_module.inc trunk/functions/adodbSQL_drivers/mysqli/mysqli_meta_module.inc trunk/functions/adodbSQL_drivers/mysqli/mysqli_perfmon_module.inc trunk/functions/adodbSQL_drivers/mysqli/mysqli_transaction_module.inc trunk/functions/adodbSQL_drivers/mysqlt/ trunk/functions/adodbSQL_drivers/mysqlt/mysqlt_datadict.inc trunk/functions/adodbSQL_drivers/mysqlt/mysqlt_date_module.inc trunk/functions/adodbSQL_drivers/mysqlt/mysqlt_driver.inc trunk/functions/adodbSQL_drivers/mysqlt/mysqlt_extend_module.inc trunk/functions/adodbSQL_drivers/mysqlt/mysqlt_meta_module.inc trunk/functions/adodbSQL_drivers/mysqlt/mysqlt_perfmon_module.inc trunk/functions/adodbSQL_drivers/mysqlt/mysqlt_transaction_module.inc trunk/functions/adodbSQL_drivers/odbc/ trunk/functions/adodbSQL_drivers/odbc/odbc_datadict.inc trunk/functions/adodbSQL_drivers/odbc/odbc_date_module.inc trunk/functions/adodbSQL_drivers/odbc/odbc_driver.inc trunk/functions/adodbSQL_drivers/odbc/odbc_extend_module.inc trunk/functions/adodbSQL_drivers/odbc/odbc_meta_module.inc trunk/functions/adodbSQL_drivers/odbc/odbc_transaction_module.inc trunk/functions/adodbSQL_drivers/postgres/ trunk/functions/adodbSQL_drivers/postgres/postgres_datadict.inc trunk/functions/adodbSQL_drivers/postgres/postgres_date_module.inc trunk/functions/adodbSQL_drivers/postgres/postgres_driver.inc trunk/functions/adodbSQL_drivers/postgres/postgres_extend_module.inc trunk/functions/adodbSQL_drivers/postgres/postgres_meta_module.inc trunk/functions/adodbSQL_drivers/postgres/postgres_transaction_module.inc trunk/functions/adodbSQL_drivers/postgres64/ trunk/functions/adodbSQL_drivers/postgres64/postgres64_datadict.inc trunk/functions/adodbSQL_drivers/postgres64/postgres64_date_module.inc trunk/functions/adodbSQL_drivers/postgres64/postgres64_driver.inc trunk/functions/adodbSQL_drivers/postgres64/postgres64_extend_module.inc trunk/functions/adodbSQL_drivers/postgres64/postgres64_meta_module.inc trunk/functions/adodbSQL_drivers/postgres64/postgres64_transaction_module.inc trunk/functions/adodbSQL_drivers/postgres7/ trunk/functions/adodbSQL_drivers/postgres7/postgres7_datadict.inc trunk/functions/adodbSQL_drivers/postgres7/postgres7_date_module.inc trunk/functions/adodbSQL_drivers/postgres7/postgres7_driver.inc trunk/functions/adodbSQL_drivers/postgres7/postgres7_extend_module.inc trunk/functions/adodbSQL_drivers/postgres7/postgres7_meta_module.inc trunk/functions/adodbSQL_drivers/postgres7/postgres7_transaction_module.inc trunk/functions/adodbSQL_drivers/postgres8/ trunk/functions/adodbSQL_drivers/postgres8/postgres8_datadict.inc trunk/functions/adodbSQL_drivers/postgres8/postgres8_date_module.inc trunk/functions/adodbSQL_drivers/postgres8/postgres8_driver.inc trunk/functions/adodbSQL_drivers/postgres8/postgres8_extend_module.inc trunk/functions/adodbSQL_drivers/postgres8/postgres8_meta_module.inc trunk/functions/adodbSQL_drivers/postgres8/postgres8_transaction_module.inc trunk/functions/adodbSQL_drivers/sqlite/ trunk/functions/adodbSQL_drivers/sqlite/sqlite_datadict.inc trunk/functions/adodbSQL_drivers/sqlite/sqlite_date_module.inc trunk/functions/adodbSQL_drivers/sqlite/sqlite_driver.inc trunk/functions/adodbSQL_drivers/sqlite/sqlite_extend_module.inc trunk/functions/adodbSQL_drivers/sqlite/sqlite_meta_module.inc trunk/functions/adodbSQL_drivers/sqlite/sqlite_transaction_module.inc trunk/functions/adodbSQL_drivers/sqlitepo/ trunk/functions/adodbSQL_drivers/sqlitepo/sqlitepo_datadict.inc trunk/functions/adodbSQL_drivers/sqlitepo/sqlitepo_date_module.inc trunk/functions/adodbSQL_drivers/sqlitepo/sqlitepo_driver.inc trunk/functions/adodbSQL_drivers/sqlitepo/sqlitepo_extend_module.inc trunk/functions/adodbSQL_drivers/sqlitepo/sqlitepo_meta_module.inc trunk/functions/adodbSQL_drivers/sqlitepo/sqlitepo_transaction_module.inc trunk/functions/adodbSQL_drivers/sybase/ trunk/functions/adodbSQL_drivers/sybase/sybase_datadict.inc trunk/functions/adodbSQL_drivers/sybase/sybase_date_module.inc trunk/functions/adodbSQL_drivers/sybase/sybase_driver.inc trunk/functions/adodbSQL_drivers/sybase/sybase_extend_module.inc trunk/functions/adodbSQL_drivers/sybase/sybase_meta_module.inc trunk/functions/adodbSQL_drivers/sybase/sybase_transaction_module.inc trunk/functions/adodbSQL_drivers/sybase_ase/ trunk/functions/adodbSQL_drivers/sybase_ase/sybase_ase_datadict.inc trunk/functions/adodbSQL_drivers/sybase_ase/sybase_ase_date_module.inc trunk/functions/adodbSQL_drivers/sybase_ase/sybase_ase_driver.inc trunk/functions/adodbSQL_drivers/sybase_ase/sybase_ase_extend_module.inc trunk/functions/adodbSQL_drivers/sybase_ase/sybase_ase_meta_module.inc trunk/functions/adodbSQL_drivers/sybase_ase/sybase_ase_transaction_module.inc trunk/functions/documentation/ trunk/functions/documentation/adodb_license.txt trunk/functions/documentation/adodb_lite_commands.html trunk/functions/documentation/adodb_lite_datadictionary.html trunk/functions/documentation/adodb_lite_debugconsole.html trunk/functions/documentation/adodb_lite_errorhandling.html trunk/functions/documentation/adodb_lite_howtoinstall.html trunk/functions/documentation/adodb_lite_modulecreation.html trunk/functions/documentation/adodb_lite_modules.html trunk/functions/documentation/adodb_lite_performancemonitor.html trunk/functions/documentation/adodb_lite_sessions.html trunk/functions/documentation/changelog.txt trunk/functions/documentation/example_generic_module.inc trunk/functions/documentation/example_module.inc trunk/functions/documentation/images/ trunk/functions/documentation/images/dot_b.gif trunk/functions/documentation/images/e05.gif trunk/functions/documentation/images/fon_bar01.gif trunk/functions/documentation/images/query_de.gif trunk/functions/documentation/license.txt trunk/functions/documentation/readme.txt trunk/functions/documentation/style.css trunk/functions/generic_modules/ trunk/functions/generic_modules/adodblite_module.inc trunk/functions/generic_modules/menu_module.inc trunk/functions/generic_modules/object_module.inc trunk/functions/generic_modules/pear_module.inc trunk/functions/lang/ trunk/functions/lang/adodb-ar.inc.php trunk/functions/lang/adodb-bg.inc.php trunk/functions/lang/adodb-bgutf8.inc.php trunk/functions/lang/adodb-ca.inc.php trunk/functions/lang/adodb-cn.inc.php trunk/functions/lang/adodb-cz.inc.php trunk/functions/lang/adodb-da.inc.php trunk/functions/lang/adodb-de.inc.php trunk/functions/lang/adodb-en.inc.php trunk/functions/lang/adodb-es.inc.php trunk/functions/lang/adodb-esperanto.inc.php trunk/functions/lang/adodb-fr.inc.php trunk/functions/lang/adodb-hu.inc.php trunk/functions/lang/adodb-it.inc.php trunk/functions/lang/adodb-nl.inc.php trunk/functions/lang/adodb-pl.inc.php trunk/functions/lang/adodb-pt-br.inc.php trunk/functions/lang/adodb-ro.inc.php trunk/functions/lang/adodb-ru1251.inc.php trunk/functions/lang/adodb-sv.inc.php trunk/functions/lang/adodb-uk1251.inc.php trunk/functions/query_debug_console/ trunk/functions/query_debug_console/query_debug_console.php trunk/functions/query_debug_console/query_debug_console.tpl trunk/functions/session/ trunk/functions/session/adodb-compress-bzip2.php trunk/functions/session/adodb-compress-gzip.php trunk/functions/session/adodb-cryptsession.php trunk/functions/session/adodb-encrypt-mcrypt.php trunk/functions/session/adodb-encrypt-md5.php trunk/functions/session/adodb-encrypt-ordcrypt.php trunk/functions/session/adodb-encrypt-secret.php trunk/functions/session/adodb-encrypt-sha1.php trunk/functions/session/adodb-session.php trunk/functions/session/adodb-sessions.mysql.sql trunk/functions/session/session_schema.xml trunk/functions/tests/ trunk/functions/tests/adodblite_thumb.jpg trunk/functions/tests/pj trunk/functions/tests/test_adodb_lite.php trunk/functions/tests/test_adodb_lite_sessions.php trunk/functions/tests/test_datadictionary.php trunk/functions/tests/xmlschema.xml trunk/functions/tohtml.inc.php trunk/functions/xmlschema.dtd Added: trunk/functions/adodb-datadict.inc.php =================================================================== --- trunk/functions/adodb-datadict.inc.php (rev 0) +++ trunk/functions/adodb-datadict.inc.php 2007-07-30 04:57:52 UTC (rev 38) @@ -0,0 +1,838 @@ +<?php + +/** + V4.65 22 July 2005 (c) 2000-2005 John Lim (jl...@na...). All rights reserved. + Released under both BSD license and Lesser GPL library license. + Whenever there is any discrepancy between the two licenses, + the BSD license will take precedence. + + Set tabs to 4 for best viewing. + + DOCUMENTATION: + + See adodb/tests/test-datadict.php for docs and examples. + + Modified 3 October, 2005 for use with ADOdb Lite by Mark Dickenson +*/ + +/* + Test script for parser +*/ + +// security - hide paths +if (!defined('ADODB_DIR')) die(); + +if (!function_exists('ctype_alnum')) { + function ctype_alnum($text) { + return preg_match('/^[a-z0-9]*$/i', $text); + } +} + +function _array_change_key_case($an_array) +{ + if (is_array($an_array)) { + $new_array = array(); + foreach($an_array as $key=>$value) + $new_array[strtoupper($key)] = $value; + + return $new_array; + } + + return $an_array; +} + +/** + Parse arguments, treat "text" (text) and 'text' as quotation marks. + To escape, use "" or '' or )) + + Will read in "abc def" sans quotes, as: abc def + Same with 'abc def'. + However if `abc def`, then will read in as `abc def` + + @param endstmtchar Character that indicates end of statement + @param tokenchars Include the following characters in tokens apart from A-Z and 0-9 + @returns 2 dimensional array containing parsed tokens. +*/ +function Lens_ParseArgs($args,$endstmtchar=',',$tokenchars='_.-') +{ + $pos = 0; + $intoken = false; + $stmtno = 0; + $endquote = false; + $tokens = array(); + $tokens[$stmtno] = array(); + $max = strlen($args); + $quoted = false; + + while ($pos < $max) { + $ch = substr($args,$pos,1); + switch($ch) { + case ' ': + case "\t": + case "\n": + case "\r": + if (!$quoted) { + if ($intoken) { + $intoken = false; + $tokens[$stmtno][] = implode('',$tokarr); + } + break; + } + $tokarr[] = $ch; + break; + case '`': + if ($intoken) $tokarr[] = $ch; + case '(': + case ')': + case '"': + case "'": + if ($intoken) { + if (empty($endquote)) { + $tokens[$stmtno][] = implode('',$tokarr); + if ($ch == '(') $endquote = ')'; + else $endquote = $ch; + $quoted = true; + $intoken = true; + $tokarr = array(); + } else if ($endquote == $ch) { + $ch2 = substr($args,$pos+1,1); + if ($ch2 == $endquote) { + $pos += 1; + $tokarr[] = $ch2; + } else { + $quoted = false; + $intoken = false; + $tokens[$stmtno][] = implode('',$tokarr); + $endquote = ''; + } + } else + $tokarr[] = $ch; + }else { + if ($ch == '(') $endquote = ')'; + else $endquote = $ch; + $quoted = true; + $intoken = true; + $tokarr = array(); + if ($ch == '`') $tokarr[] = '`'; + } + break; + default: + if (!$intoken) { + if ($ch == $endstmtchar) { + $stmtno += 1; + $tokens[$stmtno] = array(); + break; + } + $intoken = true; + $quoted = false; + $endquote = false; + $tokarr = array(); + } + if ($quoted) $tokarr[] = $ch; + else if (ctype_alnum($ch) || strpos($tokenchars,$ch) !== false) $tokarr[] = $ch; + else { + if ($ch == $endstmtchar) { + $tokens[$stmtno][] = implode('',$tokarr); + $stmtno += 1; + $tokens[$stmtno] = array(); + $intoken = false; + $tokarr = array(); + break; + } + $tokens[$stmtno][] = implode('',$tokarr); + $tokens[$stmtno][] = $ch; + $intoken = false; + } + } + $pos += 1; + } + if ($intoken) $tokens[$stmtno][] = implode('',$tokarr); + + return $tokens; +} + + +class ADODB_DataDict { + var $connection; + var $debug = false; + var $dropTable = 'DROP TABLE %s'; + var $renameTable = 'RENAME TABLE %s TO %s'; + var $dropIndex = 'DROP INDEX %s'; + var $addCol = ' ADD'; + var $alterCol = ' ALTER COLUMN'; + var $dropCol = ' DROP COLUMN'; + var $renameColumn = 'ALTER TABLE %s RENAME COLUMN %s TO %s'; // table, old-column, new-column, column-definitions (not used by default) + var $nameRegex = '\w'; + var $nameRegexBrackets = 'a-zA-Z0-9_\(\)'; + var $schema = false; + var $serverInfo = array(); + var $autoIncrement = false; + var $invalidResizeTypes4 = array('CLOB','BLOB','TEXT','DATE','TIME'); // for changetablesql + var $blobSize = 100; /// any varchar/char field this size or greater is treated as a blob + /// in other words, we use a text area for editting. + var $metaTablesSQL; + var $metaColumnsSQL; + var $debug_echo = true; + var $fetchMode; + var $raiseErrorFn; + + function SetFetchMode($mode) + { + GLOBAL $ADODB_FETCH_MODE; + $old = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = $mode; + return $old; + } + + function outp($text) + { + $this->debug_output = "<br>\n(" . $this->dbtype . "): ".htmlspecialchars($text)."<br>\n"; + if($this->debug_echo) + echo $this->debug_output; + } + + function GetCommentSQL($table,$col) + { + return false; + } + + function SetCommentSQL($table,$col,$cmt) + { + return false; + } + + /** + * @param ttype can either be 'VIEW' or 'TABLE' or false. + * If false, both views and tables are returned. + * "VIEW" returns only views + * "TABLE" returns only tables + * @param showSchema returns the schema/user with the table name, eg. USER.TABLE + * @param mask is the input mask - only supported by oci8 and postgresql + * + * @return array of tables for current database. + */ + + function MetaTables() + { + if (!$this->connection->IsConnected()) return array(); + return $this->connection->MetaTables(); + } + + /** + * List columns in a database as an array of ADOFieldObjects. + * See top of file for definition of object. + * + * @param table table name to query + * @param upper uppercase table name (required by some databases) + * @schema is optional database schema to use - not supported by all databases. + * + * @return array of ADOFieldObjects for current table. + */ + + function MetaColumns($tab, $upper=true, $schema=false) + { + if (!$this->connection->IsConnected()) return array(); + return $this->connection->MetaColumns($this->TableName($tab), $upper, $schema); + } + + /** + * @returns an array with the primary key columns in it. + */ + + function MetaPrimaryKeys($tab,$owner=false,$intkey=false) + { + if (!$this->connection->IsConnected()) return array(); + return $this->connection->MetaPrimaryKeys($this->TableName($tab), $owner, $intkey); + } + + /** + * List indexes on a table as an array. + * @param table table name to query + * @param primary true to only show primary keys. Not actually used for most databases + * + * @return array of indexes on current table. Each element represents an index, and is itself an associative array. + + Array ( + [name_of_index] => Array + ( + [unique] => true or false + [columns] => Array + ( + [0] => firstname + [1] => lastname + ) + ) + */ + + function MetaIndexes($table, $primary = false, $owner = false) + { + if (!$this->connection->IsConnected()) return array(); + return $this->connection->MetaIndexes($this->TableName($table), $primary, $owner); + } + + function MetaType($t,$len=-1,$fieldobj=false) + { + return $this->connection->MetaType($t,$len,$fieldobj); + } + + function ActualType($meta) + { + return $meta; + } + + function NameQuote($name = NULL,$allowBrackets=false) + { + if (!is_string($name)) { + return FALSE; + } + + $name = trim($name); + + if ( !is_object($this->connection) ) { + return $name; + } + + $quote = $this->connection->nameQuote; + + // if name is of the form `name`, quote it + if ( preg_match('/^`(.+)`$/', $name, $matches) ) { + return $quote . $matches[1] . $quote; + } + + // if name contains special characters, quote it + $regex = ($allowBrackets) ? $this->nameRegexBrackets : $this->nameRegex; + + if ( !preg_match('/^[' . $regex . ']+$/', $name) ) { + return $quote . $name . $quote; + } + + return $name; + } + + function TableName($name) + { + if ( $this->schema ) { + return $this->NameQuote($this->schema) .'.'. $this->NameQuote($name); + } + return $this->NameQuote($name); + } + + // Executes the sql array returned by GetTableSQL and GetIndexSQL + function ExecuteSQLArray($sql, $continueOnError = true) + { + $rez = 2; + $conn = &$this->connection; + $saved = $conn->debug; + foreach($sql as $line) { + if ($this->debug) $conn->debug = true; + $ok = $conn->Execute($line); + $conn->debug = $saved; + if (!$ok) { + if ($this->debug) $this->outp($conn->ErrorMsg()); + if (!$continueOnError) return 0; + $rez = 1; + } + } + return $rez; + } + + function CreateDatabase($dbname,$options=false) + { + $options = $this->_Options($options); + $sql = array(); + + $s = 'CREATE DATABASE ' . $this->NameQuote($dbname); + if (isset($options[$this->upperName])) + $s .= ' '.$options[$this->upperName]; + + $sql[] = $s; + return $sql; + } + + /* + Generates the SQL to create index. Returns an array of sql strings. + */ + + function CreateIndexSQL($idxname, $tabname, $flds, $idxoptions = false) + { + if (!is_array($flds)) { + $flds = explode(',',$flds); + } + foreach($flds as $key => $fld) { + # some indexes can use partial fields, eg. index first 32 chars of "name" with NAME(32) + $flds[$key] = $this->NameQuote($fld,$allowBrackets=true); + } + return $this->_IndexSQL($this->NameQuote($idxname), $this->TableName($tabname), $flds, $this->_Options($idxoptions)); + } + + function DropIndexSQL ($idxname, $tabname = NULL) + { + return array(sprintf($this->dropIndex, $this->NameQuote($idxname), $this->TableName($tabname))); + } + + function SetSchema($schema) + { + $this->schema = $schema; + } + + function AddColumnSQL($tabname, $flds) + { + $tabname = $this->TableName ($tabname); + $sql = array(); + list($lines,$pkey) = $this->_GenFields($flds); + $alter = 'ALTER TABLE ' . $tabname . $this->addCol . ' '; + foreach($lines as $v) { + $sql[] = $alter . $v; + } + return $sql; + } + + /** + * Change the definition of one column + * + * As some DBM's can't do that on there own, you need to supply the complete defintion of the new table, + * to allow, recreating the table and copying the content over to the new table + * @param string $tabname table-name + * @param string $flds column-name and type for the changed column + * @param string $tableflds='' complete defintion of the new table, eg. for postgres, default '' + * @param array/string $tableoptions='' options for the new table see CreateTableSQL, default '' + * @return array with SQL strings + */ + + function AlterColumnSQL($tabname, $flds, $tableflds='',$tableoptions='') + { + $tabname = $this->TableName ($tabname); + $sql = array(); + list($lines,$pkey) = $this->_GenFields($flds); + $alter = 'ALTER TABLE ' . $tabname . $this->alterCol . ' '; + foreach($lines as $v) { + $sql[] = $alter . $v; + } + return $sql; + } + + /** + * Rename one column + * + * Some DBM's can only do this together with changeing the type of the column (even if that stays the same, eg. mysql) + * @param string $tabname table-name + * @param string $oldcolumn column-name to be renamed + * @param string $newcolumn new column-name + * @param string $flds='' complete column-defintion-string like for AddColumnSQL, only used by mysql atm., default='' + * @return array with SQL strings + */ + + function RenameColumnSQL($tabname,$oldcolumn,$newcolumn,$flds='') + { + $tabname = $this->TableName ($tabname); + if ($flds) { + list($lines,$pkey) = $this->_GenFields($flds); + list(,$first) = each($lines); + list(,$column_def) = split("[\t ]+",$first,2); + } + return array(sprintf($this->renameColumn,$tabname,$this->NameQuote($oldcolumn),$this->NameQuote($newcolumn),$column_def)); + } + + /** + * Drop one column + * + * Some DBM's can't do that on there own, you need to supply the complete defintion of the new table, + * to allow, recreating the table and copying the content over to the new table + * @param string $tabname table-name + * @param string $flds column-name and type for the changed column + * @param string $tableflds='' complete defintion of the new table, eg. for postgres, default '' + * @param array/string $tableoptions='' options for the new table see CreateTableSQL, default '' + * @return array with SQL strings + */ + + function DropColumnSQL($tabname, $flds, $tableflds='',$tableoptions='') + { + $tabname = $this->TableName ($tabname); + if (!is_array($flds)) $flds = explode(',',$flds); + $sql = array(); + $alter = 'ALTER TABLE ' . $tabname . $this->dropCol . ' '; + foreach($flds as $v) { + $sql[] = $alter . $this->NameQuote($v); + } + return $sql; + } + + function DropTableSQL($tabname) + { + return array (sprintf($this->dropTable, $this->TableName($tabname))); + } + + function RenameTableSQL($tabname,$newname) + { + return array (sprintf($this->renameTable, $this->TableName($tabname),$this->TableName($newname))); + } + + /* + Generate the SQL to create table. Returns an array of sql strings. + */ + + function CreateTableSQL($tabname, $flds, $tableoptions=false) + { + if (!$tableoptions) $tableoptions = array(); + + list($lines,$pkey) = $this->_GenFields($flds, true); + + $taboptions = $this->_Options($tableoptions); + $tabname = $this->TableName ($tabname); + $sql = $this->_TableSQL($tabname,$lines,$pkey,$taboptions); + $tsql = $this->_Triggers($tabname,$taboptions); + foreach($tsql as $s) $sql[] = $s; + + return $sql; + } + + function _GenFields($flds,$widespacing=false) + { + if (is_string($flds)) { + $padding = ' '; + $txt = $flds.$padding; + $flds = array(); + $flds0 = Lens_ParseArgs($txt,','); + $hasparam = false; + foreach($flds0 as $f0) { + $f1 = array(); + foreach($f0 as $token) { + switch (strtoupper($token)) { + case 'CONSTRAINT': + case 'DEFAULT': + $hasparam = $token; + break; + default: + if ($hasparam) $f1[$hasparam] = $token; + else $f1[] = $token; + $hasparam = false; + break; + } + } + $flds[] = $f1; + + } + } + $this->autoIncrement = false; + $lines = array(); + $pkey = array(); + foreach($flds as $fld) { + $fld = _array_change_key_case($fld); + $fname = false; + $fdefault = false; + $fautoinc = false; + $ftype = false; + $fsize = false; + $fprec = false; + $fprimary = false; + $fnoquote = false; + $fdefts = false; + $fdefdate = false; + $fconstraint = false; + $fnotnull = false; + $funsigned = false; + + //----------------- + // Parse attributes + foreach($fld as $attr => $v) { + if ($attr == 2 && is_numeric($v)) $attr = 'SIZE'; + else if (is_numeric($attr) && $attr > 1 && !is_numeric($v)) $attr = strtoupper($v); + switch($attr) { + case '0': + case 'NAME': + $fname = $v; + break; + case '1': + case 'TYPE': + $ty = $v; $ftype = $this->ActualType(strtoupper($v)); + break; + case 'SIZE': + $dotat = strpos($v,'.'); + if ($dotat === false) $dotat = strpos($v,','); + if ($dotat === false) $fsize = $v; + else { + $fsize = substr($v,0,$dotat); + $fprec = substr($v,$dotat+1); + } + break; + case 'UNSIGNED': + $funsigned = true; + break; + case 'AUTOINCREMENT': + case 'AUTO': + $fautoinc = true; + $fnotnull = true; + break; + case 'KEY': + case 'PRIMARY': + $fprimary = $v; + $fnotnull = true; + break; + case 'DEF': + case 'DEFAULT': + $fdefault = $v; + break; + case 'NOTNULL': + $fnotnull = $v; + break; + case 'NOQUOTE': + $fnoquote = $v; + break; + case 'DEFDATE': + $fdefdate = $v; + break; + case 'DEFTIMESTAMP': + $fdefts = $v; + break; + case 'CONSTRAINT': + $fconstraint = $v; + break; + } + } + + //-------------------- + // VALIDATE FIELD INFO + if (!strlen($fname)) { + if ($this->debug) $this->outp("Undefined NAME"); + return false; + } + + $fid = strtoupper(preg_replace('/^`(.+)`$/', '$1', $fname)); + $fname = $this->NameQuote($fname); + + if (!strlen($ftype)) { + if ($this->debug) $this->outp("Undefined TYPE for field '$fname'"); + return false; + } else { + $ftype = strtoupper($ftype); + } + + $ftype = $this->_GetSize($ftype, $ty, $fsize, $fprec); + + if ($ty == 'X' || $ty == 'X2' || $ty == 'B') $fnotnull = false; // some blob types do not accept nulls + + if ($fprimary) $pkey[] = $fname; + + // some databases do not allow blobs to have defaults + if ($ty == 'X') $fdefault = false; + + //-------------------- + // CONSTRUCT FIELD SQL + if ($fdefts) { + if (substr($this->dbtype,0,5) == 'mysql') { + $ftype = 'TIMESTAMP'; + } else { + $fdefault = $this->connection->sysTimeStamp; + } + } else if ($fdefdate) { + if (substr($this->dbtype,0,5) == 'mysql') { + $ftype = 'TIMESTAMP'; + } else { + $fdefault = $this->connection->sysDate; + } + } else if ($fdefault !== false && !$fnoquote) + if ($ty == 'C' or $ty == 'X' or + ( substr($fdefault,0,1) != "'" && !is_numeric($fdefault))) + if (strlen($fdefault) != 1 && substr($fdefault,0,1) == ' ' && substr($fdefault,strlen($fdefault)-1) == ' ') + $fdefault = trim($fdefault); + else if (strtolower($fdefault) != 'null') + $fdefault = $this->connection->qstr($fdefault); + $suffix = $this->_CreateSuffix($fname,$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned); + + if ($widespacing) $fname = str_pad($fname,24); + $lines[$fid] = $fname.' '.$ftype.$suffix; + + if ($fautoinc) $this->autoIncrement = true; + } // foreach $flds + return array($lines,$pkey); + } + + /* + GENERATE THE SIZE PART OF THE DATATYPE + $ftype is the actual type + $ty is the type defined originally in the DDL + */ + + function _GetSize($ftype, $ty, $fsize, $fprec) + { + if (strlen($fsize) && $ty != 'X' && $ty != 'B' && strpos($ftype,'(') === false) { + $ftype .= "(".$fsize; + if (strlen($fprec)) $ftype .= ",".$fprec; + $ftype .= ')'; + } + return $ftype; + } + + // return string must begin with space + function _CreateSuffix($fname,$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint) + { + $suffix = ''; + if (strlen($fdefault)) $suffix .= " DEFAULT $fdefault"; + if ($fnotnull) $suffix .= ' NOT NULL'; + if ($fconstraint) $suffix .= ' '.$fconstraint; + return $suffix; + } + + function _IndexSQL($idxname, $tabname, $flds, $idxoptions) + { + $sql = array(); + + if ( isset($idxoptions['REPLACE']) || isset($idxoptions['DROP']) ) { + $sql[] = sprintf ($this->dropIndex, $idxname); + if ( isset($idxoptions['DROP']) ) + return $sql; + } + + if ( empty ($flds) ) { + return $sql; + } + + $unique = isset($idxoptions['UNIQUE']) ? ' UNIQUE' : ''; + + $s = 'CREATE' . $unique . ' INDEX ' . $idxname . ' ON ' . $tabname . ' '; + + if ( isset($idxoptions[$this->upperName]) ) + $s .= $idxoptions[$this->upperName]; + + if ( is_array($flds) ) + $flds = implode(', ',$flds); + $s .= '(' . $flds . ')'; + $sql[] = $s; + + return $sql; + } + + function _DropAutoIncrement($tabname) + { + return false; + } + + function _TableSQL($tabname,$lines,$pkey,$tableoptions) + { + $sql = array(); + + if (isset($tableoptions['REPLACE']) || isset ($tableoptions['DROP'])) { + $sql[] = sprintf($this->dropTable,$tabname); + if ($this->autoIncrement) { + $sInc = $this->_DropAutoIncrement($tabname); + if ($sInc) $sql[] = $sInc; + } + if ( isset ($tableoptions['DROP']) ) { + return $sql; + } + } + $s = "CREATE TABLE $tabname (\n"; + $s .= implode(",\n", $lines); + if (sizeof($pkey)>0) { + $s .= ",\n PRIMARY KEY ("; + $s .= implode(", ",$pkey).")"; + } + if (isset($tableoptions['CONSTRAINTS'])) + $s .= "\n".$tableoptions['CONSTRAINTS']; + + if (isset($tableoptions[$this->upperName.'_CONSTRAINTS'])) + $s .= "\n".$tableoptions[$this->upperName.'_CONSTRAINTS']; + + $s .= "\n)"; + if (isset($tableoptions[$this->upperName])) $s .= $tableoptions[$this->upperName]; + $sql[] = $s; + + return $sql; + } + + /* + GENERATE TRIGGERS IF NEEDED + used when table has auto-incrementing field that is emulated using triggers + */ + + function _Triggers($tabname,$taboptions) + { + return array(); + } + + /* + Sanitize options, so that array elements with no keys are promoted to keys + */ + + function _Options($opts) + { + if (!is_array($opts)) return array(); + $newopts = array(); + foreach($opts as $k => $v) { + if (is_numeric($k)) $newopts[strtoupper($v)] = $v; + else $newopts[strtoupper($k)] = $v; + } + return $newopts; + } + + /* + "Florian Buzin [ easywe ]" <florian.buzin#easywe.de> + + This function changes/adds new fields to your table. You don't + have to know if the col is new or not. It will check on its own. + */ + + function ChangeTableSQL($tablename, $flds, $tableoptions = false) + { + global $ADODB_FETCH_MODE; + $save = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; + if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false); + + // check table exists + $save_handler = $this->raiseErrorFn; + $this->raiseErrorFn = ''; + $cols = $this->MetaColumns($tablename); + $this->raiseErrorFn = $save_handler; + + if (isset($savem)) $this->SetFetchMode($savem); + $ADODB_FETCH_MODE = $save; + + if ( empty($cols)) { + return $this->CreateTableSQL($tablename, $flds, $tableoptions); + } + + if (is_array($flds)) { + // Cycle through the update fields, comparing + // existing fields to fields to update. + // if the Metatype and size is exactly the + // same, ignore - by Mark Newham + $holdflds = array(); + foreach($flds as $k=>$v) { + if ( isset($cols[$k]) && is_object($cols[$k]) ) { + $c = $cols[$k]; + $ml = $c->max_length; + $mt = &$this->MetaType($c->type,$ml); + if ($ml == -1) $ml = ''; + if ($mt == 'X') $ml = $v['SIZE']; + if (($mt != $v['TYPE']) || $ml != $v['SIZE']) { + $holdflds[$k] = $v; + } + } else { + $holdflds[$k] = $v; + } + } + $flds = $holdflds; + } + + // already exists, alter table instead + list($lines,$pkey) = $this->_GenFields($flds); + $alter = 'ALTER TABLE ' . $this->TableName($tablename); + $sql = array(); + + foreach ( $lines as $id => $v ) { + if ( isset($cols[$id]) && is_object($cols[$id]) ) { + $flds = Lens_ParseArgs($v,','); + // We are trying to change the size of the field, if not allowed, simply ignore the request. + if ($flds && in_array(strtoupper(substr($flds[0][1],0,4)),$this->invalidResizeTypes4)) continue; + + $sql[] = $alter . $this->alterCol . ' ' . $v; + } else { + $sql[] = $alter . $this->addCol . ' ' . $v; + } + } + return $sql; + } +} + +?> \ No newline at end of file Added: trunk/functions/adodb-error.inc.php =================================================================== --- trunk/functions/adodb-error.inc.php (rev 0) +++ trunk/functions/adodb-error.inc.php 2007-07-30 04:57:52 UTC (rev 38) @@ -0,0 +1,277 @@ +<?php +/** + * @version V4.93 10 Oct 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved. + * Released under both BSD license and Lesser GPL library license. + * Whenever there is any discrepancy between the two licenses, + * the BSD license will take precedence. + * + * Set tabs to 4 for best viewing. + * + * The following code is adapted from the PEAR DB error handling code. + * Portions (c)1997-2002 The PHP Group. + */ + + +if (!defined("DB_ERROR")) define("DB_ERROR",-1); + +if (!defined("DB_ERROR_SYNTAX")) { + define("DB_ERROR_SYNTAX", -2); + define("DB_ERROR_CONSTRAINT", -3); + define("DB_ERROR_NOT_FOUND", -4); + define("DB_ERROR_ALREADY_EXISTS", -5); + define("DB_ERROR_UNSUPPORTED", -6); + define("DB_ERROR_MISMATCH", -7); + define("DB_ERROR_INVALID", -8); + define("DB_ERROR_NOT_CAPABLE", -9); + define("DB_ERROR_TRUNCATED", -10); + define("DB_ERROR_INVALID_NUMBER", -11); + define("DB_ERROR_INVALID_DATE", -12); + define("DB_ERROR_DIVZERO", -13); + define("DB_ERROR_NODBSELECTED", -14); + define("DB_ERROR_CANNOT_CREATE", -15); + define("DB_ERROR_CANNOT_DELETE", -16); + define("DB_ERROR_CANNOT_DROP", -17); + define("DB_ERROR_NOSUCHTABLE", -18); + define("DB_ERROR_NOSUCHFIELD", -19); + define("DB_ERROR_NEED_MORE_DATA", -20); + define("DB_ERROR_NOT_LOCKED", -21); + define("DB_ERROR_VALUE_COUNT_ON_ROW", -22); + define("DB_ERROR_INVALID_DSN", -23); + define("DB_ERROR_CONNECT_FAILED", -24); + define("DB_ERROR_EXTENSION_NOT_FOUND",-25); + define("DB_ERROR_NOSUCHDB", -25); + define("DB_ERROR_ACCESS_VIOLATION", -26); +} + +function adodb_errormsg($value) +{ + global $ADODB_LANG,$ADODB_LANG_ARRAY; + + if (empty($ADODB_LANG)) + $ADODB_LANG = 'en'; + if (isset($ADODB_LANG_ARRAY['LANG']) && $ADODB_LANG_ARRAY['LANG'] == $ADODB_LANG) ; + else + { + include_once(ADODB_DIR."/lang/adodb-$ADODB_LANG.inc.php"); + } + return isset($ADODB_LANG_ARRAY[$value]) ? $ADODB_LANG_ARRAY[$value] : $ADODB_LANG_ARRAY[DB_ERROR]; +} + +function adodb_error($provider,$dbType,$errno) +{ + //var_dump($errno); + if (is_numeric($errno) && $errno == 0) + return 0; + + switch($provider) { + case 'mysql': + $map = adodb_error_mysql(); + break; + + case 'oracle': + case 'oci8': + $map = adodb_error_oci8(); + break; + + case 'ibase': + $map = adodb_error_ibase(); + break; + + case 'odbc': + $map = adodb_error_odbc(); + break; + + case 'mssql': + case 'sybase': + $map = adodb_error_mssql(); + break; + + case 'informix': + $map = adodb_error_ifx(); + break; + + case 'postgres': + return adodb_error_pg($errno); + break; + + case 'sqlite': + return $map = adodb_error_sqlite(); + break; + default: + return DB_ERROR; + } + //print_r($map); + //var_dump($errno); + if (isset($map[$errno])) + return $map[$errno]; + return DB_ERROR; +} + +//************************************************************************************** + +function adodb_error_pg($errormsg) +{ + if (is_numeric($errormsg)) + return (integer) $errormsg; + + static $error_regexps = array( + '/(Table does not exist\.|Relation [\"\'].*[\"\'] does not exist|sequence does not exist|class ".+" not found)$/' => DB_ERROR_NOSUCHTABLE, + '/Relation [\"\'].*[\"\'] already exists|Cannot insert a duplicate key into (a )?unique index.*/' => DB_ERROR_ALREADY_EXISTS, + '/divide by zero$/' => DB_ERROR_DIVZERO, + '/pg_atoi: error in .*: can\'t parse /' => DB_ERROR_INVALID_NUMBER, + '/ttribute [\"\'].*[\"\'] not found|Relation [\"\'].*[\"\'] does not have attribute [\"\'].*[\"\']/' => DB_ERROR_NOSUCHFIELD, + '/parser: parse error at or near \"/' => DB_ERROR_SYNTAX, + '/referential integrity violation/' => DB_ERROR_CONSTRAINT, + '/Relation [\"\'].*[\"\'] already exists|Cannot insert a duplicate key into (a )?unique index.*|duplicate key violates unique constraint/' + => DB_ERROR_ALREADY_EXISTS + ); + reset($error_regexps); + while (list($regexp,$code) = each($error_regexps)) + { + if (preg_match($regexp, $errormsg)) + { + return $code; + } + } + // Fall back to DB_ERROR if there was no mapping. + return DB_ERROR; +} + +function adodb_error_odbc() +{ + static $MAP = array( + '01004' => DB_ERROR_TRUNCATED, + '07001' => DB_ERROR_MISMATCH, + '21S01' => DB_ERROR_MISMATCH, + '21S02' => DB_ERROR_MISMATCH, + '22003' => DB_ERROR_INVALID_NUMBER, + '22008' => DB_ERROR_INVALID_DATE, + '22012' => DB_ERROR_DIVZERO, + '23000' => DB_ERROR_CONSTRAINT, + '24000' => DB_ERROR_INVALID, + '34000' => DB_ERROR_INVALID, + '37000' => DB_ERROR_SYNTAX, + '42000' => DB_ERROR_SYNTAX, + 'IM001' => DB_ERROR_UNSUPPORTED, + 'S0000' => DB_ERROR_NOSUCHTABLE, + 'S0001' => DB_ERROR_NOT_FOUND, + 'S0002' => DB_ERROR_NOSUCHTABLE, + 'S0011' => DB_ERROR_ALREADY_EXISTS, + 'S0012' => DB_ERROR_NOT_FOUND, + 'S0021' => DB_ERROR_ALREADY_EXISTS, + 'S0022' => DB_ERROR_NOT_FOUND, + 'S1000' => DB_ERROR_NOSUCHTABLE, + 'S1009' => DB_ERROR_INVALID, + 'S1090' => DB_ERROR_INVALID, + 'S1C00' => DB_ERROR_NOT_CAPABLE + ); + return $MAP; +} + +function adodb_error_ibase() +{ + static $MAP = array( + -104 => DB_ERROR_SYNTAX, + -150 => DB_ERROR_ACCESS_VIOLATION, + -151 => DB_ERROR_ACCESS_VIOLATION, + -155 => DB_ERROR_NOSUCHTABLE, + -157 => DB_ERROR_NOSUCHFIELD, + -158 => DB_ERROR_VALUE_COUNT_ON_ROW, + -170 => DB_ERROR_MISMATCH, + -171 => DB_ERROR_MISMATCH, + -172 => DB_ERROR_INVALID, + -204 => DB_ERROR_INVALID, + -205 => DB_ERROR_NOSUCHFIELD, + -206 => DB_ERROR_NOSUCHFIELD, + -208 => DB_ERROR_INVALID, + -219 => DB_ERROR_NOSUCHTABLE, + -297 => DB_ERROR_CONSTRAINT, + -530 => DB_ERROR_CONSTRAINT, + -803 => DB_ERROR_CONSTRAINT, + -551 => DB_ERROR_ACCESS_VIOLATION, + -552 => DB_ERROR_ACCESS_VIOLATION, + -922 => DB_ERROR_NOSUCHDB, + -923 => DB_ERROR_CONNECT_FAILED, + -924 => DB_ERROR_CONNECT_FAILED + ); + return $MAP; +} + +function adodb_error_ifx() +{ + static $MAP = array( + '-201' => DB_ERROR_SYNTAX, + '-206' => DB_ERROR_NOSUCHTABLE, + '-217' => DB_ERROR_NOSUCHFIELD, + '-329' => DB_ERROR_NODBSELECTED, + '-1204' => DB_ERROR_INVALID_DATE, + '-1205' => DB_ERROR_INVALID_DATE, + '-1206' => DB_ERROR_INVALID_DATE, + '-1209' => DB_ERROR_INVALID_DATE, + '-1210' => DB_ERROR_INVALID_DATE, + '-1212' => DB_ERROR_INVALID_DATE + ); + return $MAP; +} + +function adodb_error_oci8() +{ + static $MAP = array( + 1 => DB_ERROR_ALREADY_EXISTS, + 900 => DB_ERROR_SYNTAX, + 904 => DB_ERROR_NOSUCHFIELD, + 923 => DB_ERROR_SYNTAX, + 942 => DB_ERROR_NOSUCHTABLE, + 955 => DB_ERROR_ALREADY_EXISTS, + 1476 => DB_ERROR_DIVZERO, + 1722 => DB_ERROR_INVALID_NUMBER, + 2289 => DB_ERROR_NOSUCHTABLE, + 2291 => DB_ERROR_CONSTRAINT, + 2449 => DB_ERROR_CONSTRAINT + ); + return $MAP; +} + +function adodb_error_mssql() +{ + static $MAP = array( + 208 => DB_ERROR_NOSUCHTABLE, + 2601 => DB_ERROR_ALREADY_EXISTS + ); + return $MAP; +} + +function adodb_error_sqlite() +{ + static $MAP = array( + 1 => DB_ERROR_SYNTAX + ); + return $MAP; +} + +function adodb_error_mysql() +{ + static $MAP = array( + 1004 => DB_ERROR_CANNOT_CREATE, + 1005 => DB_ERROR_CANNOT_CREATE, + 1006 => DB_ERROR_CANNOT_CREATE, + 1007 => DB_ERROR_ALREADY_EXISTS, + 1008 => DB_ERROR_CANNOT_DROP, + 1045 => DB_ERROR_ACCESS_VIOLATION, + 1046 => DB_ERROR_NODBSELECTED, + 1049 => DB_ERROR_NOSUCHDB, + 1050 => DB_ERROR_ALREADY_EXISTS, + 1051 => DB_ERROR_NOSUCHTABLE, + 1054 => DB_ERROR_NOSUCHFIELD, + 1062 => DB_ERROR_ALREADY_EXISTS, + 1064 => DB_ERROR_SYNTAX, + 1100 => DB_ERROR_NOT_LOCKED, + 1136 => DB_ERROR_VALUE_COUNT_ON_ROW, + 1146 => DB_ERROR_NOSUCHTABLE, + 1048 => DB_ERROR_CONSTRAINT, + 2002 => DB_ERROR_CONNECT_FAILED, + 2005 => DB_ERROR_CONNECT_FAILED + ); + return $MAP; +} +?> \ No newline at end of file Added: trunk/functions/adodb-errorhandler.inc.php =================================================================== --- trunk/functions/adodb-errorhandler.inc.php (rev 0) +++ trunk/functions/adodb-errorhandler.inc.php 2007-07-30 04:57:52 UTC (rev 38) @@ -0,0 +1,79 @@ +<?php +/** + * @version V4.66 28 Sept 2005 (c) 2000-2005 John Lim (jl...@na...). All rights reserved. + * Released under both BSD license and Lesser GPL library license. + * Whenever there is any discrepancy between the two licenses, + * the BSD license will take precedence. + * + * Set tabs to 4 for best viewing. + * + * Latest version is available at http://php.weblogs.com + * +*/ + +// added Claudio Bustos clbustos#entelchile.net +if (!defined('ADODB_ERROR_HANDLER_TYPE')) define('ADODB_ERROR_HANDLER_TYPE',E_USER_ERROR); + +if (!defined('ADODB_ERROR_HANDLER')) define('ADODB_ERROR_HANDLER','ADODB_Error_Handler'); + +/** +* Default Error Handler. This will be called with the following params +* +* @param $dbms the RDBMS you are connecting to +* @param $fn the name of the calling function (in uppercase) +* @param $errno the native error number from the database +* @param $errmsg the native error msg from the database +* @param $p1 $fn specific parameter - see below +* @param $p2 $fn specific parameter - see below +* @param $thisConn $current connection object - can be false if no connection object created +*/ + +function ADODB_Error_Handler($dbms, $fn, $errno, $errmsg, $p1, $p2, &$thisConnection) +{ + if (error_reporting() == 0) + return; // obey @ protocol + + switch($fn) { + case 'EXECUTE': + $sql = $p1; + $inputparams = $p2; + $s = "$dbms error: [$errno: $errmsg] in $fn(\"$sql\")\n"; + break; + + case 'PCONNECT': + case 'CONNECT': + $host = $p1; + $database = $p2; + $s = "$dbms error: [$errno: $errmsg] in $fn($host, '****', '****', $database)\n"; + break; + + default: + $s = "$dbms error: [$errno: $errmsg] in $fn($p1, $p2)\n"; + break; + } + /* + * Log connection error somewhere + * 0 message is sent to PHP's system logger, using the Operating System's system + * logging mechanism or a file, depending on what the error_log configuration + * directive is set to. + * 1 message is sent by email to the address in the destination parameter. + * This is the only message type where the fourth parameter, extra_headers is used. + * This message type uses the same internal function as mail() does. + * 2 message is sent through the PHP debugging connection. + * This option is only available if remote debugging has been enabled. + * In this case, the destination parameter specifies the host name or IP address + * and optionally, port number, of the socket receiving the debug information. + * 3 message is appended to the file destination + */ + if (defined('ADODB_ERROR_LOG_TYPE')) { + $t = date('Y-m-d H:i:s'); + if (defined('ADODB_ERROR_LOG_DEST')) + error_log("($t) $s", ADODB_ERROR_LOG_TYPE, ADODB_ERROR_LOG_DEST); + else + error_log("($t) $s", ADODB_ERROR_LOG_TYPE); + } + + //print "<p>$s</p>"; + trigger_error($s, ADODB_ERROR_HANDLER_TYPE); +} +?> Added: trunk/functions/adodb-errorpear.inc.php =================================================================== --- trunk/functions/adodb-errorpear.inc.php (rev 0) +++ trunk/functions/adodb-errorpear.inc.php 2007-07-30 04:57:52 UTC (rev 38) @@ -0,0 +1,87 @@ +<?php +/** + * @version V4.66 28 Sept 2005 (c) 2000-2005 John Lim (jl...@na...). All rights reserved. + * Released under both BSD license and Lesser GPL library license. + * Whenever there is any discrepancy between the two licenses, + * the BSD license will take precedence. + * + * Set tabs to 4 for best viewing. + * + * Latest version is available at http://php.weblogs.com + * +*/ +include_once('PEAR.php'); + +if (!defined('ADODB_ERROR_HANDLER')) + define('ADODB_ERROR_HANDLER','ADODB_Error_PEAR'); + +/* +* Enabled the following if you want to terminate scripts when an error occurs +*/ +//PEAR::setErrorHandling (PEAR_ERROR_DIE); + +/* +* Name of the PEAR_Error derived class to call. +*/ +if (!defined('ADODB_PEAR_ERROR_CLASS')) + define('ADODB_PEAR_ERROR_CLASS','PEAR_Error'); + +/* +* Store the last PEAR_Error object here +*/ +global $ADODB_Last_PEAR_Error; + +$ADODB_Last_PEAR_Error = false; + + /** +* Error Handler with PEAR support. This will be called with the following params +* +* @param $dbms the RDBMS you are connecting to +* @param $fn the name of the calling function (in uppercase) +* @param $errno the native error number from the database +* @param $errmsg the native error msg from the database +* @param $p1 $fn specific parameter - see below +* @param $P2 $fn specific parameter - see below + */ +function ADODB_Error_PEAR($dbms, $fn, $errno, $errmsg, $p1=false, $p2=false) +{ + global $ADODB_Last_PEAR_Error; + + if (error_reporting() == 0) + return; // obey @ protocol + + switch($fn) { + case 'EXECUTE': + $sql = $p1; + $inputparams = $p2; + $s = "$dbms error: [$errno: $errmsg] in $fn(\"$sql\")"; + break; + + case 'PCONNECT': + case 'CONNECT': + $host = $p1; + $database = $p2; + $s = "$dbms error: [$errno: $errmsg] in $fn('$host', ?, ?, '$database')"; + break; + + default: + $s = "$dbms error: [$errno: $errmsg] in $fn($p1, $p2)"; + break; + } + + $class = ADODB_PEAR_ERROR_CLASS; + $ADODB_Last_PEAR_Error = new $class($s, $errno, $GLOBALS['_PEAR_default_error_mode'], $GLOBALS['_PEAR_default_error_options'], $errmsg); + //print "<p>!$s</p>"; +} + +/** +* Returns last PEAR_Error object. This error might be for an error that +* occured several sql statements ago. +*/ +function &ADODB_PEAR_Error() +{ + global $ADODB_Last_PEAR_Error; + + return $ADODB_Last_PEAR_Error; +} +?> \ No newline at end of file Added: trunk/functions/adodb-exceptions.inc.php =================================================================== --- trunk/functions/adodb-exceptions.inc.php (rev 0) +++ trunk/functions/adodb-exceptions.inc.php 2007-07-30 04:57:52 UTC (rev 38) @@ -0,0 +1,86 @@ +<?php + +/** + * @version V4.66 28 Sept 2005 (c) 2000-2005 John Lim (jl...@na...). All rights reserved. + * Released under both BSD license and Lesser GPL library license. + * Whenever there is any discrepancy between the two licenses, + * the BSD license will take precedence. + * + * Set tabs to 4 for best viewing. + * + * Latest version is available at http://php.weblogs.com + * + * Exception-handling code using PHP5 exceptions (try-catch-throw). + */ + +if (!defined('ADODB_ERROR_HANDLER_TYPE')) + define('ADODB_ERROR_HANDLER_TYPE',E_USER_ERROR); + +define('ADODB_ERROR_HANDLER','adodb_throw'); + +class ADODB_Exception extends Exception { + var $dbms; + var $fn; + var $sql = ''; + var $params = ''; + var $host = ''; + var $database = ''; + + function __construct($dbms, $fn, $errno, $errmsg, $p1, $p2, $thisConnection) + { + switch($fn) { + case 'EXECUTE': + $this->sql = $p1; + $this->params = $p2; + $s = "$dbms error: [$errno: $errmsg] in $fn(\"$p1\")\n"; + break; + + case 'PCONNECT': + case 'CONNECT': + $user = $thisConnection->username; + $s = "$dbms error: [$errno: $errmsg] in $fn($p1, '$user', '****', $p2)\n"; + break; + + default: + $s = "$dbms error: [$errno: $errmsg] in $fn($p1, $p2)\n"; + break; + } + + $this->dbms = $dbms; + $this->host = $thisConnection->host; + $this->database = $thisConnection->database; + $this->fn = $fn; + $this->msg = $errmsg; + + if (!is_numeric($errno)) + $errno = -1; + + parent::__construct($s,$errno); + } +} + +/** +* Default Error Handler. This will be called with the following params +* +* @param $dbms the RDBMS you are connecting to +* @param $fn the name of the calling function (in uppercase) +* @param $errno the native error number from the database +* @param $errmsg the native error msg from the database +* @param $p1 $fn specific parameter - see below +* @param $P2 $fn specific parameter - see below +*/ + +function adodb_throw($dbms, $fn, $errno, $errmsg, $p1, $p2, $thisConnection) +{ + global $ADODB_EXCEPTION; + + if (error_reporting() == 0) + return; // obey @ protocol + + if (is_string($ADODB_EXCEPTION)) + $errfn = $ADODB_EXCEPTION; + else $errfn = 'ADODB_EXCEPTION'; + + throw new $errfn($dbms, $fn, $errno, $errmsg, $p1, $p2, $thisConnection); +} +?> \ No newline at end of file Added: trunk/functions/adodb-perf-module.inc.php =================================================================== --- trunk/functions/adodb-perf-module.inc.php (rev 0) +++ trunk/functions/adodb-perf-module.inc.php 2007-07-30 04:57:52 UTC (rev 38) @@ -0,0 +1,974 @@ +<?php +/* +V4.65 22 July 2005 (c) 2000-2005 John Lim (jl...@na...). All rights reserved. + Released under both BSD license and Lesser GPL library license. + Whenever there is any discrepancy between the two licenses, + the BSD license will take precedence. See License.txt. + + Library for basic performance monitoring and tuning. + + Modified 23 April 2006 for use with ADOdb Lite by Pádraic Brady + Such modifications as listed (c) 2006 Pádraic Brady (mau...@ho...) + + Modifications: + - Moved below methods from adodb_perf class to create a common parent from which all driver + specific perfmon modules will extend to prevent duplicate code. + - See specific driver module files for other changes + +*/ + +eval('class perfmon_parent_EXTENDER extends ' . $last_module . '_ADOConnection { }'); + +class perfmon_parent_ADOConnection extends perfmon_parent_EXTENDER +{ + + var $color = '#F0F0F0'; + var $table = '<table style="border: 2px groove #000000; background-color: #FFFFFF;">'; + var $titles = '<tr><td><strong>Parameter</strong></td><td><strong>Value</strong></td><td><strong>Description</strong></td></tr>'; + var $warnRatio = 90; + var $tablesSQL = false; + var $cliFormat = "%32s => %s \r\n"; + var $sql1 = 'sql1'; // used for casting sql1 to text for mssql + var $explain = true; + var $helpurl = '<a href="javascript:void();">LogSQL help</a>'; + var $createTableSQL = false; + var $maxLength = 2000; + var $settings = false; + var $_logsql = false; + var $_lastload; + + /** + * Sets the table name to use for SQL logging. Returns value of current table when called. + * Usage: perfmon_parent_ADOConnection::table('custom_log_sql'); + * $currentTable = perfmon_parent_ADOConnection::table(); + * + * @access public + * @param string $newtable The name for the table to use; optional. + * @return string + */ + function table($newtable = false) + { + static $_table; + if (!empty($newtable)) $_table = $newtable; + if (empty($_table)) $_table = 'adodb_logsql'; + return $_table; + } + + /** + * Enables SQL logging to database for Performance Monitor use. + * Usage: $oldValue = $db->LogSQL( $enable ); + * $enable is optional; defaults to TRUE enabling logging. FALSE disables logging. + * + * @access public + * @param bool $enable + * @return bool + */ + function LogSQL($enable=true) + { + $old = $this->_logsql; + $this->_logsql = $enable; + return $old; + } + + /** + * Returns an array with information to calculate CPU Load + * + * @access private + * @return mixed + */ + function _CPULoad() { + // Algorithm is taken from + // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/example__obtaining_raw_performance_data.asp + if (strncmp(PHP_OS,'WIN',3)==0) + { + if (PHP_VERSION == '5.0.0') return false; + if (PHP_VERSION == '5.0.1') return false; + if (PHP_VERSION == '5.0.2') return false; + if (PHP_VERSION == '5.0.3') return false; + if (PHP_VERSION == '4.3.10') return false; # see http://bugs.php.net/bug.php?id=31737 + + @$c = new COM("WinMgmts:{impersonationLevel=impersonate}!Win32_PerfRawData_PerfOS_Processor.Name='_Total'"); + if (!$c) return false; + + $info[0] = $c->PercentProcessorTime; + $info[1] = 0; + $info[2] = 0; + $info[3] = $c->TimeStamp_Sys100NS; + return $info; + } + + // Algorithm - Steve Blinch (BlitzAffe Online, http://www.blitzaffe.com) + $statfile = '/proc/stat'; + if (!file_exists($statfile)) return false; + + $fd = fopen($statfile,"r"); + if (!$fd) return false; + + $statinfo = explode("\n",fgets($fd, 1024)); + fclose($fd); + foreach($statinfo as $line) + { + $info = explode(" ",$line); + if($info[0]=="cpu") + { + array_shift($info); // pop off "cpu" + if(!$info[0]) array_shift($info); // pop off blank space (if any) + return $info; + } + } + + return false; + } + + /* NOT IMPLEMENTED */ + function MemInfo() + { + + } + + + /** + * Returns CPU Load + * + * @access public + * @return mixed + */ + function CPULoad() + { + $info = $this->_CPULoad(); + if (!$info) return false; + + if (empty($this->_lastLoad)) + { + sleep(1); + $this->_lastLoad = $info; + $info = $this->_CPULoad(); + } + + $last = $this->_lastLoad; + $this->_lastLoad = $info; + + $d_user = $info[0] - $last[0]; + $d_nice = $info[1] - $last[1]; + $d_system = $info[2] - $last[2]; + $d_idle = $info[3] - $last[3]; + + if (strncmp(PHP_OS,'WIN',3)==0) + { + if ($d_idle < 1) $d_idle = 1; + return 100*(1-$d_user/$d_idle); + } + else + { + $total=$d_user+$d_nice+$d_system+$d_idle; + if ($total<1) $total=1; + return 100*($d_user+$d_nice+$d_system)/$total; + } + } + + function Tracer($sql) + { + $perf_table = perfmon_parent_ADOConnection::table(); + $saveE = $this->LogSQL(false); + + global $ADODB_FETCH_MODE; + $save = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + + $sqlq = $this->qstr($sql); + $arr = $this->GetArray( + "select count(*),tracer + from $perf_table where sql1=$sqlq + group by tracer + order by 1 desc" + ); + $s = ''; + if ($arr) + { + $s .= '\n<h3>Scripts Affected</h3>\n'; + foreach($arr as $k) + { + $s .= sprintf("%4d",$k[0]).' '.strip_tags($k[1]).'<br />'; + } + } + $this->LogSQL($saveE); + return $s; + } + + /* + Explain Plan for $sql. + If only a snippet of the $sql is passed in, then $partial will hold the crc32 of the + actual sql. + */ + function Explain($sql, $partial=false) + { + return false; + } + + function InvalidSQL($numsql = 10) + { + + if (isset($_GET['sql'])) return; + $s = '<h3>Invalid SQL</h3>'; + $saveE = $this->LogSQL(false); + $perf_table = perfmon_parent_ADOConnection::table(); + $rs =& $this->SelectLimit( + "select distinct count(*), sql1, tracer as error_msg + from $perf_table + where tracer like 'ERROR:%' + group by sql1, tracer + order by 1 desc" + ,$numsql + ); + $this->LogSQL($saveE); + if ($rs) + { + $s .= rs2html($rs,false,false,false,false); + } + else + { + return "\n<p>$this->helpurl. ".$this->ErrorMsg()."</p>\n"; + } + return $s; + } + + + /* + This script identifies the longest running SQL + */ + function _SuspiciousSQL($numsql = 10) + { + global $ADODB_FETCH_MODE; + + $perf_table = perfmon_parent_ADOConnection::table(); + $saveE = $this->LogSQL(false); + + if (isset($_GET['exps']) && isset($_GET['sql'])) + { + $partial = !empty($_GET['part']); + echo '<a name="explain"></a>' . $this->Explain($_GET['sql'], $partial) . "\n"; + } + + if (isset($_GET['sql'])) return; + $sql1 = $this->sql1; + + $save = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + + $rs =& $this->SelectLimit( + "select avg(timer) as avg_timer, $sql1, count(*), max(timer) as max_timer, min(timer) as min_timer + from $perf_table + where {$this->upperCase}({$this->substr}(sql0,1,5)) not in ('DROP ','INSER','COMMI','CREAT') + and (tracer is null or tracer not l... [truncated message content] |
From: <cal...@us...> - 2007-07-30 04:53:43
|
Revision: 37 http://astrospaces.svn.sourceforge.net/astrospaces/?rev=37&view=rev Author: caleb870 Date: 2007-07-29 21:53:45 -0700 (Sun, 29 Jul 2007) Log Message: ----------- Modified Paths: -------------- trunk/config.php Modified: trunk/config.php =================================================================== --- trunk/config.php 2007-07-30 03:24:55 UTC (rev 36) +++ trunk/config.php 2007-07-30 04:53:45 UTC (rev 37) @@ -7,28 +7,30 @@ 'name' => '' ); */ -global $_AS; -$_AS['ext'] = '.php'; -$_AS['lang'] = 'en-us'; +define('AS_EXT', '.php'); +define('AS_LANG', 'en-us'); -$_AS['db_type'] = 'mysql'; // Needed for ADOdb. -$_AS['db_prefix'] = 'as_'; -$_AS['db_host'] = 'localhost'; -$_AS['db_user'] = 'username'; -$_AS['db_pass'] = 'password'; -$_AS['db_schema'] = 'schema'; +define('AS_DB_TYPE', 'mysql'); +define('AS_DB_PREFIX', 'as_'); +define('AS_DB_HOST', 'localhost'); +define('AS_DB_SCHEMA', 'schema'); +define('AS_DB_USER', 'user'); +define('AS_DB_PASS', 'pass'); -$_AS['loc_url'] = 'http://localhost/'; -$_AS['loc_direct'] = 'C:/path/to/astrospaces/'; +define('AS_LOC_URL', AS_DB_PREFIX.'http://localhost/'); +define('AS_LOC_DIRECT', AS_DB_PREFIX.'C:/path/to/astrospaces/'); -$_AS['tbl_user'] = $_AS['db_prefix'].'user'; -$_AS['tbl_blog'] = $_AS['db_prefix'].'blog'; -$_AS['tbl_blog_comment'] = $_AS['db_prefix'].'blog_comments'; -$_AS['tbl_friend'] = $_AS['db_prefix'].'friend'; -$_AS['tbl_img'] = $_AS['db_prefix'].'images'; -$_AS['tbl_img_comment'] = $_AS['db_prefix'].'image_comments'; -$_AS['tbl_actions'] = $_AS['db_prefix'].'actions'; -$_AS['tbl_comments'] = $_AS['db_prefix'].'comments'; -$_AS['tbl_sessions'] = $_AS['db_prefix'].'sessions'; -$_AS['tbl_pm'] = $_AS['db_prefix'].'pm'; +define('AS_TBL_USER', AS_DB_PREFIX.'user'); +define('AS_TBL_BLOG', AS_DB_PREFIX.'blog'); +define('AS_TBL_BLOG_CMT', AS_DB_PREFIX.'blog_comments'); +define('AS_TBL_FRIEND', AS_DB_PREFIX.'friend'); +define('AS_TBL_IMG', AS_DB_PREFIX.'images'); +define('AS_TBL_IMG_CMT', AS_DB_PREFIX.'image_comments'); +define('AS_TBL_ACTION', AS_DB_PREFIX.'actions'); +define('AS_TBL_CMT', AS_DB_PREFIX.'comments'); +define('AS_TBL_SESSION', AS_DB_PREFIX.'sessions'); +define('AS_TBL_PM', AS_DB_PREFIX.'pm'); + +define('AS_DIR_TPL', 'template/'); +define('AS_TPL', AS_LOC_URL.AS_DIR_TPL); ?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cal...@us...> - 2007-07-30 03:24:52
|
Revision: 36 http://astrospaces.svn.sourceforge.net/astrospaces/?rev=36&view=rev Author: caleb870 Date: 2007-07-29 20:24:55 -0700 (Sun, 29 Jul 2007) Log Message: ----------- Removed file/folder Removed Paths: ------------- trunk/template/drill.tpl trunk/template/gallery.tpl trunk/template/home.tpl trunk/template/inbox.tpl trunk/template/outer.tpl trunk/template/read.tpl trunk/template/send.tpl Deleted: trunk/template/drill.tpl =================================================================== Deleted: trunk/template/gallery.tpl =================================================================== Deleted: trunk/template/home.tpl =================================================================== --- trunk/template/home.tpl 2007-07-30 03:24:18 UTC (rev 35) +++ trunk/template/home.tpl 2007-07-30 03:24:55 UTC (rev 36) @@ -1,7 +0,0 @@ -<!-- New Members --> -<?php -foreach($userdetail as $key => $value) -{ - echo "<img src=\"images.php?mode=thumb&id=" . $value['user_image'] . "\" /><br /><a href=\"&id=" . $value['id'] . "\">" . $key . "</a>"; -} -?> \ No newline at end of file Deleted: trunk/template/inbox.tpl =================================================================== Deleted: trunk/template/outer.tpl =================================================================== --- trunk/template/outer.tpl 2007-07-30 03:24:18 UTC (rev 35) +++ trunk/template/outer.tpl 2007-07-30 03:24:55 UTC (rev 36) @@ -1,8 +0,0 @@ -<html> - <head> - <title>Project Orange | <?php echo $title; ?></title> - </head> - <body> - <?php echo $contents; ?> - </body> -</html> \ No newline at end of file Deleted: trunk/template/read.tpl =================================================================== Deleted: trunk/template/send.tpl =================================================================== This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cal...@us...> - 2007-07-30 03:24:16
|
Revision: 35 http://astrospaces.svn.sourceforge.net/astrospaces/?rev=35&view=rev Author: caleb870 Date: 2007-07-29 20:24:18 -0700 (Sun, 29 Jul 2007) Log Message: ----------- Copied remotely Added Paths: ----------- trunk/template/default/inbox.tpl Copied: trunk/template/default/inbox.tpl (from rev 34, trunk/template/inbox.tpl) =================================================================== This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cal...@us...> - 2007-07-30 03:24:08
|
Revision: 34 http://astrospaces.svn.sourceforge.net/astrospaces/?rev=34&view=rev Author: caleb870 Date: 2007-07-29 20:24:11 -0700 (Sun, 29 Jul 2007) Log Message: ----------- Copied remotely Added Paths: ----------- trunk/template/default/gallery.tpl Copied: trunk/template/default/gallery.tpl (from rev 33, trunk/template/gallery.tpl) =================================================================== This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cal...@us...> - 2007-07-30 03:24:00
|
Revision: 33 http://astrospaces.svn.sourceforge.net/astrospaces/?rev=33&view=rev Author: caleb870 Date: 2007-07-29 20:24:02 -0700 (Sun, 29 Jul 2007) Log Message: ----------- Copied remotely Added Paths: ----------- trunk/template/default/outer.tpl Copied: trunk/template/default/outer.tpl (from rev 32, trunk/template/outer.tpl) =================================================================== --- trunk/template/default/outer.tpl (rev 0) +++ trunk/template/default/outer.tpl 2007-07-30 03:24:02 UTC (rev 33) @@ -0,0 +1,8 @@ +<html> + <head> + <title>Project Orange | <?php echo $title; ?></title> + </head> + <body> + <?php echo $contents; ?> + </body> +</html> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cal...@us...> - 2007-07-30 03:23:51
|
Revision: 32 http://astrospaces.svn.sourceforge.net/astrospaces/?rev=32&view=rev Author: caleb870 Date: 2007-07-29 20:23:53 -0700 (Sun, 29 Jul 2007) Log Message: ----------- Copied remotely Added Paths: ----------- trunk/template/default/read.tpl Copied: trunk/template/default/read.tpl (from rev 31, trunk/template/read.tpl) =================================================================== This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cal...@us...> - 2007-07-30 03:23:45
|
Revision: 31 http://astrospaces.svn.sourceforge.net/astrospaces/?rev=31&view=rev Author: caleb870 Date: 2007-07-29 20:23:47 -0700 (Sun, 29 Jul 2007) Log Message: ----------- Copied remotely Added Paths: ----------- trunk/template/default/send.tpl Copied: trunk/template/default/send.tpl (from rev 30, trunk/template/send.tpl) =================================================================== This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cal...@us...> - 2007-07-30 03:23:36
|
Revision: 30 http://astrospaces.svn.sourceforge.net/astrospaces/?rev=30&view=rev Author: caleb870 Date: 2007-07-29 20:23:38 -0700 (Sun, 29 Jul 2007) Log Message: ----------- Copied remotely Added Paths: ----------- trunk/template/default/home.tpl Copied: trunk/template/default/home.tpl (from rev 29, trunk/template/home.tpl) =================================================================== --- trunk/template/default/home.tpl (rev 0) +++ trunk/template/default/home.tpl 2007-07-30 03:23:38 UTC (rev 30) @@ -0,0 +1,7 @@ +<!-- New Members --> +<?php +foreach($userdetail as $key => $value) +{ + echo "<img src=\"images.php?mode=thumb&id=" . $value['user_image'] . "\" /><br /><a href=\"&id=" . $value['id'] . "\">" . $key . "</a>"; +} +?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |