remove refactored functions

Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann
2018-12-21 13:00:39 +01:00
parent 97b5439c0d
commit f9ad392e39
15 changed files with 5 additions and 1772 deletions

View File

@@ -1,64 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2011- the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Froxlor team <team@froxlor.org> (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;
}

View File

@@ -1,54 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Froxlor team <team@froxlor.org> (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;
}

View File

@@ -1,94 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (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 <flo@syscp.org>
* @author Froxlor team <team@froxlor.org> (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 .= '<input type="hidden" name="' . htmlspecialchars($field) . '" value="' . htmlspecialchars($value) . '" />' . "\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 .= '<input type="hidden" name="' . htmlspecialchars($field) . '" value="' . htmlspecialchars($value) . '" />' . "\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 = '<input type="hidden" name="delete_userfiles" value="0" />' . "\n";
;
}
$text = strtr($text, array(
'%s' => $targetname
));
eval("echo \"" . getTemplate('misc/question_yesno_checkbox', '1') . "\";");
exit();
}

View File

@@ -1,99 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (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 <flo@syscp.org>
*/
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[ \t]*(.*)>(.*)(<\/if>|<else>(.*)<\/if>)/Uis', $templatefile)) {
$templatefile = preg_replace('/<if[ \t]*(.*)>(.*)(<\/if>|<else>(.*)<\/if>)/Uis', '".( ($1) ? ("$2") : ("$4") )."', $templatefile);
$templatefile = str_replace('\\\\', '\\', $templatefile);
}
return $templatefile;
}
return false;
}

View File

@@ -1,65 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (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 <br /> 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 <mkaufmann@nutime.de>
*/
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 = '<label class="nobr"><input type="checkbox" name="' . $name . '" value="' . $value . '" ' . $checked . ' />&nbsp;' . $title . '</label>';
if ($break) {
$checkbox .= '<br />';
}
return $checkbox;
}

View File

@@ -1,63 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
*
*/
/**
* Return HTML Code for an option within a <select>
*
* @param
* string The caption
* @param
* string The Value which will be returned
* @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 Florian Lippert <flo@syscp.org>
*/
function makeoption($title, $value, $selvalue = NULL, $title_trusted = false, $value_trusted = false, $id = NULL, $disabled = false)
{
if ($selvalue !== NULL && ((is_array($selvalue) && in_array($value, $selvalue)) || $value == $selvalue)) {
$selected = 'selected="selected"';
} else {
$selected = '';
}
if ($disabled) {
$selected .= ' disabled="disabled"';
}
if (! $title_trusted) {
$title = htmlspecialchars($title);
}
if (! $value_trusted) {
$value = htmlspecialchars($value);
}
$id_str = ' ';
if ($id !== NULL) {
$id_str = 'id="' . $id . '"';
}
$option = '<option value="' . $value . '" ' . $id_str . $selected . ' >' . $title . '</option>';
return $option;
}

View File

@@ -1,53 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
*
*/
/**
* Returns HTML Code for two radio buttons with two choices: yes and no
*
* @param
* string Name of HTML-Variable
* @param
* string Value which will be returned if user chooses yes
* @param
* string Value which will be returned if user chooses no
* @param
* string Value which is chosen by default
* @param
* bool Whether this element is disabled or not (default: false)
* @return string HTML Code
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
*/
function makeyesno($name, $yesvalue, $novalue = '', $yesselected = '', $disabled = false)
{
global $lng, $theme;
if ($disabled) {
$d = ' disabled="disabled"';
} else {
$d = '';
}
if (isset($_SESSION['requestData'])) {
$yesselected = $yesselected & $_SESSION['requestData'][$name];
}
return '<select class="dropdown_noborder" id="' . $name . '" name="' . $name . '"' . $d . '>
<option value="' . $yesvalue . '"' . ($yesselected ? ' selected="selected"' : '') . '>' . $lng['panel']['yes'] . '</option><option value="' . $novalue . '"' . ($yesselected ? '' : ' selected="selected"') . '>' . $lng['panel']['no'] . '</option></select>';
}

View File

