First commit
This commit is contained in:
commit
c6e2478c40
13918 changed files with 2303184 additions and 0 deletions
|
@ -0,0 +1,43 @@
|
|||
<?php namespace kcfinder\cms;
|
||||
|
||||
/** This file is part of KCFinder project
|
||||
*
|
||||
* @desc CMS integration code: BolmerCMS
|
||||
* @package KCFinder
|
||||
* @version 3.12
|
||||
* @author Borisov Evgeniy <modx@agel-nash.ru>
|
||||
* @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
|
||||
*/
|
||||
class BolmerCMS{
|
||||
protected static $authenticated = false;
|
||||
static function checkAuth() {
|
||||
$current_cwd = getcwd();
|
||||
if ( ! self::$authenticated) {
|
||||
define('BOLMER_API_MODE', true);
|
||||
define('IN_MANAGER_MODE', true);
|
||||
$init = realpath(dirname(dirname(dirname(dirname(dirname(dirname(__FILE__))))))."/index.php");
|
||||
include_once($init);
|
||||
$type = getService('user', true)->getLoginUserType();
|
||||
if($type=='manager'){
|
||||
self::$authenticated = true;
|
||||
if (!isset($_SESSION['KCFINDER'])) {
|
||||
$_SESSION['KCFINDER'] = array();
|
||||
}
|
||||
if(!isset($_SESSION['KCFINDER']['disabled'])) {
|
||||
$_SESSION['KCFINDER']['disabled'] = false;
|
||||
}
|
||||
$_SESSION['KCFINDER']['_check4htaccess'] = false;
|
||||
$_SESSION['KCFINDER']['uploadURL'] = '/assets/';
|
||||
$_SESSION['KCFINDER']['uploadDir'] = BOLMER_BASE_PATH.'assets/';
|
||||
$_SESSION['KCFINDER']['theme'] = 'default';
|
||||
}
|
||||
}
|
||||
|
||||
chdir($current_cwd);
|
||||
return self::$authenticated;
|
||||
}
|
||||
}
|
||||
\kcfinder\cms\BolmerCMS::checkAuth();
|
|
@ -0,0 +1,144 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2016 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
* This file handles integration of KCFinder with wysiwyg editors
|
||||
* supported by CiviCRM
|
||||
* Ckeditor and tinyMCE
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2016
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
function checkAuthentication() {
|
||||
static $authenticated;
|
||||
if ( !isset( $authenticated ) ) {
|
||||
$current_cwd = getcwd();
|
||||
$civicrm_root = dirname(dirname(getcwd()));
|
||||
$authenticated = false;
|
||||
require_once "{$civicrm_root}/civicrm.config.php";
|
||||
require_once 'CRM/Core/Config.php';
|
||||
|
||||
$config = CRM_Core_Config::singleton();
|
||||
|
||||
if ( !isset($_SESSION['KCFINDER'] ) ) {
|
||||
$_SESSION['KCFINDER'] = array();
|
||||
}
|
||||
|
||||
$auth_function = null;
|
||||
switch ($config->userFramework) {
|
||||
case 'Drupal':
|
||||
case 'Drupal6':
|
||||
$auth_function = 'authenticate_drupal';
|
||||
break;
|
||||
case 'Joomla':
|
||||
$auth_function = 'authenticate_joomla';
|
||||
break;
|
||||
case 'WordPress':
|
||||
$auth_function = 'authenticate_wordpress';
|
||||
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."));
|
||||
}
|
||||
|
||||
$_SESSION['KCFINDER']['disabled'] = false;
|
||||
$_SESSION['KCFINDER']['uploadURL'] = $config->imageUploadURL;
|
||||
$_SESSION['KCFINDER']['uploadDir'] = $config->imageUploadDir;
|
||||
|
||||
$authenticated = true;
|
||||
chdir( $current_cwd );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If the user is already logged into Drupal, bootstrap
|
||||
* drupal with this user's permissions. Thanks to integrate/drupal.php
|
||||
* script for hints on how to do this.
|
||||
**/
|
||||
function authenticate_drupal($config) {
|
||||
global $base_url;
|
||||
$base_root = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https' : 'http';
|
||||
$base_url = $base_root .= '://'. preg_replace('/[^a-z0-9-:._]/i', '', $_SERVER['HTTP_HOST']);
|
||||
|
||||
if ($dir = trim(dirname($_SERVER['SCRIPT_NAME']), '\,/')) {
|
||||
$base_path = "/$dir";
|
||||
$base_url .= $base_path;
|
||||
}
|
||||
|
||||
// correct base_url so it points to Drupal root
|
||||
$pos = strpos($base_url, '/sites/');
|
||||
if ($pos === FALSE) {
|
||||
$pos = strpos($base_url, '/profiles/');
|
||||
}
|
||||
$base_url = substr($base_url, 0, $pos); // drupal root absolute url
|
||||
|
||||
CRM_Utils_System::loadBootStrap(CRM_Core_DAO::$_nullArray,true,false);
|
||||
|
||||
// check if user has access permission...
|
||||
if (CRM_Core_Permission::check('access CiviCRM')) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function authenticate_wordpress($config) {
|
||||
// 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;
|
||||
}
|
||||
|
||||
function authenticate_joomla($config) {
|
||||
// make sure only logged in user can see upload / view images
|
||||
$joomlaBase = dirname(dirname(dirname(dirname(dirname(dirname(dirname(dirname(__FILE__))))))));
|
||||
|
||||
define( '_JEXEC', 1 );
|
||||
define('JPATH_BASE', $joomlaBase);
|
||||
define( 'DS', DIRECTORY_SEPARATOR );
|
||||
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
|
||||
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
|
||||
|
||||
$mainframe = JFactory::getApplication('administrator');
|
||||
$mainframe->initialise();
|
||||
|
||||
if (JFactory::getUser()->id == 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
checkAuthentication( );
|
||||
|
||||
//spl_autoload_register('__autoload');
|
||||
|
||||
?>
|
|
@ -0,0 +1,113 @@
|
|||
<?php
|
||||
|
||||
/** This file is part of KCFinder project
|
||||
*
|
||||
* @desc CMS integration code: Drupal
|
||||
* @package KCFinder
|
||||
* @version 3.12
|
||||
* @author Dany Alejandro Cabrera <otello2040@gmail.com>
|
||||
* @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
|
||||
*/
|
||||
|
||||
// gets a valid drupal_path
|
||||
function get_drupal_path() {
|
||||
if (!empty($_SERVER['SCRIPT_FILENAME'])) {
|
||||
$drupal_path = dirname(dirname(dirname(dirname($_SERVER['SCRIPT_FILENAME']))));
|
||||
if (!file_exists($drupal_path . '/includes/bootstrap.inc')) {
|
||||
$drupal_path = dirname(dirname(dirname($_SERVER['SCRIPT_FILENAME'])));
|
||||
$depth = 2;
|
||||
do {
|
||||
$drupal_path = dirname($drupal_path);
|
||||
$depth++;
|
||||
} while (!($bootstrap_file_found = file_exists($drupal_path . '/includes/bootstrap.inc')) && $depth < 10);
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($bootstrap_file_found) || !$bootstrap_file_found) {
|
||||
$drupal_path = '../../../../..';
|
||||
if (!file_exists($drupal_path . '/includes/bootstrap.inc')) {
|
||||
$drupal_path = '../..';
|
||||
do {
|
||||
$drupal_path .= '/..';
|
||||
$depth = substr_count($drupal_path, '..');
|
||||
} while (!($bootstrap_file_found = file_exists($drupal_path . '/includes/bootstrap.inc')) && $depth < 10);
|
||||
}
|
||||
}
|
||||
return $drupal_path;
|
||||
}
|
||||
|
||||
function CheckAuthentication($drupal_path) {
|
||||
|
||||
static $authenticated;
|
||||
|
||||
if (!isset($authenticated)) {
|
||||
|
||||
if (!isset($bootstrap_file_found) || $bootstrap_file_found) {
|
||||
$current_cwd = getcwd();
|
||||
if (!defined('DRUPAL_ROOT')){
|
||||
define('DRUPAL_ROOT', $drupal_path);
|
||||
}
|
||||
|
||||
// Simulate being in the drupal root folder so we can share the session
|
||||
chdir(DRUPAL_ROOT);
|
||||
|
||||
global $base_url;
|
||||
$base_root = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https' : 'http';
|
||||
$base_url = $base_root .= '://'. preg_replace('/[^a-z0-9-:._]/i', '', $_SERVER['HTTP_HOST']);
|
||||
|
||||
if ($dir = trim(dirname($_SERVER['SCRIPT_NAME']), '\,/')) {
|
||||
$base_path = "/$dir";
|
||||
$base_url .= $base_path;
|
||||
}
|
||||
|
||||
// correct base_url so it points to Drupal root
|
||||
$pos = strpos($base_url, '/sites/');
|
||||
$base_url = substr($base_url, 0, $pos); // drupal root absolute url
|
||||
|
||||
// If we aren't in a Drupal installation, or if Drupal path hasn't been properly found, die
|
||||
if(!file_exists(DRUPAL_ROOT . '/includes/bootstrap.inc')) {
|
||||
die("The CMS integration service for -drupal- requires KCFinder to be properly placed inside your Drupal installation.");
|
||||
}
|
||||
|
||||
|
||||
// bootstrap
|
||||
require_once(DRUPAL_ROOT . '/includes/bootstrap.inc');
|
||||
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
|
||||
|
||||
// if user has access permission...
|
||||
if (user_access('access kcfinder')) {
|
||||
if (!isset($_SESSION['KCFINDER'])) {
|
||||
$_SESSION['KCFINDER'] = array();
|
||||
$_SESSION['KCFINDER']['disabled'] = false;
|
||||
}
|
||||
|
||||
// User has permission, so make sure KCFinder is not disabled!
|
||||
if(!isset($_SESSION['KCFINDER']['disabled'])) {
|
||||
$_SESSION['KCFINDER']['disabled'] = false;
|
||||
}
|
||||
|
||||
global $user;
|
||||
$_SESSION['KCFINDER']['uploadURL'] = strtr(variable_get('kcfinder_upload_url', 'sites/default/files/kcfinder'), array('%u' => $user->uid, '%n' => $user->name));
|
||||
$_SESSION['KCFINDER']['uploadDir'] = strtr(variable_get('kcfinder_upload_dir', ''), array('%u' => $user->uid, '%n' => $user->name));
|
||||
$_SESSION['KCFINDER']['theme'] = variable_get('kcfinder_theme', 'oxygen');
|
||||
|
||||
//echo '<br />uploadURL: ' . $_SESSION['KCFINDER']['uploadURL']<br />;
|
||||
//echo '<br />uploadDir: ' . $_SESSION['KCFINDER']['uploadDir']<br />;
|
||||
|
||||
chdir($current_cwd);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
chdir($current_cwd);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CheckAuthentication(get_drupal_path());
|
||||
|
||||
?>
|
Loading…
Add table
Add a link
Reference in a new issue