|
|
- <?php
- /**
- * @package Dynamic Script Forum
- * @file includes/class_db.php
- * @version 1.0.x, 23-08-2008, 17:48
- * @copyright 2008(c) PioDer <pioder@wp.pl>
- * @link http://pioder.gim2przemysl.int.pl/dsf.html
- * @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 optymalization 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: class_db.php, Line: '.__LINE__));
- $return_id = $return_id[$id];
- $return_id = $return_id+1;
- return $return_id;
- unset($table, $return_id, $id, $sql);
- }
- }
- ?>
|