get rid of more functions

Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann
2018-12-20 12:38:18 +01:00
parent f263175802
commit 5888927239
53 changed files with 639 additions and 858 deletions

View File

@@ -1,44 +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
*
*/
/**
* Function customerHasPerlEnabled
*
* returns true or false whether perl is
* enabled for the given customer
*
* @param int customer-id
*
* @return boolean
*/
function customerHasPerlEnabled($cid = 0) {
if ($cid > 0) {
$result_stmt = Database::prepare("
SELECT `perlenabled` FROM `".TABLE_PANEL_CUSTOMERS."` WHERE `customerid` = :cid"
);
Database::pexecute($result_stmt, array('cid' => $cid));
$result = $result_stmt->fetch(PDO::FETCH_ASSOC);
if (is_array($result)
&& isset($result['perlenabled'])
) {
return ($result['perlenabled'] == '1') ? true : false;
}
}
return false;
}

View File

@@ -1,64 +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
*
*/
/**
* check whether a domain has subdomains added as full-domains
* #329
*
* @param int $id domain-id
*
* @return boolean
*/
function domainHasMainSubDomains($id = 0) {
$result_stmt = Database::prepare("
SELECT COUNT(`id`) as `mainsubs` FROM `".TABLE_PANEL_DOMAINS."`
WHERE `ismainbutsubto` = :id"
);
$result = Database::pexecute_first($result_stmt, array('id' => $id));
if (isset($result['mainsubs'])
&& $result['mainsubs'] > 0
) {
return true;
}
return false;
}
/**
* check whether a subof-domain exists
* #329
*
* @param int $id subof-domain-id
*
* @return boolean
*/
function domainMainToSubExists($id = 0) {
$result_stmt = Database::prepare("
SELECT `id` FROM `".TABLE_PANEL_DOMAINS."` WHERE `id` = :id"
);
Database::pexecute($result_stmt, array('id' => $id));
$result = $result_stmt->fetch(PDO::FETCH_ASSOC);
if (isset($result['id'])
&& $result['id'] > 0
) {
return true;
}
return false;
}

View File

@@ -1,43 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2013 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 Michael Kaufmann <mkaufmann@nutime.de>
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Cron
*
* @since 0.9.29.1-dev1
*
*/
/**
* Check whether a given domain has an ssl-ip/port assigned
*
* @param int $domainid
*
* @return boolean
*/
function domainHasSslIpPort($domainid = 0) {
$result_stmt = Database::prepare("
SELECT `dt`.* FROM `".TABLE_DOMAINTOIP."` `dt`, `".TABLE_PANEL_IPSANDPORTS."` `iap`
WHERE `dt`.`id_ipandports` = `iap`.`id` AND `iap`.`ssl` = '1' AND `dt`.`id_domain` = :domainid;"
);
Database::pexecute($result_stmt, array('domainid' => $domainid));
$result = $result_stmt->fetch(PDO::FETCH_ASSOC);
if (is_array($result)
&& isset($result['id_ipandports'])
) {
return true;
}
return false;
}

View File

