summaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
authorEvan Prodromou <evan@status.net>2010-10-14 14:22:17 -0400
committerEvan Prodromou <evan@status.net>2010-10-14 14:22:17 -0400
commitb31c49c5d47e04c59bbbcf878ffd307fbf60b533 (patch)
tree83398b62b5a6d7032118bf12c8715e9837980a5c /classes
parentecb582e41900b9a8fe0cc01eac9c68b4da61d734 (diff)
Make HTTPS urls in File::url() if necessary
Diffstat (limited to 'classes')
-rw-r--r--classes/File.php54
1 files changed, 36 insertions, 18 deletions
diff --git a/classes/File.php b/classes/File.php
index d457968b5..da029e39b 100644
--- a/classes/File.php
+++ b/classes/File.php
@@ -261,22 +261,41 @@ class File extends Memcached_DataObject
// TRANS: Client exception thrown if a file upload does not have a valid name.
throw new ClientException(_("Invalid filename."));
}
- if(common_config('site','private')) {
+
+ if (common_config('site','private')) {
return common_local_url('getfile',
array('filename' => $filename));
- } else {
- $path = common_config('attachments', 'path');
+ }
- if ($path[strlen($path)-1] != '/') {
- $path .= '/';
- }
+ if (StatusNet::isHTTPS()) {
+
+ $sslserver = common_config('attachments', 'sslserver');
- if ($path[0] != '/') {
- $path = '/'.$path;
+ if (empty($sslserver)) {
+ // XXX: this assumes that background dir == site dir + /file/
+ // not true if there's another server
+ if (is_string(common_config('site', 'sslserver')) &&
+ mb_strlen(common_config('site', 'sslserver')) > 0) {
+ $server = common_config('site', 'sslserver');
+ } else if (common_config('site', 'server')) {
+ $server = common_config('site', 'server');
+ }
+ $path = common_config('site', 'path') . '/file/';
+ } else {
+ $server = $sslserver;
+ $path = common_config('attachments', 'sslpath');
+ if (empty($path)) {
+ $path = common_config('attachments', 'path');
+ }
}
+ $protocol = 'https';
+
+ } else {
+
+ $path = common_config('attachments', 'path');
$server = common_config('attachments', 'server');
if (empty($server)) {
@@ -285,19 +304,18 @@ class File extends Memcached_DataObject
$ssl = common_config('attachments', 'ssl');
- if (is_null($ssl)) { // null -> guess
- if (common_config('site', 'ssl') == 'always' &&
- !common_config('attachments', 'server')) {
- $ssl = true;
- } else {
- $ssl = false;
- }
- }
-
$protocol = ($ssl) ? 'https' : 'http';
+ }
- return $protocol.'://'.$server.$path.$filename;
+ if ($path[strlen($path)-1] != '/') {
+ $path .= '/';
}
+
+ if ($path[0] != '/') {
+ $path = '/'.$path;
+ }
+
+ return $protocol.'://'.$server.$path.$filename;
}
function getEnclosure(){