Skip to content
This repository has been archived by the owner on Feb 23, 2021. It is now read-only.

Commit

Permalink
3.20-test2
Browse files Browse the repository at this point in the history
* jQuery adapter added
* Session handling improvements. Now `_sessionVar` option could get
arrays by reference
* Session related ini options in `conf/config.php` are removed and no
more supported
* Removed redundant closing tags in PHP files
  • Loading branch information
sunhater committed Aug 24, 2014
1 parent 2a36d5a commit 4d10cb9
Show file tree
Hide file tree
Showing 65 changed files with 99 additions and 203 deletions.
2 changes: 0 additions & 2 deletions browse.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,3 @@
$browser = "kcfinder\\browser"; // To execute core/bootstrap.php on older
$browser = new $browser(); // PHP versions (even PHP 4)
$browser->action();

?>
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "sunhater/kcfinder",
"description": "KCFinder web file manager",
"version": "3.20-test1",
"version": "3.20-test2",
"type": "library",
"keywords": [
"kcfinder",
Expand Down
15 changes: 3 additions & 12 deletions conf/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
even if you are using session configuration.
See http://kcfinder.sunhater.com/install for setting descriptions */

$_CONFIG = array(
return array(


// GENERAL SETTINGS
Expand Down Expand Up @@ -108,20 +108,11 @@

// THE FOLLOWING SETTINGS CANNOT BE OVERRIDED WITH SESSION SETTINGS

'_normalizeFilenames' => false,
'_sessionVar' => "KCFINDER",
'_check4htaccess' => true,
'_normalizeFilenames' => false,
'_dropUploadMaxFilesize' => 10485760,
//'_tinyMCEPath' => "/tiny_mce",

'_sessionVar' => "KCFINDER",
//'_sessionLifetime' => 30,
//'_sessionDir' => "/full/directory/path",
//'_sessionDomain' => ".mysite.com",
//'_sessionPath' => "/my/path",

//'_cssMinCmd' => "java -jar /path/to/yuicompressor.jar --type css {file}",
//'_jsMinCmd' => "java -jar /path/to/yuicompressor.jar --type js {file}",

);

?>
12 changes: 2 additions & 10 deletions core/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,8 @@
list($ns, $class) = $path;

if ($ns == "kcfinder") {

if ($class == "uploader")
require "core/class/uploader.php";
elseif ($class == "browser")
require "core/class/browser.php";
elseif ($class == "minifier")
require "core/class/minifier.php";

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"))
Expand All @@ -37,5 +31,3 @@
require "lib/helper_$class.php";
}
});

?>
2 changes: 0 additions & 2 deletions core/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,5 +177,3 @@ public function gc($maxlifetime) {


// PUT YOUR ADDITIONAL CODE HERE

?>
2 changes: 0 additions & 2 deletions core/class/browser.php
Original file line number Diff line number Diff line change
Expand Up @@ -936,5 +936,3 @@ protected function getLangs() {
return $langs;
}
}

?>
9 changes: 3 additions & 6 deletions core/class/minifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,12 @@ class minifier {
);

public function __construct($type=null) {
require "conf/config.php";
$this->config = $_CONFIG;
$this->config = require("conf/config.php");
$type = strtolower($type);
if (isset($this->mime[$type]))
$this->type = $type;
if (isset($_CONFIG["_{$this->type}MinCmd"]))
$this->minCmd = $_CONFIG["_{$this->type}MinCmd"];
if (isset($this->config["_{$this->type}MinCmd"]))
$this->minCmd = $this->config["_{$this->type}MinCmd"];
}

public function minify($cacheFile=null, $dir=null) {
Expand Down Expand Up @@ -110,5 +109,3 @@ public function minify($cacheFile=null, $dir=null) {

}
}

?>
76 changes: 76 additions & 0 deletions core/class/session.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?php

/** This file is part of KCFinder project
*
* @desc Session class
* @package KCFinder
* @version 3.12
* @author Pavel Tzonkov <[email protected]>
* @copyright 2010-2014 KCFinder Project
* @license http://opensource.org/licenses/GPL-3.0 GPLv3
* @license http://opensource.org/licenses/LGPL-3.0 LGPLv3
* @link http://kcfinder.sunhater.com
*/

namespace kcfinder;

class session {

const SESSION_VAR = "_sessionVar";
public $values;
protected $config;

public function __construct($configFile) {

// Start session if it is not already started
if (!session_id())
session_start();

$config = require($configFile);

// _sessionVar option is set
if (isset($config[self::SESSION_VAR])) {
$session = &$config[self::SESSION_VAR];

// _sessionVar option is string
if (is_string($session))
$session = &$_SESSION[$session];

if (!is_array($session))
$session = array();

// Use global _SESSION array if _sessionVar option is not set
} else
$session = &$_SESSION;

// Securing the session
$stamp = array(
'ip' => $_SERVER['REMOTE_ADDR'],
'agent' => md5($_SERVER['HTTP_USER_AGENT'])
);
if (!isset($session['stamp']))
$session['stamp'] = $stamp;
elseif (!is_array($session['stamp']) || ($session['stamp'] !== $stamp)) {
// Destroy session if user agent is different (e.g. after browser update)
if ($session['stamp']['ip'] === $stamp['ip'])
session_destroy();
die;
}

// Load session configuration
foreach ($config as $key => $val)
$this->config[$key] = ((substr($key, 0, 1) != "_") && isset($session[$key]))
? $session[$key]
: $val;

// Session data goes to 'self' element
if (!isset($session['self']))
$session['self'] = array();
$this->values = &$session['self'];
}

public function getConfig() {
return $this->config;
}

}
61 changes: 5 additions & 56 deletions core/class/uploader.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
class uploader {

/** Release version */
const VERSION = "3.20-test1";
const VERSION = "3.20-test2";

/** Config session-overrided settings
* @var array */
Expand Down Expand Up @@ -107,59 +107,10 @@ public function __construct() {
if (count($_FILES))
$this->file = &$_FILES[key($_FILES)];

// LOAD DEFAULT CONFIGURATION
require "conf/config.php";

// SETTING UP SESSION
if (!session_id()) {
if (isset($_CONFIG['_sessionLifetime']))
ini_set('session.gc_maxlifetime', $_CONFIG['_sessionLifetime'] * 60);
if (isset($_CONFIG['_sessionDir']))
ini_set('session.save_path', $_CONFIG['_sessionDir']);
if (isset($_CONFIG['_sessionDomain']))
ini_set('session.cookie_domain', $_CONFIG['_sessionDomain']);
session_start();
}

// LOAD SESSION CONFIGURATION IF EXISTS
$this->config = $_CONFIG;
$sessVar = "_sessionVar";
if (isset($_CONFIG[$sessVar])) {

$sessVar = $_CONFIG[$sessVar];

if (!isset($_SESSION[$sessVar]))
$_SESSION[$sessVar] = array();

$sessVar = &$_SESSION[$sessVar];

if (!is_array($sessVar))
$sessVar = array();

foreach ($sessVar as $key => $val)
if ((substr($key, 0, 1) != "_") && isset($_CONFIG[$key]))
$this->config[$key] = $val;

if (!isset($sessVar['self']))
$sessVar['self'] = array();

$this->session = &$sessVar['self'];

} else
$this->session = &$_SESSION;

// SECURING THE SESSION
$stamp = array(
'ip' => $_SERVER['REMOTE_ADDR'],
'agent' => md5($_SERVER['HTTP_USER_AGENT'])
);
if (!isset($this->session['stamp']))
$this->session['stamp'] = $stamp;
elseif (!is_array($this->session['stamp']) || ($this->session['stamp'] !== $stamp)) {
if ($this->session['stamp']['ip'] === $stamp['ip'])
session_destroy();
die;
}
// CONFIG & SESSION SETUP
$session = new session("conf/config.php");
$this->config = $session->getConfig();
$this->session = &$session->values;

// IMAGE DRIVER INIT
if (isset($this->config['imageDriversPriority'])) {
Expand Down Expand Up @@ -813,5 +764,3 @@ protected function get_htaccess() {
return file_get_contents("conf/upload.htaccess");
}
}

?>
2 changes: 0 additions & 2 deletions core/types/type_img.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,3 @@ public function checkFile($file, array $config) {
return true;
}
}

?>
2 changes: 0 additions & 2 deletions core/types/type_mime.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,3 @@ public function checkFile($file, array $config) {
: true;
}
}

