Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add integration/authentication for Yii1 framework running on php8 server. #8

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/class/session.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ private function initSession()
$session = & $this->config[self::SESSION_VAR];

if (!is_array($session) && !$session instanceof \Traversable) {
$session = $this->getDefaultSession()[$session];
$session = $this->getDefaultSession()[$session] ?? [];

if (!is_array($session)) {
$session = array();
Expand Down
2 changes: 1 addition & 1 deletion core/types/type_mime.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
class type_mime {

public function checkFile($file, array $config) {
if (!class_exists("finfo"))
if (!extension_loaded("fileinfo"))
return "Fileinfo PECL extension is missing.";

if (!isset($config['params']))
Expand Down
42 changes: 42 additions & 0 deletions integration/Yii.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php namespace kcfinder\integration;

class Yii {
protected static $authenticated = null;
static function checkAuthentication() {
if (self::$authenticated !== null) {
return self::authenticated;
}
$current_cwd = getcwd();
chdir('..');
include './vendor/autoload.php';
$dir = dirname(__DIR__, 2);
\Yii::createWebApplication($dir . '/protected/config/main.php');
$state = \Yii::app()->user->getState('id');

if ($state === null) {
// not authenticated
self::$authenticated = false;
return false;
}
/*
* Intentionally don't restore pwd if not authenticated, so that file
* system related functionality is only for authenticated users.
*/
chdir($current_cwd);
if (!isset($_SESSION['KCFINDER'])) {
$_SESSION['KCFINDER'] = array();
}
if (!isset($_SESSION['KCFINDER']['disabled'])) {
$_SESSION['KCFINDER']['disabled'] = false;
}
$_SESSION['KCFINDER']['_check4htaccess'] = false;
$_SESSION['KCFINDER']['uploadURL'] = $_SERVER['KCFINDER_UPLOAD_URL'];
$_SESSION['KCFINDER']['uploadDir'] = $_SERVER['KCFINDER_UPLOAD_DIR'];
$_SESSION['KCFINDER']['theme'] = 'default';
self::$authenticated = true;
return true;
}
}
if (!\kcfinder\integration\Yii::checkAuthentication()) {
die("NOT AUTHORISED. SESSION TIMED OUT.");
}
4 changes: 2 additions & 2 deletions lib/class_image.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ final protected function buildImage($image) {
$img = $image->image;

} elseif (is_array($image)) {
list($key, $width) = each($image);
list($key, $height) = each($image);
$width = $image[0];
$height = $image[1];
$img = $this->getBlankImage($width, $height);

} else
Expand Down
2 changes: 1 addition & 1 deletion lib/class_image_gd.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ protected function getImage($image, &$width, &$height) {
// PSEUDO-ABSTRACT STATIC METHODS

static function available() {
return function_exists("imagecreatefromjpeg");
return extension_loaded('gd');
}

static function checkImage($file) {
Expand Down
2 changes: 1 addition & 1 deletion lib/class_image_gmagick.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ protected function getImage($image, &$width, &$height) {
// PSEUDO-ABSTRACT STATIC METHODS

static function available() {
return class_exists("Gmagick");
return extension_loaded("gmagick");
}

static function checkImage($file) {
Expand Down
2 changes: 1 addition & 1 deletion lib/class_image_imagick.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ protected function getImage($image, &$width, &$height) {
// PSEUDO-ABSTRACT STATIC METHODS

static function available() {
return class_exists("\\Imagick");
return extension_loaded("imagick");
}

static function checkImage($file) {
Expand Down
2 changes: 1 addition & 1 deletion lib/helper_file.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ static function getExtension($filename, $toLower=true) {
* @return string */

static function getMimeType($filename, $magic=null) {
if (class_exists("finfo")) {
if (extension_loaded("fileinfo")) {
$finfo = new \finfo(FILEINFO_MIME, $magic);
if ($finfo) {
$mime = $finfo->file($filename);
Expand Down
2 changes: 1 addition & 1 deletion tpl/tpl_javascript.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
?>
<script type="text/javascript">
_.version = "<?php echo self::VERSION ?>";
_.support.zip = <?php echo (class_exists('ZipArchive') && !$this->config['denyZipDownload']) ? "true" : "false" ?>;
_.support.zip = <?php echo (extension_loaded('zip') && !$this->config['denyZipDownload']) ? "true" : "false" ?>;
_.support.check4Update = <?php echo ((!isset($this->config['denyUpdateCheck']) || !$this->config['denyUpdateCheck']) && (ini_get("allow_url_fopen") || function_exists("http_get") || function_exists("curl_init") || function_exists('socket_create'))) ? "true" : "false" ?>;
_.lang = "<?php echo text::jsValue($this->lang) ?>";
_.type = "<?php echo text::jsValue($this->type) ?>";
Expand Down