Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- *
- * @ This file is created by http://DeZender.Net
- * @ deZender (PHP7 Decoder for ionCube Encoder)
- *
- * @ Version : 4.0.9.0
- * @ Author : DeZender
- * @ Release on : 08.08.2019
- * @ Official site : http://DeZender.Net
- *
- */
- class Registry
- {
- /**
- * Factory
- * @var object
- */
- public $factory;
- /**
- * Registry data
- * @var array
- */
- public $data = [];
- /**
- * Database
- * @var object
- */
- public $db;
- /**
- * Configuration values
- * @var array
- */
- public $config;
- /**
- * Language values
- * @var array
- */
- public $language;
- /**
- * Registry instance
- * @var Registry
- */
- static private $thisInstance;
- /**
- * Load the factory
- * @param object $factory
- * @return Registry
- */
- public function __construct($factory)
- {
- spl_autoload_register([$this, 'load']);
- $this->factory = $factory;
- }
- /**
- * Get the registry instance
- * @return Registry
- */
- static public function getInstance()
- {
- if (self::$thisInstance == NULL) {
- self::$thisInstance = new Registry(new Factory());
- }
- return self::$thisInstance;
- }
- /**
- * Load files
- * @param string $className
- */
- public function load($className)
- {
- if (file_exists(PMDROOT . '/includes/class_' . strtolower($className) . '.php')) {
- include PMDROOT . '/includes/class_' . strtolower($className) . '.php';
- }
- }
- /**
- * Get a value from the registry
- * @param string $className
- * @param mixed $constructor_input
- * @param boolean $getnew
- */
- public function get($className, $constructor_input = NULL, $getnew = false)
- {
- $className = strtolower($className);
- $constructor = 'make' . $className;
- if (!array_key_exists($className, $this->data) || $getnew) {
- if (!method_exists($this->factory, $constructor)) {
- if (class_exists($className)) {
- if (is_null($constructor_input)) {
- $this->data[$className] = new $className($this);
- }
- else {
- $this->data[$className] = new $className($this, $constructor_input);
- }
- }
- else {
- return false;
- }
- }
- else if (!is_null($constructor_input)) {
- if ($getnew) {
- return $this->factory->$constructor($this, $constructor_input);
- }
- else {
- $this->data[$className] = $this->factory->$constructor($this, $constructor_input);
- }
- }
- else if ($getnew) {
- return $this->factory->$constructor($this);
- }
- else {
- $this->data[$className] = $this->factory->$constructor($this);
- }
- }
- return $this->data[$className];
- }
- /**
- * Returns a new copy of an object
- * @param mixed $className
- * @param mixed $constructor_input
- * @return mixed
- */
- public function getNew($className, $constructor_input = NULL)
- {
- return $this->get($className, $constructor_input, true);
- }
- /**
- * Set a value in the registry or session
- * @param string $variable_name
- * @param mixed $data
- * @param boolean $in_session
- */
- public function set($variable_name, $data, $in_session = false)
- {
- if ($in_session) {
- $_SESSION[$variable_name] = $data;
- }
- else {
- $this->data[$variable_name] = $data;
- }
- }
- /**
- * Add multiple data into one variable
- * @param string $variable_name
- * @param mixed $data
- */
- public function setAdd($variable_name, $data, $flush = false)
- {
- if (!isset($this->data[$variable_name]) || $flush) {
- $this->data[$variable_name] = [];
- }
- if (!is_array($this->data[$variable_name])) {
- $this->data[$variable_name] = [$this->data[$variable_name]];
- }
- $this->data[$variable_name] = array_merge($this->data[$variable_name], is_array($data) ? $data : [$data]);
- }
- /**
- * Add data onto a multidimensional array
- */
- public function setAddArray()
- {
- $variable_name = func_get_arg(0);
- if (func_num_args() == 2) {
- $data = func_get_arg(1);
- $this->data[$variable_name][] = (is_array($data) ? $data : [$data]);
- }
- else {
- $key = $data = func_get_arg(1);
- $data = func_get_arg(2);
- $this->data[$variable_name][$key] = (is_array($data) ? $data : [$data]);
- }
- }
- /**
- * Load configuration values from the database
- * @param mixed $sections
- */
- public function loadConfig($sections = [])
- {
- $this->config = $this->get('DB')->GetAssoc('SELECT varname, value FROM ' . T_SETTINGS);
- .................................................................................
- ..................................................
- ....................
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement