Advertisement
Guest User

Untitled

a guest
Nov 15th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.52 KB | None | 0 0
  1. <?php
  2. /**
  3. *
  4. * @ This file is created by http://DeZender.Net
  5. * @ deZender (PHP7 Decoder for ionCube Encoder)
  6. *
  7. * @ Version : 4.0.9.0
  8. * @ Author : DeZender
  9. * @ Release on : 08.08.2019
  10. * @ Official site : http://DeZender.Net
  11. *
  12. */
  13.  
  14. class Registry
  15. {
  16. /**
  17. * Factory
  18. * @var object
  19. */
  20. public $factory;
  21. /**
  22. * Registry data
  23. * @var array
  24. */
  25. public $data = [];
  26. /**
  27. * Database
  28. * @var object
  29. */
  30. public $db;
  31. /**
  32. * Configuration values
  33. * @var array
  34. */
  35. public $config;
  36. /**
  37. * Language values
  38. * @var array
  39. */
  40. public $language;
  41. /**
  42. * Registry instance
  43. * @var Registry
  44. */
  45. static private $thisInstance;
  46.  
  47. /**
  48. * Load the factory
  49. * @param object $factory
  50. * @return Registry
  51. */
  52. public function __construct($factory)
  53. {
  54. spl_autoload_register([$this, 'load']);
  55. $this->factory = $factory;
  56. }
  57.  
  58. /**
  59. * Get the registry instance
  60. * @return Registry
  61. */
  62. static public function getInstance()
  63. {
  64. if (self::$thisInstance == NULL) {
  65. self::$thisInstance = new Registry(new Factory());
  66. }
  67.  
  68. return self::$thisInstance;
  69. }
  70.  
  71. /**
  72. * Load files
  73. * @param string $className
  74. */
  75. public function load($className)
  76. {
  77. if (file_exists(PMDROOT . '/includes/class_' . strtolower($className) . '.php')) {
  78. include PMDROOT . '/includes/class_' . strtolower($className) . '.php';
  79. }
  80. }
  81.  
  82. /**
  83. * Get a value from the registry
  84. * @param string $className
  85. * @param mixed $constructor_input
  86. * @param boolean $getnew
  87. */
  88. public function get($className, $constructor_input = NULL, $getnew = false)
  89. {
  90. $className = strtolower($className);
  91. $constructor = 'make' . $className;
  92. if (!array_key_exists($className, $this->data) || $getnew) {
  93. if (!method_exists($this->factory, $constructor)) {
  94. if (class_exists($className)) {
  95. if (is_null($constructor_input)) {
  96. $this->data[$className] = new $className($this);
  97. }
  98. else {
  99. $this->data[$className] = new $className($this, $constructor_input);
  100. }
  101. }
  102. else {
  103. return false;
  104. }
  105. }
  106. else if (!is_null($constructor_input)) {
  107. if ($getnew) {
  108. return $this->factory->$constructor($this, $constructor_input);
  109. }
  110. else {
  111. $this->data[$className] = $this->factory->$constructor($this, $constructor_input);
  112. }
  113. }
  114. else if ($getnew) {
  115. return $this->factory->$constructor($this);
  116. }
  117. else {
  118. $this->data[$className] = $this->factory->$constructor($this);
  119. }
  120. }
  121.  
  122. return $this->data[$className];
  123. }
  124.  
  125. /**
  126. * Returns a new copy of an object
  127. * @param mixed $className
  128. * @param mixed $constructor_input
  129. * @return mixed
  130. */
  131. public function getNew($className, $constructor_input = NULL)
  132. {
  133. return $this->get($className, $constructor_input, true);
  134. }
  135.  
  136. /**
  137. * Set a value in the registry or session
  138. * @param string $variable_name
  139. * @param mixed $data
  140. * @param boolean $in_session
  141. */
  142. public function set($variable_name, $data, $in_session = false)
  143. {
  144. if ($in_session) {
  145. $_SESSION[$variable_name] = $data;
  146. }
  147. else {
  148. $this->data[$variable_name] = $data;
  149. }
  150. }
  151.  
  152. /**
  153. * Add multiple data into one variable
  154. * @param string $variable_name
  155. * @param mixed $data
  156. */
  157. public function setAdd($variable_name, $data, $flush = false)
  158. {
  159. if (!isset($this->data[$variable_name]) || $flush) {
  160. $this->data[$variable_name] = [];
  161. }
  162.  
  163. if (!is_array($this->data[$variable_name])) {
  164. $this->data[$variable_name] = [$this->data[$variable_name]];
  165. }
  166.  
  167. $this->data[$variable_name] = array_merge($this->data[$variable_name], is_array($data) ? $data : [$data]);
  168. }
  169.  
  170. /**
  171. * Add data onto a multidimensional array
  172. */
  173. public function setAddArray()
  174. {
  175. $variable_name = func_get_arg(0);
  176.  
  177. if (func_num_args() == 2) {
  178. $data = func_get_arg(1);
  179. $this->data[$variable_name][] = (is_array($data) ? $data : [$data]);
  180. }
  181. else {
  182. $key = $data = func_get_arg(1);
  183. $data = func_get_arg(2);
  184. $this->data[$variable_name][$key] = (is_array($data) ? $data : [$data]);
  185. }
  186. }
  187.  
  188. /**
  189. * Load configuration values from the database
  190. * @param mixed $sections
  191. */
  192. public function loadConfig($sections = [])
  193. {
  194. $this->config = $this->get('DB')->GetAssoc('SELECT varname, value FROM ' . T_SETTINGS);
  195. .................................................................................
  196. ..................................................
  197. ....................
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement