isRestricted() public static method

Check if the given item is restricted from being shown.
public static isRestricted ( string $where ) : boolean
$where string The current file path.
return boolean Is item allowed to be displayed?
Example #1
0
 /**
  * Global variables defined:
  *   $chora_conf
  *   $sourceroots
  */
 protected function _init()
 {
     global $acts, $conf, $defaultActs, $where, $atdir, $fullname, $sourceroot, $page_output;
     // TODO: If chora isn't fully/properly setup, init() will throw fatal
     // errors. Don't want that if this class is being loaded simply to
     // obtain basic chora application information.
     $initial_app = $GLOBALS['registry']->initialApp == 'chora';
     try {
         $GLOBALS['sourceroots'] = Horde::loadConfiguration('backends.php', 'sourceroots');
     } catch (Horde_Exception $e) {
         $GLOBALS['sourceroots'] = array();
         if (!$initial_app) {
             return;
         }
         $GLOBALS['notification']->push($e);
     }
     $sourceroots = Chora::sourceroots();
     /**
      * Variables we wish to propagate across web pages
      *  ha  = Hide Attic Files
      *  ord = Sort order
      *  sbt = Sort By Type (name, age, author, etc)
      *
      * Obviously, defaults go into $defaultActs :)
      * TODO: defaults of 1 will not get propagated correctly - avsm
      * XXX: Rewrite this propagation code, since it sucks - avsm
      */
     $defaultActs = $acts = array('onb' => 0, 'ord' => Horde_Vcs::SORT_ASCENDING, 'rev' => 0, 'rt' => null, 'sa' => 0, 'sbt' => constant($conf['options']['defaultsort']), 'ws' => 1);
     /* See if any actions have been passed as form variables, and if so,
      * assign them into the acts array. */
     $vars = Horde_Variables::getDefaultVariables();
     foreach (array_keys($acts) as $key) {
         if (isset($vars->{$key})) {
             $acts[$key] = $vars->{$key};
         }
     }
     /* Use the value of the 'rt' form value for the sourceroot. If not
      * present, use the last sourceroot used as the default value if the
      * user has that preference. Otherwise, use default sourceroot. */
     $last_sourceroot = $GLOBALS['prefs']->getValue('last_sourceroot');
     if (is_null($acts['rt'])) {
         if (!empty($last_sourceroot) && !empty($sourceroots[$last_sourceroot]) && is_array($sourceroots[$last_sourceroot])) {
             $acts['rt'] = $last_sourceroot;
         } else {
             foreach ($sourceroots as $key => $val) {
                 if (!isset($acts['rt']) || isset($val['default'])) {
                     $acts['rt'] = $key;
                     break;
                 }
             }
             if (is_null($acts['rt'])) {
                 if ($initial_app) {
                     Chora::fatal(new Chora_Exception(_("No repositories found.")));
                 }
                 return;
             }
         }
     }
     if (!isset($sourceroots[$acts['rt']])) {
         if ($initial_app) {
             Chora::fatal(new Chora_Exception(sprintf(_("The repository with the slug '%s' was not found"), $acts['rt'])));
         }
         return;
     }
     $sourcerootopts = $sourceroots[$acts['rt']];
     $sourceroot = $acts['rt'];
     /* Store last repository viewed */
     if ($acts['rt'] != $last_sourceroot) {
         $GLOBALS['prefs']->setValue('last_sourceroot', $acts['rt']);
     }
     // Cache.
     $cache = empty($conf['caching']) ? null : $GLOBALS['injector']->getInstance('Horde_Cache');
     $GLOBALS['chora_conf'] = array('cvsusers' => $sourcerootopts['location'] . '/' . (isset($sourcerootopts['cvsusers']) ? $sourcerootopts['cvsusers'] : ''), 'introText' => CHORA_BASE . '/config/' . (isset($sourcerootopts['intro']) ? $sourcerootopts['intro'] : ''), 'introTitle' => isset($sourcerootopts['title']) ? $sourcerootopts['title'] : '', 'sourceRootName' => $sourcerootopts['name']);
     $chora_conf =& $GLOBALS['chora_conf'];
     $GLOBALS['VC'] = Horde_Vcs::factory(Horde_String::ucfirst($sourcerootopts['type']), array('cache' => $cache, 'sourceroot' => $sourcerootopts['location'], 'paths' => array_merge($conf['paths'], array('temp' => Horde::getTempDir())), 'username' => isset($sourcerootopts['username']) ? $sourcerootopts['username'] : '', 'password' => isset($sourcerootopts['password']) ? $sourcerootopts['password'] : ''));
     if (!$initial_app) {
         return;
     }
     $where = Horde_Util::getFormData('f', '/');
     /* Location relative to the sourceroot. */
     $where = preg_replace(array('|^/|', '|\\.\\.|'), '', $where);
     $fullname = $sourcerootopts['location'] . (substr($sourcerootopts['location'], -1) == '/' ? '' : '/') . $where;
     if ($sourcerootopts['type'] == 'cvs') {
         $fullname = preg_replace('|/$|', '', $fullname);
         $atdir = @is_dir($fullname);
     } else {
         $atdir = !$where || substr($where, -1) == '/';
     }
     $where = preg_replace('|/$|', '', $where);
     if ($sourcerootopts['type'] == 'cvs' && !@is_dir($sourcerootopts['location'])) {
         Chora::fatal(new Chora_Exception(_("Sourceroot not found. This could be a misconfiguration by the server administrator, or the server could be having temporary problems. Please try again later.")));
     }
     if (Chora::isRestricted($where)) {
         Chora::fatal(new Chora_Exception(sprintf(_("%s: Forbidden by server configuration"), $where)));
     }
 }
