public static function cleanupSessionSavePath()
 {
     $f = new Folder(session_save_path());
     while ($e = $f->getEntry()) {
         if (0 === strncmp('sess_', $e, 5)) {
             unlink($f->getURI() . $e);
         }
     }
 }
Esempio n. 2
0
 /**
  * Get a file
  *
  * @param   string filename
  * @return  org.webdav.WebdavObject
  * @throws  lang.ElementNotFoundException
  * @throws  org.webdav.OperationNotAllowedException
  */
 public function get($filename, $token = NULL)
 {
     $this->c->debug('FILENAME', $filename);
     $this->c->debug('TOKEN', $token);
     $filename = $this->_normalizePath($filename);
     // check for lock
     $lockinfo = $this->getLockInfo($filename);
     if ($lockinfo and $lockinfo['type'] == 'exclusive' and 'opaquelocktoken:' . $lockinfo['token'] != $token) {
         throw new IllegalArgumentException($filename . ' is locked exclusive');
     }
     if (is_dir($this->base . $filename)) {
         $this->c->debug(get_class($this), '::GET Dir', $filename);
         $f = new Folder($this->base . $filename);
         if (!$f->exists()) {
             throw new ElementNotFoundException($filename . ' not found');
         }
         while ($maxdepth >= 0 && ($entry = $f->getEntry())) {
             $isdir = is_dir($this->base . $filename . '/' . $entry);
             $atime = date('H:i:s  d.m.y', fileatime($this->base . $filename . '/' . $entry));
             if ($isdir) {
                 $flist[0][$entry] .= sprintf('
         <tr>
         <td><a href="%s/">%s</a></td>
         <td>&lt;DIR&gt;</td>
         <td>%s</td>
         <td>&nbsp;&nbsp;</td>
         </tr> 
         ', rawurlencode($entry), $entry, $atime);
             } else {
                 $flist[1][$entry] .= sprintf('
         <tr>
         <td><a href="%s">%s</a></td>
         <td>&nbsp;&nbsp;&nbsp;</td>
         <td>%s</td>
         <td>%s Bytes</td>
         </tr> 
         ', rawurlencode($entry), $entry, $atime, filesize($this->base . $filename . '/' . $entry));
             }
         }
         asort($flist[0]);
         $html = '<table cellpadding=3>' . (strlen($filename) > 2 ? '<tr><td><a href="../">..</a></td><td>&lt;DIR&gt;</tr>' : '') . implode('', $flist[0]);
         asort($flist[1]);
         $flist = $html . implode('', $flist[1]) . '</table>';
         $o = new WebdavObject($f->uri, NULL, strlen($flist), 'text/html', new Date(filectime($f->uri)), new Date(filemtime($f->uri)));
         $o->setData($flist);
         $f->close();
         return $o;
     }
     $this->c->debug(get_class($this), '::GET filename', $filename);
     $this->c->debug(get_class($this), '::GET base', $this->base);
     // Open file and read contents
     // contentype
     if (!file_exists($this->base . $filename)) {
         throw new ElementNotFoundException($filename . ' not found');
     }
     $f = new File($this->base . $filename);
     $contentType = '';
     $this->c->debug(get_class($this), '::get ', $this->base . filename);
     $eProps = $this->propStorage->getProperties($f->uri);
     if (!empty($eProps['getcontenttype'])) {
         $contentType = $eProps['getcontenttype'][0];
     }
     if (empty($contentType)) {
         $contentType = MimeType::getByFilename($f->uri, 'text/plain');
     }
     $o = new WebdavObject($f->uri, NULL, $f->size(), $contentType, new Date($f->createdAt()), new Date($f->lastModified()));
     try {
         $f->open(FILE_MODE_READ);
         $o->setData($f->read($f->size()));
         $f->close();
     } catch (FileFoundException $e) {
         throw new ElementNotFoundException($filename . ' not found');
     }
     $this->c->debug('OBJ', $o->properties);
     return $o;
 }
Esempio n. 3
0
$propertyFile = $param->exists('conf') ? $param->value('conf') : 'core_fonts.ini';
$pattern = basename($search);
$base = dirname($search);
printf("===> Start for %s [allfiles %s]\n", $base, $pattern);
$prop = new Properties($propertyFile);
if (!$prop->exists()) {
    try {
        printf("---> Creating configfile %s\n", $propertyFile);
        $prop->create();
    } catch (IOException $e) {
        $e->printStackTrace();
        exit;
    }
}
// Verzeichnis durchsuchen
$d = new Folder($base);
while ($e = $d->getEntry()) {
    if (is_dir($d->uri . '/' . $e) || !preg_match('/' . $pattern . '/', $e)) {
        continue;
    }
    printf("---> Saving fontdef for %s to %s\n", $e, $propertyFile);
    writeFontDef($d->uri . '/' . $e, $prop);
}
$d->close();
// Property-File schreiben
try {
    $prop->save();
} catch (IOException $e) {
    $e->printStackTrace();
}
delete($prop);
 /**
  * Gets the count of messages with speciefied attribute
  * or all messages when no attribute was specified
  *
  * @param   peer.mail.Mailfolder f
  * @param   int attr default 0xFFFF
  * @return  int count
  */
 public function getMessageCount($f, $attr = 0xffff)
 {
     $this->openFolder($f);
     $f = new Folder($f->name . DIRECTORY_SEPARATOR . 'cur');
     if (!$f->exists()) {
         return 0;
     }
     $cnt = 0;
     $f->open();
     while ($e = $f->getEntry()) {
         if ($attr & $this->_getMailFlags($e)) {
             $cnt++;
         }
     }
     $f->close();
     return $cnt;
 }
Esempio n. 5
0
 /**
  * Read the selected directory's content
  *
  */
 public function readFiles()
 {
     $f = new Folder($this->dir);
     // Disable Up button if we are at top
     $this->buttons['up']->set_sensitive(strlen($this->dir) > 1);
     // Update entry
     $entry = $this->combo->entry;
     $entry->set_text($f->uri);
     // Update list
     $this->files->freeze();
     $this->files->clear();
     try {
         while ($entry = $f->getEntry()) {
             $icon = $mask = NULL;
             if ($dir = is_dir($f->uri . $entry)) {
                 // Set folder icon
                 $icon = $this->pixmaps['p:folder'];
                 $mask = $this->pixmaps['m:folder'];
             } else {
                 if (!preg_match(':' . $this->filter . ':i', $entry)) {
                     continue;
                 }
                 $ext = '(n/a)';
                 if (FALSE !== ($p = strrpos($entry, '.')) && $p > 0) {
                     $ext = substr($entry, $p + 1);
                 }
                 // Check for "special" files
                 if (preg_match('#README|TODO|INSTALL|COPYRIGHT|NEWS#', $entry)) {
                     $idx = 'special.readme';
                 } else {
                     $idx = isset($this->pixmaps['p:ext.' . $ext]) ? 'ext.' . $ext : 'none';
                 }
                 // Set icon
                 $icon = $this->pixmaps['p:' . $idx];
                 $mask = $this->pixmaps['m:' . $idx];
             }
             // Get file owner's name
             // !!! TBD: Generic approach, posix_getpwuid may not exist !!!
             $owner = posix_getpwuid(fileowner($f->uri . $entry));
             $this->files->set_pixtext($this->files->append(array($entry, $dir ? '' : $ext, $this->_size(filesize($f->uri . $entry)), date('Y-m-d H:i', filemtime($f->uri . $entry)), $owner['name'], substr(sprintf("%o", fileperms($f->uri . $entry)), 3 - $dir))), 0, $entry, 4, $icon, $mask);
         }
         // Copy folder's URI (will be full path)
         $this->dir = $f->uri;
         $f->close();
     } catch (IOException $e) {
         $e->printStackTrace();
     }
     $this->files->sort();
     $this->files->thaw();
 }