diff options
Diffstat (limited to 'includes')
-rw-r--r-- | includes/debug.php | 4 | ||||
-rw-r--r-- | includes/functions.php | 26 | ||||
-rw-r--r-- | includes/sql.class.php | 86 |
3 files changed, 68 insertions, 48 deletions
diff --git a/includes/debug.php b/includes/debug.php index c67ee9c..2f6e40a 100644 --- a/includes/debug.php +++ b/includes/debug.php @@ -33,13 +33,13 @@ static $log_message_pos = 0; function decho($message, $force = false) { global $log_message_last, $log_message_queue, $log_message_pos, $config; - /* + if($force == false) { if($config['debug']['enabled'] == false || $config['debug']['show_messages'] == false) return; } - */ + date_default_timezone_set($config['logs']['timezone']); $timestamp = date('H:i:s T'); diff --git a/includes/functions.php b/includes/functions.php index f0fe60e..bc169ff 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -301,10 +301,10 @@ if(!defined("CALLED_FROM_ADMIN")) * Begins a Bayonet site table. * @return */ - function OpenTable() + function OpenTable($width = "100%") { //width="100%" is important. Otherwise all of our tables will be text width. - echo "<table width=\"100%\" align=\"center\" class=\"cleartable\">\n"; + echo "<table width=\"{$width}\" align=\"center\" class=\"cleartable\">\n"; } /** @@ -314,7 +314,7 @@ if(!defined("CALLED_FROM_ADMIN")) */ function CloseTable() { - //echo "</table>"; + echo "</table>"; } /** @@ -412,6 +412,19 @@ function ReportHack($message) CloseTable(); } +/** + * PageRedirect() + * + * performs an http redirect + * + * @param $delay + * @param $link + */ +function PageRedirect($delay, $link) +{ + echo "<meta http-equiv=\"Refresh\" content=\"{$delay};url={$link}\">"; +} + /** * array_dump() @@ -588,11 +601,8 @@ function GetBlocks($position = BLOCK_LEFT) $result = $db->Query("SELECT * FROM `bayonet_blocks` ORDER BY weight, position"); //$result = mysql_query("SELECT * FROM bayonet_blocks ORDER BY weight, position"); - while(($row = $db->Fetch($result))!==false) - { - $blocks[] = $row; - } - $db->Free($result); + $blocks = $db->Fetch($result); + $blocks[] = $row; foreach($blocks as $block) { diff --git a/includes/sql.class.php b/includes/sql.class.php index 0dcd0d5..3b93e2a 100644 --- a/includes/sql.class.php +++ b/includes/sql.class.php @@ -33,51 +33,38 @@ class Bayonet_SQL $this->hostname = $hostname; decho("Connecting ('$hostname')"); - return mysql_connect($hostname, $username, $passwd); + return ($GLOBALS['___mysqli_ston'] = mysqli_connect($hostname, $username, $passwd)); } public function Disconnect($link) { decho("Disconnecting ('$link' from '$this->hostname')"); - //return mysql_close($link); + return mysqli_close($GLOBALS['___mysqli_ston']); } public function Stat() { - return mysql_stat(); + return mysqli_stat($GLOBALS['___mysqli_ston']); } public function Select_db($db) { decho("Selecting database ('$db')"); - return mysql_select_db($db); + return mysqli_select_db($GLOBALS['___mysqli_ston'], $db); } public function Query($str) { global $db_queries; ++$db_queries; - //FIGURE OUT HOW TO CHECK EXCEPTION, TRY CATCH ??? - // if(!mysql_query($str)) - // { - // throw new Exception(mysql_error()); - // } - /* - try{ - - }catch(Exception $e){ - - } */ - - return mysql_query($str); + return mysqli_query($GLOBALS['___mysqli_ston'], $str); } public function Free($result) { global $db_frees; ++$db_frees; - decho("Freeing result"); - return mysql_free_result($result); + @((mysqli_free_result($result) || (is_object($result) && (get_class($result) == "mysqli_result"))) ? true : false); } public function Fetch($result) @@ -85,42 +72,65 @@ class Bayonet_SQL return $this->FetchArray($result); } - public function FetchArray($result) - { - global $db_fetches; - ++$db_fetches; - /* Alias Fetch() prefered, so no decho information */ - decho("Fetching result"); - return mysql_fetch_array($result,MYSQL_ASSOC); - } + public function FetchArray($p_result) + { + global $db_fetches; + ++$db_fetches; + + decho('Fetching result'); + + while ($row = mysqli_fetch_array($p_result, MYSQLI_ASSOC)) { + $result[] = $row; + } + + $this->Free($p_result); + + return is_array($result) ? $result : array(); + } - public function FetchObject($result,$class) + public function FetchObject($p_result, $class) { global $db_fetches; ++$db_fetches; + decho("Fetching object result"); - return mysql_fetch_object($result,$class); + + while ($row = mysqli_fetch_object($p_result, $class)) { + (object)$result[] = $row; + } + + $this->Free($p_result); + + return is_object($result) ? $result : (object)array(); } public function FetchAssoc($result) - { - global $db_fetches; - ++$db_fetches; - decho("Fetching assoc result"); - return mysql_fetch_assoc($result); + { + return $this->FetchArray($result); } - public function FetchRow($result) + public function FetchRow($p_result) { + global $db_fetches; + ++$db_fetches; + decho("Fetching single row"); - return mysql_fetch_row($result); + + while ($row = mysqli_fetch_row($p_result)) { + $result[] = $row; + } + + $this->Free($p_result); + + return is_array($result) ? $result : array(); } public function Rows($result) { decho("Fetching number of rows"); - return mysql_num_rows($result); + + return mysqli_num_rows($result); } } -?>
\ No newline at end of file +?> |