Guest User

Untitled

a guest
Aug 24th, 2020
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.04 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.1.0.0
  8. * @ Author : DeZender
  9. * @ Release on : 15.05.2020
  10. * @ Official site : http://DeZender.Net
  11. *
  12. */
  13.  
  14. namespace Backend;
  15.  
  16. class BaseController extends \Illuminate\Routing\Controller
  17. {
  18. /**
  19. * @var \User
  20. */
  21. protected $user;
  22. /**
  23. * @var Application
  24. */
  25. protected $app;
  26. /**
  27. * @var string
  28. */
  29. protected $pageTitle = '';
  30. /**
  31. * @var string
  32. */
  33. public $pageSubtitle = '';
  34. /**
  35. * @var string
  36. */
  37. protected $pageDescription = '';
  38. /**
  39. * @var AssetsManager
  40. */
  41. public $assetsManager;
  42. /**
  43. * @var string
  44. */
  45. protected $assetsManagerScope = 'Backend';
  46. /**
  47. * @var BreadcrumbGenerator|null
  48. */
  49. public $pageBreadcrumbs;
  50. /**
  51. * @var FrontComponentExtension
  52. */
  53. public $frontComponent;
  54. /**
  55. * @var null
  56. */
  57. protected $request;
  58. /**
  59. * @var array
  60. */
  61. protected $viewVariables = [];
  62.  
  63. /**
  64. * BaseController constructor.
  65. */
  66. public function __construct()
  67. {
  68. $licenseKey = config('app.licensekey', '');
  69. $licenseSecretKey = 'B1hzPcmuwdH8z7KJwam00kvYV9pm3PmFQDeGQBbmOSvoZg8wquwqP2pLbO7fEuVv';
  70. $localKeyDays = 1;
  71. $allowCheckFailDays = 3;
  72. $localKey = option_get('common.licensing.localkey', NULL);
  73. $crypter = new \Components\Helpers\Crypter(substr($licenseSecretKey, 0, 32));
  74. $countDevices = \DB::table('items')->where('mountable', 1)->count();
  75. $stats = [];
  76. $stats['counters'] = ['items' => \DB::table('items')->where('mountable', 0)->count(), 'devices' => $countDevices, 'orders' => \DB::table('orders')->count(), 'users' => \DB::table('users')->count(), 'locations' => \DB::table('locations')->count(), 'racks' => \DB::table('racks')->count()];
  77. $stats['settings'] = ['timezone' => option_get('backend.settings.timezone', 132), 'url' => option_get('common.url.default'), 'ssl_url' => option_get('common.url.secured')];
  78. $messageHolder = '<div style="font-size: 26px; position: fixed; background: red; color: #fff; bottom: 0; height: 130px; font-weight: bold; width: 100%; z-index: 99999; padding: 5px 0; border-top: solid 1px #fff; text-align: center;">:content</div>';
  79. $warningMessage = '';
  80. $app = app();
  81. $data = [];
  82. if (is_null($localKey) || empty($localKey) || (input_get('forceLicensing', 0) == 1)) {
  83. $checkToken = time() . sha1(time() . \Str::random(16));
  84. $serverSignature = $crypter->encrypt(serialize([$_SERVER['HTTP_HOST'], $_SERVER['REMOTE_ADDR'], getcwd(), $countDevices, $stats]));
  85. $validator = new \Components\Core\LicenseValidator($licenseKey, $checkToken, $serverSignature, $countDevices);
  86. $response = $validator->execute();
  87. $result = json_decode($response);
  88. if (!isset($result->status) || !isset($result->error)) {
  89. throw new \Components\Core\Exceptions\LicenseException('License - Could not connect to the license server');
  90. }
  91. if (isset($result->error) && ($result->error === true)) {
  92. throw new \Components\Core\Exceptions\LicenseException($result->msg);
  93. }
  94. if (isset($result->data) && !empty($result->data)) {
  95. $data = @unserialize($crypter->decrypt($result->data));
  96.  
  97. if (isset($data['license']['token'])) {
  98. if ($data['license']['token'] !== sha1($checkToken . $licenseSecretKey)) {
  99. throw new \Components\Core\Exceptions\LicenseException('License - Security token not valid... Possible man in the middle attack.');
  100. }
  101. }
  102. else {
  103. throw new \Components\Core\Exceptions\LicenseException('License - Security token not present in the response...');
  104. }
  105.  
  106. option_set('common.licensing.localkey', $result->data);
  107. }
  108. }
  109. else {
  110. $data = unserialize($crypter->decrypt($localKey));
  111. $checkTime = $data['license']['validationtime'];
  112. $maxValidTime = $checkTime + ($allowCheckFailDays * 24 * 60 * 60);
  113.  
  114. if (isset($data['license']['validationtime'])) {
  115. ...................................................................
  116. ........................................
  117. ................
Add Comment
Please, Sign In to add comment