Guest User

Untitled

a guest
Jul 19th, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 KB | None | 0 0
  1. <?php
  2.  
  3. /*
  4. * __ .__ __
  5. * _____________ |__|_ _ _|__| _____/ |_ ___________
  6. * \____ \_ __ \| \ \/ \/ / |/ \ __\/ __ \_ __ \
  7. * | |_> > | \/| |\ /| | | \ | \ ___/| | \/
  8. * | __/|__/\__| | \/\_/ |__|___| /__| \___ >__|
  9. * |__| \______| \/ \/
  10. *
  11. * Flexible and easy-to-use PHP framework
  12. */
  13.  
  14. class Engine extends Functions {
  15.  
  16. /*
  17. * Variables
  18. */
  19.  
  20. private $host, $user, $pass, $dbname, $port, $enabled, $link;
  21.  
  22. /*
  23. * Initalise
  24. */
  25.  
  26. final public function initalise($host, $user, $pass, $dbname, $port) {
  27. if(!$this->enabled) {
  28. $this->host = $host;
  29. $this->user = $user;
  30. $this->pass = $pass;
  31. $this->dbname = $dbname;
  32. $this->port = $port;
  33. $this->link = mysql_pconnect($this->host, $this->user, $this->pass);
  34. if(mysql_select_db($this->dbname, $this->link)) {
  35. $this->enabled = true;
  36. } else {
  37. parent::throwError("Engine Error", "Failed to connect to server host.");
  38. }
  39. }
  40. }
  41.  
  42. /*
  43. * Filter
  44. */
  45.  
  46. final public function filter($string) {
  47. return mysql_real_escape_string($string);
  48. }
  49.  
  50. /*
  51. * Handlers
  52. */
  53.  
  54. final public function close() {
  55. if($this->enabled) {
  56. mysql_close();
  57. $this->enabled = false;
  58. } else {
  59. parent::throwError("Engine Error", "There is no established connection to close.");
  60. }
  61. }
  62.  
  63. final public function send($string) {
  64. if($this->enabled) {
  65. $this->filter($string);
  66. mysql_query($string);
  67. } else {
  68. parent::throwError("Engine Error", "Failed to send to the specified database. Info: " . mysql_error());
  69. }
  70. }
  71. }
  72.  
  73. ?>
Add Comment
Please, Sign In to add comment