@@ -1,89 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
*
*/
/**
* Sends an header ( 'Location ...' ) to the browser.
*
* @param
* string Destination
* @param
* array Get-Variables
* @param
* boolean if the target we are creating for a redirect
* should be a relative or an absolute url
*
* @return boolean false if params is not an array
*
* @author Florian Lippert <flo@syscp.org>
* @author Martin Burchert <eremit@syscp.org>
*
* @changes martin@2005-01-29
* - added isRelative parameter
* - speed up the url generation
* - fixed bug #91
*/
function redirectTo($destination, $get_variables = null, $isRelative = true)
{
global $s;
if (is_array($get_variables)) {
if (isset($get_variables['s'])) {
$linker = new linker($destination, $get_variables['s']);
} else {
$linker = new linker($destination, $s);
}
foreach ($get_variables as $key => $value) {
$linker->add($key, $value);
}
if ($isRelative) {
$linker->protocol = '';
$linker->hostname = '';
$path = './';
} else {
if (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') {
$linker->protocol = 'https';
} else {
$linker->protocol = 'http';
}
$linker->hostname = $_SERVER['HTTP_HOST'];
if (dirname($_SERVER['PHP_SELF']) == '/') {
$path = '/';
} else {
$path = dirname($_SERVER['PHP_SELF']) . '/';
}
$linker->filename = $path . $destination;
}
header('Location: ' . $linker->getLink());
exit();
} elseif ($get_variables == null) {
if ($isRelative) {
$linker = new linker($destination, $s);
} else {
$linker = new linker($destination);
}
header('Location: ' . $linker->getLink());
exit();
}
return false;
}

View File

@@ -1,85 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
*
*/
/**
* Prints one ore more errormessages on screen
*
* @param
* array Errormessages
* @param
* string A %s in the errormessage will be replaced by this string.
* @author Florian Lippert <flo@syscp.org>
* @author Ron Brand <ron.brand@web.de>
*/
function standard_error($errors = '', $replacer = '', $throw_exception = false)
{
global $userinfo, $s, $header, $footer, $lng, $theme;
$_SESSION['requestData'] = $_POST;
$replacer = htmlentities($replacer);
if (! is_array($errors)) {
$errors = array(
$errors
);
}
$link = '';
if (isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST']) !== false) {
$link = '<a href="' . htmlentities($_SERVER['HTTP_REFERER']) . '">' . $lng['panel']['back'] . '</a>';
}
$error = '';
foreach ($errors as $single_error) {
if (isset($lng['error'][$single_error])) {
$single_error = $lng['error'][$single_error];
$single_error = strtr($single_error, array(
'%s' => $replacer
));
} else {
$error = 'Unknown Error (' . $single_error . '): ' . $replacer;
break;
}
if (empty($error)) {
$error = $single_error;
} else {
$error .= ' ' . $single_error;
}
}
if ($throw_exception) {
throw new Exception(strip_tags($error), 400);
}
eval("echo \"" . getTemplate('misc/error', '1') . "\";");
exit();
}
function dynamic_error($message)
{
global $userinfo, $s, $header, $footer, $lng, $theme;
$_SESSION['requestData'] = $_POST;
$link = '';
if (isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST']) !== false) {
$link = '<a href="' . htmlentities($_SERVER['HTTP_REFERER']) . '">' . $lng['panel']['back'] . '</a>';
}
$error = $message;
eval("echo \"" . getTemplate('misc/error', '1') . "\";");
exit();
}

View File

@@ -1,58 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
*
*/
/**
* Prints one ore more errormessages on screen
*
* @param
* array Errormessages
* @param
* string A %s in the errormessage will be replaced by this string.
* @author Florian Lippert <flo@syscp.org>
*/
function standard_success($success_message = '', $replacer = '', $params = array(), $throw_exception = false)
{
global $s, $header, $footer, $lng, $theme;
if (isset($lng['success'][$success_message])) {
$success_message = strtr($lng['success'][$success_message], array(
'%s' => htmlentities($replacer)
));
}
if ($throw_exception) {
throw new Exception(strip_tags($success_message), 200);
}
if (is_array($params) && isset($params['filename'])) {
$redirect_url = $params['filename'] . '?s=' . $s;
unset($params['filename']);
foreach ($params as $varname => $value) {
if ($value != '') {
$redirect_url .= '&amp;' . $varname . '=' . $value;
}
}
} else {
$redirect_url = '';
}
eval("echo \"" . getTemplate('misc/success', '1') . "\";");
exit();
}