Guest User

Untitled

a guest
Apr 22nd, 2026
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.35 KB | None | 0 0
  1. <?php
  2.  
  3. class Sitemap
  4. {
  5. private $validLicence;
  6. private $licence;
  7. public function __construct($licence = "")
  8. {
  9. $this->licence = $licence;
  10. if ($this->isValidLicence($this->licence)) {
  11. $this->validLicence = true;
  12. } else {
  13. $this->validLicence = false;
  14. }
  15. }
  16. public function getCategoryPriority($data)
  17. {
  18. $time_now = date_create(date("Y-m-d H:i:s"));
  19. $time_was = date_create(date($data["date"]));
  20. $diff = date_diff($time_now, $time_was);
  21. $priority = "0.1";
  22. if ($this->validLicence) {
  23. $priority = $data["priority_correlation"][80];
  24. if ($diff->days <= 70) {
  25. $priority = $data["priority_correlation"][70];
  26. }
  27. if ($diff->days <= 65) {
  28. $priority = $data["priority_correlation"][65];
  29. }
  30. if ($diff->days <= 60) {
  31. $priority = $data["priority_correlation"][60];
  32. }
  33. if ($diff->days <= 30) {
  34. $priority = $data["priority_correlation"][30];
  35. }
  36. if ($diff->days <= 20) {
  37. $priority = $data["priority_correlation"][20];
  38. }
  39. if ($diff->days <= 15) {
  40. $priority = $data["priority_correlation"][10];
  41. }
  42. if ($diff->days <= 10) {
  43. $priority = $data["priority_correlation"][10];
  44. }
  45. if ($diff->days <= 5) {
  46. $priority = $data["priority_correlation"][5];
  47. }
  48. }
  49. return $priority;
  50. }
  51. public function getCategoryChangefreq($data)
  52. {
  53. $time_now = date_create(date("Y-m-d H:i:s"));
  54. $time_was = date_create(date($data["date"]));
  55. $diff = date_diff($time_now, $time_was);
  56. $changefreq = "yearly";
  57. if ($this->validLicence) {
  58. $changefreq = $data["changefreq_default"];
  59. if ($diff->days <= 365) {
  60. $changefreq = $data["changefreq_correlation"][365];
  61. }
  62. if ($diff->days <= 30) {
  63. $changefreq = $data["changefreq_correlation"][30];
  64. }
  65. if ($diff->days <= 7) {
  66. $changefreq = $data["changefreq_correlation"][7];
  67. }
  68. if ($diff->days <= 1) {
  69. $changefreq = $data["changefreq_correlation"][1];
  70. }
  71. }
  72. return $changefreq;
  73. }
  74. public function getProductPriority($data)
  75. {
  76. $time_now = date_create(date("Y-m-d H:i:s"));
  77. $time_was = date_create(date($data["date"]));
  78. $diff = date_diff($time_now, $time_was);
  79. $priority = "0.1";
  80. if ($this->validLicence) {
  81. $priority = $data["priority_correlation"][80];
  82. if ($diff->days <= 70) {
  83. $priority = $data["priority_correlation"][70];
  84. }
  85. if ($diff->days <= 65) {
  86. $priority = $data["priority_correlation"][65];
  87. }
  88. if ($diff->days <= 60) {
  89. $priority = $data["priority_correlation"][60];
  90. }
  91. if ($diff->days <= 30) {
  92. $priority = $data["priority_correlation"][30];
  93. }
  94. if ($diff->days <= 20) {
  95. $priority = $data["priority_correlation"][20];
  96. }
  97. if ($diff->days <= 15) {
  98. $priority = $data["priority_correlation"][10];
  99. }
  100. if ($diff->days <= 10) {
  101. $priority = $data["priority_correlation"][10];
  102. }
  103. if ($diff->days <= 5) {
  104. $priority = $data["priority_correlation"][5];
  105. }
  106. }
  107. return $priority;
  108. }
  109. public function getProductChangefreq($data)
  110. {
  111. $time_now = date_create(date("Y-m-d H:i:s"));
  112. $time_was = date_create(date($data["date"]));
  113. $diff = date_diff($time_now, $time_was);
  114. $changefreq = "yearly";
  115. if ($this->validLicence) {
  116. $changefreq = $data["changefreq_default"];
  117. if ($diff->days <= 365) {
  118. $changefreq = $data["changefreq_correlation"][365];
  119. }
  120. if ($diff->days <= 30) {
  121. $changefreq = $data["changefreq_correlation"][30];
  122. }
  123. if ($diff->days <= 7) {
  124. $changefreq = $data["changefreq_correlation"][7];
  125. }
  126. if ($diff->days <= 1) {
  127. $changefreq = $data["changefreq_correlation"][1];
  128. }
  129. }
  130. return $changefreq;
  131. }
  132. public function isValidLicence($licence)
  133. {
  134. $a_licence = $this->decodeLicence($licence);
  135. $licenced_site = str_replace(["http:", "https:", "//", "www."], ["", "", "", ""], $a_licence["site"]);
  136. $this_site = $this->get_sitename(HTTPS_SERVER);
  137. if ($this_site != $licenced_site && $this->get_site_without_subdomain($this_site) != $licenced_site) {
  138. return false;
  139. }
  140. return true;
  141. }
  142. private function decodeLicence($licence)
  143. {
  144. $res = [];
  145. $real_licence_code = base64_decode($licence);
  146. preg_match("/L32w3za9AQLzAdHd(.*)B0V12SS6HmvXkLHS/siU", $real_licence_code, $matches);
  147. if ($matches) {
  148. $res["site"] = base64_decode($matches[1]);
  149. unset($matches);
  150. preg_match("/YQwdlPAm1XW(.*)A4D7JsGzAhh2G/siU", $real_licence_code, $matches);
  151. if ($matches) {
  152. $res["time"] = base64_decode(base64_decode($matches[1]));
  153. unset($matches);
  154. preg_match("/ZqMpLshbvKddAP(.*)D5jAew2dh5aosg/siU", $real_licence_code, $matches);
  155. if ($matches) {
  156. $res["days"] = base64_decode(base64_decode(base64_decode($matches[1])));
  157. unset($matches);
  158. if (count($res) < 3) {
  159. return false;
  160. }
  161. return $res;
  162. }
  163. return false;
  164. }
  165. return false;
  166. }
  167. return false;
  168. }
  169. private function get_sitename($site)
  170. {
  171. $site = $this->get_site_domain_name($site);
  172. if (!preg_match("/[a-z.-]+\$/", $site)) {
  173. require_once DIR_SYSTEM . "library/branched_sitemap/idna_convert.class.php";
  174. $IDN = new idna_convert();
  175. $input = mb_convert_encoding($site, "utf-8", mb_detect_encoding($site));
  176. $site = $IDN->encode($input);
  177. }
  178. return $site;
  179. }
  180. private function get_site_domain_name($site)
  181. {
  182. $site = str_replace(["http:", "https:", "//", "www."], ["", "", "", ""], $site);
  183. $site = $this->get_sitename_without_dirs($site);
  184. return $site;
  185. }
  186. private function get_sitename_without_dirs($site)
  187. {
  188. $n = mb_strlen($site);
  189. $last_char = mb_substr($site, $n - 1, $n, "UTF-8");
  190. if ("/" == $last_char) {
  191. $site = mb_substr($site, 0, $n - 1, "UTF-8");
  192. }
  193. if (stristr($site, "/")) {
  194. $array = explode("/", $site);
  195. $site = $array[0];
  196. }
  197. return $site;
  198. }
  199. private function get_site_without_subdomain($site)
  200. {
  201. $a_site = explode(".", $site, 2);
  202. return $a_site[1];
  203. }
  204. }
  205.  
  206. ?>
Add Comment
Please, Sign In to add comment