Skip to content

Commit

Permalink
Fixed issue: Images inserted into HTML emails were not properly linke…
Browse files Browse the repository at this point in the history
…d to the server
  • Loading branch information
c-schmitz committed Apr 27, 2012
1 parent 74edabf commit 6552633
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 21 deletions.
9 changes: 8 additions & 1 deletion application/controllers/admin/kcfinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,14 @@ function index($load = false)
if (hasSurveyPermission($surveyid, 'surveycontent', 'update'))
{
$_SESSION['KCFINDER']['disabled'] = false;
$_SESSION['KCFINDER']['uploadURL'] = $this->getController()->createUrl("upload/surveys/{$surveyid}/");
if (preg_match('/^edit:emailsettings/',$_SESSION['FileManagerContext']) != 0)
{
$_SESSION['KCFINDER']['uploadURL'] = $this->getController()->createAbsoluteUrl("upload/surveys/{$surveyid}/");
}
else
{
$_SESSION['KCFINDER']['uploadURL'] = $this->getController()->createUrl("upload/surveys/{$surveyid}/");
}
$_SESSION['KCFINDER']['uploadDir'] = ROOT . "/upload/surveys/{$surveyid}/";
}
}
Expand Down
55 changes: 36 additions & 19 deletions scripts/admin/kcfinder/core/uploader.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,25 +107,42 @@ public function __construct() {
if (!strlen($this->config['cookiePath']))
$this->config['cookiePath'] = "/";

// UPLOAD FOLDER INIT
if ($this->config['uploadURL'] == "/") {
$this->config['uploadDir'] = strlen($this->config['uploadDir'])
? path::normalize($this->config['uploadDir'])
: path::normalize($_SERVER['DOCUMENT_ROOT']);
$this->typeDir = "{$this->config['uploadDir']}/{$this->type}";
$this->typeURL = "/{$this->type}";
} else {
$this->config['uploadURL'] = (substr($this->config['uploadURL'], 0, 1) === "/")
? path::normalize($this->config['uploadURL'])
: path::rel2abs_url($this->config['uploadURL']);
$this->config['uploadDir'] = strlen($this->config['uploadDir'])
? path::normalize($this->config['uploadDir'])
: path::url2fullPath($this->config['uploadURL']);
$this->typeDir = "{$this->config['uploadDir']}/{$this->type}";
$this->typeURL = "{$this->config['uploadURL']}/{$this->type}";
}
if (!is_dir($this->config['uploadDir']))
@mkdir($this->config['uploadDir'], $this->config['dirPerms']);
// UPLOAD FOLDER INIT

// FULL URL
if (preg_match('/^([a-z]+)\:\/\/([^\/^\:]+)(\:(\d+))?\/(.+)\/?$/',
$this->config['uploadURL'], $patt)
) {
list($unused, $protocol, $domain, $unused, $port, $path) = $patt;
$path = path::normalize($path);
$this->config['uploadURL'] = "$protocol://$domain" . (strlen($port) ? ":$port" : "") . "/$path";
$this->config['uploadDir'] = strlen($this->config['uploadDir'])
? path::normalize($this->config['uploadDir'])
: path::url2fullPath("/$path");
$this->typeDir = "{$this->config['uploadDir']}/{$this->type}";
$this->typeURL = "{$this->config['uploadURL']}/{$this->type}";

// SITE ROOT
} elseif ($this->config['uploadURL'] == "/") {
$this->config['uploadDir'] = strlen($this->config['uploadDir'])
? path::normalize($this->config['uploadDir'])
: path::normalize($_SERVER['DOCUMENT_ROOT']);
$this->typeDir = "{$this->config['uploadDir']}/{$this->type}";
$this->typeURL = "/{$this->type}";

// ABSOLUTE & RELATIVE
} else {
$this->config['uploadURL'] = (substr($this->config['uploadURL'], 0, 1) === "/")
? path::normalize($this->config['uploadURL'])
: path::rel2abs_url($this->config['uploadURL']);
$this->config['uploadDir'] = strlen($this->config['uploadDir'])
? path::normalize($this->config['uploadDir'])
: path::url2fullPath($this->config['uploadURL']);
$this->typeDir = "{$this->config['uploadDir']}/{$this->type}";
$this->typeURL = "{$this->config['uploadURL']}/{$this->type}";
}
if (!is_dir($this->config['uploadDir']))
@mkdir($this->config['uploadDir'], $this->config['dirPerms']);

// HOST APPLICATIONS INIT
if (isset($this->get['CKEditorFuncNum']))
Expand Down
14 changes: 13 additions & 1 deletion scripts/admin/kcfinder/js/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,23 @@ _.getFileExtension = function(filename, toLower) {
};

_.escapeDirs = function(path) {
var fullDirExpr = /^([a-z]+)\:\/\/([^\/^\:]+)(\:(\d+))?\/(.+)$/,
prefix = "";
if (fullDirExpr.test(path)) {
var port = path.replace(fullDirExpr, "$4");
prefix = path.replace(fullDirExpr, "$1://$2")
if (port.length)
prefix += ":" + port;
prefix += "/";
path = path.replace(fullDirExpr, "$5");
}

var dirs = path.split('/');
var escapePath = '';
for (var i = 0; i < dirs.length; i++)
escapePath += encodeURIComponent(dirs[i]) + '/';
return escapePath.substr(0, escapePath.length - 1);

return prefix + escapePath.substr(0, escapePath.length - 1);
};

_.outerSpace = function(selector, type, mbp) {
Expand Down

0 comments on commit 6552633

Please sign in to comment.