@@ -1,32 +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
*
*/
function getCustomerDetail($customerid, $varname) {
$customer_stmt = Database::prepare("
SELECT `" . $varname . "` FROM `" . TABLE_PANEL_CUSTOMERS . "` WHERE `customerid` = :customerid
");
$customer = Database::pexecute_first($customer_stmt, array('customerid' => $customerid));
if (isset($customer[$varname])) {
return $customer[$varname];
} else {
return false;
}
}

View File

@@ -1,41 +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
*
*/
function getIpAddresses() {
$result_stmt = Database::query("
SELECT `id`, `ip`, `port` FROM `" . TABLE_PANEL_IPSANDPORTS . "` ORDER BY `ip` ASC, `port` ASC
");
$system_ipaddress_array = array();
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
if (!isset($system_ipaddress_array[$row['ip']])
&& !in_array($row['ip'], $system_ipaddress_array)
) {
if (filter_var($row['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
$row['ip'] = '[' . $row['ip'] . ']';
}
$system_ipaddress_array[$row['ip']] = $row['ip'];
}
}
return $system_ipaddress_array;
}

View File

@@ -1,68 +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
*
*/
function getIpPortCombinations($ssl = false) {
global $userinfo;
$additional_conditions_params = array();
$additional_conditions_array = array();
if ($userinfo['ip'] != '-1') {
$admin_ip_stmt = Database::prepare("
SELECT `id`, `ip`, `port` FROM `" . TABLE_PANEL_IPSANDPORTS . "` WHERE `id` = IN (:ipid)
");
$myips = implode(",", json_decode($userinfo['ip'], true));
Database::pexecute($admin_ip_stmt, array('ipid' => $myips));
$additional_conditions_array[] = "`ip` IN (:adminips)";
$additional_conditions_params['adminips'] = $myips;
}
if ($ssl !== null) {
$additional_conditions_array[] = "`ssl` = :ssl";
$additional_conditions_params['ssl'] = ($ssl === true ? '1' : '0' );
}
$additional_conditions = '';
if (count($additional_conditions_array) > 0) {
$additional_conditions = " WHERE " . implode(" AND ", $additional_conditions_array) . " ";
}
$result_stmt = Database::prepare("
SELECT `id`, `ip`, `port` FROM `" . TABLE_PANEL_IPSANDPORTS . "` " .
$additional_conditions . " ORDER BY `ip` ASC, `port` ASC
");
Database::pexecute($result_stmt, $additional_conditions_params);
$system_ipaddress_array = array();
while($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
if (filter_var($row['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
$row['ip'] = '[' . $row['ip'] . ']';
}
$system_ipaddress_array[$row['id']] = $row['ip'] . ':' . $row['port'];
}
return $system_ipaddress_array;
}
function getSslIpPortCombinations() {
global $lng;
return array('' => $lng['panel']['none_value']) + getIpPortCombinations(true);
}

View File

@@ -1,23 +0,0 @@
<?php
/**
* returns the loginname of a customer by given uid
*
* @param int $uid uid of customer
*
* @return string customers loginname
*/
function getLoginNameByUid($uid = null) {
$result_stmt = Database::prepare("
SELECT `loginname` FROM `" . TABLE_PANEL_CUSTOMERS . "` WHERE `guid` = :guid
");
$result = Database::pexecute_first($result_stmt, array('guid' => $uid));
if (is_array($result)
&& isset($result['loginname'])
) {
return $result['loginname'];
}
return false;
}

View File

@@ -1,117 +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
*
*/
/**
* Inserts a task into the PANEL_TASKS-Table
*
* @param
* int Type of task
* @param
* string Parameter 1
* @param
* string Parameter 2
* @param
* string Parameter 3
* @author Florian Lippert <flo@syscp.org>
* @author Froxlor team <team@froxlor.org>
*/
function inserttask($type, $param1 = '', $param2 = '', $param3 = '', $param4 = '')
{
// prepare the insert-statement
$ins_stmt = Database::prepare("
INSERT INTO `" . TABLE_PANEL_TASKS . "` SET `type` = :type, `data` = :data
");
if ($type == '1' || $type == '3' || $type == '4' || $type == '5' || $type == '10' || $type == '99') {
// 4 = bind -> if bind disabled -> no task
if ($type == '4' && Settings::Get('system.bind_enable') == '0') {
return;
}
// 10 = quota -> if quota disabled -> no task
if ($type == '10' && Settings::Get('system.diskquota_enabled') == '0') {
return;
}
// delete previously inserted tasks if they are the same as we only need ONE
$del_stmt = Database::prepare("
DELETE FROM `" . TABLE_PANEL_TASKS . "` WHERE `type` = :type
");
Database::pexecute($del_stmt, array(
'type' => $type
));
// insert the new task
Database::pexecute($ins_stmt, array(
'type' => $type,
'data' => ''
));
} elseif ($type == '2' && $param1 != '' && $param2 != '' && $param3 != '' && ($param4 == 0 || $param4 == 1)) {
$data = array();
$data['loginname'] = $param1;
$data['uid'] = $param2;
$data['gid'] = $param3;
$data['store_defaultindex'] = $param4;
$data = json_encode($data);
Database::pexecute($ins_stmt, array(
'type' => '2',
'data' => $data
));
} elseif ($type == '6' && $param1 != '') {
$data = array();
$data['loginname'] = $param1;
$data = json_encode($data);
Database::pexecute($ins_stmt, array(
'type' => '6',
'data' => $data
));
} elseif ($type == '7' && $param1 != '' && $param2 != '') {
$data = array();
$data['loginname'] = $param1;
$data['email'] = $param2;
$data = json_encode($data);
Database::pexecute($ins_stmt, array(
'type' => '7',
'data' => $data
));
} elseif ($type == '8' && $param1 != '' && $param2 != '') {
$data = array();
$data['loginname'] = $param1;
$data['homedir'] = $param2;
$data = json_encode($data);
Database::pexecute($ins_stmt, array(
'type' => '8',
'data' => $data
));
} elseif ($type == '11' && $param1 != '') {
$data = array();
$data['domain'] = $param1;
$data = json_encode($data);
Database::pexecute($ins_stmt, array(
'type' => '11',
'data' => $data
));
} elseif ($type == '20' && is_array($param1)) {
$data = json_encode($param1);
Database::pexecute($ins_stmt, array(
'type' => '20',
'data' => $data
));
}
}

View File

@@ -1,43 +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 true or false whether a given domain id
* is the std-subdomain of a customer
*
* @param int domain-id
*
* @return boolean
*/
function isCustomerStdSubdomain($did = 0) {
if ($did > 0) {
$result_stmt = Database::prepare("
SELECT `customerid` FROM `".TABLE_PANEL_CUSTOMERS."`
WHERE `standardsubdomain` = :did
");
$result = Database::pexecute_first($result_stmt, array('did' => $did));
if (is_array($result)
&& isset($result['customerid'])
&& $result['customerid'] > 0
) {
return true;
}
}
return false;
}

View File

@@ -1,34 +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 Daniel Reichelt <hacking@nachtgeist.net> (2016-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
*
*/
function triggerLetsEncryptCSRForAliasDestinationDomain($aliasDestinationDomainID, $log)
{
if (isset($aliasDestinationDomainID) && $aliasDestinationDomainID > 0) {
$log->logAction(ADM_ACTION, LOG_INFO, "LetsEncrypt CSR triggered for domain ID " . $aliasDestinationDomainID);
$upd_stmt = Database::prepare(
"UPDATE
`" . TABLE_PANEL_DOMAIN_SSL_SETTINGS . "`
SET
`expirationdate` = null
WHERE
domainid = :domainid
");
Database::pexecute($upd_stmt, array(
'domainid' => $aliasDestinationDomainID
));
}
}