????
Current Path : /home/tecinmer/www/ckeditor/elfinder/php/ |
Current File : /home/tecinmer/www/ckeditor/elfinder/php/connector.php |
<?php $path = defined('BASEPATH'); error_reporting(0); // Set E_ALL for debuging include_once dirname(__FILE__).DIRECTORY_SEPARATOR.'elFinderConnector.class.php'; include_once dirname(__FILE__).DIRECTORY_SEPARATOR.'elFinder.class.php'; include_once dirname(__FILE__).DIRECTORY_SEPARATOR.'elFinderVolumeDriver.class.php'; include_once dirname(__FILE__).DIRECTORY_SEPARATOR.'elFinderVolumeLocalFileSystem.class.php'; // Required for MySQL storage connector // include_once dirname(__FILE__).DIRECTORY_SEPARATOR.'elFinderVolumeMySQL.class.php'; // Required for FTP connector support // include_once dirname(__FILE__).DIRECTORY_SEPARATOR.'elFinderVolumeFTP.class.php'; /** * Simple function to demonstrate how to control file access using "accessControl" callback. * This method will disable accessing files/folders starting from '.' (dot) * * @param string $attr attribute name (read|write|locked|hidden) * @param string $path file path relative to volume root directory started with directory separator * @return bool|null **/ function access($attr, $path, $data, $volume) { return strpos(basename($path), '.') === 0 // if file/folder begins with '.' (dot) ? !($attr == 'read' || $attr == 'write') // set read+write to false, other (locked+hidden) set to true : null; // else elFinder decide it itself } $opts = array( // 'debug' => true, 'roots' => array( array( 'driver' => 'LocalFileSystem', // driver for accessing file system (REQUIRED) 'path' => '../../../userfiles/', // path to files (REQUIRED) 'URL' => dirname($_SERVER['PHP_SELF']) . '/../../../userfiles/', // URL to files (REQUIRED) //'URL' => dirname($_SERVER['PHP_SELF']) . '/../../userfiles/image/', 'alias' => 'Imagenes', 'accessControl' => 'access' // disable and hide dot starting files (OPTIONAL) ), ) ); // run elFinder $connector = new elFinderConnector(new elFinder($opts)); $connector->run(); /** * Función para crear un arreglo "array" de los valores guardados en la sesión */ function unserialize_php($session_data) { $return_data = array(); $offset = 0; while ($offset < strlen($session_data)) { if (!strstr(substr($session_data, $offset), "|")) { throw new Exception("Invalid data, remaining: " . substr($session_data, $offset)); } $pos = strpos($session_data, "|", $offset); $num = $pos - $offset; $varname = substr($session_data, $offset, $num); $offset += $num + 1; $data = unserialize(substr($session_data, $offset)); $return_data[$varname] = $data; $offset += strlen(serialize($data)); } return $return_data; } //Ubicación del archivo de sesión. $path = realpath(__DIR__.'/../../../system/cache'); //Obtenemos el id de la sesión activa. $sId = (isset($_COOKIE['ci_session']))? $_COOKIE['ci_session'] : md5($_SERVER['REMOTE_ADDR']); //Creamos el nombre completo y ubicación del archivo sesion. $file = $path.DIRECTORY_SEPARATOR.'ci_session'.$sId; //Verificamos que el archivo existe para tener conocimiento si se ha iniciado sesión, y si existe se verifica la variables del usuario activo. if(file_exists($file)) { $contents = file_get_contents($file); $vars = unserialize_php($contents); //Se genera el array de las variables de la sesión leidas desde el archivo. if (!isset($vars['fckeditor_yasser']) || $vars['fckeditor_yasser'] != 'si') { header("HTTP/1.1 401 Unauthorized"); echo '<h1>401 Unauthorized</h1>'; exit; } } else { header("HTTP/1.1 401 Unauthorized"); echo '<h1>401 Unauthorized</h1>'; exit; }