Snoop-Dogg

original db script

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