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.2 KiB

  1. <?php
  2. /**
  3. * @package uForum
  4. * @file includes/class_db.php
  5. * @version $Id$
  6. * @copyright 2009(c) PioDer <pioder@wp.pl>
  7. * @link http://pioder.gim2przemysl.int.pl/
  8. * @license GNU GPL v3
  9. **/
  10. if ( !defined('IN_uF') )
  11. {
  12. die('Hacking attempt');
  13. }
  14. class DataBase
  15. {
  16. function db_connect()
  17. {
  18. $connect = mysql_pconnect(DB_HOST, DB_USER, DB_PASS) or message_die('CRITICAL',' Could not connect to database server.',mysql_error());
  19. mysql_query("SET NAMES 'utf8'",$connect);
  20. mysql_select_db(DB_NAME, $connect) or message_die('CRITICAL',' Could not connect to database.',mysql_error());
  21. }
  22. function sql_query($sql, $type, $msg, $no_count = false)
  23. {
  24. if (isset($_COOKIE['queries']))
  25. {
  26. $no_count = false;
  27. if(!$no_count)
  28. {
  29. $_COOKIE['queries'] = $_COOKIE['queries']+1;
  30. }
  31. }
  32. //echo '<span class="fsmall">'.$sql.'<br></span>'; //for optymalization ONLY!!!!!!!!!!!!!!
  33. $query = mysql_query($sql) or message_die($type, $msg, mysql_error());
  34. return $query;
  35. }
  36. function new_id($table)
  37. {
  38. //check table id
  39. switch($table)
  40. {
  41. case BANLIST_TABLE: { $id = 'b_id'; break; }
  42. case CATS_TABLE: { $id = 'c_id'; break; }
  43. case CENSORLIST_TABLE: { $id = 'w_id'; break; }
  44. case FORUMS_TABLE: { $id = 'f_id'; break; }
  45. case GROUPS_TABLE: { $id = 'g_id'; break; }
  46. case PM_INBOX_TABLE: { $id = 'm_id'; break; }
  47. case PM_SENTBOX_TABLE: { $id = 'm_id'; break; }
  48. case POSTS_TABLE: { $id = 'p_id'; break; }
  49. case TOPICS_TABLE: { $id = 't_id'; break; }
  50. case SESSIONS_TABLE: { $id = 's_id'; break; }
  51. case SKINS_TABLE: { $id = 's_id'; break; }
  52. case SMILES_TABLE: { $id = 's_id'; break; }
  53. case USERS_TABLE: { $id = 'u_id'; break; }
  54. case USERS_GROUP_TABLE: { $id = 'id'; break; }
  55. case WARNINGS_TABLE: { $id = 'w_id'; break; }
  56. }
  57. $sql = "SELECT `$id` FROM $table ORDER BY `$id` DESC LIMIT 1";
  58. $return_id = mysql_fetch_array(DataBase::sql_query($sql,'GENERAL','Error with obtain last id.<br> File: class_db.php, Line: '.__LINE__));
  59. $return_id = $return_id[$id];
  60. $return_id = $return_id+1;
  61. return $return_id;
  62. unset($table, $return_id, $id, $sql);
  63. }
  64. }
  65. ?>