|
- <?php
- // Representative WHMCS boundary only: not an implementation of the encrypted router.
- namespace WHMCS\User { class Client {} }
- namespace WHMCS\Authentication {
- class CurrentUser {
- public function isAuthenticatedAdmin() { return $GLOBALS['isAdmin'] ?? false; }
- public function user() { return new \BackupTestUser(); }
- public function client() { return $GLOBALS['actor'] ?? null; }
- public function isAuthenticatedUser() { return isset($GLOBALS['actor']); }
- }
- }
- namespace WHMCS\Database {
- class Capsule {
- public static function table($table) { return new Query($table); }
- }
- class Query {
- private $table; private $where = [];
- public function __construct($table) { $this->table = $table; }
- public function where($key, $value) { $this->where[$key] = $value; return $this; }
- public function get() {
- return array_values(array_filter($GLOBALS['db'][$this->table] ?? [], function ($row) {
- foreach ($this->where as $key => $value) if ($row->$key != $value) return false;
- return true;
- }));
- }
- public function first() { return $this->get()[0] ?? null; }
- }
- }
- namespace {
- class BackupTestClient extends \WHMCS\User\Client {
- public $id; public $permitted;
- public function __construct($id, $permitted = true) { $this->id = $id; $this->permitted = $permitted; }
- public function hasPermission($permission) { throw new \RuntimeException('Unsupported client permission API'); }
- }
- class BackupTestUser {
- public function getClientsByPermission($permission) {
- if (isset($GLOBALS['permissionClients'])) return $GLOBALS['permissionClients'];
- $c=$GLOBALS['actor']??null; return $permission==='products' && $c && $c->permitted ? [$c] : [];
- }
- }
- function logActivity($message) { $GLOBALS['safeLogs'][] = $message; }
- }
|