\**********************************/ 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(); }
<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) } }
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; }