Advertisement
Guest User

Untitled

a guest
Sep 30th, 2019
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.35 KB | None | 0 0
  1. <?php
  2. /**
  3. *
  4. * @ This file is created by http://DeZender.Net
  5. * @ deZender (PHP7 Decoder for SourceGuardian 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 FaoscThemesBodyClass
  15. {
  16. static private $instance;
  17. private $class;
  18.  
  19. private function __construct()
  20. {
  21. $this->class = [];
  22. }
  23.  
  24. static public function newInstance()
  25. {
  26. if (!(self::$instance instanceof self)) {
  27. self::$instance = new self();
  28. }
  29.  
  30. return self::$instance;
  31. }
  32.  
  33. public function add($class)
  34. {
  35. $this->class[] = $class;
  36. }
  37.  
  38. public function get()
  39. {
  40. return $this->class;
  41. }
  42. }
  43.  
  44. class faosclass_divarman_guard_theme
  45. {
  46. private $localHost = ['127.0.0.1', '::1'];
  47. private $license_file_name = 'oc-content/themes/' . FOLDER_THEME_DIVAR . '/admin/license.php';
  48. static private $instance;
  49.  
  50. static public function newInstance()
  51. {
  52. if (!(self::$instance instanceof self)) {
  53. self::$instance = new self();
  54. }
  55.  
  56. return self::$instance;
  57. }
  58.  
  59. public function __construct()
  60. {
  61. osc_add_hook('init_admin', [$this, 'install'], 2);
  62. osc_add_hook('login_admin', [$this, 'my_handle_login'], 0);
  63. $last_time = self::license_info();
  64.  
  65. if (86400 < (time() - (int) $last_time['date'])) {
  66. osc_add_hook('admin_footer', [$this, 'check_divarman_ajax_update_admin_footer']);
  67. osc_add_hook('ajax_admin_check_divarman_ajax_update', [$this, 'check_divarman_ajax_update']);
  68. }
  69. }
  70.  
  71. static public function get_host()
  72. {
  73. $possibleHostSources = ['HTTP_X_FORWARDED_HOST', 'HTTP_HOST', 'SERVER_NAME', 'SERVER_ADDR'];
  74. $sourceTransformations = ['HTTP_X_FORWARDED_HOST' => 'function($value) {' . "\n\t\t\t" . '$elements = explode(\',\', $value);' . "\n\t\t\t" . 'return trim(end($elements));' . "\n\t\t" . '}'];
  75. $host = '';
  76.  
  77. foreach ($possibleHostSources as $source) {
  78. if (!empty($host)) {
  79. break;
  80. }
  81.  
  82. if (empty($_SERVER[$source])) {
  83. continue;
  84. }
  85.  
  86. $host = $_SERVER[$source];
  87.  
  88. if (array_key_exists($source, $sourceTransformations)) {
  89. $host = $sourceTransformations[$source]($host);
  90. }
  91. }
  92.  
  93. $host = preg_replace('/:\\d+$/', '', $host);
  94. $host = str_ireplace('www.', '', $host);
  95. return trim($host);
  96. }
  97.  
  98. public function my_handle_login()
  99. {
  100. $this->revalidate_license();
  101. }
  102.  
  103. static public function revalidate_license($forced = false)
  104. {
  105. $license_info = self::license_info();
  106. $license = $license_info['code'];
  107. $count = $old_count = (int) $license_info['count'];
  108. $message = $license_info['message'];
  109. $action = $license_info['action'];
  110. $date = $license_info['date'];
  111. $count = $count + 1;
  112. $sr = (int) $count % 5;
  113. if (($sr == 0) || $forced) {
  114. $result = self::check_license($license_info['code']);
  115.  
  116. if ($result->status == 'successful') {
  117. $message = 'لایسنس معتبر می باشد.';
  118. $action = 1;
  119. $date = time();
  120. }
  121. else {
  122. $message = 'لایسنس نامعتبر می باشد.';
  123. $action = 0;
  124. $count = 0;
  125. $date = time();
  126. }
  127. }
  128.  
  129. if ($count != $old_count) {
  130. $private_session = osc_get_preference(self::option_name());
  131. osc_delete_preference($private_session);
  132. $rand_key = md5(osc_genRandomPassword(12));
  133. osc_set_preference(self::option_name(), $rand_key);
  134. $result = ['starter' => base64_encode($license), 'url' => base64_encode(self::get_host()), 'count' => $count, 'action' => $action, 'message' => $message, 'timer' => $date];
  135. osc_set_preference($rand_key, self::crypt(json_encode($result)));
  136. }
  137. }
  138.  
  139. public function check_divarman_ajax_update_admin_footer()
  140. {
  141. echo ' <script type="text/javascript">' . "\r\n" . ' $(document).ready(function() {' . "\r\n" . ' $.getJSON(' . "\r\n" . ' \'';
  142. echo osc_admin_base_url(true);
  143. echo '?page=ajax&action=runhook&hook=check_divarman_ajax_update\',' . "\r\n" . ' {},' . "\r\n" . ' function(data){}' . "\r\n" . ' );' . "\r\n" . ' });' . "\r\n" . ' </script>' . "\r\n" . ' ';
  144. }
  145.  
  146. public function check_divarman_ajax_update()
  147. {
  148. self::revalidate_license(true);
  149. }
  150.  
  151. static public function check_license($license_code)
  152. {
  153. $params = ['product' => self::productName(), 'domain' => self::get_host(), 'license_code' => $license_code];
  154. $result = self::send_request('verify', $params);
  155. return $result;
  156. }
  157.  
  158. static public function send_request($method, $params = [])
  159. {
  160. $param_string = http_build_query($params);
  161. $url = self::api_url();
  162. $ch = curl_init();
  163. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  164. curl_setopt($ch, CURLOPT_URL, $url . $method . '?' . $param_string);
  165. $content = curl_exec($ch);
  166. return json_decode($content);
  167. }
  168.  
  169. static public function is_activated()
  170. {
  171. $private_session = osc_get_preference(self::option_name());
  172. $now = json_decode(self::decrypt(osc_get_preference($private_session)));
  173.  
  174. if (empty($now)) {
  175. return false;
  176. }
  177. else if ($now->action != 1) {
  178. return false;
  179. }
  180. else {
  181. return true;
  182. }
  183. }
  184.  
  185. static public function license_info()
  186. {
  187. $private_session = osc_get_preference(self::option_name());
  188. $get_data = json_decode(self::decrypt(osc_get_preference($private_session)));
  189. $license_info = [];
  190. if (($get_data != NULL) && !empty($get_data)) {
  191. $license_info['code'] = base64_decode($get_data->starter);
  192. $license_info['action'] = $get_data->action;
  193. $license_info['count'] = $get_data->count;
  194. $license_info['message'] = $get_data->message;
  195. $license_info['date'] = $get_data->timer;
  196. }
  197.  
  198. return $license_info;
  199. }
  200.  
  201. public function install()
  202. {
  203. $page = Params::getParam('page');
  204. $license = Params::getParam('license');
  205. $action = Params::getParam('action');
  206. $theme_action = Params::getParam('theme_action');
  207. $file = Params::getParam('file');
  208. if (($page == 'appearance') && ($file == $this->license_file_name) && ($action == 'render') && ($theme_action == 'check_license')) {
  209. if (empty($license)) {
  210. ob_get_clean();
  211. osc_add_flash_error_message('لایسنس را بصورت صحیح وارد نمایید.', 'admin');
  212. osc_redirect_to(osc_admin_render_theme_url($this->license_file_name));
  213. exit();
  214. }
  215.  
  216. $private_session = osc_get_preference(self::option_name());
  217. osc_delete_preference($private_session);
  218. $result = self::check_license($license);
  219. $rand_key = md5(osc_genRandomPassword(12));
  220. osc_set_preference(self::option_name(), $rand_key);
  221.  
  222. if ($result->status == 'successful') {
  223. $result = ['starter' => base64_encode($license), 'url' => base64_encode(self::get_host()), 'action' => 1, 'count' => 1, 'message' => implode('<br>', $result->message), 'timer' => time()];
  224. osc_set_preference($rand_key, self::crypt(json_encode($result)));
  225. ob_get_clean();
  226. osc_add_flash_ok_message('لایسنس با موفقیت ثبت شد.', 'admin');
  227. osc_redirect_to(osc_admin_render_theme_url($this->license_file_name));
  228. exit();
  229. }
  230. else {
  231. $result = ['starter' => base64_encode($license), 'url' => base64_encode(self::get_host()), 'action' => 0, 'count' => 0, 'message' => implode('<br>', $result->message), 'timer' => time()];
  232. osc_set_preference($rand_key, self::crypt(json_encode($result)));
  233. ob_get_clean();
  234. osc_add_flash_error_message('لایسنس وارد شده نامعتبر می باشد لطفا یک لایسنس معتبر وارد نمایید.', 'admin');
  235. osc_redirect_to(osc_admin_render_theme_url($this->license_file_name));
  236. exit();
  237. }
  238. }
  239. }
  240.  
  241. static public function crypt($string)
  242. {
  243. if (class_exists('Cryptor') && Cryptor::Usable()) {
  244. $key = hash('sha256', self::crypt_key(), true);
  245. return Cryptor::Encrypt($string, $key);
  246. }
  247.  
  248. $cypher = MCRYPT_RIJNDAEL_256;
  249. $mode = MCRYPT_MODE_ECB;
  250. return base64_encode(mcrypt_encrypt($cypher, self::crypt_key(), $string, $mode, mcrypt_create_iv(mcrypt_get_iv_size($cypher, $mode), MCRYPT_RAND)));
  251. }
  252.  
  253. static public function decrypt($string)
  254. {
  255. if ($string == '') {
  256. return '';
  257. }
  258. if (class_exists('Cryptor') && Cryptor::Usable()) {
  259. $key = hash('sha256', self::crypt_key(), true);
  260. return Cryptor::Decrypt($string, $key);
  261. }
  262.  
  263. $cypher = MCRYPT_RIJNDAEL_256;
  264. $mode = MCRYPT_MODE_ECB;
  265. return str_replace("\0", '', mcrypt_decrypt($cypher, self::crypt_key(), base64_decode($string), $mode, mcrypt_create_iv(mcrypt_get_iv_size($cypher, $mode), MCRYPT_RAND)));
  266. }
  267.  
  268. static public function crypt_key()
  269. {
  270. return 'tr554fgft15edfgc';
  271. }
  272.  
  273. static public function option_name()
  274. {
  275. return 'dajeqiys81rqw78eiuk7rshkgihhq0s901u';
  276. }
  277.  
  278. static public function api_url()
  279. {
  280. return 'http://guard.faosclass.com/api/v1/';
  281. }
  282.  
  283. static public function productName()
  284. {
  285. return 'faosclass_divar_man_theme';
  286. }
  287. }
  288.  
  289. function faosc_themes_script()
  290. {
  291. if (!OC_ADMIN) {
  292. osc_enqueue_style('faosc-jquery-ui', osc_current_web_theme_url('js/jquery-ui/jquery-ui-1.10.2.custom.min.css'));
  293. osc_enqueue_style('faosc-themes-bootstrap-min', osc_current_web_theme_url('css/bootstrap.min.css'));
  294. osc_enqueue_style('faosc-themes-bootstrap-rtl', osc_current_web_theme_url('css/bootstrap-rtl.min.css'));
  295. osc_enqueue_style('faosc-themes-style', osc_current_web_theme_url('css/style.css'));
  296. ...............................................................................
  297. .....................................
  298. ...........
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement