getTempDir() public static method

Determines the location of the system temporary directory. If a specific configuration cannot be found, it defaults to /tmp.
public static getTempDir ( ) : string
return string A directory name that can be used for temp files. Returns false if one could not be found.
Esempio n. 1
0
 /**
  * @throws Horde_Exception
  */
 public function create(Horde_Injector $injector)
 {
     if (empty($GLOBALS['conf']['timezone']['location'])) {
         throw new Horde_Exception('Timezone database location is not configured');
     }
     return new Horde_Timezone(array('cache' => $injector->getInstance('Horde_Cache'), 'location' => $GLOBALS['conf']['timezone']['location'], 'temp' => Horde::getTempDir()));
 }
Esempio n. 2
0
 /**
  * Gets the configuration for a MIME type.
  *
  * @param string $type  The MIME type.
  * @param string $app   The current Horde application.
  *
  * @return array  The driver and a list of configuration parameters.
  */
 public function getViewerConfig($type, $app)
 {
     $config = $this->_getDriver($type, $app);
     $config['driver'] = Horde_String::ucfirst($config['driver']);
     $driver = $config['app'] == 'horde' ? $config['driver'] : $config['app'] . '_Mime_Viewer_' . $config['driver'];
     $params = array_merge($config, array('charset' => 'UTF-8', 'temp_file' => array('Horde', 'getTempFile'), 'text_filter' => array($this->_injector->getInstance('Horde_Core_Factory_TextFilter'), 'filter')));
     switch ($config['driver']) {
         case 'Deb':
         case 'Rpm':
             $params['monospace'] = 'fixed';
             break;
         case 'Html':
             $params['browser'] = $GLOBALS['browser'];
             $params['dns'] = $this->_injector->getInstance('Net_DNS2_Resolver');
             $params['external_callback'] = array('Horde', 'externalUrl');
             break;
         case 'Ooo':
             $params['temp_dir'] = Horde::getTempDir();
             $params['zip'] = Horde_Compress::factory('Zip');
             break;
         case 'Rar':
             $params['monospace'] = 'fixed';
             $params['rar'] = Horde_Compress::factory('Rar');
             break;
         case 'Report':
         case 'Security':
             $params['viewer_callback'] = array($this, 'getViewerCallback');
             break;
         case 'Syntaxhighlighter':
             if ($config['app'] == 'horde') {
                 $driver = 'Horde_Core_Mime_Viewer_Syntaxhighlighter';
             }
             $params['registry'] = $GLOBALS['registry'];
             break;
         case 'Tgz':
             $params['gzip'] = Horde_Compress::factory('Gzip');
             $params['monospace'] = 'fixed';
             $params['tar'] = Horde_Compress::factory('Tar');
             break;
         case 'Tnef':
             $params['tnef'] = Horde_Compress::factory('Tnef');
             break;
         case 'Vcard':
             if ($config['app'] == 'horde') {
                 $driver = 'Horde_Core_Mime_Viewer_Vcard';
             }
             $params['browser'] = $GLOBALS['browser'];
             $params['notification'] = $GLOBALS['notification'];
             $params['prefs'] = $GLOBALS['prefs'];
             $params['registry'] = $GLOBALS['registry'];
             break;
         case 'Zip':
             $params['monospace'] = 'fixed';
             $params['zip'] = Horde_Compress::factory('Zip');
             break;
     }
     return array($this->_getDriverName($driver, 'Horde_Mime_Viewer'), $params);
 }
Esempio n. 3
0
 /**
  * Sends an RPC request to the server and returns the result.
  *
  * @param string $request  The raw request string.
  *
  * @return string  The XML encoded response from the server.
  */
 function getResponse($request)
 {
     $backendparms = array('debug_dir' => Horde::getTempDir() . '/sync', 'debug_files' => true, 'log_level' => 'DEBUG');
     /* Create the backend. */
     $GLOBALS['backend'] = Horde_SyncMl_Backend::factory('Horde', $backendparms);
     /* Handle request. */
     $h = new Horde_SyncMl_ContentHandler();
     $response = $h->process($request, $this->getResponseContentType(), Horde::url($GLOBALS['registry']->get('webroot', 'horde') . '/rpc.php', true, -1));
     /* Close the backend. */
     $GLOBALS['backend']->close();
     return $response;
 }
Esempio n. 4
0
 /**
  */
 public function __construct(array $params = array())
 {
     global $injector;
     try {
         $vfs = $injector->getInstance('Horde_Core_Factory_Vfs')->create();
     } catch (Horde_Vfs_Exception $e) {
     }
     if (!isset($vfs) || $vfs instanceof Horde_Vfs_Null) {
         $vfs = new Horde_Vfs_File(array('vfsroot' => Horde::getTempDir()));
     }
     parent::__construct(array_merge($params, array('logger' => $injector->getInstance('Horde_Core_Log_Wrapper'), 'vfs' => $vfs)));
 }
Esempio n. 5
0
 public function create(Horde_Injector $injector)
 {
     if (!class_exists('Net_DNS2_Resolver')) {
         return null;
     }
     if ($tmpdir = Horde::getTempDir()) {
         $config = array('cache_file' => $tmpdir . '/horde_dns.cache', 'cache_size' => 100000, 'cache_type' => 'file');
     } else {
         $config = array();
     }
     $resolver = new Net_DNS2_Resolver($config);
     if (is_readable('/etc/resolv.conf')) {
         try {
             $resolver->setServers('/etc/resolv.conf');
         } catch (Net_DNS2_Exception $e) {
         }
     }
     return $resolver;
 }
Esempio n. 6
0
 /**
  * Creates a temporary filename for the lifetime of the script, and
  * (optionally) registers it to be deleted at request shutdown.
  *
  * @param string $prefix   Prefix to make the temporary name more
  *                         recognizable.
  * @param boolean $delete  Delete the file at the end of the request?
  * @param string $dir      Directory to create the temporary file in.
  * @param boolean $secure  If deleting file, should we securely delete the
  *                         file?
  *
  * @return string   Returns the full path-name to the temporary file or
  *                  false if a temporary file could not be created.
  */
 function getTempFile($prefix = 'Horde', $delete = true, $dir = '', $secure = false)
 {
     if (empty($dir) || !is_dir($dir)) {
         $dir = Horde::getTempDir();
     }
     return Util::getTempFile($prefix, $delete, $dir, $secure);
 }
Esempio n. 7
0
 *            the transport class needs. See examples below for further details.
 *            Valid options for 'driver' are:
 *   - ispconfig: ISPConfig SOAP server (only for vacation notices).
 *   - ldap:      LDAP server.
 *   - null:      No backend server (i.e. for script drivers, such as 'imap',
 *                that does not use scripts).
 *   - sql:       Database server (only for vacation notices).
 *   - timsieved: Timsieved (managesieve) server.
 *   - vfs:       Use Horde VFS.
 *
 *   NOTE: By default, the transport driver will use Horde credentials to
 *         authenticate to the backend. If a different username/password is
 *         needed, use the 'transport_auth' hook (see hooks.php) to define
 *         these values.
 */
/* IMAP Example */
$backends['imap'] = array('disabled' => false, 'transport' => array(Ingo::RULE_ALL => array('driver' => 'null', 'params' => array())), 'script' => array(Ingo::RULE_ALL => array('driver' => 'imap', 'params' => array())), 'shares' => false);
/* Maildrop Example */
$backends['maildrop'] = array('disabled' => true, 'transport' => array(Ingo::RULE_ALL => array('driver' => 'vfs', 'params' => array('hostspec' => 'localhost', 'filename' => '.mailfilter', 'vfstype' => 'ftp', 'port' => 21))), 'script' => array(Ingo::RULE_ALL => array('driver' => 'maildrop', 'params' => array('mailbotargs' => '-N', 'path_style' => 'mbox', 'strip_inbox' => false, 'variables' => array()))), 'shares' => false);
/* Procmail Example */
$backends['procmail'] = array('disabled' => true, 'transport' => array(Ingo::RULE_ALL => array('driver' => 'vfs', 'params' => array('hostspec' => 'localhost', 'filename' => '.procmailrc', 'vfstype' => 'ftp', 'port' => 21))), 'script' => array(Ingo::RULE_ALL => array('driver' => 'procmail', 'params' => array('path_style' => 'mbox', 'variables' => array()))), 'shares' => false);
/* Sieve Example */
$backends['sieve'] = array('disabled' => true, 'transport' => array(Ingo::RULE_ALL => array('driver' => 'timsieved', 'params' => array('hostspec' => 'localhost', 'logintype' => 'PLAIN', 'usetls' => true, 'port' => 4190, 'scriptname' => 'ingo', 'debug' => false))), 'script' => array(Ingo::RULE_ALL => array('driver' => 'sieve', 'params' => array('date' => true, 'utf8' => false))), 'shares' => false);
/* sivtest Example */
$backends['sivtest'] = array('disabled' => true, 'transport' => array(Ingo::RULE_ALL => array('driver' => 'sivtest', 'params' => array('hostspec' => 'localhost', 'logintype' => 'GSSAPI', 'usetls' => true, 'port' => 4190, 'scriptname' => 'ingo', 'command' => '/usr/bin/sivtest', 'socket' => Horde::getTempDir() . '/sivtest.' . uniqid(mt_rand()) . '.sock'))), 'script' => array(Ingo::RULE_ALL => array('driver' => 'sieve', 'params' => array())), 'shares' => false);
/* Sun ONE/JES Example (LDAP/Sieve) */
$backends['ldapsieve'] = array('disabled' => true, 'transport' => array(Ingo::RULE_ALL => array('driver' => 'ldap', 'params' => array('hostspec' => 'localhost', 'port' => 389, 'version' => 3, 'tls' => true, 'bind_dn' => 'cn=ingo, ou=applications, dc=example, dc=com', 'bind_password' => 'secret', 'script_base' => 'ou=People, dc=example, dc=com', 'script_filter' => '(uid=%u)', 'script_attribute' => 'mailSieveRuleSource'))), 'script' => array(Ingo::RULE_ALL => array('driver' => 'sieve', 'params' => array())));
/* ISPConfig Example */
$backends['ispconfig'] = array('disabled' => true, 'transport' => array(Ingo::RULE_ALL => array('driver' => 'ispconfig', 'params' => array('soap_uri' => 'http://ispconfig-webinterface.example.com:8080/remote/', 'soap_user' => 'horde', 'soap_pass' => 'secret'))), 'script' => array(Ingo::RULE_ALL => array('driver' => 'ispconfig', 'params' => array())), 'shares' => false);
/* Custom SQL Example */
$backends['customsql'] = array('disabled' => true, 'transport' => array(Ingo::RULE_ALL => array('driver' => 'sql', 'params' => $GLOBALS['conf']['sql'])), 'script' => array(Ingo::RULE_ALL => array('driver' => 'customsql', 'params' => array('vacation_unset' => 'UPDATE vacation SET active = 0 WHERE user = %u', 'vacation_set' => 'REPLACE INTO vacation (active, subject, message, user) VALUES (1, %s, %m, %u)'))), 'shares' => false);
Esempio n. 8
0
<?php

/**
 * Process an single image (to be called by ajax)
 *
 * Copyright 2008-2015 Horde LLC (http://www.horde.org/)
 *
 * See the enclosed file COPYING for license information (GPL). If you
 * did not receive this file, see http://www.horde.org/licenses/gpl.
 *
 * @author Duck <*****@*****.**>
 */
require_once 'tabs.php';
/* check if image exists */
$tmp = Horde::getTempDir();
$path = $tmp . '/search_face_' . $registry->getAuth() . Ansel_Faces::getExtension();
if (file_exists($path) !== true) {
    $notification->push(_("You must upload the search photo first"));
    Horde::url('faces/search/image.php')->redirect();
}
$title = _("Create a new face");
$x1 = 0;
$y1 = 0;
$x2 = 0;
$y2 = 0;
try {
    $faces = $faces->getFaces($path);
} catch (Ansel_Exception $e) {
    exit;
}
if (count($faces) > 1) {
Esempio n. 9
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)));
     }
 }
Esempio n. 10
0
 *   dealt with: should be fixed easily by retrieving service using some
 *   regular expression magic.
 *
 * - Limited to 3 messages per session style. This is more serious.
 *
 * - Currently the test case has to start with a slowsync. Maybe we can remove
 *   this restriction and thus allow test cases with "production phones".
 *   An idea to deal with this: make testsync.php work with *any* recorded
 *   sessions:
 *   - change any incoming auth to syncmltest:syncmltest
 *   - identify twowaysync and create fake anchors for that */
require_once 'SyncMl.php';
define('SYNCMLTEST_USERNAME', 'syncmltest');
// Setup default backend parameters:
$syncml_backend_driver = 'Horde';
$syncml_backend_parms = array('debug_dir' => Horde::getTempDir() . '/sync', 'debug_files' => true, 'log_level' => 'DEBUG');
/* Get any options. */
if (!isset($argv)) {
    print_usage();
}
/* Get rid of the first arg which is the script name. */
$this_script = array_shift($argv);
while ($arg = array_shift($argv)) {
    if ($arg == '--help') {
        print_usage();
    } elseif (strstr($arg, '--setup')) {
        $testsetuponly = true;
    } elseif (strstr($arg, '--url')) {
        list(, $url) = explode('=', $arg);
    } elseif (strstr($arg, '--dir')) {
        list(, $dir) = explode('=', $arg);
Esempio n. 11
0
 /**
  * The content to go in this block.
  *
  * @return string   The content
  */
 function _content()
 {
     if (!@(include_once 'Services/Weather.php')) {
         Horde::logMessage('The weather.com block will not work without Services_Weather from PEAR. Run pear install Services_Weather.', __FILE__, __LINE__, PEAR_LOG_ERR);
         return _("The weather.com block is not available.");
     }
     global $conf;
     $cacheDir = Horde::getTempDir();
     $html = '';
     if (empty($this->_params['location'])) {
         return _("No location is set.");
     }
     $weatherDotCom =& Services_Weather::service("WeatherDotCom");
     $weatherDotCom->setAccountData(isset($conf['weatherdotcom']['partner_id']) ? $conf['weatherdotcom']['partner_id'] : '', isset($conf['weatherdotcom']['license_key']) ? $conf['weatherdotcom']['license_key'] : '');
     if (!$cacheDir) {
         return PEAR::raiseError(_("No temporary directory available for cache."), 'horde.error');
     } else {
         $weatherDotCom->setCache("file", array("cache_dir" => $cacheDir . '/'));
     }
     $weatherDotCom->setDateTimeFormat("m.d.Y", "H:i");
     $weatherDotCom->setUnitsFormat($this->_params['units']);
     $units = $weatherDotCom->getUnitsFormat();
     // If the user entered a zip code for the location, no need to
     // search (weather.com accepts zip codes as location IDs).
     // The location ID should already have been validated in
     // getParams.
     $search = preg_match('/\\b(?:\\d{5}(-\\d{5})?)|(?:[A-Z]{4}\\d{4})\\b/', $this->_params['location'], $matches) ? $matches[0] : $weatherDotCom->searchLocation($this->_params['location']);
     if (is_a($search, 'PEAR_Error')) {
         return $search->getmessage();
     }
     if (is_array($search)) {
         // Several locations returned due to imprecise location parameter
         $html = _("Several locations possible with the parameter: ");
         $html .= $this->_params['location'];
         $html .= "<br/><ul>";
         foreach ($search as $id_weather => $real_location) {
             $html .= "<li>{$real_location} ({$id_weather})</li>\n";
         }
         $html .= "</ul>";
         return $html;
     }
     $location = $weatherDotCom->getLocation($search);
     if (is_a($location, 'PEAR_Error')) {
         return $location->getmessage();
     }
     $weather = $weatherDotCom->getWeather($search);
     if (is_a($weather, 'PEAR_Error')) {
         return $weather->getmessage();
     }
     $forecast = $weatherDotCom->getForecast($search, $this->_params['days']);
     if (is_a($forecast, 'PEAR_Error')) {
         return $forecast->getmessage();
     }
     // Location and local time.
     $html .= "<table width=100%><tr><td class=control>";
     $html .= '<b>' . $location['name'] . '</b>' . ' local time ' . $location['time'];
     $html .= "</b></td></tr></table>";
     // Sunrise/sunset.
     $html .= '<b>' . _("Sunrise: ") . '</b>' . Horde::img('block/sunrise/sunrise.gif', _("Sunrise")) . $location['sunrise'];
     $html .= ' <b>' . _("Sunset: ") . '</b>' . Horde::img('block/sunrise/sunset.gif', _("Sunset")) . $location['sunset'];
     // Temperature.
     $html .= '<br /><b>' . _("Temperature: ") . '</b>';
     $html .= $weather['temperature'] . '&deg;' . String::upper($units['temp']);
     // Dew point.
     $html .= ' <b>' . _("Dew point: ") . '</b>';
     $html .= $weather['dewPoint'] . '&deg;' . String::upper($units['temp']);
     // Feels like temperature.
     $html .= ' <b>' . _("Feels like: ") . '</b>';
     $html .= $weather['feltTemperature'] . '&deg;' . String::upper($units['temp']);
     // Pressure and trend.
     $html .= '<br /><b>' . _("Pressure: ") . '</b>';
     $html .= number_format($weather['pressure'], 2) . ' ' . $units['pres'];
     $html .= _(" and ") . $weather['pressureTrend'];
     // Wind.
     $html .= '<br /><b>' . _("Wind: ") . '</b>';
     if ($weather['windDirection'] == 'VAR') {
         $html .= _("Variable");
     } elseif ($weather['windDirection'] == 'CALM') {
         $html .= _("Calm");
     } else {
         $html .= _("From the ") . $weather['windDirection'];
         $html .= ' (' . $weather['windDegrees'] . ')';
     }
     $html .= _(" at ") . $weather['wind'] . ' ' . $units['wind'];
     // Humidity.
     $html .= '<br /><b>' . _("Humidity: ") . '</b>';
     $html .= $weather['humidity'] . '%';
     // Visibility.
     $html .= ' <b>' . _("Visibility: ") . '</b>';
     $html .= $weather['visibility'] . (is_numeric($weather['visibility']) ? ' ' . $units['vis'] : '');
     // UV index.
     $html .= ' <b>' . _("U.V. index: ") . '</b>';
     $html .= $weather['uvIndex'] . ' - ' . $weather['uvText'];
     // Current condition.
     $html .= '<br /><b>' . _("Current condition: ") . '</b>' . Horde::img('block/weatherdotcom/32x32/' . $weather['conditionIcon'] . '.png', _(String::lower($weather['condition'])), 'align="middle"');
     $html .= ' ' . $weather['condition'];
     // Do the forecast now.
     $html .= '<table border="0" width="100%" align="center"><tr>';
     $html .= '<tr><td class="control" colspan="' . $this->_params['days'] * 2 . '"><center><b>' . $this->_params['days'] . '-day forecast</b></center></td></tr><tr>';
     $futureDays = 0;
     foreach ($forecast['days'] as $which => $day) {
         $html .= '<td colspan="2" align="center">';
         // Day name.
         $html .= '<b>';
         if ($which == 0) {
             $html .= _("Today");
         } elseif ($which == 1) {
             $html .= _("Tomorrow");
         } else {
             $html .= strftime('%A', mktime(0, 0, 0, date('m'), date('d') + $futureDays, date('Y')));
         }
         $html .= '</b><br />';
         $futureDays++;
         // High/low temp. If after 2 p.m. local time, the "day"
         // forecast is no longer valid.
         if ($which > 0 || $which == 0 && strtotime($location['time']) < strtotime('14:00')) {
             $html .= '<span style="color:red">' . $day['tempertureHigh'] . '&deg;' . String::upper($units['temp']) . '</span>/';
         }
         $html .= '<span style="color:blue">' . $day['temperatureLow'] . '&deg;' . String::upper($units['temp']) . '</span>';
         $html .= '</td>';
     }
     $html .= '</tr><tr>';
     $elementWidth = 100 / ($this->_params['days'] * 2);
     foreach ($forecast['days'] as $which => $day) {
         // Day forecast.
         $html .= '<td align="center" valign="top" width="' . $elementWidth . '%">';
         if ($which > 0 || $which == 0 && strtotime($location['time']) < strtotime('14:00')) {
             $html .= '<b><i>Day</i></b><br />';
             $html .= Horde::img('block/weatherdotcom/23x23/' . $day['day']['conditionIcon'] . '.png', $day['day']['condition']);
             $html .= '<br />' . $day['day']['condition'];
         } else {
             $html .= '&nbsp;';
         }
         $html .= '</td>';
         // Night forecast.
         $html .= '<td align="center" valign="top" width="' . $elementWidth . '%">';
         $html .= '<b><i>Night</i></b><br />';
         $html .= Horde::img('block/weatherdotcom/23x23/' . $day['night']['conditionIcon'] . '.png', $day['night']['condition']);
         $html .= '<br />' . $day['night']['condition'];
         $html .= '</td>';
     }
     $html .= '</tr></table>';
     // Display a bar at the bottom of the block with the required
     // attribution to weather.com and the logo, both linked to
     // weather.com with the partner ID.
     $html .= '<table width=100%><tr>';
     $html .= '<td align=right class=control>';
     $html .= 'Weather data provided by ';
     $html .= Horde::link('http://www.weather.com/?prod=xoap&par=' . $weatherDotCom->_partnerID, 'weather.com', '', '_blank', '', 'weather.com');
     $html .= '<i>weather.com</i>&reg; ';
     $html .= Horde::img('block/weatherdotcom/32x32/TWClogo_32px.png', 'weather.com logo');
     $html .= '</a></td></tr></table>';
     return $html;
 }
Esempio n. 12
0
 /**
  * Return the Horde_Crypt:: instance.
  *
  * @param string $driver  The driver name.
  * @param array $params   Any parameters needed by the driver.
  *
  * @return Horde_Crypt  The instance.
  * @throws Horde_Exception
  */
 public function create($driver, $params = array())
 {
     global $registry;
     $params = array_merge(array('email_charset' => $registry->getEmailCharset(), 'temp' => Horde::getTempDir()), $params);
     return Horde_Crypt::factory($driver, $params);
 }
Esempio n. 13
0
 function provideHordeBase()
 {
     return Horde::getTempDir() . '/test_config';
 }
Esempio n. 14
0
    $ftpform->addVariable(_("Username"), 'username', 'text', true, false, null, array('', 20));
    $ftpform->addVariable(_("Password"), 'password', 'password', false);
    if ($ftpform->validate($vars)) {
        $ftpform->getInfo($vars, $info);
        $upload = _uploadFTP($info);
        if ($upload) {
            $notification->push(_("Uploaded all application configuration files to the server."), 'horde.success');
            Horde::url('admin/config/index.php', true)->redirect();
        }
    }
    /* Render the form. */
    Horde::startBuffer();
    $ftpform->renderActive(new Horde_Form_Renderer(), $vars, Horde::url('admin/config/index.php'), 'post');
    $ftpform = Horde::endBuffer();
}
if (file_exists(Horde::getTempDir() . '/horde_configuration_upgrade.php')) {
    /* Action to remove the configuration upgrade PHP script. */
    $url = Horde::url('admin/config/scripts.php')->add('clean', 'tmp');
    $action = _("Remove saved script from server's temporary directory.");
    $actions[] = array('icon' => Horde_Themes_Image::tag('delete.png', array('attr' => array('align' => 'middle'))), 'link' => Horde::link($url) . $action . '</a>');
}
$view = new Horde_View(array('templatePath' => HORDE_TEMPLATES . '/admin/config'));
$view->actions = $actions;
$view->apps = $apps;
$view->config_outdated = $config_outdated;
$view->ftpform = $ftpform;
$view->schema_outdated = $schema_outdated;
$view->version_action = Horde::url('admin/config/index.php');
$view->version_input = Horde_Util::formInput();
$view->versions = !empty($versions);
$page_output->addScriptFile('stripe.js', 'horde');
Esempio n. 15
0
 function handleMessage($fqhostname, $sender, $resource, $tmpfname)
 {
     global $conf;
     $rdata = $this->_getResourceData($sender, $resource);
     if (is_a($rdata, 'PEAR_Error')) {
         return $rdata;
     } else {
         if ($rdata === false) {
             /* No data, probably not a local user */
             return true;
         } else {
             if ($rdata['homeserver'] && $rdata['homeserver'] != $fqhostname) {
                 /* Not the users homeserver, ignore */
                 return true;
             }
         }
     }
     $cn = $rdata['cn'];
     $id = $rdata['id'];
     if (isset($rdata['action'])) {
         $action = $rdata['action'];
     } else {
         // Manual is the only safe default!
         $action = RM_ACT_MANUAL;
     }
     Horde::log(sprintf('Action for %s is %s', $sender, $action), 'DEBUG');
     // Get out as early as possible if manual
     if ($action == RM_ACT_MANUAL) {
         Horde::log(sprintf('Passing through message to %s', $id), 'INFO');
         return true;
     }
     /* Get the iCalendar data (i.e. the iTip request) */
     $iCalendar =& $this->_getICal($tmpfname);
     if ($iCalendar === false) {
         // No iCal in mail
         Horde::log(sprintf('Could not parse iCalendar data, passing through to %s', $id), 'INFO');
         return true;
     }
     // Get the event details out of the iTip request
     $itip =& $iCalendar->findComponent('VEVENT');
     if ($itip === false) {
         Horde::log(sprintf('No VEVENT found in iCalendar data, passing through to %s', $id), 'INFO');
         return true;
     }
     $itip = new Horde_Kolab_Resource_Itip($itip);
     // What is the request's method? i.e. should we create a new event/cancel an
     // existing event, etc.
     $method = Horde_String::upper($iCalendar->getAttributeDefault('METHOD', $itip->getMethod()));
     // What resource are we managing?
     Horde::log(sprintf('Processing %s method for %s', $method, $id), 'DEBUG');
     // This is assumed to be constant across event creation/modification/deletipn
     $uid = $itip->getUid();
     Horde::log(sprintf('Event has UID %s', $uid), 'DEBUG');
     // Who is the organiser?
     $organiser = $itip->getOrganizer();
     Horde::log(sprintf('Request made by %s', $organiser), 'DEBUG');
     // What is the events summary?
     $summary = $itip->getSummary();
     $estart = new Horde_Kolab_Resource_Epoch($itip->getStart());
     $dtstart = $estart->getEpoch();
     $eend = new Horde_Kolab_Resource_Epoch($itip->getEnd());
     $dtend = $eend->getEpoch();
     Horde::log(sprintf('Event starts on <%s> %s and ends on <%s> %s.', $dtstart, $this->iCalDate2Kolab($dtstart), $dtend, $this->iCalDate2Kolab($dtend)), 'DEBUG');
     if ($action == RM_ACT_ALWAYS_REJECT) {
         if ($method == 'REQUEST') {
             Horde::log(sprintf('Rejecting %s method', $method), 'INFO');
             return $this->sendITipReply($cn, $resource, $itip, RM_ITIP_DECLINE, $organiser, $uid, $is_update);
         } else {
             Horde::log(sprintf('Passing through %s method for ACT_ALWAYS_REJECT policy', $method), 'INFO');
             return true;
         }
     }
     $is_update = false;
     $imap_error = false;
     $ignore = array();
     $folder = $this->_imapConnect($id);
     if (is_a($folder, 'PEAR_Error')) {
         $imap_error =& $folder;
     }
     if (!is_a($imap_error, 'PEAR_Error') && !$folder->exists()) {
         $imap_error =& PEAR::raiseError('Error, could not open calendar folder!', OUT_LOG | EX_TEMPFAIL);
     }
     if (!is_a($imap_error, 'PEAR_Error')) {
         $data = $folder->getData();
         if (is_a($data, 'PEAR_Error')) {
             $imap_error =& $data;
         }
     }
     if (is_a($imap_error, 'PEAR_Error')) {
         Horde::log(sprintf('Failed accessing IMAP calendar: %s', $folder->getMessage()), 'ERR');
         if ($action == RM_ACT_MANUAL_IF_CONFLICTS) {
             return true;
         }
     }
     switch ($method) {
         case 'REQUEST':
             if ($action == RM_ACT_MANUAL) {
                 Horde::log(sprintf('Passing through %s method', $method), 'INFO');
                 break;
             }
             if (is_a($imap_error, 'PEAR_Error') || !$data->objectUidExists($uid)) {
                 $old_uid = null;
             } else {
                 $old_uid = $uid;
                 $ignore[] = $uid;
                 $is_update = true;
             }
             /** Generate the Kolab object */
             $object = $itip->getKolabObject();
             $outofperiod = 0;
             // Don't even bother checking free/busy info if RM_ACT_ALWAYS_ACCEPT
             // is specified
             if ($action != RM_ACT_ALWAYS_ACCEPT) {
                 try {
                     require_once 'Horde/Kolab/Resource/Freebusy.php';
                     $fb = Horde_Kolab_Resource_Freebusy::singleton();
                     $vfb = $fb->get($resource);
                 } catch (Exception $e) {
                     return PEAR::raiseError($e->getMessage(), OUT_LOG | EX_UNAVAILABLE);
                 }
                 $vfbstart = $vfb->getAttributeDefault('DTSTART', 0);
                 $vfbend = $vfb->getAttributeDefault('DTEND', 0);
                 Horde::log(sprintf('Free/busy info starts on <%s> %s and ends on <%s> %s', $vfbstart, $this->iCalDate2Kolab($vfbstart), $vfbend, $this->iCalDate2Kolab($vfbend)), 'DEBUG');
                 $evfbend = new Horde_Kolab_Resource_Epoch($vfbend);
                 if ($vfbstart && $dtstart > $evfbend->getEpoch()) {
                     $outofperiod = 1;
                 } else {
                     // Check whether we are busy or not
                     $busyperiods = $vfb->getBusyPeriods();
                     Horde::log(sprintf('Busyperiods: %s', print_r($busyperiods, true)), 'DEBUG');
                     $extraparams = $vfb->getExtraParams();
                     Horde::log(sprintf('Extraparams: %s', print_r($extraparams, true)), 'DEBUG');
                     $conflict = false;
                     if (!empty($object['recurrence'])) {
                         $recurrence = new Horde_Date_Recurrence($dtstart);
                         $recurrence->fromHash($object['recurrence']);
                         $duration = $dtend - $dtstart;
                         $events = array();
                         $next_start = $vfbstart;
                         $next = $recurrence->nextActiveRecurrence($vfbstart);
                         while ($next !== false && $next->compareDate($vfbend) <= 0) {
                             $next_ts = $next->timestamp();
                             $events[$next_ts] = $next_ts + $duration;
                             $next = $recurrence->nextActiveRecurrence(array('year' => $next->year, 'month' => $next->month, 'mday' => $next->mday + 1, 'hour' => $next->hour, 'min' => $next->min, 'sec' => $next->sec));
                         }
                     } else {
                         $events = array($dtstart => $dtend);
                     }
                     foreach ($events as $dtstart => $dtend) {
                         Horde::log(sprintf('Requested event from %s to %s', strftime('%a, %d %b %Y %H:%M:%S %z', $dtstart), strftime('%a, %d %b %Y %H:%M:%S %z', $dtend)), 'DEBUG');
                         foreach ($busyperiods as $busyfrom => $busyto) {
                             if (empty($busyfrom) && empty($busyto)) {
                                 continue;
                             }
                             Horde::log(sprintf('Busy period from %s to %s', strftime('%a, %d %b %Y %H:%M:%S %z', $busyfrom), strftime('%a, %d %b %Y %H:%M:%S %z', $busyto)), 'DEBUG');
                             if (isset($extraparams[$busyfrom]['X-UID']) && in_array(base64_decode($extraparams[$busyfrom]['X-UID']), $ignore) || isset($extraparams[$busyfrom]['X-SID']) && in_array(base64_decode($extraparams[$busyfrom]['X-SID']), $ignore)) {
                                 // Ignore
                                 continue;
                             }
                             if ($busyfrom >= $dtstart && $busyfrom < $dtend || $dtstart >= $busyfrom && $dtstart < $busyto) {
                                 Horde::log('Request overlaps', 'DEBUG');
                                 $conflict = true;
                                 break;
                             }
                         }
                         if ($conflict) {
                             break;
                         }
                     }
                     if ($conflict) {
                         if ($action == RM_ACT_MANUAL_IF_CONFLICTS) {
                             //sendITipReply(RM_ITIP_TENTATIVE);
                             Horde::log('Conflict detected; Passing mail through', 'INFO');
                             return true;
                         } else {
                             if ($action == RM_ACT_REJECT_IF_CONFLICTS) {
                                 Horde::log('Conflict detected; rejecting', 'INFO');
                                 return $this->sendITipReply($cn, $id, $itip, RM_ITIP_DECLINE, $organiser, $uid, $is_update);
                             }
                         }
                     }
                 }
             }
             if (is_a($imap_error, 'PEAR_Error')) {
                 Horde::log('Could not access users calendar; rejecting', 'INFO');
                 return $this->sendITipReply($cn, $id, $itip, RM_ITIP_DECLINE, $organiser, $uid, $is_update);
             }
             // At this point there was either no conflict or RM_ACT_ALWAYS_ACCEPT
             // was specified; either way we add the new event & send an 'ACCEPT'
             // iTip reply
             Horde::log(sprintf('Adding event %s', $uid), 'INFO');
             if (!empty($conf['kolab']['filter']['simple_locks'])) {
                 if (!empty($conf['kolab']['filter']['simple_locks_timeout'])) {
                     $timeout = $conf['kolab']['filter']['simple_locks_timeout'];
                 } else {
                     $timeout = 60;
                 }
                 if (!empty($conf['kolab']['filter']['simple_locks_dir'])) {
                     $lockdir = $conf['kolab']['filter']['simple_locks_dir'];
                 } else {
                     $lockdir = Horde::getTempDir() . '/Kolab_Filter_locks';
                     if (!is_dir($lockdir)) {
                         mkdir($lockdir, 0700);
                     }
                 }
                 if (is_dir($lockdir)) {
                     $lockfile = $lockdir . '/' . $resource . '.lock';
                     $counter = 0;
                     while ($counter < $timeout && file_exists($lockfile)) {
                         sleep(1);
                         $counter++;
                     }
                     if ($counter == $timeout) {
                         Horde::log(sprintf('Lock timeout of %s seconds exceeded. Rejecting invitation.', $timeout), 'ERR');
                         return $this->sendITipReply($cn, $id, $itip, RM_ITIP_DECLINE, $organiser, $uid, $is_update);
                     }
                     $result = file_put_contents($lockfile, 'LOCKED');
                     if ($result === false) {
                         Horde::log(sprintf('Failed creating lock file %s.', $lockfile), 'ERR');
                     } else {
                         $this->lockfile = $lockfile;
                     }
                 } else {
                     Horde::log(sprintf('The lock directory %s is missing. Disabled locking.', $lockdir), 'ERR');
                 }
             }
             $itip->setAccepted($resource);
             $result = $data->save($itip->getKolabObject(), $old_uid);
             if (is_a($result, 'PEAR_Error')) {
                 $result->code = OUT_LOG | EX_UNAVAILABLE;
                 return $result;
             }
             if ($outofperiod) {
                 Horde::log('No freebusy information available', 'NOTICE');
                 return $this->sendITipReply($cn, $resource, $itip, RM_ITIP_TENTATIVE, $organiser, $uid, $is_update);
             } else {
                 return $this->sendITipReply($cn, $resource, $itip, RM_ITIP_ACCEPT, $organiser, $uid, $is_update);
             }
         case 'CANCEL':
             Horde::log(sprintf('Removing event %s', $uid), 'INFO');
             if (is_a($imap_error, 'PEAR_Error')) {
                 $body = sprintf(Horde_Kolab_Resource_Translation::t("Unable to access %s's calendar:"), $resource) . "\n\n" . $summary;
                 $subject = sprintf(Horde_Kolab_Resource_Translation::t("Error processing \"%s\""), $summary);
             } else {
                 if (!$data->objectUidExists($uid)) {
                     Horde::log(sprintf('Canceled event %s is not present in %s\'s calendar', $uid, $resource), 'WARNING');
                     $body = sprintf(Horde_Kolab_Resource_Translation::t("The following event that was canceled is not present in %s's calendar:"), $resource) . "\n\n" . $summary;
                     $subject = sprintf(Horde_Kolab_Resource_Translation::t("Error processing \"%s\""), $summary);
                 } else {
                     /**
                      * Delete the messages from IMAP
                      * Delete any old events that we updated
                      */
                     Horde::log(sprintf('Deleting %s because of cancel', $uid), 'DEBUG');
                     $result = $data->delete($uid);
                     if (is_a($result, 'PEAR_Error')) {
                         Horde::log(sprintf('Deleting %s failed with %s', $uid, $result->getMessage()), 'DEBUG');
                     }
                     $body = Horde_Kolab_Resource_Translation::t("The following event has been successfully removed:") . "\n\n" . $summary;
                     $subject = sprintf(Horde_Kolab_Resource_Translation::t("%s has been cancelled"), $summary);
                 }
             }
             Horde::log(sprintf('Sending confirmation of cancelation to %s', $organiser), 'WARNING');
             $body = new MIME_Part('text/plain', Horde_String::wrap($body, 76));
             $mime =& MIME_Message::convertMimePart($body);
             $mime->setTransferEncoding('quoted-printable');
             $mime->transferEncodeContents();
             // Build the reply headers.
             $msg_headers = new MIME_Headers();
             $msg_headers->addHeader('Date', date('r'));
             $msg_headers->addHeader('From', $resource);
             $msg_headers->addHeader('To', $organiser);
             $msg_headers->addHeader('Subject', $subject);
             $msg_headers->addMIMEHeaders($mime);
             $reply = new Horde_Kolab_Resource_Reply($resource, $organiser, $msg_headers, $mime);
             Horde::log('Successfully prepared cancellation reply', 'INFO');
             return $reply;
         default:
             // We either don't currently handle these iTip methods, or they do not
             // apply to what we're trying to accomplish here
             Horde::log(sprintf('Ignoring %s method and passing message through to %s', $method, $resource), 'INFO');
             return true;
     }
 }
Esempio n. 16
0
 /**
  */
 public function __construct($user, $id = null)
 {
     global $conf, $injector;
     parent::__construct($user, $id);
     $this->_vfs = $conf['compose']['use_vfs'] ? $injector->getInstance('Horde_Core_Factory_Vfs')->create() : new Horde_Vfs_File(array('vfsroot' => Horde::getTempDir()));
 }
Esempio n. 17
0
File: Test.php Progetto: horde/horde
 /**
  * Any application specific tests that need to be done.
  *
  * @return string  HTML output.
  */
 public function appTests()
 {
     /* File upload information. */
     $upload_check = $this->phpSettingCheck(array('file_uploads' => array('error' => 'file_uploads must be enabled for some features like sending emails with IMP.', 'setting' => true)));
     $upload_tmp_dir = ($dir = ini_get('upload_tmp_dir')) ? '<li>upload_tmp_dir: <strong style="color:"' . (is_writable($dir) ? 'green' : 'red') . '">' . $dir . '</strong></li>' : '';
     $ret = '<h1>File Uploads</h1><ul>' . $upload_check . $upload_tmp_dir . '<li>upload_max_filesize: ' . ini_get('upload_max_filesize') . '</li>' . '<li>post_max_size: ' . ini_get('post_max_size') . '<br />' . 'This value should be several times the expect largest upload size (notwithstanding any upload limits present in an application). Any upload that exceeds this size will cause any state information sent along with the uploaded data to be lost. This is a PHP limitation and can not be worked around.' . '</li></ul>';
     /* Check for supported translations. */
     $ret .= '<h1>Supported locales</h1><ul>';
     $missing = false;
     foreach ($GLOBALS['registry']->nlsconfig->languages as $code => $language) {
         if ($GLOBALS['registry']->nlsconfig->validLang($code)) {
             $color = 'green';
         } else {
             $color = 'red';
             $missing = true;
         }
         $ret .= sprintf('<li>%s &#x202d;(%s): <strong style="color:%s">%s</strong></li>', $language, $code, $color, $color == 'green' ? 'Yes' : 'No');
     }
     $ret .= '</ul>';
     /* Determine if 'static' is writable by the web user. */
     $user = function_exists('posix_getuid') ? posix_getpwuid(posix_getuid()) : null;
     $static_dir = $GLOBALS['registry']->get('staticfs', 'horde');
     $ret .= '<h1>Local File Permissions</h1><ul>' . sprintf('<li>Is <tt>%s</tt> writable by the web server user%s? ', htmlspecialchars($static_dir), $user ? ' (' . $user['name'] . ')' : '');
     $ret .= is_writable($static_dir) ? '<strong style="color:green">Yes</strong>' : '<strong style="color:red">No</strong><br /><strong style="color:orange">If caching javascript and CSS files by storing them in static files (HIGHLY RECOMMENDED), this directory must be writable as the user the web server runs as%s.</strong>';
     /* Determine if 'tmpdir' is writable by the web user. */
     $tmpdir = Horde::getTempDir();
     $ret .= sprintf('<li>Is tmpdir <tt>%s</tt> writable by the web server user%s? ', htmlspecialchars($tmpdir), $user ? ' (' . $user['name'] . ')' : '');
     $ret .= is_writable($tmpdir) ? '<strong style="color:green">Yes</strong>' : '<strong style="color:red">No</strong><br />';
     if (extension_loaded('imagick')) {
         $im = new Imagick();
         $imagick = is_callable(array($im, 'getIteratorIndex'));
         $ret .= '</li></ul><h1>Imagick</h1><ul>' . '<li>Imagick compiled against current ImageMagick version: <strong style="color:' . ($imagick ? 'green">Yes' : 'red">No') . '</strong>';
     }
     return $ret . '</li></ul>';
 }
Esempio n. 18
0
    if ($ftpform->validate($vars)) {
        $ftpform->getInfo($vars, $info);
        $upload = _uploadFTP($info);
        if ($upload) {
            $notification->push(sprintf(_("Uploaded all application setup files to server '%s'."), $info['hostspec']), 'horde.success');
            $url = Horde::applicationUrl('admin/setup/index.php', true);
            header('Location: ' . $url);
            exit;
        }
    }
    /* Render the form. */
    require_once HORDE_LIBS . 'Horde/Form/Renderer.php';
    $renderer =& new Horde_Form_Renderer();
    $ftpform = Util::bufferOutput(array($ftpform, 'renderActive'), $renderer, $vars, 'index.php', 'post');
}
if (file_exists(Horde::getTempDir() . '/horde_setup_upgrade.php')) {
    /* Action to remove the configuration upgrade PHP script. */
    $url = Horde::applicationUrl('admin/setup/scripts.php');
    $url = Util::addParameter($url, 'clean', 'tmp');
    $action = _("Remove saved script from server's temporary directory.");
    $actions[] = Horde::link($url, $action, '', '', '', $action) . $action . '</a>';
}
/* Set up the template. */
$template =& new Horde_Template();
$menu =& new Menu(true, true, true);
$template->set('apps', $apps);
$template->set('actions', $actions, true);
$template->set('ftpform', $ftpform, true);
$template->set('menu', $menu->getMenu());
$template->set('notify', Util::bufferOutput(array($notification, 'notify')));
$title = _("Horde Configuration");
Esempio n. 19
0
        $data .= str_replace(array('\\', '\''), array('\\\\', '\\\''), $php);
        $data .= '\')) {' . "\n";
        $data .= '    echo \'' . sprintf('Saved %s configuration.', $app) . '\' . "\\n";' . "\n";
        $data .= '} else {' . "\n";
        $data .= '    echo \'' . sprintf('Could NOT save %s configuration.', $app) . '\' . "\\n";' . "\n";
        $data .= '    exit;' . "\n";
        $data .= '}' . "\n\n";
    }
}
if ($vars->save != 'tmp') {
    /* Output script to browser for download. */
    $browser->downloadHeaders($filename, 'text/plain', false, strlen($data));
    echo $data;
    exit;
}
$tmp_dir = Horde::getTempDir();
/* Add self-destruct code. */
$data .= 'echo \'Self-destructing...\' . "\\n";' . "\n";
$data .= 'if (@unlink(__FILE__)) {' . "\n";
$data .= '    echo \'Upgrade script deleted.\' . "\\n";' . "\n";
$data .= '} else {' . "\n";
$data .= '    echo \'WARNING!!! REMOVE SCRIPT MANUALLY FROM ' . $tmp_dir . '\' . "\\n";' . "\n";
$data .= '}' . "\n";
/* The script should be saved to server's temporary directory. */
$path = Horde_Util::realPath($tmp_dir . '/' . $filename);
if (file_put_contents($tmp_dir . '/' . $filename, $data)) {
    chmod($tmp_dir . '/' . $filename, 0777);
    $notification->push(sprintf(_("Saved configuration upgrade script to: \"%s\"."), $path), 'horde.success', array('sticky'));
} else {
    $notification->push(sprintf(_("Could not save configuration upgrade script to: \"%s\"."), $path), 'horde.error');
}
Esempio n. 20
0
$attributes['businessCategory'] = array('label' => _("Business Category"), 'type' => 'text', 'required' => false, 'params' => array('regex' => '', 'size' => 40, 'maxlength' => 255));
$attributes['company'] = array('label' => _("Company"), 'type' => 'text', 'required' => false, 'params' => array('regex' => '', 'size' => 40, 'maxlength' => 255));
$attributes['department'] = array('label' => _("Department"), 'type' => 'text', 'required' => false, 'params' => array('regex' => '', 'size' => 40, 'maxlength' => 255));
$attributes['office'] = array('label' => _("Office"), 'type' => 'text', 'required' => false, 'params' => array('regex' => '', 'size' => 40, 'maxlength' => 255));
$attributes['logo'] = array('label' => _("Logo"), 'type' => 'image', 'required' => false, 'params' => array('show_upload' => true, 'show_keeporig' => true, 'max_filesize' => null));
$attributes['logotype'] = array('label' => _("Logo MIME Type"), 'type' => 'text', 'required' => false, 'params' => array('regex' => '', 'size' => 40, 'maxlength' => 255));
/* Other */
$attributes['notes'] = array('label' => _("Notes"), 'type' => 'longtext', 'required' => false, 'params' => array('rows' => 3, 'cols' => 40));
$attributes['website'] = array('label' => _("Website URL"), 'type' => 'text', 'required' => false, 'params' => array('regex' => '', 'size' => 40, 'maxlength' => 255));
$attributes['freebusyUrl'] = array('label' => _("Freebusy URL"), 'type' => 'text', 'required' => false, 'params' => array('regex' => '', 'size' => 40, 'maxlength' => 255));
if (!empty($GLOBALS['conf']['gnupg']['path'])) {
    $attributes['pgpPublicKey'] = array('label' => _("PGP Public Key"), 'type' => 'pgp', 'required' => false, 'params' => array('gpg' => $GLOBALS['conf']['gnupg']['path'], 'temp_dir' => Horde::getTempDir(), 'rows' => 3, 'cols' => 40));
} else {
    $attributes['pgpPublicKey'] = array('label' => _("PGP Public Key"), 'type' => 'longtext', 'required' => false, 'params' => array('rows' => 3, 'cols' => 40));
}
$attributes['smimePublicKey'] = array('label' => _("S/MIME Public Certificate"), 'type' => 'smime', 'required' => false, 'params' => array('temp_dir' => Horde::getTempDir(), 'rows' => 3, 'cols' => 40));
$attributes['category'] = array('label' => _("Category"), 'type' => 'category', 'params' => array(), 'required' => false);
/* Additional attributes supported by Kolab */
$attributes['kolabHomeServer'] = array('label' => _("Kolab Home Server"), 'type' => 'text', 'required' => false, 'params' => array('regex' => '', 'size' => 40, 'maxlength' => 255));
$attributes['initials'] = array('label' => _("Initials"), 'type' => 'text', 'required' => false, 'params' => array('regex' => '', 'size' => 40, 'maxlength' => 255));
$attributes['manager'] = array('label' => _("Manager"), 'type' => 'text', 'required' => false, 'params' => array('regex' => '', 'size' => 40, 'maxlength' => 255));
$attributes['assistant'] = array('label' => _("Assistant"), 'type' => 'text', 'required' => false, 'params' => array('regex' => '', 'size' => 40, 'maxlength' => 255));
$attributes['gender'] = array('label' => _("Gender"), 'type' => 'enum', 'required' => false, 'params' => array('values' => array('male' => _("male"), 'female' => _("female")), 'prompt' => true));
$attributes['language'] = array('label' => _("Language"), 'type' => 'text', 'required' => false, 'params' => array('regex' => '', 'size' => 40, 'maxlength' => 255));
$attributes['latitude'] = array('label' => _("Latitude"), 'type' => 'number', 'required' => false);
$attributes['longitude'] = array('label' => _("Longitude"), 'type' => 'number', 'required' => false);
/* Additional attributes supported by some SyncML clients */
$attributes['workEmail'] = array('label' => _("Work Email"), 'type' => 'email', 'required' => false, 'params' => array('allow_multi' => false, 'strip_domain' => false, 'link_compose' => true, 'link_name' => null, 'delimiters' => ',', 'size' => null));
$attributes['homeEmail'] = array('label' => _("Home Email"), 'type' => 'email', 'required' => false, 'params' => array('allow_multi' => false, 'strip_domain' => false, 'link_compose' => true, 'link_name' => null, 'delimiters' => ',', 'size' => null));
$attributes['phone'] = array('label' => _("Common Phone"), 'type' => 'phone', 'required' => false, 'params' => array('size' => 15));
$attributes['workFax'] = array('label' => _("Work Fax"), 'type' => 'phone', 'required' => false, 'params' => array('size' => 15));
Esempio n. 21
0
 /**
  * Loads any existing image data into the image field. Requires that the
  * array $image passed to it contains the structure:
  *   $image['load']['file'] - the filename of the image;
  *   $image['load']['data'] - the raw image data.
  *
  * @param array $image  The image array.
  */
 function loadImageData(&$image)
 {
     /* No existing image data to load. */
     if (!isset($image['load'])) {
         return;
     }
     /* Save the data to the temp dir. */
     $tmp_file = Horde::getTempDir() . '/' . $image['load']['file'];
     if ($fd = fopen($tmp_file, 'w')) {
         fwrite($fd, $image['load']['data']);
         fclose($fd);
     }
     $image['img'] = array('file' => $image['load']['file']);
     unset($image['load']);
 }
Esempio n. 22
0
 function _checkFifo()
 {
     static $fifoName;
     if (is_null($fifoName) || empty($fifoName)) {
         $fifoName = Horde::getTempDir() . '/nwnadmin-input';
     }
     if (!file_exists($fifoName) && !posix_mkfifo($fifoName, 0640)) {
         $fifoName = '';
     }
     return $fifoName;
 }