diff --git a/lib/Froxlor/FroxlorLogger.php b/lib/Froxlor/FroxlorLogger.php
index b0e7ddfe..c65e7241 100644
--- a/lib/Froxlor/FroxlorLogger.php
+++ b/lib/Froxlor/FroxlorLogger.php
@@ -55,7 +55,7 @@ class FroxlorLogger
switch ($logger) {
case 'syslog':
- self::$_ml->pushHandler(new SyslogHandler('froxlor', Logger::DEBUG));
+ self::$_ml->pushHandler(new SyslogHandler('froxlor', LOG_USER, Logger::DEBUG));
break;
case 'file':
self::$_ml->pushHandler(new StreamHandler(Settings::Get('logger.logfile'), Logger::DEBUG));
diff --git a/lib/classes/output/class.htmlform.php b/lib/classes/output/class.htmlform.php
deleted file mode 100644
index dc13fdc0..00000000
--- a/lib/classes/output/class.htmlform.php
+++ /dev/null
@@ -1,350 +0,0 @@
- (2010-)
- * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
- * @package Classes
- *
- */
-class htmlform
-{
-
- /**
- * internal tmp-variable to store form
- *
- * @var string
- */
- private static $_form = '';
-
- private static $_filename = '';
-
- public static function genHTMLForm($data = array())
- {
- global $lng, $theme;
- $nob = false;
-
- self::$_form = '';
-
- foreach ($data as $fdata) {
- $sections = $fdata['sections'];
-
- foreach ($sections as $section) {
- /*
- * here be section title & image
- */
- $title = $section['title'];
- $image = $section['image'];
-
- if (isset($section['visible']) && $section['visible'] === false) {
- continue;
- }
-
- if (! isset($section['nobuttons']) || $section['nobuttons'] == false) {
- eval("self::\$_form .= \"" . getTemplate("misc/form/table_section", "1") . "\";");
- } else {
- $nob = true;
- }
-
- $nexto = false;
- foreach ($section['fields'] as $fieldname => $fielddata) {
- if (isset($fielddata['visible']) && $fielddata['visible'] === false) {
- continue;
- }
-
- if ($nexto === false || (isset($fielddata['next_to']) && $nexto['field'] != $fielddata['next_to'])) {
- $label = $fielddata['label'];
- $desc = (isset($fielddata['desc']) ? $fielddata['desc'] : '');
- $style = (isset($fielddata['style']) ? ' class="' . $fielddata['style'] . '"' : '');
- $mandatory = self::_getMandatoryFlag($fielddata);
- $data_field = self::_parseDataField($fieldname, $fielddata);
- if (isset($fielddata['has_nextto'])) {
- $nexto = array(
- 'field' => $fieldname
- );
- $data_field .= '{NEXTTOFIELD_' . $fieldname . '}';
- } else {
- $nexto = false;
- }
- eval("self::\$_form .= \"" . getTemplate("misc/form/table_row", "1") . "\";");
- } else {
- $data_field = self::_parseDataField($fieldname, $fielddata);
- $data_field = str_replace("\t", "", $data_field);
- $data_field = $fielddata['next_to_prefix'] . $data_field;
- self::$_form = str_replace('{NEXTTOFIELD_' . $fielddata['next_to'] . '}', $data_field, self::$_form);
- $nexto = false;
- }
- }
- }
- }
-
- // add save/reset buttons at the end of the form
- if (! $nob) {
- eval("self::\$_form .= \"" . getTemplate("misc/form/table_end", "1") . "\";");
- }
-
- return self::$_form;
- }
-
- private static function _parseDataField($fieldname, $data = array())
- {
- switch ($data['type']) {
- case 'text':
- return self::_textBox($fieldname, $data);
- break;
- case 'textul':
- return self::_textBox($fieldname, $data, 'text', true);
- break;
- case 'password':
- return self::_textBox($fieldname, $data, 'password');
- break;
- case 'hidden':
- return self::_textBox($fieldname, $data, 'hidden');
- break;
- case 'yesno':
- return self::_yesnoBox($data);
- break;
- case 'select':
- return self::_selectBox($fieldname, $data);
- break;
- case 'label':
- return self::_labelField($data);
- break;
- case 'textarea':
- return self::_textArea($fieldname, $data);
- break;
- case 'checkbox':
- return self::_checkbox($fieldname, $data);
- break;
- case 'file':
- return self::_file($fieldname, $data);
- break;
- case 'int':
- return self::_int($fieldname, $data);
- break;
- }
- }
-
- private static function _getMandatoryFlag($data = array())
- {
- if (isset($data['mandatory'])) {
- return ' *';
- } elseif (isset($data['mandatory_ex'])) {
- return ' **';
- }
- return '';
- }
-
- private static function _textBox($fieldname = '', $data = array(), $type = 'text', $unlimited = false)
- {
- $return = '';
- $extras = '';
- if (isset($data['maxlength'])) {
- $extras .= ' maxlength="' . $data['maxlength'] . '"';
- }
- if (isset($data['size'])) {
- $extras .= ' size="' . $data['size'] . '"';
- }
- if (isset($data['autocomplete'])) {
- $extras .= ' autocomplete="' . $data['autocomplete'] . '"';
- }
-
- // add support to save reloaded forms
- if (isset($data['value'])) {
- $value = $data['value'];
- } elseif (isset($_SESSION['requestData'][$fieldname])) {
- $value = $_SESSION['requestData'][$fieldname];
- } else {
- $value = '';
- }
-
- $ulfield = ($unlimited == true ? ' ' . $data['ul_field'] : '');
- if (isset($data['display']) && $data['display'] != '') {
- $ulfield = '' . $data['display'] . '';
- }
-
- eval("\$return = \"" . getTemplate("misc/form/input_text", "1") . "\";");
- return $return;
- }
-
- private static function _textArea($fieldname = '', $data = array())
- {
- $return = '';
- $extras = '';
- if (isset($data['cols'])) {
- $extras .= ' cols="' . $data['cols'] . '"';
- }
- if (isset($data['rows'])) {
- $extras .= ' rows="' . $data['rows'] . '"';
- }
-
- // add support to save reloaded forms
- if (isset($data['value'])) {
- $value = $data['value'];
- } elseif (isset($_SESSION['requestData'][$fieldname])) {
- $value = $_SESSION['requestData'][$fieldname];
- } else {
- $value = '';
- }
- trim($value);
-
- eval("\$return = \"" . getTemplate("misc/form/input_textarea", "1") . "\";");
- return $return;
- }
-
- private static function _yesnoBox($data = array())
- {
- return $data['yesno_var'];
- }
-
- private static function _labelField($data = array())
- {
- return $data['value'];
- }
-
- private static function _selectBox($fieldname = '', $data = array())
- {
- // add support to save reloaded forms
- if (isset($data['select_var'])) {
- $select_var = $data['select_var'];
- } elseif (isset($_SESSION['requestData'][$fieldname])) {
- $select_var = $_SESSION['requestData'][$fieldname];
- } else {
- $select_var = '';
- }
-
- return '';
- }
-
- /**
- * Function to generate checkboxes.
- *
- *
- * $data = array(
- * 'label' => $lng['customer']['email_imap'],
- * 'type' => 'checkbox',
- * 'values' => array(
- * array( 'label' => 'active',
- * 'value' => '1'
- * )
- * ),
- * 'value' => array('1'),
- * 'mandatory' => true
- * )
- *
- *
- * @param string $fieldname
- * contains the fieldname
- * @param array $data
- * contains the data array
- */
- public static function _checkbox($fieldname = '', $data = array())
- {
- // $data['value'] contains checked items
- $checked = array();
- if (isset($data['value'])) {
- $checked = $data['value'];
- }
-
- if (isset($_SESSION['requestData'])) {
- if (isset($_SESSION['requestData'][$fieldname])) {
- $checked = array(
- $_SESSION['requestData'][$fieldname]
- );
- }
- }
-
- // default value is none, so the checkbox isn't an array
- $isArray = '';
-
- if (count($data['values']) > 1 || (isset($data['is_array']) && $data['is_array'] == 1)) {
- $isArray = '[]';
- }
-
- // will contain the output
- $output = "";
- foreach ($data['values'] as $val) {
- $key = $val['label'];
- // is this box checked?
- $isChecked = '';
- if (is_array($checked) && count($checked) > 0) {
- foreach ($checked as $tmp) {
- if ($tmp == $val['value']) {
- $isChecked = ' checked="checked" ';
- break;
- }
- }
- }
- $output .= '';
- }
-
- return $output;
- }
-
- private static function _file($fieldname = '', $data = array())
- {
- $return = '';
- $extras = '';
- if (isset($data['maxlength'])) {
- $extras .= ' maxlength="' . $data['maxlength'] . '"';
- }
-
- // add support to save reloaded forms
- if (isset($data['value'])) {
- $value = $data['value'];
- } elseif (isset($_SESSION['requestData'][$fieldname])) {
- $value = $_SESSION['requestData'][$fieldname];
- } else {
- $value = '';
- }
-
- if (isset($data['display']) && $data['display'] != '') {
- $ulfield = '' . $data['display'] . '';
- }
-
- eval("\$return = \"" . getTemplate("misc/form/input_file", "1") . "\";");
- return $return;
- }
-
- private static function _int($fieldname = '', $data = array())
- {
- $return = '';
- $extras = '';
- if (isset($data['int_min'])) {
- $extras .= ' min="' . $data['int_min'] . '"';
- }
- if (isset($data['int_max'])) {
- $extras .= ' max="' . $data['int_max'] . '"';
- }
-
- // add support to save reloaded forms
- if (isset($data['value'])) {
- $value = $data['value'];
- } elseif (isset($_SESSION['requestData'][$fieldname])) {
- $value = $_SESSION['requestData'][$fieldname];
- } else {
- $value = '';
- }
-
- $type = 'number';
- $ulfield = '';
- eval("\$return = \"" . getTemplate("misc/form/input_text", "1") . "\";");
- return $return;
- }
-}
diff --git a/lib/classes/output/class.linker.php b/lib/classes/output/class.linker.php
deleted file mode 100644
index ef8e7d6e..00000000
--- a/lib/classes/output/class.linker.php
+++ /dev/null
@@ -1,172 +0,0 @@
- (2010-)
- * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
- * @package Panel
- *
- */
-class linker
-{
-
- private $protocol = '';
-
- private $username = '';
-
- private $password = '';
-
- private $hostname = '';
-
- private $port = 80;
-
- private $filename = 'index.php';
-
- private $args = array();
-
- public function __construct($file = 'index.php', $sessionid = '', $hostname = '', $protocol = '', $port = '', $username = '', $password = '')
- {
- // Set the basic parts of our URL
- $this->protocol = $protocol;
- $this->username = $username;
- $this->password = $password;
- $this->hostname = $hostname;
- $this->port = $port;
- $this->filename = $file;
- // @TODO: Remove this
- $this->args['s'] = $sessionid;
- }
-
- public function __set($key, $value)
- {
- switch (strtolower($key)) {
- case 'protocol':
- $this->protocol = $value;
- break;
- case 'username':
- $this->username = $value;
- break;
- case 'password':
- $this->password = $value;
- break;
- case 'hostname':
- $this->hostname = $value;
- break;
- case 'port':
- $this->port = $value;
- break;
- case 'filename':
- $this->filename = $value;
- break;
- default:
- return false;
- }
- return true;
- }
-
- public function add($key, $value)
- {
- // Add a new value to our parameters (overwrite = enabled)
- $this->args[$key] = $value;
- }
-
- public function del($key)
- {
- // If the key exists in our array -> delete it
- if (isset($this->args[$key])) {
- unset($this->args[$key]);
- }
- }
-
- public function delAll()
- {
- // Just resetting the array
- // Until the sessionid can be removed: save it
- // @TODO: Remove this
- $this->args = array(
- 's' => $this->args['s']
- );
- }
-
- public function getLink()
- {
- $link = '';
-
- // Build the basic URL
- if (strlen($this->protocol) > 0 && strlen($this->hostname) > 0) {
- $link = $this->protocol . '://';
- }
-
- // Let's see if we shall use a username in the URL
- // This is only available if a hostname is used as well
- if (strlen($this->username) > 0 && strlen($this->hostname) > 0) {
- $link .= urlencode($this->username);
-
- // Maybe we even have to append a password?
- if ($this->password != '') {
- $link .= ':' . urlencode($this->password);
- }
-
- // At least a username was given, add the @ to allow appending the hostname
- $link .= '@';
- }
-
- // Add hostname, port and filename to the URL
- if (strlen($this->hostname) > 0) {
- $link .= $this->hostname;
-
- // A port may only be used if hostname is used as well
- if (strlen($this->port) > 0) {
- $link .= ':' . $this->port;
- }
- }
-
- // Overwrite $this->args with parameters of this function (if necessary)
- if (func_num_args() == 1 && is_array(func_get_arg(0))) {
- $arguments = func_get_arg(0);
- $this->args = array_merge($this->args, $arguments);
- }
-
- // temporary until frontcontroller exists
- // We got a section in the URL -> morph AREA and section into filename
- // @TODO: Remove this
- if (isset($this->args['section']) && strlen($this->args['section']) > 0) {
- $link .= AREA . '_' . $this->args['section'] . '.php';
- unset($this->args['section']);
- } else {
- // filename has a prefixed slash
- $link .= $this->filename;
- }
-
- // Let's see if we are done (no arguments in query)
- if (count($this->args) == 0) {
- return $link;
- }
-
- // We have parameters, add them with a "?"
- $link .= "?";
-
- // Loop through arguments and add them to the link
- foreach ($this->args as $key => $value) {
- // For all but the first argument, prepend "&"
- if (substr($link, - 1) != "?") {
- $link .= "&";
- }
-
- // Encode parameters and add them to the link
- $link .= urlencode($key) . '=' . urlencode($value);
- }
-
- // Reset our class for further use
- $this->delAll();
- return $link;
- }
-}
diff --git a/lib/classes/output/class.paging.php b/lib/classes/output/class.paging.php
deleted file mode 100644
index 203ab3a5..00000000
--- a/lib/classes/output/class.paging.php
+++ /dev/null
@@ -1,519 +0,0 @@
- (2003-2009)
- * @author Froxlor team (2010-)
- * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
- * @package Classes
- *
- */
-
-/**
- * Class to manage paging system
- *
- * @package Functions
- */
-class paging
-{
-
- /**
- * Userinfo
- *
- * @var array
- */
- private $userinfo = array();
-
- /**
- * MySQL-Table
- *
- * @var string
- */
- private $table = '';
-
- /**
- * Fields with description which should be selectable
- *
- * @var array
- */
- private $fields = array();
-
- /**
- * Entries per page
- *
- * @var int
- */
- private $entriesperpage = 0;
-
- /**
- * Number of entries of table
- *
- * @var int
- */
- private $entries = 0;
-
- /**
- * Sortorder, asc or desc
- *
- * @var string
- */
- public $sortorder = 'asc';
-
- /**
- * Sortfield
- *
- * @var string
- */
- public $sortfield = '';
-
- /**
- * Searchfield
- *
- * @var string
- */
- private $searchfield = '';
-
- /**
- * Searchtext
- *
- * @var string
- */
- private $searchtext = '';
-
- /**
- * Pagenumber
- *
- * @var int
- */
- private $pageno = 0;
-
- /**
- * Switch natsorting on/off
- *
- * @var bool
- */
- private $natSorting = false;
-
- private $_limit = 0;
-
- /**
- * Class constructor.
- * Loads settings from request or from userdata and saves them to session.
- *
- * @param
- * array userinfo
- * @param
- * string Name of Table
- * @param
- * array Fields, in format array( 'fieldname_in_mysql' => 'field_caption' )
- * @param
- * int *deprecated* entries per page
- * @param
- * bool *deprecated* Switch natsorting on/off (global, affects all calls of sort)
- * @param int $default_field
- * default sorting-field-index
- * @param string $default_order
- * default sorting order 'asc' or 'desc'
- *
- */
- public function __construct($userinfo, $table, $fields, $entriesperpage = 0, $natSorting = false, $default_field = 0, $default_order = 'asc', $limit = 0)
- {
-
- // entries per page and natsorting-flag are not
- // passed as parameter anymore, because these are
- // from the settings anyway
- $entriesperpage = \Froxlor\Settings::Get('panel.paging');
- $natSorting = \Froxlor\Settings::Get('panel.natsorting');
-
- $this->userinfo = $userinfo;
-
- if (! is_array($this->userinfo['lastpaging'])) {
- $this->userinfo['lastpaging'] = json_decode($this->userinfo['lastpaging'], true);
- }
-
- $this->table = $table;
- $this->fields = $fields;
- $this->entriesperpage = $entriesperpage;
- $this->natSorting = $natSorting;
- $checklastpaging = (isset($this->userinfo['lastpaging']['table']) && $this->userinfo['lastpaging']['table'] == $this->table);
- $this->userinfo['lastpaging']['table'] = $this->table;
-
- if (isset($_REQUEST['sortorder']) && (strtolower($_REQUEST['sortorder']) == 'desc' || strtolower($_REQUEST['sortorder']) == 'asc')) {
- $this->sortorder = strtolower($_REQUEST['sortorder']);
- } else {
-
- if ($checklastpaging && isset($this->userinfo['lastpaging']['sortorder']) && (strtolower($this->userinfo['lastpaging']['sortorder']) == 'desc' || strtolower($this->userinfo['lastpaging']['sortorder']) == 'asc')) {
- $this->sortorder = strtolower($this->userinfo['lastpaging']['sortorder']);
- } else {
- $this->sortorder = $default_order;
- }
- }
-
- $this->userinfo['lastpaging']['sortorder'] = $this->sortorder;
-
- if (isset($_REQUEST['sortfield']) && isset($fields[$_REQUEST['sortfield']])) {
- $this->sortfield = $_REQUEST['sortfield'];
- } else {
- if ($checklastpaging && isset($this->userinfo['lastpaging']['sortfield']) && isset($fields[$this->userinfo['lastpaging']['sortfield']])) {
- $this->sortfield = $this->userinfo['lastpaging']['sortfield'];
- } else {
- $fieldnames = array_keys($fields);
- $this->sortfield = $fieldnames[$default_field];
- }
- }
-
- $this->userinfo['lastpaging']['sortfield'] = $this->sortfield;
-
- if (isset($_REQUEST['searchfield']) && isset($fields[$_REQUEST['searchfield']])) {
- $this->searchfield = $_REQUEST['searchfield'];
- } else {
- if ($checklastpaging && isset($this->userinfo['lastpaging']['searchfield']) && isset($fields[$this->userinfo['lastpaging']['searchfield']])) {
- $this->searchfield = $this->userinfo['lastpaging']['searchfield'];
- } else {
- $fieldnames = array_keys($fields);
- $this->searchfield = $fieldnames[0];
- }
- }
-
- $this->userinfo['lastpaging']['searchfield'] = $this->searchfield;
-
- if (isset($_REQUEST['searchtext']) && (preg_match('/[-_@\p{L}\p{N}*.]+$/u', $_REQUEST['searchtext']) || $_REQUEST['searchtext'] === '')) {
- $this->searchtext = trim($_REQUEST['searchtext']);
- } else {
- if ($checklastpaging && isset($this->userinfo['lastpaging']['searchtext']) && preg_match('/[-_@\p{L}\p{N}*.]+$/u', $this->userinfo['lastpaging']['searchtext'])) {
- $this->searchtext = $this->userinfo['lastpaging']['searchtext'];
- } else {
- $this->searchtext = '';
- }
- }
-
- $this->userinfo['lastpaging']['searchtext'] = $this->searchtext;
-
- if (isset($_REQUEST['pageno']) && intval($_REQUEST['pageno']) != 0) {
- $this->pageno = intval($_REQUEST['pageno']);
- } else {
- if ($checklastpaging && isset($this->userinfo['lastpaging']['pageno']) && intval($this->userinfo['lastpaging']['pageno']) != 0) {
- $this->pageno = intval($this->userinfo['lastpaging']['pageno']);
- } else {
- $this->pageno = 1;
- }
- }
-
- $this->userinfo['lastpaging']['pageno'] = $this->pageno;
- $upd_stmt = \Froxlor\Database\Database::prepare("
- UPDATE `" . TABLE_PANEL_SESSIONS . "` SET
- `lastpaging` = :lastpaging
- WHERE `hash` = :hash AND `userid` = :userid
- AND `ipaddress` = :ipaddr AND `useragent` = :ua
- AND `adminsession` = :adminsession
- ");
- $upd_data = array(
- 'lastpaging' => json_encode($this->userinfo['lastpaging']),
- 'hash' => $userinfo['hash'],
- 'userid' => $userinfo['userid'],
- 'ipaddr' => $userinfo['ipaddress'],
- 'ua' => $userinfo['useragent'],
- 'adminsession' => $userinfo['adminsession']
- );
- \Froxlor\Database\Database::pexecute($upd_stmt, $upd_data);
-
- $this->_limit = $limit;
- }
-
- /**
- * Sets number of entries and adjusts pageno if the number of entries doesn't correspond to the pageno.
- *
- * @param
- * int entries
- */
- public function setEntries($entries)
- {
- $this->entries = $entries;
-
- if (($this->pageno - 1) * $this->entriesperpage > $this->entries) {
- $this->pageno = 1;
- }
-
- return true;
- }
-
- /**
- * Checks if a row should be displayed or not, used in loops
- *
- * @param
- * int number of row
- * @return bool to display or not to display, that's the question
- */
- public function checkDisplay($count)
- {
- $begin = (intval($this->pageno) - 1) * intval($this->entriesperpage);
- $end = (intval($this->pageno) * intval($this->entriesperpage));
- return (($count >= $begin && $count < $end) || $this->entriesperpage == 0);
- }
-
- /**
- * Returns condition code for sql query
- *
- * @param
- * bool should returned condition code start with WHERE (false) or AND (true)?
- * @return string the condition code
- */
- public function getSqlWhere($append = false)
- {
- if ($this->searchtext != '') {
- if ($append == true) {
- $condition = ' AND ';
- } else {
- $condition = ' WHERE ';
- }
-
- $searchfield = explode('.', $this->searchfield);
- foreach ($searchfield as $id => $field) {
- if (substr($field, - 1, 1) != '`') {
- $field .= '`';
- }
-
- if ($field{0} != '`') {
- $field = '`' . $field;
- }
-
- $searchfield[$id] = $field;
- }
-
- $searchfield = implode('.', $searchfield);
-
- $ops = array(
- '<',
- '>',
- '='
- );
-
- // check if we use an operator or not
- $useOper = 0;
- $oper = "=";
- if (in_array(substr($this->searchtext, 0, 1), $ops)) {
- $useOper = 1;
- $oper = substr($this->searchtext, 0, 1);
- }
-
- // check for diskspace and whether searchtext is a number
- // in any other case the logical-operators would make no sense
- if (strpos($searchfield, 'diskspace') > 0 && is_numeric(substr($this->searchtext, $useOper))) {
- // anything with diskspace is *1024
- $searchtext = ((int) substr($this->searchtext, $useOper)) * 1024;
- $useOper = 1;
- } elseif (strpos($searchfield, 'traffic') > 0 && is_numeric(substr($this->searchtext, $useOper))) {
- // anything with traffic is *1024*1024
- $searchtext = ((int) substr($this->searchtext, $useOper)) * 1024 * 1024;
- $useOper = 1;
- } else {
- // any other field
- $searchtext = substr($this->searchtext, $useOper);
- }
-
- if ($useOper == 1 && is_numeric(substr($this->searchtext, $useOper))) {
- // now as we use >, < or = we use the given operator and not LIKE
- $condition .= $searchfield . " " . $oper . " " . \Froxlor\Database\Database::quote($searchtext);
- } else {
- $searchtext = str_replace('*', '%', $this->searchtext);
- // append wildcards if user did not enter any
- if (strpos($searchtext, '%') === false)
- $searchtext = '%' . $searchtext . '%';
- $condition .= $searchfield . " LIKE " . \Froxlor\Database\Database::quote($searchtext);
- }
- } else {
- $condition = '';
- }
-
- return $condition;
- }
-
- /**
- * Returns "order by"-code for sql query
- *
- * @param
- * bool Switch natsorting on/off (local, affects just this call)
- * @return string the "order by"-code
- */
- public function getSqlOrderBy($natSorting = null)
- {
- $sortfield = explode('.', $this->sortfield);
- foreach ($sortfield as $id => $field) {
- if (substr($field, - 1, 1) != '`') {
- $field .= '`';
- }
-
- if ($field{0} != '`') {
- $field = '`' . $field;
- }
-
- $sortfield[$id] = $field;
- }
-
- $sortfield = implode('.', $sortfield);
- $sortorder = strtoupper($this->sortorder);
-
- if ($natSorting == true || ($natSorting === null && $this->natSorting == true)) {
- // Acts similar to php's natsort(), found in one comment at http://my.opera.com/cpr/blog/show.dml/160556
- $sortcode = "ORDER BY CONCAT( IF( ASCII( LEFT( " . $sortfield . ", 5 ) ) > 57,
- LEFT( " . $sortfield . ", 1 ), 0 ),
- IF( ASCII( RIGHT( " . $sortfield . ", 1 ) ) > 57,
- LPAD( " . $sortfield . ", 255, '0' ),
- LPAD( CONCAT( " . $sortfield . ", '-' ), 255, '0' )
- )) " . $sortorder;
- } else {
- $sortcode = 'ORDER BY ' . $sortfield . ' ' . $sortorder;
- }
-
- return $sortcode;
- }
-
- /**
- * Currently not used
- *
- * @return string always empty
- */
- public function getSqlLimit()
- {
- if ($this->_limit > 0) {
- $_offset = ($this->pageno - 1) * $this->_limit;
- return ' LIMIT ' . $_offset . ',' . $this->_limit;
- }
- /**
- * currently not in use
- */
- return '';
- }
-
- /**
- * Returns html code for sorting field
- *
- * @param
- * array Language array
- * @return string the html sortcode
- */
- public function getHtmlSortCode($lng, $break = false)
- {
- $sortcode = '';
- $fieldoptions = '';
- $orderoptions = '';
-
- foreach ($this->fields as $fieldname => $fieldcaption) {
- $fieldoptions .= makeoption($fieldcaption, $fieldname, $this->sortfield, true, true);
- }
-
- $breakorws = ($break ? '
' : ' ');
- foreach (array(
- 'asc' => $lng['panel']['ascending'],
- 'desc' => $lng['panel']['descending']
- ) as $sortordertype => $sortorderdescription) {
- $orderoptions .= makeoption($sortorderdescription, $sortordertype, $this->sortorder, true, true);
- }
-
- eval("\$sortcode =\"" . getTemplate("misc/htmlsortcode", '1') . "\";");
- return $sortcode;
- }
-
- /**
- * Returns html code for sorting arrows
- *
- * @param
- * string URL to use as base for links
- * @param
- * string If set, only this field will be returned
- * @return mixed An array or a string (if field is set) of html code of arrows
- */
- public function getHtmlArrowCode($baseurl, $field = '')
- {
- global $theme;
-
- if ($field != '' && isset($this->fields[$field])) {
- $baseurl = htmlspecialchars($baseurl);
- $fieldname = htmlspecialchars($field);
- eval("\$arrowcode =\"" . getTemplate("misc/htmlarrowcode", '1') . "\";");
- } else {
- $baseurl = htmlspecialchars($baseurl);
- $arrowcode = array();
- foreach ($this->fields as $fieldname => $fieldcaption) {
- $fieldname = htmlspecialchars($fieldname);
- eval("\$arrowcode[\$fieldname] =\"" . getTemplate("misc/htmlarrowcode", '1') . "\";");
- }
- }
-
- return $arrowcode;
- }
-
- /**
- * Returns html code for searching field
- *
- * @param
- * array Language array
- * @return string the html searchcode
- */
- public function getHtmlSearchCode($lng)
- {
- $searchcode = '';
- $fieldoptions = '';
- $searchtext = htmlspecialchars($this->searchtext);
- foreach ($this->fields as $fieldname => $fieldcaption) {
- $fieldoptions .= makeoption($fieldcaption, $fieldname, $this->searchfield, true, true);
- }
- eval("\$searchcode =\"" . getTemplate("misc/htmlsearchcode", '1') . "\";");
- return $searchcode;
- }
-
- /**
- * Returns html code for paging
- *
- * @param
- * string URL to use as base for links
- * @return string the html pagingcode
- */
- public function getHtmlPagingCode($baseurl)
- {
- if ($this->entriesperpage == 0) {
- return '';
- } else {
- $pages = intval($this->entries / $this->entriesperpage);
- }
-
- if ($this->entries % $this->entriesperpage != 0) {
- $pages ++;
- }
-
- if ($pages > 1) {
-
- $start = $this->pageno - 4;
- if ($start < 1) {
- $start = 1;
- }
-
- $stop = $this->pageno + 4;
- if ($stop > $pages) {
- $stop = $pages;
- }
-
- $pagingcode = '« < ';
- for ($i = $start; $i <= $stop; $i ++) {
- if ($i != $this->pageno) {
- $pagingcode .= ' ' . $i . ' ';
- } else {
- $pagingcode .= ' ' . $i . ' ';
- }
- }
- $pagingcode .= ' > »';
- } else {
- $pagingcode = '';
- }
-
- return $pagingcode;
- }
-}
diff --git a/lib/cron_init.php b/lib/cron_init.php
index 54c5c436..29164c6b 100644
--- a/lib/cron_init.php
+++ b/lib/cron_init.php
@@ -23,8 +23,6 @@ if (@php_sapi_name() != 'cli' && @php_sapi_name() != 'cgi' && @php_sapi_name() !
die('This script will only work in the shell.');
}
-require __DIR__ . '/vendor/autoload.php';
-
// ensure that default timezone is set
if (function_exists("date_default_timezone_set") && function_exists("date_default_timezone_get")) {
@date_default_timezone_set(@date_default_timezone_get());
@@ -107,7 +105,7 @@ while ($fName = readdir($lockDirHandle)) {
if ($lastline == '=== Keep lockfile because of exception ===') {
fclose($debugHandler);
unlink($lockfile);
- dieWithMail('Last cron jailed out with an exception. Exiting...' . "\n" . 'Take a look into the contents of ' . $lockdir . $fName . '* for more information!' . "\n");
+ \Froxlor\System\Cronjob::dieWithMail('Last cron jailed out with an exception. Exiting...' . "\n" . 'Take a look into the contents of ' . $lockdir . $fName . '* for more information!' . "\n");
}
// Check if cron is running or has died.
@@ -133,7 +131,7 @@ while ($fName = readdir($lockDirHandle)) {
// ... and delete it
unlink($lockfile);
- dieWithMail('There is already a Cronjob for ' . $crontype . ' in progress. Exiting...' . "\n" . 'Take a look into the contents of ' . $lockdir . $lockFilename . '* for more information!' . "\n");
+ \Froxlor\System\Cronjob::dieWithMail('There is already a Cronjob for ' . $crontype . ' in progress. Exiting...' . "\n" . 'Take a look into the contents of ' . $lockdir . $lockFilename . '* for more information!' . "\n");
}
}
}
@@ -178,9 +176,9 @@ if (\Froxlor\Froxlor::hasUpdates() || \Froxlor\Froxlor::hasDbUpdates()) {
unlink($lockfile);
$errormessage = "Version of file doesn't match version of database. Exiting...\n\n";
$errormessage .= "Possible reason: Froxlor update\n";
- $errormessage .= "Information: Current version in database: " . \Froxlor\Settings::Get('panel.version') . "-" . \Froxlor\Froxlor::BRANDING . " (DB: " . \Froxlor\Settings::Get('panel.db_version') . ") - version of Froxlor files: " . \Froxlor\Froxlor::getVersionString() . ")\n";
+ $errormessage .= "Information: Current version in database: " . \Froxlor\Settings::Get('panel.version') . (! empty(\Froxlor\Froxlor::BRANDING) ? "-" . \Froxlor\Froxlor::BRANDING : "") . " (DB: " . \Froxlor\Settings::Get('panel.db_version') . ") - version of Froxlor files: " . \Froxlor\Froxlor::getVersionString() . ")\n";
$errormessage .= "Solution: Please visit your Foxlor admin interface for further information.\n";
- dieWithMail($errormessage);
+ \Froxlor\System\Cronjob::dieWithMail($errormessage);
}
if (\Froxlor\Settings::Get('system.cron_allowautoupdate') == 1) {
diff --git a/lib/functions/froxlor/function.getFilesystemQuota.php b/lib/functions/froxlor/function.getFilesystemQuota.php
deleted file mode 100644
index c1aab238..00000000
--- a/lib/functions/froxlor/function.getFilesystemQuota.php
+++ /dev/null
@@ -1,64 +0,0 @@
- (2011-)
- * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
- * @package Functions
- *
- */
-function getFilesystemQuota()
-{
-
- // enabled at all?
- if (Settings::Get('system.diskquota_enabled')) {
-
- // set linux defaults
- $repquota_params = "-np";
- // $quota_line_regex = "/^#([0-9]+)\s*[+-]{2}\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)/i";
- $quota_line_regex = "/^#([0-9]+)\s+[+-]{2}\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/i";
-
- // check for freebsd - which needs other values
- if (isFreeBSD()) {
- $repquota_params = "-nu";
- $quota_line_regex = "/^([0-9]+)\s+[+-]{2}\s+(\d+)\s+(\d+)\s+(\d+)\s+(\S+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\S+)/i";
- }
-
- // Fetch all quota in the desired partition
- exec(Settings::Get('system.diskquota_repquota_path') . " " . $repquota_params . " " . escapeshellarg(Settings::Get('system.diskquota_customer_partition')), $repquota);
-
- $usedquota = array();
- foreach ($repquota as $tmpquota) {
-
- // Let's see if the line matches a quota - line
- if (preg_match($quota_line_regex, $tmpquota, $matches)) {
-
- // It matches - put it into an array with userid as key (for easy lookup later)
- $usedquota[$matches[1]] = array(
- 'block' => array(
- 'used' => $matches[2],
- 'soft' => $matches[3],
- 'hard' => $matches[4],
- 'grace' => (isFreeBSD() ? '0' : $matches[5])
- ),
- 'file' => array(
- 'used' => $matches[6],
- 'soft' => $matches[7],
- 'hard' => $matches[8],
- 'grace' => (isFreeBSD() ? '0' : $matches[9])
- )
- );
- }
- }
-
- return $usedquota;
- }
- return false;
-}
diff --git a/lib/functions/froxlor/function.getThemes.php b/lib/functions/froxlor/function.getThemes.php
deleted file mode 100644
index bb945005..00000000
--- a/lib/functions/froxlor/function.getThemes.php
+++ /dev/null
@@ -1,54 +0,0 @@
- (2010-)
- * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
- * @package Functions
- *
- */
-
-/**
- * returns an array for the settings-array
- *
- * @return array
- */
-function getThemes()
-{
- $themespath = \Froxlor\FileDir::makeCorrectDir(\Froxlor\Froxlor::getInstallDir() . '/templates/');
- $themes_available = array();
-
- if (is_dir($themespath)) {
- $its = new DirectoryIterator($themespath);
-
- foreach ($its as $it) {
- if ($it->isDir() && $it->getFilename() != '.' && $it->getFilename() != '..' && $it->getFilename() != 'misc') {
- $theme = $themespath . $it->getFilename();
- if (file_exists($theme . '/config.json')) {
- $themeconfig = json_decode(file_get_contents($theme . '/config.json'), true);
- if (array_key_exists('variants', $themeconfig) && is_array($themeconfig['variants'])) {
- foreach ($themeconfig['variants'] as $variant => $data) {
- if ($variant == "default") {
- $themes_available[$it->getFilename()] = $it->getFilename();
- } elseif (array_key_exists('description', $data)) {
- $themes_available[$it->getFilename() . '_' . $variant] = $data['description'];
- } else {
- $themes_available[$it->getFilename() . '_' . $variant] = $it->getFilename() . ' (' . $variant . ')';
- }
- }
- } else {
- $themes_available[$it->getFilename()] = $it->getFilename();
- }
- }
- }
- }
- }
- return $themes_available;
-}
diff --git a/lib/functions/output/function.ask_yesno.php b/lib/functions/output/function.ask_yesno.php
deleted file mode 100644
index 4d6fff18..00000000
--- a/lib/functions/output/function.ask_yesno.php
+++ /dev/null
@@ -1,94 +0,0 @@
- (2003-2009)
- * @author Froxlor team (2010-)
- * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
- * @package Functions
- *
- */
-
-/**
- * Prints Question on screen
- *
- * @param string $text
- * The question
- * @param string $yesfile
- * File which will be called with POST if user clicks yes
- * @param array $params
- * Values which will be given to $yesfile. Format: array(variable1=>value1, variable2=>value2, variable3=>value3)
- * @param string $targetname
- * Name of the target eg Domain or eMail address etc.
- * @param int $back_nr
- * Number of steps to go back when "No" is pressed
- *
- * @author Florian Lippert
- * @author Froxlor team (2010-)
- *
- * @return string outputs parsed question_yesno template
- */
-function ask_yesno($text, $yesfile, $params = array(), $targetname = '', $back_nr = 1)
-{
- global $userinfo, $s, $header, $footer, $lng, $theme;
-
- $hiddenparams = '';
-
- if (is_array($params)) {
- foreach ($params as $field => $value) {
- $hiddenparams .= '' . "\n";
- }
- }
-
- if (isset($lng['question'][$text])) {
- $text = $lng['question'][$text];
- }
-
- $text = strtr($text, array(
- '%s' => $targetname
- ));
- eval("echo \"" . getTemplate('misc/question_yesno', '1') . "\";");
- exit();
-}
-
-function ask_yesno_withcheckbox($text, $chk_text, $yesfile, $params = array(), $targetname = '', $show_checkbox = true)
-{
- global $userinfo, $s, $header, $footer, $lng, $theme;
-
- $hiddenparams = '';
-
- if (is_array($params)) {
- foreach ($params as $field => $value) {
- $hiddenparams .= '' . "\n";
- }
- }
-
- if (isset($lng['question'][$text])) {
- $text = $lng['question'][$text];
- }
-
- if (isset($lng['question'][$chk_text])) {
- $chk_text = $lng['question'][$chk_text];
- }
-
- if ($show_checkbox) {
- $checkbox = makecheckbox('delete_userfiles', $chk_text, '1', false, '0', true, true);
- } else {
- $checkbox = '' . "\n";
- ;
- }
-
- $text = strtr($text, array(
- '%s' => $targetname
- ));
- eval("echo \"" . getTemplate('misc/question_yesno_checkbox', '1') . "\";");
- exit();
-}
diff --git a/lib/functions/output/function.getTemplate.php b/lib/functions/output/function.getTemplate.php
deleted file mode 100644
index a0404ca3..00000000
--- a/lib/functions/output/function.getTemplate.php
+++ /dev/null
@@ -1,99 +0,0 @@
- (2003-2009)
- * @author Froxlor team (2010-)
- * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
- * @package Functions
- *
- */
-
-/**
- * Get template from filesystem
- *
- * @param
- * string Templatename
- * @param
- * string noarea If area should be used to get template
- * @return string The Template
- * @author Florian Lippert
- */
-function getTemplate($template, $noarea = 0)
-{
- global $templatecache, $theme;
-
- $fallback_theme = 'Sparkle';
-
- if (! isset($theme) || $theme == '') {
- $theme = $fallback_theme;
- }
-
- if ($noarea != 1) {
- $template = AREA . '/' . $template;
- }
-
- if (! isset($templatecache[$theme][$template])) {
-
- $filename = './templates/' . $theme . '/' . $template . '.tpl';
-
- // check the current selected theme for the template
- $templatefile = _checkAndParseTpl($filename);
-
- if ($templatefile == false && $theme != $fallback_theme) {
- // check fallback
- $_filename = './templates/' . $fallback_theme . '/' . $template . '.tpl';
- $templatefile = _checkAndParseTpl($_filename);
-
- if ($templatefile == false) {
- // check for old layout
- $_filename = './templates/' . $template . '.tpl';
- $templatefile = _checkAndParseTpl($_filename);
-
- if ($templatefile == false) {
- // not found
- $templatefile = 'TEMPLATE NOT FOUND: ' . $filename;
- }
- }
- }
-
- $output = $templatefile;
- $templatecache[$theme][$template] = $output;
- }
-
- return $templatecache[$theme][$template];
-}
-
-/**
- * check whether a tpl file exists and if so, return it's content or else return false
- *
- * @param string $filename
- *
- * @return string|bool content on success, else false
- */
-function _checkAndParseTpl($filename)
-{
- $templatefile = "";
-
- if (file_exists($filename) && is_readable($filename)) {
-
- $templatefile = addcslashes(file_get_contents($filename), '"\\');
-
- // loop through template more than once in case we have an "if"-statement in another one
- while (preg_match('/(.*)(<\/if>|(.*)<\/if>)/Uis', $templatefile)) {
- $templatefile = preg_replace('/(.*)(<\/if>|(.*)<\/if>)/Uis', '".( ($1) ? ("$2") : ("$4") )."', $templatefile);
- $templatefile = str_replace('\\\\', '\\', $templatefile);
- }
-
- return $templatefile;
- }
- return false;
-}
diff --git a/lib/functions/output/function.makecheckbox.php b/lib/functions/output/function.makecheckbox.php
deleted file mode 100644
index 2e92a106..00000000
--- a/lib/functions/output/function.makecheckbox.php
+++ /dev/null
@@ -1,65 +0,0 @@
- (2003-2009)
- * @author Froxlor team (2010-)
- * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
- * @package Functions
- *
- */
-
-/**
- * Return HTML Code for a checkbox
- *
- * @param
- * string The fieldname
- * @param
- * string The captions
- * @param
- * string The Value which will be returned
- * @param
- * bool Add a
at the end of the checkbox
- * @param
- * string Values which will be selected by default
- * @param
- * bool Whether the title may contain html or not
- * @param
- * bool Whether the value may contain html or not
- * @return string HTML Code
- * @author Michael Kaufmann
- */
-function makecheckbox($name, $title, $value, $break = false, $selvalue = NULL, $title_trusted = false, $value_trusted = false)
-{
- if ($selvalue !== NULL && $value == $selvalue) {
- $checked = 'checked="checked"';
- } else if (isset($_SESSION['requestData'][$name])) {
- $checked = 'checked="checked"';
- } else {
- $checked = '';
- }
-
- if (! $title_trusted) {
- $title = htmlspecialchars($title);
- }
-
- if (! $value_trusted) {
- $value = htmlspecialchars($value);
- }
-
- $checkbox = '';
-
- if ($break) {
- $checkbox .= '
';
- }
-
- return $checkbox;
-}
diff --git a/lib/functions/output/function.makeoption.php b/lib/functions/output/function.makeoption.php
deleted file mode 100644
index 3e334446..00000000
--- a/lib/functions/output/function.makeoption.php
+++ /dev/null
@@ -1,63 +0,0 @@
- (2003-2009)
- * @author Froxlor team (2010-)
- * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
- * @package Functions
- *
- */
-
-/**
- * Return HTML Code for an option within a