Advertisement
Guest User

Untitled

a guest
Jan 25th, 2013
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.37 KB | None | 0 0
  1. <?php
  2. /**
  3. *
  4. * @ This file is created by deZender.Net
  5. * @ deZender (PHP5 Decoder for ionCube Encoder)
  6. *
  7. * @ Version : 1.1.5.0
  8. * @ Author : DeZender
  9. * @ Release on : 09.06.2012
  10. * @ Official site : http://DeZender.Net
  11. *
  12. */
  13.  
  14.  
  15. class DbClass {
  16. var $type = null;
  17. var $link = null;
  18. var $res = null;
  19.  
  20. function DbClass($type) {
  21. $this->type = $type;
  22. }
  23.  
  24. function connect($host, $user, $pass, $dbname) {
  25. switch ($this->type) {
  26. case 'mysql': {
  27. if ($this->link = @mysql_connect( $host, $user, $pass, true )) {
  28. return true;
  29. }
  30.  
  31. break;
  32. }
  33.  
  34. case 'pgsql': {
  35. $host = explode( ':', $host );
  36.  
  37. if (!$host[1]) {
  38. $host[1] = 5432;
  39. }
  40.  
  41.  
  42. if ($this->link = @pg_connect( '' . 'host=' . $host[0] . ' port=' . $host[1] . ' user=' . $user . ' password=' . $pass . ' dbname=' . $dbname )) {
  43. return true;
  44. }
  45. }
  46. }
  47.  
  48. return false;
  49. }
  50.  
  51. function selectdb($db) {
  52. switch ($this->type) {
  53. case 'mysql': {
  54. if (@mysql_select_db( $db )) {
  55. return true;
  56. }
  57. }
  58. }
  59.  
  60. return false;
  61. }
  62.  
  63. function query($str) {
  64. switch ($this->type) {
  65. case 'mysql': {
  66. return $this->res = @mysql_query( $str );
  67. }
  68.  
  69. case 'pgsql': {
  70. return $this->res = @pg_query( $this->link, $str );
  71. }
  72. }
  73.  
  74. return false;
  75. }
  76.  
  77. function fetch() {
  78. $res = (func_num_args( ) ? func_get_arg( 0 ) : $this->res);
  79. switch ($this->type) {
  80. case 'mysql': {
  81. return @mysql_fetch_assoc( $res );
  82. }
  83.  
  84. case 'pgsql': {
  85. return @pg_fetch_assoc( $res );
  86. }
  87. }
  88.  
  89. return false;
  90. }
  91.  
  92. function listDbs() {
  93. switch ($this->type) {
  94. case 'mysql': {
  95. return $this->query( 'SHOW databases' );
  96. }
  97.  
  98. case 'pgsql': {
  99. return $this->res = $this->query( 'SELECT datname FROM pg_database WHERE datistemplate!=\'t\'' );
  100. }
  101. }
  102.  
  103. return false;
  104. }
  105.  
  106. function listTables() {
  107. switch ($this->type) {
  108. case 'mysql': {
  109. return $this->res = $this->query( 'SHOW TABLES' );
  110. }
  111.  
  112. case 'pgsql': {
  113. return $this->res = $this->query( 'select table_name from information_schema.tables where table_schema != \'information_schema\' AND table_schema != \'pg_catalog\'' );
  114. }
  115. }
  116.  
  117. return false;
  118. }
  119. .....................................................
  120. ...........................
  121. ............
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement