Explorar el Código

Selectively use HTTPS links for TVDB

Zachary Kotlarek hace 12 años
padre
commit
7c91535304
Se han modificado 3 ficheros con 14 adiciones y 1 borrados
  1. 1 1
      web/includes/config.php
  2. 1 0
      web/includes/tvdb.php
  3. 12 0
      web/includes/util.php

+ 1 - 1
web/includes/config.php

@@ -12,7 +12,7 @@ $TVDB_DELAY       = 20;		# Minimum delay between TVDB downloads
 $TVDB_DELAY_COUNT = 3;		# Number of TVDB requests allowed without throttling
 $TVDB_TIMEOUT     = 15;		# Maximum load time for TVDB pages
 $TVDB_LANG_ID     = 7;		# Default language ID for TVDB URLs
-$TVDB_URL         = 'https://thetvdb.com/?tab=series';
+$TVDB_URL         = 'http://thetvdb.com/?tab=series';
 
 ### App Config
 $EXISTS_FILES  = array('no_quality_checks', 'more_number_formats', 'skip');

+ 1 - 0
web/includes/tvdb.php

@@ -31,6 +31,7 @@ function TVDBURL($id, $lid) {
 	}
 	if ($id) {
 		$url = $TVDB_URL . '&id=' . $id . '&lid=' . $lid;
+		$url = adjustProtocol($url);
 	}
 
 	return $url;

+ 12 - 0
web/includes/util.php

@@ -63,4 +63,16 @@ function staleCacheName($file) {
 	return $file . '.stale';
 }
 
+function protocolName() {
+	$protocol = 'http';
+	if ($_SERVER['HTTPS']) {
+		$protocol = 'https';
+	}
+	return $protocol;
+}
+
+function adjustProtocol($url) {
+	return preg_replace('/^https?\:/i', protocolName() . ':', $url);
+}
+
 ?>