function getFaxData($fax_id) { $path = Hylax::getVFSPath($fax_id); $file = $fax_id . '.ps'; try { return $this->_vfs->read($path, $file); } catch (Horde_Vfs_Exception $e) { Horde::log(sprintf("%s '%s/%s'.", $e->getMessage(), $path, $file), 'ERR'); throw $e; } }
/** * Garbage collect files in the VFS storage system. * * @param VFS $vfs The VFS object to perform garbage collection on. * @param string $path The VFS path to clean. * @param integer $secs The minimum amount of time (in seconds) required * before a file is removed. */ public static function gc($vfs, $path, $secs = 345600) { /* A 0.1% chance we will run garbage collection during a call. */ if (substr(time(), -3) !== '000') { return; } /* Use a backend-specific method if one exists. */ if (is_callable(array($vfs, 'gc'))) { $vfs->gc($path, $secs); } /* Make sure cleaning is done recursively. */ try { $modtime = time() - $secs; foreach ($vfs->listFolder($path, null, true, false, true) as $val) { if ($val['date'] < $modtime) { $vfs->deleteFile($path, $val['name']); } } } catch (Horde_Vfs_Exception $e) { } }
/** * Modifies a pine password record for a user. * * @param string $user The user whose record we will udpate. * @param string $newPassword The new password value to set. * * @throws Passwd_Exception */ protected function _modify($user, $newPassword) { for ($i = 0; $i < sizeof($this->_contents); $i++) { if ($this->_contents[$i][1] == $user && ($this->_contents[$i][2] == $this->_params['imaphost'] || !empty($this->_contents[$i][4]) && $this->_contents[$i][4] == $this->_params['imaphost'])) { $this->_contents[$i][0] = $newPassword; } } $string = $this->_encode($this->_contents); try { $this->_ftp->writeData($this->_params['path'], $this->_params['file'], $string); } catch (Horde_Vfs_Exception $e) { throw new Passwd_Exception($e); } }
/** * Does an FTP upload to save the configuration. */ function _uploadFTP($params) { global $registry, $notification; require_once HORDE_LIBS . 'VFS.php'; $vfs =& VFS::singleton('ftp', $params); if (is_a($vfs, 'PEAR_Error')) { $notification->push(sprintf(_("Could not connect to server '%s' using FTP: %s"), $params['hostspec'], $vfs->getMessage()), 'horde.error'); return false; } /* Loop through the config and write to FTP. */ $no_errors = true; foreach ($_SESSION['_config'] as $app => $config) { $path = $registry->getParam('fileroot', $app) . '/config'; $write = $vfs->writeData($path, 'conf.php', $config); if (is_a($write, 'PEAR_Error')) { $no_errors = false; $notification->push(sprintf(_("Could not write configuration for '%s': %s"), $app, $write->getMessage()), 'horde.error'); } else { $notification->push(sprintf(_("Successfully wrote %s"), $path . '/conf.php'), 'horde.success'); unset($_SESSION['_config'][$app]); } } return $no_errors; }
$auth =& Auth::singleton($conf['auth']['driver']); function _setValuesToKeys($in) { $out = array(); foreach ($in as $value) { $out[$value] = $value; } asort($out); return $out; } /* Set up VFS. */ require_once HORDE_LIBS . 'VFS.php'; $vfs_type = $conf['vfs']['type']; $vfs_args = Horde::getDriverConfig('vfs', $vfs_type); $vfs_args['user'] = Auth::getAuth(); $vfs =& VFS::singleton($vfs_type, $vfs_args); @define('TEMPLATES_VFS_PATH', '.horde_templates'); /* Require Horde_Form libs. */ require_once HORDE_LIBS . 'Horde/Form.php'; require_once HORDE_LIBS . 'Horde/Form/Renderer.php'; require_once HORDE_LIBS . 'Horde/Form/Action.php'; /* Set up Horde_Form. */ $vars =& Variables::getDefaultVariables(); $form =& Horde_Form::singleton('TemplatesForm', $vars); $action =& Horde_Form_Action::factory('submit'); /* Set up form fields. */ $apps = _setValuesToKeys($registry->listApps()); $select_app =& $form->addVariable(_("Application"), 'app', 'enum', true, false, null, array($apps)); $select_app->setAction($action); $form->addHidden('', 'old_app', 'text', false, false); /* Set up some variables. */
* 's' - the source, either the 'tmp' directory or VFS. * 'c' - which app's config to use for VFS, defaults to Horde. * 'n' - the name to set to the filename or default to same as filename. * 'a' - perform some action on the image, such as scaling. */ $file = basename(Util::getFormData('f')); $source = strtolower(Util::getFormData('s', 'tmp')); $app_conf = strtolower(Util::getFormData('c', 'horde')); $name = Util::getFormData('n', $file); $action = strtolower(Util::getFormData('a')); switch ($source) { case 'vfs': /* Change app if needed to get the right VFS config. */ $changed_conf = $registry->pushApp($app_conf); /* Getting a file from Horde's VFS. */ require_once HORDE_LIBS . 'VFS.php'; $vfs =& VFS::singleton($conf['vfs']['type'], Horde::getDriverConfig('vfs', $conf['vfs']['type'])); $path = Util::getFormData('p'); $file_data = $vfs->read($path, $file); if (is_a($file_data, 'PEAR_Error')) { Horde::logMessage(sprintf('Error displaying image [%s]: %s', $path . '/' . $file, $file_data->getMessage()), __FILE__, __LINE__, PEAR_LOG_ERR); exit; } /* Return the original app if changed previously. */ if ($changed_conf) { $registry->popApp($app_conf); } break; case 'tmp': /* Getting a file from Horde's temp dir. */ $tmpdir = Horde::getTempDir(); if (empty($action) || $action == 'resize') {