summaryrefslogtreecommitdiff
path: root/manager/library
diff options
context:
space:
mode:
Diffstat (limited to 'manager/library')
-rw-r--r--manager/library/CAcert/User/Emails.php120
-rw-r--r--manager/library/actions/ActionIndex.php106
-rw-r--r--manager/library/actions/ActionLogin.php106
-rw-r--r--manager/library/actions/ActionMail.php106
-rw-r--r--manager/library/actions/FWAction.php14
-rw-r--r--manager/library/config/Config.php207
-rw-r--r--manager/library/config/Config_Db.php678
-rw-r--r--manager/library/config/Config_Writer_Db.php434
-rw-r--r--manager/library/date/HumanReadableTime.php280
-rw-r--r--manager/library/date/exception.HumanReadableTimeException.php73
-rw-r--r--manager/library/date/testHumanReadableTime.php31
-rw-r--r--manager/library/exception/exception.Base.php195
-rw-r--r--manager/library/global/defines.php56
-rw-r--r--manager/library/i18n/I18n.php190
-rw-r--r--manager/library/imap/exception.IMAPException.php68
-rw-r--r--manager/library/l10n/L10n.php94
-rw-r--r--manager/library/log/Log.php210
-rw-r--r--manager/library/plugins/plugin.buildmenu.php148
-rw-r--r--manager/library/plugins/plugin.charsetheader.php26
-rw-r--r--manager/library/plugins/plugin.forceauth.php58
-rw-r--r--manager/library/plugins/plugin.loginlogout.php62
21 files changed, 1629 insertions, 1633 deletions
diff --git a/manager/library/CAcert/User/Emails.php b/manager/library/CAcert/User/Emails.php
index 3988c2a..099d09c 100644
--- a/manager/library/CAcert/User/Emails.php
+++ b/manager/library/CAcert/User/Emails.php
@@ -1,60 +1,60 @@
-<?php
-
-class CAcert_User_Emails {
- private $db = null;
-
- public function __construct($db) {
- $this->db = $db;
- }
-
- /**
- * get list of email addresses by login, needed to be able to filter emails
- * @param string $addr
- * @return array
- */
- public function getEmailAddressesByLogin($addr) {
- $db = $this->db;
-
- /**
- * find out user id by email address
- */
- $sql = 'select users.id from users where email=?';
-
- $id = $db->fetchOne($sql, array($addr));
-
- /**
- * get secondary email addresses
- */
- $sql = 'select email.email from email where memid=?';
-
- $res = $db->query($sql, array($id));
-
- $emails = array();
-
- $num = $res->rowCount();
- for ($i = 0; $i < $num; $i++) {
- $row = $res->fetch(PDO::FETCH_ASSOC);
- $emails[] = $row['email'];
- }
-
- /**
- * get additional addresses by domains
- */
- $sql = 'select domains.domain from domains where memid=?';
-
- $res = $db->query($sql, array($id));
- $num = $res->rowCount();
- $variants = array('root','hostmaster','postmaster','admin','webmaster');
- for ($i = 0; $i < $num; $i++) {
- $row = $res->fetch(PDO::FETCH_ASSOC);
-
- foreach ($variants as $variant) {
- $emails[] = $variant . '@' . $row['domain'];
- }
- }
-
- // Log::Log()->debug(__METHOD__ . ' addresses ' . implode(',', $emails));
-
- return $emails;
- }
-}
+<?php
+
+class CAcert_User_Emails {
+ private $db = null;
+
+ public function __construct($db) {
+ $this->db = $db;
+ }
+
+ /**
+ * get list of email addresses by login, needed to be able to filter emails
+ * @param string $addr
+ * @return array
+ */
+ public function getEmailAddressesByLogin($addr) {
+ $db = $this->db;
+
+ /**
+ * find out user id by email address
+ */
+ $sql = 'select users.id from users where email=?';
+
+ $id = $db->fetchOne($sql, array($addr));
+
+ /**
+ * get secondary email addresses
+ */
+ $sql = 'select email.email from email where memid=?';
+
+ $res = $db->query($sql, array($id));
+
+ $emails = array();
+
+ $num = $res->rowCount();
+ for ($i = 0; $i < $num; $i++) {
+ $row = $res->fetch(PDO::FETCH_ASSOC);
+ $emails[] = $row['email'];
+ }
+
+ /**
+ * get additional addresses by domains
+ */
+ $sql = 'select domains.domain from domains where memid=?';
+
+ $res = $db->query($sql, array($id));
+ $num = $res->rowCount();
+ $variants = array('root','hostmaster','postmaster','admin','webmaster');
+ for ($i = 0; $i < $num; $i++) {
+ $row = $res->fetch(PDO::FETCH_ASSOC);
+
+ foreach ($variants as $variant) {
+ $emails[] = $variant . '@' . $row['domain'];
+ }
+ }
+
+ // Log::Log()->debug(__METHOD__ . ' addresses ' . implode(',', $emails));
+
+ return $emails;
+ }
+}
diff --git a/manager/library/actions/ActionIndex.php b/manager/library/actions/ActionIndex.php
index 2771bad..1b12d3c 100644
--- a/manager/library/actions/ActionIndex.php
+++ b/manager/library/actions/ActionIndex.php
@@ -1,53 +1,53 @@
-<?php
-
-require_once (FWACTIONS_PATH . '/FWAction.php');
-
-class Index extends FWAction {
- /**
- * get a list of required permissions that are needed to access this action
- * @return array
- */
- public static function getRequiredPermissions() {
- return array();
- }
-
- /**
- * get a role that is required for accessing that action
- * @return string
- */
- public static function getRequiredRole() {
- return 'User';
- }
-
- /**
- * sort order for top navigation
- * @return integer
- */
- public static function getTopNavPrio() {
- return 1;
- }
-
- /**
- * controller to invoke
- * @return string
- */
- public static function getController() {
- return 'index';
- }
-
- /**
- * action to invoke
- * @return string
- */
- public static function getAction() {
- return 'index';
- }
-
- /**
- * get text for menu, caller is responsible for translating
- * @return string
- */
- public static function getMenuText() {
- return 'Dashboard';
- }
-}
+<?php
+
+require_once (FWACTIONS_PATH . '/FWAction.php');
+
+class Index extends FWAction {
+ /**
+ * get a list of required permissions that are needed to access this action
+ * @return array
+ */
+ public static function getRequiredPermissions() {
+ return array();
+ }
+
+ /**
+ * get a role that is required for accessing that action
+ * @return string
+ */
+ public static function getRequiredRole() {
+ return 'User';
+ }
+
+ /**
+ * sort order for top navigation
+ * @return integer
+ */
+ public static function getTopNavPrio() {
+ return 1;
+ }
+
+ /**
+ * controller to invoke
+ * @return string
+ */
+ public static function getController() {
+ return 'index';
+ }
+
+ /**
+ * action to invoke
+ * @return string
+ */
+ public static function getAction() {
+ return 'index';
+ }
+
+ /**
+ * get text for menu, caller is responsible for translating
+ * @return string
+ */
+ public static function getMenuText() {
+ return 'Dashboard';
+ }
+}
diff --git a/manager/library/actions/ActionLogin.php b/manager/library/actions/ActionLogin.php
index 02bae86..d363ee8 100644
--- a/manager/library/actions/ActionLogin.php
+++ b/manager/library/actions/ActionLogin.php
@@ -1,53 +1,53 @@
-<?php
-
-require_once (FWACTIONS_PATH . '/FWAction.php');
-
-class Login extends FWAction {
- /**
- * get a list of required permissions that are needed to access this action
- * @return array
- */
- public static function getRequiredPermissions() {
- return array();
- }
-
- /**
- * get a role that is required for accessing that action
- * @return string
- */
- public static function getRequiredRole() {
- return 'User';
- }
-
- /**
- * sort order for top navigation
- * @return integer
- */
- public static function getTopNavPrio() {
- return 1000;
- }
-
- /**
- * controller to invoke
- * @return string
- */
- public static function getController() {
- return 'login';
- }
-
- /**
- * action to invoke
- * @return string
- */
- public static function getAction() {
- return 'index';
- }
-
- /**
- * get text for menu, caller is responsible for translating
- * @return string
- */
- public static function getMenuText() {
- return 'Login';
- }
-}
+<?php
+
+require_once (FWACTIONS_PATH . '/FWAction.php');
+
+class Login extends FWAction {
+ /**
+ * get a list of required permissions that are needed to access this action
+ * @return array
+ */
+ public static function getRequiredPermissions() {
+ return array();
+ }
+
+ /**
+ * get a role that is required for accessing that action
+ * @return string
+ */
+ public static function getRequiredRole() {
+ return 'User';
+ }
+
+ /**
+ * sort order for top navigation
+ * @return integer
+ */
+ public static function getTopNavPrio() {
+ return 1000;
+ }
+
+ /**
+ * controller to invoke
+ * @return string
+ */
+ public static function getController() {
+ return 'login';
+ }
+
+ /**
+ * action to invoke
+ * @return string
+ */
+ public static function getAction() {
+ return 'index';
+ }
+
+ /**
+ * get text for menu, caller is responsible for translating
+ * @return string
+ */
+ public static function getMenuText() {
+ return 'Login';
+ }
+}
diff --git a/manager/library/actions/ActionMail.php b/manager/library/actions/ActionMail.php
index 4ed23de..fc4f172 100644
--- a/manager/library/actions/ActionMail.php
+++ b/manager/library/actions/ActionMail.php
@@ -1,53 +1,53 @@
-<?php
-
-require_once (FWACTIONS_PATH . '/FWAction.php');
-
-class Mail extends FWAction {
- /**
- * get a list of required permissions that are needed to access this action
- * @return array
- */
- public static function getRequiredPermissions() {
- return array();
- }
-
- /**
- * get a role that is required for accessing that action
- * @return string
- */
- public static function getRequiredRole() {
- return 'User';
- }
-
- /**
- * sort order for top navigation
- * @return integer
- */
- public static function getTopNavPrio() {
- return 100;
- }
-
- /**
- * controller to invoke
- * @return string
- */
- public static function getController() {
- return 'mail';
- }
-
- /**
- * action to invoke
- * @return string
- */
- public static function getAction() {
- return 'index';
- }
-
- /**
- * get text for menu, caller is responsible for translating
- * @return string
- */
- public static function getMenuText() {
- return 'Mail';
- }
-}
+<?php
+
+require_once (FWACTIONS_PATH . '/FWAction.php');
+
+class Mail extends FWAction {
+ /**
+ * get a list of required permissions that are needed to access this action
+ * @return array
+ */
+ public static function getRequiredPermissions() {
+ return array();
+ }
+
+ /**
+ * get a role that is required for accessing that action
+ * @return string
+ */
+ public static function getRequiredRole() {
+ return 'User';
+ }
+
+ /**
+ * sort order for top navigation
+ * @return integer
+ */
+ public static function getTopNavPrio() {
+ return 100;
+ }
+
+ /**
+ * controller to invoke
+ * @return string
+ */
+ public static function getController() {
+ return 'mail';
+ }
+
+ /**
+ * action to invoke
+ * @return string
+ */
+ public static function getAction() {
+ return 'index';
+ }
+
+ /**
+ * get text for menu, caller is responsible for translating
+ * @return string
+ */
+ public static function getMenuText() {
+ return 'Mail';
+ }
+}
diff --git a/manager/library/actions/FWAction.php b/manager/library/actions/FWAction.php
index 346e4fa..3bd2879 100644
--- a/manager/library/actions/FWAction.php
+++ b/manager/library/actions/FWAction.php
@@ -1,7 +1,7 @@
-<?php
-/**
- * @author markus
- */
-abstract class FWAction {
-
-}
+<?php
+/**
+ * @author markus
+ */
+abstract class FWAction {
+
+}
diff --git a/manager/library/config/Config.php b/manager/library/config/Config.php
index 26b21fa..fe47ae6 100644
--- a/manager/library/config/Config.php
+++ b/manager/library/config/Config.php
@@ -1,104 +1,103 @@
-<?php
-
-require_once('config/Config_Db.php');
-
-class Config {
- /**
- * static pointer to instances
- * @var array(Config)
- */
- private static $instances = array();
-
- /**
- * can handle several instances, distinct by instance name string
- * @var string
- */
- private $instanceName = '';
-
- /**
- * config object
- * @var Config_Db
- */
- private $config = null;
-
- /**
- * make a new Config_Db
- *
- * by using the $where statement you can limit the data that is fetched from db, i.e. only get config for zone $id
- *
- * @param string $instanceName
- * @param Zend_Db_Adapter $db
- * @param string $where
- */
- protected function __construct($instanceName = null, $db = null, $where = null) {
- if ($instanceName === null)
- throw new Exception(__METHOD__ . ': expected an instance name, got none');
-
- $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini', APPLICATION_ENV);
- $this->instanceName = $instanceName;
-
- if ($db === null)
- $db = Zend_Db::factory($config->dnssecme->db->config->pdo, $config->dnssecme->db->config);
-
- $this->config = new Config_Db($db, $instanceName, $where, true);
- }
-
- /**
- * get already existing instance, make new instance or throw an exception
- * @param string $instanceName
- * @param Zend_Db_Adapter $db
- * @param string $where
- */
- public static function getInstance($instanceName, $db = null, $where = null) {
- if ($instanceName === null)
- throw new Exception(__METHOD__ . ': expected an instance name, got none');
-
- // no caching if presumeably volatile data is requested
- if ($db !== null && $where !== null) {
- return new Config($instanceName, $db, $where);
- }
-
- if (!array_key_exists($instanceName, self::$instances)) {
- self::$instances[$instanceName] = new Config($instanceName, $db, $where);
- }
-
- return self::$instances[$instanceName];
- }
-
- /**
- * magic method that dispatches all unrecognized method calls to the config object
- *
- * @param string $param
- */
- public function __get($param) {
- return $this->config->$param;
- }
-
- /**
- * magic method that handles isset inquiries to attributes
- *
- * @param string $param
- */
- public function __isset($param) {
- return isset($this->config->$param);
- }
-
- /**
- * magic method that dispatches all unrecognized method calls to the config object
- *
- * @param string $param
- * @param string $value
- */
- public function __set($param, $value) {
- $this->config->$param = $value;
- }
-
- /**
- * get the config object
- * @return Zend_Config_*
- */
- public function getConfig() {
- return $this->config;
- }
-}
-?> \ No newline at end of file
+<?php
+
+require_once('config/Config_Db.php');
+
+class Config {
+ /**
+ * static pointer to instances
+ * @var array(Config)
+ */
+ private static $instances = array();
+
+ /**
+ * can handle several instances, distinct by instance name string
+ * @var string
+ */
+ private $instanceName = '';
+
+ /**
+ * config object
+ * @var Config_Db
+ */
+ private $config = null;
+
+ /**
+ * make a new Config_Db
+ *
+ * by using the $where statement you can limit the data that is fetched from db, i.e. only get config for zone $id
+ *
+ * @param string $instanceName
+ * @param Zend_Db_Adapter $db
+ * @param string $where
+ */
+ protected function __construct($instanceName = null, $db = null, $where = null) {
+ if ($instanceName === null)
+ throw new Exception(__METHOD__ . ': expected an instance name, got none');
+
+ $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini', APPLICATION_ENV);
+ $this->instanceName = $instanceName;
+
+ if ($db === null)
+ $db = Zend_Db::factory($config->dnssecme->db->config->pdo, $config->dnssecme->db->config);
+
+ $this->config = new Config_Db($db, $instanceName, $where, true);
+ }
+
+ /**
+ * get already existing instance, make new instance or throw an exception
+ * @param string $instanceName
+ * @param Zend_Db_Adapter $db
+ * @param string $where
+ */
+ public static function getInstance($instanceName, $db = null, $where = null) {
+ if ($instanceName === null)
+ throw new Exception(__METHOD__ . ': expected an instance name, got none');
+
+ // no caching if presumeably volatile data is requested
+ if ($db !== null && $where !== null) {
+ return new Config($instanceName, $db, $where);
+ }
+
+ if (!array_key_exists($instanceName, self::$instances)) {
+ self::$instances[$instanceName] = new Config($instanceName, $db, $where);
+ }
+
+ return self::$instances[$instanceName];
+ }
+
+ /**
+ * magic method that dispatches all unrecognized method calls to the config object
+ *
+ * @param string $param
+ */
+ public function __get($param) {
+ return $this->config->$param;
+ }
+
+ /**
+ * magic method that handles isset inquiries to attributes
+ *
+ * @param string $param
+ */
+ public function __isset($param) {
+ return isset($this->config->$param);
+ }
+
+ /**
+ * magic method that dispatches all unrecognized method calls to the config object
+ *
+ * @param string $param
+ * @param string $value
+ */
+ public function __set($param, $value) {
+ $this->config->$param = $value;
+ }
+
+ /**
+ * get the config object
+ * @return Zend_Config_*
+ */
+ public function getConfig() {
+ return $this->config;
+ }
+}
diff --git a/manager/library/config/Config_Db.php b/manager/library/config/Config_Db.php
index fa312df..83af68b 100644
--- a/manager/library/config/Config_Db.php
+++ b/manager/library/config/Config_Db.php
@@ -1,339 +1,339 @@
-<?php
-/**
- * Add database driven configuration to the framework, source based on Zend_Config_Ini
- *
- * Zend Framework
- *
- * LICENSE
- *
- * This source file is subject to the new BSD license that is bundled
- * with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://framework.zend.com/license/new-bsd
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@zend.com so we can send you a copy immediately.
- *
- * @category Zend
- * @package Zend_Config
- * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id: Config_Db.php 27 2009-12-03 13:00:29Z markus $
- */
-
-
-/**
- * @see Zend_Config
- */
-require_once 'Zend/Config.php';
-
-
-/**
- * @category Zend
- * @package Zend_Config
- * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- */
-class Config_Db extends Zend_Config
-{
- /**
- * String that separates nesting levels of configuration data identifiers
- *
- * @var string
- */
- protected $_nestSeparator = '.';
-
- /**
- * String that separates the parent section name
- *
- * @var string
- */
- protected $_sectionSeparator = ':';
-
- /**
- * Wether to skip extends or not
- *
- * @var boolean
- */
- protected $_skipExtends = false;
-
- /**
- * Loads the section $section from the config file $filename for
- * access facilitated by nested object properties.
- *
- * If the section name contains a ":" then the section name to the right
- * is loaded and included into the properties. Note that the keys in
- * this $section will override any keys of the same
- * name in the sections that have been included via ":".
- *
- * If the $section is null, then all sections in the ini file are loaded.
- *
- * If any key includes a ".", then this will act as a separator to
- * create a sub-property.
- *
- * example ini file:
- * [all]
- * db.connection = database
- * hostname = live
- *
- * [staging : all]
- * hostname = staging
- *
- * after calling $data = new Zend_Config_Ini($file, 'staging'); then
- * $data->hostname === "staging"
- * $data->db->connection === "database"
- *
- * The $options parameter may be provided as either a boolean or an array.
- * If provided as a boolean, this sets the $allowModifications option of
- * Zend_Config. If provided as an array, there are two configuration
- * directives that may be set. For example:
- *
- * $options = array(
- * 'allowModifications' => false,
- * 'nestSeparator' => '->'
- * );
- *
- * @param Zend_Db $dbc
- * @param string $db_table
- * @param string|null $section
- * @param boolean|array $options
- * @throws Zend_Config_Exception
- * @return void
- */
- public function __construct($dbc, $db_table, $section = null, $options = false)
- {
- if (empty($dbc)) {
- /**
- * @see Zend_Config_Exception
- */
- require_once 'Zend/Config/Exception.php';
- throw new Zend_Config_Exception('Database connection is not set');
- }
-
- if (empty($db_table)) {
- /**
- * @see Zend_Config_Exception
- */
- require_once 'Zend/Config/Exception.php';
- throw new Zend_Config_Exception('Database table is not set');
- }
-
- $allowModifications = false;
- if (is_bool($options)) {
- $allowModifications = $options;
- } elseif (is_array($options)) {
- if (isset($options['allowModifications'])) {
- $allowModifications = (bool) $options['allowModifications'];
- }
- if (isset($options['nestSeparator'])) {
- $this->_nestSeparator = (string) $options['nestSeparator'];
- }
- if (isset($options['skipExtends'])) {
- $this->_skipExtends = (bool) $options['skipExtends'];
- }
- }
-
- $iniArray = $this->_loadIniFile($dbc, $db_table, $section);
- $section = null;
-
- if (null === $section) {
- // Load entire file
- $dataArray = array();
- foreach ($iniArray as $sectionName => $sectionData) {
- if(!is_array($sectionData)) {
- $dataArray = array_merge_recursive($dataArray, $this->_processKey(array(), $sectionName, $sectionData));
- } else {
- $dataArray[$sectionName] = $this->_processSection($iniArray, $sectionName);
- }
- }
- parent::__construct($dataArray, $allowModifications);
- } else {
- // Load one or more sections
- if (!is_array($section)) {
- $section = array($section);
- }
- $dataArray = array();
- foreach ($section as $sectionName) {
- if (!isset($iniArray[$sectionName])) {
- /**
- * @see Zend_Config_Exception
- */
- require_once 'Zend/Config/Exception.php';
- throw new Zend_Config_Exception("Section '$sectionName' cannot be found");
- }
- $dataArray = array_merge($this->_processSection($iniArray, $sectionName), $dataArray);
-
- }
- parent::__construct($dataArray, $allowModifications);
- }
-
- $this->_loadedSection = $section;
- }
-
- /**
- * Load data from database and preprocess the section separator (':' in the
- * section name (that is used for section extension) so that the resultant
- * array has the correct section names and the extension information is
- * stored in a sub-key called ';extends'. We use ';extends' as this can
- * never be a valid key name in an INI file that has been loaded using
- * parse_ini_file().
- *
- * @param Zend_Db $dbc
- * @param string $db_table
- * @throws Zend_Config_Exception
- * @return array
- */
- protected function _loadIniFile($dbc, $db_table, $section = null)
- {
- set_error_handler(array($this, '_loadFileErrorHandler'));
- $loaded = $this->_parse_ini_db($dbc, $db_table, $section); // Warnings and errors are suppressed
- restore_error_handler();
- // Check if there was a error while loading file
- if ($this->_loadFileErrorStr !== null) {
- /**
- * @see Zend_Config_Exception
- */
- require_once 'Zend/Config/Exception.php';
- throw new Zend_Config_Exception($this->_loadFileErrorStr);
- }
-
- $iniArray = array();
- foreach ($loaded as $key => $data)
- {
- $pieces = explode($this->_sectionSeparator, $key);
- $thisSection = trim($pieces[0]);
- switch (count($pieces)) {
- case 1:
- $iniArray[$thisSection] = $data;
- break;
-
- case 2:
- $extendedSection = trim($pieces[1]);
- $iniArray[$thisSection] = array_merge(array(';extends'=>$extendedSection), $data);
- break;
-
- default:
- /**
- * @see Zend_Config_Exception
- */
- require_once 'Zend/Config/Exception.php';
- throw new Zend_Config_Exception("Section '$thisSection' may not extend multiple sections");
- }
- }
-
- return $iniArray;
- }
-
- /**
- * read config from (current db in $dbc).$db_table
- *
- * @param Zend_Db $dbc
- * @param string $db_table
- * @param string $section
- * @return array
- */
- protected function _parse_ini_db($dbc, $db_table, $section) {
- $sql = 'select * from ' . $db_table;
- if ($section !== null) {
- $sql .= ' where ' . $section;
- }
-
- $db_config = $dbc->query($sql);
-
- $config = array();
-
- while (($row = $db_config->fetch()) !== false) {
- $key = explode('.', $row['config_key']);
- $depth = count($key);
- $ci = &$config;
- for ($cnt = 0; $cnt < $depth; $cnt++) {
- if ($cnt == ($depth - 1))
- $ci[$key[$cnt]] = $row['config_value'];
- elseif (!isset($ci[$key[$cnt]]))
- $ci[$key[$cnt]] = array();
- $ci = &$ci[$key[$cnt]];
- }
- }
- return $config;
- }
-
- /**
- * Process each element in the section and handle the ";extends" inheritance
- * key. Passes control to _processKey() to handle the nest separator
- * sub-property syntax that may be used within the key name.
- *
- * @param array $iniArray
- * @param string $section
- * @param array $config
- * @throws Zend_Config_Exception
- * @return array
- */
- protected function _processSection($iniArray, $section, $config = array())
- {
- $thisSection = $iniArray[$section];
-
- foreach ($thisSection as $key => $value) {
- if (strtolower($key) == ';extends') {
- if (isset($iniArray[$value])) {
- $this->_assertValidExtend($section, $value);
-
- if (!$this->_skipExtends) {
- $config = $this->_processSection($iniArray, $value, $config);
- }
- } else {
- /**
- * @see Zend_Config_Exception
- */
- require_once 'Zend/Config/Exception.php';
- throw new Zend_Config_Exception("Parent section '$section' cannot be found");
- }
- } else {
- $config = $this->_processKey($config, $key, $value);
- }
- }
- return $config;
- }
-
- /**
- * Assign the key's value to the property list. Handles the
- * nest separator for sub-properties.
- *
- * @param array $config
- * @param string $key
- * @param string $value
- * @throws Zend_Config_Exception
- * @return array
- */
- protected function _processKey($config, $key, $value)
- {
- if (strpos($key, $this->_nestSeparator) !== false) {
- $pieces = explode($this->_nestSeparator, $key, 2);
- if (strlen($pieces[0]) && strlen($pieces[1])) {
- if (!isset($config[$pieces[0]])) {
- if ($pieces[0] === '0' && !empty($config)) {
- // convert the current values in $config into an array
- $config = array($pieces[0] => $config);
- } else {
- $config[$pieces[0]] = array();
- }
- } elseif (!is_array($config[$pieces[0]])) {
- /**
- * @see Zend_Config_Exception
- */
- require_once 'Zend/Config/Exception.php';
- throw new Zend_Config_Exception("Cannot create sub-key for '{$pieces[0]}' as key already exists");
- }
- $config[$pieces[0]] = $this->_processKey($config[$pieces[0]], $pieces[1], $value);
- } else {
- /**
- * @see Zend_Config_Exception
- */
- require_once 'Zend/Config/Exception.php';
- throw new Zend_Config_Exception("Invalid key '$key'");
- }
- } else {
- $config[$key] = $value;
- }
- return $config;
- }
-}
+<?php
+/**
+ * Add database driven configuration to the framework, source based on Zend_Config_Ini
+ *
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category Zend
+ * @package Zend_Config
+ * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: Config_Db.php 27 2009-12-03 13:00:29Z markus $
+ */
+
+
+/**
+ * @see Zend_Config
+ */
+require_once 'Zend/Config.php';
+
+
+/**
+ * @category Zend
+ * @package Zend_Config
+ * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class Config_Db extends Zend_Config
+{
+ /**
+ * String that separates nesting levels of configuration data identifiers
+ *
+ * @var string
+ */
+ protected $_nestSeparator = '.';
+
+ /**
+ * String that separates the parent section name
+ *
+ * @var string
+ */
+ protected $_sectionSeparator = ':';
+
+ /**
+ * Wether to skip extends or not
+ *
+ * @var boolean
+ */
+ protected $_skipExtends = false;
+
+ /**
+ * Loads the section $section from the config file $filename for
+ * access facilitated by nested object properties.
+ *
+ * If the section name contains a ":" then the section name to the right
+ * is loaded and included into the properties. Note that the keys in
+ * this $section will override any keys of the same
+ * name in the sections that have been included via ":".
+ *
+ * If the $section is null, then all sections in the ini file are loaded.
+ *
+ * If any key includes a ".", then this will act as a separator to
+ * create a sub-property.
+ *
+ * example ini file:
+ * [all]
+ * db.connection = database
+ * hostname = live
+ *
+ * [staging : all]
+ * hostname = staging
+ *
+ * after calling $data = new Zend_Config_Ini($file, 'staging'); then
+ * $data->hostname === "staging"
+ * $data->db->connection === "database"
+ *
+ * The $options parameter may be provided as either a boolean or an array.
+ * If provided as a boolean, this sets the $allowModifications option of
+ * Zend_Config. If provided as an array, there are two configuration
+ * directives that may be set. For example:
+ *
+ * $options = array(
+ * 'allowModifications' => false,
+ * 'nestSeparator' => '->'
+ * );
+ *
+ * @param Zend_Db $dbc
+ * @param string $db_table
+ * @param string|null $section
+ * @param boolean|array $options
+ * @throws Zend_Config_Exception
+ * @return void
+ */
+ public function __construct($dbc, $db_table, $section = null, $options = false)
+ {
+ if (empty($dbc)) {
+ /**
+ * @see Zend_Config_Exception
+ */
+ require_once 'Zend/Config/Exception.php';
+ throw new Zend_Config_Exception('Database connection is not set');
+ }
+
+ if (empty($db_table)) {
+ /**
+ * @see Zend_Config_Exception
+ */
+ require_once 'Zend/Config/Exception.php';
+ throw new Zend_Config_Exception('Database table is not set');
+ }
+
+ $allowModifications = false;
+ if (is_bool($options)) {
+ $allowModifications = $options;
+ } elseif (is_array($options)) {
+ if (isset($options['allowModifications'])) {
+ $allowModifications = (bool) $options['allowModifications'];
+ }
+ if (isset($options['nestSeparator'])) {
+ $this->_nestSeparator = (string) $options['nestSeparator'];
+ }
+ if (isset($options['skipExtends'])) {
+ $this->_skipExtends = (bool) $options['skipExtends'];
+ }
+ }
+
+ $iniArray = $this->_loadIniFile($dbc, $db_table, $section);
+ $section = null;
+
+ if (null === $section) {
+ // Load entire file
+ $dataArray = array();
+ foreach ($iniArray as $sectionName => $sectionData) {
+ if(!is_array($sectionData)) {
+ $dataArray = array_merge_recursive($dataArray, $this->_processKey(array(), $sectionName, $sectionData));
+ } else {
+ $dataArray[$sectionName] = $this->_processSection($iniArray, $sectionName);
+ }
+ }
+ parent::__construct($dataArray, $allowModifications);
+ } else {
+ // Load one or more sections
+ if (!is_array($section)) {
+ $section = array($section);
+ }
+ $dataArray = array();
+ foreach ($section as $sectionName) {
+ if (!isset($iniArray[$sectionName])) {
+ /**
+ * @see Zend_Config_Exception
+ */
+ require_once 'Zend/Config/Exception.php';
+ throw new Zend_Config_Exception("Section '$sectionName' cannot be found");
+ }
+ $dataArray = array_merge($this->_processSection($iniArray, $sectionName), $dataArray);
+
+ }
+ parent::__construct($dataArray, $allowModifications);
+ }
+
+ $this->_loadedSection = $section;
+ }
+
+ /**
+ * Load data from database and preprocess the section separator (':' in the
+ * section name (that is used for section extension) so that the resultant
+ * array has the correct section names and the extension information is
+ * stored in a sub-key called ';extends'. We use ';extends' as this can
+ * never be a valid key name in an INI file that has been loaded using
+ * parse_ini_file().
+ *
+ * @param Zend_Db $dbc
+ * @param string $db_table
+ * @throws Zend_Config_Exception
+ * @return array
+ */
+ protected function _loadIniFile($dbc, $db_table, $section = null)
+ {
+ set_error_handler(array($this, '_loadFileErrorHandler'));
+ $loaded = $this->_parse_ini_db($dbc, $db_table, $section); // Warnings and errors are suppressed
+ restore_error_handler();
+ // Check if there was a error while loading file
+ if ($this->_loadFileErrorStr !== null) {
+ /**
+ * @see Zend_Config_Exception
+ */
+ require_once 'Zend/Config/Exception.php';
+ throw new Zend_Config_Exception($this->_loadFileErrorStr);
+ }
+
+ $iniArray = array();
+ foreach ($loaded as $key => $data)
+ {
+ $pieces = explode($this->_sectionSeparator, $key);
+ $thisSection = trim($pieces[0]);
+ switch (count($pieces)) {
+ case 1:
+ $iniArray[$thisSection] = $data;
+ break;
+
+ case 2:
+ $extendedSection = trim($pieces[1]);
+ $iniArray[$thisSection] = array_merge(array(';extends'=>$extendedSection), $data);
+ break;
+
+ default:
+ /**
+ * @see Zend_Config_Exception
+ */
+ require_once 'Zend/Config/Exception.php';
+ throw new Zend_Config_Exception("Section '$thisSection' may not extend multiple sections");
+ }
+ }
+
+ return $iniArray;
+ }
+
+ /**
+ * read config from (current db in $dbc).$db_table
+ *
+ * @param Zend_Db $dbc
+ * @param string $db_table
+ * @param string $section
+ * @return array
+ */
+ protected function _parse_ini_db($dbc, $db_table, $section) {
+ $sql = 'select * from ' . $db_table;
+ if ($section !== null) {
+ $sql .= ' where ' . $section;
+ }
+
+ $db_config = $dbc->query($sql);
+
+ $config = array();
+
+ while (($row = $db_config->fetch()) !== false) {
+ $key = explode('.', $row['config_key']);
+ $depth = count($key);
+ $ci = &$config;
+ for ($cnt = 0; $cnt < $depth; $cnt++) {
+ if ($cnt == ($depth - 1))
+ $ci[$key[$cnt]] = $row['config_value'];
+ elseif (!isset($ci[$key[$cnt]]))
+ $ci[$key[$cnt]] = array();
+ $ci = &$ci[$key[$cnt]];
+ }
+ }
+ return $config;
+ }
+
+ /**
+ * Process each element in the section and handle the ";extends" inheritance
+ * key. Passes control to _processKey() to handle the nest separator
+ * sub-property syntax that may be used within the key name.
+ *
+ * @param array $iniArray
+ * @param string $section
+ * @param array $config
+ * @throws Zend_Config_Exception
+ * @return array
+ */
+ protected function _processSection($iniArray, $section, $config = array())
+ {
+ $thisSection = $iniArray[$section];
+
+ foreach ($thisSection as $key => $value) {
+ if (strtolower($key) == ';extends') {
+ if (isset($iniArray[$value])) {
+ $this->_assertValidExtend($section, $value);
+
+ if (!$this->_skipExtends) {
+ $config = $this->_processSection($iniArray, $value, $config);
+ }
+ } else {
+ /**
+ * @see Zend_Config_Exception
+ */
+ require_once 'Zend/Config/Exception.php';
+ throw new Zend_Config_Exception("Parent section '$section' cannot be found");
+ }
+ } else {
+ $config = $this->_processKey($config, $key, $value);
+ }
+ }
+ return $config;
+ }
+
+ /**
+ * Assign the key's value to the property list. Handles the
+ * nest separator for sub-properties.
+ *
+ * @param array $config
+ * @param string $key
+ * @param string $value
+ * @throws Zend_Config_Exception
+ * @return array
+ */
+ protected function _processKey($config, $key, $value)
+ {
+ if (strpos($key, $this->_nestSeparator) !== false) {
+ $pieces = explode($this->_nestSeparator, $key, 2);
+ if (strlen($pieces[0]) && strlen($pieces[1])) {
+ if (!isset($config[$pieces[0]])) {
+ if ($pieces[0] === '0' && !empty($config)) {
+ // convert the current values in $config into an array
+ $config = array($pieces[0] => $config);
+ } else {
+ $config[$pieces[0]] = array();
+ }
+ } elseif (!is_array($config[$pieces[0]])) {
+ /**
+ * @see Zend_Config_Exception
+ */
+ require_once 'Zend/Config/Exception.php';
+ throw new Zend_Config_Exception("Cannot create sub-key for '{$pieces[0]}' as key already exists");
+ }
+ $config[$pieces[0]] = $this->_processKey($config[$pieces[0]], $pieces[1], $value);
+ } else {
+ /**
+ * @see Zend_Config_Exception
+ */
+ require_once 'Zend/Config/Exception.php';
+ throw new Zend_Config_Exception("Invalid key '$key'");
+ }
+ } else {
+ $config[$key] = $value;
+ }
+ return $config;
+ }
+}
diff --git a/manager/library/config/Config_Writer_Db.php b/manager/library/config/Config_Writer_Db.php
index 1614a41..132c456 100644
--- a/manager/library/config/Config_Writer_Db.php
+++ b/manager/library/config/Config_Writer_Db.php
@@ -1,217 +1,217 @@
-<?php
-/**
- * Zend Framework
- *
- * LICENSE
- *
- * This source file is subject to the new BSD license that is bundled
- * with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://framework.zend.com/license/new-bsd
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@zend.com so we can send you a copy immediately.
- *
- * @category Zend
- * @package Zend_Config
- * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id: Config_Writer_Db.php 43 2009-12-21 14:12:34Z markus $
- */
-
-/**
- * Usage:
- * require_once(LIBRARY_PATH . '/config/Config_Writer_Db.php');
- * $writer = new Config_Writer_Db();
- * $writer->setTableName('system_config');
- * $writer->write(Zend_Registry::get('config_dbc'), Zend_Registry::get('config'));
- *
- * $writer = new Config_Writer_Db();
- * $writer->setTableName('dnssec_org_param');
- * $writer->write(Zend_Registry::get('config_dbc'), dnssec_org_conf, 'dnssec_org_id="2"');
- */
-
-/**
- * @see Zend_Config_Writer
- */
-require_once 'Zend/Config/Writer.php';
-
-/**
- * @category Zend
- * @package Zend_Config
- * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- */
-class Config_Writer_Db extends Zend_Config_Writer
-{
- /**
- * String that separates nesting levels of configuration data identifiers
- *
- * @var string
- */
- protected $_nestSeparator = '.';
-
- protected $_set = null;
-
- protected $_tableName = null;
-
- /**
- * Set the nest separator
- *
- * @param string $filename
- * @return Zend_Config_Writer_Ini
- */
- public function setNestSeparator($separator)
- {
- $this->_nestSeparator = $separator;
-
- return $this;
- }
-
- public function setTableName($name)
- {
- $this->_tableName = $name;
-
- return $this;
- }
-
- /**
- * Defined by Zend_Config_Writer
- *
- * use set to limit impact when a shared config file is used (i.e. config per item using foreign keys)
- *
- * @param string $filename
- * @param Config_Db $config
- * @param string $set
- * @return void
- */
- public function write($db = null, $config = null, $set = null) {
- $this->_set = $set;
-
- // this method is specialized for writing back Config objects (which hold config_db objects)
- if ($config !== null) {
- if ($config instanceof Config)
- $this->setConfig($config->getConfig());
- else {
- $this->setConfig($config);
- }
- }
-
- if ($this->_config === null) {
- require_once 'Zend/Config/Exception.php';
- throw new Zend_Config_Exception('No config was set');
- }
-
- if ($db === null) {
- require_once 'Zend/Config/Exception.php';
- throw new Zend_Config_Exception('No db was set');
- }
-
- $sql = array();
-
- $string = 'delete from ' . $this->_tableName;
- if ($this->_set !== null) {
- $string .= ' where ' . $this->_set;
- }
-
- $sql[] = $string;
-
- $iniString = '';
- $extends = $this->_config->getExtends();
- $sectionName = $this->_config->getSectionName();
-
- foreach ($this->_config as $key => $data) {
- $sql= array_merge($sql, $this->addEntry($sectionName, $key, $data));
- }
-
- try {
- $db->beginTransaction();
- foreach ($sql as $command) {
- #Log::Log()->debug($command);
- $db->query($command);
- }
- $db->commit();
- } catch (Exception $e) {
- $db->rollBack();
- Log::Log()->err($e);
- throw $e;
- }
- }
-
- /**
- * build key value pairs, key is created by recursively adding section names, delimited by "."
- * @param string $prefix
- * @param string $key
- * @param mixed $data
- */
- protected function addEntry($prefix, $key, $data) {
- $sql = array();
-
- if ($data instanceof Zend_Config) {
- if ($prefix != '')
- $prefix .= '.';
- $prefix .= $key;
- foreach ($data as $k => $v) {
- $sql = array_merge($sql, $this->addEntry($prefix, $k, $v));
- }
- }
- else {
- $string = 'insert into ' . $this->_tableName . ' set ';
- $pkey = $prefix;
- if ($pkey != '')
- $pkey .= '.';
- $pkey .= $key;
- $string .= 'config_key=' . $this->_prepareValue($pkey) . ', ';
- $string .= 'config_value=' . $this->_prepareValue($data);
- if ($this->_set !== null)
- $string .= ', ' . $this->_set;
-
- $sql[] = $string;
- }
-
- return $sql;
- }
-
- /**
- * Add a branch to an INI string recursively
- *
- * @param Zend_Config $config
- * @return void
- */
- protected function _addBranch(Zend_Config $config, $parents = array())
- {
- $iniString = '';
-
- foreach ($config as $key => $value) {
- $group = array_merge($parents, array($key));
-
- if ($value instanceof Zend_Config) {
- $iniString .= $this->_addBranch($value, $group);
- } else {
- $iniString .= implode($this->_nestSeparator, $group)
- . ' = '
- . $this->_prepareValue($value)
- . "\n";
- }
- }
-
- return $iniString;
- }
-
- /**
- * Prepare a value for INI
- *
- * @param mixed $value
- * @return string
- */
- protected function _prepareValue($value)
- {
- if (is_integer($value) || is_float($value)) {
- return $value;
- } elseif (is_bool($value)) {
- return ($value ? 'true' : 'false');
- } else {
- return '"' . addslashes($value) . '"';
- }
- }
-}
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category Zend
+ * @package Zend_Config
+ * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: Config_Writer_Db.php 43 2009-12-21 14:12:34Z markus $
+ */
+
+/**
+ * Usage:
+ * require_once(LIBRARY_PATH . '/config/Config_Writer_Db.php');
+ * $writer = new Config_Writer_Db();
+ * $writer->setTableName('system_config');
+ * $writer->write(Zend_Registry::get('config_dbc'), Zend_Registry::get('config'));
+ *
+ * $writer = new Config_Writer_Db();
+ * $writer->setTableName('dnssec_org_param');
+ * $writer->write(Zend_Registry::get('config_dbc'), dnssec_org_conf, 'dnssec_org_id="2"');
+ */
+
+/**
+ * @see Zend_Config_Writer
+ */
+require_once 'Zend/Config/Writer.php';
+
+/**
+ * @category Zend
+ * @package Zend_Config
+ * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class Config_Writer_Db extends Zend_Config_Writer
+{
+ /**
+ * String that separates nesting levels of configuration data identifiers
+ *
+ * @var string
+ */
+ protected $_nestSeparator = '.';
+
+ protected $_set = null;
+
+ protected $_tableName = null;
+
+ /**
+ * Set the nest separator
+ *
+ * @param string $filename
+ * @return Zend_Config_Writer_Ini
+ */
+ public function setNestSeparator($separator)
+ {
+ $this->_nestSeparator = $separator;
+
+ return $this;
+ }
+
+ public function setTableName($name)
+ {
+ $this->_tableName = $name;
+
+ return $this;
+ }
+
+ /**
+ * Defined by Zend_Config_Writer
+ *
+ * use set to limit impact when a shared config file is used (i.e. config per item using foreign keys)
+ *
+ * @param string $filename
+ * @param Config_Db $config
+ * @param string $set
+ * @return void
+ */
+ public function write($db = null, $config = null, $set = null) {
+ $this->_set = $set;
+
+ // this method is specialized for writing back Config objects (which hold config_db objects)
+ if ($config !== null) {
+ if ($config instanceof Config)
+ $this->setConfig($config->getConfig());
+ else {
+ $this->setConfig($config);
+ }
+ }
+
+ if ($this->_config === null) {
+ require_once 'Zend/Config/Exception.php';
+ throw new Zend_Config_Exception('No config was set');
+ }
+
+ if ($db === null) {
+ require_once 'Zend/Config/Exception.php';
+ throw new Zend_Config_Exception('No db was set');
+ }
+
+ $sql = array();
+
+ $string = 'delete from ' . $this->_tableName;
+ if ($this->_set !== null) {
+ $string .= ' where ' . $this->_set;
+ }
+
+ $sql[] = $string;
+
+ $iniString = '';
+ $extends = $this->_config->getExtends();
+ $sectionName = $this->_config->getSectionName();
+
+ foreach ($this->_config as $key => $data) {
+ $sql= array_merge($sql, $this->addEntry($sectionName, $key, $data));
+ }
+
+ try {
+ $db->beginTransaction();
+ foreach ($sql as $command) {
+ #Log::Log()->debug($command);
+ $db->query($command);
+ }
+ $db->commit();
+ } catch (Exception $e) {
+ $db->rollBack();
+ Log::Log()->err($e);
+ throw $e;
+ }
+ }
+
+ /**
+ * build key value pairs, key is created by recursively adding section names, delimited by "."
+ * @param string $prefix
+ * @param string $key
+ * @param mixed $data
+ */
+ protected function addEntry($prefix, $key, $data) {
+ $sql = array();
+
+ if ($data instanceof Zend_Config) {
+ if ($prefix != '')
+ $prefix .= '.';
+ $prefix .= $key;
+ foreach ($data as $k => $v) {
+ $sql = array_merge($sql, $this->addEntry($prefix, $k, $v));
+ }
+ }
+ else {
+ $string = 'insert into ' . $this->_tableName . ' set ';
+ $pkey = $prefix;
+ if ($pkey != '')
+ $pkey .= '.';
+ $pkey .= $key;
+ $string .= 'config_key=' . $this->_prepareValue($pkey) . ', ';
+ $string .= 'config_value=' . $this->_prepareValue($data);
+ if ($this->_set !== null)
+ $string .= ', ' . $this->_set;
+
+ $sql[] = $string;
+ }
+
+ return $sql;
+ }
+
+ /**
+ * Add a branch to an INI string recursively
+ *
+ * @param Zend_Config $config
+ * @return void
+ */
+ protected function _addBranch(Zend_Config $config, $parents = array())
+ {
+ $iniString = '';
+
+ foreach ($config as $key => $value) {
+ $group = array_merge($parents, array($key));
+
+ if ($value instanceof Zend_Config) {
+ $iniString .= $this->_addBranch($value, $group);
+ } else {
+ $iniString .= implode($this->_nestSeparator, $group)
+ . ' = '
+ . $this->_prepareValue($value)
+ . "\n";
+ }
+ }
+
+ return $iniString;
+ }
+
+ /**
+ * Prepare a value for INI
+ *
+ * @param mixed $value
+ * @return string
+ */
+ protected function _prepareValue($value)
+ {
+ if (is_integer($value) || is_float($value)) {
+ return $value;
+ } elseif (is_bool($value)) {
+ return ($value ? 'true' : 'false');
+ } else {
+ return '"' . addslashes($value) . '"';
+ }
+ }
+}
diff --git a/manager/library/date/HumanReadableTime.php b/manager/library/date/HumanReadableTime.php
index ee75703..3d33f9a 100644
--- a/manager/library/date/HumanReadableTime.php
+++ b/manager/library/date/HumanReadableTime.php
@@ -1,140 +1,140 @@
-<?php
-
-/**
- * class that provides methods to convert human readable time / interval length
- * expressions into other formats
- *
- * @author markus
- * $Id: HumanReadableTime.php 92 2010-03-10 11:43:15Z markus $
- */
-
-require_once(LIBRARY_PATH . '/date/exception.HumanReadableTimeException.php');
-
-class HumanReadableTime {
- /**
- * normalize an HRT string, convert from HRT to seconds and then convert back to
- * HRT
- * @param string $hrt
- * @param string $maxunit
- * @return string
- */
- public static function NormalizeHRT($hrt, $maxunit = 'w') {
- return self::Seconds2HR(self::HR2Seconds($hrt), $maxunit);
- }
-
- /**
- * convert string / interger which contains an interval length to
- * human readable format (1w2d7h)
- *
- * if $maxunit is set, it defines the biggest unit in output (i.e. $maxunit = 'h' will
- * allow only hms)
- *
- * @param string|integer $seconds
- * @param string $maxunit
- * @return string
- */
- public static function Seconds2HR($seconds, $maxunit = 'w') {
- $maxunit = trim(strtolower($maxunit));
- $allowed = array('w' => 0, 'd' => 0, 'h' => 0, 'm' => 0, 's' => 0);
- if (!in_array($maxunit, array_keys($allowed), true))
- throw new HumanReadableTimeException('illegal value for maxunit: "' . $maxunit . '"');
- foreach ($allowed as $key => $value) {
- if ($maxunit == $key)
- break;
- unset($allowed[$key]);
- }
-
- $seconds = intval($seconds);
- $hrt = '';
- foreach ($allowed as $key => $value) {
- switch ($key) {
- case 'w':
- $tmp = intval($seconds / (7*86400));
- if ($tmp > 0)
- $seconds %= (7*86400);
- $allowed[$key] += $tmp;
- break;
- case 'd':
- $tmp = intval($seconds / (86400));
- if ($tmp > 0)
- $seconds %= (86400);
- $allowed[$key] += $tmp;
- break;
- case 'h':
- $tmp = intval($seconds / (3600));
- if ($tmp > 0)
- $seconds %= (3600);
- $allowed[$key] += $tmp;
- break;
- case 'm':
- $tmp = intval($seconds / (60));
- if ($tmp > 0)
- $seconds %= (60);
- $allowed[$key] += $tmp;
- break;
- case 's':
- $allowed[$key] += $seconds;
- break;
- }
- }
-
- $hrt = '';
- foreach ($allowed as $key => $value) {
- if ($value > 0)
- $hrt .= sprintf('%d%s', $value, $key);
- }
- return $hrt;
- }
-
- /**
- * parse a string of 3h2m7s and return the number of seconds as integer
- * add "s" to the end of the number if $addsecond is set to true
- * @param string $hr
- * @param boolean $addsecond
- * @return integer|string
- */
- public static function HR2Seconds($hr, $addsecond = false) {
- $hr = trim($hr);
- if ($hr == '') {
- if ($addsecond === true)
- return '0s';
- else
- return 0;
- }
-
- $hr = strtolower($hr);
-
- $matches = array();
- if (preg_match_all('/([0-9]*)([wdhms])/', $hr, $matches, PREG_SET_ORDER) > 0) {
- $interval = 0;
- for ($i = 0; $i < count($matches); $i++) {
- switch ($matches[$i][2]) {
- case 'w':
- $interval += $matches[$i][1] * 7 * 86400;
- break;
- case 'd':
- $interval += $matches[$i][1] * 86400;
- break;
- case 'h':
- $interval += $matches[$i][1] * 3600;
- break;
- case 'm':
- $interval += $matches[$i][1] * 60;
- break;
- case 's':
- $interval += $matches[$i][1];
- break;
- }
- }
- if ($addsecond === true)
- return sprintf('%ds', $interval);
- else
- return $interval;
- }
-
- if ($addsecond === true)
- return '0s';
- else
- return 0;
- }
-}
+<?php
+
+/**
+ * class that provides methods to convert human readable time / interval length
+ * expressions into other formats
+ *
+ * @author markus
+ * $Id: HumanReadableTime.php 92 2010-03-10 11:43:15Z markus $
+ */
+
+require_once(LIBRARY_PATH . '/date/exception.HumanReadableTimeException.php');
+
+class HumanReadableTime {
+ /**
+ * normalize an HRT string, convert from HRT to seconds and then convert back to
+ * HRT
+ * @param string $hrt
+ * @param string $maxunit
+ * @return string
+ */
+ public static function NormalizeHRT($hrt, $maxunit = 'w') {
+ return self::Seconds2HR(self::HR2Seconds($hrt), $maxunit);
+ }
+
+ /**
+ * convert string / interger which contains an interval length to
+ * human readable format (1w2d7h)
+ *
+ * if $maxunit is set, it defines the biggest unit in output (i.e. $maxunit = 'h' will
+ * allow only hms)
+ *
+ * @param string|integer $seconds
+ * @param string $maxunit
+ * @return string
+ */
+ public static function Seconds2HR($seconds, $maxunit = 'w') {
+ $maxunit = trim(strtolower($maxunit));
+ $allowed = array('w' => 0, 'd' => 0, 'h' => 0, 'm' => 0, 's' => 0);
+ if (!in_array($maxunit, array_keys($allowed), true))
+ throw new HumanReadableTimeException('illegal value for maxunit: "' . $maxunit . '"');
+ foreach ($allowed as $key => $value) {
+ if ($maxunit == $key)
+ break;
+ unset($allowed[$key]);
+ }
+
+ $seconds = intval($seconds);
+ $hrt = '';
+ foreach ($allowed as $key => $value) {
+ switch ($key) {
+ case 'w':
+ $tmp = intval($seconds / (7*86400));
+ if ($tmp > 0)
+ $seconds %= (7*86400);
+ $allowed[$key] += $tmp;
+ break;
+ case 'd':
+ $tmp = intval($seconds / (86400));
+ if ($tmp > 0)
+ $seconds %= (86400);
+ $allowed[$key] += $tmp;
+ break;
+ case 'h':
+ $tmp = intval($seconds / (3600));
+ if ($tmp > 0)
+ $seconds %= (3600);
+ $allowed[$key] += $tmp;
+ break;
+ case 'm':
+ $tmp = intval($seconds / (60));
+ if ($tmp > 0)
+ $seconds %= (60);
+ $allowed[$key] += $tmp;
+ break;
+ case 's':
+ $allowed[$key] += $seconds;
+ break;
+ }
+ }
+
+ $hrt = '';
+ foreach ($allowed as $key => $value) {
+ if ($value > 0)
+ $hrt .= sprintf('%d%s', $value, $key);
+ }
+ return $hrt;
+ }
+
+ /**
+ * parse a string of 3h2m7s and return the number of seconds as integer
+ * add "s" to the end of the number if $addsecond is set to true
+ * @param string $hr
+ * @param boolean $addsecond
+ * @return integer|string
+ */
+ public static function HR2Seconds($hr, $addsecond = false) {
+ $hr = trim($hr);
+ if ($hr == '') {
+ if ($addsecond === true)
+ return '0s';
+ else
+ return 0;
+ }
+
+ $hr = strtolower($hr);
+
+ $matches = array();
+ if (preg_match_all('/([0-9]*)([wdhms])/', $hr, $matches, PREG_SET_ORDER) > 0) {
+ $interval = 0;
+ for ($i = 0; $i < count($matches); $i++) {
+ switch ($matches[$i][2]) {
+ case 'w':
+ $interval += $matches[$i][1] * 7 * 86400;
+ break;
+ case 'd':
+ $interval += $matches[$i][1] * 86400;
+ break;
+ case 'h':
+ $interval += $matches[$i][1] * 3600;
+ break;
+ case 'm':
+ $interval += $matches[$i][1] * 60;
+ break;
+ case 's':
+ $interval += $matches[$i][1];
+ break;
+ }
+ }
+ if ($addsecond === true)
+ return sprintf('%ds', $interval);
+ else
+ return $interval;
+ }
+
+ if ($addsecond === true)
+ return '0s';
+ else
+ return 0;
+ }
+}
diff --git a/manager/library/date/exception.HumanReadableTimeException.php b/manager/library/date/exception.HumanReadableTimeException.php
index 2698d58..67d38e8 100644
--- a/manager/library/date/exception.HumanReadableTimeException.php
+++ b/manager/library/date/exception.HumanReadableTimeException.php
@@ -1,37 +1,36 @@
-<?php
-/**
- * @package SLS
- * @subpackage CONFIG.EXCEPTION
- */
-
-/**
- * required files
- * @ignore
- */
-require_once(LIBRARY_PATH . '/exception/exception.Base.php');
-
-/**
- * Exceptions thrown in the DNSSEC library classes
- *
- * @package SLS
- * @subpackage CONFIG.EXCEPTION
- * @author Markus Warg <mw@it-sls.de>
- * @since 2009-02-25 13:05
- * @version $Id: exception.HumanReadableTimeException.php 91 2010-03-10 10:36:25Z markus $
- */
-class HumanReadableTimeException extends BaseException {
- /**
- * make new object
- *
- * @access public
- * @param string $message
- * @param int $code
- * @param string $extra
- */
- /*
- public function __construct($message,$code = 0,$extra = '') {
- parent::__construct($message,$code, $extra);
- }
- */
-}
-?> \ No newline at end of file
+<?php
+/**
+ * @package SLS
+ * @subpackage CONFIG.EXCEPTION
+ */
+
+/**
+ * required files
+ * @ignore
+ */
+require_once(LIBRARY_PATH . '/exception/exception.Base.php');
+
+/**
+ * Exceptions thrown in the DNSSEC library classes
+ *
+ * @package SLS
+ * @subpackage CONFIG.EXCEPTION
+ * @author Markus Warg <mw@it-sls.de>
+ * @since 2009-02-25 13:05
+ * @version $Id: exception.HumanReadableTimeException.php 91 2010-03-10 10:36:25Z markus $
+ */
+class HumanReadableTimeException extends BaseException {
+ /**
+ * make new object
+ *
+ * @access public
+ * @param string $message
+ * @param int $code
+ * @param string $extra
+ */
+ /*
+ public function __construct($message,$code = 0,$extra = '') {
+ parent::__construct($message,$code, $extra);
+ }
+ */
+}
diff --git a/manager/library/date/testHumanReadableTime.php b/manager/library/date/testHumanReadableTime.php
index 177d650..dfcd96c 100644
--- a/manager/library/date/testHumanReadableTime.php
+++ b/manager/library/date/testHumanReadableTime.php
@@ -1,16 +1,15 @@
-<?php
-defined('LIBARARY_PATH')
- || define('LIBRARY_PATH', realpath(dirname(__FILE__) . '/..'));
-
-require_once('HumanReadableTime.php');
-
-$hrf = HumanReadableTime::HR2Seconds($argv[1], true);
-print 'Seconds: ' . $hrf . "\n";
-
-print 'Default: ' . HumanReadableTime::Seconds2HR($hrf) . "\n";
-print 'Week: ' . HumanReadableTime::Seconds2HR($hrf, 'w') . "\n";
-print 'Day: ' . HumanReadableTime::Seconds2HR($hrf, 'd') . "\n";
-print 'Hour: ' . HumanReadableTime::Seconds2HR($hrf, 'h') . "\n";
-print 'Minute: ' . HumanReadableTime::Seconds2HR($hrf, 'm') . "\n";
-print 'Second: ' . HumanReadableTime::Seconds2HR($hrf, 's') . "\n";
-
+<?php
+defined('LIBARARY_PATH')
+ || define('LIBRARY_PATH', realpath(dirname(__FILE__) . '/..'));
+
+require_once('HumanReadableTime.php');
+
+$hrf = HumanReadableTime::HR2Seconds($argv[1], true);
+print 'Seconds: ' . $hrf . "\n";
+
+print 'Default: ' . HumanReadableTime::Seconds2HR($hrf) . "\n";
+print 'Week: ' . HumanReadableTime::Seconds2HR($hrf, 'w') . "\n";
+print 'Day: ' . HumanReadableTime::Seconds2HR($hrf, 'd') . "\n";
+print 'Hour: ' . HumanReadableTime::Seconds2HR($hrf, 'h') . "\n";
+print 'Minute: ' . HumanReadableTime::Seconds2HR($hrf, 'm') . "\n";
+print 'Second: ' . HumanReadableTime::Seconds2HR($hrf, 's') . "\n";
diff --git a/manager/library/exception/exception.Base.php b/manager/library/exception/exception.Base.php
index a91c086..d7f2a2c 100644
--- a/manager/library/exception/exception.Base.php
+++ b/manager/library/exception/exception.Base.php
@@ -1,98 +1,97 @@
-<?php
-/**
- * @package SLS
- * @subpackage EXCEPTION
- */
-
-/**
- * extend PHPs standard exception by some details
- *
- * @package SLS
- * @subpackage EXCEPTION
- * @author Markus Warg <mw@it-sls.de>
- * @since 2009-02-23 16:10
- * @version $Id: exception.Base.php 90 2010-03-09 09:48:27Z markus $
- */
-class BaseException extends Exception {
- /**
- * additional data / string
- * @var string
- */
- protected $extra = '';
-
- /**
- * location of thrower
- * @var string
- */
- protected $exception_location = '';
-
- /**
- * make new object
- *
- * @access public
- * @param string $message
- * @param int $code
- */
- public function __construct($message, $code = 0, $extra = '') {
- $bt = debug_backtrace();
-
- $remove_exception = 0;
- while( $remove_exception < count($bt) && isset($bt[$remove_exception]['class']) && eregi('exception', $bt[$remove_exception]['class']) ) {
- $remove_exception++;
- }
-
- if ($remove_exception > 0)
- $remove_exception--;
-
- if ($remove_exception < count($bt)) {
- $this->exception_location = $bt[$remove_exception]['file'].':'.$bt[$remove_exception]['line'];
- }
-
- $this->extra = $extra;
-
- parent::__construct($message,$code);
- }
-
- /**
- * Make a string out of this exception
- *
- * @access public
- * @return string
- */
- public function __toString() {
- $out = __CLASS__ . '['.$this->code.']:';
-
- if ($this->exception_location != '')
- $out.= $this->exception_location;
- $out .= ':';
-
- $out .= " {$this->message}";
-
- if (isset($this->extra) && strlen($this->extra) > 0)
- $out .= " ({$this->extra})\n";
-
- return $out;
- }
-
- /**
- * get the extra info string
- *
- * @access public
- * @return string
- */
- public function getExtraInfo() {
- return $this->extra;
- }
-
- /**
- * get the exception location string
- *
- * @access public
- * @return string
- */
- public function getExceptionLocation() {
- return $this->exception_location;
- }
-
-}
-?> \ No newline at end of file
+<?php
+/**
+ * @package SLS
+ * @subpackage EXCEPTION
+ */
+
+/**
+ * extend PHPs standard exception by some details
+ *
+ * @package SLS
+ * @subpackage EXCEPTION
+ * @author Markus Warg <mw@it-sls.de>
+ * @since 2009-02-23 16:10
+ * @version $Id: exception.Base.php 90 2010-03-09 09:48:27Z markus $
+ */
+class BaseException extends Exception {
+ /**
+ * additional data / string
+ * @var string
+ */
+ protected $extra = '';
+
+ /**
+ * location of thrower
+ * @var string
+ */
+ protected $exception_location = '';
+
+ /**
+ * make new object
+ *
+ * @access public
+ * @param string $message
+ * @param int $code
+ */
+ public function __construct($message, $code = 0, $extra = '') {
+ $bt = debug_backtrace();
+
+ $remove_exception = 0;
+ while( $remove_exception < count($bt) && isset($bt[$remove_exception]['class']) && eregi('exception', $bt[$remove_exception]['class']) ) {
+ $remove_exception++;
+ }
+
+ if ($remove_exception > 0)
+ $remove_exception--;
+
+ if ($remove_exception < count($bt)) {
+ $this->exception_location = $bt[$remove_exception]['file'].':'.$bt[$remove_exception]['line'];
+ }
+
+ $this->extra = $extra;
+
+ parent::__construct($message,$code);
+ }
+
+ /**
+ * Make a string out of this exception
+ *
+ * @access public
+ * @return string
+ */
+ public function __toString() {
+ $out = __CLASS__ . '['.$this->code.']:';
+
+ if ($this->exception_location != '')
+ $out.= $this->exception_location;
+ $out .= ':';
+
+ $out .= " {$this->message}";
+
+ if (isset($this->extra) && strlen($this->extra) > 0)
+ $out .= " ({$this->extra})\n";
+
+ return $out;
+ }
+
+ /**
+ * get the extra info string
+ *
+ * @access public
+ * @return string
+ */
+ public function getExtraInfo() {
+ return $this->extra;
+ }
+
+ /**
+ * get the exception location string
+ *
+ * @access public
+ * @return string
+ */
+ public function getExceptionLocation() {
+ return $this->exception_location;
+ }
+
+}
diff --git a/manager/library/global/defines.php b/manager/library/global/defines.php
index 4e90ac5..30d6ebc 100644
--- a/manager/library/global/defines.php
+++ b/manager/library/global/defines.php
@@ -1,28 +1,28 @@
-<?php
-/**
- * @author markus
- * $Id: defines.php 95 2010-03-19 14:14:39Z markus $
- */
-
-// Define path to application directory
-defined('APPLICATION_PATH')
- || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../../application'));
-defined('LIBARARY_PATH')
- || define('LIBRARY_PATH', realpath(dirname(__FILE__) . '/..'));
-defined('FWACTIONS_PATH')
- || define('FWACTIONS_PATH', LIBRARY_PATH . '/actions');
-defined('LOCALE_PATH')
- || define('LOCALE_PATH', realpath(dirname(__FILE__) . '/../../locale'));
-
-// Define application environment
-defined('APPLICATION_ENV')
- || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
-
-define('SYSTEM_CONFIG', 'system_config');
-define('SYSTEM_LOG', 'log');
-
-// Ensure library/ is on include_path
-set_include_path(implode(PATH_SEPARATOR, array(
- LIBRARY_PATH,
- get_include_path(),
-)));
+<?php
+/**
+ * @author markus
+ * $Id: defines.php 95 2010-03-19 14:14:39Z markus $
+ */
+
+// Define path to application directory
+defined('APPLICATION_PATH')
+ || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../../application'));
+defined('LIBARARY_PATH')
+ || define('LIBRARY_PATH', realpath(dirname(__FILE__) . '/..'));
+defined('FWACTIONS_PATH')
+ || define('FWACTIONS_PATH', LIBRARY_PATH . '/actions');
+defined('LOCALE_PATH')
+ || define('LOCALE_PATH', realpath(dirname(__FILE__) . '/../../locale'));
+
+// Define application environment
+defined('APPLICATION_ENV')
+ || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
+
+define('SYSTEM_CONFIG', 'system_config');
+define('SYSTEM_LOG', 'log');
+
+// Ensure library/ is on include_path
+set_include_path(implode(PATH_SEPARATOR, array(
+ LIBRARY_PATH,
+ get_include_path(),
+)));
diff --git a/manager/library/i18n/I18n.php b/manager/library/i18n/I18n.php
index ea103c7..961ae6c 100644
--- a/manager/library/i18n/I18n.php
+++ b/manager/library/i18n/I18n.php
@@ -1,95 +1,95 @@
-<?php
-/**
- * encapsulate Zend_Translate within an singleton class
- * @author markus
- * $Id: I18n.php 33 2009-12-10 15:08:38Z markus $
- */
-
-require_once('l10n/L10n.php');
-
-class I18n {
- /**
- * static pointer to instance
- * @var array(I18n)
- */
- private static $instance = null;
-
- /**
- * config object
- * @var Zend_Translate
- */
- private $translate = null;
-
- /**
- * make new translate
- */
- protected function __construct() {
- $options = array(
- 'log' => Log::Log(),
- 'logUntranslated' => false
- );
-
- $locale = L10n::getInstance();
- $supported = $locale->getBrowser();
- arsort($supported, SORT_NUMERIC);
-
- $file = '';
- foreach ($supported as $loc => $val) {
- if (file_exists(LOCALE_PATH . '/' . $loc . '/locale.php')) {
- $file = LOCALE_PATH . '/' . $loc . '/locale.php';
- $locale->setLocale($loc);
- break;
- }
- }
-
- if ($file == '' && file_exists(LOCALE_PATH . '/en_US/locale.php')) {
- $file = LOCALE_PATH . '/en_US/locale.php';
- $locale->setLocale('en_US');
- }
-
- if ($file != '') {
- $this->translate = new Zend_Translate(Zend_Translate::AN_ARRAY, $file, $locale->getLanguage(), $options);
- #Log::Log()->debug('locale ' . $locale->getLanguage() . '_' .$locale->getRegion() . ' loaded');
- }
- else
- throw new Exception(__METHOD__ . ': no translation files available');
- }
-
- /**
- * get already existing instance, make new instance or throw an exception
- * @return I18n
- */
- public static function getInstance() {
- if (self::$instance === null) {
- self::$instance = new I18n();
- }
-
- return self::$instance;
- }
-
- /**
- * return the Zend_Translate object
- * @return Zend_Translate
- */
- public static function getTranslate() {
- return self::getInstance()->translate;
- }
-
- /**
- * map _ to translate
- * @param unknown_type $text
- * @param unknown_type $locale
- */
- public function _($text, $locale = null) {
- return self::getInstance()->translate->_($text, $locale);
- }
-
- /**
- * magic __call dispatches all unknown methods to Zend_Translate
- * @param unknown_type $method
- * @param unknown_type $arguments
- */
- public function __call($method, $arguments) {
- return call_user_func_array(array($this->translate, $method), $arguments);
- }
-}
+<?php
+/**
+ * encapsulate Zend_Translate within an singleton class
+ * @author markus
+ * $Id: I18n.php 33 2009-12-10 15:08:38Z markus $
+ */
+
+require_once('l10n/L10n.php');
+
+class I18n {
+ /**
+ * static pointer to instance
+ * @var array(I18n)
+ */
+ private static $instance = null;
+
+ /**
+ * config object
+ * @var Zend_Translate
+ */
+ private $translate = null;
+
+ /**
+ * make new translate
+ */
+ protected function __construct() {
+ $options = array(
+ 'log' => Log::Log(),
+ 'logUntranslated' => false
+ );
+
+ $locale = L10n::getInstance();
+ $supported = $locale->getBrowser();
+ arsort($supported, SORT_NUMERIC);
+
+ $file = '';
+ foreach ($supported as $loc => $val) {
+ if (file_exists(LOCALE_PATH . '/' . $loc . '/locale.php')) {
+ $file = LOCALE_PATH . '/' . $loc . '/locale.php';
+ $locale->setLocale($loc);
+ break;
+ }
+ }
+
+ if ($file == '' && file_exists(LOCALE_PATH . '/en_US/locale.php')) {
+ $file = LOCALE_PATH . '/en_US/locale.php';
+ $locale->setLocale('en_US');
+ }
+
+ if ($file != '') {
+ $this->translate = new Zend_Translate(Zend_Translate::AN_ARRAY, $file, $locale->getLanguage(), $options);
+ #Log::Log()->debug('locale ' . $locale->getLanguage() . '_' .$locale->getRegion() . ' loaded');
+ }
+ else
+ throw new Exception(__METHOD__ . ': no translation files available');
+ }
+
+ /**
+ * get already existing instance, make new instance or throw an exception
+ * @return I18n
+ */
+ public static function getInstance() {
+ if (self::$instance === null) {
+ self::$instance = new I18n();
+ }
+
+ return self::$instance;
+ }
+
+ /**
+ * return the Zend_Translate object
+ * @return Zend_Translate
+ */
+ public static function getTranslate() {
+ return self::getInstance()->translate;
+ }
+
+ /**
+ * map _ to translate
+ * @param unknown_type $text
+ * @param unknown_type $locale
+ */
+ public function _($text, $locale = null) {
+ return self::getInstance()->translate->_($text, $locale);
+ }
+
+ /**
+ * magic __call dispatches all unknown methods to Zend_Translate
+ * @param unknown_type $method
+ * @param unknown_type $arguments
+ */
+ public function __call($method, $arguments) {
+ return call_user_func_array(array($this->translate, $method), $arguments);
+ }
+}
diff --git a/manager/library/imap/exception.IMAPException.php b/manager/library/imap/exception.IMAPException.php
index 4672f6a..23780ed 100644
--- a/manager/library/imap/exception.IMAPException.php
+++ b/manager/library/imap/exception.IMAPException.php
@@ -1,34 +1,34 @@
-<?php
-/**
- * @author markus
- * $Id: $
- */
-
-/**
- * required files
- * @ignore
- */
-require_once(LIBRARY_PATH . '/exception/exception.Base.php');
-
-/**
- * Exceptions thrown in the IMAP classes
- *
- * @package SLS
- * @subpackage CONFIG.EXCEPTION
- * @author Markus Warg <mw@it-sls.de>
- */
-class IMAPException extends BaseException {
- /**
- * make new object
- *
- * @access public
- * @param string $message
- * @param int $code
- * @param string $extra
- */
- /*
- public function __construct($message,$code = 0,$extra = '') {
- parent::__construct($message,$code, $extra);
- }
- */
-}
+<?php
+/**
+ * @author markus
+ * $Id: $
+ */
+
+/**
+ * required files
+ * @ignore
+ */
+require_once(LIBRARY_PATH . '/exception/exception.Base.php');
+
+/**
+ * Exceptions thrown in the IMAP classes
+ *
+ * @package SLS
+ * @subpackage CONFIG.EXCEPTION
+ * @author Markus Warg <mw@it-sls.de>
+ */
+class IMAPException extends BaseException {
+ /**
+ * make new object
+ *
+ * @access public
+ * @param string $message
+ * @param int $code
+ * @param string $extra
+ */
+ /*
+ public function __construct($message,$code = 0,$extra = '') {
+ parent::__construct($message,$code, $extra);
+ }
+ */
+}
diff --git a/manager/library/l10n/L10n.php b/manager/library/l10n/L10n.php
index 80fb091..01a8d1b 100644
--- a/manager/library/l10n/L10n.php
+++ b/manager/library/l10n/L10n.php
@@ -1,47 +1,47 @@
-<?php
-/**
- * encapsulate Zend_Locale within an singleton class
- * @author markus
- * $Id: L10n.php 13 2009-11-24 14:52:56Z markus $
- */
-class L10n {
- /**
- * static pointer to instance
- * @var L10n
- */
- private static $instance = null;
-
- /**
- * config object
- * @var Zend_Locale
- */
- private $locale = null;
-
- /**
- * make new translate
- */
- protected function __construct() {
- $this->locale = new Zend_Locale();
- }
-
- /**
- * get already existing instance, make new instance or throw an exception
- * @return L10n
- */
- public static function getInstance() {
- if (self::$instance === null) {
- self::$instance = new L10n();
- }
-
- return self::$instance;
- }
-
- /**
- * magic __call dispatches all unknown methods to Zend_Locale
- * @param unknown_type $method
- * @param unknown_type $arguments
- */
- public function __call($method, $arguments) {
- return call_user_func_array(array($this->locale, $method), $arguments);
- }
-}
+<?php
+/**
+ * encapsulate Zend_Locale within an singleton class
+ * @author markus
+ * $Id: L10n.php 13 2009-11-24 14:52:56Z markus $
+ */
+class L10n {
+ /**
+ * static pointer to instance
+ * @var L10n
+ */
+ private static $instance = null;
+
+ /**
+ * config object
+ * @var Zend_Locale
+ */
+ private $locale = null;
+
+ /**
+ * make new translate
+ */
+ protected function __construct() {
+ $this->locale = new Zend_Locale();
+ }
+
+ /**
+ * get already existing instance, make new instance or throw an exception
+ * @return L10n
+ */
+ public static function getInstance() {
+ if (self::$instance === null) {
+ self::$instance = new L10n();
+ }
+
+ return self::$instance;
+ }
+
+ /**
+ * magic __call dispatches all unknown methods to Zend_Locale
+ * @param unknown_type $method
+ * @param unknown_type $arguments
+ */
+ public function __call($method, $arguments) {
+ return call_user_func_array(array($this->locale, $method), $arguments);
+ }
+}
diff --git a/manager/library/log/Log.php b/manager/library/log/Log.php
index 8ad27b9..af97c9d 100644
--- a/manager/library/log/Log.php
+++ b/manager/library/log/Log.php
@@ -1,105 +1,105 @@
-<?php
-/**
- * encapsulate Zend_Log with one or several log writers within an singleton class
- * @author markus
- * $Id: Log.php 77 2010-02-26 11:58:34Z markus $
- */
-class Log {
- /**
- * static pointer to instances
- * @var array(Config)
- */
- private static $instances = array();
-
- /**
- * can handle several instances, distinct by instance name string
- * @var string
- */
- private $instanceName = '';
-
- /**
- * config object
- * @var Zend_Log
- */
- private $log = null;
-
- /**
- * make new logger, configuration is taken from system_config, section $instanceName
- * @param string $instanceName
- * @param string $application
- */
- protected function __construct($instanceName, $application = null) {
- if ($instanceName === null)
- throw new Exception(__METHOD__ . ': expected an instance name, got none');
-
- $config = Config::getInstance(SYSTEM_CONFIG);
- $log_config = $config->$instanceName;
-
- $this->log = new Zend_Log();
- if (isset($log_config->file) && intval($log_config->file->enabled) !== 0) {
- $file_logger = new Zend_Log_Writer_Stream($log_config->file->name);
-
- /**
- *
- $format = Zend_Log_Formatter_Simple::DEFAULT_FORMAT;
- $formatter = new Zend_Log_Formatter_Simple($format);
- $file_logger->setFormatter($formatter);
- */
- if (isset($application) && $application != '')
- $this->log->setEventItem('application', $application);
- $formatter = new Zend_Log_Formatter_Simple('%syslog_time% %application%[%pid%]: %priorityName%: %message%' . PHP_EOL);
- $file_logger->setFormatter($formatter);
- $this->log->addWriter($file_logger);
- }
- if (isset($log_config->syslog) && intval($log_config->syslog->enabled) !== 0) {
- $param = array('facility' => $log_config->syslog->facility);
- if (isset($application) && $application != '')
- $param['application'] = $application;
-
- $sys_logger = new Zend_Log_Writer_Syslog($param);
- $formatter = new Zend_Log_Formatter_Simple('%priorityName%: %message%' . PHP_EOL);
- $sys_logger->setFormatter($formatter);
- $this->log->addWriter($sys_logger);
- }
-
- $filter = new Zend_Log_Filter_Priority(intval($log_config->priority));
- $this->log->addFilter($filter);
- }
-
- /**
- * get already existing instance, make new instance or throw an exception
- * @param string $instanceName
- * @param string $application
- */
- public static function getInstance($instanceName = null, $application = null) {
- if ($instanceName === null) {
- if (count(self::$instances) == 0)
- throw new Exception(__METHOD__ . ': expected an instance name, got none');
- return self::$instances[0];
- }
-
- if (!array_key_exists($instanceName, self::$instances)) {
- self::$instances[$instanceName] = new Log($instanceName, $application);
- }
-
- return self::$instances[$instanceName];
- }
-
- /**
- * return SYSTEM_LOG for convenience
- * @return Zend_Log
- */
- public static function Log() {
- return self::$instances[SYSTEM_LOG]->getLog();
- }
-
- /**
- * get the Zend_Log object
- * @return Zend_Log
- */
- public function getLog() {
- $this->log->setEventItem('pid', posix_getpid());
- $this->log->setEventItem('syslog_time', date('Y-m-d H:i:s'));
- return $this->log;
- }
-}
+<?php
+/**
+ * encapsulate Zend_Log with one or several log writers within an singleton class
+ * @author markus
+ * $Id: Log.php 77 2010-02-26 11:58:34Z markus $
+ */
+class Log {
+ /**
+ * static pointer to instances
+ * @var array(Config)
+ */
+ private static $instances = array();
+
+ /**
+ * can handle several instances, distinct by instance name string
+ * @var string
+ */
+ private $instanceName = '';
+
+ /**
+ * config object
+ * @var Zend_Log
+ */
+ private $log = null;
+
+ /**
+ * make new logger, configuration is taken from system_config, section $instanceName
+ * @param string $instanceName
+ * @param string $application
+ */
+ protected function __construct($instanceName, $application = null) {
+ if ($instanceName === null)
+ throw new Exception(__METHOD__ . ': expected an instance name, got none');
+
+ $config = Config::getInstance(SYSTEM_CONFIG);
+ $log_config = $config->$instanceName;
+
+ $this->log = new Zend_Log();
+ if (isset($log_config->file) && intval($log_config->file->enabled) !== 0) {
+ $file_logger = new Zend_Log_Writer_Stream($log_config->file->name);
+
+ /**
+ *
+ $format = Zend_Log_Formatter_Simple::DEFAULT_FORMAT;
+ $formatter = new Zend_Log_Formatter_Simple($format);
+ $file_logger->setFormatter($formatter);
+ */
+ if (isset($application) && $application != '')
+ $this->log->setEventItem('application', $application);
+ $formatter = new Zend_Log_Formatter_Simple('%syslog_time% %application%[%pid%]: %priorityName%: %message%' . PHP_EOL);
+ $file_logger->setFormatter($formatter);
+ $this->log->addWriter($file_logger);
+ }
+ if (isset($log_config->syslog) && intval($log_config->syslog->enabled) !== 0) {
+ $param = array('facility' => $log_config->syslog->facility);
+ if (isset($application) && $application != '')
+ $param['application'] = $application;
+
+ $sys_logger = new Zend_Log_Writer_Syslog($param);
+ $formatter = new Zend_Log_Formatter_Simple('%priorityName%: %message%' . PHP_EOL);
+ $sys_logger->setFormatter($formatter);
+ $this->log->addWriter($sys_logger);
+ }
+
+ $filter = new Zend_Log_Filter_Priority(intval($log_config->priority));
+ $this->log->addFilter($filter);
+ }
+
+ /**
+ * get already existing instance, make new instance or throw an exception
+ * @param string $instanceName
+ * @param string $application
+ */
+ public static function getInstance($instanceName = null, $application = null) {
+ if ($instanceName === null) {
+ if (count(self::$instances) == 0)
+ throw new Exception(__METHOD__ . ': expected an instance name, got none');
+ return self::$instances[0];
+ }
+
+ if (!array_key_exists($instanceName, self::$instances)) {
+ self::$instances[$instanceName] = new Log($instanceName, $application);
+ }
+
+ return self::$instances[$instanceName];
+ }
+
+ /**
+ * return SYSTEM_LOG for convenience
+ * @return Zend_Log
+ */
+ public static function Log() {
+ return self::$instances[SYSTEM_LOG]->getLog();
+ }
+
+ /**
+ * get the Zend_Log object
+ * @return Zend_Log
+ */
+ public function getLog() {
+ $this->log->setEventItem('pid', posix_getpid());
+ $this->log->setEventItem('syslog_time', date('Y-m-d H:i:s'));
+ return $this->log;
+ }
+}
diff --git a/manager/library/plugins/plugin.buildmenu.php b/manager/library/plugins/plugin.buildmenu.php
index d98b14e..f3cb261 100644
--- a/manager/library/plugins/plugin.buildmenu.php
+++ b/manager/library/plugins/plugin.buildmenu.php
@@ -1,74 +1,74 @@
-<?php
-
-/**
- * this plugin tries to add modules to the top navigation depending on the user
- * which is logged in and the required permissions needed (provided by the action modules)
- *
- * @author markus
- * $Id: plugin.buildmenu.php 95 2010-03-19 14:14:39Z markus $
- */
-class BuildMenu extends Zend_Controller_Plugin_Abstract {
- public function preDispatch(Zend_Controller_Request_Abstract $request) {
- $session = Zend_Registry::get('session');
- if (!isset($session->authdata) || !isset($session->authdata['authed']) || $session->authdata['authed'] === false)
- return;
-
- $cur_ctrl = $request->getControllerName();
- $cur_action = $request->getActionName();
-
- $view = Zend_Registry::get('view');
-
- if (is_dir(FWACTIONS_PATH)) {
- $dir = opendir(FWACTIONS_PATH);
-
- while (($file = readdir($dir)) !== false) {
- if ($file == '.' || $file == '..')
- continue;
- if (preg_match('/^Action([a-zA-Z0-9_]*)\.php/', $file, $match)) {
- $path = FWACTIONS_PATH . '/' . $file;
- require_once($path);
-
- $r = new ReflectionClass($match[1]);
-
- if ($r->isSubclassOf('FWAction')) {
- /**
- * match Actions permission with the permissions of the currently logged in user,
- * add to menu if user has access to that action
- */
-
- $required = $r->getMethod('getRequiredPermissions')->invoke(null);
- $menuprio = $r->getMethod('getTopNavPrio')->invoke(null);
- $ctrl = $r->getMethod('getController')->invoke(null);
- $action = $r->getMethod('getAction')->invoke(null);
- $text = $r->getMethod('getMenutext')->invoke(null);
- $role = $session->authdata['authed_role'];
-
- if ($cur_ctrl == $ctrl) # && $cur_action == $action)
- $aclass = ' class="active"';
- else
- $aclass = '';
-
- $acl = $session->authdata['authed_permissions'];
- if (is_array($required) && count($required) == 0) {
- $view->topNav('<a href="' .
- $view->url(array('controller' => $ctrl, 'action' => $action), 'default', true) .
- '"' . $aclass . '>' . I18n::_($text) . '</a>', Zend_View_Helper_Placeholder_Container_Abstract::SET, $menuprio);
- }
- else {
- foreach ($required as $rperm) {
- if ($acl->has($rperm) && $acl->isAllowed($role, $rperm, 'view')) {
- $view->topNav('<a href="' .
- $view->url(array('controller' => $ctrl, 'action' => $action), 'default', true) .
- '"' . $aclass . '>' . I18n::_($text) . '</a>', Zend_View_Helper_Placeholder_Container_Abstract::SET, $menuprio);
- break; // exit on first match
- }
- }
- }
- }
- }
- }
-
- closedir($dir);
- }
- }
-} \ No newline at end of file
+<?php
+
+/**
+ * this plugin tries to add modules to the top navigation depending on the user
+ * which is logged in and the required permissions needed (provided by the action modules)
+ *
+ * @author markus
+ * $Id: plugin.buildmenu.php 95 2010-03-19 14:14:39Z markus $
+ */
+class BuildMenu extends Zend_Controller_Plugin_Abstract {
+ public function preDispatch(Zend_Controller_Request_Abstract $request) {
+ $session = Zend_Registry::get('session');
+ if (!isset($session->authdata) || !isset($session->authdata['authed']) || $session->authdata['authed'] === false)
+ return;
+
+ $cur_ctrl = $request->getControllerName();
+ $cur_action = $request->getActionName();
+
+ $view = Zend_Registry::get('view');
+
+ if (is_dir(FWACTIONS_PATH)) {
+ $dir = opendir(FWACTIONS_PATH);
+
+ while (($file = readdir($dir)) !== false) {
+ if ($file == '.' || $file == '..')
+ continue;
+ if (preg_match('/^Action([a-zA-Z0-9_]*)\.php/', $file, $match)) {
+ $path = FWACTIONS_PATH . '/' . $file;
+ require_once($path);
+
+ $r = new ReflectionClass($match[1]);
+
+ if ($r->isSubclassOf('FWAction')) {
+ /**
+ * match Actions permission with the permissions of the currently logged in user,
+ * add to menu if user has access to that action
+ */
+
+ $required = $r->getMethod('getRequiredPermissions')->invoke(null);
+ $menuprio = $r->getMethod('getTopNavPrio')->invoke(null);
+ $ctrl = $r->getMethod('getController')->invoke(null);
+ $action = $r->getMethod('getAction')->invoke(null);
+ $text = $r->getMethod('getMenutext')->invoke(null);
+ $role = $session->authdata['authed_role'];
+
+ if ($cur_ctrl == $ctrl) # && $cur_action == $action)
+ $aclass = ' class="active"';
+ else
+ $aclass = '';
+
+ $acl = $session->authdata['authed_permissions'];
+ if (is_array($required) && count($required) == 0) {
+ $view->topNav('<a href="' .
+ $view->url(array('controller' => $ctrl, 'action' => $action), 'default', true) .
+ '"' . $aclass . '>' . I18n::_($text) . '</a>', Zend_View_Helper_Placeholder_Container_Abstract::SET, $menuprio);
+ }
+ else {
+ foreach ($required as $rperm) {
+ if ($acl->has($rperm) && $acl->isAllowed($role, $rperm, 'view')) {
+ $view->topNav('<a href="' .
+ $view->url(array('controller' => $ctrl, 'action' => $action), 'default', true) .
+ '"' . $aclass . '>' . I18n::_($text) . '</a>', Zend_View_Helper_Placeholder_Container_Abstract::SET, $menuprio);
+ break; // exit on first match
+ }
+ }
+ }
+ }
+ }
+ }
+
+ closedir($dir);
+ }
+ }
+}
diff --git a/manager/library/plugins/plugin.charsetheader.php b/manager/library/plugins/plugin.charsetheader.php
index 57e4f50..b5c3357 100644
--- a/manager/library/plugins/plugin.charsetheader.php
+++ b/manager/library/plugins/plugin.charsetheader.php
@@ -1,13 +1,13 @@
-<?php
-/**
- * @author markus
- * $Id: plugin.charsetheader.php 13 2009-11-24 14:52:56Z markus $
- */
-class CharsetHeader extends Zend_Controller_Plugin_Abstract {
- public function preDispatch(Zend_Controller_Request_Abstract $request) {
- $response = $this->getResponse();
- if ($response->canSendHeaders() === true) {
- $response->setHeader('Content-Type', 'text/html; charset=utf-8');
- }
- }
-} \ No newline at end of file
+<?php
+/**
+ * @author markus
+ * $Id: plugin.charsetheader.php 13 2009-11-24 14:52:56Z markus $
+ */
+class CharsetHeader extends Zend_Controller_Plugin_Abstract {
+ public function preDispatch(Zend_Controller_Request_Abstract $request) {
+ $response = $this->getResponse();
+ if ($response->canSendHeaders() === true) {
+ $response->setHeader('Content-Type', 'text/html; charset=utf-8');
+ }
+ }
+}
diff --git a/manager/library/plugins/plugin.forceauth.php b/manager/library/plugins/plugin.forceauth.php
index 4fa9068..004e500 100644
--- a/manager/library/plugins/plugin.forceauth.php
+++ b/manager/library/plugins/plugin.forceauth.php
@@ -1,29 +1,29 @@
-<?php
-/**
- * @author markus
- * $Id: plugin.forceauth.php 40 2009-12-21 09:40:43Z markus $
- */
-class ForceAuth extends Zend_Controller_Plugin_Abstract {
- public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request) {
- $session = Zend_Registry::get('session');
-
- if (in_array($request->getControllerName(), array('login', 'error', 'js', 'img', 'css')))
- return;
-
- if (!isset($session->authdata) || !isset($session->authdata['authed']) || $session->authdata['authed'] === false) {
- $fc = Zend_Controller_Front::getInstance();
-
- $response = $fc->getResponse();
- $response->canSendHeaders(true);
-
- $response->setHeader('Location', 'login', true);
- $response->setHeader('Status', '301', true);
- Log::Log()->debug('redirected to login');
-
- $request->setModuleName('default')
- ->setControllerName('login')
- ->setActionName('index')
- ->setDispatched(false);
- }
- }
-}
+<?php
+/**
+ * @author markus
+ * $Id: plugin.forceauth.php 40 2009-12-21 09:40:43Z markus $
+ */
+class ForceAuth extends Zend_Controller_Plugin_Abstract {
+ public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request) {
+ $session = Zend_Registry::get('session');
+
+ if (in_array($request->getControllerName(), array('login', 'error', 'js', 'img', 'css')))
+ return;
+
+ if (!isset($session->authdata) || !isset($session->authdata['authed']) || $session->authdata['authed'] === false) {
+ $fc = Zend_Controller_Front::getInstance();
+
+ $response = $fc->getResponse();
+ $response->canSendHeaders(true);
+
+ $response->setHeader('Location', 'login', true);
+ $response->setHeader('Status', '301', true);
+ Log::Log()->debug('redirected to login');
+
+ $request->setModuleName('default')
+ ->setControllerName('login')
+ ->setActionName('index')
+ ->setDispatched(false);
+ }
+ }
+}
diff --git a/manager/library/plugins/plugin.loginlogout.php b/manager/library/plugins/plugin.loginlogout.php
index 8bd13db..75885d6 100644
--- a/manager/library/plugins/plugin.loginlogout.php
+++ b/manager/library/plugins/plugin.loginlogout.php
@@ -1,31 +1,31 @@
-<?php
-
-/**
- * this plugin just monitors the authdata section in the current session and adds an login / logout link to the
- * top navigation bar depending on the value that was found
- * @author markus
- * $Id: plugin.loginlogout.php 95 2010-03-19 14:14:39Z markus $
- */
-class LoginLogout extends Zend_Controller_Plugin_Abstract {
- public function postDispatch(Zend_Controller_Request_Abstract $request) {
- $session = Zend_Registry::get('session');
- if (!isset($session->authdata) || !isset($session->authdata['authed']) || $session->authdata['authed'] === false) {
- $controller = 'login';
- $text = 'Login';
- }
- else {
- $controller = 'logout';
- $text = 'Logout';
- }
- $cur_ctrl = $request->getControllerName();
- if ($cur_ctrl == 'login')
- $aclass=' class="active"';
- else
- $aclass='';
-
- $view = Zend_Registry::get('view');
- $view->topNav('<a href="' .
- $view->url(array('controller' => $controller), 'default', true) .
- '"' . $aclass . '>' . I18n::_($text) . '</a>', Zend_View_Helper_Placeholder_Container_Abstract::SET, 1000);
- }
-}
+<?php
+
+/**
+ * this plugin just monitors the authdata section in the current session and adds an login / logout link to the
+ * top navigation bar depending on the value that was found
+ * @author markus
+ * $Id: plugin.loginlogout.php 95 2010-03-19 14:14:39Z markus $
+ */
+class LoginLogout extends Zend_Controller_Plugin_Abstract {
+ public function postDispatch(Zend_Controller_Request_Abstract $request) {
+ $session = Zend_Registry::get('session');
+ if (!isset($session->authdata) || !isset($session->authdata['authed']) || $session->authdata['authed'] === false) {
+ $controller = 'login';
+ $text = 'Login';
+ }
+ else {
+ $controller = 'logout';
+ $text = 'Logout';
+ }
+ $cur_ctrl = $request->getControllerName();
+ if ($cur_ctrl == 'login')
+ $aclass=' class="active"';
+ else
+ $aclass='';
+
+ $view = Zend_Registry::get('view');
+ $view->topNav('<a href="' .
+ $view->url(array('controller' => $controller), 'default', true) .
+ '"' . $aclass . '>' . I18n::_($text) . '</a>', Zend_View_Helper_Placeholder_Container_Abstract::SET, 1000);
+ }
+}