Просмотр исходного кода

URL absolue pour token

Corrige https://github.com/marienfressinaud/FreshRSS/issues/213
Abandonne le protocole relatif "//" et repasse à des "http://" ou
"https://" explicites
Alexandre Alapetite 12 лет назад
Родитель
Сommit
8bb25589ff
2 измененных файлов с 9 добавлено и 6 удалено
  1. 1 1
      app/views/configure/display.phtml
  2. 8 5
      lib/minz/Url.php

+ 1 - 1
app/views/configure/display.phtml

@@ -56,7 +56,7 @@
 			<?php $token = $this->conf->token (); ?>
 			<div class="group-controls">
 				<input type="text" id="token" name="token" value="<?php echo $token; ?>"  placeholder="<?php echo Translate::t ('blank_to_disable'); ?>"/>
-				<i class="icon i_help"></i> <?php echo Translate::t('explain_token', Url::display(), $token); ?>
+				<i class="icon i_help"></i> <?php echo Translate::t('explain_token', Url::display(null, 'html', true), $token); ?>
 			</div>
 		</div>
 	

+ 8 - 5
lib/minz/Url.php

@@ -22,11 +22,14 @@ class Url {
 		$url_string = '';
 		
 		if ($absolute) {
-			$protocol = (is_array ($url) && isset ($url['protocol'])) ? ($url['protocol'] . ':') : '';	//Empty protocol will use automatic http or https
-			$url_string = $protocol
-			            . '//'
-			            . Request::getDomainName ()
-			            . Request::getBaseUrl ();
+			if (is_array ($url) && isset ($url['protocol'])) {
+				$protocol = $url['protocol'];
+			} elseif (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
+				$protocol = 'https:';
+			} else {
+				$protocol = 'http:';
+			}
+			$url_string = $protocol . '//' . Request::getDomainName () . Request::getBaseUrl ();
 		}
 		else {
 			$url_string = '.';