Commit e8003f3985aa03f56a4748978350f3839f32d93d

Authored by kevin_fourie
1 parent 1d336588

Merged in from STABLE trunk...

KTS-3686
"kt_url() is overwritten regularly and the cached server name also has newlines when edited in some editors"
Fixed.

Committed By: Conrad Vermeulen
Reviewed By: Megan Watson


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/STABLE/branches/3.5.3a-Release-Branch@9279 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing 1 changed file with 14 additions and 4 deletions
lib/util/ktutil.inc
... ... @@ -60,6 +60,13 @@ class KTUtil {
60 60 {
61 61 global $default;
62 62 $cacheDir = $default->cacheDirectory;
  63 +
  64 + $serverFilename = $cacheDir . '/' . KTUtil::SERVER_NAME_FILE;
  65 + if (file_exists($serverFilename))
  66 + {
  67 + return;
  68 + }
  69 +
63 70 $rootUrl = $default->rootUrl;
64 71 $protocol = $default->sslEnabled ? 'https' : 'http';
65 72 $port = $_SERVER['SERVER_PORT']+0;
... ... @@ -79,7 +86,7 @@ class KTUtil {
79 86 // Add the root url
80 87 $base_url .= $rootUrl;
81 88  
82   - @file_put_contents($cacheDir . '/' . KTUtil::SERVER_NAME_FILE, $base_url);
  89 + @file_put_contents($serverFilename, $base_url);
83 90 }
84 91  
85 92  
... ... @@ -88,6 +95,11 @@ class KTUtil {
88 95 global $default;
89 96 static $base_url = null;
90 97  
  98 + if (!is_null($base_url))
  99 + {
  100 + return $base_url;
  101 + }
  102 +
91 103 $cacheDir = $default->cacheDirectory;
92 104  
93 105 $base_url = @file_get_contents($cacheDir . '/' . KTUtil::SERVER_NAME_FILE);
... ... @@ -100,6 +112,7 @@ class KTUtil {
100 112  
101 113 if (false !== $base_url)
102 114 {
  115 + $base_url = str_replace(array("\n","\r"), array('',''), $base_url);
103 116 return $base_url;
104 117 }
105 118  
... ... @@ -113,10 +126,7 @@ class KTUtil {
113 126 {
114 127 $default->log->debug("kt_url: base url - $base_url");
115 128 }
116   -
117   -
118 129 return $base_url;
119   -
120 130 }
121 131  
122 132 static function call_page($path)
... ...