?>
2 changes: 0 additions & 2 deletions css/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,3 @@
require "core/autoload.php";
$min = new minifier("css");
$min->minify("cache/base.css");

?>
7 changes: 7 additions & 0 deletions doc/Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
3.20-test2: 2014-08-24
----------------------
* jQuery adapter added
* Session handling improvements. Now `_sessionVar` option could get arrays by reference
* Session related ini options in `conf/config.php` are removed and no more supported
* Removed redundant closing tags in PHP files

3.20-test1: 2014-08-19
----------------------
* "`DOCUMENT_ROOT` is symlink" bugfix
Expand Down
3 changes: 0 additions & 3 deletions index.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
<?php

require "browse.php";

?>
2 changes: 0 additions & 2 deletions integration/drupal.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,5 +109,3 @@ function CheckAuthentication($drupal_path) {
}

CheckAuthentication(get_drupal_path());

?>
2 changes: 0 additions & 2 deletions js/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,3 @@
require "core/autoload.php";
$min = new minifier("js");
$min->minify("cache/base.js");

?>
2 changes: 0 additions & 2 deletions js_localize.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,3 @@
}

echo "}";

?>
2 changes: 0 additions & 2 deletions lang/af.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,5 +244,3 @@
"Select Thumbnails" => "Kies duimnaels",
"Download files" => "Laai lêers af",
);

?>
2 changes: 0 additions & 2 deletions lang/bg.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,5 +276,3 @@
"Uploaded {uploaded} of {total}" => "Качено {uploaded} от общо {total}",
"Errors:" => "Грешки:"
);

?>
2 changes: 0 additions & 2 deletions lang/ca.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,5 +126,3 @@
"Uploading file {number} of {count}... {progress}" => "Carregant arxiu {number} de {count}... {progress}",
"Failed to upload {filename}!" => "Error al carregar {filename}",
);

?>
2 changes: 0 additions & 2 deletions lang/cs.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,5 +130,3 @@
"Confirmation" => "Potvrzení",
"Warning" => "Varování",
);

?>
2 changes: 0 additions & 2 deletions lang/da.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,5 +125,3 @@
"Uploading file {number} of {count}... {progress}" => "Uploader fil {number} af {count} ... {progress}",
"Failed to upload {filename}!" => "Kunne ikke uploade {filename}!",
);

?>
2 changes: 0 additions & 2 deletions lang/de.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,5 +130,3 @@
"Confirmation" => "Bestätigung",
"Warning" => "Warnung"
);

?>
2 changes: 0 additions & 2 deletions lang/el.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,5 +130,3 @@
"Confirmation" => "Επιβεβαίωση",
"Warning" => "Προειδοποίηση",
);

?>
2 changes: 0 additions & 2 deletions lang/en.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,3 @@
'_dateTimeMid' => "%a %b %e %Y %I:%M %p",
'_dateTimeSmall' => "%m/%d/%Y %I:%M %p",
);

?>
2 changes: 0 additions & 2 deletions lang/es.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,5 +125,3 @@
"Uploading file {number} of {count}... {progress}" => "Cargando archivo {number} de {count}... {progress}",
"Failed to upload {filename}!" => "¡No se pudo cargar el archivo {filename}!",
);

?>
2 changes: 0 additions & 2 deletions lang/et.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,5 +125,3 @@
"Uploading file {number} of {count}... {progress}" => "Laen üles faili {number} {count}-st... {progress}",
"Failed to upload {filename}!" => "{filename} üleslaadimine ebaõnnestus!",
);

?>
Loading

0 comments on commit 4d10cb9

Please sign in to comment.