Advertisement
Guest User

Untitled

a guest
Feb 9th, 2024
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. <?php
  2. /**
  3. *
  4. * @ This file is created by http://DeZender.Net
  5. * @ deZender (PHP7 Decoder for ionCube Encoder)
  6. *
  7. * @ Version : 5.0.1.0
  8. * @ Author : DeZender
  9. * @ Release on : 22.04.2022
  10. * @ Official site : http://DeZender.Net
  11. *
  12. */
  13.  
  14. class Database
  15. {
  16. public $result = null;
  17. public $last_query = null;
  18. public $dbh = null;
  19. public $connected = false;
  20.  
  21. public function __construct($migrate = false)
  22. {
  23. $this->dbh = false;
  24. $this->db_connect($migrate);
  25. }
  26.  
  27. public function close_mysql()
  28. {
  29. if ($this->connected) {
  30. $this->connected = false;
  31. $this->dbh = NULL;
  32. }
  33.  
  34. return true;
  35. }
  36.  
  37. public function __destruct()
  38. {
  39. $this->close_mysql();
  40. }
  41.  
  42. public function ping()
  43. {
  44. try {
  45. $this->dbh->query('SELECT 1');
  46. }
  47. catch (Exception $e) {
  48. return false;
  49. }
  50.  
  51. return true;
  52. }
  53.  
  54. public function db_connect($migrate = false)
  55. {
  56. try {
  57. $this->dbh = Xcms\Functions::connect($migrate);
  58.  
  59. if (!$this->dbh) {
  60. if ($migrate) {
  61. return false;
  62. }
  63.  
  64. exit(json_encode(['error' => 'MySQL: Cannot connect to database! Please check credentials.']));
  65. }
  66. }
  67. catch (PDOException $e) {
  68. exit(json_encode(['error' => 'MySQL: ' . $e->getMessage()]));
  69. }
  70.  
  71. $this->dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  72. $this->connected = true;
  73. return true;
  74. }
  75.  
  76. public function db_explicit_connect($rHost, $rPort, $rDatabase, $rUsername, $rPassword)
  77. {
  78. try {
  79. $this->dbh = new PDO('mysql:host=' . $rHost . ';port=' . $rPort . ';dbname=' . $rDatabase, $rUsername, $rPassword);
  80.  
  81. if (!$this->dbh) {
  82. return false;
  83. .............................................................................
  84. ..............................................
  85. ....................
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement