Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Core extends mysqli implements Configurations {
- public $MySQL, $Output, $Variables, $License;
- interface Configurations {
- const Name = "Aldmor";
- const Description = "MMORPG";
- const RootPath = "/";
- const NewUserFile = "Newuser/NewUserTest.swf";
- const LoaderFile = "LoaderR1.swf";
- const MySQLHost = "127.0.0.1";
- const MySQLUser = "root";
- const MySQLPort = 3306;
- const MySQLPass = "Jufedruvat3tr5sp";
- const MySQLData = "Cake";
- }
- public function Core() {
- $this->MySQL = new stdClass();
- $this->MySQL->Connection = null;
- $this->MySQL->TotalQuery = 0;
- $this->MySQL->Configurations = null;
- }
- public function assign($VariableName, $Value = null) {
- if(is_array($VariableName) || is_object($VariableName) && is_null($Value)):
- $this->Variables += $VariableName;
- while(list($key, $value) = each($this->Variables)):
- $this->Variables["{{$key}}"] = $value;
- endwhile;
- elseif(is_string($VariableName) && strlen($VariableName) > 0 && !is_null($Value)):
- $this->Variables["{{$VariableName}}"] = $Value;
- endif;
- }
- public function getAssigned($Name) {
- return (array_key_exists("{{$Name}}", $this->Variables) ? $this->Variables["{{$Name}}"] : $ $this->Variables[$Name]);
- }
- public function protect($sql) {
- $sql = preg_replace(sql_regcase("/(from|union|select|order by|or|insert|delete|where|drop table|show tables|#|'|`|\"|\*|--|\\\\)/"), "", $sql);
- $sql = trim($sql);
- $sql = strip_tags($sql);
- $sql = addslashes($sql);
- return $sql;
- }
- public function Template($temp) {
- $template = "templates/{$temp}.html";
- if (!file_exists($template))
- $this->SystemExit('Template not found: ' . $template, __LINE__, __FILE__);
- $data[0][0] = fopen($template, "r");
- $data[0][1] = fread($data[0][0], filesize($template));
- fclose($data[0][0]);
- $data[0][1] = empty($this->Variables) ? $data[0][1] : str_replace(array_keys($this->Variables), array_values($this->Variables), $data[0][1]);
- return $data[0][1];
- }
- public function Content() {
- $this->Output = empty($this->Variables) ? $this->Output : str_replace(array_keys($this->Variables), array_values($this->Variables), $this->Output);
- print $this->Output;
- exit(0);
- }
- public function connectDB() {
- parent::__construct(Configurations::MySQLHost, Configurations::MySQLUser, Configurations::MySQLPass, Configurations::MySQLData);
- if (mysqli_connect_error())
- $this->SystemExit(mysqli_connect_errno() . mysqli_connect_error(), __LINE__, __FILE__);
- else
- $this->MySQL->Connection = true;
- }
- public function DBase($type, $params = array()) {
- if (!$this->MySQL->Connection)
- $this->SystemExit('No available MySQLi connection', __LINE__, __FILE__);
- switch (strtoupper($type)) {
- case 'QUERY':
- if ($Query = parent::query($params[0])) {
- $this->MySQL->TotalQuery++;
- return $Query;
- } else
- $this->SystemExit('MySQLi failed to query: ' . $params[0], __LINE__, __FILE__);
- break;
- case 'PREPARE':
- if ($Query = parent::prepare($params[0])) {
- $this->MySQL->TotalQuery++;
- return $Query;
- } else
- $this->SystemExit('MySQLi failed to prepare: ' . $params[0], __LINE__, __FILE__);
- break;
- case 'ESCAPESTRING':
- if ($Escape = parent::real_escape_string($params[0]))
- return $Escape;
- else
- $this->SystemExit('MySQLi failed to escape: ' . $params[0], __LINE__, __FILE__);
- break;
- }
- }
- public function SystemExit($text, $line, $file = null) {
- if (ob_get_level()) ob_end_clean();
- header('Content-Type: text/plain');
- print ("$text - " . date("F j, Y, g:i a"));
- print ("\nLocation: $file ($line)");
- print ("Calm your fucking tits. The template doesn't exist.");
- exit(1);
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement