diff --git a/core/autoload.php b/core/autoload.php index 8d1fbcf..70201f9 100644 --- a/core/autoload.php +++ b/core/autoload.php @@ -21,13 +21,15 @@ list($ns, $class) = $path; if ($ns == "kcfinder") { + $dir = dirname(__FILE__); + if (in_array($class, array("uploader", "browser", "minifier", "session"))) - require "core/class/$class.php"; - elseif (file_exists("core/types/$class.php")) - require "core/types/$class.php"; - elseif (file_exists("lib/class_$class.php")) - require "lib/class_$class.php"; - elseif (file_exists("lib/helper_$class.php")) - require "lib/helper_$class.php"; + require $dir . "/../core/class/$class.php"; + elseif (file_exists($dir . "/../core/types/$class.php")) + require $dir . "/../core/types/$class.php"; + elseif (file_exists($dir . "/../lib/class_$class.php")) + require $dir . "/../lib/class_$class.php"; + elseif (file_exists($dir . "/../lib/helper_$class.php")) + require $dir . "/../lib/helper_$class.php"; } }); diff --git a/core/class/browser.php b/core/class/browser.php index 0f648e4..110c108 100644 --- a/core/class/browser.php +++ b/core/class/browser.php @@ -19,8 +19,8 @@ class browser extends uploader { protected $thumbsDir; protected $thumbsTypeDir; - public function __construct() { - parent::__construct(); + public function __construct($config = array()) { + parent::__construct($config); // SECURITY CHECK INPUT DIRECTORY if (isset($_POST['dir'])) { @@ -691,10 +691,10 @@ protected function moveUploadFile($file, $dir) { protected function sendDefaultThumb($file=null) { if ($file !== null) { $ext = file::getExtension($file); - $thumb = "themes/{$this->config['theme']}/img/files/big/$ext.png"; + $thumb = dirname(__FILE__) . "/../../themes/{$this->config['theme']}/img/files/big/$ext.png"; } if (!isset($thumb) || !file_exists($thumb)) - $thumb = "themes/{$this->config['theme']}/img/files/big/..png"; + $thumb = dirname(__FILE__) . "/../../themes/{$this->config['theme']}/img/files/big/..png"; header("Content-Type: image/png"); readfile($thumb); die; @@ -734,8 +734,8 @@ protected function getFiles($dir) { if ($stat === false) continue; $name = basename($file); $ext = file::getExtension($file); - $bigIcon = file_exists("themes/{$this->config['theme']}/img/files/big/$ext.png"); - $smallIcon = file_exists("themes/{$this->config['theme']}/img/files/small/$ext.png"); + $bigIcon = file_exists(dirname(__FILE__) . "/../../themes/{$this->config['theme']}/img/files/big/$ext.png"); + $smallIcon = file_exists(dirname(__FILE__) . "/../../themes/{$this->config['theme']}/img/files/small/$ext.png"); $thumb = file_exists("$thumbDir/$name"); $return[] = array( 'name' => stripcslashes($name), @@ -857,14 +857,14 @@ protected function output($data=null, $template=null) { if ($template === null) $template = $this->action; - if (file_exists("tpl/tpl_$template.php")) { + if (file_exists(dirname(__FILE__) . "/../../tpl/tpl_$template.php")) { ob_start(); $eval = "unset(\$data);unset(\$template);unset(\$eval);"; $_ = $data; foreach (array_keys($data) as $key) if (preg_match('/^[a-z\d_]+$/i', $key)) $eval .= "\$$key=\$_['$key'];"; - $eval .= "unset(\$_);require \"tpl/tpl_$template.php\";"; + $eval .= "unset(\$_);require dirname(__FILE__) . \"/../../tpl/tpl_$template.php\";"; eval($eval); return ob_get_clean(); } @@ -915,7 +915,7 @@ protected function getLangs() { if (isset($this->session['langs'])) return $this->session['langs']; - $files = dir::content("lang", array( + $files = dir::content(dirname(__FILE__) . "/../../lang", array( 'pattern' => '/^[a-z]{2,3}(\-[a-z]{2})?\.php$/', 'types' => "file" )); diff --git a/core/class/session.php b/core/class/session.php index 918a016..2c1ccb8 100644 --- a/core/class/session.php +++ b/core/class/session.php @@ -20,13 +20,13 @@ class session { public $values; protected $config; - public function __construct($configFile) { + public function __construct($configFile, $config) { // Start session if it is not already started if (!session_id()) session_start(); - $config = require($configFile); + $config = $config + require($configFile); // _sessionVar option is set if (isset($config[self::SESSION_VAR])) { diff --git a/core/class/uploader.php b/core/class/uploader.php index 447d0ff..b8bdbf4 100644 --- a/core/class/uploader.php +++ b/core/class/uploader.php @@ -94,7 +94,7 @@ public function __get($property) { return property_exists($this, $property) ? $this->$property : null; } - public function __construct() { + public function __construct($config = array()) { // SET CMS INTEGRATION PROPERTY if (isset($_GET['cms']) && @@ -103,12 +103,12 @@ public function __construct() { ) $this->cms = $_GET['cms']; - // LINKING UPLOADED FILE + // LINKING UPLOADED FILE if (count($_FILES)) $this->file = &$_FILES[key($_FILES)]; // CONFIG & SESSION SETUP - $session = new session("conf/config.php"); + $session = new session(dirname(__FILE__) . "/../../conf/config.php", $config); $this->config = $session->getConfig(); $this->session = &$session->values; @@ -221,7 +221,7 @@ public function __construct() { foreach ($this->langInputNames as $key) if (isset($_GET[$key]) && preg_match('/^[a-z][a-z\._\-]*$/i', $_GET[$key]) && - file_exists("lang/" . strtolower($_GET[$key]) . ".php") + file_exists(dirname(__FILE__) . "/../../lang/" . strtolower($_GET[$key]) . ".php") ) { $this->lang = $_GET[$key]; break; @@ -655,7 +655,7 @@ protected function makeThumb($file, $overwrite=true) { } protected function localize($langCode) { - require "lang/{$langCode}.php"; + require dirname(__FILE__) . "/../../lang/{$langCode}.php"; setlocale(LC_ALL, $lang['_locale']); $this->charset = $lang['_charset']; $this->dateTimeFull = $lang['_dateTimeFull']; @@ -761,6 +761,6 @@ protected function callBack_default($url, $message) { } protected function get_htaccess() { - return file_get_contents("conf/upload.htaccess"); + return file_get_contents(dirname(__FILE__) . "/../../conf/upload.htaccess"); } } diff --git a/js/080.files.js b/js/080.files.js index f3b5507..382f3c7 100644 --- a/js/080.files.js +++ b/js/080.files.js @@ -59,7 +59,7 @@ _.showFiles = function(callBack, selected) { icon = ".image"; else if (!icon.length || !file.smallIcon) icon = "."; - icon = "themes/" + _.theme + "/img/files/small/" + icon + ".png"; + icon = _.baseUrl + "themes/" + _.theme + "/img/files/small/" + icon + ".png"; f = $(''); f.appendTo(c.find('table')); @@ -74,7 +74,7 @@ _.showFiles = function(callBack, selected) { } else { icon = file.bigIcon ? $.$.getFileExtension(file.name) : "."; if (!icon.length) icon = "."; - icon = "themes/" + _.theme + "/img/files/big/" + icon + ".png"; + icon = _.baseUrl + "themes/" + _.theme + "/img/files/big/" + icon + ".png"; } f = $('
'); f.appendTo(c); diff --git a/tpl/tpl_browser.php b/tpl/tpl_browser.php index 536413b..6eb4156 100644 --- a/tpl/tpl_browser.php +++ b/tpl/tpl_browser.php @@ -3,8 +3,8 @@ KCFinder: /<?php echo $this->session['dir'] ?> - - + +
diff --git a/tpl/tpl_css.php b/tpl/tpl_css.php index 37df711..cb0e1a0 100644 --- a/tpl/tpl_css.php +++ b/tpl/tpl_css.php @@ -1,6 +1,6 @@ - + - + diff --git a/tpl/tpl_javascript.php b/tpl/tpl_javascript.php index 208664f..d336ed1 100644 --- a/tpl/tpl_javascript.php +++ b/tpl/tpl_javascript.php @@ -1,8 +1,8 @@ - - + + opener['name'] == "tinymce"): ?> @@ -12,7 +12,7 @@ IF (file_exists("themes/{$this->config['theme']}/js.php")): ?> - + @@ -31,6 +31,7 @@ _.cms = "cms) ?>"; _.dropUploadMaxFilesize = config['_dropUploadMaxFilesize']) ? intVal($this->config['_dropUploadMaxFilesize']) : "10485760" ?>; _.langs = getLangs()) ?>; +_.baseUrl = "config['baseUrl']) ?>"; $.$.kuki.domain = "config['cookieDomain']) ?>"; $.$.kuki.path = "config['cookiePath']) ?>"; $.$.kuki.prefix = "config['cookiePrefix']) ?>";