[Shuttlebb-svn] SF.net SVN: shuttlebb: [66] branch/sources
Brought to you by:
afterlife69,
danb00
From: <aft...@us...> - 2006-12-03 13:45:52
|
Revision: 66 http://svn.sourceforge.net/shuttlebb/?rev=66&view=rev Author: afterlife69 Date: 2006-12-03 05:45:51 -0800 (Sun, 03 Dec 2006) Log Message: ----------- sessions work! Modified Paths: -------------- branch/sources/class_dbal.php branch/sources/class_session.php branch/sources/dbal/dbal_mysql.php branch/sources/dbal/dbal_mysqli.php Modified: branch/sources/class_dbal.php =================================================================== --- branch/sources/class_dbal.php 2006-12-03 13:16:50 UTC (rev 65) +++ branch/sources/class_dbal.php 2006-12-03 13:45:51 UTC (rev 66) @@ -38,27 +38,6 @@ */ /** - * @todo Database Layer(s) <<< - * - * Each database layer must contain the following methods: - * - * dbal_layer::dbal_layer - * - * dbal_layer::sql_connect - * dbal_layer::sql_close - * dbal_layer::sql_query - * dbal_layer::sql_freeresult - * dbal_layer::sql_escape - * dbal_layer::sql_field_info - * dbal_layer::sql_num_rows - * dbal_layer::sql_num_fields - * dbal_layer::sql_info - * dbal_layer::sql_select_db - * - * >>> - */ - -/** * Prevent include errors */ if ( class_exists ( 'dbal' ) ) @@ -237,7 +216,7 @@ if ( ! $result = $this->layer->sql_query($sql) ) { // Report a query error. - trigger_error('Error_DB_Query(' . $sql . ')'); + trigger_error('Error_DB_Query(' . $this->layer->sql_error($result) . ',' . $sql . ')'); } } Modified: branch/sources/class_session.php =================================================================== --- branch/sources/class_session.php 2006-12-03 13:16:50 UTC (rev 65) +++ branch/sources/class_session.php 2006-12-03 13:45:51 UTC (rev 66) @@ -7,6 +7,11 @@ * @package sbb_core */ +if ( ! defined ( 'IN_SBB' ) ) +{ + return; +} + /** * Session Emulation Class. * This class manages sessions without using the built-in php session handler @@ -69,7 +74,7 @@ // Set the class variables $this->ip = ( preg_match ( '/^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/', $_SERVER['REMOTE_ADDR'] ) ) ? $_SERVER['REMOTE_ADDR'] : ''; $this->agent = ( isset ( $_SERVER['HTTP_USER_AGENT'] ) ) ? $_SERVER['HTTP_USER_AGENT'] : false; - $this->page = ( ! empty ( $page_id ) ) ? $page_id : PAGE_MAIN; + $this->page = ( ! empty ( $page_id ) ) ? $page_id : 0; $this->method = ( ! empty ( $_COOKIE['_sid']) ) ? 'cookie' : 'get'; $this->sid = ( $this->method == 'cookie' ) ? $_COOKIE['_sid'] : $_GET['sid']; @@ -153,7 +158,7 @@ global $db; // Update the session - $db->sql_query('UPDATE TABLE ' . SESSIONS_TABLE . ' ' . + $db->sql_query('UPDATE ' . SESSIONS_TABLE . ' ' . $db->sql_build_update(array( 'session_ip' => (string) $db->sql_escape($this->ip), 'session_time' => (int) time(), Modified: branch/sources/dbal/dbal_mysql.php =================================================================== --- branch/sources/dbal/dbal_mysql.php 2006-12-03 13:16:50 UTC (rev 65) +++ branch/sources/dbal/dbal_mysql.php 2006-12-03 13:45:51 UTC (rev 66) @@ -118,6 +118,11 @@ // delete field in table return $this->sql_query("ALTER TABLE `$table` DROP `$field`"); } + + function sql_error($result) + { + return @mysql_errno($result) . ':' . @mysql_error($result); + } } ?> \ No newline at end of file Modified: branch/sources/dbal/dbal_mysqli.php =================================================================== --- branch/sources/dbal/dbal_mysqli.php 2006-12-03 13:16:50 UTC (rev 65) +++ branch/sources/dbal/dbal_mysqli.php 2006-12-03 13:45:51 UTC (rev 66) @@ -37,19 +37,20 @@ function sql_connect($db_user, $db_pass, $db_name, $db_server) { // connect to database - return $this->conn_id = @mysqli_connect($db_server, $db_user, $db_pass, $db_name); + $this->conn_id = new mysqli($db_server, $db_user, $db_pass, $db_name); + return ( ! mysqli_connect_errno() ); } function sql_close() { // close db connection - return @mysqli_close($this->conn_id); + return $this->conn_id->close(); } function sql_query($sql) { // exec sql query - return @mysqli_query($this->conn_id, $sql); + return $this->conn_id->query($sql); } function sql_fetchrow($result, $type) @@ -58,13 +59,13 @@ { default: case 'assoc': - return @mysqli_fetch_assoc($result); + return $result->fetch_assoc(); break; case 'object': - return @mysqli_fetch_object($result); + return $result->fetch_object(); break; case 'index': - return @mysqli_fetch_array($result, MYSQLI_NUM); + return $result->fetch_array(MYSQLI_NUM); break; } } @@ -72,37 +73,37 @@ function sql_freeresult($resource) { // free the sql result - return @mysqli_free_result($resource); + return $result->close(); } function sql_escape($value) { // escape the value - return @mysqli_real_escape_string($this->conn_id, $value); + return $this->conn_id->real_escape_string($value); } function sql_num_fields($result) { // number of fields in result - return @mysqli_num_fields($result); + return $result->field_count; } function sql_num_rows($result) { // number of rows in result - return @mysqli_num_rows($reuslt); + return $result->row_count; } function sql_info() { // mysqli info - return @mysqli_info($this->conn_id); + return ( isset($this->conn_id->info) ) ? $this->conn_id->info : false; } function sql_select_db($dbname) { // select database - return @mysqli_select_db($this->conn_id, $dbname); + return true; } function sql_field_create($table, $field, $type, $len) @@ -116,6 +117,11 @@ // delete field in table return $this->sql_query("ALTER TABLE `$table` DROP `$field`"); } + + function sql_error($result) + { + return $result->errno . ':' . $result->error; + } } ?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |