auto-format all files; add table-definitions to test-bootstrap file
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -19,9 +19,9 @@
|
||||
*
|
||||
* @return array array of enabled redirect-codes
|
||||
*/
|
||||
function getRedirectCodesArray() {
|
||||
|
||||
$sql = "SELECT * FROM `".TABLE_PANEL_REDIRECTCODES."` WHERE `enabled` = '1' ORDER BY `id` ASC";
|
||||
function getRedirectCodesArray()
|
||||
{
|
||||
$sql = "SELECT * FROM `" . TABLE_PANEL_REDIRECTCODES . "` WHERE `enabled` = '1' ORDER BY `id` ASC";
|
||||
$result_stmt = Database::query($sql);
|
||||
|
||||
$codes = array();
|
||||
@@ -36,22 +36,23 @@ function getRedirectCodesArray() {
|
||||
* return an array of all enabled redirect-codes
|
||||
* for the settings form
|
||||
*
|
||||
* @param bool $add_desc optional, default true, add the code-description
|
||||
*
|
||||
* @param bool $add_desc
|
||||
* optional, default true, add the code-description
|
||||
*
|
||||
* @return array array of enabled redirect-codes
|
||||
*/
|
||||
function getRedirectCodes($add_desc = true) {
|
||||
|
||||
function getRedirectCodes($add_desc = true)
|
||||
{
|
||||
global $lng;
|
||||
|
||||
$sql = "SELECT * FROM `".TABLE_PANEL_REDIRECTCODES."` WHERE `enabled` = '1' ORDER BY `id` ASC";
|
||||
$sql = "SELECT * FROM `" . TABLE_PANEL_REDIRECTCODES . "` WHERE `enabled` = '1' ORDER BY `id` ASC";
|
||||
$result_stmt = Database::query($sql);
|
||||
|
||||
$codes = array();
|
||||
while ($rc = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||
$codes[$rc['id']] = $rc['code'];
|
||||
if ($add_desc) {
|
||||
$codes[$rc['id']] .= ' ('.$lng['redirect_desc'][$rc['desc']].')';
|
||||
$codes[$rc['id']] .= ' (' . $lng['redirect_desc'][$rc['desc']] . ')';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,11 +63,13 @@ function getRedirectCodes($add_desc = true) {
|
||||
* returns the redirect-code for a given
|
||||
* domain-id
|
||||
*
|
||||
* @param integer $domainid id of the domain
|
||||
*
|
||||
* @param integer $domainid
|
||||
* id of the domain
|
||||
*
|
||||
* @return string redirect-code
|
||||
*/
|
||||
function getDomainRedirectCode($domainid = 0) {
|
||||
function getDomainRedirectCode($domainid = 0)
|
||||
{
|
||||
|
||||
// get system default
|
||||
$default = '301';
|
||||
@@ -80,14 +83,14 @@ function getDomainRedirectCode($domainid = 0) {
|
||||
|
||||
$result_stmt = Database::prepare("
|
||||
SELECT `r`.`code` as `redirect`
|
||||
FROM `".TABLE_PANEL_REDIRECTCODES."` `r`, `".TABLE_PANEL_DOMAINREDIRECTS."` `rc`
|
||||
FROM `" . TABLE_PANEL_REDIRECTCODES . "` `r`, `" . TABLE_PANEL_DOMAINREDIRECTS . "` `rc`
|
||||
WHERE `r`.`id` = `rc`.`rid` and `rc`.`did` = :domainid
|
||||
");
|
||||
$result = Database::pexecute_first($result_stmt, array('domainid' => $domainid));
|
||||
$result = Database::pexecute_first($result_stmt, array(
|
||||
'domainid' => $domainid
|
||||
));
|
||||
|
||||
if (is_array($result)
|
||||
&& isset($result['redirect'])
|
||||
) {
|
||||
if (is_array($result) && isset($result['redirect'])) {
|
||||
$code = ($result['redirect'] == '---') ? $default : $result['redirect'];
|
||||
}
|
||||
}
|
||||
@@ -98,25 +101,26 @@ function getDomainRedirectCode($domainid = 0) {
|
||||
* returns the redirect-id for a given
|
||||
* domain-id
|
||||
*
|
||||
* @param integer $domainid id of the domain
|
||||
*
|
||||
* @param integer $domainid
|
||||
* id of the domain
|
||||
*
|
||||
* @return integer redirect-code-id
|
||||
*/
|
||||
function getDomainRedirectId($domainid = 0) {
|
||||
|
||||
function getDomainRedirectId($domainid = 0)
|
||||
{
|
||||
$code = 1;
|
||||
if ($domainid > 0) {
|
||||
$result_stmt = Database::prepare("
|
||||
SELECT `r`.`id` as `redirect`
|
||||
FROM `".TABLE_PANEL_REDIRECTCODES."` `r`, `".TABLE_PANEL_DOMAINREDIRECTS."` `rc`
|
||||
FROM `" . TABLE_PANEL_REDIRECTCODES . "` `r`, `" . TABLE_PANEL_DOMAINREDIRECTS . "` `rc`
|
||||
WHERE `r`.`id` = `rc`.`rid` and `rc`.`did` = :domainid
|
||||
");
|
||||
$result = Database::pexecute_first($result_stmt, array('domainid' => $domainid));
|
||||
$result = Database::pexecute_first($result_stmt, array(
|
||||
'domainid' => $domainid
|
||||
));
|
||||
|
||||
if (is_array($result)
|
||||
&& isset($result['redirect'])
|
||||
) {
|
||||
$code = (int)$result['redirect'];
|
||||
if (is_array($result) && isset($result['redirect'])) {
|
||||
$code = (int) $result['redirect'];
|
||||
}
|
||||
}
|
||||
return $code;
|
||||
@@ -125,17 +129,23 @@ function getDomainRedirectId($domainid = 0) {
|
||||
/**
|
||||
* adds a redirectcode for a domain
|
||||
*
|
||||
* @param integer $domainid id of the domain to add the code for
|
||||
* @param integer $redirect selected redirect-id
|
||||
*
|
||||
* @param integer $domainid
|
||||
* id of the domain to add the code for
|
||||
* @param integer $redirect
|
||||
* selected redirect-id
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
function addRedirectToDomain($domainid = 0, $redirect = 1) {
|
||||
function addRedirectToDomain($domainid = 0, $redirect = 1)
|
||||
{
|
||||
if ($domainid > 0) {
|
||||
$ins_stmt = Database::prepare("
|
||||
INSERT INTO `".TABLE_PANEL_DOMAINREDIRECTS."` SET `rid` = :rid, `did` = :did
|
||||
INSERT INTO `" . TABLE_PANEL_DOMAINREDIRECTS . "` SET `rid` = :rid, `did` = :did
|
||||
");
|
||||
Database::pexecute($ins_stmt, array('rid' => $redirect, 'did' => $domainid));
|
||||
Database::pexecute($ins_stmt, array(
|
||||
'rid' => $redirect,
|
||||
'did' => $domainid
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,26 +153,33 @@ function addRedirectToDomain($domainid = 0, $redirect = 1) {
|
||||
* updates the redirectcode of a domain
|
||||
* if redirect-code is false, nothing happens
|
||||
*
|
||||
* @param integer $domainid id of the domain to update
|
||||
* @param integer $redirect selected redirect-id or false
|
||||
*
|
||||
* @param integer $domainid
|
||||
* id of the domain to update
|
||||
* @param integer $redirect
|
||||
* selected redirect-id or false
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
function updateRedirectOfDomain($domainid = 0, $redirect = false) {
|
||||
|
||||
function updateRedirectOfDomain($domainid = 0, $redirect = false)
|
||||
{
|
||||
if ($redirect == false) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($domainid > 0) {
|
||||
$del_stmt = Database::prepare("
|
||||
DELETE FROM `".TABLE_PANEL_DOMAINREDIRECTS."` WHERE `did` = :domainid
|
||||
DELETE FROM `" . TABLE_PANEL_DOMAINREDIRECTS . "` WHERE `did` = :domainid
|
||||
");
|
||||
Database::pexecute($del_stmt, array('domainid' => $domainid));
|
||||
Database::pexecute($del_stmt, array(
|
||||
'domainid' => $domainid
|
||||
));
|
||||
|
||||
$ins_stmt = Database::prepare("
|
||||
INSERT INTO `".TABLE_PANEL_DOMAINREDIRECTS."` SET `rid` = :rid, `did` = :did
|
||||
INSERT INTO `" . TABLE_PANEL_DOMAINREDIRECTS . "` SET `rid` = :rid, `did` = :did
|
||||
");
|
||||
Database::pexecute($ins_stmt, array('rid' => $redirect, 'did' => $domainid));
|
||||
Database::pexecute($ins_stmt, array(
|
||||
'rid' => $redirect,
|
||||
'did' => $domainid
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,26 +20,31 @@
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
* @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) {
|
||||
|
||||
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";
|
||||
$hiddenparams .= '<input type="hidden" name="' . htmlspecialchars($field) . '" value="' . htmlspecialchars($value) . '" />' . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,20 +52,22 @@ function ask_yesno($text, $yesfile, $params = array(), $targetname = '', $back_n
|
||||
$text = $lng['question'][$text];
|
||||
}
|
||||
|
||||
$text = strtr($text, array('%s' => $targetname));
|
||||
$text = strtr($text, array(
|
||||
'%s' => $targetname
|
||||
));
|
||||
eval("echo \"" . getTemplate('misc/question_yesno', '1') . "\";");
|
||||
exit;
|
||||
exit();
|
||||
}
|
||||
|
||||
function ask_yesno_withcheckbox($text, $chk_text, $yesfile, $params = array(), $targetname = '', $show_checkbox = true) {
|
||||
|
||||
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";
|
||||
$hiddenparams .= '<input type="hidden" name="' . htmlspecialchars($field) . '" value="' . htmlspecialchars($value) . '" />' . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,10 +82,13 @@ function ask_yesno_withcheckbox($text, $chk_text, $yesfile, $params = array(), $
|
||||
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";;
|
||||
$checkbox = '<input type="hidden" name="delete_userfiles" value="0" />' . "\n";
|
||||
;
|
||||
}
|
||||
|
||||
$text = strtr($text, array('%s' => $targetname));
|
||||
$text = strtr($text, array(
|
||||
'%s' => $targetname
|
||||
));
|
||||
eval("echo \"" . getTemplate('misc/question_yesno_checkbox', '1') . "\";");
|
||||
exit;
|
||||
exit();
|
||||
}
|
||||
|
||||
@@ -19,48 +19,47 @@
|
||||
|
||||
/**
|
||||
* Build Navigation Sidebar
|
||||
* @param array navigation data
|
||||
* @param array userinfo the userinfo of the user
|
||||
* @return string the content of the navigation bar
|
||||
*
|
||||
* @param
|
||||
* array navigation data
|
||||
* @param
|
||||
* array userinfo the userinfo of the user
|
||||
* @return string the content of the navigation bar
|
||||
*
|
||||
* @author Florian Lippert <flo@syscp.org>
|
||||
*/
|
||||
|
||||
function buildNavigation($navigation, $userinfo) {
|
||||
function buildNavigation($navigation, $userinfo)
|
||||
{
|
||||
global $theme;
|
||||
|
||||
$returnvalue = '';
|
||||
|
||||
// sanitize user-given input (url-manipulation)
|
||||
if (isset($_GET['page']) && is_array($_GET['page'])) {
|
||||
$_GET['page'] = (string)$_GET['page'][0];
|
||||
$_GET['page'] = (string) $_GET['page'][0];
|
||||
}
|
||||
if (isset($_GET['action']) && is_array($_GET['action'])) {
|
||||
$_GET['action'] = (string)$_GET['action'][0];
|
||||
$_GET['action'] = (string) $_GET['action'][0];
|
||||
}
|
||||
|
||||
foreach($navigation as $box) {
|
||||
if ((!isset($box['show_element']) || $box['show_element'] === true) &&
|
||||
(!isset($box['required_resources']) || $box['required_resources'] == '' || (isset($userinfo[$box['required_resources']]) && ((int)$userinfo[$box['required_resources']] > 0 || $userinfo[$box['required_resources']] == '-1')))) {
|
||||
foreach ($navigation as $box) {
|
||||
if ((! isset($box['show_element']) || $box['show_element'] === true) && (! isset($box['required_resources']) || $box['required_resources'] == '' || (isset($userinfo[$box['required_resources']]) && ((int) $userinfo[$box['required_resources']] > 0 || $userinfo[$box['required_resources']] == '-1')))) {
|
||||
$navigation_links = '';
|
||||
foreach ($box['elements'] as $element_id => $element) {
|
||||
if ((!isset($element['show_element']) || $element['show_element'] === true) &&
|
||||
(!isset($element['required_resources']) || $element['required_resources'] == '' || (isset($userinfo[$element['required_resources']]) && ((int)$userinfo[$element['required_resources']] > 0 || $userinfo[$element['required_resources']] == '-1')))
|
||||
) {
|
||||
if ((! isset($element['show_element']) || $element['show_element'] === true) && (! isset($element['required_resources']) || $element['required_resources'] == '' || (isset($userinfo[$element['required_resources']]) && ((int) $userinfo[$element['required_resources']] > 0 || $userinfo[$element['required_resources']] == '-1')))) {
|
||||
$target = '';
|
||||
$active = '';
|
||||
$navurl = '#';
|
||||
if (isset($element['url']) && trim($element['url']) != '') {
|
||||
// append sid only to local
|
||||
|
||||
if (!preg_match('/^https?\:\/\//', $element['url'])
|
||||
&& (isset($userinfo['hash']) && $userinfo['hash'] != '')) {
|
||||
if (! preg_match('/^https?\:\/\//', $element['url']) && (isset($userinfo['hash']) && $userinfo['hash'] != '')) {
|
||||
// generate sid with ? oder &
|
||||
|
||||
if (strpos($element['url'], '?') !== false) {
|
||||
$element['url'].= '&s=' . $userinfo['hash'];
|
||||
$element['url'] .= '&s=' . $userinfo['hash'];
|
||||
} else {
|
||||
$element['url'].= '?s=' . $userinfo['hash'];
|
||||
$element['url'] .= '?s=' . $userinfo['hash'];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +69,7 @@ function buildNavigation($navigation, $userinfo) {
|
||||
|
||||
if (isset($_GET['page']) && substr_count($element['url'], "page=" . $_GET['page']) > 0 && substr_count($element['url'], basename($_SERVER["SCRIPT_FILENAME"])) > 0 && isset($_GET['action']) && substr_count($element['url'], "action=" . $_GET['action']) > 0) {
|
||||
$active = ' active';
|
||||
} elseif (isset($_GET['page']) && substr_count($element['url'], "page=" . $_GET['page']) > 0 && substr_count($element['url'], basename($_SERVER["SCRIPT_FILENAME"])) > 0 && substr_count($element['url'], "action=") == 0 && !isset($_GET['action'])) {
|
||||
} elseif (isset($_GET['page']) && substr_count($element['url'], "page=" . $_GET['page']) > 0 && substr_count($element['url'], basename($_SERVER["SCRIPT_FILENAME"])) > 0 && substr_count($element['url'], "action=") == 0 && ! isset($_GET['action'])) {
|
||||
$active = ' active';
|
||||
}
|
||||
|
||||
@@ -89,20 +88,20 @@ function buildNavigation($navigation, $userinfo) {
|
||||
if (isset($box['url']) && trim($box['url']) != '') {
|
||||
// append sid only to local
|
||||
|
||||
if (!preg_match('/^https?\:\/\//', $box['url']) && (isset($userinfo['hash']) && $userinfo['hash'] != '')) {
|
||||
if (! preg_match('/^https?\:\/\//', $box['url']) && (isset($userinfo['hash']) && $userinfo['hash'] != '')) {
|
||||
// generate sid with ? oder &
|
||||
|
||||
if (strpos($box['url'], '?') !== false) {
|
||||
$box['url'].= '&s=' . $userinfo['hash'];
|
||||
$box['url'] .= '&s=' . $userinfo['hash'];
|
||||
} else {
|
||||
$box['url'].= '?s=' . $userinfo['hash'];
|
||||
$box['url'] .= '?s=' . $userinfo['hash'];
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($box['new_window']) && $box['new_window'] == true) {
|
||||
$target = ' target="_blank"';
|
||||
}
|
||||
|
||||
|
||||
$navurl = htmlspecialchars($box['url']);
|
||||
$navlabel = $box['label'];
|
||||
} else {
|
||||
|
||||
@@ -20,25 +20,23 @@
|
||||
/**
|
||||
* Returns full style user details "Name, Firstname | Company"
|
||||
*
|
||||
* @param array An array with keys firstname, name and company
|
||||
* @param
|
||||
* array An array with keys firstname, name and company
|
||||
* @return string The full details
|
||||
*
|
||||
*
|
||||
* @author Florian Lippert <flo@syscp.org>
|
||||
*/
|
||||
|
||||
function getCorrectFullUserDetails($userinfo) {
|
||||
function getCorrectFullUserDetails($userinfo)
|
||||
{
|
||||
$returnval = '';
|
||||
|
||||
if (isset($userinfo['firstname']) && isset($userinfo['name']) && isset($userinfo['company'])) {
|
||||
if ($userinfo['company'] == '') {
|
||||
$returnval = $userinfo['name'] . ', ' . $userinfo['firstname'];
|
||||
}
|
||||
else {
|
||||
if ($userinfo['name'] != ''
|
||||
&& $userinfo['firstname'] != '') {
|
||||
} else {
|
||||
if ($userinfo['name'] != '' && $userinfo['firstname'] != '') {
|
||||
$returnval = $userinfo['name'] . ', ' . $userinfo['firstname'] . ' | ' . $userinfo['company'];
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$returnval = $userinfo['company'];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,26 +20,22 @@
|
||||
/**
|
||||
* Returns correct user salutation, either "Firstname Name" or "Company"
|
||||
*
|
||||
* @param array An array with keys firstname, name and company
|
||||
* @param
|
||||
* array An array with keys firstname, name and company
|
||||
* @return string The correct salutation
|
||||
*
|
||||
*
|
||||
* @author Florian Lippert <flo@syscp.org>
|
||||
*/
|
||||
|
||||
function getCorrectUserSalutation($userinfo)
|
||||
{
|
||||
$returnval = '';
|
||||
|
||||
if(isset($userinfo['firstname']) && isset($userinfo['name']) && isset($userinfo['company']))
|
||||
{
|
||||
|
||||
if (isset($userinfo['firstname']) && isset($userinfo['name']) && isset($userinfo['company'])) {
|
||||
// Always prefer firstname name
|
||||
|
||||
if($userinfo['company'] != '' && $userinfo['name'] == '' && $userinfo['firstname'] == '')
|
||||
{
|
||||
if ($userinfo['company'] != '' && $userinfo['name'] == '' && $userinfo['firstname'] == '') {
|
||||
$returnval = $userinfo['company'];
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$returnval = $userinfo['firstname'] . ' ' . $userinfo['name'];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,19 +20,20 @@
|
||||
/**
|
||||
* Get template from filesystem
|
||||
*
|
||||
* @param string Templatename
|
||||
* @param string noarea If area should be used to get template
|
||||
* @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) {
|
||||
|
||||
function getTemplate($template, $noarea = 0)
|
||||
{
|
||||
global $templatecache, $theme;
|
||||
|
||||
$fallback_theme = 'Sparkle';
|
||||
|
||||
if (!isset($theme) || $theme == '') {
|
||||
if (! isset($theme) || $theme == '') {
|
||||
$theme = $fallback_theme;
|
||||
}
|
||||
|
||||
@@ -40,7 +41,7 @@ function getTemplate($template, $noarea = 0) {
|
||||
$template = AREA . '/' . $template;
|
||||
}
|
||||
|
||||
if (!isset($templatecache[$theme][$template])) {
|
||||
if (! isset($templatecache[$theme][$template])) {
|
||||
|
||||
$filename = './templates/' . $theme . '/' . $template . '.tpl';
|
||||
|
||||
@@ -78,13 +79,11 @@ function getTemplate($template, $noarea = 0) {
|
||||
*
|
||||
* @return string|bool content on success, else false
|
||||
*/
|
||||
function _checkAndParseTpl($filename) {
|
||||
|
||||
function _checkAndParseTpl($filename)
|
||||
{
|
||||
$templatefile = "";
|
||||
|
||||
if (file_exists($filename)
|
||||
&& is_readable($filename)
|
||||
) {
|
||||
if (file_exists($filename) && is_readable($filename)) {
|
||||
|
||||
$templatefile = addcslashes(file_get_contents($filename), '"\\');
|
||||
|
||||
|
||||
@@ -20,48 +20,45 @@
|
||||
/**
|
||||
* 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
|
||||
* @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)
|
||||
{
|
||||
if ($selvalue !== NULL && $value == $selvalue) {
|
||||
$checked = 'checked="checked"';
|
||||
}
|
||||
else if(isset($_SESSION['requestData'][$name]))
|
||||
{
|
||||
} else if (isset($_SESSION['requestData'][$name])) {
|
||||
$checked = 'checked="checked"';
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$checked = '';
|
||||
}
|
||||
|
||||
if(!$title_trusted)
|
||||
{
|
||||
if (! $title_trusted) {
|
||||
$title = htmlspecialchars($title);
|
||||
}
|
||||
|
||||
if(!$value_trusted)
|
||||
{
|
||||
if (! $value_trusted) {
|
||||
$value = htmlspecialchars($value);
|
||||
}
|
||||
|
||||
$checkbox = '<label class="nobr"><input type="checkbox" name="' . $name . '" value="' . $value . '" ' . $checked . ' /> ' . $title . '</label>';
|
||||
|
||||
if($break)
|
||||
{
|
||||
$checkbox.= '<br />';
|
||||
if ($break) {
|
||||
$checkbox .= '<br />';
|
||||
}
|
||||
|
||||
return $checkbox;
|
||||
|
||||
@@ -20,43 +20,41 @@
|
||||
/**
|
||||
* 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
|
||||
* @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))
|
||||
{
|
||||
if ($selvalue !== NULL && ((is_array($selvalue) && in_array($value, $selvalue)) || $value == $selvalue)) {
|
||||
$selected = 'selected="selected"';
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$selected = '';
|
||||
}
|
||||
|
||||
|
||||
if ($disabled) {
|
||||
$selected .= ' disabled="disabled"';
|
||||
}
|
||||
|
||||
if(!$title_trusted)
|
||||
{
|
||||
if (! $title_trusted) {
|
||||
$title = htmlspecialchars($title);
|
||||
}
|
||||
|
||||
if(!$value_trusted)
|
||||
{
|
||||
if (! $value_trusted) {
|
||||
$value = htmlspecialchars($value);
|
||||
}
|
||||
|
||||
$id_str = ' ';
|
||||
if($id !== NULL) {
|
||||
if ($id !== NULL) {
|
||||
$id_str = 'id="' . $id . '"';
|
||||
}
|
||||
|
||||
|
||||
@@ -20,33 +20,34 @@
|
||||
/**
|
||||
* 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)
|
||||
* @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-)
|
||||
* @author Froxlor team <team@froxlor.org> (2010-)
|
||||
*/
|
||||
|
||||
function makeyesno($name, $yesvalue, $novalue = '', $yesselected = '', $disabled = false)
|
||||
{
|
||||
global $lng, $theme;
|
||||
|
||||
if($disabled) {
|
||||
|
||||
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>';
|
||||
|
||||
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>';
|
||||
}
|
||||
|
||||
@@ -20,24 +20,26 @@
|
||||
/**
|
||||
* 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>
|
||||
*
|
||||
* @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) {
|
||||
|
||||
function redirectTo($destination, $get_variables = null, $isRelative = true)
|
||||
{
|
||||
global $s;
|
||||
|
||||
if (is_array($get_variables)) {
|
||||
@@ -56,9 +58,7 @@ function redirectTo($destination, $get_variables = null, $isRelative = true) {
|
||||
$linker->hostname = '';
|
||||
$path = './';
|
||||
} else {
|
||||
if (isset($_SERVER['HTTPS'])
|
||||
&& strtolower($_SERVER['HTTPS']) == 'on'
|
||||
) {
|
||||
if (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') {
|
||||
$linker->protocol = 'https';
|
||||
} else {
|
||||
$linker->protocol = 'http';
|
||||
@@ -74,8 +74,7 @@ function redirectTo($destination, $get_variables = null, $isRelative = true) {
|
||||
$linker->filename = $path . $destination;
|
||||
}
|
||||
header('Location: ' . $linker->getLink());
|
||||
exit;
|
||||
|
||||
exit();
|
||||
} elseif ($get_variables == null) {
|
||||
if ($isRelative) {
|
||||
$linker = new linker($destination, $s);
|
||||
@@ -83,7 +82,7 @@ function redirectTo($destination, $get_variables = null, $isRelative = true) {
|
||||
$linker = new linker($destination);
|
||||
}
|
||||
header('Location: ' . $linker->getLink());
|
||||
exit;
|
||||
exit();
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -20,19 +20,21 @@
|
||||
/**
|
||||
* Prints one ore more errormessages on screen
|
||||
*
|
||||
* @param array Errormessages
|
||||
* @param string A %s in the errormessage will be replaced by this string.
|
||||
* @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) {
|
||||
|
||||
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)) {
|
||||
if (! is_array($errors)) {
|
||||
$errors = array(
|
||||
$errors
|
||||
);
|
||||
@@ -40,14 +42,16 @@ function standard_error($errors = '', $replacer = '', $throw_exception = false)
|
||||
|
||||
$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>';
|
||||
$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));
|
||||
$single_error = strtr($single_error, array(
|
||||
'%s' => $replacer
|
||||
));
|
||||
} else {
|
||||
$error = 'Unknown Error (' . $single_error . '): ' . $replacer;
|
||||
break;
|
||||
@@ -56,7 +60,7 @@ function standard_error($errors = '', $replacer = '', $throw_exception = false)
|
||||
if (empty($error)) {
|
||||
$error = $single_error;
|
||||
} else {
|
||||
$error.= ' ' . $single_error;
|
||||
$error .= ' ' . $single_error;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,17 +68,18 @@ function standard_error($errors = '', $replacer = '', $throw_exception = false)
|
||||
throw new Exception(strip_tags($error), 400);
|
||||
}
|
||||
eval("echo \"" . getTemplate('misc/error', '1') . "\";");
|
||||
exit;
|
||||
exit();
|
||||
}
|
||||
|
||||
function dynamic_error($message) {
|
||||
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>';
|
||||
$link = '<a href="' . htmlentities($_SERVER['HTTP_REFERER']) . '">' . $lng['panel']['back'] . '</a>';
|
||||
}
|
||||
$error = $message;
|
||||
eval("echo \"" . getTemplate('misc/error', '1') . "\";");
|
||||
exit;
|
||||
exit();
|
||||
}
|
||||
|
||||
@@ -29,21 +29,21 @@
|
||||
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 .= '&' . $varname . '=' . $value;
|
||||
@@ -52,7 +52,7 @@ function standard_success($success_message = '', $replacer = '', $params = array
|
||||
} else {
|
||||
$redirect_url = '';
|
||||
}
|
||||
|
||||
|
||||
eval("echo \"" . getTemplate('misc/success', '1') . "\";");
|
||||
exit();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user