/**
  * Load your component.
  * 
  * @param \Cx\Core\ContentManager\Model\Entity\Page $page       The resolved page
  */
 public function load(\Cx\Core\ContentManager\Model\Entity\Page $page)
 {
     global $_CORELANG, $subMenuTitle, $objTemplate;
     switch ($this->cx->getMode()) {
         case \Cx\Core\Core\Controller\Cx::MODE_FRONTEND:
             $objDirectory = new Directory(\Env::get('cx')->getPage()->getContent());
             \Env::get('cx')->getPage()->setContent($objDirectory->getPage());
             $directory_pagetitle = $objDirectory->getPageTitle();
             if (!empty($directory_pagetitle)) {
                 \Env::get('cx')->getPage()->setTitle($directory_pagetitle);
                 \Env::get('cx')->getPage()->setContentTitle($directory_pagetitle);
                 \Env::get('cx')->getPage()->setMetaTitle($directory_pagetitle);
             }
             if ($_GET['cmd'] == 'detail' && isset($_GET['id'])) {
                 $objTemplate->setVariable(array('DIRECTORY_ENTRY_ID' => intval($_GET['id'])));
             }
             break;
         case \Cx\Core\Core\Controller\Cx::MODE_BACKEND:
             $this->cx->getTemplate()->addBlockfile('CONTENT_OUTPUT', 'content_master', 'LegacyContentMaster.html');
             $objTemplate = $this->cx->getTemplate();
             $subMenuTitle = $_CORELANG['TXT_LINKS_MODULE_DESCRIPTION'];
             $objDirectoryManager = new DirectoryManager();
             $objDirectoryManager->getPage();
             break;
         default:
             break;
     }
 }
Exemplo n.º 2
0
 /**
  * @name delete This function can delete a folder completely
  * 	You can specify some values to only empty or only empty him files (and subdirectories)
  * 	So this function give a lot of possibilites
  * @param string $dir Directory to delete
  * @param boolean $myself If is true, delete himself
  * @param boolean $deleteDirs If is true delete subfolders too
  * @param boolean $recursive If is true, it will do it recursivelly (seraching in each subfolder)
  * @param number $dateOld Seconds minimum since it was created to can delete directory/file. If is 0 it will be deleted instead
  * 	time() - 24 * 60 * 60; // Delete files with 24 hours of antique
  * 	time() - strtotime("-1 day");
  * 	You can put the number negative to delete only FILES NEWERS THAN
  * @param array $exceptions Specify name of files/directories to not delete
  * 	WARNING: IT DON'T RECOGNIZE * or ?, ONLY FULL NAMES
  * @param boolean $subdir Internal function var (DON'T CHANGE IT)
  * @return boolean WARNING: It can return "false" but it can be deleted any 
  * 
  * @example
  * DirectoryManager::delete('directorio', true); // It don't do nothing (for safety reasons)
  * DirectoryManager::delete('directorio', false, true, true); // Delete all content except the main directory
  * DirectoryManager::delete('directorio', true, true, true); // Delete directory and all content
  * DirectoryManager::delete('directorio', false, true, false, 0); // Delete only all files from main directory
  * DirectoryManager::delete('directorio', false, true, true, 60); // Delete only files from any directory with minimum 1 minute of life 
  * DirectoryManager::delete('directorio', false, true, true, 60, array('notdelete')); // Delete ALL content except folders or files called EXACTLY "notdelete" 
  */
 static function delete($dir, $myself = false, $deleteDirs = true, $recursive = false, $dateOld = 0, $exceptions = array(), $subdir = false)
 {
     // Mask for CHMOD
     umask(00);
     // Is not a directory
     if (!is_dir($dir) and !is_file($dir)) {
         return true;
     }
     // If is the main directory...
     if (!$subdir) {
         // If are vars incoherent...
         if ($myself and (!$deleteDirs or !$recursive or $dateOld > 0 or !empty($exceptions))) {
             die('The parameters given to the function of removing directories are incorrect. <br /> You may not want to delete the directory WITHOUT deleting the content.');
         }
         // Adding exceptions "." (myself) and ".." (parent)
         array_push($exceptions, ".", "..");
     }
     if (substr($dir, -1) != "/") {
         $dir .= "/";
     }
     // End slash if is not present
     $contenido = array_diff(scandir($dir), $exceptions);
     // Read all files and directories without exceptions
     if ($dateOld != 0) {
         $time = time();
     }
     // Current time to date old
     foreach ($contenido as $item) {
         $target = $dir . $item;
         // Current directory/file
         chmod($target, 0777);
         if (is_dir($target)) {
             // If is a directory reload this function changing "position" to do recursivity
             // If the directory have to self delete it will do once end the next function
             if ($recursive) {
                 DirectoryManager::delete($target, $deleteDirs, $deleteDirs, $recursive, $dateOld, $exceptions, true);
             }
         } else {
             // Is a file
             if ($dateOld == 0 or $time - filemtime($target) > $dateOld) {
                 unlink($target);
             }
         }
     }
     // Deleting directory if is fully empty
     if ($myself) {
         $contenido = array_diff(scandir($dir), array(".", ".."));
         // Load all content dir
         if (empty($contenido)) {
             return rmdir($dir);
         }
     }
     return false;
 }
Exemplo n.º 3
0
 public function __construct()
 {
     global $IP;
     self::$dirBase = $IP;
     global $wgCapitalLinks;
     $wgCapitalLinks = false;
     $this->filePattern = null;
     $this->dirPattern = null;
     $this->linePattern = null;
     global $wgMessageCache;
     foreach (self::$msg as $key => $value) {
         $wgMessageCache->addMessages(self::$msg[$key], $key);
     }
 }
Exemplo n.º 4
0
<?php

if (empty($_SESSION['id'])) {
    session_start();
}
ini_set('memory_limit', '1024M');
require 'Session.php';
require 'DirectoryManager.php';
$session = new Session();
$directory = new DirectoryManager();
$session->init();
if (isset($_POST)) {
    /*************************************
     *** GET PICTURE ***
     ************************************/
    //Variables
    $path = (string) filter_input(INPUT_GET, 'path');
    $extension = (string) filter_input(INPUT_GET, 'extension');
    $type = (string) filter_input(INPUT_GET, 'type');
    //Set session and directory
    $id = $session->getId();
    //"/media/Temp/1234/1234.yyy"
    $simplePath = $path . $id . DIRECTORY_SEPARATOR . $id . '.' . $extension;
    //"C:/xxxx/media/Temp/1234"
    $basePath = (string) $_SERVER['DOCUMENT_ROOT'] . $path . $id;
    //"C:/xxxx/media/Temp/1234/1234.yyy"
    $baseFilename = (string) $basePath . DIRECTORY_SEPARATOR . $id . '.' . $extension;
    //Search inside "C:/xxxx/media/Temp/1234" directory
    $directory->setDirectoryIterator($basePath);
    //Get media
    $media = file_get_contents('php://input');
Exemplo n.º 5
0
			<script type="text/javascript">
				window.___gcfg = {lang: 'fr'};
				
				(function() {
					var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
					po.src = 'https://apis.google.com/js/plusone.js';
					var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
				})();
			</script>
			<!--/GOOGLE-->
			<?php 
$preload = new SimpleBlockComponent();
$preload->setID("preload");
$preload->setClass("hidden");
$dir = "styles/" . $_SESSION[STYLE] . "/images/";
$descStack = DirectoryManager::getContent($dir, true);
$files = array();
while (!empty($descStack)) {
    $descriptor = array_pop($descStack);
    if ($descriptor['type'] === 'file') {
        $files[] = $dir . $descriptor['name'];
    } else {
        if ($descriptor['type'] === 'directory') {
            foreach ($descriptor['content'] as $sub) {
                $sub['name'] = $descriptor['name'] . '/' . $sub['name'];
                array_push($descStack, $sub);
            }
        } else {
            // ignore others (not recognized)
        }
    }
Exemplo n.º 6
0
\**********************************/
session_start();
if (isset($_GET[MODE_H])) {
    $_SESSION[MODE_H] = $_GET[MODE_H];
    $url = Url::getCurrentUrl();
    $url->removeQueryVar(MODE_H);
    header('Location: ' . $url->toString());
    exit;
} else {
    if (!isset($_SESSION[MODE_H])) {
        $_SESSION[MODE_H] = false;
    } else {
        // let the state as is
    }
}
$dirs = DirectoryManager::getContent("styles");
$styles = array();
foreach ($dirs as $info) {
    $styles[] = $info['name'];
}
if (!isset($_SESSION[STYLE])) {
    $_SESSION[STYLE] = null;
} else {
    // keep it as is
}
$_SESSION[STYLE] = Check::getInputIn(isset($_GET[STYLE]) ? $_GET[STYLE] : $_SESSION[STYLE], $styles, "default");
if (TEST_MODE_ACTIVATED && Url::getCurrentUrl()->hasQueryVar('setdate')) {
    $_SESSION[CURRENT_TIME] = Url::getCurrentUrl()->getQueryVar('setdate');
} else {
    $_SESSION[CURRENT_TIME] = time();
}
Exemplo n.º 7
0
 * 
 * This script will be executed some time (every 24 hours for example).
 * It will do some tasks like delete depecrated cache, etc...
 */
// Configuring server
error_reporting(E_ALL);
set_time_limit(-1);
// Load KernelWeb main core
include '../../KernelWeb/rel/main.php';
// Start loader time
ServerStatus::calcTime();
/*
 * CONFIGURATIONS 
 */
// CACHE
$dir_cache = kw::$app_dir . 'cache';
$max_life_cache = 86400;
/*
 * HERE GOES THE CRON 
 */
// CACHE
// Delete depecreated cache (with more than 24 h)
// If you wish, you can specify some directorys to not delete
echo "Deleting cache in with more than : " . $dir_cache . "<br />\n";
DirectoryManager::delete($dir_cache, false, true, true, $max_life_cache);
/*
 * END CRON
*/
// End test time
echo "\n\n<br /><br /><hr />";
ServerStatus::calcTime();
<?php

/**
 * Internationalisation file for AutoRedirect extension.
 *
 * $Id$
 * 
*/
DirectoryManager::$msg = array();
DirectoryManager::$msg['en'] = array('directorymanager' . 'title' => 'Directory Manager', 'directorymanager' . 'view' => 'View directory <i>$1</i>', 'directorymanager' . '-template' => '	<filepattern>[[Filesystem:$1]]</filepattern>
	<dirpattern>{{#directory:$1|$1}}</dirpattern>
	<linepattern>$1<br/></linepattern>

	<b>Directory Listing</b>
<br/>
');
 public static function getContent($path, $recursive = false, $sorting = array(), $ignore = array('.', '..'))
 {
     $directory = @opendir($path);
     if ($directory === false) {
         throw new ErrorException("Impossible d'ouvrir le dossier '{$path}'.", E_USER_ERROR);
     }
     // safe formating
     $lastIndex = strlen($path) - 1;
     if (in_array($path[$lastIndex], array('/', '\\'))) {
         $path = substr($path, 0, $lastIndex);
     }
     // browsing of the directory
     $list = array();
     while ($file = readdir($directory)) {
         if (!in_array($file, $ignore)) {
             $element = array();
             $file_path = $path . '/' . $file;
             $element['name'] = $file;
             if (is_file($file_path)) {
                 $element['type'] = 'file';
             } elseif (is_dir($file_path)) {
                 $element['type'] = 'directory';
                 if ($recursive) {
                     $element['content'] = DirectoryManager::getContent($file_path, $recursive, $sorting, $ignore);
                 }
             } else {
                 $element['type'] = 'unknown';
             }
             $element['size'] = filesize($file_path);
             $element['access'] = 0;
             $element['access'] += is_readable($file_path) ? 4 : 0;
             $element['access'] += is_writable($file_path) ? 2 : 0;
             $element['access'] += is_executable($file_path) ? 1 : 0;
             $list[] = $element;
         }
     }
     closedir($directory);
     // sorting
     if (!empty($sorting)) {
         // data formating
         $sort_order = array();
         $last_sort = NULL;
         foreach ($sorting as $key => $direction) {
             switch ($key) {
                 case DM_SORT_NAME:
                     $last_sort = 'name';
                     break;
                 case DM_SORT_TYPE:
                     $last_sort = 'type';
                     break;
                 case DM_SORT_SIZE:
                     $last_sort = 'size';
                     break;
                 default:
                     throw new ErrorException("Bad formating of the sorting type: " . $key, E_USER_ERROR);
             }
             switch ($direction) {
                 case SORT_ASC:
                 case SORT_DESC:
                     $sort_order[$last_sort] = $direction;
                     break;
                 default:
                     throw new ErrorException("Bad formating of the sorting direction: " . $direction, E_USER_ERROR);
             }
         }
         // sorting phase
         if (!empty($sort_order)) {
             $sort = array();
             $sort_direction = array();
             $i = 0;
             foreach ($sort_order as $key => $direction) {
                 $sort_direction[$i] = $sort_order[$key];
                 foreach ($list as $num => $row) {
                     $sort[$i][$num] = strtolower($row[$key]);
                 }
                 ++$i;
             }
             switch ($i) {
                 case 1:
                     array_multisort($sort[0], $sort_direction[0], $list);
                     break;
                 case 2:
                     array_multisort($sort[0], $sort_direction[0], $sort[1], $sort_direction[1], $list);
                     break;
                 case 3:
                     array_multisort($sort[0], $sort_direction[0], $sort[1], $sort_direction[1], $sort[2], $sort_direction[2], $list);
                     break;
                 default:
             }
         }
     }
     // sorted list
     return $list;
 }