Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Sitemap
- {
- private $validLicence;
- private $licence;
- public function __construct($licence = "")
- {
- $this->licence = $licence;
- if ($this->isValidLicence($this->licence)) {
- $this->validLicence = true;
- } else {
- $this->validLicence = false;
- }
- }
- public function getCategoryPriority($data)
- {
- $time_now = date_create(date("Y-m-d H:i:s"));
- $time_was = date_create(date($data["date"]));
- $diff = date_diff($time_now, $time_was);
- $priority = "0.1";
- if ($this->validLicence) {
- $priority = $data["priority_correlation"][80];
- if ($diff->days <= 70) {
- $priority = $data["priority_correlation"][70];
- }
- if ($diff->days <= 65) {
- $priority = $data["priority_correlation"][65];
- }
- if ($diff->days <= 60) {
- $priority = $data["priority_correlation"][60];
- }
- if ($diff->days <= 30) {
- $priority = $data["priority_correlation"][30];
- }
- if ($diff->days <= 20) {
- $priority = $data["priority_correlation"][20];
- }
- if ($diff->days <= 15) {
- $priority = $data["priority_correlation"][10];
- }
- if ($diff->days <= 10) {
- $priority = $data["priority_correlation"][10];
- }
- if ($diff->days <= 5) {
- $priority = $data["priority_correlation"][5];
- }
- }
- return $priority;
- }
- public function getCategoryChangefreq($data)
- {
- $time_now = date_create(date("Y-m-d H:i:s"));
- $time_was = date_create(date($data["date"]));
- $diff = date_diff($time_now, $time_was);
- $changefreq = "yearly";
- if ($this->validLicence) {
- $changefreq = $data["changefreq_default"];
- if ($diff->days <= 365) {
- $changefreq = $data["changefreq_correlation"][365];
- }
- if ($diff->days <= 30) {
- $changefreq = $data["changefreq_correlation"][30];
- }
- if ($diff->days <= 7) {
- $changefreq = $data["changefreq_correlation"][7];
- }
- if ($diff->days <= 1) {
- $changefreq = $data["changefreq_correlation"][1];
- }
- }
- return $changefreq;
- }
- public function getProductPriority($data)
- {
- $time_now = date_create(date("Y-m-d H:i:s"));
- $time_was = date_create(date($data["date"]));
- $diff = date_diff($time_now, $time_was);
- $priority = "0.1";
- if ($this->validLicence) {
- $priority = $data["priority_correlation"][80];
- if ($diff->days <= 70) {
- $priority = $data["priority_correlation"][70];
- }
- if ($diff->days <= 65) {
- $priority = $data["priority_correlation"][65];
- }
- if ($diff->days <= 60) {
- $priority = $data["priority_correlation"][60];
- }
- if ($diff->days <= 30) {
- $priority = $data["priority_correlation"][30];
- }
- if ($diff->days <= 20) {
- $priority = $data["priority_correlation"][20];
- }
- if ($diff->days <= 15) {
- $priority = $data["priority_correlation"][10];
- }
- if ($diff->days <= 10) {
- $priority = $data["priority_correlation"][10];
- }
- if ($diff->days <= 5) {
- $priority = $data["priority_correlation"][5];
- }
- }
- return $priority;
- }
- public function getProductChangefreq($data)
- {
- $time_now = date_create(date("Y-m-d H:i:s"));
- $time_was = date_create(date($data["date"]));
- $diff = date_diff($time_now, $time_was);
- $changefreq = "yearly";
- if ($this->validLicence) {
- $changefreq = $data["changefreq_default"];
- if ($diff->days <= 365) {
- $changefreq = $data["changefreq_correlation"][365];
- }
- if ($diff->days <= 30) {
- $changefreq = $data["changefreq_correlation"][30];
- }
- if ($diff->days <= 7) {
- $changefreq = $data["changefreq_correlation"][7];
- }
- if ($diff->days <= 1) {
- $changefreq = $data["changefreq_correlation"][1];
- }
- }
- return $changefreq;
- }
- public function isValidLicence($licence)
- {
- $a_licence = $this->decodeLicence($licence);
- $licenced_site = str_replace(["http:", "https:", "//", "www."], ["", "", "", ""], $a_licence["site"]);
- $this_site = $this->get_sitename(HTTPS_SERVER);
- if ($this_site != $licenced_site && $this->get_site_without_subdomain($this_site) != $licenced_site) {
- return false;
- }
- return true;
- }
- private function decodeLicence($licence)
- {
- $res = [];
- $real_licence_code = base64_decode($licence);
- preg_match("/L32w3za9AQLzAdHd(.*)B0V12SS6HmvXkLHS/siU", $real_licence_code, $matches);
- if ($matches) {
- $res["site"] = base64_decode($matches[1]);
- unset($matches);
- preg_match("/YQwdlPAm1XW(.*)A4D7JsGzAhh2G/siU", $real_licence_code, $matches);
- if ($matches) {
- $res["time"] = base64_decode(base64_decode($matches[1]));
- unset($matches);
- preg_match("/ZqMpLshbvKddAP(.*)D5jAew2dh5aosg/siU", $real_licence_code, $matches);
- if ($matches) {
- $res["days"] = base64_decode(base64_decode(base64_decode($matches[1])));
- unset($matches);
- if (count($res) < 3) {
- return false;
- }
- return $res;
- }
- return false;
- }
- return false;
- }
- return false;
- }
- private function get_sitename($site)
- {
- $site = $this->get_site_domain_name($site);
- if (!preg_match("/[a-z.-]+\$/", $site)) {
- require_once DIR_SYSTEM . "library/branched_sitemap/idna_convert.class.php";
- $IDN = new idna_convert();
- $input = mb_convert_encoding($site, "utf-8", mb_detect_encoding($site));
- $site = $IDN->encode($input);
- }
- return $site;
- }
- private function get_site_domain_name($site)
- {
- $site = str_replace(["http:", "https:", "//", "www."], ["", "", "", ""], $site);
- $site = $this->get_sitename_without_dirs($site);
- return $site;
- }
- private function get_sitename_without_dirs($site)
- {
- $n = mb_strlen($site);
- $last_char = mb_substr($site, $n - 1, $n, "UTF-8");
- if ("/" == $last_char) {
- $site = mb_substr($site, 0, $n - 1, "UTF-8");
- }
- if (stristr($site, "/")) {
- $array = explode("/", $site);
- $site = $array[0];
- }
- return $site;
- }
- private function get_site_without_subdomain($site)
- {
- $a_site = explode(".", $site, 2);
- return $a_site[1];
- }
- }
- ?>
Add Comment
Please, Sign In to add comment