added Subdomains.add; minor fixes and enhancements

Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann (d00p)
2018-02-27 15:54:07 +01:00
parent 6318e5514b
commit a038e35e45
8 changed files with 421 additions and 313 deletions

View File

@@ -339,25 +339,25 @@ abstract class ApiCommand
*/
private function getModFunctionString()
{
$_c = get_called_class();
$_class = get_called_class();
$level = 2;
if (version_compare(PHP_VERSION, "5.4.0", "<")) {
$t = debug_backtrace();
$trace = debug_backtrace();
} else {
$t = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
}
while (true) {
$c = $t[$level]['class'];
$f = $t[$level]['function'];
if ($c != get_called_class()) {
$class = $trace[$level]['class'];
$func = $trace[$level]['function'];
if ($class != $_class) {
$level ++;
if ($level > 5) {
break;
}
continue;
}
return $c . ':' . $f;
return $class . ':' . $func;
}
}
@@ -426,6 +426,28 @@ abstract class ApiCommand
return $json_response;
}
/**
* increase/decrease a resource field for customers/admins
*
* @param string $table
* @param string $keyfield
* @param int $key
* @param string $op
* @param string $resource
* @param string $extra
*/
protected static function updateResourceUsage($table = null, $keyfield = null, $key = null, $op = '+', $resource = null, $extra = null)
{
$stmt = Database::prepare("
UPDATE `" . $table . "`
SET `" . $resource . "` = `" . $resource . "` " . $op . " 1 " . $extra . "
WHERE `" . $keyfield . "` = :key
");
Database::pexecute($stmt, array(
'key' => $key
), true, true);
}
/**
* read user data from database by api-request-header fields
*