enhance phpdoc and add @access to specify which usergroup can use the ApiCommands; add --import-settings parameter to config-services.php CLI script to gain even more automatism when setting up

Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann (d00p)
2018-02-24 10:57:52 +01:00
parent 81d6a856d9
commit 9a61a56732
9 changed files with 217 additions and 62 deletions

View File

@@ -1,7 +1,7 @@
<?php <?php
if (! defined('AREA')) { if (! defined('AREA')) {
header("Location: index.php"); header("Location: index.php");
exit; exit();
} }
/** /**
@@ -17,12 +17,12 @@ if (! defined('AREA')) {
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Panel * @package Panel
* @since 0.10.0 * @since 0.10.0
* *
*/ */
// This file is being included in admin_index and customer_index // This file is being included in admin_index and customer_index
// and therefore does not need to require lib/init.php // and therefore does not need to require lib/init.php
try { try {
$json_result = Froxlor::getLocal($userinfo)->listFunctions(); $json_result = Froxlor::getLocal($userinfo)->listFunctions();
} catch (Exception $e) { } catch (Exception $e) {
@@ -48,7 +48,8 @@ foreach ($m_arr as $module) {
$output_arr[$module['module']][$module['function']] = array( $output_arr[$module['module']][$module['function']] = array(
'return_type' => (isset($module['return']['type']) && $module['return']['type'] != "" ? $module['return']['type'] : - 1), 'return_type' => (isset($module['return']['type']) && $module['return']['type'] != "" ? $module['return']['type'] : - 1),
'params_list' => array(), 'params_list' => array(),
'head' => $module['head'] 'head' => $module['head'],
'access' => isset($module['access']) ? $module['access'] : null
); );
if (isset($module['params']) && is_array($module['params'])) { if (isset($module['params']) && is_array($module['params'])) {
@@ -73,12 +74,12 @@ foreach ($output_arr as $module => $functions) {
// sort by function // sort by function
ksort($functions); ksort($functions);
$apihelp .= "<h2>".$module."</h2><hr /><br>"; $apihelp .= "<h2>" . $module . "</h2><hr /><br>";
// output ALL the functions // output ALL the functions
foreach ($functions as $function => $funcdata) { foreach ($functions as $function => $funcdata) {
$apihelp .= "<div class=\"well\">"; $apihelp .= "<div class=\"well\">";
$apihelp .= "<h3>".$module." - "; $apihelp .= "<h3>" . $module . " - ";
// description // description
if (strtoupper(substr($funcdata['head'], 0, 5)) == "@TODO") { if (strtoupper(substr($funcdata['head'], 0, 5)) == "@TODO") {
$apihelp .= "<span class=\"red\">"; $apihelp .= "<span class=\"red\">";
@@ -88,8 +89,12 @@ foreach ($output_arr as $module => $functions) {
$apihelp .= "</span>"; $apihelp .= "</span>";
} }
$apihelp .= "</h3>"; $apihelp .= "</h3>";
$apihelp .= "<b>Command"."</b>&nbsp;"; $apihelp .= "<b>Command" . "</b>&nbsp;";
$apihelp .= "<span class=\"label\">".$module.".".$function."</span><br>"; $apihelp .= "<span class=\"label\">" . $module . "." . $function . "</span><br>";
if (isset($funcdata['access']['groups']) && ! empty($funcdata['access']['groups'])) {
$apihelp .= "<br><b>Access:</b>&nbsp;";
$apihelp .= $funcdata['access']['groups'] . "<br>";
}
// output ALL the params; // output ALL the params;
if (count($funcdata['params_list']) > 0) { if (count($funcdata['params_list']) > 0) {
@@ -102,15 +107,15 @@ foreach ($output_arr as $module => $functions) {
$parms .= "<tr><td><pre>"; $parms .= "<tr><td><pre>";
// check whether the parameter is optional // check whether the parameter is optional
if (! empty($param['desc']) && strtolower(substr(trim($param['desc']), 0, 8)) == "optional") { if (! empty($param['desc']) && strtolower(substr(trim($param['desc']), 0, 8)) == "optional") {
$parms .= "<i>".$param['name']."</i>"; $parms .= "<i>" . $param['name'] . "</i>";
$param['desc'] = substr(trim($param['desc']), 8); $param['desc'] = substr(trim($param['desc']), 8);
if (substr($param['desc'], 0, 1) == ',') { if (substr($param['desc'], 0, 1) == ',') {
$param['desc'] = substr(trim($param['desc']), 1); $param['desc'] = substr(trim($param['desc']), 1);
} }
} else { } else {
$parms .= "<b>".$param['name']."</b>"; $parms .= "<b>" . $param['name'] . "</b>";
} }
$parms .= "</pre></td><td>" . (strtolower($param['type']) == 'unknown' ? "<span class=\"red\">unknown</span>" : $param['type'])."</td>"; $parms .= "</pre></td><td>" . (strtolower($param['type']) == 'unknown' ? "<span class=\"red\">unknown</span>" : $param['type']) . "</td>";
$parms .= "<td>"; $parms .= "<td>";
if (! empty($param['desc'])) { if (! empty($param['desc'])) {
$parms .= trim($param['desc']); $parms .= trim($param['desc']);

View File

@@ -43,6 +43,7 @@ class ConfigServicesCmd extends CmdLineHandler
public static $params = array( public static $params = array(
'create', 'create',
'apply', 'apply',
'import-settings',
'daemon', 'daemon',
'list-daemons', 'list-daemons',
'froxlor-dir', 'froxlor-dir',
@@ -68,6 +69,10 @@ class ConfigServicesCmd extends CmdLineHandler
self::println("--daemon\t\tWhen running --apply you can specify a daemon. This will be the only service that gets configured"); self::println("--daemon\t\tWhen running --apply you can specify a daemon. This will be the only service that gets configured");
self::println("\t\t\tExample: --apply=/path/to/my-config.json --daemon=apache24"); self::println("\t\t\tExample: --apply=/path/to/my-config.json --daemon=apache24");
self::println(""); self::println("");
self::println("");
self::println("--import-settings\tImport settings from another froxlor installation. This should be done prior to running --apply or alternatively in the same command together.");
self::println("\t\t\tExample: --import-settings=/path/to/Froxlor_settings-[version]-[dbversion]-[date].json");
self::println("");
self::println("--froxlor-dir\t\tpath to froxlor installation"); self::println("--froxlor-dir\t\tpath to froxlor installation");
self::println("\t\t\tExample: --froxlor-dir=/var/www/froxlor/"); self::println("\t\t\tExample: --froxlor-dir=/var/www/froxlor/");
self::println(""); self::println("");
@@ -115,10 +120,15 @@ class Action
require FROXLOR_INSTALL_DIR . '/lib/tables.inc.php'; require FROXLOR_INSTALL_DIR . '/lib/tables.inc.php';
require FROXLOR_INSTALL_DIR . '/lib/functions.php'; require FROXLOR_INSTALL_DIR . '/lib/functions.php';
require FROXLOR_INSTALL_DIR . '/lib/classes/settings/class.Settings.php'; require FROXLOR_INSTALL_DIR . '/lib/classes/settings/class.Settings.php';
require FROXLOR_INSTALL_DIR . '/lib/classes/settings/class.SImExporter.php';
require FROXLOR_INSTALL_DIR . '/lib/classes/config/class.ConfigParser.php'; require FROXLOR_INSTALL_DIR . '/lib/classes/config/class.ConfigParser.php';
require FROXLOR_INSTALL_DIR . '/lib/classes/config/class.ConfigService.php'; require FROXLOR_INSTALL_DIR . '/lib/classes/config/class.ConfigService.php';
require FROXLOR_INSTALL_DIR . '/lib/classes/config/class.ConfigDaemon.php'; require FROXLOR_INSTALL_DIR . '/lib/classes/config/class.ConfigDaemon.php';
if (array_key_exists("import-settings", $this->_args)) {
$this->_importSettings();
}
if (array_key_exists("create", $this->_args)) { if (array_key_exists("create", $this->_args)) {
$this->_createConfig(); $this->_createConfig();
} elseif (array_key_exists("apply", $this->_args)) { } elseif (array_key_exists("apply", $this->_args)) {
@@ -128,6 +138,20 @@ class Action
} }
} }
private function _importSettings()
{
if (! is_file($this->_args["import-settings"])) {
throw new Exception("Given settings file is not a file");
} elseif (! file_exists($this->_args["import-settings"])) {
throw new Exception("Given settings file cannot be found ('" . $this->_args["import-settings"] . "')");
} elseif (! is_readable($this->_args["import-settings"])) {
throw new Exception("Given settings file cannot be read ('" . $this->_args["import-settings"] . "')");
}
$imp_content = file_get_contents($this->_args["import-settings"]);
SImExporter::import($imp_content);
CmdLineHandler::printsucc("Successfully imported settings from '" . $this->_args["import-settings"] . "'");
}
private function _createConfig() private function _createConfig()
{ {
$_daemons_config = array( $_daemons_config = array(

View File

@@ -21,6 +21,8 @@ class Admins extends ApiCommand implements ResourceEntity
/** /**
* lists all admin entries * lists all admin entries
* *
* @access admin
* @throws Exception
* @return array count|list * @return array count|list
*/ */
public function list() public function list()
@@ -52,7 +54,8 @@ class Admins extends ApiCommand implements ResourceEntity
* optional, the admin-id * optional, the admin-id
* @param string $loginname * @param string $loginname
* optional, the loginname * optional, the loginname
* *
* @access admin
* @throws Exception * @throws Exception
* @return array * @return array
*/ */
@@ -84,6 +87,13 @@ class Admins extends ApiCommand implements ResourceEntity
throw new Exception("Not allowed to execute given command.", 403); throw new Exception("Not allowed to execute given command.", 403);
} }
/**
* create a new admin user
*
* @access admin
* @throws Exception
* @return array
*/
public function add() public function add()
{ {
if ($this->isAdmin() && $this->getUserDetail('change_serversettings') == 1) { if ($this->isAdmin() && $this->getUserDetail('change_serversettings') == 1) {
@@ -290,6 +300,18 @@ class Admins extends ApiCommand implements ResourceEntity
throw new Exception("Not allowed to execute given command.", 403); throw new Exception("Not allowed to execute given command.", 403);
} }
/**
* update an admin user by given id or loginname
*
* @param int $id
* optional, the admin-id
* @param string $loginname
* optional, the loginname
*
* @access admin
* @throws Exception
* @return array
*/
public function update() public function update()
{ {
if ($this->isAdmin() && $this->getUserDetail('change_serversettings') == 1) { if ($this->isAdmin() && $this->getUserDetail('change_serversettings') == 1) {
@@ -551,7 +573,8 @@ class Admins extends ApiCommand implements ResourceEntity
* optional, the admin-id * optional, the admin-id
* @param string $loginname * @param string $loginname
* optional, the loginname * optional, the loginname
* *
* @access admin
* @throws Exception * @throws Exception
* @return array * @return array
*/ */
@@ -619,7 +642,8 @@ class Admins extends ApiCommand implements ResourceEntity
* optional, the admin-id * optional, the admin-id
* @param string $loginname * @param string $loginname
* optional, the loginname * optional, the loginname
* *
* @access admin
* @throws Exception * @throws Exception
* @return array * @return array
*/ */

View File

@@ -21,6 +21,7 @@ class Customers extends ApiCommand implements ResourceEntity
/** /**
* lists all customer entries * lists all customer entries
* *
* @access admin
* @return array count|list * @return array count|list
*/ */
public function list() public function list()
@@ -61,20 +62,21 @@ class Customers extends ApiCommand implements ResourceEntity
* @param string $loginname * @param string $loginname
* optional, the loginname * optional, the loginname
* *
* @access admin, customer
* @throws Exception * @throws Exception
* @return array * @return array
*/ */
public function get() public function get()
{ {
$id = $this->getParam('id', true, 0);
$ln_optional = ($id <= 0 ? false : true);
$loginname = $this->getParam('loginname', $ln_optional, '');
if ($id <= 0 && empty($loginname)) {
throw new Exception("Either 'id' or 'loginname' parameter must be given", 406);
}
if ($this->isAdmin()) { if ($this->isAdmin()) {
$id = $this->getParam('id', true, 0);
$ln_optional = ($id <= 0 ? false : true);
$loginname = $this->getParam('loginname', $ln_optional, '');
if ($id <= 0 && empty($loginname)) {
throw new Exception("Either 'id' or 'loginname' parameter must be given", 406);
}
$result_stmt = Database::prepare(" $result_stmt = Database::prepare("
SELECT * FROM `" . TABLE_PANEL_CUSTOMERS . "` SELECT * FROM `" . TABLE_PANEL_CUSTOMERS . "`
WHERE " . ($id > 0 ? "`customerid` = :idln" : "`loginname` = :idln") . ($this->getUserDetail('customers_see_all') ? '' : " AND `adminid` = :adminid")); WHERE " . ($id > 0 ? "`customerid` = :idln" : "`loginname` = :idln") . ($this->getUserDetail('customers_see_all') ? '' : " AND `adminid` = :adminid"));
@@ -84,17 +86,32 @@ class Customers extends ApiCommand implements ResourceEntity
if ($this->getUserDetail('customers_see_all') == '0') { if ($this->getUserDetail('customers_see_all') == '0') {
$params['adminid'] = $this->getUserDetail('adminid'); $params['adminid'] = $this->getUserDetail('adminid');
} }
$result = Database::pexecute_first($result_stmt, $params, true, true); } else {
if ($result) { if (($id > 0 && $id != $this->getUserDetail('customerid')) || ! empty($loginname) && $loginname != $this->getUserDetail('loginname')) {
$this->logger()->logAction(ADM_ACTION, LOG_NOTICE, "[API] get customer '" . $result['loginname'] . "'"); throw new Exception("You cannot access data of other customers", 401);
return $this->response(200, "successfull", $result);
} }
$key = ($id > 0 ? "id #" . $id : "loginname '" . $loginname . "'"); $result_stmt = Database::prepare("
throw new Exception("Customer with " . $key . " could not be found", 404); SELECT * FROM `" . TABLE_PANEL_CUSTOMERS . "`
WHERE " . ($id > 0 ? "`customerid` = :idln" : "`loginname` = :idln"));
$params = array(
'idln' => ($id <= 0 ? $loginname : $id)
);
} }
throw new Exception("Not allowed to execute given command.", 403); $result = Database::pexecute_first($result_stmt, $params, true, true);
if ($result) {
$this->logger()->logAction($this->isAdmin() ? ADM_ACTION : USR_ACTION, LOG_NOTICE, "[API] get customer '" . $result['loginname'] . "'");
return $this->response(200, "successfull", $result);
}
$key = ($id > 0 ? "id #" . $id : "loginname '" . $loginname . "'");
throw new Exception("Customer with " . $key . " could not be found", 404);
} }
/**
* create a new customer with default ftp-user and standard-subdomain (if wanted)
*
* @access admin
* @return array
*/
public function add() public function add()
{ {
if ($this->isAdmin()) { if ($this->isAdmin()) {
@@ -236,7 +253,9 @@ class Customers extends ApiCommand implements ResourceEntity
))->get(); ))->get();
$loginname_check = json_decode($dup_check_result, true)['data']; $loginname_check = json_decode($dup_check_result, true)['data'];
} catch (Exception $e) { } catch (Exception $e) {
$loginname_check = array('loginname' => ''); $loginname_check = array(
'loginname' => ''
);
} }
// Check if an admin with the loginname already exists // Check if an admin with the loginname already exists
@@ -246,7 +265,9 @@ class Customers extends ApiCommand implements ResourceEntity
))->get(); ))->get();
$loginname_check_admin = json_decode($dup_check_result, true)['data']; $loginname_check_admin = json_decode($dup_check_result, true)['data'];
} catch (Exception $e) { } catch (Exception $e) {
$loginname_check_admin = array('loginname' => ''); $loginname_check_admin = array(
'loginname' => ''
);
} }
if (strtolower($loginname_check['loginname']) == strtolower($loginname) || strtolower($loginname_check_admin['loginname']) == strtolower($loginname)) { if (strtolower($loginname_check['loginname']) == strtolower($loginname) || strtolower($loginname_check_admin['loginname']) == strtolower($loginname)) {
@@ -646,17 +667,29 @@ class Customers extends ApiCommand implements ResourceEntity
throw new Exception("Not allowed to execute given command.", 403); throw new Exception("Not allowed to execute given command.", 403);
} }
/**
* update customer entry by either id or loginname
*
* @param int $id
* optional, the customer-id
* @param string $loginname
* optional, the loginname
*
* @access admin, customer
* @throws Exception
* @return array
*/
public function update() public function update()
{ {
if ($this->isAdmin()) { if ($this->isAdmin()) {
$id = $this->getParam('id', true, 0); $id = $this->getParam('id', true, 0);
$ln_optional = ($id <= 0 ? false : true); $ln_optional = ($id <= 0 ? false : true);
$loginname = $this->getParam('loginname', $ln_optional, ''); $loginname = $this->getParam('loginname', $ln_optional, '');
if ($id <= 0 && empty($loginname)) { if ($id <= 0 && empty($loginname)) {
throw new Exception("Either 'id' or 'loginname' parameter must be given", 406); throw new Exception("Either 'id' or 'loginname' parameter must be given", 406);
} }
$json_result = Customers::getLocal($this->getUserData(), array( $json_result = Customers::getLocal($this->getUserData(), array(
'id' => $id, 'id' => $id,
'loginname' => $loginname 'loginname' => $loginname
@@ -729,36 +762,18 @@ class Customers extends ApiCommand implements ResourceEntity
if (Settings::Get('ticket.enabled') != '1') { if (Settings::Get('ticket.enabled') != '1') {
$tickets = - 1; $tickets = - 1;
} }
if (empty($theme)) { if (empty($theme)) {
$theme = Settings::Get('panel.default_theme'); $theme = Settings::Get('panel.default_theme');
} }
$diskspace = $diskspace * 1024; $diskspace = $diskspace * 1024;
$traffic = $traffic * 1024 * 1024; $traffic = $traffic * 1024 * 1024;
if (((($this->getUserDetail('diskspace_used') + $diskspace - $result['diskspace']) > $this->getUserDetail('diskspace')) && ($this->getUserDetail('diskspace') / 1024) != '-1') if (((($this->getUserDetail('diskspace_used') + $diskspace - $result['diskspace']) > $this->getUserDetail('diskspace')) && ($this->getUserDetail('diskspace') / 1024) != '-1') || ((($this->getUserDetail('mysqls_used') + $mysqls - $result['mysqls']) > $this->getUserDetail('mysqls')) && $this->getUserDetail('mysqls') != '-1') || ((($this->getUserDetail('emails_used') + $emails - $result['emails']) > $this->getUserDetail('emails')) && $this->getUserDetail('emails') != '-1') || ((($this->getUserDetail('email_accounts_used') + $email_accounts - $result['email_accounts']) > $this->getUserDetail('email_accounts')) && $this->getUserDetail('email_accounts') != '-1') || ((($this->getUserDetail('email_forwarders_used') + $email_forwarders - $result['email_forwarders']) > $this->getUserDetail('email_forwarders')) && $this->getUserDetail('email_forwarders') != '-1') || ((($this->getUserDetail('email_quota_used') + $email_quota - $result['email_quota']) > $this->getUserDetail('email_quota')) && $this->getUserDetail('email_quota') != '-1' && Settings::Get('system.mail_quota_enabled') == '1') || ((($this->getUserDetail('ftps_used') + $ftps - $result['ftps']) > $this->getUserDetail('ftps')) && $this->getUserDetail('ftps') != '-1') || ((($this->getUserDetail('tickets_used') + $tickets - $result['tickets']) > $this->getUserDetail('tickets')) && $this->getUserDetail('tickets') != '-1') || ((($this->getUserDetail('subdomains_used') + $subdomains - $result['subdomains']) > $this->getUserDetail('subdomains')) && $this->getUserDetail('subdomains') != '-1') || (($diskspace / 1024) == '-1' && ($this->getUserDetail('diskspace') / 1024) != '-1') || ($mysqls == '-1' && $this->getUserDetail('mysqls') != '-1') || ($emails == '-1' && $this->getUserDetail('emails') != '-1') || ($email_accounts == '-1' && $this->getUserDetail('email_accounts') != '-1') || ($email_forwarders == '-1' && $this->getUserDetail('email_forwarders') != '-1') || ($email_quota == '-1' && $this->getUserDetail('email_quota') != '-1' && Settings::Get('system.mail_quota_enabled') == '1') || ($ftps == '-1' && $this->getUserDetail('ftps') != '-1') || ($tickets == '-1' && $this->getUserDetail('tickets') != '-1') || ($subdomains == '-1' && $this->getUserDetail('subdomains') != '-1')) {
|| ((($this->getUserDetail('mysqls_used') + $mysqls - $result['mysqls']) > $this->getUserDetail('mysqls')) && $this->getUserDetail('mysqls') != '-1')
|| ((($this->getUserDetail('emails_used') + $emails - $result['emails']) > $this->getUserDetail('emails')) && $this->getUserDetail('emails') != '-1')
|| ((($this->getUserDetail('email_accounts_used') + $email_accounts - $result['email_accounts']) > $this->getUserDetail('email_accounts')) && $this->getUserDetail('email_accounts') != '-1')
|| ((($this->getUserDetail('email_forwarders_used') + $email_forwarders - $result['email_forwarders']) > $this->getUserDetail('email_forwarders')) && $this->getUserDetail('email_forwarders') != '-1')
|| ((($this->getUserDetail('email_quota_used') + $email_quota - $result['email_quota']) > $this->getUserDetail('email_quota')) && $this->getUserDetail('email_quota') != '-1' && Settings::Get('system.mail_quota_enabled') == '1')
|| ((($this->getUserDetail('ftps_used') + $ftps - $result['ftps']) > $this->getUserDetail('ftps')) && $this->getUserDetail('ftps') != '-1')
|| ((($this->getUserDetail('tickets_used') + $tickets - $result['tickets']) > $this->getUserDetail('tickets')) && $this->getUserDetail('tickets') != '-1')
|| ((($this->getUserDetail('subdomains_used') + $subdomains - $result['subdomains']) > $this->getUserDetail('subdomains')) && $this->getUserDetail('subdomains') != '-1')
|| (($diskspace / 1024) == '-1' && ($this->getUserDetail('diskspace') / 1024) != '-1')
|| ($mysqls == '-1' && $this->getUserDetail('mysqls') != '-1')
|| ($emails == '-1' && $this->getUserDetail('emails') != '-1')
|| ($email_accounts == '-1' && $this->getUserDetail('email_accounts') != '-1')
|| ($email_forwarders == '-1' && $this->getUserDetail('email_forwarders') != '-1')
|| ($email_quota == '-1' && $this->getUserDetail('email_quota') != '-1' && Settings::Get('system.mail_quota_enabled') == '1')
|| ($ftps == '-1' && $this->getUserDetail('ftps') != '-1')
|| ($tickets == '-1' && $this->getUserDetail('tickets') != '-1')
|| ($subdomains == '-1' && $this->getUserDetail('subdomains') != '-1')
) {
standard_error('youcantallocatemorethanyouhave', '', true); standard_error('youcantallocatemorethanyouhave', '', true);
} }
// Either $name and $firstname or the $company must be inserted // Either $name and $firstname or the $company must be inserted
if ($name == '' && $company == '') { if ($name == '' && $company == '') {
standard_error(array( standard_error(array(
@@ -1160,6 +1175,7 @@ class Customers extends ApiCommand implements ResourceEntity
* @param bool $delete_userfiles * @param bool $delete_userfiles
* optional, default false * optional, default false
* *
* @access admin
* @throws Exception * @throws Exception
* @return array * @return array
*/ */
@@ -1405,6 +1421,7 @@ class Customers extends ApiCommand implements ResourceEntity
* @param string $loginname * @param string $loginname
* optional, the loginname * optional, the loginname
* *
* @access admin
* @throws Exception * @throws Exception
* @return array * @return array
*/ */
@@ -1414,11 +1431,11 @@ class Customers extends ApiCommand implements ResourceEntity
$id = $this->getParam('id', true, 0); $id = $this->getParam('id', true, 0);
$ln_optional = ($id <= 0 ? false : true); $ln_optional = ($id <= 0 ? false : true);
$loginname = $this->getParam('loginname', $ln_optional, ''); $loginname = $this->getParam('loginname', $ln_optional, '');
if ($id <= 0 && empty($loginname)) { if ($id <= 0 && empty($loginname)) {
throw new Exception("Either 'id' or 'loginname' parameter must be given", 406); throw new Exception("Either 'id' or 'loginname' parameter must be given", 406);
} }
$json_result = Customers::getLocal($this->getUserData(), array( $json_result = Customers::getLocal($this->getUserData(), array(
'id' => $id, 'id' => $id,
'loginname' => $loginname 'loginname' => $loginname

View File

@@ -21,6 +21,8 @@ class FpmDaemons extends ApiCommand implements ResourceEntity
/** /**
* lists all fpm-daemon entries * lists all fpm-daemon entries
* *
* @access admin
* @throws Exception
* @return array count|list * @return array count|list
*/ */
public function list() public function list()
@@ -72,6 +74,8 @@ class FpmDaemons extends ApiCommand implements ResourceEntity
* *
* @param int $id fpm-daemon-id * @param int $id fpm-daemon-id
* *
* @access admin
* @throws Exception
* @return array * @return array
*/ */
public function get() public function get()
@@ -93,6 +97,13 @@ class FpmDaemons extends ApiCommand implements ResourceEntity
throw new Exception("Not allowed to execute given command.", 403); throw new Exception("Not allowed to execute given command.", 403);
} }
/**
* create a new fpm-daemon entry
*
* @access admin
* @throws Exception
* @return array
*/
public function add() public function add()
{ {
if ($this->isAdmin() && $this->getUserDetail('change_serversettings') == 1) { if ($this->isAdmin() && $this->getUserDetail('change_serversettings') == 1) {
@@ -166,6 +177,15 @@ class FpmDaemons extends ApiCommand implements ResourceEntity
throw new Exception("Not allowed to execute given command.", 403); throw new Exception("Not allowed to execute given command.", 403);
} }
/**
* update a fpm-daemon entry by given id
*
* @param int $id
*
* @access admin
* @throws Exception
* @return array
*/
public function update() public function update()
{ {
if ($this->isAdmin() && $this->getUserDetail('change_serversettings') == 1) { if ($this->isAdmin() && $this->getUserDetail('change_serversettings') == 1) {
@@ -251,6 +271,7 @@ class FpmDaemons extends ApiCommand implements ResourceEntity
* *
* @param int $id fpm-daemon-id * @param int $id fpm-daemon-id
* *
* @access admin
* @throws Exception * @throws Exception
* @return array * @return array
*/ */

View File

@@ -21,6 +21,7 @@ class Froxlor extends ApiCommand
/** /**
* checks whether there is a newer version of froxlor available * checks whether there is a newer version of froxlor available
* *
* @access admin
* @throws Exception * @throws Exception
* @return string * @return string
*/ */
@@ -82,6 +83,8 @@ class Froxlor extends ApiCommand
/** /**
* *
* @todo import settings * @todo import settings
*
* @access admin
*/ */
public function importSettings() public function importSettings()
{} {}
@@ -89,6 +92,8 @@ class Froxlor extends ApiCommand
/** /**
* *
* @todo export settings to file * @todo export settings to file
*
* @access admin
*/ */
public function exportSettings() public function exportSettings()
{} {}
@@ -96,6 +101,8 @@ class Froxlor extends ApiCommand
/** /**
* return a list of all settings * return a list of all settings
* *
* @access admin
* @throws Exception
* @return array count|list * @return array count|list
*/ */
public function listSettings() public function listSettings()
@@ -126,6 +133,7 @@ class Froxlor extends ApiCommand
* @param string $key * @param string $key
* settinggroup.varname couple * settinggroup.varname couple
* *
* @access admin
* @throws Exception * @throws Exception
* @return string * @return string
*/ */
@@ -146,6 +154,7 @@ class Froxlor extends ApiCommand
* @param string $value * @param string $value
* optional the new value, default is '' * optional the new value, default is ''
* *
* @access admin
* @throws Exception * @throws Exception
* @return string * @return string
*/ */
@@ -153,7 +162,7 @@ class Froxlor extends ApiCommand
{ {
// currently not implemented as it required validation too so no wrong settings are being stored via API // currently not implemented as it required validation too so no wrong settings are being stored via API
throw new Exception("Not available yet.", 501); throw new Exception("Not available yet.", 501);
if ($this->isAdmin() && $this->getUserDetail('change_serversettings')) { if ($this->isAdmin() && $this->getUserDetail('change_serversettings')) {
$setting = $this->getParam('key'); $setting = $this->getParam('key');
$value = $this->getParam('value', true, ''); $value = $this->getParam('value', true, '');
@@ -173,6 +182,7 @@ class Froxlor extends ApiCommand
* @param string $module * @param string $module
* optional, return list of functions for a specific module * optional, return list of functions for a specific module
* *
* @access admin, customer
* @throws Exception * @throws Exception
* @return array * @return array
*/ */
@@ -260,7 +270,7 @@ class Froxlor extends ApiCommand
'head' => 'There is no comment-block for "' . $module . '.' . $function . '"' 'head' => 'There is no comment-block for "' . $module . '.' . $function . '"'
); );
} }
$clines = explode("\n", $comment); $clines = explode("\n", $comment);
$result = array(); $result = array();
$result['params'] = array(); $result['params'] = array();
@@ -277,6 +287,15 @@ class Froxlor extends ApiCommand
'desc' => (isset($r[3]) ? trim($r['3']) : '') 'desc' => (isset($r[3]) ? trim($r['3']) : '')
); );
$param_desc = true; $param_desc = true;
} // check access-section
elseif (strpos($c, '@access')) {
preg_match('/^\*\s\@access\s(.*)/', $c, $r);
if (! isset($r[0]) || empty($r[0])) {
$r[1] = 'This function has no restrictions';
}
$result['access'] = array(
'groups' => (isset($r[1]) ? trim($r[1]) : '')
);
} // check return-section } // check return-section
elseif (strpos($c, '@return')) { elseif (strpos($c, '@return')) {
preg_match('/^\*\s\@return\s(\w+)(\s.*)?/', $c, $r); preg_match('/^\*\s\@return\s(\w+)(\s.*)?/', $c, $r);
@@ -312,6 +331,7 @@ class Froxlor extends ApiCommand
} }
} }
} }
$result['head'] =trim($result['head']);
return $result; return $result;
} catch (\ReflectionException $e) { } catch (\ReflectionException $e) {
return array(); return array();

View File

@@ -21,6 +21,8 @@ class IpsAndPorts extends ApiCommand implements ResourceEntity
/** /**
* lists all ip/port entries * lists all ip/port entries
* *
* @access admin
* @throws Exception
* @return array count|list * @return array count|list
*/ */
public function list() public function list()
@@ -48,7 +50,8 @@ class IpsAndPorts extends ApiCommand implements ResourceEntity
* *
* @param int $id * @param int $id
* ip-port-id * ip-port-id
* *
* @access admin
* @throws Exception * @throws Exception
* @return array * @return array
*/ */
@@ -71,6 +74,13 @@ class IpsAndPorts extends ApiCommand implements ResourceEntity
throw new Exception("Not allowed to execute given command.", 403); throw new Exception("Not allowed to execute given command.", 403);
} }
/**
* create a new ip/port entry
*
* @access admin
* @throws Exception
* @return array
*/
public function add() public function add()
{ {
if ($this->isAdmin() && $this->getUserDetail('change_serversettings')) { if ($this->isAdmin() && $this->getUserDetail('change_serversettings')) {
@@ -199,6 +209,15 @@ class IpsAndPorts extends ApiCommand implements ResourceEntity
throw new Exception("Not allowed to execute given command.", 403); throw new Exception("Not allowed to execute given command.", 403);
} }
/**
* update ip/port entry by given id
*
* @param int $id
*
* @access admin
* @throws ErrorException
* @return array
*/
public function update() public function update()
{ {
if ($this->isAdmin() && $this->getUserDetail('change_serversettings')) { if ($this->isAdmin() && $this->getUserDetail('change_serversettings')) {
@@ -349,7 +368,8 @@ class IpsAndPorts extends ApiCommand implements ResourceEntity
* *
* @param int $id * @param int $id
* ip-port-id * ip-port-id
* *
* @access admin
* @throws Exception * @throws Exception
* @return array * @return array
*/ */

View File

@@ -31,6 +31,7 @@ class Mysqls extends ApiCommand implements ResourceEntity
* @param int $dbserver * @param int $dbserver
* optional, specify database-server, default is none * optional, specify database-server, default is none
* *
* @access admin, customer
* @throws Exception * @throws Exception
* @return array * @return array
*/ */
@@ -130,6 +131,7 @@ class Mysqls extends ApiCommand implements ResourceEntity
* @param string $loginname * @param string $loginname
* optional, admin-only, select dbs of a specific customer by loginname * optional, admin-only, select dbs of a specific customer by loginname
* *
* @access admin, customer
* @return array count|list * @return array count|list
*/ */
public function list() public function list()
@@ -220,6 +222,7 @@ class Mysqls extends ApiCommand implements ResourceEntity
* @param int $dbserver * @param int $dbserver
* optional, specify database-server, default is none * optional, specify database-server, default is none
* *
* @access admin, customer
* @throws Exception * @throws Exception
* @return array * @return array
*/ */

View File

@@ -21,6 +21,8 @@ class PhpSettings extends ApiCommand implements ResourceEntity
/** /**
* lists all php-setting entries * lists all php-setting entries
* *
* @access admin
* @throws Exception
* @return array count|list * @return array count|list
*/ */
public function list() public function list()
@@ -106,6 +108,8 @@ class PhpSettings extends ApiCommand implements ResourceEntity
* *
* @param int $id php-settings-id * @param int $id php-settings-id
* *
* @access admin
* @throws Exception
* @return array * @return array
*/ */
public function get() public function get()
@@ -127,6 +131,13 @@ class PhpSettings extends ApiCommand implements ResourceEntity
throw new Exception("Not allowed to execute given command.", 403); throw new Exception("Not allowed to execute given command.", 403);
} }
/**
* add new php-settings entry
*
* @access admin
* @throws Exception
* @return array
*/
public function add() public function add()
{ {
if ($this->isAdmin() && $this->getUserDetail('change_serversettings') == 1) { if ($this->isAdmin() && $this->getUserDetail('change_serversettings') == 1) {
@@ -226,6 +237,15 @@ class PhpSettings extends ApiCommand implements ResourceEntity
throw new Exception("Not allowed to execute given command.", 403); throw new Exception("Not allowed to execute given command.", 403);
} }
/**
* update a php-setting entry by given id
*
* @param int $id
*
* @access admin
* @throws Exception::
* @return array
*/
public function update() public function update()
{ {
if ($this->isAdmin() && $this->getUserDetail('change_serversettings') == 1) { if ($this->isAdmin() && $this->getUserDetail('change_serversettings') == 1) {
@@ -333,6 +353,7 @@ class PhpSettings extends ApiCommand implements ResourceEntity
* *
* @param int $id php-settings-id * @param int $id php-settings-id
* *
* @access admin
* @throws Exception * @throws Exception
* @return array * @return array
*/ */