comparison Sitemap.inc @ 133:00255ca89459

Generate URLs with correct protocol based on forwarded proto.
author Tom Fredrik Blenning <bfg@bfgconsult.no>
date Sun, 22 Jan 2023 19:15:55 +0100
parents 6b882fb6ea46
children
comparison
equal deleted inserted replaced
132:51b53cd01080 133:00255ca89459
67 function mayValidate() 67 function mayValidate()
68 { 68 {
69 return false; 69 return false;
70 } 70 }
71 71
72 private function processDir($dir, $lang, $acceptedLanguages, $base) { 72 private function processDir($dir, $lang, $acceptedLanguages, $baseurl) {
73 $urls = array(); 73 $urls = array();
74 74
75 $base=basePath(); 75 $base=basePath();
76 $base=$_SERVER['DOCUMENT_ROOT']; 76 $base=$_SERVER['DOCUMENT_ROOT'];
77 $baseurl = $_SERVER["REQUEST_SCHEME"] ."://". $_SERVER["SERVER_NAME"];
78
79 77
80 if ($handle = opendir($base . "/${dir}")) { 78 if ($handle = opendir($base . "/${dir}")) {
81 while (false !== ($entry = readdir($handle))) { 79 while (false !== ($entry = readdir($handle))) {
82 if (endsWith($entry, '.xml')) { 80 if (endsWith($entry, '.xml')) {
83 $fentry = $base . "/${dir}/${entry}"; 81 $fentry = $base . "/${dir}/${entry}";
124 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 122 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
125 xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 123 xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
126 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"> 124 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
127 '; 125 ';
128 126
129 $base = $_SERVER["REQUEST_SCHEME"] ."://". $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"]; 127 $proto= $_SERVER["REQUEST_SCHEME"];
128 if (array_key_exists('HTTP_X_FORWARDED_PROTO', $_SERVER)) {
129 $proto=$_SERVER['HTTP_X_FORWARDED_PROTO'];
130 }
131 $base = $proto ."://". $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
130 $l = strrpos($base, '/'); 132 $l = strrpos($base, '/');
131 if ($l) 133 if ($l)
132 $base = substr($base, 0, $l); 134 $base = substr($base, 0, $l);
133 135
134 $acceptedLanguages = $this->options->getAcceptedLanguages(); 136 $acceptedLanguages = $this->options->getAcceptedLanguages();