/** * 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') {