A lightweight forum engine written in PHP. Repository is now obsolete and read-only. http://www.pioder.pl/uforum.html
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

65 lines
2.1 KiB

<?php
/**
* @package uForum
* @file includes/db.php
* @version $Id$
* @copyright 2009(c) PioDer <[email protected]>
* @link http://pioder.gim2przemysl.int.pl/
* @license GNU GPL v3
**/
if ( !defined('IN_uF') )
{
die('Hacking attempt');
}
class DataBase
{
function db_connect()
{
$connect = mysql_pconnect(DB_HOST, DB_USER, DB_PASS) or message_die('CRITICAL',' Could not connect to database server.',mysql_error());
mysql_query("SET NAMES 'utf8'",$connect);
mysql_select_db(DB_NAME, $connect) or message_die('CRITICAL',' Could not connect to database.',mysql_error());
}
function sql_query($sql, $type, $msg, $no_count = false)
{
if (isset($_COOKIE['queries']))
{
$no_count = false;
if(!$no_count)
{
$_COOKIE['queries'] = $_COOKIE['queries']+1;
}
}
//echo '<span class="fsmall">'.$sql.'<br></span>'; //for optimizing only
$query = mysql_query($sql) or message_die($type, $msg, mysql_error());
return $query;
}
function new_id($table)
{
//check table id
switch($table)
{
case BANLIST_TABLE: { $id = 'b_id'; break; }
case CATS_TABLE: { $id = 'c_id'; break; }
case CENSORLIST_TABLE: { $id = 'w_id'; break; }
case FORUMS_TABLE: { $id = 'f_id'; break; }
case GROUPS_TABLE: { $id = 'g_id'; break; }
case PM_INBOX_TABLE: { $id = 'm_id'; break; }
case PM_SENTBOX_TABLE: { $id = 'm_id'; break; }
case POSTS_TABLE: { $id = 'p_id'; break; }
case TOPICS_TABLE: { $id = 't_id'; break; }
case SESSIONS_TABLE: { $id = 's_id'; break; }
case SKINS_TABLE: { $id = 's_id'; break; }
case SMILES_TABLE: { $id = 's_id'; break; }
case USERS_TABLE: { $id = 'u_id'; break; }
case USERS_GROUP_TABLE: { $id = 'id'; break; }
case WARNINGS_TABLE: { $id = 'w_id'; break; }
}
$sql = "SELECT `$id` FROM $table ORDER BY `$id` DESC LIMIT 1";
$return_id = mysql_fetch_array(DataBase::sql_query($sql,'GENERAL','Error with obtain last id.<br> File: db.php, Line: '.__LINE__));
$return_id = $return_id[$id];
$return_id = $return_id+1;
return $return_id;
unset($table, $return_id, $id, $sql);
}
}
?>