<?php
class PowerBBSQL
{
var $host = 'localhost';
var $db_username = '';
var $db_password = '';
var $db_name = '';
var $use_pconnect = true;
var $debug = false;
var $store_queries = false;
var $queries = array();
var $number;
var $_from;
var $_query;
var $_x = 0;
function SetInformation($host,$db_username,$db_password,$db_name)
{
$this->host = $host;
$this->db_username = $db_username;
$this->db_password = $db_password;
$this->db_name = $db_name;
}
function SetDebug($debug)
{
$this->debug = $debug;
}
function SetQueriesStore($store)
{
$this->store_queries = $store;
}
function GetQueriesNumber()
{
return $this->number;
}
function GetQueriesArray()
{
return $this->queries;
}
function sql_connect()
{
$function = (!$this->user_pconnect) ? 'mysql_connect' : 'mysql_pconnect';
$connect = @$function($this->host,$this->db_username,$this->db_password);
$this->_from = 'connect';
if (!$connect)
{
$this->_error();
}
return $connect;
}
function sql_select_db()
{
$select = @mysql_select_db($this->db_name);
$this->_from = 'select';
if (!$select)
{
$this->_error();
}
return $select;
}
function sql_close()
{
$close = @mysql_close();
$this->_from = 'close';
if (!$close)
{
$this->_error();
}
return $close;
}
function sql_query($query)
{
global $PowerBB;
$result = @mysql_query($query);
$this->_from = 'query';
if (!$result)
{
$this->_query = $query;
$this->_error();
}
/*
$PowerBB->_CONF['temp']['query_numbers']++;
$PowerBB->_CONF['temp']['queries'][] = $query;
*/
if ($this->debug)
{
if ($this->store_queries)
{
$this->queries[$this->_x++] = $query;
}
}
return $result;
}
function sql_unbuffered_query($query)
{
$result = @mysql_unbuffered_query($query);
$this->_from = 'query';
if (!$result)
{
$this->_query = $query;
$this->_error();
}
/*
$PowerBB->_CONF['temp']['query_numbers']++;
$PowerBB->_CONF['temp']['queries'][] = $query;
*/
if ($this->debug)
{
if ($this->store_queries)
{
$this->queries[$this->_x++] = $query;
}
}
return $result;
}
function sql_fetch_array($result)
{
$out = @mysql_fetch_array($result,MYSQL_ASSOC);
return $out;
}
function sql_num_rows($result)
{
$out = @mysql_num_rows($result);
return $out;
}
function sql_insert_id()
{
$out = @mysql_insert_id();
return $out;
}
function check($table)
{
$result = @mysql_query("SELECT * FROM " . $table);
if (!$result)
{
$err = mysql_errno();
if ($err = 1146)
{
return false;
}
else
{
return true;
}
}
else
{
return true;
}
}
function _error()
{
$error_no = mysql_errno();
$error_msg = mysql_error();
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
echo '<html dir="rtl" xmlns="http://www.w3.org/1999/xhtml" xml:lang="ar" lang="ar">';
echo '<head>';
echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />';
echo '<title>خطأ ÙÙ ÙÙØ§Ø¹Ø¯ Ø§ÙØ¨ÙØ§ÙØ§Øª</title>';
echo '<style type="text/css"> body { font-family:tahoma; font-size:12px; } </style>';
echo '</head>';
echo '<body dir="rtl">';
echo '<div align="center">';
echo 'ØØ¯Ø« خطأ Ù
ع ÙÙØ§Ø¹Ø¯ Ø§ÙØ¨ÙØ§ÙØ§Øª <br />';
if (!empty($this->_from))
{
echo '<strong>';
echo 'سبب Ø§ÙØ®Ø·Ø£ : ';
if ($this->_from == 'connect')
{
echo 'Ø§ÙØ§ØªØµØ§Ù بÙÙØ§Ø¹Ø¯ Ø§ÙØ¨ÙØ§ÙØ§Øª';
}
elseif ($this->_from == 'select')
{
echo 'Ø§Ø®ØªÙØ§Ø± ÙØ§Ø¹Ø¯Ø© Ø§ÙØ¨ÙØ§ÙØ§Øª';
}
elseif ($this->_from == 'close')
{
echo 'Ø§ØºÙØ§Ù Ø§ÙØ§ØªØµØ§Ù';
}
elseif ($this->_from == 'query')
{
echo 'Ø§Ø³ØªØ¹ÙØ§Ù
';
}
else
{
echo 'ØºÙØ± Ù
عرÙÙ';
}
echo '</strong>';
echo '<br />';
}
echo 'رÙÙ
Ø§ÙØ®Ø·Ø£ : ' . $error_no . '<br />';
echo 'Ø±Ø³Ø§ÙØ© Ø§ÙØ®Ø·Ø£ : ' . $error_msg . '<br />';
if ($this->debug)
{
echo 'Ø§ÙØ§Ø³ØªØ¹ÙاÙ
اÙÙ
سبب ÙÙØ®Ø·Ø£ : <br />';
echo '<div dir="ltr">';
echo $this->_query;
echo '</div>';
}
echo '</div>';
echo '</body>';
exit();
}
}
?>