Advertisement
Snoop-Dogg

original db script

Dec 8th, 2020
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.18 KB | None | 0 0
  1. <?php
  2. /****************************************************************/
  3. /* phpStatus */
  4. /* db.php file */
  5. /* (c)copyright 2003 */
  6. /* By hinton design */
  7. /* http://www.hintondesign.org */
  8. /* support@hintondesign.org */
  9. /* */
  10. /* This program is free software. You can redistrabute it and/or*/
  11. /* modify it under the terms of the GNU General Public Licence */
  12. /* as published by the Free Software Foundation; either version */
  13. /* 2 of the license. */
  14. /* */
  15. /****************************************************************/
  16.  
  17. if(preg_match("/db.php/i", $_SERVER['PHP_SELF'])) {
  18. header("Location: ../index.php");
  19. exit();
  20. }
  21.  
  22. class db {
  23.  
  24. var $dbhost, $dbuser, $dbpass, $dbname, $query, $sql, $conn, $num, $fetch;
  25.  
  26.  
  27. function db($dbhost, $dbuser, $dbpass, $dbname) {
  28. $this->connect($dbhost, $dbuser, $dbpass, $dbname);
  29. }
  30.  
  31. function connect($dbhost, $dbuser, $dbpass, $dbname = '', $persistant = 0) {
  32. $this->dbhost = $dbhost;
  33. $this->dbuser = $dbuser;
  34. $this->dbpass = $dbpass;
  35. if($persistant) {
  36. $this->conn = @mysql_pconnect($this->dbhost, $this->dbuser, $this->dbpass);
  37. } else {
  38. $this->conn = @mysql_connect($this->dbhost, $this->dbuser, $this->dbpass);
  39. }
  40. if(!$this->conn) {
  41. $msg = @mysql_errno() . "\t" . @mysql_error();
  42. return false;
  43. } else {
  44. $this->setdb($dbname);
  45. }
  46. }
  47. function setdb($dbname) {
  48. $this->dbname = $dbname;
  49. if(@mysql_select_db($this->dbname,$this->conn)) {
  50. return true;
  51. } else {
  52. $msg = @mysql_errno() . "\t" . @mysql_error() . "\t" . $this->db;
  53. }
  54. }
  55. function query($sql) {
  56. $this->sql = $sql;
  57. $this->query = @mysql_query($this->sql, $this->conn);
  58. if(!$this->query) {
  59. $msg = @mysql_errno() . "\t" . @mysql_error . "\t" . $this->sql;
  60. return false;
  61. } else {
  62. return true;
  63. }
  64. }
  65. function fetch() {
  66. if($this->query) {
  67. $this->fetch = @mysql_fetch_array($this->query);
  68. return $this->fetch;
  69. } else {
  70. return 0;
  71. }
  72. }
  73. function result() {
  74. if($this->query) {
  75. $this->result = mysql_result($this->query, 0);
  76. return $this->result;
  77. } else {
  78. return 0;
  79. }
  80. }
  81. function num() {
  82. if($this->query) {
  83. $this->num = @mysql_num_rows($this->query);
  84. return $this->num;
  85. } else {
  86. return 0;
  87. }
  88. }
  89. function close() {
  90. if(@mysql_close($this->conn)) {
  91. return true;
  92. } else {
  93. $msg = @mysql_errno() . "\t" . @mysql_error() . "\t" . $this->sql;
  94. return false;
  95. }
  96. }
  97. }
  98. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement