Advertisement
Guest User

Untitled

a guest
Jul 14th, 2021
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 7.68 KB | None | 0 0
  1. <?php
  2. /*
  3.  * @ https://EasyToYou.eu - IonCube v10 Decoder Online
  4.  * @ PHP 5.5
  5.  * @ Decoder version: 1.0.4
  6.  * @ Release: 02/06/2020
  7.  *
  8.  * @ ZendGuard Decoder PHP 5.5
  9.  */
  10.  
  11. class ClassLicense
  12. {
  13.     private $KEY = "8g-hg0fh-fjc0-gvh-9dg283fq-r9nsda[foc";
  14.     private $DEBUG = 0;
  15.     private $config = NULL;
  16.     private $db = NULL;
  17.     private $module_key = NULL;
  18.     private $module_key2 = NULL;
  19.     private $url = NULL;
  20.     private $checked_domain = NULL;
  21.     private $checked_base_domain = NULL;
  22.     public function __construct($db, $config, $url, $module_key)
  23.     {
  24.         $this->config = $config;
  25.         $this->db = $db;
  26.         $this->url = $url;
  27.         $this->module_key = $module_key;
  28.         $this->module_key2 = str_replace("2", "", $module_key);
  29.     }
  30.     public function uploadURL($url)
  31.     {
  32.         $url .= "?license=" . implode(",", $this->getHashs());
  33.         $page = "";
  34.         if (extension_loaded("curl")) {
  35.             $c = curl_init($url);
  36.             curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
  37.             $page = curl_exec($c);
  38.             curl_close($c);
  39.         } else {
  40.             $page = file_get_contents($url);
  41.         }
  42.         return $page;
  43.     }
  44.     public function setDebug($value)
  45.     {
  46.         $this->DEBUG = $value;
  47.     }
  48.     public function saveLicense($code)
  49.     {
  50.         if (!$this->checkLicenseCode($code)) {
  51.             if ($this->DEBUG) {
  52.                 exit("ERROR code");
  53.             }
  54.             return false;
  55.         }
  56.         $this->updateOneSetting("spk_license_" . $this->module_key, $code, "spk");
  57.         return true;
  58.     }
  59.     private function getCheckedDomains()
  60.     {
  61.         if (!$this->checked_domain) {
  62.             $this->checked_domain = $this->getCheckedDomain();
  63.         }
  64.         if (!$this->checked_base_domain) {
  65.             $this->checked_base_domain = $this->getBaseDomain($this->checked_domain);
  66.         }
  67.         return array($this->checked_domain, $this->checked_base_domain);
  68.     }
  69.     private function getHashs()
  70.     {
  71.         list($checked_domain, $checked_base_domain) = $this->getCheckedDomains();
  72.         $hash = "";
  73.         $hash2 = "";
  74.         if ($checked_domain && $checked_base_domain) {
  75.             $hash = md5($this->module_key2 . "|" . $checked_domain . "|" . $this->KEY);
  76.             $hash2 = md5($this->module_key2 . "|" . $checked_base_domain . "|" . $this->KEY);
  77.         }
  78.         return array($hash, $hash2);
  79.     }
  80.     public function checkLicenseCode($code)
  81.     {
  82.         $code = trim($code);
  83.         list($hash, $hash2) = $this->getHashs();
  84.         if (strstr($this->checked_base_domain, "localhost")) {
  85.             return true;
  86.         }
  87.         if (!$this->checked_domain) {
  88.             if ($this->DEBUG) {
  89.                 exit("ERROR domain");
  90.             }
  91.             return false;
  92.         }
  93.         return $this->checkLicenseStatus($hash, $hash2);
  94.     }
  95.     private function checkLicenseStatus($hash, $hash2)
  96.     {
  97.         if ($this->config->get($this->module_key . "2_lista") && ($this->config->get($this->module_key . "2_lista") == md5($hash . $this->KEY) || $this->config->get($this->module_key . "2_lista") == md5($hash2 . $this->KEY))) {
  98.             return 1;
  99.         }
  100.         $url = "http://softpodkluch.ru/API/RP2/DATA.php?license=" . $hash . "," . $hash2 . "&checkonly=1";
  101.         if (extension_loaded("curl")) {
  102.             $c = curl_init($url);
  103.             curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
  104.             $page = curl_exec($c);
  105.             curl_close($c);
  106.             if (!$page) {
  107.                 $page = file_get_contents($url);
  108.             }
  109.         } else {
  110.             $page = file_get_contents($url);
  111.         }
  112.         if ($page == "ERROR-1") {
  113.             return -1;
  114.         }
  115.         if ($page == "ERROR-2") {
  116.             return -2;
  117.         }
  118.         if ($page == "ERROR-3") {
  119.             return -3;
  120.         }
  121.         if ($page == "ERROR-4") {
  122.             return -4;
  123.         }
  124.         if ($page != md5($hash . $this->KEY) && $page != md5($hash2 . $this->KEY)) {
  125.             return -1;
  126.         }
  127.         $this->updateOneSetting($this->module_key . "2_lista", $page);
  128.         return true;
  129.     }
  130.     public function getVersion()
  131.     {
  132.         $VERSION = VERSION;
  133.         $VERSION = str_replace(".", "", $VERSION);
  134.         if (strlen($VERSION) == 3) {
  135.             $VERSION .= "0";
  136.         } else {
  137.             if (4 < strlen($VERSION)) {
  138.                 $VERSION = substr($VERSION, 0, 4);
  139.             }
  140.         }
  141.         return $VERSION;
  142.     }
  143.     public function checkLicense()
  144.     {
  145.         if (!$this->config->get("spk_license_" . $this->module_key)) {
  146.             if ($this->DEBUG) {
  147.                 exit("license don't created");
  148.             }
  149.             return false;
  150.         }
  151.         list($hash, $hash2) = $this->getHashs();
  152.         if (strstr($this->checked_base_domain, "localhost")) {
  153.             return true;
  154.         }
  155.         if (!$this->checked_domain) {
  156.             return false;
  157.         }
  158.         if ($this->config->get("spk_license_" . $this->module_key) != $hash && $this->config->get("spk_license_" . $this->module_key) != $hash2) {
  159.             return false;
  160.         }
  161.         return $this->checkLicenseStatus($hash, $hash2);
  162.     }
  163.     private function getBaseDomain($domain)
  164.     {
  165.         if (!strstr($domain, ".")) {
  166.             return $domain;
  167.         }
  168.         $ar = explode(".", $domain);
  169.         $domain = $ar[count($ar) - 2] . "." . $ar[count($ar) - 1];
  170.         return $domain;
  171.     }
  172.     private function getCheckedDomain()
  173.     {
  174.         $rand = md5(rand());
  175.         $this->updateOneSetting("spk_license_rand", $rand);
  176.         $domain = "";
  177.         if (defined("HTTP_CATALOG")) {
  178.             $domain = HTTP_CATALOG;
  179.         } else {
  180.             if (defined("HTTPS_CATALOG")) {
  181.                 $domain = HTTPS_CATALOG;
  182.             } else {
  183.                 if (defined("HTTP_SERVER")) {
  184.                     $domain = HTTP_SERVER;
  185.                 } else {
  186.                     if (defined("HTTPS_SERVER")) {
  187.                         $domain = HTTPS_SERVER;
  188.                     } else {
  189.                         if (isset($_SERVER["HTTP_HOST"])) {
  190.                             $domain = $_SERVER["HTTP_HOST"];
  191.                         }
  192.                     }
  193.                 }
  194.             }
  195.         }
  196.         $domain = preg_replace("/^https\\:\\/\\//", "", $domain);
  197.         $domain = preg_replace("/^http\\:\\/\\//", "", $domain);
  198.         $domain = preg_replace("/^www\\./", "", $domain);
  199.         $domain = preg_replace("/\\/\$/", "", $domain);
  200.         return $domain;
  201.     }
  202.     public function updateOneSetting($key, $value, $group = "")
  203.     {
  204.         $groupField = "group";
  205.         if (2010 <= $this->getVersion()) {
  206.             $groupField = "code";
  207.         }
  208.         if (!$group) {
  209.             $group = $this->module_key . "2";
  210.         }
  211.         $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "setting WHERE \r\n\t\t\t\t`" . $groupField . "` = '" . $this->db->escape($group) . "' AND \r\n\t\t\t\t`key` = '" . $this->db->escape($key) . "'");
  212.         if (0 < count($query->rows)) {
  213.             $this->db->query("UPDATE " . DB_PREFIX . "setting \r\n\t\t\tSET \r\n\t\t\t\t`value` = '" . $this->db->escape($value) . "'\r\n\t\t\tWHERE \r\n\t\t\t\t`" . $groupField . "` = '" . $this->db->escape($group) . "' AND \r\n\t\t\t\t`key` = '" . $this->db->escape($key) . "'\r\n\t\t\t");
  214.         } else {
  215.             $this->db->query("INSERT INTO " . DB_PREFIX . "setting \r\n\t\t\tSET \r\n\t\t\t\t`value` = '" . $this->db->escape($value) . "',\r\n\t\t\t\t`" . $groupField . "` = '" . $this->db->escape($group) . "',\r\n\t\t\t\t`key` = '" . $this->db->escape($key) . "'\r\n\t\t\t");
  216.         }
  217.     }
  218. }
  219.  
  220. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement