forked from civicrm/civicrm-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '5.19.4-cividesk' of https://github.com/cividesk/civicrm…
…-core into 5.19.4-cividesk
- Loading branch information
Showing
2 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--- a/packages/kcfinder/integration/civicrm.php | ||
+++ b/packages/kcfinder/integration/civicrm.php | ||
@@ -69,6 +69,9 @@ | ||
case 'Drupal8': | ||
$auth_function = 'authenticate_drupal8'; | ||
break; | ||
+ case 'Standalone': | ||
+ $auth_function = 'authenticate_standalone'; | ||
+ break; | ||
} | ||
if(!$auth_function($config)) { | ||
CRM_Core_Error::fatal(ts("You must be logged in with proper permissions to edit, add, or delete uploaded images.")); | ||
@@ -205,6 +208,17 @@ | ||
return true; | ||
} | ||
|
||
+function authenticate_standalone($config) { | ||
+ session_start(); | ||
+ // make sure user has access to civicrm | ||
+ CRM_Utils_System::loadBootStrap(); | ||
+ require_once "CRM/Core/Permission.php"; | ||
+ if (CRM_Core_Permission::check('access CiviCRM')) { | ||
+ return true; | ||
+ } | ||
+ return false; | ||
+} | ||
+ | ||
checkAuthentication( ); | ||
|
||
//spl_autoload_register('__autoload'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
--- a/packages/kcfinder/core/class/uploader.php | ||
+++ b/packages/kcfinder/core/class/uploader.php | ||
@@ -227,18 +227,18 @@ | ||
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']) | ||
+ $this->config['uploadDir'] = $this->realpath(strlen($this->config['uploadDir']) | ||
? path::normalize($this->config['uploadDir']) | ||
- : path::url2fullPath("/$path"); | ||
- $this->typeDir = "{$this->config['uploadDir']}/{$this->type}"; | ||
+ : path::url2fullPath("/$path")); | ||
+ $this->typeDir = $this->realpath("{$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']) | ||
+ $this->config['uploadDir'] = $this->realpath(strlen($this->config['uploadDir']) | ||
? path::normalize($this->config['uploadDir']) | ||
- : path::normalize($_SERVER['DOCUMENT_ROOT']); | ||
- $this->typeDir = "{$this->config['uploadDir']}/{$this->type}"; | ||
+ : path::normalize(realpath($_SERVER['DOCUMENT_ROOT']))); | ||
+ $this->typeDir = $this->realpath("{$this->config['uploadDir']}/{$this->type}"); | ||
$this->typeURL = "/{$this->type}"; | ||
|
||
// ABSOLUTE & RELATIVE | ||
@@ -246,10 +246,10 @@ | ||
$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']) | ||
+ $this->config['uploadDir'] = $this->realpath(strlen($this->config['uploadDir']) | ||
? path::normalize($this->config['uploadDir']) | ||
- : path::url2fullPath($this->config['uploadURL']); | ||
- $this->typeDir = "{$this->config['uploadDir']}/{$this->type}"; | ||
+ : path::url2fullPath($this->config['uploadURL'])); | ||
+ $this->typeDir = $this->realpath("{$this->config['uploadDir']}/{$this->type}"); | ||
$this->typeURL = "{$this->config['uploadURL']}/{$this->type}"; | ||
} | ||
|
||
@@ -324,6 +324,20 @@ | ||
} | ||
} | ||
|
||
+ protected function realpath($path) { | ||
+ // PHP's realpath() does not work on files that don't exist, but | ||
+ // there might be a symlink somewhere in the path so we need to | ||
+ // check it. | ||
+ $existing_path = $path; | ||
+ while (!file_exists($existing_path)) { | ||
+ $existing_path = dirname($existing_path); | ||
+ } | ||
+ $rPath = realpath($existing_path) . substr($path, strlen($existing_path)); | ||
+ if (strtoupper(substr(PHP_OS, 0, 3)) == "WIN") | ||
+ $rPath = str_replace("\\", "/", $rPath); | ||
+ return $rPath; | ||
+ } | ||
+ | ||
public function upload() { | ||
$config = &$this->config; | ||
$file = &$this->file; | ||
@@ -418,9 +432,7 @@ | ||
} | ||
|
||
protected function checkFilePath($file) { | ||
- $rPath = realpath($file); | ||
- if (strtoupper(substr(PHP_OS, 0, 3)) == "WIN") | ||
- $rPath = str_replace("\\", "/", $rPath); | ||
+ $rPath = $this->realpath($file); | ||
return (substr($rPath, 0, strlen($this->typeDir)) === $this->typeDir); | ||
} | ||
|