Example #2
0
    foreach ($dirList as $currentDir) {
        if ($conf['hide_restricted'] && Chora::isRestricted($currentDir)) {
            continue;
        }
        $url = Chora::url('browsedir', $where . '/' . $currentDir . '/', $branchArgs);
        $currDir = $injector->getInstance('Horde_Core_Factory_TextFilter')->filter($currentDir, 'space2html', array('encode' => true, 'encode_all' => true));
        require CHORA_TEMPLATES . '/directory/dir.inc';
    }
    echo '</tbody>';
}
/* Display all of the files in this directory */
$readmes = array();
if ($fileList) {
    echo '<tbody>';
    foreach ($fileList as $currFile) {
        if ($conf['hide_restricted'] && Chora::isRestricted($currFile->getFileName())) {
            continue;
        }
        $lg = $currFile->getLastLog();
        $realname = $currFile->getFileName();
        $mimeType = Horde_Mime_Magic::filenameToMIME($realname);
        $currFile->mimeType = $mimeType;
        if (Horde_String::lower(Horde_String::substr($realname, 0, 6)) == 'readme') {
            $readmes[] = $currFile;
        }
        $icon = $injector->getInstance('Horde_Core_Factory_MimeViewer')->getIcon($mimeType);
        $author = Chora::showAuthorName($lg->getAuthor());
        $filerev = $lg->getRevision();
        $date = $lg->getDate();
        $log = $lg->getMessage();
        $attic = $currFile->isDeleted();
Example #3
0
// Load the Horde Framework core, and set up inclusion paths.
require_once HORDE_BASE . '/lib/core.php';
// Registry
$registry =& Registry::singleton();
if (is_a($pushed = $registry->pushApp('chora', !defined('AUTH_HANDLER')), 'PEAR_Error')) {
    if ($pushed->getCode() == 'permission_denied') {
        Horde::authenticationFailureRedirect();
    }
    Horde::fatal($pushed, __FILE__, __LINE__, false);
}
$conf =& $GLOBALS['conf'];
@define('CHORA_TEMPLATES', $registry->getParam('templates'));
// Notification system.
$notification =& Notification::singleton();
$notification->attach('status');
// Find the base file path of Chora.
@define('CHORA_BASE', dirname(__FILE__) . '/..');
// Horde base libraries.
require_once HORDE_LIBS . 'Horde/Text.php';
require_once HORDE_LIBS . 'Horde/Help.php';
// Chora libraries and config.
require_once CHORA_BASE . '/config/sourceroots.php';
require_once CHORA_BASE . '/lib/Chora.php';
require_once HORDE_LIBS . 'Horde/VC.php';
// Initialize objects, path, etc.
Chora::init();
if (Chora::isRestricted($where)) {
    Chora::fatal('403 Forbidden', "{$where}: Forbidden by server configuration");
}
/* Start compression, if requested. */
Horde::compressOutput();