Beispiel #1
0
 /**
  * List all packages (aka folders).
  */
 function packages($app = 'saf')
 {
     if ($app == 'saf') {
         $dir = 'saf/lib';
     } else {
         $dir = 'inc/app/' . $app . '/lib';
     }
     $packages = array();
     $files = Dir::fetch($dir);
     foreach ($files as $k => $v) {
         if ($v == 'CVS' || $v == '.' || $v == '..' || $v == 'PEAR' || $v == 'Ext' || $v == 'Zend') {
             unset($files[$k]);
             continue;
         } elseif (strpos($v, '_') === 0) {
             unset($files[$k]);
             continue;
         }
         if (strpos($files[$k], '.php') !== false) {
             $pkg = $app . '.' . array_shift(explode('.', $files[$k]));
         } else {
             $pkg = $app . '.' . $v;
         }
         if (!in_array($pkg, $packages)) {
             $packages[] = $pkg;
         }
     }
     return $packages;
 }
Beispiel #2
0
function sitegallery_first_image($path)
{
    loader_import('saf.File.Directory');
    $valid = appconf('valid');
    $files = Dir::fetch($path, true);
    foreach ($files as $file) {
        $info = pathinfo($file);
        if (in_array($info['extension'], $valid)) {
            $path = preg_replace('|^pix/|', '', $path);
            return $path . '/' . $file;
        }
    }
    return false;
}
Beispiel #3
0
}
if ($parameters['ctype'] == 'all') {
    unset($parameters['ctype']);
}
if ($parameters['domains'] == 'all') {
    unset($parameters['domains']);
}
if ($cgi->multiple == 'yes') {
    $multiple = true;
} else {
    $multiple = false;
}
$sitesearch_allowed = array();
$sitesearch_highlight = array();
loader_import('saf.File.Directory');
foreach (Dir::fetch('inc/app/cms/conf/collections') as $file) {
    if (strpos($file, '.') === 0 || @is_dir('inc/app/cms/conf/collections/' . $file)) {
        continue;
    }
    $config = ini_parse('inc/app/cms/conf/collections/' . $file);
    if (isset($config['Collection']['sitesearch_url'])) {
        if (isset($config['Collection']['sitesearch_access']) && session_allowed($config['Collection']['sitesearch_access'], 'r', 'access')) {
            $sitesearch_allowed[] = $config['Collection']['name'];
        }
        $sitesearch_highlight[$config['Collection']['name']] = $config['Collection']['name'];
        if (isset($config['Collection']['sitesearch_highlight']) && !$config['Collection']['sitesearch_highlight']) {
            unset($sitesearch_highlight[$config['Collection']['name']]);
        }
    }
}
$folders = ini_parse('inc/app/sitesearch/conf/folders.ini.php');
Beispiel #4
0
     shell_exec('wget -m -w 2 -E -P tmp/ http://' . $info['domain'] . ' > /dev/null 2>&1');
     // 2. set $info['folder']
     $info['folder'] = 'tmp/' . $info['domain'];
     // 3. set $info['prefix'] as $info['domain']
     $info['prefix'] = 'http://' . $info['domain'];
     // 4. proceed with what's below
 // 4. proceed with what's below
 case 'folder':
 default:
     $files = array();
     $folders = array_merge(array($info['folder']), Dir::getStruct($info['folder']));
     foreach ($folders as $folder) {
         if (preg_match('/CVS$/', $folder)) {
             continue;
         }
         $list = Dir::fetch($folder);
         foreach ($list as $f) {
             if (strpos($f, '.') === 0 || @is_dir($folder . '/' . $f)) {
                 continue;
             } elseif (preg_match('/\\.(jpg|png|gif|css|js)$/i', $f)) {
                 continue;
             }
             $pref = str_replace($info['folder'], '', $folder);
             if (!preg_match('|/$|', $pref)) {
                 $pref .= '/';
             }
             if ($info['type'] == 'site' && $info['sitellite']) {
                 $files[$folder . '/' . $f] = $info['prefix'] . $pref . preg_replace('/\\.html$/i', '', $f);
             } else {
                 $files[$folder . '/' . $f] = $info['prefix'] . $pref . $f;
             }
Beispiel #5
0
     header('Content-Length: ' . strlen($info->body));
     header('Content-Disposition: attachment; filename=' . basename($path));
     echo $info->body;
     exit;
     break;
 case 'list':
     $path = webfiles_request();
     if (!is_dir($prefix . $path)) {
         webfiles_error(404, 'Not found');
     }
     $obj = new StdClass();
     $obj->root = $path . '/';
     $obj->files = array();
     $folder_list = array();
     $file_list = array();
     $files = Dir::fetch($prefix . $path, true);
     foreach ($files as $file) {
         if ($file == 'CVS') {
             continue;
         }
         if (is_dir($prefix . $path . '/' . $file)) {
             $folder_list[] = (object) array('type' => 'httpd/unix-directory', 'name' => $path . '/' . $file, 'created' => filectime($prefix . $path . '/' . $file), 'modified' => filemtime($prefix . $path . '/' . $file), 'lock' => webfiles_lock($path . '/' . $file));
         } else {
             $info = $rex->getCurrent(ltrim($path . '/' . $file, '/'));
             unset($info->name);
             unset($info->body);
             if (!session_allowed($info, 'rw')) {
                 continue;
             }
             $file_list[] = (object) array('type' => mime($file), 'name' => $path . '/' . $file, 'size' => $info->filesize, 'created' => $info->date_created, 'modified' => $info->last_modified, 'keywords' => $info->keywords, 'description' => $info->description, 'access' => $info->sitellite_access, 'status' => $info->sitellite_status, 'team' => $info->sitellite_team, 'owner' => $info->sitellite_owner, 'lock' => webfiles_lock($path . '/' . $file));
         }
Beispiel #6
0
 /**
  * Returns the "structure" of the filesystem below the specified path.
  * This is a list of sub-directories, recursively.
  *
  * @access	public
  * @param	string	$path
  * @return	array	files
  *
  */
 function getStruct($path)
 {
     $struct = array();
     $files = Dir::fetch($path);
     foreach ($files as $file) {
         if (strpos($file, '.') === 0 || !@is_dir($path . '/' . $file)) {
             continue;
         }
         $struct[] = $path . '/' . $file;
         foreach (Dir::getStruct($path . '/' . $file) as $file) {
             $struct[] = $file;
         }
     }
     return $struct;
 }