Advertisement
Guest User

Untitled

a guest
May 14th, 2016
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.22 KB | None | 0 0
  1. <?php
  2. class Core extends mysqli implements Configurations {
  3. public $MySQL, $Output, $Variables, $License;
  4.  
  5. interface Configurations {
  6. const Name = "Aldmor";
  7. const Description = "MMORPG";
  8. const RootPath = "/";
  9.  
  10. const NewUserFile = "Newuser/NewUserTest.swf";
  11. const LoaderFile = "LoaderR1.swf";
  12.  
  13. const MySQLHost = "127.0.0.1";
  14. const MySQLUser = "root";
  15. const MySQLPort = 3306;
  16. const MySQLPass = "Jufedruvat3tr5sp";
  17. const MySQLData = "Cake";
  18. }
  19.  
  20. public function Core() {
  21. $this->MySQL = new stdClass();
  22. $this->MySQL->Connection = null;
  23. $this->MySQL->TotalQuery = 0;
  24. $this->MySQL->Configurations = null;
  25. }
  26.  
  27. public function assign($VariableName, $Value = null) {
  28. if(is_array($VariableName) || is_object($VariableName) && is_null($Value)):
  29. $this->Variables += $VariableName;
  30. while(list($key, $value) = each($this->Variables)):
  31. $this->Variables["{{$key}}"] = $value;
  32. endwhile;
  33. elseif(is_string($VariableName) && strlen($VariableName) > 0 && !is_null($Value)):
  34. $this->Variables["{{$VariableName}}"] = $Value;
  35. endif;
  36. }
  37.  
  38. public function getAssigned($Name) {
  39. return (array_key_exists("{{$Name}}", $this->Variables) ? $this->Variables["{{$Name}}"] : $ $this->Variables[$Name]);
  40. }
  41.  
  42. public function protect($sql) {
  43. $sql = preg_replace(sql_regcase("/(from|union|select|order by|or|insert|delete|where|drop table|show tables|#|'|`|\"|\*|--|\\\\)/"), "", $sql);
  44. $sql = trim($sql);
  45. $sql = strip_tags($sql);
  46. $sql = addslashes($sql);
  47. return $sql;
  48. }
  49.  
  50. public function Template($temp) {
  51. $template = "templates/{$temp}.html";
  52.  
  53. if (!file_exists($template))
  54. $this->SystemExit('Template not found: ' . $template, __LINE__, __FILE__);
  55.  
  56. $data[0][0] = fopen($template, "r");
  57. $data[0][1] = fread($data[0][0], filesize($template));
  58. fclose($data[0][0]);
  59.  
  60. $data[0][1] = empty($this->Variables) ? $data[0][1] : str_replace(array_keys($this->Variables), array_values($this->Variables), $data[0][1]);
  61. return $data[0][1];
  62. }
  63.  
  64. public function Content() {
  65. $this->Output = empty($this->Variables) ? $this->Output : str_replace(array_keys($this->Variables), array_values($this->Variables), $this->Output);
  66. print $this->Output;
  67. exit(0);
  68. }
  69.  
  70. public function connectDB() {
  71. parent::__construct(Configurations::MySQLHost, Configurations::MySQLUser, Configurations::MySQLPass, Configurations::MySQLData);
  72. if (mysqli_connect_error())
  73. $this->SystemExit(mysqli_connect_errno() . mysqli_connect_error(), __LINE__, __FILE__);
  74. else
  75. $this->MySQL->Connection = true;
  76. }
  77.  
  78. public function DBase($type, $params = array()) {
  79. if (!$this->MySQL->Connection)
  80. $this->SystemExit('No available MySQLi connection', __LINE__, __FILE__);
  81.  
  82. switch (strtoupper($type)) {
  83. case 'QUERY':
  84. if ($Query = parent::query($params[0])) {
  85. $this->MySQL->TotalQuery++;
  86. return $Query;
  87. } else
  88. $this->SystemExit('MySQLi failed to query: ' . $params[0], __LINE__, __FILE__);
  89. break;
  90. case 'PREPARE':
  91. if ($Query = parent::prepare($params[0])) {
  92. $this->MySQL->TotalQuery++;
  93. return $Query;
  94. } else
  95. $this->SystemExit('MySQLi failed to prepare: ' . $params[0], __LINE__, __FILE__);
  96. break;
  97. case 'ESCAPESTRING':
  98. if ($Escape = parent::real_escape_string($params[0]))
  99. return $Escape;
  100. else
  101. $this->SystemExit('MySQLi failed to escape: ' . $params[0], __LINE__, __FILE__);
  102. break;
  103. }
  104. }
  105.  
  106. public function SystemExit($text, $line, $file = null) {
  107. if (ob_get_level()) ob_end_clean();
  108. header('Content-Type: text/plain');
  109. print ("$text - " . date("F j, Y, g:i a"));
  110. print ("\nLocation: $file ($line)");
  111. print ("Calm your fucking tits. The template doesn't exist.");
  112. exit(1);
  113. }
  114. }
  115. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement