diff options
50 files changed, 502 insertions, 4649 deletions
diff --git a/public_html/bin/smarty_install.sh b/bin/smarty_install.sh index 2039743..2039743 100755 --- a/public_html/bin/smarty_install.sh +++ b/bin/smarty_install.sh diff --git a/cache/.htaccess b/cache/.htaccess new file mode 100644 index 0000000..93169e4 --- /dev/null +++ b/cache/.htaccess @@ -0,0 +1,2 @@ +Order deny,allow +Deny from all diff --git a/lib/client/kolab_admin_client_task_main.php b/lib/client/kolab_admin_client_task_main.php index d15a9ca..bd538cf 100644 --- a/lib/client/kolab_admin_client_task_main.php +++ b/lib/client/kolab_admin_client_task_main.php @@ -1,30 +1,27 @@ <?php - class kolab_admin_client_task_main extends kolab_admin_client_task - { - protected $menu = array( - 'user.default' => 'menu.users', - 'group.default' => 'menu.groups', - 'domain.default' => 'menu.domains', - 'about.default' => 'menu.about', - ); - +class kolab_admin_client_task_main extends kolab_admin_client_task +{ + protected $menu = array( + 'user.default' => 'menu.users', + 'group.default' => 'menu.groups', + 'about.default' => 'menu.about', + ); - public function action_default() - { - // assign token - $this->output->set_env('token', $_SESSION['user']['token']); - // add watermark content - $this->output->set_env('watermark', $this->output->get_template('watermark')); + public function action_default() + { + // assign token + $this->output->set_env('token', $_SESSION['user']['token']); - // assign default set of translations - $this->output->add_translation('loading', 'servererror', 'search'); + // add watermark content + $this->output->set_env('watermark', $this->output->get_template('watermark')); - $this->output->assign('main_menu', $this->menu()); - $this->output->assign('user', $_SESSION['user']); - } + // assign default set of translations + $this->output->add_translation('loading', 'servererror', 'search'); + $this->output->assign('main_menu', $this->menu()); + $this->output->assign('user', $_SESSION['user']); } -?> +} diff --git a/lib/client/kolab_admin_client_task_user.php b/lib/client/kolab_admin_client_task_user.php index 66c3d99..2550c7d 100644 --- a/lib/client/kolab_admin_client_task_user.php +++ b/lib/client/kolab_admin_client_task_user.php @@ -8,6 +8,9 @@ class kolab_admin_client_task_user extends kolab_admin_client_task 'add' => 'user.add', ); + /** + * Default action. + */ public function action_default() { $this->output->set_object('content', 'user', true); @@ -16,6 +19,9 @@ class kolab_admin_client_task_user extends kolab_admin_client_task $this->action_list(); } + /** + * Users list action. + */ public function action_list() { $result = $this->api->post('users.list'); @@ -54,12 +60,38 @@ class kolab_admin_client_task_user extends kolab_admin_client_task $this->output->set_object('userlist', $table); } + /** + * User information (form) action. + */ public function action_info() { $id = $this->get_input('id', 'POST'); $result = $this->api->get('user.info', array('user' => $id)); $user = $result->get($id); + $output = $this->user_form(null, $user); + + $this->output->set_object('taskcontent', $output); + } + + /** + * Users adding (form) action. + */ + public function action_add() + { + $output = $this->user_form(null, null); + + $this->output->set_object('taskcontent', $output); + } + + private function user_form($attribs, $data = array()) + { $form = new kolab_form(); + $utypes = $this->user_types(); + + foreach ($utypes as $idx => $elem) { + $utypes[$idx] = array('value' => $elem['key'], 'content' => $elem['name']); + } + $fields = array( 'personal' => array( 'label' => 'user.personal', @@ -71,12 +103,6 @@ class kolab_admin_client_task_user extends kolab_admin_client_task 'type' => kolab_form::INPUT_TEXT, 'maxlength' => 50, ), - 'initials' => array( - 'label' => 'user.initials', - 'description' => 'user.initials.desc', - 'type' => kolab_form::INPUT_TEXT, - 'maxlength' => 50, - ), 'sn' => array( 'label' => 'user.surname', 'description' => 'user.surname.desc', @@ -84,6 +110,12 @@ class kolab_admin_client_task_user extends kolab_admin_client_task 'type' => kolab_form::INPUT_TEXT, 'maxlength' => 50, ), + 'initials' => array( + 'label' => 'user.initials', + 'description' => 'user.initials.desc', + 'type' => kolab_form::INPUT_TEXT, + 'maxlength' => 50, + ), 'title' => array( 'label' => 'user.title', 'description' => 'user.title.desc', @@ -100,6 +132,41 @@ class kolab_admin_client_task_user extends kolab_admin_client_task 'description' => 'user.email.desc', 'type' => kolab_form::INPUT_TEXT, 'maxlength' => 50, + 'required' => true, + ), + 'uid' => array( + 'label' => 'user.uid', + 'description' => 'user.uid.desc', + 'type' => kolab_form::INPUT_TEXT, + 'maxlength' => 50, + 'required' => true, + ), + 'password' => array( + 'label' => 'user.password', + 'description' => 'user.password.desc', + 'type' => kolab_form::INPUT_TEXT, + 'maxlength' => 50, + 'required' => true, + ), + 'password2' => array( + 'label' => 'user.password-confirm', + 'description' => 'user.password-confirm.desc', + 'type' => kolab_form::INPUT_TEXT, + 'maxlength' => 50, + 'required' => true, + ), + 'kolabhomeserver' => array( + 'label' => 'user.homeserver', + 'description' => 'user.homeserver.desc', + 'type' => kolab_form::INPUT_TEXT, + 'maxlength' => 50, + 'required' => true, + ), + 'accttype' => array( + 'label' => 'user.type', + 'description' => 'user.type.desc', + 'type' => kolab_form::INPUT_SELECT, + 'options' => $utypes, ), ), ), @@ -111,12 +178,34 @@ class kolab_admin_client_task_user extends kolab_admin_client_task 'description' => 'user.quota.desc', 'type' => kolab_form::INPUT_TEXT, 'maxlength' => 10, + 'suffix' => 'MB', ), 'kolabFreeBusyFuture' => array( 'label' => 'user.fbinterval', 'description' => 'user.fbinterval.desc', 'type' => kolab_form::INPUT_TEXT, 'maxlength' => 5, + 'suffix' => 'days', + ), + 'kolabinvitationpolicy' => array( + 'label' => 'user.invitation-policy', + 'description' => 'user.invitation-policy.desc', + 'type' => kolab_form::INPUT_TEXTAREA, + ), + 'alias' => array( + 'label' => 'user.alias', + 'description' => 'user.alias.desc', + 'type' => kolab_form::INPUT_TEXTAREA, + ), + 'kolabdelegate' => array( + 'label' => 'user.delegate', + 'description' => 'user.delegate.desc', + 'type' => kolab_form::INPUT_TEXTAREA, + ), + 'kolabAllowSMTPRecipient' => array( + 'label' => 'user.smtp-recipients', + 'description' => 'user.smtp-recipients.desc', + 'type' => kolab_form::INPUT_TEXTAREA, ), ), ), @@ -187,29 +276,56 @@ class kolab_admin_client_task_user extends kolab_admin_client_task ), ); - + // Parse elements and add them to the form object foreach ($fields as $section_idx => $section) { $form->add_section($section_idx, kolab_html::escape($this->translate($section['label']))); foreach ($section['fields'] as $idx => $field) { $field['section'] = $section_idx; - $field['value'] = kolab_html::escape($user[$idx]); $field['label'] = kolab_html::escape($this->translate($field['label'])); - $field['description'] = kolab_html::escape($this->translate($field['description'])); + + if (isset($data[$idx])) { + $field['value'] = kolab_html::escape($data[$idx]); + } + + if (!empty($field['suffix'])) { + $field['suffix'] = kolab_html::escape($this->translate($field['suffix'])); + } + + if (!empty($field['options'])) { + foreach ($field['options'] as $opt_idx => $option) { + if (is_array($option)) { + $field['options'][$opt_idx]['content'] = kolab_html::escape($this->translate($option['content'])); + } + else { + $field['options'][$opt_idx] = kolab_html::escape($this->translate($option)); + } + } + } + + if (!empty($field['description'])) { + $description = kolab_html::escape($this->translate($field['description'])); + if ($description != $field['description']) { + $field['title'] = $description; + } + unset($field['description']); + } + + if (empty($field['name'])) { + $field['name'] = $idx; + } $form->add_element($field); } } - $this->output->set_object('taskcontent', $form->output()); + return $form->output(); } - public function user_add() + private function search_form() { + $form = new kolab_form(); + return $form->output(); } - private function user_types() - { - $result = $this->api->post('user_types.list'); - } } diff --git a/lib/functions.php b/lib/functions.php index e09669c..00930ae 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -1,102 +1,117 @@ <?php - ini_set('include_path', dirname(__FILE__) . PATH_SEPARATOR . ini_get('include_path')); - ini_set('include_path', dirname(__FILE__) . "/ext/" . PATH_SEPARATOR . ini_get('include_path')); - - // These are just here for some statistics. - list($usec, $sec) = explode(' ',microtime()); - - $GLOBALS['parse_start'] = ((float)$usec + (float)$sec); - - // Initialize some runtime variables - $messages = Array(); - - require_once('Conf.php'); - - // register autoloader - function class_autoloader($classname) { - $classname = preg_replace('/(Net|MDB2|HTTP)_(.+)/', "\\1/\\2", $classname); - - if ($fp = @fopen("$classname.php", 'r', true)) { - include_once("$classname.php"); - fclose($fp); - return true; - } elseif ($fp = @fopen("api/$classname.php", 'r', true)) { - include_once("api/$classname.php"); - fclose($fp); - return true; - } elseif ($fp = @fopen("client/$classname.php", 'r', true)) { - include_once("client/$classname.php"); - fclose($fp); - return true; - } - - return false; - } - spl_autoload_register('class_autoloader'); +// Initialization and basic functions - function query($query, $_conn = 'kolab_wap') { - require_once('SQL.php'); +// application constants +define('KADM_START', microtime(true)); +define('KADM_VERSION', '0.1'); +define('KADM_CHARSET', 'utf-8'); +define('INSTALL_PATH', dirname(__FILE__)); - $sql = SQL::get_instance($_conn); - return $sql->query($query); +// Check critical PHP settings here. +$crit_opts = array( + 'mbstring.func_overload' => 0, + 'magic_quotes_runtime' => 0, + 'session.use_cookies' => 1, +); +foreach ($crit_opts as $optname => $optval) { + if ($optval != ini_get($optname)) { + die("ERROR: Wrong '$optname' option value!"); } +} - function need_login() { - print "You are not logged in<br/>"; - print '<form method="post">'; - print '<input type="text" name="username" /><br/>'; - print '<input type="password" name="password" /><br/>'; - print '<input type="submit" name="submit" value="Log in"/></form>'; - echo "<pre>"; print_r($_SESSION); echo "</pre>"; - exit; - } +$include_path = INSTALL_PATH . PATH_SEPARATOR; +$include_path .= INSTALL_PATH . '/client' . PATH_SEPARATOR; +$include_path .= INSTALL_PATH . '/api' . PATH_SEPARATOR; +$include_path .= INSTALL_PATH . '/ext' . PATH_SEPARATOR; +$include_path .= ini_get('include_path'); - function valid_login() { - // The $_SESSION variable is controlled through lib/User.php's - // _authenticate() - // - return $_SESSION['user']->authenticated(); - } +if (set_include_path($include_path) === false) { + die("Fatal error: ini_set/set_include_path does not work."); +} + +ini_set('error_reporting', E_ALL&~E_NOTICE); +ini_set('error_log', INSTALL_PATH . '/../logs/errors'); - /** - * Prints debug info into the 'console' log - */ - function console() { - $args = func_get_args(); +// Set internal charset +mb_internal_encoding(KADM_CHARSET); +@mb_regex_encoding(KADM_CHARSET); - $msg = array(); - foreach ($args as $arg) { - $msg[] = !is_string($arg) ? var_export($arg, true) : $arg; - } +// register autoloader +function class_autoloader($classname) { + $classname = preg_replace('/(Net|MDB2|HTTP)_(.+)/', "\\1/\\2", $classname); - write_log('console', join(";\n", $msg)); + if ($fp = @fopen("$classname.php", 'r', true)) { + include_once("$classname.php"); + fclose($fp); + return true; } - /** - * Appends a line to a log file in the logs directory. - * Date will be added automatically to the line. - * - * @param string $name Name of the log file - * @param mixed $line Line to append - */ - function write_log($name, $line) { - if (!is_string($line)) { - $line = var_export($line, true); - } - - $log_dir = dirname(__FILE__) . '/../logs'; - $logfile = $log_dir . '/' . $name; - $date = date('d-M-Y H:i:s O'); - $line = sprintf("[%s](%s): %s\n", $date, session_id(), $line); - - if ($fp = @fopen($logfile, 'a')) { - fwrite($fp, $line); - fflush($fp); - fclose($fp); - } + return false; +} + +spl_autoload_register('class_autoloader'); + +function query($query, $_conn = 'kolab_wap') { + require_once('SQL.php'); + + $sql = SQL::get_instance($_conn); + + return $sql->query($query); +} + +function need_login() { + print "You are not logged in<br/>"; + print '<form method="post">'; + print '<input type="text" name="username" /><br/>'; + print '<input type="password" name="password" /><br/>'; + print '<input type="submit" name="submit" value="Log in"/></form>'; + echo "<pre>"; print_r($_SESSION); echo "</pre>"; + exit; +} + +function valid_login() { + // The $_SESSION variable is controlled through lib/User.php's + // _authenticate() + // + return $_SESSION['user']->authenticated(); +} + +/** + * Prints debug info into the 'console' log + */ +function console() { + $args = func_get_args(); + + $msg = array(); + foreach ($args as $arg) { + $msg[] = !is_string($arg) ? var_export($arg, true) : $arg; } + write_log('console', join(";\n", $msg)); +} + +/** + * Appends a line to a log file in the logs directory. + * Date will be added automatically to the line. + * + * @param string $name Name of the log file + * @param mixed $line Line to append + */ +function write_log($name, $line) { + if (!is_string($line)) { + $line = var_export($line, true); + } + + $log_dir = dirname(__FILE__) . '/../logs'; + $logfile = $log_dir . '/' . $name; + $date = date('d-M-Y H:i:s O'); + $line = sprintf("[%s](%s): %s\n", $date, session_id(), $line); -?> + if ($fp = @fopen($logfile, 'a')) { + fwrite($fp, $line); + fflush($fp); + fclose($fp); + } +} diff --git a/lib/kolab_admin_api.php b/lib/kolab_admin_api.php index 65d4311..99e0aa9 100644 --- a/lib/kolab_admin_api.php +++ b/lib/kolab_admin_api.php @@ -1,6 +1,5 @@ <?php -require_once("HTTP/Request2.php"); class kolab_admin_api { @@ -17,7 +16,8 @@ class kolab_admin_api const STATUS_OK = 0; const STATUS_ERROR = 1; - const ERROR_INTERNAL = 500; + const ERROR_INTERNAL = 100; + const ERROR_CONNECTION = 200; /** * Class constructor. @@ -27,6 +27,14 @@ class kolab_admin_api public function __construct($base_url) { $this->base_url = $base_url; + $this->init(); + } + + /** + * Initializes HTTP Request object. + */ + public function init() + { $this->request = new HTTP_Request2(); } @@ -36,7 +44,7 @@ class kolab_admin_api * @param string $username User name * @param string $password User password * - * @return array Session user data (token, domain) + * @return kolab_admin_api_result Request response */ public function login($username, $password) { @@ -47,12 +55,7 @@ class kolab_admin_api $response = $this->post('system.authenticate', null, $query); - if ($token = $response->get('session_token')) { - return array( - 'token' => $token, - 'domain' => $response->get('domain'), - ); - } + return $response; } /** @@ -74,7 +77,6 @@ class kolab_admin_api */ public function set_session_token($token) { - console("Setting X-Session-Token header to: " . $token); $this->request->setHeader('X-Session-Token', $token); } @@ -162,7 +164,7 @@ class kolab_admin_api } catch (Exception $e) { return new kolab_admin_api_result(null, - self::ERROR_INTERNAL, $e->getMessage()); + self::ERROR_CONNECTION, $e->getMessage()); } try { @@ -173,14 +175,13 @@ class kolab_admin_api self::ERROR_INTERNAL, $e->getMessage()); } -//print_r($body); $body = @json_decode($body, true); $err_code = null; $err_str = null; if (is_array($body) && (empty($body['status']) || $body['status'] != 'OK')) { - $err_code = !empty($data['code']) ? $data['code'] : self::ERROR_INTERNAL; - $err_str = !empty($data['reason']) ? $data['reason'] : 'Unknown error'; + $err_code = !empty($body['code']) ? $body['code'] : self::ERROR_INTERNAL; + $err_str = !empty($body['reason']) ? $body['reason'] : 'Unknown error'; } else if (!is_array($body)) { $err_code = self::ERROR_INTERNAL; @@ -189,4 +190,5 @@ class kolab_admin_api return new kolab_admin_api_result($body, $err_code, $err_str); } + } diff --git a/lib/kolab_admin_api_result.php b/lib/kolab_admin_api_result.php index 772030f..178350f 100644 --- a/lib/kolab_admin_api_result.php +++ b/lib/kolab_admin_api_result.php @@ -23,12 +23,12 @@ class kolab_admin_api_result public function get_error_code() { - $this->error_code; + return $this->error_code; } public function get_error_str() { - $this->error_str; + return $this->error_str; } public function get($name = null) diff --git a/lib/kolab_admin_client_output.php b/lib/kolab_admin_client_output.php index 17c5e52..c6c145c 100644 --- a/lib/kolab_admin_client_output.php +++ b/lib/kolab_admin_client_output.php @@ -20,9 +20,9 @@ class kolab_admin_client_output require_once 'Smarty/Smarty.class.php'; $SMARTY = new Smarty; + $SMARTY->template_dir = 'skins/' . $this->skin . '/templates'; - $SMARTY->compile_dir = 'cache'; - $SMARTY->plugins_dir = dirname(__FILE__) . '/Smarty/plugins/'; + $SMARTY->compile_dir = INSTALL_PATH . '/../cache'; $SMARTY->debugging = false; $this->tpl = $SMARTY; diff --git a/lib/kolab_admin_client_task.php b/lib/kolab_admin_client_task.php index 9090a66..77d9c5d 100644 --- a/lib/kolab_admin_client_task.php +++ b/lib/kolab_admin_client_task.php @@ -25,7 +25,7 @@ class kolab_admin_client_task */ public function __construct() { - $this->conf = Conf::get_instance(); + $this->config_init(); $this->output_init(); $this->api_init(); @@ -58,12 +58,12 @@ class kolab_admin_client_task $lang = $lang[0]; $lang = str_replace('-', '_', $lang); - if (file_exists(dirname(__FILE__) . "/locale/$lang.php")) { + if (file_exists(INSTALL_PATH . "/locale/$lang.php")) { $language = $lang; break; } if (isset($aliases[$lang]) && ($alias = $aliases[$lang]) - && file_exists(dirname(__FILE__) . "/locale/$alias.php") + && file_exists(INSTALL_PATH . "/locale/$alias.php") ) { $language = $alias; break; @@ -71,10 +71,10 @@ class kolab_admin_client_task } $LANG = array(); - @include dirname(__FILE__) . '/locale/en_US.php'; + @include INSTALL_PATH . '/locale/en_US.php'; if (isset($language)) { - @include dirname(__FILE__) . "/locale/$language.php"; + @include INSTALL_PATH . "/locale/$language.php"; setlocale(LC_ALL, $language . '.utf8', 'en_US.utf8'); } else { @@ -84,26 +84,20 @@ class kolab_admin_client_task self::$translation = $LANG; } -<<<<<<< HEAD:public_html/include/kolab_admin_task.php /** * Configuration initialization. */ private function config_init() { - include_once INSTALL_PATH . '/config/config.php'; - - $this->config = $CONFIG; + $this->config = Conf::get_instance(); } /** * Output initialization. */ -======= ->>>>>>> fa17922ff4fa6617851d6dc4147da0d8660ca2bc:lib/kolab_admin_client_task.php private function output_init() { - $skin = $this->conf->get('kolab_wap', 'skin'); - + $skin = $this->config_get('skin', 'default'); $this->output = new kolab_admin_client_output($skin); } @@ -112,7 +106,7 @@ class kolab_admin_client_task */ private function api_init() { - $url = $this->conf->get('kolab_wap', 'api_url'); + $url = $this->config_get('api_url', ''); $this->api = new kolab_admin_api($url); } @@ -127,23 +121,39 @@ class kolab_admin_client_task if ($login['username']) { $result = $this->api->login($login['username'], $login['password']); - if ($result) { - $this->api->set_session_token($result['token']); + if ($token = $result->get('session_token')) { + $user = array('token' => $token, 'domain' => $result->get('domain')); + + $this->api->set_session_token($user['token']); + // find user settings $res = $this->api->get('user.info', array('user' => $login['username'])); $res = $res->get(); if (is_array($res) && ($res = array_shift($res))) { - $result['language'] = $res['preferredlanguage']; - $result['fullname'] = $res['cn']; + $user['language'] = $res['preferredlanguage']; + $user['fullname'] = $res['cn']; } - $_SESSION['user'] = $result; + // Initialize list of user types + $this->user_types(); + + $_SESSION['user'] = $user; header('Location: ?'); die; } else { - $this->output->command('display_message', 'loginerror', 'error'); + $code = $result->get_error_code(); + $str = $result->get_error_str(); + $label = 'loginerror'; + + if ($code == kolab_admin_api::ERROR_INTERNAL + || $code == kolab_admin_api::ERROR_CONNECTION + ) { + $label = 'internalerror'; + $this->raise_error(500, 'Login failed. ' . $str); + } + $this->output->command('display_message', $label, 'error'); } } } @@ -191,18 +201,15 @@ class kolab_admin_client_task // Check AJAX-only tasks if ($this->ajax_only && !$ajax) { - $this->raise_error(500, 'Invalid request type!'); + $this->raise_error(500, 'Invalid request type!', null, true); } // CSRF prevention - $token = $ajax ? kolab_utils::get_request_header('X-KAP-Request') : $this->get_input('token'); + $token = $ajax ? kolab_utils::request_header('X-KAP-Request') : $this->get_input('token'); $task = $this->get_task(); - console("Ajax:", $ajax, "Token:", $token, "X-KAP-Request:", kolab_utils::get_request_header('X-KAP-Request')); - console("User session token:", $_SESSION['user']['token'], "Task:", $task); - if ($task != 'main' && $token != $_SESSION['user']['token']) { - $this->raise_error(403, 'Invalid request data!'); + $this->raise_error(403, 'Invalid request data!', null, true); } } @@ -214,14 +221,14 @@ class kolab_admin_client_task if (!empty($_SESSION['user']) && !empty($_SESSION['user']['token'])) { $this->api->logout(); } - unset($_SESSION['user']); + $_SESSION = array(); if ($this->output->is_ajax()) { $this->output->command('main_logout'); } else { $this->output->assign('login', $this->get_input('login', 'POST')); - $this->output->add_translation('loginerror'); + $this->output->add_translation('loginerror', 'internalerror'); $this->output->send('login'); } exit; @@ -230,23 +237,27 @@ class kolab_admin_client_task /** * Error action (with error logging). * - * @param int $code Error code - * @param string $msg Error message - * @param array $args Optional arguments (type, file, line) + * @param int $code Error code + * @param string $msg Error message + * @param array $args Optional arguments (type, file, line) + * @param bool $output Enable to send output and finish */ - public function raise_error($code, $msg, $type = 'PHP') + public function raise_error($code, $msg, $args = array(), $output = false) { - $log_entry = sprintf("%s Error: %s%s (%s)", + $log_line = sprintf("%s Error: %s (%s)", isset($args['type']) ? $args['type'] : 'PHP', - $msg, - isset($arg_arr['file']) ? sprintf(' in %s on line %d', $args['file'], $args['line']) : '', + $msg . (isset($args['file']) ? sprintf(' in %s on line %d', $args['file'], $args['line']) : ''), $_SERVER['REQUEST_METHOD']); - if (!write_log('errors', $log_entry)) { + if (!write_log('errors', $log_line)) { // send error to PHPs error handler if write_log() didn't succeed trigger_error($msg); } + if (!$output) { + return; + } + if ($this->output->is_ajax()) { header("HTTP/1.0 $code $msg"); die; @@ -287,7 +298,6 @@ class kolab_admin_client_task } } -<<<<<<< HEAD:public_html/include/kolab_admin_task.php /** * Returns configuration option value. * @@ -298,7 +308,8 @@ class kolab_admin_client_task */ public function config_get($name, $fallback = null) { - return isset($this->config[$name]) ? $this->config[$name] : $fallback; + $value = $this->config->get('kolab_wap', $name); + return $value !== null ? $value : $fallback; } /** @@ -306,8 +317,6 @@ class kolab_admin_client_task * * @return string Translated string. */ -======= ->>>>>>> fa17922ff4fa6617851d6dc4147da0d8660ca2bc:lib/kolab_admin_client_task.php public static function translate() { $args = func_get_args(); @@ -388,15 +397,31 @@ class kolab_admin_client_task return '<ul>' . implode("\n", $menu) . '</ul>'; } -<<<<<<< HEAD:public_html/include/kolab_admin_task.php /** * Adds watermark page definition into main page. */ protected function watermark($name) -======= - public function watermark($name) ->>>>>>> fa17922ff4fa6617851d6dc4147da0d8660ca2bc:lib/kolab_admin_client_task.php { $this->output->command('set_watermark', $name); } + + /** + * Returns list of user types. + * + * @param array List of user types + */ + protected function user_types() + { + if (!isset($_SESSION['user_types'])) { + $result = $this->api->post('user_types.list'); + $list = $result->get(); + + if (is_array($list)) { + $_SESSION['user_types'] = $list; + } + } + + return $_SESSION['user_types']; + } + } diff --git a/lib/kolab_form.php b/lib/kolab_form.php index 4c67533..4a59a87 100644 --- a/lib/kolab_form.php +++ b/lib/kolab_form.php @@ -10,22 +10,41 @@ class kolab_form const INPUT_RADIO = 5; const INPUT_BUTTON = 6; const INPUT_SUBMIT = 7; + const INPUT_SELECT = 8; + const INPUT_HIDDEN = 9; private $attribs = array(); private $elements = array(); private $sections = array(); + /** + * Class constructor. + * + * @param array $attribs Form attributes + */ public function __construct($attribs = array()) { $this->attribs = $attribs; } + /** + * Adds form section definition. + * + * @param string $index Section internal index + * @param string $legend Section label (fieldset's legend) + */ public function add_section($index, $legend) { $this->sections[$index] = $legend; } + /** + * Adds form element definition. + * + * @param array $attribs Element attributes + * @param string $section Section index + */ public function add_element($attribs, $section = null) { if (!empty($section)) { @@ -35,6 +54,11 @@ class kolab_form $this->elements[] = $attribs; } + /** + * Returns HTML output of the form. + * + * @return string HTML output + */ public function output() { $content = ''; @@ -90,7 +114,13 @@ class kolab_form ), ); - return array('cells' => $cells); + $attrib = array('cells' => $cells); + + if ($element['required']) { + $attrib['class'] = 'required'; + } + + return $attrib; } private function get_element($attribs) @@ -113,8 +143,24 @@ class kolab_form $content = kolab_html::input($attribs); break; + case self::INPUT_HIDDEN: + $attribs['type'] = 'hidden'; + $content = kolab_html::input($attribs); + break; + case self::INPUT_TEXTAREA: - $content = kolab_html::textarea($attribs); + if (empty($attribs['rows'])) { + $attribs['rows'] = 5; + } + if (empty($attribs['cols'])) { + $attribs['cols'] = 50; + } + + $content = kolab_html::textarea($attribs, true); + break; + + case self::INPUT_SELECT: + $content = kolab_html::select($attribs); break; default: @@ -126,6 +172,10 @@ class kolab_form } } + if (!empty($attribs['suffix'])) { + $content .= ' ' . $attribs['suffix']; + } + return $content; } diff --git a/lib/kolab_html.php b/lib/kolab_html.php index d8e8d7b..6773fd0 100644 --- a/lib/kolab_html.php +++ b/lib/kolab_html.php @@ -119,13 +119,16 @@ class kolab_html $content = array(); if (!empty($attribs['options']) && is_array($attribs['options'])) { - foreach ($attribs['options'] as $option) { -<<<<<<< HEAD:public_html/include/kolab_html.php + foreach ($attribs['options'] as $idx => $option) { + if (!is_array($option)) { + $option = array('content' => $option); + } + if (empty($option['value'])) { + $option['value'] = $idx; + } if (!empty($attribs['value']) && $attribs['value'] == $option['value']) { $option['selected'] = true; } -======= ->>>>>>> fa17922ff4fa6617851d6dc4147da0d8660ca2bc:lib/kolab_html.php $content[] = self::option($option, $escape); } } @@ -139,13 +142,6 @@ class kolab_html $elem_attribs = array_merge(self::$option_attribs, self::$common_attribs); $content = isset($attribs['content']) ? $attribs['content'] : ''; -<<<<<<< HEAD:public_html/include/kolab_html.php -======= - - if ($escape) { - $content = self::escape($content); - } ->>>>>>> fa17922ff4fa6617851d6dc4147da0d8660ca2bc:lib/kolab_html.php if ($escape) { $content = self::escape($content); diff --git a/lib/kolab_utils.php b/lib/kolab_utils.php index 97b8bdf..1acd4ba 100644 --- a/lib/kolab_utils.php +++ b/lib/kolab_utils.php @@ -1,78 +1,97 @@ <?php - class kolab_utils { - /** - * Read a specific HTTP request header - * - * @param string $name Header name - * @return mixed Header value or null if not available - */ - public static function get_request_header($name) { - if (function_exists('getallheaders')) { - $hdrs = array_change_key_case(getallheaders(), CASE_UPPER); - $key = strtoupper($name); - } else { - $key = 'HTTP_' . strtoupper(strtr($name, '-', '_')); - $hdrs = array_change_key_case($_SERVER, CASE_UPPER); - } +class kolab_utils +{ + const REQUEST_ANY = 0; + const REQUEST_GET = 1; + const REQUEST_POST = 2; - if (array_key_exists($key, $hdrs)) { - return $hdrs[$key]; - } else { - return null; - } + /** + * Read a specific HTTP request header + * + * @param string $name Header name + * + * @return mixed Header value or null if not available + */ + public static function request_header($name) + { + if (function_exists('getallheaders')) { + $hdrs = array_change_key_case(getallheaders(), CASE_UPPER); + $key = strtoupper($name); } - - /** - * Make sure the string ends with a slash - */ - public static function slashify($str) - { - return self::unslashify($str).'/'; + else { + $key = 'HTTP_' . strtoupper(strtr($name, '-', '_')); + $hdrs = array_change_key_case($_SERVER, CASE_UPPER); } - /** - * Remove slash at the end of the string - */ - public static function unslashify($str) - { - return preg_replace('/\/$/', '', $str); + return $hdrs[$key]; + } + + /** + * Returns input parameter value. + * + * @param string $name Parameter name + * @param int $type Parameter type + * @param bool $allow_html Enable to strip invalid/unsecure content + * + * @return mixed Input value + */ + public static function get_input($name, $type = null, $allow_html = false) + { + if ($type == self::REQUEST_GET) { + $value = isset($_GET[$name]) ? $_GET[$name] : null; + } + else if ($type == self::REQUEST_POST) { + $value = isset($_POST[$name]) ? $_POST[$name] : null; + } + else { + $value = isset($_REQUEST[$name]) ? $_REQUEST[$name] : null; } - public static function get_input($name, $type = null, $allow_html = false) - { - if ($type == 'GET') { - $value = isset($_GET[$name]) ? $_GET[$name] : null; - } - else if ($type == 'POST') { - $value = isset($_POST[$name]) ? $_POST[$name] : null; - } - else { - $value = isset($_REQUEST[$name]) ? $_REQUEST[$name] : null; - } + return self::parse_input($value, $allow_html); + } - return self::parse_input($value, $allow_html); + /** + * Input parsing. + * + * @param mixed $value Input value + * @param bool $allow_html Enable to strip invalid/unsecure content + * + * @return mixed Input value + */ + public static function parse_input($value, $allow_html = false) + { + if (empty($value)) { + return $value; } - public static function parse_input($value, $allow_html = false) - { - if (empty($value)) { - return $value; + if (is_array($value)) { + foreach ($value as $idx => $val) { + $value[$idx] = self::parse_input($val, $allow_html); } + } + // remove HTML tags if not allowed + else if (!$allow_html) { + $value = strip_tags($value); + } - if (is_array($value)) { - foreach ($value as $idx => $val) { - $value[$idx] = self::parse_input($val, $allow_html); - } - } - // remove HTML tags if not allowed - else if (!$allow_html) { - $value = strip_tags($value); - } + return $value; + } - return $value; - } + /** + * Make sure the string ends with a slash + */ + public static function slashify($str) + { + return self::unslashify($str).'/'; + } + /** + * Remove slash at the end of the string + */ + public static function unslashify($str) + { + return preg_replace('/\/$/', '', $str); } -?> +} diff --git a/lib/locale/en_US.php b/lib/locale/en_US.php index f018885..da5cdb1 100644 --- a/lib/locale/en_US.php +++ b/lib/locale/en_US.php @@ -5,6 +5,8 @@ $LANG['password'] = 'Password'; $LANG['loading'] = 'Loading...'; $LANG['error'] = 'Error'; $LANG['servererror'] = 'Server Error!'; +$LANG['loginerror'] = 'Incorrect username or password!'; +$LANG['internalerror'] = 'Internal system error!'; $LANG['search'] = 'Search'; $LANG['search.criteria'] = 'Search criteria'; @@ -62,4 +64,3 @@ $LANG['group.add'] = 'Add Group'; $LANG['MB'] = 'MB'; $LANG['days'] = 'days'; -$LANG['loginerror'] = 'Incorrect username or password!'; diff --git a/logs/.htaccess b/logs/.htaccess new file mode 100644 index 0000000..93169e4 --- /dev/null +++ b/logs/.htaccess @@ -0,0 +1,2 @@ +Order deny,allow +Deny from all diff --git a/public_html/config/config.php b/public_html/config/config.php deleted file mode 100644 index a4a0dc6..0000000 --- a/public_html/config/config.php +++ /dev/null @@ -1,4 +0,0 @@ -<?php - -$CONFIG['api_url'] = 'http://admin.klab.cc/~vanmeeuwen/kolab-wap/public_html/api'; - diff --git a/public_html/include/init.php b/public_html/include/init.php deleted file mode 100644 index 06bc4d7..0000000 --- a/public_html/include/init.php +++ /dev/null @@ -1,62 +0,0 @@ -<?php - -/* - * Kolab Admin Panel - * - * (C) Copyright 2011 Kolab Systems AG - * - */ - -// Initialisation and basic functions - -// Check critical PHP settings here. -$crit_opts = array( - 'mbstring.func_overload' => 0, - 'magic_quotes_runtime' => 0, - 'session.use_cookies' => 1, -); -foreach ($crit_opts as $optname => $optval) { - if ($optval != ini_get($optname)) { - die("ERROR: Wrong '$optname' option value!"); - } -} - -$include_path = INSTALL_PATH . '/lib' . PATH_SEPARATOR; -$include_path.= ini_get('include_path'); - -if (set_include_path($include_path) === false) { - die("Fatal error: ini_set/set_include_path does not work."); -} - -ini_set('error_reporting', E_ALL&~E_NOTICE); -ini_set('error_log', 'logs/errors'); - -// Set internal charset -mb_internal_encoding(KADM_CHARSET); -@mb_regex_encoding(KADM_CHARSET); - -/** - * Kolab Admin Classes Autoloader - */ -function kolab_admin_autoload($classname) -{ - if (preg_match('/^kolab_/', $classname)) { - if (preg_match('/^kolab_admin_task_([a-z]+)$/', $classname, $m)) { - $filename = INSTALL_PATH . '/include/tasks/' . $m[1] . '.php'; - } - else { - $filename = INSTALL_PATH . "/include/$classname.php"; - } - - if ($fp = @fopen($filename, 'r')) { - fclose($fp); - include_once($filename); - return true; - } - } - - return false; -} - -spl_autoload_register('kolab_admin_autoload'); - diff --git a/public_html/include/kolab_admin_api_result.php b/public_html/include/kolab_admin_api_result.php deleted file mode 100644 index 772030f..0000000 --- a/public_html/include/kolab_admin_api_result.php +++ /dev/null @@ -1,42 +0,0 @@ -<?php - -class kolab_admin_api_result -{ - /** - * @var array - */ - private $data = array(); - - private $error_code; - private $error_str; - - - public function __construct($data = array(), $error_code = null, $error_str = null) - { - if (is_array($data) && isset($data['result'])) { - $this->data = $data['result']; - } - - $this->error_code = $error_code; - $this->error_str = $error_str; - } - - public function get_error_code() - { - $this->error_code; - } - - public function get_error_str() - { - $this->error_str; - } - - public function get($name = null) - { - if ($name !== null) { - return isset($this->data[$name]) ? $this->data[$name] : null; - } - - return $this->data; - } -} diff --git a/public_html/include/kolab_form.php b/public_html/include/kolab_form.php deleted file mode 100644 index a990bbb..0000000 --- a/public_html/include/kolab_form.php +++ /dev/null @@ -1,189 +0,0 @@ -<?php - - -class kolab_form -{ - const INPUT_TEXT = 1; - const INPUT_PASSWORD = 2; - const INPUT_TEXTAREA = 3; - const INPUT_CHECKBOX = 4; - const INPUT_RADIO = 5; - const INPUT_BUTTON = 6; - const INPUT_SUBMIT = 7; - const INPUT_SELECT = 8; - const INPUT_HIDDEN = 9; - - private $attribs = array(); - private $elements = array(); - private $sections = array(); - - - /** - * Class constructor. - * - * @param array $attribs Form attributes - */ - public function __construct($attribs = array()) - { - $this->attribs = $attribs; - } - - /** - * Adds form section definition. - * - * @param string $index Section internal index - * @param string $legend Section label (fieldset's legend) - */ - public function add_section($index, $legend) - { - $this->sections[$index] = $legend; - } - - /** - * Adds form element definition. - * - * @param array $attribs Element attributes - * @param string $section Section index - */ - public function add_element($attribs, $section = null) - { - if (!empty($section)) { - $attribs['section'] = $section; - } - - $this->elements[] = $attribs; - } - - /** - * Returns HTML output of the form. - * - * @return string HTML output - */ - public function output() - { - $content = ''; - - if (!empty($this->sections)) { - foreach ($this->sections as $set_idx => $set) { - $rows = array(); - - foreach ($this->elements as $element) { - if (empty($element['section']) || $element['section'] != $set_idx) { - continue; - } - - $rows[] = $this->form_row($element); - } - - if (!empty($rows)) { - $content .= "\n" . kolab_html::fieldset(array( - 'legend' => $set, - 'content' => kolab_html::table(array('body' => $rows, 'class' => 'form')) - )); - } - } - } - - $rows = array(); - - foreach ($this->elements as $element) { - if (!empty($element['section'])) { - continue; - } - - $rows[] = $this->form_row($element); - } - - if (!empty($rows)) { - $content = kolab_html::table(array('body' => $rows, 'class' => 'form')); - } - - return kolab_html::form($this->attribs, $content); - } - - private function form_row($element) - { - $cells = array( - 0 => array( - 'class' => 'label', - 'body' => $element['label'], - ), - 1 => array( - 'class' => 'value', - 'body' => $this->get_element($element), - ), - ); - - $attrib = array('cells' => $cells); - - if ($element['required']) { - $attrib['class'] = 'required'; - } - - return $attrib; - } - - private function get_element($attribs) - { - $type = isset($attribs['type']) ? $attribs['type'] : 0; - - switch ($type) { - case self::INPUT_TEXT: - case self::INPUT_PASSWORD: - // INPUT type - $attribs['type'] = $type == self::INPUT_PASSWORD ? 'password' : 'text'; - // INPUT size - if (empty($attribs['size'])) { - $attribs['size'] = 40; - if (!empty($attribs['maxlength'])) { - $attribs['size'] = $attribs['maxlength'] > 10 ? 40 : 10; - } - } - - $content = kolab_html::input($attribs); - break; - - case self::INPUT_HIDDEN: - $attribs['type'] = 'hidden'; - $content = kolab_html::input($attribs); - break; - - case self::INPUT_TEXTAREA: - if (empty($attribs['rows'])) { - $attribs['rows'] = 5; - } - if (empty($attribs['cols'])) { - $attribs['cols'] = 50; - } - - $content = kolab_html::textarea($attribs, true); - break; - - case self::INPUT_SELECT: - foreach ($attribs['options'] as $idx => $opt) { - $attribs['options'][$idx] = array( - 'value' => $idx, - 'content' => $opt, - ); - } - - $content = kolab_html::select($attribs); - break; - - default: - if (is_array($attribs)) { - $content = isset($attribs['value']) ? $attribs['value'] : ''; - } - else { - $content = $attribs; - } - } - - if (!empty($attribs['suffix'])) { - $content .= ' ' . $attribs['suffix']; - } - - return $content; - } - -} diff --git a/public_html/include/kolab_utils.php b/public_html/include/kolab_utils.php deleted file mode 100644 index 4f2c68c..0000000 --- a/public_html/include/kolab_utils.php +++ /dev/null @@ -1,80 +0,0 @@ -<?php - -class kolab_utils -{ - const REQUEST_ANY = 0; - const REQUEST_GET = 1; - const REQUEST_POST = 2; - - /** - * Read a specific HTTP request header - * - * @param string $name Header name - * - * @return mixed Header value or null if not available - */ - public static function request_header($name) - { - if (function_exists('getallheaders')) { - $hdrs = array_change_key_case(getallheaders(), CASE_UPPER); - $key = strtoupper($name); - } - else { - $key = 'HTTP_' . strtoupper(strtr($name, '-', '_')); - $hdrs = array_change_key_case($_SERVER, CASE_UPPER); - } - - return $hdrs[$key]; - } - - /** - * Returns input parameter value. - * - * @param string $name Parameter name - * @param int $type Parameter type - * @param bool $allow_html Enable to strip invalid/unsecure content - * - * @return mixed Input value - */ - public static function get_input($name, $type = null, $allow_html = false) - { - if ($type == self::REQUEST_GET) { - $value = isset($_GET[$name]) ? $_GET[$name] : null; - } - else if ($type == self::REQUEST_POST) { - $value = isset($_POST[$name]) ? $_POST[$name] : null; - } - else { - $value = isset($_REQUEST[$name]) ? $_REQUEST[$name] : null; - } - - return self::parse_input($value, $allow_html); - } - - /** - * Input parsing. - * - * @param mixed $value Input value - * @param bool $allow_html Enable to strip invalid/unsecure content - * - * @return mixed Input value - */ - public static function parse_input($value, $allow_html = false) - { - if (empty($value)) { - return $value; - } - - if (is_array($value)) { - foreach ($value as $idx => $val) { - $value[$idx] = self::parse_input($val, $allow_html); - } - } - // remove HTML tags if not allowed - else if (!$allow_html) { - $value = strip_tags($value); - } - - return $value; - } -} diff --git a/public_html/include/tasks/main.php b/public_html/include/tasks/main.php deleted file mode 100644 index 8dfca52..0000000 --- a/public_html/include/tasks/main.php +++ /dev/null @@ -1,27 +0,0 @@ -<?php - -class kolab_admin_task_main extends kolab_admin_task -{ - protected $menu = array( - 'user.default' => 'menu.users', - 'group.default' => 'menu.groups', - 'about.default' => 'menu.about', - ); - - - public function action_default() - { - // assign token - $this->output->set_env('token', $_SESSION['user']['token']); - - // add watermark content - $this->output->set_env('watermark', $this->output->get_template('watermark')); - - // assign default set of translations - $this->output->add_translation('loading', 'servererror', 'search'); - - $this->output->assign('main_menu', $this->menu()); - $this->output->assign('user', $_SESSION['user']); - } - -} diff --git a/public_html/include/tasks/user.php b/public_html/include/tasks/user.php deleted file mode 100644 index ff05138..0000000 --- a/public_html/include/tasks/user.php +++ /dev/null @@ -1,324 +0,0 @@ -<?php - -class kolab_admin_task_user extends kolab_admin_task -{ - protected $ajax_only = true; - - protected $menu = array( - 'add' => 'user.add', - ); - - /** - * Default action. - */ - public function action_default() - { - $this->output->set_object('content', 'user', true); - $this->output->set_object('task_navigation', $this->menu()); - - $this->action_list(); - } - - /** - * Users list action. - */ - public function action_list() - { - $result = $this->api->post('users.list'); - $result = (array) $result->get(); - - $rows = $head = array(); - $cols = array('name'); - $i = 0; - - // table header - $head[0]['cells'][] = array('class' => 'name', 'body' => $this->translate('user.name')); - - if (!empty($result)) { - foreach ($result as $idx => $item) { - if (!is_array($item) || empty($item['uid'])) { - continue; - } - - $i++; - $cells = array(); - $cells[] = array('class' => 'name', 'body' => kolab_html::escape($item['uid']), - 'onclick' => "kadm.command('user.info', '$idx')"); - $rows[] = array('id' => $i, 'class' => 'selectable', 'cells' => $cells); - } - } - else { - $rows[] = array('cells' => array( - 0 => array('class' => 'empty-body', 'body' => $this->translate('user.norecords') - ))); - } - - $table = kolab_html::table(array('id' => 'userlist', 'class' => 'list', - 'head' => $head, 'body' => $rows)); - - $this->watermark('taskcontent'); - $this->output->set_object('userlist', $table); - } - - /** - * User information (form) action. - */ - public function action_info() - { - $id = $this->get_input('id', 'POST'); - $result = $this->api->get('user.info', array('user' => $id)); - $user = $result->get($id); - $output = $this->user_form(null, $user); - - $this->output->set_object('taskcontent', $output); - } - - /** - * Users adding (form) action. - */ - public function action_add() - { - $output = $this->user_form(null, null); - - $this->output->set_object('taskcontent', $output); - } - - private function user_types() - { - $result = $this->api->post('user_types.list'); - } - - private function user_form($attribs, $data = array()) - { - $form = new kolab_form(); - $fields = array( - 'personal' => array( - 'label' => 'user.personal', - 'fields' => array( - 'givenname' => array( - 'label' => 'user.givenname', - 'description' => 'user.givenname.desc', - 'required' => true, - 'type' => kolab_form::INPUT_TEXT, - 'maxlength' => 50, - ), - 'sn' => array( - 'label' => 'user.surname', - 'description' => 'user.surname.desc', - 'required' => true, - 'type' => kolab_form::INPUT_TEXT, - 'maxlength' => 50, - ), - 'initials' => array( - 'label' => 'user.initials', - 'description' => 'user.initials.desc', - 'type' => kolab_form::INPUT_TEXT, - 'maxlength' => 50, - ), - 'title' => array( - 'label' => 'user.title', - 'description' => 'user.title.desc', - 'type' => kolab_form::INPUT_TEXT, - 'maxlength' => 10, - ), - ), - ), - 'system' => array( - 'label' => 'user.system', - 'fields' => array( - 'mail' => array( - 'label' => 'user.email', - 'description' => 'user.email.desc', - 'type' => kolab_form::INPUT_TEXT, - 'maxlength' => 50, - 'required' => true, - ), - 'uid' => array( - 'label' => 'user.uid', - 'description' => 'user.uid.desc', - 'type' => kolab_form::INPUT_TEXT, - 'maxlength' => 50, - 'required' => true, - ), - 'password' => array( - 'label' => 'user.password', - 'description' => 'user.password.desc', - 'type' => kolab_form::INPUT_TEXT, - 'maxlength' => 50, - 'required' => true, - ), - 'password2' => array( - 'label' => 'user.password-confirm', - 'description' => 'user.password-confirm.desc', - 'type' => kolab_form::INPUT_TEXT, - 'maxlength' => 50, - 'required' => true, - ), - 'kolabhomeserver' => array( - 'label' => 'user.homeserver', - 'description' => 'user.homeserver.desc', - 'type' => kolab_form::INPUT_TEXT, - 'maxlength' => 50, - 'required' => true, - ), - 'accttype' => array( - 'label' => 'user.type', - 'description' => 'user.type.desc', - 'type' => kolab_form::INPUT_SELECT, - 'options' => array( - 'aaa', 'bbb' - ), - ), - ), - ), - 'config' => array( - 'label' => 'user.config', - 'fields' => array( - 'cyrus-userquota' => array( - 'label' => 'user.quota', - 'description' => 'user.quota.desc', - 'type' => kolab_form::INPUT_TEXT, - 'maxlength' => 10, - 'suffix' => 'MB', - ), - 'kolabFreeBusyFuture' => array( - 'label' => 'user.fbinterval', - 'description' => 'user.fbinterval.desc', - 'type' => kolab_form::INPUT_TEXT, - 'maxlength' => 5, - 'suffix' => 'days', - ), - 'kolabinvitationpolicy' => array( - 'label' => 'user.invitation-policy', - 'description' => 'user.invitation-policy.desc', - 'type' => kolab_form::INPUT_TEXTAREA, - ), - 'alias' => array( - 'label' => 'user.alias', - 'description' => 'user.alias.desc', - 'type' => kolab_form::INPUT_TEXTAREA, - ), - 'kolabdelegate' => array( - 'label' => 'user.delegate', - 'description' => 'user.delegate.desc', - 'type' => kolab_form::INPUT_TEXTAREA, - ), - 'kolabAllowSMTPRecipient' => array( - 'label' => 'user.smtp-recipients', - 'description' => 'user.smtp-recipients.desc', - 'type' => kolab_form::INPUT_TEXTAREA, - ), - ), - ), - 'contact' => array( - 'label' => 'user.contact', - 'fields' => array( - 'telephoneNumber' => array( - 'label' => 'user.phone', - 'description' => 'user.phone.desc', - 'type' => kolab_form::INPUT_TEXT, - 'maxlength' => 50, - ), - 'facsimileTelephoneNumber' => array( - 'label' => 'user.fax', - 'description' => 'user.fax.desc', - 'type' => kolab_form::INPUT_TEXT, - 'maxlength' => 50, - ), - 'o' => array( - 'label' => 'user.org', - 'description' => 'user.org.desc', - 'type' => kolab_form::INPUT_TEXT, - 'maxlength' => 50, - ), - 'ou' => array( - 'label' => 'user.orgunit', - 'description' => 'user.orgunit.desc', - 'type' => kolab_form::INPUT_TEXT, - 'maxlength' => 50, - ), - 'roomNumber' => array( - 'label' => 'user.room', - 'description' => 'user.room.desc', - 'type' => kolab_form::INPUT_TEXT, - 'maxlength' => 10, - ), - 'street' => array( - 'label' => 'user.street', - 'description' => 'user.street.desc', - 'type' => kolab_form::INPUT_TEXT, - 'maxlength' => 50, - ), - 'l' => array( - 'label' => 'user.city', - 'description' => 'user.city.desc', - 'type' => kolab_form::INPUT_TEXT, - 'maxlength' => 50, - ), - 'postOfficeBox' => array( - 'label' => 'user.postbox', - 'description' => 'user.postbox.desc', - 'type' => kolab_form::INPUT_TEXT, - 'maxlength' => 20, - ), - 'postalCode' => array( - 'label' => 'user.postcode', - 'description' => 'user.postcode.desc', - 'type' => kolab_form::INPUT_TEXT, - 'maxlength' => 10, - ), - 'c' => array( - 'label' => 'user.country', - 'description' => 'user.country.desc', - 'type' => kolab_form::INPUT_TEXT, - 'maxlength' => 2, - ), - ), - ), - ); - - foreach ($fields as $section_idx => $section) { - $form->add_section($section_idx, kolab_html::escape($this->translate($section['label']))); - foreach ($section['fields'] as $idx => $field) { - $field['section'] = $section_idx; - $field['label'] = kolab_html::escape($this->translate($field['label'])); - - if (isset($data[$idx])) { - $field['value'] = kolab_html::escape($data[$idx]); - } - - if (!empty($field['suffix'])) { - $field['suffix'] = kolab_html::escape($this->translate($field['suffix'])); - } - - if (!empty($field['options'])) { - $field['options'] = array_map(array($this, 'translate'), $field['options']); - } - - if (!empty($field['description'])) { - $description = kolab_html::escape($this->translate($field['description'])); - if ($description != $field['description']) { - $field['title'] = $description; - } - unset($field['description']); - } - - if (empty($field['name'])) { - $field['name'] = $idx; - } - - $form->add_element($field); - } - } - - return $form->output(); - } - - private function search_form() - { - $form = new kolab_form(); - - return $form->output(); - } - -} diff --git a/public_html/index.php b/public_html/index.php index 60ee06c..9e07188 100644 --- a/public_html/index.php +++ b/public_html/index.php @@ -1,23 +1,26 @@ <?php - require_once(dirname(__FILE__) . "/../lib/functions.php"); +/* + * Kolab Admin Panel + * + * (C) Copyright 2011 Kolab Systems AG + * + */ - // starting task - $task = kolab_utils::get_input('task', 'GET'); +// environment initialization +require_once '../lib/functions.php'; - console(__FILE__.":".__LINE__.": " . $task); +// starting task +$task = kolab_utils::get_input('task', kolab_utils::REQUEST_GET); - if (!$task) { - $task = 'main'; - } +if (!$task) { + $task = 'main'; +} - console(__FILE__.":".__LINE__.": " . $task); +$class = "kolab_admin_client_task_$task"; - $class = "kolab_admin_client_task_$task"; +$KADM = new $class; - $KADM = new $class; - - // run actions and send output - $KADM->run(); - $KADM->send(); -?> +// run actions and send output +$KADM->run(); +$KADM->send(); diff --git a/public_html/lib/Smarty/Smarty.class.php b/public_html/lib/Smarty/Smarty.class.php deleted file mode 100644 index 379d8d4..0000000 --- a/public_html/lib/Smarty/Smarty.class.php +++ /dev/null @@ -1,1502 +0,0 @@ -<?php -/** - * Project: Smarty: the PHP compiling template engine - * File: Smarty.class.php - * SVN: $Id: Smarty.class.php 4518 2011-12-18 18:48:07Z rodneyrehm $ - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * For questions, help, comments, discussion, etc., please join the - * Smarty mailing list. Send a blank e-mail to - * smarty-discussion-subscribe@googlegroups.com - * - * @link http://www.smarty.net/ - * @copyright 2008 New Digital Group, Inc. - * @author Monte Ohrt <monte at ohrt dot com> - * @author Uwe Tews - * @author Rodney Rehm - * @package Smarty - * @version 3.1.7 - */ - -/** - * define shorthand directory separator constant - */ -if (!defined('DS')) { - define('DS', DIRECTORY_SEPARATOR); -} - -/** - * set SMARTY_DIR to absolute path to Smarty library files. - * Sets SMARTY_DIR only if user application has not already defined it. - */ -if (!defined('SMARTY_DIR')) { - define('SMARTY_DIR', dirname(__FILE__) . DS); -} - -/** - * set SMARTY_SYSPLUGINS_DIR to absolute path to Smarty internal plugins. - * Sets SMARTY_SYSPLUGINS_DIR only if user application has not already defined it. - */ -if (!defined('SMARTY_SYSPLUGINS_DIR')) { - define('SMARTY_SYSPLUGINS_DIR', SMARTY_DIR . 'sysplugins' . DS); -} -if (!defined('SMARTY_PLUGINS_DIR')) { - define('SMARTY_PLUGINS_DIR', SMARTY_DIR . 'plugins' . DS); -} -if (!defined('SMARTY_MBSTRING')) { - define('SMARTY_MBSTRING', function_exists('mb_strlen')); -} -if (!defined('SMARTY_RESOURCE_CHAR_SET')) { - // UTF-8 can only be done properly when mbstring is available! - /** - * @deprecated in favor of Smarty::$_CHARSET - */ - define('SMARTY_RESOURCE_CHAR_SET', SMARTY_MBSTRING ? 'UTF-8' : 'ISO-8859-1'); -} -if (!defined('SMARTY_RESOURCE_DATE_FORMAT')) { - /** - * @deprecated in favor of Smarty::$_DATE_FORMAT - */ - define('SMARTY_RESOURCE_DATE_FORMAT', '%b %e, %Y'); -} - -/** - * register the class autoloader - */ -if (!defined('SMARTY_SPL_AUTOLOAD')) { - define('SMARTY_SPL_AUTOLOAD', 0); -} - -if (SMARTY_SPL_AUTOLOAD && set_include_path(get_include_path() . PATH_SEPARATOR . SMARTY_SYSPLUGINS_DIR) !== false) { - $registeredAutoLoadFunctions = spl_autoload_functions(); - if (!isset($registeredAutoLoadFunctions['spl_autoload'])) { - spl_autoload_register(); - } -} else { - spl_autoload_register('smartyAutoload'); -} - -/** - * Load always needed external class files - */ -include_once SMARTY_SYSPLUGINS_DIR.'smarty_internal_data.php'; -include_once SMARTY_SYSPLUGINS_DIR.'smarty_internal_templatebase.php'; -include_once SMARTY_SYSPLUGINS_DIR.'smarty_internal_template.php'; -include_once SMARTY_SYSPLUGINS_DIR.'smarty_resource.php'; -include_once SMARTY_SYSPLUGINS_DIR.'smarty_internal_resource_file.php'; -include_once SMARTY_SYSPLUGINS_DIR.'smarty_cacheresource.php'; -include_once SMARTY_SYSPLUGINS_DIR.'smarty_internal_cacheresource_file.php'; - -/** - * This is the main Smarty class - * @package Smarty - */ -class Smarty extends Smarty_Internal_TemplateBase { - - /**#@+ - * constant definitions - */ - - /** - * smarty version - */ - const SMARTY_VERSION = 'Smarty-3.1.7'; - - /** - * define variable scopes - */ - const SCOPE_LOCAL = 0; - const SCOPE_PARENT = 1; - const SCOPE_ROOT = 2; - const SCOPE_GLOBAL = 3; - /** - * define caching modes - */ - const CACHING_OFF = 0; - const CACHING_LIFETIME_CURRENT = 1; - const CACHING_LIFETIME_SAVED = 2; - /** - * define compile check modes - */ - const COMPILECHECK_OFF = 0; - const COMPILECHECK_ON = 1; - const COMPILECHECK_CACHEMISS = 2; - /** - * modes for handling of "<?php ... ?>" tags in templates. - */ - const PHP_PASSTHRU = 0; //-> print tags as plain text - const PHP_QUOTE = 1; //-> escape tags as entities - const PHP_REMOVE = 2; //-> escape tags as entities - const PHP_ALLOW = 3; //-> escape tags as entities - /** - * filter types - */ - const FILTER_POST = 'post'; - const FILTER_PRE = 'pre'; - const FILTER_OUTPUT = 'output'; - const FILTER_VARIABLE = 'variable'; - /** - * plugin types - */ - const PLUGIN_FUNCTION = 'function'; - const PLUGIN_BLOCK = 'block'; - const PLUGIN_COMPILER = 'compiler'; - const PLUGIN_MODIFIER = 'modifier'; - const PLUGIN_MODIFIERCOMPILER = 'modifiercompiler'; - - /**#@-*/ - - /** - * assigned global tpl vars - */ - public static $global_tpl_vars = array(); - - /** - * error handler returned by set_error_hanlder() in Smarty::muteExpectedErrors() - */ - public static $_previous_error_handler = null; - /** - * contains directories outside of SMARTY_DIR that are to be muted by muteExpectedErrors() - */ - public static $_muted_directories = array(); - /** - * Flag denoting if Multibyte String functions are available - */ - public static $_MBSTRING = SMARTY_MBSTRING; - /** - * The character set to adhere to (e.g. "UTF-8") - */ - public static $_CHARSET = SMARTY_RESOURCE_CHAR_SET; - /** - * The date format to be used internally - * (accepts date() and strftime()) - */ - public static $_DATE_FORMAT = SMARTY_RESOURCE_DATE_FORMAT; - /** - * Flag denoting if PCRE should run in UTF-8 mode - */ - public static $_UTF8_MODIFIER = 'u'; - - - /**#@+ - * variables - */ - - /** - * auto literal on delimiters with whitspace - * @var boolean - */ - public $auto_literal = true; - /** - * display error on not assigned variables - * @var boolean - */ - public $error_unassigned = false; - /** - * look up relative filepaths in include_path - * @var boolean - */ - public $use_include_path = false; - /** - * template directory - * @var array - */ - private $template_dir = array(); - /** - * joined template directory string used in cache keys - * @var string - */ - public $joined_template_dir = null; - /** - * joined config directory string used in cache keys - * @var string - */ - public $joined_config_dir = null; - /** - * default template handler - * @var callable - */ - public $default_template_handler_func = null; - /** - * default config handler - * @var callable - */ - public $default_config_handler_func = null; - /** - * default plugin handler - * @var callable - */ - public $default_plugin_handler_func = null; - /** - * compile directory - * @var string - */ - private $compile_dir = null; - /** - * plugins directory - * @var array - */ - private $plugins_dir = array(); - /** - * cache directory - * @var string - */ - private $cache_dir = null; - /** - * config directory - * @var array - */ - private $config_dir = array(); - /** - * force template compiling? - * @var boolean - */ - public $force_compile = false; - /** - * check template for modifications? - * @var boolean - */ - public $compile_check = true; - /** - * use sub dirs for compiled/cached files? - * @var boolean - */ - public $use_sub_dirs = false; - /** - * allow ambiguous resources (that are made unique by the resource handler) - * @var boolean - */ - public $allow_ambiguous_resources = false; - /** - * caching enabled - * @var boolean - */ - public $caching = false; - /** - * merge compiled includes - * @var boolean - */ - public $merge_compiled_includes = false; - /** - * cache lifetime in seconds - * @var integer - */ - public $cache_lifetime = 3600; - /** - * force cache file creation - * @var boolean - */ - public $force_cache = false; - /** - * Set this if you want different sets of cache files for the same - * templates. - * - * @var string - */ - public $cache_id = null; - /** - * Set this if you want different sets of compiled files for the same - * templates. - * - * @var string - */ - public $compile_id = null; - /** - * template left-delimiter - * @var string - */ - public $left_delimiter = "{"; - /** - * template right-delimiter - * @var string - */ - public $right_delimiter = "}"; - /**#@+ - * security - */ - /** - * class name - * - * This should be instance of Smarty_Security. - * - * @var string - * @see Smarty_Security - */ - public $security_class = 'Smarty_Security'; - /** - * implementation of security class - * - * @var Smarty_Security - */ - public $security_policy = null; - /** - * controls handling of PHP-blocks - * - * @var integer - */ - public $php_handling = self::PHP_PASSTHRU; - /** - * controls if the php template file resource is allowed - * - * @var bool - */ - public $allow_php_templates = false; - /** - * Should compiled-templates be prevented from being called directly? - * - * {@internal - * Currently used by Smarty_Internal_Template only. - * }} - * - * @var boolean - */ - public $direct_access_security = true; - /**#@-*/ - /** - * debug mode - * - * Setting this to true enables the debug-console. - * - * @var boolean - */ - public $debugging = false; - /** - * This determines if debugging is enable-able from the browser. - * <ul> - * <li>NONE => no debugging control allowed</li> - * <li>URL => enable debugging when SMARTY_DEBUG is found in the URL.</li> - * </ul> - * @var string - */ - public $debugging_ctrl = 'NONE'; - /** - * Name of debugging URL-param. - * - * Only used when $debugging_ctrl is set to 'URL'. - * The name of the URL-parameter that activates debugging. - * - * @var type - */ - public $smarty_debug_id = 'SMARTY_DEBUG'; - /** - * Path of debug template. - * @var string - */ - public $debug_tpl = null; - /** - * When set, smarty uses this value as error_reporting-level. - * @var int - */ - public $error_reporting = null; - /** - * Internal flag for getTags() - * @var boolean - */ - public $get_used_tags = false; - - /**#@+ - * config var settings - */ - - /** - * Controls whether variables with the same name overwrite each other. - * @var boolean - */ - public $config_overwrite = true; - /** - * Controls whether config values of on/true/yes and off/false/no get converted to boolean. - * @var boolean - */ - public $config_booleanize = true; - /** - * Controls whether hidden config sections/vars are read from the file. - * @var boolean - */ - public $config_read_hidden = false; - - /**#@-*/ - - /**#@+ - * resource locking - */ - - /** - * locking concurrent compiles - * @var boolean - */ - public $compile_locking = true; - /** - * Controls whether cache resources should emply locking mechanism - * @var boolean - */ - public $cache_locking = false; - /** - * seconds to wait for acquiring a lock before ignoring the write lock - * @var float - */ - public $locking_timeout = 10; - - /**#@-*/ - - /** - * global template functions - * @var array - */ - public $template_functions = array(); - /** - * resource type used if none given - * - * Must be an valid key of $registered_resources. - * @var string - */ - public $default_resource_type = 'file'; - /** - * caching type - * - * Must be an element of $cache_resource_types. - * - * @var string - */ - public $caching_type = 'file'; - /** - * internal config properties - * @var array - */ - public $properties = array(); - /** - * config type - * @var string - */ - public $default_config_type = 'file'; - /** - * cached template objects - * @var array - */ - public $template_objects = array(); - /** - * check If-Modified-Since headers - * @var boolean - */ - public $cache_modified_check = false; - /** - * registered plugins - * @var array - */ - public $registered_plugins = array(); - /** - * plugin search order - * @var array - */ - public $plugin_search_order = array('function', 'block', 'compiler', 'class'); - /** - * registered objects - * @var array - */ - public $registered_objects = array(); - /** - * registered classes - * @var array - */ - public $registered_classes = array(); - /** - * registered filters - * @var array - */ - public $registered_filters = array(); - /** - * registered resources - * @var array - */ - public $registered_resources = array(); - /** - * resource handler cache - * @var array - */ - public $_resource_handlers = array(); - /** - * registered cache resources - * @var array - */ - public $registered_cache_resources = array(); - /** - * cache resource handler cache - * @var array - */ - public $_cacheresource_handlers = array(); - /** - * autoload filter - * @var array - */ - public $autoload_filters = array(); - /** - * default modifier - * @var array - */ - public $default_modifiers = array(); - /** - * autoescape variable output - * @var boolean - */ - public $escape_html = false; - /** - * global internal smarty vars - * @var array - */ - public static $_smarty_vars = array(); - /** - * start time for execution time calculation - * @var int - */ - public $start_time = 0; - /** - * default file permissions - * @var int - */ - public $_file_perms = 0644; - /** - * default dir permissions - * @var int - */ - public $_dir_perms = 0771; - /** - * block tag hierarchy - * @var array - */ - public $_tag_stack = array(); - /** - * self pointer to Smarty object - * @var Smarty - */ - public $smarty; - /** - * required by the compiler for BC - * @var string - */ - public $_current_file = null; - /** - * internal flag to enable parser debugging - * @var bool - */ - public $_parserdebug = false; - /** - * Saved parameter of merged templates during compilation - * - * @var array - */ - public $merged_templates_func = array(); - /**#@-*/ - - /** - * Initialize new Smarty object - * - */ - public function __construct() - { - // selfpointer needed by some other class methods - $this->smarty = $this; - if (is_callable('mb_internal_encoding')) { - mb_internal_encoding(Smarty::$_CHARSET); - } - $this->start_time = microtime(true); - // set default dirs - $this->setTemplateDir('.' . DS . 'templates' . DS) - ->setCompileDir('.' . DS . 'templates_c' . DS) - ->setPluginsDir(SMARTY_PLUGINS_DIR) - ->setCacheDir('.' . DS . 'cache' . DS) - ->setConfigDir('.' . DS . 'configs' . DS); - - $this->debug_tpl = 'file:' . dirname(__FILE__) . '/debug.tpl'; - if (isset($_SERVER['SCRIPT_NAME'])) { - $this->assignGlobal('SCRIPT_NAME', $_SERVER['SCRIPT_NAME']); - } - } - - - /** - * Class destructor - */ - public function __destruct() - { - // intentionally left blank - } - - /** - * <<magic>> set selfpointer on cloned object - */ - public function __clone() - { - $this->smarty = $this; - } - - - /** - * <<magic>> Generic getter. - * - * Calls the appropriate getter function. - * Issues an E_USER_NOTICE if no valid getter is found. - * - * @param string $name property name - * @return mixed - */ - public function __get($name) - { - $allowed = array( - 'template_dir' => 'getTemplateDir', - 'config_dir' => 'getConfigDir', - 'plugins_dir' => 'getPluginsDir', - 'compile_dir' => 'getCompileDir', - 'cache_dir' => 'getCacheDir', - ); - - if (isset($allowed[$name])) { - return $this->{$allowed[$name]}(); - } else { - trigger_error('Undefined property: '. get_class($this) .'::$'. $name, E_USER_NOTICE); - } - } - - /** - * <<magic>> Generic setter. - * - * Calls the appropriate setter function. - * Issues an E_USER_NOTICE if no valid setter is found. - * - * @param string $name property name - * @param mixed $value parameter passed to setter - */ - public function __set($name, $value) - { - $allowed = array( - 'template_dir' => 'setTemplateDir', - 'config_dir' => 'setConfigDir', - 'plugins_dir' => 'setPluginsDir', - 'compile_dir' => 'setCompileDir', - 'cache_dir' => 'setCacheDir', - ); - - if (isset($allowed[$name])) { - $this->{$allowed[$name]}($value); - } else { - trigger_error('Undefined property: ' . get_class($this) . '::$' . $name, E_USER_NOTICE); - } - } - - /** - * Check if a template resource exists - * - * @param string $resource_name template name - * @return boolean status - */ - public function templateExists($resource_name) - { - // create template object - $save = $this->template_objects; - $tpl = new $this->template_class($resource_name, $this); - // check if it does exists - $result = $tpl->source->exists; - $this->template_objects = $save; - return $result; - } - - /** - * Returns a single or all global variables - * - * @param object $smarty - * @param string $varname variable name or null - * @return string variable value or or array of variables - */ - public function getGlobal($varname = null) - { - if (isset($varname)) { - if (isset(self::$global_tpl_vars[$varname])) { - return self::$global_tpl_vars[$varname]->value; - } else { - return ''; - } - } else { - $_result = array(); - foreach (self::$global_tpl_vars AS $key => $var) { - $_result[$key] = $var->value; - } - return $_result; - } - } - - /** - * Empty cache folder - * - * @param integer $exp_time expiration time - * @param string $type resource type - * @return integer number of cache files deleted - */ - function clearAllCache($exp_time = null, $type = null) - { - // load cache resource and call clearAll - $_cache_resource = Smarty_CacheResource::load($this, $type); - Smarty_CacheResource::invalidLoadedCache($this); - return $_cache_resource->clearAll($this, $exp_time); - } - - /** - * Empty cache for a specific template - * - * @param string $template_name template name - * @param string $cache_id cache id - * @param string $compile_id compile id - * @param integer $exp_time expiration time - * @param string $type resource type - * @return integer number of cache files deleted - */ - public function clearCache($template_name, $cache_id = null, $compile_id = null, $exp_time = null, $type = null) - { - // load cache resource and call clear - $_cache_resource = Smarty_CacheResource::load($this, $type); - Smarty_CacheResource::invalidLoadedCache($this); - return $_cache_resource->clear($this, $template_name, $cache_id, $compile_id, $exp_time); - } - - /** - * Loads security class and enables security - * - * @param string|Smarty_Security $security_class if a string is used, it must be class-name - * @return Smarty current Smarty instance for chaining - * @throws SmartyException when an invalid class name is provided - */ - public function enableSecurity($security_class = null) - { - if ($security_class instanceof Smarty_Security) { - $this->security_policy = $security_class; - return $this; - } elseif (is_object($security_class)) { - throw new SmartyException("Class '" . get_class($security_class) . "' must extend Smarty_Security."); - } - if ($security_class == null) { - $security_class = $this->security_class; - } - if (!class_exists($security_class)) { - throw new SmartyException("Security class '$security_class' is not defined"); - } elseif ($security_class !== 'Smarty_Security' && !is_subclass_of($security_class, 'Smarty_Security')) { - throw new SmartyException("Class '$security_class' must extend Smarty_Security."); - } else { - $this->security_policy = new $security_class($this); - } - - return $this; - } - - /** - * Disable security - * @return Smarty current Smarty instance for chaining - */ - public function disableSecurity() - { - $this->security_policy = null; - - return $this; - } - - /** - * Set template directory - * - * @param string|array $template_dir directory(s) of template sources - * @return Smarty current Smarty instance for chaining - */ - public function setTemplateDir($template_dir) - { - $this->template_dir = array(); - foreach ((array) $template_dir as $k => $v) { - $this->template_dir[$k] = rtrim($v, '/\\') . DS; - } - - $this->joined_template_dir = join(DIRECTORY_SEPARATOR, $this->template_dir); - return $this; - } - - /** - * Add template directory(s) - * - * @param string|array $template_dir directory(s) of template sources - * @param string $key of the array element to assign the template dir to - * @return Smarty current Smarty instance for chaining - * @throws SmartyException when the given template directory is not valid - */ - public function addTemplateDir($template_dir, $key=null) - { - // make sure we're dealing with an array - $this->template_dir = (array) $this->template_dir; - - if (is_array($template_dir)) { - foreach ($template_dir as $k => $v) { - if (is_int($k)) { - // indexes are not merged but appended - $this->template_dir[] = rtrim($v, '/\\') . DS; - } else { - // string indexes are overridden - $this->template_dir[$k] = rtrim($v, '/\\') . DS; - } - } - } elseif ($key !== null) { - // override directory at specified index - $this->template_dir[$key] = rtrim($template_dir, '/\\') . DS; - } else { - // append new directory - $this->template_dir[] = rtrim($template_dir, '/\\') . DS; - } - $this->joined_template_dir = join(DIRECTORY_SEPARATOR, $this->template_dir); - return $this; - } - - /** - * Get template directories - * - * @param mixed index of directory to get, null to get all - * @return array|string list of template directories, or directory of $index - */ - public function getTemplateDir($index=null) - { - if ($index !== null) { - return isset($this->template_dir[$index]) ? $this->template_dir[$index] : null; - } - - return (array)$this->template_dir; - } - - /** - * Set config directory - * - * @param string|array $template_dir directory(s) of configuration sources - * @return Smarty current Smarty instance for chaining - */ - public function setConfigDir($config_dir) - { - $this->config_dir = array(); - foreach ((array) $config_dir as $k => $v) { - $this->config_dir[$k] = rtrim($v, '/\\') . DS; - } - - $this->joined_config_dir = join(DIRECTORY_SEPARATOR, $this->config_dir); - return $this; - } - - /** - * Add config directory(s) - * - * @param string|array $config_dir directory(s) of config sources - * @param string key of the array element to assign the config dir to - * @return Smarty current Smarty instance for chaining - */ - public function addConfigDir($config_dir, $key=null) - { - // make sure we're dealing with an array - $this->config_dir = (array) $this->config_dir; - - if (is_array($config_dir)) { - foreach ($config_dir as $k => $v) { - if (is_int($k)) { - // indexes are not merged but appended - $this->config_dir[] = rtrim($v, '/\\') . DS; - } else { - // string indexes are overridden - $this->config_dir[$k] = rtrim($v, '/\\') . DS; - } - } - } elseif( $key !== null ) { - // override directory at specified index - $this->config_dir[$key] = rtrim($config_dir, '/\\') . DS; - } else { - // append new directory - $this->config_dir[] = rtrim($config_dir, '/\\') . DS; - } - - $this->joined_config_dir = join(DIRECTORY_SEPARATOR, $this->config_dir); - return $this; - } - - /** - * Get config directory - * - * @param mixed index of directory to get, null to get all - * @return array|string configuration directory - */ - public function getConfigDir($index=null) - { - if ($index !== null) { - return isset($this->config_dir[$index]) ? $this->config_dir[$index] : null; - } - - return (array)$this->config_dir; - } - - /** - * Set plugins directory - * - * @param string|array $plugins_dir directory(s) of plugins - * @return Smarty current Smarty instance for chaining - */ - public function setPluginsDir($plugins_dir) - { - $this->plugins_dir = array(); - foreach ((array)$plugins_dir as $k => $v) { - $this->plugins_dir[$k] = rtrim($v, '/\\') . DS; - } - - return $this; - } - - /** - * Adds directory of plugin files - * - * @param object $smarty - * @param string $ |array $ plugins folder - * @return Smarty current Smarty instance for chaining - */ - public function addPluginsDir($plugins_dir) - { - // make sure we're dealing with an array - $this->plugins_dir = (array) $this->plugins_dir; - - if (is_array($plugins_dir)) { - foreach ($plugins_dir as $k => $v) { - if (is_int($k)) { - // indexes are not merged but appended - $this->plugins_dir[] = rtrim($v, '/\\') . DS; - } else { - // string indexes are overridden - $this->plugins_dir[$k] = rtrim($v, '/\\') . DS; - } - } - } else { - // append new directory - $this->plugins_dir[] = rtrim($plugins_dir, '/\\') . DS; - } - - $this->plugins_dir = array_unique($this->plugins_dir); - return $this; - } - - /** - * Get plugin directories - * - * @return array list of plugin directories - */ - public function getPluginsDir() - { - return (array)$this->plugins_dir; - } - - /** - * Set compile directory - * - * @param string $compile_dir directory to store compiled templates in - * @return Smarty current Smarty instance for chaining - */ - public function setCompileDir($compile_dir) - { - $this->compile_dir = rtrim($compile_dir, '/\\') . DS; - if (!isset(Smarty::$_muted_directories[$this->compile_dir])) { - Smarty::$_muted_directories[$this->compile_dir] = null; - } - return $this; - } - - /** - * Get compiled directory - * - * @return string path to compiled templates - */ - public function getCompileDir() - { - return $this->compile_dir; - } - - /** - * Set cache directory - * - * @param string $cache_dir directory to store cached templates in - * @return Smarty current Smarty instance for chaining - */ - public function setCacheDir($cache_dir) - { - $this->cache_dir = rtrim($cache_dir, '/\\') . DS; - if (!isset(Smarty::$_muted_directories[$this->cache_dir])) { - Smarty::$_muted_directories[$this->cache_dir] = null; - } - return $this; - } - - /** - * Get cache directory - * - * @return string path of cache directory - */ - public function getCacheDir() - { - return $this->cache_dir; - } - - /** - * Set default modifiers - * - * @param array|string $modifiers modifier or list of modifiers to set - * @return Smarty current Smarty instance for chaining - */ - public function setDefaultModifiers($modifiers) - { - $this->default_modifiers = (array) $modifiers; - return $this; - } - - /** - * Add default modifiers - * - * @param array|string $modifiers modifier or list of modifiers to add - * @return Smarty current Smarty instance for chaining - */ - public function addDefaultModifiers($modifiers) - { - if (is_array($modifiers)) { - $this->default_modifiers = array_merge($this->default_modifiers, $modifiers); - } else { - $this->default_modifiers[] = $modifiers; - } - - return $this; - } - - /** - * Get default modifiers - * - * @return array list of default modifiers - */ - public function getDefaultModifiers() - { - return $this->default_modifiers; - } - - - /** - * Set autoload filters - * - * @param array $filters filters to load automatically - * @param string $type "pre", "output", … specify the filter type to set. Defaults to none treating $filters' keys as the appropriate types - * @return Smarty current Smarty instance for chaining - */ - public function setAutoloadFilters($filters, $type=null) - { - if ($type !== null) { - $this->autoload_filters[$type] = (array) $filters; - } else { - $this->autoload_filters = (array) $filters; - } - - return $this; - } - - /** - * Add autoload filters - * - * @param array $filters filters to load automatically - * @param string $type "pre", "output", … specify the filter type to set. Defaults to none treating $filters' keys as the appropriate types - * @return Smarty current Smarty instance for chaining - */ - public function addAutoloadFilters($filters, $type=null) - { - if ($type !== null) { - if (!empty($this->autoload_filters[$type])) { - $this->autoload_filters[$type] = array_merge($this->autoload_filters[$type], (array) $filters); - } else { - $this->autoload_filters[$type] = (array) $filters; - } - } else { - foreach ((array) $filters as $key => $value) { - if (!empty($this->autoload_filters[$key])) { - $this->autoload_filters[$key] = array_merge($this->autoload_filters[$key], (array) $value); - } else { - $this->autoload_filters[$key] = (array) $value; - } - } - } - - return $this; - } - - /** - * Get autoload filters - * - * @param string $type type of filter to get autoloads for. Defaults to all autoload filters - * @return array array( 'type1' => array( 'filter1', 'filter2', … ) ) or array( 'filter1', 'filter2', …) if $type was specified - */ - public function getAutoloadFilters($type=null) - { - if ($type !== null) { - return isset($this->autoload_filters[$type]) ? $this->autoload_filters[$type] : array(); - } - - return $this->autoload_filters; - } - - /** - * return name of debugging template - * - * @return string - */ - public function getDebugTemplate() - { - return $this->debug_tpl; - } - - /** - * set the debug template - * - * @param string $tpl_name - * @return Smarty current Smarty instance for chaining - * @throws SmartyException if file is not readable - */ - public function setDebugTemplate($tpl_name) - { - if (!is_readable($tpl_name)) { - throw new SmartyException("Unknown file '{$tpl_name}'"); - } - $this->debug_tpl = $tpl_name; - - return $this; - } - - /** - * creates a template object - * - * @param string $template the resource handle of the template file - * @param mixed $cache_id cache id to be used with this template - * @param mixed $compile_id compile id to be used with this template - * @param object $parent next higher level of Smarty variables - * @param boolean $do_clone flag is Smarty object shall be cloned - * @return object template object - */ - public function createTemplate($template, $cache_id = null, $compile_id = null, $parent = null, $do_clone = true) - { - if (!empty($cache_id) && (is_object($cache_id) || is_array($cache_id))) { - $parent = $cache_id; - $cache_id = null; - } - if (!empty($parent) && is_array($parent)) { - $data = $parent; - $parent = null; - } else { - $data = null; - } - // default to cache_id and compile_id of Smarty object - $cache_id = $cache_id === null ? $this->cache_id : $cache_id; - $compile_id = $compile_id === null ? $this->compile_id : $compile_id; - // already in template cache? - if ($this->allow_ambiguous_resources) { - $_templateId = Smarty_Resource::getUniqueTemplateName($this, $template) . $cache_id . $compile_id; - } else { - $_templateId = $this->joined_template_dir . '#' . $template . $cache_id . $compile_id; - } - if (isset($_templateId[150])) { - $_templateId = sha1($_templateId); - } - if ($do_clone) { - if (isset($this->template_objects[$_templateId])) { - // return cached template object - $tpl = clone $this->template_objects[$_templateId]; - $tpl->smarty = clone $tpl->smarty; - $tpl->parent = $parent; - $tpl->tpl_vars = array(); - $tpl->config_vars = array(); - } else { - $tpl = new $this->template_class($template, clone $this, $parent, $cache_id, $compile_id); - } - } else { - if (isset($this->template_objects[$_templateId])) { - // return cached template object - $tpl = $this->template_objects[$_templateId]; - $tpl->parent = $parent; - $tpl->tpl_vars = array(); - $tpl->config_vars = array(); - } else { - $tpl = new $this->template_class($template, $this, $parent, $cache_id, $compile_id); - } - } - // fill data if present - if (!empty($data) && is_array($data)) { - // set up variable values - foreach ($data as $_key => $_val) { - $tpl->tpl_vars[$_key] = new Smarty_variable($_val); - } - } - return $tpl; - } - - - /** - * Takes unknown classes and loads plugin files for them - * class name format: Smarty_PluginType_PluginName - * plugin filename format: plugintype.pluginname.php - * - * @param string $plugin_name class plugin name to load - * @param bool $check check if already loaded - * @return string |boolean filepath of loaded file or false - */ - public function loadPlugin($plugin_name, $check = true) - { - // if function or class exists, exit silently (already loaded) - if ($check && (is_callable($plugin_name) || class_exists($plugin_name, false))) { - return true; - } - // Plugin name is expected to be: Smarty_[Type]_[Name] - $_name_parts = explode('_', $plugin_name, 3); - // class name must have three parts to be valid plugin - // count($_name_parts) < 3 === !isset($_name_parts[2]) - if (!isset($_name_parts[2]) || strtolower($_name_parts[0]) !== 'smarty') { - throw new SmartyException("plugin {$plugin_name} is not a valid name format"); - return false; - } - // if type is "internal", get plugin from sysplugins - if (strtolower($_name_parts[1]) == 'internal') { - $file = SMARTY_SYSPLUGINS_DIR . strtolower($plugin_name) . '.php'; - if (file_exists($file)) { - require_once($file); - return $file; - } else { - return false; - } - } - // plugin filename is expected to be: [type].[name].php - $_plugin_filename = "{$_name_parts[1]}.{$_name_parts[2]}.php"; - - // loop through plugin dirs and find the plugin - foreach($this->getPluginsDir() as $_plugin_dir) { - $names = array( - $_plugin_dir . $_plugin_filename, - $_plugin_dir . strtolower($_plugin_filename), - ); - foreach ($names as $file) { - if (file_exists($file)) { - require_once($file); - return $file; - } - if ($this->use_include_path && !preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $_plugin_dir)) { - // try PHP include_path - if (($file = Smarty_Internal_Get_Include_Path::getIncludePath($file)) !== false) { - require_once($file); - return $file; - } - } - } - } - // no plugin loaded - return false; - } - - /** - * Compile all template files - * - * @param string $extension file extension - * @param bool $force_compile force all to recompile - * @param int $time_limit - * @param int $max_errors - * @return integer number of template files recompiled - */ - public function compileAllTemplates($extention = '.tpl', $force_compile = false, $time_limit = 0, $max_errors = null) - { - return Smarty_Internal_Utility::compileAllTemplates($extention, $force_compile, $time_limit, $max_errors, $this); - } - - /** - * Compile all config files - * - * @param string $extension file extension - * @param bool $force_compile force all to recompile - * @param int $time_limit - * @param int $max_errors - * @return integer number of template files recompiled - */ - public function compileAllConfig($extention = '.conf', $force_compile = false, $time_limit = 0, $max_errors = null) - { - return Smarty_Internal_Utility::compileAllConfig($extention, $force_compile, $time_limit, $max_errors, $this); - } - - /** - * Delete compiled template file - * - * @param string $resource_name template name - * @param string $compile_id compile id - * @param integer $exp_time expiration time - * @return integer number of template files deleted - */ - public function clearCompiledTemplate($resource_name = null, $compile_id = null, $exp_time = null) - { - return Smarty_Internal_Utility::clearCompiledTemplate($resource_name, $compile_id, $exp_time, $this); - } - - - /** - * Return array of tag/attributes of all tags used by an template - * - * @param object $templae template object - * @return array of tag/attributes - */ - public function getTags(Smarty_Internal_Template $template) - { - return Smarty_Internal_Utility::getTags($template); - } - - /** - * Run installation test - * - * @param array $errors Array to write errors into, rather than outputting them - * @return boolean true if setup is fine, false if something is wrong - */ - public function testInstall(&$errors=null) - { - return Smarty_Internal_Utility::testInstall($this, $errors); - } - - /** - * Error Handler to mute expected messages - * - * @link http://php.net/set_error_handler - * @param integer $errno Error level - * @return boolean - */ - public static function mutingErrorHandler($errno, $errstr, $errfile, $errline, $errcontext) - { - $_is_muted_directory = false; - - // add the SMARTY_DIR to the list of muted directories - if (!isset(Smarty::$_muted_directories[SMARTY_DIR])) { - $smarty_dir = realpath(SMARTY_DIR); - Smarty::$_muted_directories[SMARTY_DIR] = array( - 'file' => $smarty_dir, - 'length' => strlen($smarty_dir), - ); - } - - // walk the muted directories and test against $errfile - foreach (Smarty::$_muted_directories as $key => &$dir) { - if (!$dir) { - // resolve directory and length for speedy comparisons - $file = realpath($key); - $dir = array( - 'file' => $file, - 'length' => strlen($file), - ); - } - if (!strncmp($errfile, $dir['file'], $dir['length'])) { - $_is_muted_directory = true; - break; - } - } - - // pass to next error handler if this error did not occur inside SMARTY_DIR - // or the error was within smarty but masked to be ignored - if (!$_is_muted_directory || ($errno && $errno & error_reporting())) { - if (Smarty::$_previous_error_handler) { - return call_user_func(Smarty::$_previous_error_handler, $errno, $errstr, $errfile, $errline, $errcontext); - } else { - return false; - } - } - } - - /** - * Enable error handler to mute expected messages - * - * @return void - */ - public static function muteExpectedErrors() - { - /* - error muting is done because some people implemented custom error_handlers using - http://php.net/set_error_handler and for some reason did not understand the following paragraph: - - It is important to remember that the standard PHP error handler is completely bypassed for the - error types specified by error_types unless the callback function returns FALSE. - error_reporting() settings will have no effect and your error handler will be called regardless - - however you are still able to read the current value of error_reporting and act appropriately. - Of particular note is that this value will be 0 if the statement that caused the error was - prepended by the @ error-control operator. - - Smarty deliberately uses @filemtime() over file_exists() and filemtime() in some places. Reasons include - - @filemtime() is almost twice as fast as using an additional file_exists() - - between file_exists() and filemtime() a possible race condition is opened, - which does not exist using the simple @filemtime() approach. - */ - $error_handler = array('Smarty', 'mutingErrorHandler'); - $previous = set_error_handler($error_handler); - - // avoid dead loops - if ($previous !== $error_handler) { - Smarty::$_previous_error_handler = $previous; - } - } - - /** - * Disable error handler muting expected messages - * - * @return void - */ - public static function unmuteExpectedErrors() - { - restore_error_handler(); - } -} - -// let PCRE (preg_*) treat strings as ISO-8859-1 if we're not dealing with UTF-8 -if (Smarty::$_CHARSET !== 'UTF-8') { - Smarty::$_UTF8_MODIFIER = ''; -} - -/** - * Smarty exception class - * @package Smarty - */ -class SmartyException extends Exception { -} - -/** - * Smarty compiler exception class - * @package Smarty - */ -class SmartyCompilerException extends SmartyException { -} - -/** - * Autoloader - */ -function smartyAutoload($class) -{ - $_class = strtolower($class); - $_classes = array( - 'smarty_config_source' => true, - 'smarty_config_compiled' => true, - 'smarty_security' => true, - 'smarty_cacheresource' => true, - 'smarty_cacheresource_custom' => true, - 'smarty_cacheresource_keyvaluestore' => true, - 'smarty_resource' => true, - 'smarty_resource_custom' => true, - 'smarty_resource_uncompiled' => true, - 'smarty_resource_recompiled' => true, - ); - - if (!strncmp($_class, 'smarty_internal_', 16) || isset($_classes[$_class])) { - include SMARTY_SYSPLUGINS_DIR . $_class . '.php'; - } -} - -?> diff --git a/public_html/lib/Smarty/plugins/block.textformat.php b/public_html/lib/Smarty/plugins/block.textformat.php deleted file mode 100644 index b22b104..0000000 --- a/public_html/lib/Smarty/plugins/block.textformat.php +++ /dev/null @@ -1,113 +0,0 @@ -<?php -/** - * Smarty plugin to format text blocks - * - * @package Smarty - * @subpackage PluginsBlock - */ - -/** - * Smarty {textformat}{/textformat} block plugin - * - * Type: block function<br> - * Name: textformat<br> - * Purpose: format text a certain way with preset styles - * or custom wrap/indent settings<br> - * Params: - * <pre> - * - style - string (email) - * - indent - integer (0) - * - wrap - integer (80) - * - wrap_char - string ("\n") - * - indent_char - string (" ") - * - wrap_boundary - boolean (true) - * </pre> - * - * @link http://www.smarty.net/manual/en/language.function.textformat.php {textformat} - * (Smarty online manual) - * @param array $params parameters - * @param string $content contents of the block - * @param Smarty_Internal_Template $template template object - * @param boolean &$repeat repeat flag - * @return string content re-formatted - * @author Monte Ohrt <monte at ohrt dot com> - */ -function smarty_block_textformat($params, $content, $template, &$repeat) -{ - if (is_null($content)) { - return; - } - - $style = null; - $indent = 0; - $indent_first = 0; - $indent_char = ' '; - $wrap = 80; - $wrap_char = "\n"; - $wrap_cut = false; - $assign = null; - - foreach ($params as $_key => $_val) { - switch ($_key) { - case 'style': - case 'indent_char': - case 'wrap_char': - case 'assign': - $$_key = (string)$_val; - break; - - case 'indent': - case 'indent_first': - case 'wrap': - $$_key = (int)$_val; - break; - - case 'wrap_cut': - $$_key = (bool)$_val; - break; - - default: - trigger_error("textformat: unknown attribute '$_key'"); - } - } - - if ($style == 'email') { - $wrap = 72; - } - // split into paragraphs - $_paragraphs = preg_split('![\r\n]{2}!', $content); - $_output = ''; - - - foreach ($_paragraphs as &$_paragraph) { - if (!$_paragraph) { - continue; - } - // convert mult. spaces & special chars to single space - $_paragraph = preg_replace(array('!\s+!' . Smarty::$_UTF8_MODIFIER, '!(^\s+)|(\s+$)!' . Smarty::$_UTF8_MODIFIER), array(' ', ''), $_paragraph); - // indent first line - if ($indent_first > 0) { - $_paragraph = str_repeat($indent_char, $indent_first) . $_paragraph; - } - // wordwrap sentences - if (Smarty::$_MBSTRING) { - require_once(SMARTY_PLUGINS_DIR . 'shared.mb_wordwrap.php'); - $_paragraph = smarty_mb_wordwrap($_paragraph, $wrap - $indent, $wrap_char, $wrap_cut); - } else { - $_paragraph = wordwrap($_paragraph, $wrap - $indent, $wrap_char, $wrap_cut); - } - // indent lines - if ($indent > 0) { - $_paragraph = preg_replace('!^!m', str_repeat($indent_char, $indent), $_paragraph); - } - } - $_output = implode($wrap_char . $wrap_char, $_paragraphs); - - if ($assign) { - $template->assign($assign, $_output); - } else { - return $_output; - } -} - -?>
\ No newline at end of file diff --git a/public_html/lib/Smarty/plugins/function.fetch.php b/public_html/lib/Smarty/plugins/function.fetch.php deleted file mode 100644 index eca1182..0000000 --- a/public_html/lib/Smarty/plugins/function.fetch.php +++ /dev/null @@ -1,214 +0,0 @@ -<?php -/** - * Smarty plugin - * - * @package Smarty - * @subpackage PluginsFunction - */ - -/** - * Smarty {fetch} plugin - * - * Type: function<br> - * Name: fetch<br> - * Purpose: fetch file, web or ftp data and display results - * - * @link http://www.smarty.net/manual/en/language.function.fetch.php {fetch} - * (Smarty online manual) - * @author Monte Ohrt <monte at ohrt dot com> - * @param array $params parameters - * @param Smarty_Internal_Template $template template object - * @return string|null if the assign parameter is passed, Smarty assigns the result to a template variable - */ -function smarty_function_fetch($params, $template) -{ - if (empty($params['file'])) { - trigger_error("[plugin] fetch parameter 'file' cannot be empty",E_USER_NOTICE); - return; - } - - // strip file protocol - if (stripos($params['file'], 'file://') === 0) { - $params['file'] = substr($params['file'], 7); - } - - $protocol = strpos($params['file'], '://'); - if ($protocol !== false) { - $protocol = strtolower(substr($params['file'], 0, $protocol)); - } - - if (isset($template->smarty->security_policy)) { - if ($protocol) { - // remote resource (or php stream, …) - if(!$template->smarty->security_policy->isTrustedUri($params['file'])) { - return; - } - } else { - // local file - if(!$template->smarty->security_policy->isTrustedResourceDir($params['file'])) { - return; - } - } - } - - $content = ''; - if ($protocol == 'http') { - // http fetch - if($uri_parts = parse_url($params['file'])) { - // set defaults - $host = $server_name = $uri_parts['host']; - $timeout = 30; - $accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*"; - $agent = "Smarty Template Engine ". Smarty::SMARTY_VERSION; - $referer = ""; - $uri = !empty($uri_parts['path']) ? $uri_parts['path'] : '/'; - $uri .= !empty($uri_parts['query']) ? '?' . $uri_parts['query'] : ''; - $_is_proxy = false; - if(empty($uri_parts['port'])) { - $port = 80; - } else { - $port = $uri_parts['port']; - } - if(!empty($uri_parts['user'])) { - $user = $uri_parts['user']; - } - if(!empty($uri_parts['pass'])) { - $pass = $uri_parts['pass']; - } - // loop through parameters, setup headers - foreach($params as $param_key => $param_value) { - switch($param_key) { - case "file": - case "assign": - case "assign_headers": - break; - case "user": - if(!empty($param_value)) { - $user = $param_value; - } - break; - case "pass": - if(!empty($param_value)) { - $pass = $param_value; - } - break; - case "accept": - if(!empty($param_value)) { - $accept = $param_value; - } - break; - case "header": - if(!empty($param_value)) { - if(!preg_match('![\w\d-]+: .+!',$param_value)) { - trigger_error("[plugin] invalid header format '".$param_value."'",E_USER_NOTICE); - return; - } else { - $extra_headers[] = $param_value; - } - } - break; - case "proxy_host": - if(!empty($param_value)) { - $proxy_host = $param_value; - } - break; - case "proxy_port": - if(!preg_match('!\D!', $param_value)) { - $proxy_port = (int) $param_value; - } else { - trigger_error("[plugin] invalid value for attribute '".$param_key."'",E_USER_NOTICE); - return; - } - break; - case "agent": - if(!empty($param_value)) { - $agent = $param_value; - } - break; - case "referer": - if(!empty($param_value)) { - $referer = $param_value; - } - break; - case "timeout": - if(!preg_match('!\D!', $param_value)) { - $timeout = (int) $param_value; - } else { - trigger_error("[plugin] invalid value for attribute '".$param_key."'",E_USER_NOTICE); - return; - } - break; - default: - trigger_error("[plugin] unrecognized attribute '".$param_key."'",E_USER_NOTICE); - return; - } - } - if(!empty($proxy_host) && !empty($proxy_port)) { - $_is_proxy = true; - $fp = fsockopen($proxy_host,$proxy_port,$errno,$errstr,$timeout); - } else { - $fp = fsockopen($server_name,$port,$errno,$errstr,$timeout); - } - - if(!$fp) { - trigger_error("[plugin] unable to fetch: $errstr ($errno)",E_USER_NOTICE); - return; - } else { - if($_is_proxy) { - fputs($fp, 'GET ' . $params['file'] . " HTTP/1.0\r\n"); - } else { - fputs($fp, "GET $uri HTTP/1.0\r\n"); - } - if(!empty($host)) { - fputs($fp, "Host: $host\r\n"); - } - if(!empty($accept)) { - fputs($fp, "Accept: $accept\r\n"); - } - if(!empty($agent)) { - fputs($fp, "User-Agent: $agent\r\n"); - } - if(!empty($referer)) { - fputs($fp, "Referer: $referer\r\n"); - } - if(isset($extra_headers) && is_array($extra_headers)) { - foreach($extra_headers as $curr_header) { - fputs($fp, $curr_header."\r\n"); - } - } - if(!empty($user) && !empty($pass)) { - fputs($fp, "Authorization: BASIC ".base64_encode("$user:$pass")."\r\n"); - } - - fputs($fp, "\r\n"); - while(!feof($fp)) { - $content .= fgets($fp,4096); - } - fclose($fp); - $csplit = preg_split("!\r\n\r\n!",$content,2); - - $content = $csplit[1]; - - if(!empty($params['assign_headers'])) { - $template->assign($params['assign_headers'],preg_split("!\r\n!",$csplit[0])); - } - } - } else { - trigger_error("[plugin fetch] unable to parse URL, check syntax",E_USER_NOTICE); - return; - } - } else { - $content = @file_get_contents($params['file']); - if ($content === false) { - throw new SmartyException("{fetch} cannot read resource '" . $params['file'] ."'"); - } - } - - if (!empty($params['assign'])) { - $template->assign($params['assign'], $content); - } else { - return $content; - } -} - -?>
\ No newline at end of file diff --git a/public_html/lib/Smarty/plugins/function.html_checkboxes.php b/public_html/lib/Smarty/plugins/function.html_checkboxes.php deleted file mode 100644 index fb9584b..0000000 --- a/public_html/lib/Smarty/plugins/function.html_checkboxes.php +++ /dev/null @@ -1,216 +0,0 @@ -<?php -/** - * Smarty plugin - * - * @package Smarty - * @subpackage PluginsFunction - */ - -/** - * Smarty {html_checkboxes} function plugin - * - * File: function.html_checkboxes.php<br> - * Type: function<br> - * Name: html_checkboxes<br> - * Date: 24.Feb.2003<br> - * Purpose: Prints out a list of checkbox input types<br> - * Examples: - * <pre> - * {html_checkboxes values=$ids output=$names} - * {html_checkboxes values=$ids name='box' separator='<br>' output=$names} - * {html_checkboxes values=$ids checked=$checked separator='<br>' output=$names} - * </pre> - * Params: - * <pre> - * - name (optional) - string default "checkbox" - * - values (required) - array - * - options (optional) - associative array - * - checked (optional) - array default not set - * - separator (optional) - ie <br> or - * - output (optional) - the output next to each checkbox - * - assign (optional) - assign the output as an array to this variable - * - escape (optional) - escape the content (not value), defaults to true - * </pre> - * - * @link http://www.smarty.net/manual/en/language.function.html.checkboxes.php {html_checkboxes} - * (Smarty online manual) - * @author Christopher Kvarme <christopher.kvarme@flashjab.com> - * @author credits to Monte Ohrt <monte at ohrt dot com> - * @version 1.0 - * @param array $params parameters - * @param object $template template object - * @return string - * @uses smarty_function_escape_special_chars() - */ -function smarty_function_html_checkboxes($params, $template) -{ - require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'); - - $name = 'checkbox'; - $values = null; - $options = null; - $selected = array(); - $separator = ''; - $escape = true; - $labels = true; - $label_ids = false; - $output = null; - - $extra = ''; - - foreach($params as $_key => $_val) { - switch($_key) { - case 'name': - case 'separator': - $$_key = (string) $_val; - break; - - case 'escape': - case 'labels': - case 'label_ids': - $$_key = (bool) $_val; - break; - - case 'options': - $$_key = (array) $_val; - break; - - case 'values': - case 'output': - $$_key = array_values((array) $_val); - break; - - case 'checked': - case 'selected': - if (is_array($_val)) { - $selected = array(); - foreach ($_val as $_sel) { - if (is_object($_sel)) { - if (method_exists($_sel, "__toString")) { - $_sel = smarty_function_escape_special_chars((string) $_sel->__toString()); - } else { - trigger_error("html_checkboxes: selected attribute contains an object of class '". get_class($_sel) ."' without __toString() method", E_USER_NOTICE); - continue; - } - } else { - $_sel = smarty_function_escape_special_chars((string) $_sel); - } - $selected[$_sel] = true; - } - } elseif (is_object($_val)) { - if (method_exists($_val, "__toString")) { - $selected = smarty_function_escape_special_chars((string) $_val->__toString()); - } else { - trigger_error("html_checkboxes: selected attribute is an object of class '". get_class($_val) ."' without __toString() method", E_USER_NOTICE); - } - } else { - $selected = smarty_function_escape_special_chars((string) $_val); - } - break; - - case 'checkboxes': - trigger_error('html_checkboxes: the use of the "checkboxes" attribute is deprecated, use "options" instead', E_USER_WARNING); - $options = (array) $_val; - break; - - case 'assign': - break; - - default: - if(!is_array($_val)) { - $extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"'; - } else { - trigger_error("html_checkboxes: extra attribute '$_key' cannot be an array", E_USER_NOTICE); - } - break; - } - } - - if (!isset($options) && !isset($values)) - return ''; /* raise error here? */ - - $_html_result = array(); - - if (isset($options)) { - foreach ($options as $_key=>$_val) { - $_html_result[] = smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels, $label_ids, $escape); - } - } else { - foreach ($values as $_i=>$_key) { - $_val = isset($output[$_i]) ? $output[$_i] : ''; - $_html_result[] = smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels, $label_ids, $escape); - } - } - - if(!empty($params['assign'])) { - $template->assign($params['assign'], $_html_result); - } else { - return implode("\n", $_html_result); - } - -} - -function smarty_function_html_checkboxes_output($name, $value, $output, $selected, $extra, $separator, $labels, $label_ids, $escape=true) { - $_output = ''; - - if (is_object($value)) { - if (method_exists($value, "__toString")) { - $value = (string) $value->__toString(); - } else { - trigger_error("html_options: value is an object of class '". get_class($value) ."' without __toString() method", E_USER_NOTICE); - return ''; - } - } else { - $value = (string) $value; - } - - if (is_object($output)) { - if (method_exists($output, "__toString")) { - $output = (string) $output->__toString(); - } else { - trigger_error("html_options: output is an object of class '". get_class($output) ."' without __toString() method", E_USER_NOTICE); - return ''; - } - } else { - $output = (string) $output; - } - - if ($labels) { - if ($label_ids) { - $_id = smarty_function_escape_special_chars(preg_replace('![^\w\-\.]!' . Smarty::$_UTF8_MODIFIER, '_', $name . '_' . $value)); - $_output .= '<label for="' . $_id . '">'; - } else { - $_output .= '<label>'; - } - } - - $name = smarty_function_escape_special_chars($name); - $value = smarty_function_escape_special_chars($value); - if ($escape) { - $output = smarty_function_escape_special_chars($output); - } - - $_output .= '<input type="checkbox" name="' . $name . '[]" value="' . $value . '"'; - - if ($labels && $label_ids) { - $_output .= ' id="' . $_id . '"'; - } - - if (is_array($selected)) { - if (isset($selected[$value])) { - $_output .= ' checked="checked"'; - } - } elseif ($value === $selected) { - $_output .= ' checked="checked"'; - } - - $_output .= $extra . ' />' . $output; - if ($labels) { - $_output .= '</label>'; - } - - $_output .= $separator; - return $_output; -} - -?>
\ No newline at end of file diff --git a/public_html/lib/Smarty/plugins/function.html_image.php b/public_html/lib/Smarty/plugins/function.html_image.php deleted file mode 100644 index 6521966..0000000 --- a/public_html/lib/Smarty/plugins/function.html_image.php +++ /dev/null @@ -1,159 +0,0 @@ -<?php -/** - * Smarty plugin - * - * @package Smarty - * @subpackage PluginsFunction - */ - -/** - * Smarty {html_image} function plugin - * - * Type: function<br> - * Name: html_image<br> - * Date: Feb 24, 2003<br> - * Purpose: format HTML tags for the image<br> - * Examples: {html_image file="/images/masthead.gif"}<br> - * Output: <img src="/images/masthead.gif" width=400 height=23><br> - * Params: - * <pre> - * - file - (required) - file (and path) of image - * - height - (optional) - image height (default actual height) - * - width - (optional) - image width (default actual width) - * - basedir - (optional) - base directory for absolute paths, default is environment variable DOCUMENT_ROOT - * - path_prefix - prefix for path output (optional, default empty) - * </pre> - * - * @link http://www.smarty.net/manual/en/language.function.html.image.php {html_image} - * (Smarty online manual) - * @author Monte Ohrt <monte at ohrt dot com> - * @author credits to Duda <duda@big.hu> - * @version 1.0 - * @param array $params parameters - * @param Smarty_Internal_Template $template template object - * @return string - * @uses smarty_function_escape_special_chars() - */ -function smarty_function_html_image($params, $template) -{ - require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'); - - $alt = ''; - $file = ''; - $height = ''; - $width = ''; - $extra = ''; - $prefix = ''; - $suffix = ''; - $path_prefix = ''; - $basedir = isset($_SERVER['DOCUMENT_ROOT']) ? $_SERVER['DOCUMENT_ROOT'] : ''; - foreach($params as $_key => $_val) { - switch ($_key) { - case 'file': - case 'height': - case 'width': - case 'dpi': - case 'path_prefix': - case 'basedir': - $$_key = $_val; - break; - - case 'alt': - if (!is_array($_val)) { - $$_key = smarty_function_escape_special_chars($_val); - } else { - throw new SmartyException ("html_image: extra attribute '$_key' cannot be an array", E_USER_NOTICE); - } - break; - - case 'link': - case 'href': - $prefix = '<a href="' . $_val . '">'; - $suffix = '</a>'; - break; - - default: - if (!is_array($_val)) { - $extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"'; - } else { - throw new SmartyException ("html_image: extra attribute '$_key' cannot be an array", E_USER_NOTICE); - } - break; - } - } - - if (empty($file)) { - trigger_error("html_image: missing 'file' parameter", E_USER_NOTICE); - return; - } - - if ($file[0] == '/') { - $_image_path = $basedir . $file; - } else { - $_image_path = $file; - } - - // strip file protocol - if (stripos($params['file'], 'file://') === 0) { - $params['file'] = substr($params['file'], 7); - } - - $protocol = strpos($params['file'], '://'); - if ($protocol !== false) { - $protocol = strtolower(substr($params['file'], 0, $protocol)); - } - - if (isset($template->smarty->security_policy)) { - if ($protocol) { - // remote resource (or php stream, …) - if(!$template->smarty->security_policy->isTrustedUri($params['file'])) { - return; - } - } else { - // local file - if(!$template->smarty->security_policy->isTrustedResourceDir($params['file'])) { - return; - } - } - } - - if (!isset($params['width']) || !isset($params['height'])) { - // FIXME: (rodneyrehm) getimagesize() loads the complete file off a remote resource, use custom [jpg,png,gif]header reader! - if (!$_image_data = @getimagesize($_image_path)) { - if (!file_exists($_image_path)) { - trigger_error("html_image: unable to find '$_image_path'", E_USER_NOTICE); - return; - } else if (!is_readable($_image_path)) { - trigger_error("html_image: unable to read '$_image_path'", E_USER_NOTICE); - return; - } else { - trigger_error("html_image: '$_image_path' is not a valid image file", E_USER_NOTICE); - return; - } - } - - if (!isset($params['width'])) { - $width = $_image_data[0]; - } - if (!isset($params['height'])) { - $height = $_image_data[1]; - } - } - - if (isset($params['dpi'])) { - if (strstr($_SERVER['HTTP_USER_AGENT'], 'Mac')) { - // FIXME: (rodneyrehm) wrong dpi assumption - // don't know who thought this up… even if it was true in 1998, it's definitely wrong in 2011. - $dpi_default = 72; - } else { - $dpi_default = 96; - } - $_resize = $dpi_default / $params['dpi']; - $width = round($width * $_resize); - $height = round($height * $_resize); - } - - return $prefix . '<img src="' . $path_prefix . $file . '" alt="' . $alt . '" width="' . $width . '" height="' . $height . '"' . $extra . ' />' . $suffix; -} - -?>
\ No newline at end of file diff --git a/public_html/lib/Smarty/plugins/function.html_radios.php b/public_html/lib/Smarty/plugins/function.html_radios.php deleted file mode 100644 index 7c83072..0000000 --- a/public_html/lib/Smarty/plugins/function.html_radios.php +++ /dev/null @@ -1,200 +0,0 @@ -<?php -/** - * Smarty plugin - * - * @package Smarty - * @subpackage PluginsFunction - */ - -/** - * Smarty {html_radios} function plugin - * - * File: function.html_radios.php<br> - * Type: function<br> - * Name: html_radios<br> - * Date: 24.Feb.2003<br> - * Purpose: Prints out a list of radio input types<br> - * Params: - * <pre> - * - name (optional) - string default "radio" - * - values (required) - array - * - options (required) - associative array - * - checked (optional) - array default not set - * - separator (optional) - ie <br> or - * - output (optional) - the output next to each radio button - * - assign (optional) - assign the output as an array to this variable - * - escape (optional) - escape the content (not value), defaults to true - * </pre> - * Examples: - * <pre> - * {html_radios values=$ids output=$names} - * {html_radios values=$ids name='box' separator='<br>' output=$names} - * {html_radios values=$ids checked=$checked separator='<br>' output=$names} - * </pre> - * - * @link http://smarty.php.net/manual/en/language.function.html.radios.php {html_radios} - * (Smarty online manual) - * @author Christopher Kvarme <christopher.kvarme@flashjab.com> - * @author credits to Monte Ohrt <monte at ohrt dot com> - * @version 1.0 - * @param array $params parameters - * @param Smarty_Internal_Template $template template object - * @return string - * @uses smarty_function_escape_special_chars() - */ -function smarty_function_html_radios($params, $template) -{ - require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'); - - $name = 'radio'; - $values = null; - $options = null; - $selected = null; - $separator = ''; - $escape = true; - $labels = true; - $label_ids = false; - $output = null; - $extra = ''; - - foreach($params as $_key => $_val) { - switch ($_key) { - case 'name': - case 'separator': - $$_key = (string) $_val; - break; - - case 'checked': - case 'selected': - if (is_array($_val)) { - trigger_error('html_radios: the "' . $_key . '" attribute cannot be an array', E_USER_WARNING); - } elseif (is_object($_val)) { - if (method_exists($_val, "__toString")) { - $selected = smarty_function_escape_special_chars((string) $_val->__toString()); - } else { - trigger_error("html_radios: selected attribute is an object of class '". get_class($_val) ."' without __toString() method", E_USER_NOTICE); - } - } else { - $selected = (string) $_val; - } - break; - - case 'escape': - case 'labels': - case 'label_ids': - $$_key = (bool) $_val; - break; - - case 'options': - $$_key = (array) $_val; - break; - - case 'values': - case 'output': - $$_key = array_values((array) $_val); - break; - - case 'radios': - trigger_error('html_radios: the use of the "radios" attribute is deprecated, use "options" instead', E_USER_WARNING); - $options = (array) $_val; - break; - - case 'assign': - break; - - default: - if (!is_array($_val)) { - $extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"'; - } else { - trigger_error("html_radios: extra attribute '$_key' cannot be an array", E_USER_NOTICE); - } - break; - } - } - - if (!isset($options) && !isset($values)) { - /* raise error here? */ - return ''; - } - - $_html_result = array(); - - if (isset($options)) { - foreach ($options as $_key => $_val) { - $_html_result[] = smarty_function_html_radios_output($name, $_key, $_val, $selected, $extra, $separator, $labels, $label_ids, $escape); - } - } else { - foreach ($values as $_i => $_key) { - $_val = isset($output[$_i]) ? $output[$_i] : ''; - $_html_result[] = smarty_function_html_radios_output($name, $_key, $_val, $selected, $extra, $separator, $labels, $label_ids, $escape); - } - } - - if (!empty($params['assign'])) { - $template->assign($params['assign'], $_html_result); - } else { - return implode("\n", $_html_result); - } -} - -function smarty_function_html_radios_output($name, $value, $output, $selected, $extra, $separator, $labels, $label_ids, $escape) -{ - $_output = ''; - - if (is_object($value)) { - if (method_exists($value, "__toString")) { - $value = (string) $value->__toString(); - } else { - trigger_error("html_options: value is an object of class '". get_class($value) ."' without __toString() method", E_USER_NOTICE); - return ''; - } - } else { - $value = (string) $value; - } - - if (is_object($output)) { - if (method_exists($output, "__toString")) { - $output = (string) $output->__toString(); - } else { - trigger_error("html_options: output is an object of class '". get_class($output) ."' without __toString() method", E_USER_NOTICE); - return ''; - } - } else { - $output = (string) $output; - } - - if ($labels) { - if ($label_ids) { - $_id = smarty_function_escape_special_chars(preg_replace('![^\w\-\.]!' . Smarty::$_UTF8_MODIFIER, '_', $name . '_' . $value)); - $_output .= '<label for="' . $_id . '">'; - } else { - $_output .= '<label>'; - } - } - - $name = smarty_function_escape_special_chars($name); - $value = smarty_function_escape_special_chars($value); - if ($escape) { - $output = smarty_function_escape_special_chars($output); - } - - $_output .= '<input type="radio" name="' . $name . '" value="' . $value . '"'; - - if ($labels && $label_ids) { - $_output .= ' id="' . $_id . '"'; - } - - if ($value === $selected) { - $_output .= ' checked="checked"'; - } - - $_output .= $extra . ' />' . $output; - if ($labels) { - $_output .= '</label>'; - } - - $_output .= $separator; - return $_output; -} - -?>
\ No newline at end of file diff --git a/public_html/lib/Smarty/plugins/function.mailto.php b/public_html/lib/Smarty/plugins/function.mailto.php deleted file mode 100644 index 55d5c06..0000000 --- a/public_html/lib/Smarty/plugins/function.mailto.php +++ /dev/null @@ -1,152 +0,0 @@ -<?php -/** - * Smarty plugin - * - * @package Smarty - * @subpackage PluginsFunction - */ - -/** - * Smarty {mailto} function plugin - * - * Type: function<br> - * Name: mailto<br> - * Date: May 21, 2002 - * Purpose: automate mailto address link creation, and optionally encode them.<br> - * Params: - * <pre> - * - address - (required) - e-mail address - * - text - (optional) - text to display, default is address - * - encode - (optional) - can be one of: - * * none : no encoding (default) - * * javascript : encode with javascript - * * javascript_charcode : encode with javascript charcode - * * hex : encode with hexidecimal (no javascript) - * - cc - (optional) - address(es) to carbon copy - * - bcc - (optional) - address(es) to blind carbon copy - * - subject - (optional) - e-mail subject - * - newsgroups - (optional) - newsgroup(s) to post to - * - followupto - (optional) - address(es) to follow up to - * - extra - (optional) - extra tags for the href link - * </pre> - * Examples: - * <pre> - * {mailto address="me@domain.com"} - * {mailto address="me@domain.com" encode="javascript"} - * {mailto address="me@domain.com" encode="hex"} - * {mailto address="me@domain.com" subject="Hello to you!"} - * {mailto address="me@domain.com" cc="you@domain.com,they@domain.com"} - * {mailto address="me@domain.com" extra='class="mailto"'} - * </pre> - * - * @link http://www.smarty.net/manual/en/language.function.mailto.php {mailto} - * (Smarty online manual) - * @version 1.2 - * @author Monte Ohrt <monte at ohrt dot com> - * @author credits to Jason Sweat (added cc, bcc and subject functionality) - * @param array $params parameters - * @param Smarty_Internal_Template $template template object - * @return string - */ -function smarty_function_mailto($params, $template) -{ - static $_allowed_encoding = array('javascript' => true, 'javascript_charcode' => true, 'hex' => true, 'none' => true); - $extra = ''; - - if (empty($params['address'])) { - trigger_error("mailto: missing 'address' parameter",E_USER_WARNING); - return; - } else { - $address = $params['address']; - } - - $text = $address; - // netscape and mozilla do not decode %40 (@) in BCC field (bug?) - // so, don't encode it. - $search = array('%40', '%2C'); - $replace = array('@', ','); - $mail_parms = array(); - foreach ($params as $var => $value) { - switch ($var) { - case 'cc': - case 'bcc': - case 'followupto': - if (!empty($value)) - $mail_parms[] = $var . '=' . str_replace($search, $replace, rawurlencode($value)); - break; - - case 'subject': - case 'newsgroups': - $mail_parms[] = $var . '=' . rawurlencode($value); - break; - - case 'extra': - case 'text': - $$var = $value; - - default: - } - } - - if ($mail_parms) { - $address .= '?' . join('&', $mail_parms); - } - - $encode = (empty($params['encode'])) ? 'none' : $params['encode']; - if (!isset($_allowed_encoding[$encode])) { - trigger_error("mailto: 'encode' parameter must be none, javascript, javascript_charcode or hex", E_USER_WARNING); - return; - } - // FIXME: (rodneyrehm) document.write() excues me what? 1998 has passed! - if ($encode == 'javascript') { - $string = 'document.write(\'<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>\');'; - - $js_encode = ''; - for ($x = 0, $_length = strlen($string); $x < $_length; $x++) { - $js_encode .= '%' . bin2hex($string[$x]); - } - - return '<script type="text/javascript">eval(unescape(\'' . $js_encode . '\'))</script>'; - } elseif ($encode == 'javascript_charcode') { - $string = '<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>'; - - for($x = 0, $y = strlen($string); $x < $y; $x++) { - $ord[] = ord($string[$x]); - } - - $_ret = "<script type=\"text/javascript\" language=\"javascript\">\n" - . "{document.write(String.fromCharCode(" - . implode(',', $ord) - . "))" - . "}\n" - . "</script>\n"; - - return $_ret; - } elseif ($encode == 'hex') { - preg_match('!^(.*)(\?.*)$!', $address, $match); - if (!empty($match[2])) { - trigger_error("mailto: hex encoding does not work with extra attributes. Try javascript.",E_USER_WARNING); - return; - } - $address_encode = ''; - for ($x = 0, $_length = strlen($address); $x < $_length; $x++) { - if (preg_match('!\w!' . Smarty::$_UTF8_MODIFIER, $address[$x])) { - $address_encode .= '%' . bin2hex($address[$x]); - } else { - $address_encode .= $address[$x]; - } - } - $text_encode = ''; - for ($x = 0, $_length = strlen($text); $x < $_length; $x++) { - $text_encode .= '&#x' . bin2hex($text[$x]) . ';'; - } - - $mailto = "mailto:"; - return '<a href="' . $mailto . $address_encode . '" ' . $extra . '>' . $text_encode . '</a>'; - } else { - // no encoding - return '<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>'; - } -} - -?>
\ No newline at end of file diff --git a/public_html/lib/Smarty/plugins/modifier.capitalize.php b/public_html/lib/Smarty/plugins/modifier.capitalize.php deleted file mode 100644 index a78e363..0000000 --- a/public_html/lib/Smarty/plugins/modifier.capitalize.php +++ /dev/null @@ -1,65 +0,0 @@ -<?php -/** - * Smarty plugin - * - * @package Smarty - * @subpackage PluginsModifier - */ - -/** - * Smarty capitalize modifier plugin - * - * Type: modifier<br> - * Name: capitalize<br> - * Purpose: capitalize words in the string - * - * {@internal {$string|capitalize:true:true} is the fastest option for MBString enabled systems }} - * - * @param string $string string to capitalize - * @param boolean $uc_digits also capitalize "x123" to "X123" - * @param boolean $lc_rest capitalize first letters, lowercase all following letters "aAa" to "Aaa" - * @return string capitalized string - * @author Monte Ohrt <monte at ohrt dot com> - * @author Rodney Rehm - */ -function smarty_modifier_capitalize($string, $uc_digits = false, $lc_rest = false) -{ - if (Smarty::$_MBSTRING) { - if ($lc_rest) { - // uppercase (including hyphenated words) - $upper_string = mb_convert_case( $string, MB_CASE_TITLE, Smarty::$_CHARSET ); - } else { - // uppercase word breaks - $upper_string = preg_replace("!(^|[^\p{L}'])([\p{Ll}])!eS" . Smarty::$_UTF8_MODIFIER, "stripslashes('\\1').mb_convert_case(stripslashes('\\2'),MB_CASE_UPPER, '" . addslashes(Smarty::$_CHARSET) . "')", $string); - } - // check uc_digits case - if (!$uc_digits) { - if (preg_match_all("!\b([\p{L}]*[\p{N}]+[\p{L}]*)\b!" . Smarty::$_UTF8_MODIFIER, $string, $matches, PREG_OFFSET_CAPTURE)) { - foreach($matches[1] as $match) { - $upper_string = substr_replace($upper_string, mb_strtolower($match[0], Smarty::$_CHARSET), $match[1], strlen($match[0])); - } - } - } - $upper_string = preg_replace("!((^|\s)['\"])(\w)!e" . Smarty::$_UTF8_MODIFIER, "stripslashes('\\1').mb_convert_case(stripslashes('\\3'),MB_CASE_UPPER, '" . addslashes(Smarty::$_CHARSET) . "')", $upper_string); - return $upper_string; - } - - // lowercase first - if ($lc_rest) { - $string = strtolower($string); - } - // uppercase (including hyphenated words) - $upper_string = preg_replace("!(^|[^\p{L}'])([\p{Ll}])!eS" . Smarty::$_UTF8_MODIFIER, "stripslashes('\\1').ucfirst(stripslashes('\\2'))", $string); - // check uc_digits case - if (!$uc_digits) { - if (preg_match_all("!\b([\p{L}]*[\p{N}]+[\p{L}]*)\b!" . Smarty::$_UTF8_MODIFIER, $string, $matches, PREG_OFFSET_CAPTURE)) { - foreach($matches[1] as $match) { - $upper_string = substr_replace($upper_string, strtolower($match[0]), $match[1], strlen($match[0])); - } - } - } - $upper_string = preg_replace("!((^|\s)['\"])(\w)!e" . Smarty::$_UTF8_MODIFIER, "stripslashes('\\1').strtoupper(stripslashes('\\3'))", $upper_string); - return $upper_string; -} - -?>
\ No newline at end of file diff --git a/public_html/lib/Smarty/plugins/modifier.date_format.php b/public_html/lib/Smarty/plugins/modifier.date_format.php deleted file mode 100644 index 3cca7d3..0000000 --- a/public_html/lib/Smarty/plugins/modifier.date_format.php +++ /dev/null @@ -1,65 +0,0 @@ -<?php -/** - * Smarty plugin - * - * @package Smarty - * @subpackage PluginsModifier - */ - -/** - * Smarty date_format modifier plugin - * - * Type: modifier<br> - * Name: date_format<br> - * Purpose: format datestamps via strftime<br> - * Input:<br> - * - string: input date string - * - format: strftime format for output - * - default_date: default date if $string is empty - * - * @link http://www.smarty.net/manual/en/language.modifier.date.format.php date_format (Smarty online manual) - * @author Monte Ohrt <monte at ohrt dot com> - * @param string $string input date string - * @param string $format strftime format for output - * @param string $default_date default date if $string is empty - * @param string $formatter either 'strftime' or 'auto' - * @return string |void - * @uses smarty_make_timestamp() - */ -function smarty_modifier_date_format($string, $format=null, $default_date='', $formatter='auto') -{ - if ($format === null) { - $format = Smarty::$_DATE_FORMAT; - } - /** - * Include the {@link shared.make_timestamp.php} plugin - */ - require_once(SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php'); - if ($string != '') { - $timestamp = smarty_make_timestamp($string); - } elseif ($default_date != '') { - $timestamp = smarty_make_timestamp($default_date); - } else { - return; - } - if($formatter=='strftime'||($formatter=='auto'&&strpos($format,'%')!==false)) { - if (DS == '\\') { - $_win_from = array('%D', '%h', '%n', '%r', '%R', '%t', '%T'); - $_win_to = array('%m/%d/%y', '%b', "\n", '%I:%M:%S %p', '%H:%M', "\t", '%H:%M:%S'); - if (strpos($format, '%e') !== false) { - $_win_from[] = '%e'; - $_win_to[] = sprintf('%\' 2d', date('j', $timestamp)); - } - if (strpos($format, '%l') !== false) { - $_win_from[] = '%l'; - $_win_to[] = sprintf('%\' 2d', date('h', $timestamp)); - } - $format = str_replace($_win_from, $_win_to, $format); - } - return strftime($format, $timestamp); - } else { - return date($format, $timestamp); - } -} - -?>
\ No newline at end of file diff --git a/public_html/lib/Smarty/plugins/modifier.debug_print_var.php b/public_html/lib/Smarty/plugins/modifier.debug_print_var.php deleted file mode 100644 index fa44100..0000000 --- a/public_html/lib/Smarty/plugins/modifier.debug_print_var.php +++ /dev/null @@ -1,105 +0,0 @@ -<?php -/** - * Smarty plugin - * - * @package Smarty - * @subpackage Debug - */ - -/** - * Smarty debug_print_var modifier plugin - * - * Type: modifier<br> - * Name: debug_print_var<br> - * Purpose: formats variable contents for display in the console - * - * @author Monte Ohrt <monte at ohrt dot com> - * @param array|object $var variable to be formatted - * @param integer $depth maximum recursion depth if $var is an array - * @param integer $length maximum string length if $var is a string - * @return string - */ -function smarty_modifier_debug_print_var ($var, $depth = 0, $length = 40) -{ - $_replace = array("\n" => '<i>\n</i>', - "\r" => '<i>\r</i>', - "\t" => '<i>\t</i>' - ); - - switch (gettype($var)) { - case 'array' : - $results = '<b>Array (' . count($var) . ')</b>'; - foreach ($var as $curr_key => $curr_val) { - $results .= '<br>' . str_repeat(' ', $depth * 2) - . '<b>' . strtr($curr_key, $_replace) . '</b> => ' - . smarty_modifier_debug_print_var($curr_val, ++$depth, $length); - $depth--; - } - break; - - case 'object' : - $object_vars = get_object_vars($var); - $results = '<b>' . get_class($var) . ' Object (' . count($object_vars) . ')</b>'; - foreach ($object_vars as $curr_key => $curr_val) { - $results .= '<br>' . str_repeat(' ', $depth * 2) - . '<b> ->' . strtr($curr_key, $_replace) . '</b> = ' - . smarty_modifier_debug_print_var($curr_val, ++$depth, $length); - $depth--; - } - break; - - case 'boolean' : - case 'NULL' : - case 'resource' : - if (true === $var) { - $results = 'true'; - } elseif (false === $var) { - $results = 'false'; - } elseif (null === $var) { - $results = 'null'; - } else { - $results = htmlspecialchars((string) $var); - } - $results = '<i>' . $results . '</i>'; - break; - - case 'integer' : - case 'float' : - $results = htmlspecialchars((string) $var); - break; - - case 'string' : - $results = strtr($var, $_replace); - if (Smarty::$_MBSTRING) { - if (mb_strlen($var, Smarty::$_CHARSET) > $length) { - $results = mb_substr($var, 0, $length - 3, Smarty::$_CHARSET) . '...'; - } - } else { - if (isset($var[$length])) { - $results = substr($var, 0, $length - 3) . '...'; - } - } - - $results = htmlspecialchars('"' . $results . '"'); - break; - - case 'unknown type' : - default : - $results = strtr((string) $var, $_replace); - if (Smarty::$_MBSTRING) { - if (mb_strlen($results, Smarty::$_CHARSET) > $length) { - $results = mb_substr($results, 0, $length - 3, Smarty::$_CHARSET) . '...'; - } - } else { - if (strlen($results) > $length) { - $results = substr($results, 0, $length - 3) . '...'; - } - } - - $results = htmlspecialchars($results); - } - - return $results; -} - -?>
\ No newline at end of file diff --git a/public_html/lib/Smarty/plugins/modifier.escape.php b/public_html/lib/Smarty/plugins/modifier.escape.php deleted file mode 100644 index 523d065..0000000 --- a/public_html/lib/Smarty/plugins/modifier.escape.php +++ /dev/null @@ -1,143 +0,0 @@ -<?php -/** - * Smarty plugin - * - * @package Smarty - * @subpackage PluginsModifier - */ - -/** - * Smarty escape modifier plugin - * - * Type: modifier<br> - * Name: escape<br> - * Purpose: escape string for output - * - * @link http://www.smarty.net/manual/en/language.modifier.count.characters.php count_characters (Smarty online manual) - * @author Monte Ohrt <monte at ohrt dot com> - * @param string $string input string - * @param string $esc_type escape type - * @param string $char_set character set, used for htmlspecialchars() or htmlentities() - * @param boolean $double_encode encode already encoded entitites again, used for htmlspecialchars() or htmlentities() - * @return string escaped input string - */ -function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $double_encode = true) -{ - if (!$char_set) { - $char_set = Smarty::$_CHARSET; - } - - switch ($esc_type) { - case 'html': - return htmlspecialchars($string, ENT_QUOTES, $char_set, $double_encode); - - case 'htmlall': - if (Smarty::$_MBSTRING) { - // mb_convert_encoding ignores htmlspecialchars() - $string = htmlspecialchars($string, ENT_QUOTES, $char_set, $double_encode); - // htmlentities() won't convert everything, so use mb_convert_encoding - return mb_convert_encoding($string, 'HTML-ENTITIES', $char_set); - } - - // no MBString fallback - return htmlentities($string, ENT_QUOTES, $char_set, $double_encode); - - case 'url': - return rawurlencode($string); - - case 'urlpathinfo': - return str_replace('%2F', '/', rawurlencode($string)); - - case 'quotes': - // escape unescaped single quotes - return preg_replace("%(?<!\\\\)'%", "\\'", $string); - - case 'hex': - // escape every byte into hex - // Note that the UTF-8 encoded character ä will be represented as %c3%a4 - $return = ''; - $_length = strlen($string); - for ($x = 0; $x < $_length; $x++) { - $return .= '%' . bin2hex($string[$x]); - } - return $return; - - case 'hexentity': - $return = ''; - if (Smarty::$_MBSTRING) { - require_once(SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php'); - $return = ''; - foreach (smarty_mb_to_unicode($string, Smarty::$_CHARSET) as $unicode) { - $return .= '&#x' . strtoupper(dechex($unicode)) . ';'; - } - return $return; - } - // no MBString fallback - $_length = strlen($string); - for ($x = 0; $x < $_length; $x++) { - $return .= '&#x' . bin2hex($string[$x]) . ';'; - } - return $return; - - case 'decentity': - $return = ''; - if (Smarty::$_MBSTRING) { - require_once(SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php'); - $return = ''; - foreach (smarty_mb_to_unicode($string, Smarty::$_CHARSET) as $unicode) { - $return .= '&#' . $unicode . ';'; - } - return $return; - } - // no MBString fallback - $_length = strlen($string); - for ($x = 0; $x < $_length; $x++) { - $return .= '&#' . ord($string[$x]) . ';'; - } - return $return; - - case 'javascript': - // escape quotes and backslashes, newlines, etc. - return strtr($string, array('\\' => '\\\\', "'" => "\\'", '"' => '\\"', "\r" => '\\r', "\n" => '\\n', '</' => '<\/')); - - case 'mail': - if (Smarty::$_MBSTRING) { - require_once(SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php'); - return smarty_mb_str_replace(array('@', '.'), array(' [AT] ', ' [DOT] '), $string); - } - // no MBString fallback - return str_replace(array('@', '.'), array(' [AT] ', ' [DOT] '), $string); - - case 'nonstd': - // escape non-standard chars, such as ms document quotes - $return = ''; - if (Smarty::$_MBSTRING) { - require_once(SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php'); - foreach (smarty_mb_to_unicode($string, Smarty::$_CHARSET) as $unicode) { - if ($unicode >= 126) { - $return .= '&#' . $unicode . ';'; - } else { - $return .= chr($unicode); - } - } - return $return; - } - - $_length = strlen($string); - for ($_i = 0; $_i < $_length; $_i++) { - $_ord = ord(substr($string, $_i, 1)); - // non-standard char, escape it - if ($_ord >= 126) { - $return .= '&#' . $_ord . ';'; - } else { - $return .= substr($string, $_i, 1); - } - } - return $return; - - default: - return $string; - } -} - -?>
\ No newline at end of file diff --git a/public_html/lib/Smarty/plugins/modifier.replace.php b/public_html/lib/Smarty/plugins/modifier.replace.php deleted file mode 100644 index 4d71a6e..0000000 --- a/public_html/lib/Smarty/plugins/modifier.replace.php +++ /dev/null @@ -1,33 +0,0 @@ -<?php -/** - * Smarty plugin - * @package Smarty - * @subpackage PluginsModifier - */ - -/** - * Smarty replace modifier plugin - * - * Type: modifier<br> - * Name: replace<br> - * Purpose: simple search/replace - * - * @link http://smarty.php.net/manual/en/language.modifier.replace.php replace (Smarty online manual) - * @author Monte Ohrt <monte at ohrt dot com> - * @author Uwe Tews - * @param string $string input string - * @param string $search text to search for - * @param string $replace replacement text - * @return string - */ -function smarty_modifier_replace($string, $search, $replace) -{ - if (Smarty::$_MBSTRING) { - require_once(SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php'); - return smarty_mb_str_replace($search, $replace, $string); - } - - return str_replace($search, $replace, $string); -} - -?>
\ No newline at end of file diff --git a/public_html/lib/Smarty/plugins/modifier.spacify.php b/public_html/lib/Smarty/plugins/modifier.spacify.php deleted file mode 100644 index a907232..0000000 --- a/public_html/lib/Smarty/plugins/modifier.spacify.php +++ /dev/null @@ -1,27 +0,0 @@ -<?php -/** - * Smarty plugin - * @package Smarty - * @subpackage PluginsModifier - */ - -/** - * Smarty spacify modifier plugin - * - * Type: modifier<br> - * Name: spacify<br> - * Purpose: add spaces between characters in a string - * - * @link http://smarty.php.net/manual/en/language.modifier.spacify.php spacify (Smarty online manual) - * @author Monte Ohrt <monte at ohrt dot com> - * @param string $string input string - * @param string $spacify_char string to insert between characters. - * @return string - */ -function smarty_modifier_spacify($string, $spacify_char = ' ') -{ - // well… what about charsets besides latin and UTF-8? - return implode($spacify_char, preg_split('//' . Smarty::$_UTF8_MODIFIER, $string, -1, PREG_SPLIT_NO_EMPTY)); -} - -?>
\ No newline at end of file diff --git a/public_html/lib/Smarty/plugins/modifier.truncate.php b/public_html/lib/Smarty/plugins/modifier.truncate.php deleted file mode 100644 index 9a803ec..0000000 --- a/public_html/lib/Smarty/plugins/modifier.truncate.php +++ /dev/null @@ -1,59 +0,0 @@ -<?php -/** - * Smarty plugin - * - * @package Smarty - * @subpackage PluginsModifier - */ - -/** - * Smarty truncate modifier plugin - * - * Type: modifier<br> - * Name: truncate<br> - * Purpose: Truncate a string to a certain length if necessary, - * optionally splitting in the middle of a word, and - * appending the $etc string or inserting $etc into the middle. - * - * @link http://smarty.php.net/manual/en/language.modifier.truncate.php truncate (Smarty online manual) - * @author Monte Ohrt <monte at ohrt dot com> - * @param string $string input string - * @param integer $length length of truncated text - * @param string $etc end string - * @param boolean $break_words truncate at word boundary - * @param boolean $middle truncate in the middle of text - * @return string truncated string - */ -function smarty_modifier_truncate($string, $length = 80, $etc = '...', $break_words = false, $middle = false) { - if ($length == 0) - return ''; - - if (Smarty::$_MBSTRING) { - if (mb_strlen($string, Smarty::$_CHARSET) > $length) { - $length -= min($length, mb_strlen($etc, Smarty::$_CHARSET)); - if (!$break_words && !$middle) { - $string = preg_replace('/\s+?(\S+)?$/' . Smarty::$_UTF8_MODIFIER, '', mb_substr($string, 0, $length + 1, Smarty::$_CHARSET)); - } - if (!$middle) { - return mb_substr($string, 0, $length, Smarty::$_CHARSET) . $etc; - } - return mb_substr($string, 0, $length / 2, Smarty::$_CHARSET) . $etc . mb_substr($string, - $length / 2, $length, Smarty::$_CHARSET); - } - return $string; - } - - // no MBString fallback - if (isset($string[$length])) { - $length -= min($length, strlen($etc)); - if (!$break_words && !$middle) { - $string = preg_replace('/\s+?(\S+)?$/', '', substr($string, 0, $length + 1)); - } - if (!$middle) { - return substr($string, 0, $length) . $etc; - } - return substr($string, 0, $length / 2) . $etc . substr($string, - $length / 2); - } - return $string; -} - -?>
\ No newline at end of file diff --git a/public_html/lib/Smarty/plugins/modifiercompiler.count_characters.php b/public_html/lib/Smarty/plugins/modifiercompiler.count_characters.php deleted file mode 100644 index 98e8efa..0000000 --- a/public_html/lib/Smarty/plugins/modifiercompiler.count_characters.php +++ /dev/null @@ -1,33 +0,0 @@ -<?php
-/**
- * Smarty plugin
- *
- * @package Smarty
- * @subpackage PluginsModifierCompiler
- */
-
-/**
- * Smarty count_characters modifier plugin
- *
- * Type: modifier<br>
- * Name: count_characteres<br>
- * Purpose: count the number of characters in a text
- *
- * @link http://www.smarty.net/manual/en/language.modifier.count.characters.php count_characters (Smarty online manual)
- * @author Uwe Tews
- * @param array $params parameters
- * @return string with compiled code
- */
-function smarty_modifiercompiler_count_characters($params, $compiler)
-{
- if (!isset($params[1]) || $params[1] != 'true') {
- return 'preg_match_all(\'/[^\s]/' . Smarty::$_UTF8_MODIFIER . '\',' . $params[0] . ', $tmp)';
- }
- if (Smarty::$_MBSTRING) {
- return 'mb_strlen(' . $params[0] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')';
- }
- // no MBString fallback
- return 'strlen(' . $params[0] . ')';
-}
-
-?>
\ No newline at end of file diff --git a/public_html/lib/Smarty/plugins/modifiercompiler.count_sentences.php b/public_html/lib/Smarty/plugins/modifiercompiler.count_sentences.php deleted file mode 100644 index 2f517be..0000000 --- a/public_html/lib/Smarty/plugins/modifiercompiler.count_sentences.php +++ /dev/null @@ -1,28 +0,0 @@ -<?php
-/**
- * Smarty plugin
- *
- * @package Smarty
- * @subpackage PluginsModifierCompiler
- */
-
-/**
- * Smarty count_sentences modifier plugin
- *
- * Type: modifier<br>
- * Name: count_sentences
- * Purpose: count the number of sentences in a text
- *
- * @link http://www.smarty.net/manual/en/language.modifier.count.paragraphs.php
- * count_sentences (Smarty online manual)
- * @author Uwe Tews
- * @param array $params parameters
- * @return string with compiled code
- */
-function smarty_modifiercompiler_count_sentences($params, $compiler)
-{
- // find periods, question marks, exclamation marks with a word before but not after.
- return 'preg_match_all("#\w[\.\?\!](\W|$)#S' . Smarty::$_UTF8_MODIFIER . '", ' . $params[0] . ', $tmp)';
-}
-
-?>
\ No newline at end of file diff --git a/public_html/lib/Smarty/plugins/modifiercompiler.count_words.php b/public_html/lib/Smarty/plugins/modifiercompiler.count_words.php deleted file mode 100644 index e05738c..0000000 --- a/public_html/lib/Smarty/plugins/modifiercompiler.count_words.php +++ /dev/null @@ -1,32 +0,0 @@ -<?php
-/**
- * Smarty plugin
- *
- * @package Smarty
- * @subpackage PluginsModifierCompiler
- */
-
-/**
- * Smarty count_words modifier plugin
- *
- * Type: modifier<br>
- * Name: count_words<br>
- * Purpose: count the number of words in a text
- *
- * @link http://www.smarty.net/manual/en/language.modifier.count.words.php count_words (Smarty online manual)
- * @author Uwe Tews
- * @param array $params parameters
- * @return string with compiled code
-*/
-function smarty_modifiercompiler_count_words($params, $compiler)
-{
- if (Smarty::$_MBSTRING) {
- // return 'preg_match_all(\'#[\w\pL]+#' . Smarty::$_UTF8_MODIFIER . '\', ' . $params[0] . ', $tmp)';
- // expression taken from http://de.php.net/manual/en/function.str-word-count.php#85592
- return 'preg_match_all(\'/\p{L}[\p{L}\p{Mn}\p{Pd}\\\'\x{2019}]*/' . Smarty::$_UTF8_MODIFIER . '\', ' . $params[0] . ', $tmp)';
- }
- // no MBString fallback
- return 'str_word_count(' . $params[0] . ')';
-}
-
-?>
\ No newline at end of file diff --git a/public_html/lib/Smarty/plugins/modifiercompiler.escape.php b/public_html/lib/Smarty/plugins/modifiercompiler.escape.php deleted file mode 100644 index b4cd3c8..0000000 --- a/public_html/lib/Smarty/plugins/modifiercompiler.escape.php +++ /dev/null @@ -1,90 +0,0 @@ -<?php
-/**
- * Smarty plugin
- *
- * @package Smarty
- * @subpackage PluginsModifierCompiler
- */
-
-/**
- * @ignore
- */
-require_once( SMARTY_PLUGINS_DIR .'shared.literal_compiler_param.php' );
-
-/**
- * Smarty escape modifier plugin
- *
- * Type: modifier<br>
- * Name: escape<br>
- * Purpose: escape string for output
- *
- * @link http://www.smarty.net/docsv2/en/language.modifier.escape count_characters (Smarty online manual)
- * @author Rodney Rehm
- * @param array $params parameters
- * @return string with compiled code
- */
-function smarty_modifiercompiler_escape($params, $compiler)
-{
- try {
- $esc_type = smarty_literal_compiler_param($params, 1, 'html');
- $char_set = smarty_literal_compiler_param($params, 2, Smarty::$_CHARSET);
- $double_encode = smarty_literal_compiler_param($params, 3, true);
-
- if (!$char_set) {
- $char_set = Smarty::$_CHARSET;
- }
-
- switch ($esc_type) {
- case 'html':
- return 'htmlspecialchars('
- . $params[0] .', ENT_QUOTES, '
- . var_export($char_set, true) . ', '
- . var_export($double_encode, true) . ')';
-
- case 'htmlall':
- if (Smarty::$_MBSTRING) {
- return 'mb_convert_encoding(htmlspecialchars('
- . $params[0] .', ENT_QUOTES, '
- . var_export($char_set, true) . ', '
- . var_export($double_encode, true)
- . '), "HTML-ENTITIES", '
- . var_export($char_set, true) . ')';
- }
-
- // no MBString fallback
- return 'htmlentities('
- . $params[0] .', ENT_QUOTES, '
- . var_export($char_set, true) . ', '
- . var_export($double_encode, true) . ')';
-
- case 'url':
- return 'rawurlencode(' . $params[0] . ')';
-
- case 'urlpathinfo':
- return 'str_replace("%2F", "/", rawurlencode(' . $params[0] . '))';
-
- case 'quotes':
- // escape unescaped single quotes
- return 'preg_replace("%(?<!\\\\\\\\)\'%", "\\\'",' . $params[0] . ')';
-
- case 'javascript':
- // escape quotes and backslashes, newlines, etc.
- return 'strtr(' . $params[0] . ', array("\\\\" => "\\\\\\\\", "\'" => "\\\\\'", "\"" => "\\\\\"", "\\r" => "\\\\r", "\\n" => "\\\n", "</" => "<\/" ))';
-
- }
- } catch(SmartyException $e) {
- // pass through to regular plugin fallback
- }
-
- // could not optimize |escape call, so fallback to regular plugin
- if ($compiler->tag_nocache | $compiler->nocache) {
- $compiler->template->required_plugins['nocache']['escape']['modifier']['file'] = SMARTY_PLUGINS_DIR .'modifier.escape.php';
- $compiler->template->required_plugins['nocache']['escape']['modifier']['function'] = 'smarty_modifier_escape';
- } else {
- $compiler->template->required_plugins['compiled']['escape']['modifier']['file'] = SMARTY_PLUGINS_DIR .'modifier.escape.php';
- $compiler->template->required_plugins['compiled']['escape']['modifier']['function'] = 'smarty_modifier_escape';
- }
- return 'smarty_modifier_escape(' . join( ', ', $params ) . ')';
-}
-
-?>
\ No newline at end of file diff --git a/public_html/lib/Smarty/plugins/modifiercompiler.from_charset.php b/public_html/lib/Smarty/plugins/modifiercompiler.from_charset.php deleted file mode 100644 index 93b568a..0000000 --- a/public_html/lib/Smarty/plugins/modifiercompiler.from_charset.php +++ /dev/null @@ -1,34 +0,0 @@ -<?php
-/**
- * Smarty plugin
- *
- * @package Smarty
- * @subpackage PluginsModifierCompiler
- */
-
-/**
- * Smarty from_charset modifier plugin
- *
- * Type: modifier<br>
- * Name: from_charset<br>
- * Purpose: convert character encoding from $charset to internal encoding
- *
- * @author Rodney Rehm
- * @param array $params parameters
- * @return string with compiled code
- */
-function smarty_modifiercompiler_from_charset($params, $compiler)
-{
- if (!Smarty::$_MBSTRING) {
- // FIXME: (rodneyrehm) shouldn't this throw an error?
- return $params[0];
- }
-
- if (!isset($params[1])) {
- $params[1] = '"ISO-8859-1"';
- }
-
- return 'mb_convert_encoding(' . $params[0] . ', "' . addslashes(Smarty::$_CHARSET) . '", ' . $params[1] . ')';
-}
-
-?>
\ No newline at end of file diff --git a/public_html/lib/Smarty/plugins/modifiercompiler.lower.php b/public_html/lib/Smarty/plugins/modifiercompiler.lower.php deleted file mode 100644 index 1845cc1..0000000 --- a/public_html/lib/Smarty/plugins/modifiercompiler.lower.php +++ /dev/null @@ -1,31 +0,0 @@ -<?php
-/**
- * Smarty plugin
- * @package Smarty
- * @subpackage PluginsModifierCompiler
- */
-
-/**
- * Smarty lower modifier plugin
- *
- * Type: modifier<br>
- * Name: lower<br>
- * Purpose: convert string to lowercase
- *
- * @link http://www.smarty.net/manual/en/language.modifier.lower.php lower (Smarty online manual)
- * @author Monte Ohrt <monte at ohrt dot com>
- * @author Uwe Tews
- * @param array $params parameters
- * @return string with compiled code
- */
-
-function smarty_modifiercompiler_lower($params, $compiler)
-{
- if (Smarty::$_MBSTRING) {
- return 'mb_strtolower(' . $params[0] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')' ;
- }
- // no MBString fallback
- return 'strtolower(' . $params[0] . ')';
-}
-
-?>
\ No newline at end of file diff --git a/public_html/lib/Smarty/plugins/modifiercompiler.strip.php b/public_html/lib/Smarty/plugins/modifiercompiler.strip.php deleted file mode 100644 index f1d5db0..0000000 --- a/public_html/lib/Smarty/plugins/modifiercompiler.strip.php +++ /dev/null @@ -1,33 +0,0 @@ -<?php
-/**
- * Smarty plugin
- *
- * @package Smarty
- * @subpackage PluginsModifierCompiler
- */
-
-/**
- * Smarty strip modifier plugin
- *
- * Type: modifier<br>
- * Name: strip<br>
- * Purpose: Replace all repeated spaces, newlines, tabs
- * with a single space or supplied replacement string.<br>
- * Example: {$var|strip} {$var|strip:" "}<br>
- * Date: September 25th, 2002
- *
- * @link http://www.smarty.net/manual/en/language.modifier.strip.php strip (Smarty online manual)
- * @author Uwe Tews
- * @param array $params parameters
- * @return string with compiled code
- */
-
-function smarty_modifiercompiler_strip($params, $compiler)
-{
- if (!isset($params[1])) {
- $params[1] = "' '";
- }
- return "preg_replace('!\s+!" . Smarty::$_UTF8_MODIFIER . "', {$params[1]},{$params[0]})";
-}
-
-?>
\ No newline at end of file diff --git a/public_html/lib/Smarty/plugins/modifiercompiler.to_charset.php b/public_html/lib/Smarty/plugins/modifiercompiler.to_charset.php deleted file mode 100644 index f5cdf45..0000000 --- a/public_html/lib/Smarty/plugins/modifiercompiler.to_charset.php +++ /dev/null @@ -1,34 +0,0 @@ -<?php
-/**
- * Smarty plugin
- *
- * @package Smarty
- * @subpackage PluginsModifierCompiler
- */
-
-/**
- * Smarty to_charset modifier plugin
- *
- * Type: modifier<br>
- * Name: to_charset<br>
- * Purpose: convert character encoding from internal encoding to $charset
- *
- * @author Rodney Rehm
- * @param array $params parameters
- * @return string with compiled code
- */
-function smarty_modifiercompiler_to_charset($params, $compiler)
-{
- if (!Smarty::$_MBSTRING) {
- // FIXME: (rodneyrehm) shouldn't this throw an error?
- return $params[0];
- }
-
- if (!isset($params[1])) {
- $params[1] = '"ISO-8859-1"';
- }
-
- return 'mb_convert_encoding(' . $params[0] . ', ' . $params[1] . ', "' . addslashes(Smarty::$_CHARSET) . '")';
-}
-
-?>
\ No newline at end of file diff --git a/public_html/lib/Smarty/plugins/modifiercompiler.unescape.php b/public_html/lib/Smarty/plugins/modifiercompiler.unescape.php deleted file mode 100644 index ce0bd63..0000000 --- a/public_html/lib/Smarty/plugins/modifiercompiler.unescape.php +++ /dev/null @@ -1,48 +0,0 @@ -<?php
-/**
- * Smarty plugin
- *
- * @package Smarty
- * @subpackage PluginsModifierCompiler
- */
-
-/**
- * Smarty unescape modifier plugin
- *
- * Type: modifier<br>
- * Name: unescape<br>
- * Purpose: unescape html entities
- *
- * @author Rodney Rehm
- * @param array $params parameters
- * @return string with compiled code
- */
-function smarty_modifiercompiler_unescape($params, $compiler)
-{
- if (!isset($params[1])) {
- $params[1] = 'html';
- }
- if (!isset($params[2])) {
- $params[2] = '\'' . addslashes(Smarty::$_CHARSET) . '\'';
- } else {
- $params[2] = "'" . $params[2] . "'";
- }
-
- switch (trim($params[1], '"\'')) {
- case 'entity':
- return 'mb_convert_encoding(' . $params[0] . ', ' . $params[2] . ', \'HTML-ENTITIES\')';
- case 'htmlall':
- if (Smarty::$_MBSTRING) {
- return 'mb_convert_encoding(' . $params[0] . ', ' . $params[2] . ', \'HTML-ENTITIES\')';
- }
- return 'html_entity_decode(' . $params[0] . ', ENT_QUOTES, ' . $params[2] . ')';
-
- case 'html':
- return 'htmlspecialchars_decode(' . $params[0] . ', ENT_QUOTES)';
-
- default:
- return $params[0];
- }
-}
-
-?>
\ No newline at end of file diff --git a/public_html/lib/Smarty/plugins/modifiercompiler.upper.php b/public_html/lib/Smarty/plugins/modifiercompiler.upper.php deleted file mode 100644 index f368e37..0000000 --- a/public_html/lib/Smarty/plugins/modifiercompiler.upper.php +++ /dev/null @@ -1,30 +0,0 @@ -<?php
-/**
- * Smarty plugin
- *
- * @package Smarty
- * @subpackage PluginsModifierCompiler
- */
-
-/**
- * Smarty upper modifier plugin
- *
- * Type: modifier<br>
- * Name: lower<br>
- * Purpose: convert string to uppercase
- *
- * @link http://smarty.php.net/manual/en/language.modifier.upper.php lower (Smarty online manual)
- * @author Uwe Tews
- * @param array $params parameters
- * @return string with compiled code
- */
-function smarty_modifiercompiler_upper($params, $compiler)
-{
- if (Smarty::$_MBSTRING) {
- return 'mb_strtoupper(' . $params[0] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')' ;
- }
- // no MBString fallback
- return 'strtoupper(' . $params[0] . ')';
-}
-
-?>
\ No newline at end of file diff --git a/public_html/lib/Smarty/plugins/modifiercompiler.wordwrap.php b/public_html/lib/Smarty/plugins/modifiercompiler.wordwrap.php deleted file mode 100644 index f6845ad..0000000 --- a/public_html/lib/Smarty/plugins/modifiercompiler.wordwrap.php +++ /dev/null @@ -1,46 +0,0 @@ -<?php
-/**
- * Smarty plugin
- *
- * @package Smarty
- * @subpackage PluginsModifierCompiler
- */
-
-/**
- * Smarty wordwrap modifier plugin
- *
- * Type: modifier<br>
- * Name: wordwrap<br>
- * Purpose: wrap a string of text at a given length
- *
- * @link http://smarty.php.net/manual/en/language.modifier.wordwrap.php wordwrap (Smarty online manual)
- * @author Uwe Tews
- * @param array $params parameters
- * @return string with compiled code
- */
-function smarty_modifiercompiler_wordwrap($params, $compiler)
-{
- if (!isset($params[1])) {
- $params[1] = 80;
- }
- if (!isset($params[2])) {
- $params[2] = '"\n"';
- }
- if (!isset($params[3])) {
- $params[3] = 'false';
- }
- $function = 'wordwrap';
- if (Smarty::$_MBSTRING) {
- if ($compiler->tag_nocache | $compiler->nocache) {
- $compiler->template->required_plugins['nocache']['wordwrap']['modifier']['file'] = SMARTY_PLUGINS_DIR .'shared.mb_wordwrap.php';
- $compiler->template->required_plugins['nocache']['wordwrap']['modifier']['function'] = 'smarty_mb_wordwrap';
- } else {
- $compiler->template->required_plugins['compiled']['wordwrap']['modifier']['file'] = SMARTY_PLUGINS_DIR .'shared.mb_wordwrap.php';
- $compiler->template->required_plugins['compiled']['wordwrap']['modifier']['function'] = 'smarty_mb_wordwrap';
- }
- $function = 'smarty_mb_wordwrap';
- }
- return $function . '(' . $params[0] . ',' . $params[1] . ',' . $params[2] . ',' . $params[3] . ')';
-}
-
-?>
\ No newline at end of file diff --git a/public_html/lib/Smarty/plugins/shared.escape_special_chars.php b/public_html/lib/Smarty/plugins/shared.escape_special_chars.php deleted file mode 100644 index d2609b6..0000000 --- a/public_html/lib/Smarty/plugins/shared.escape_special_chars.php +++ /dev/null @@ -1,51 +0,0 @@ -<?php -/** - * Smarty shared plugin - * - * @package Smarty - * @subpackage PluginsShared - */ - -if (version_compare(PHP_VERSION, '5.2.3', '>=')) { - /** - * escape_special_chars common function - * - * Function: smarty_function_escape_special_chars<br> - * Purpose: used by other smarty functions to escape - * special chars except for already escaped ones - * - * @author Monte Ohrt <monte at ohrt dot com> - * @param string $string text that should by escaped - * @return string - */ - function smarty_function_escape_special_chars($string) - { - if (!is_array($string)) { - $string = htmlspecialchars($string, ENT_COMPAT, Smarty::$_CHARSET, false); - } - return $string; - } -} else { - /** - * escape_special_chars common function - * - * Function: smarty_function_escape_special_chars<br> - * Purpose: used by other smarty functions to escape - * special chars except for already escaped ones - * - * @author Monte Ohrt <monte at ohrt dot com> - * @param string $string text that should by escaped - * @return string - */ - function smarty_function_escape_special_chars($string) - { - if (!is_array($string)) { - $string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string); - $string = htmlspecialchars($string); - $string = str_replace(array('%%%SMARTY_START%%%', '%%%SMARTY_END%%%'), array('&', ';'), $string); - } - return $string; - } -} - -?>
\ No newline at end of file diff --git a/public_html/lib/Smarty/plugins/shared.mb_wordwrap.php b/public_html/lib/Smarty/plugins/shared.mb_wordwrap.php deleted file mode 100644 index ba3498c..0000000 --- a/public_html/lib/Smarty/plugins/shared.mb_wordwrap.php +++ /dev/null @@ -1,83 +0,0 @@ -<?php -/** - * Smarty shared plugin - * - * @package Smarty - * @subpackage PluginsShared - */ - -if(!function_exists('smarty_mb_wordwrap')) { - - /** - * Wrap a string to a given number of characters - * - * @link http://php.net/manual/en/function.wordwrap.php for similarity - * @param string $str the string to wrap - * @param int $width the width of the output - * @param string $break the character used to break the line - * @param boolean $cut ignored parameter, just for the sake of - * @return string wrapped string - * @author Rodney Rehm - */ - function smarty_mb_wordwrap($str, $width=75, $break="\n", $cut=false) - { - // break words into tokens using white space as a delimiter - $tokens = preg_split('!(\s)!S' . Smarty::$_UTF8_MODIFIER, $str, -1, PREG_SPLIT_NO_EMPTY + PREG_SPLIT_DELIM_CAPTURE); - $length = 0; - $t = ''; - $_previous = false; - - foreach ($tokens as $_token) { - $token_length = mb_strlen($_token, Smarty::$_CHARSET); - $_tokens = array($_token); - if ($token_length > $width) { - // remove last space - $t = mb_substr($t, 0, -1, Smarty::$_CHARSET); - $_previous = false; - $length = 0; - - if ($cut) { - $_tokens = preg_split('!(.{' . $width . '})!S' . Smarty::$_UTF8_MODIFIER, $_token, -1, PREG_SPLIT_NO_EMPTY + PREG_SPLIT_DELIM_CAPTURE); - // broken words go on a new line - $t .= $break; - } - } - - foreach ($_tokens as $token) { - $_space = !!preg_match('!^\s$!S' . Smarty::$_UTF8_MODIFIER, $token); - $token_length = mb_strlen($token, Smarty::$_CHARSET); - $length += $token_length; - - if ($length > $width) { - // remove space before inserted break - if ($_previous && $token_length < $width) { - $t = mb_substr($t, 0, -1, Smarty::$_CHARSET); - } - - // add the break before the token - $t .= $break; - $length = $token_length; - - // skip space after inserting a break - if ($_space) { - $length = 0; - continue; - } - } else if ($token == "\n") { - // hard break must reset counters - $_previous = 0; - $length = 0; - } else { - // remember if we had a space or not - $_previous = $_space; - } - // add the token - $t .= $token; - } - } - - return $t; - } - -} -?>
\ No newline at end of file diff --git a/public_html/lib/Smarty/plugins/variablefilter.htmlspecialchars.php b/public_html/lib/Smarty/plugins/variablefilter.htmlspecialchars.php deleted file mode 100644 index aff711e..0000000 --- a/public_html/lib/Smarty/plugins/variablefilter.htmlspecialchars.php +++ /dev/null @@ -1,21 +0,0 @@ -<?php -/** - * Smarty plugin - * - * @package Smarty - * @subpackage PluginsFilter - */ - -/** - * Smarty htmlspecialchars variablefilter plugin - * - * @param string $source input string - * @param Smarty_Internal_Template $smarty Smarty object - * @return string filtered output - */ -function smarty_variablefilter_htmlspecialchars($source, $smarty) -{ - return htmlspecialchars($source, ENT_QUOTES, Smarty::$_CHARSET); -} - -?>
\ No newline at end of file |