/** * Construct a view * * @param string $path * @param array $data * @param array $injectors * @throws \Exception * @return View */ public function __construct($path, $data = array(), $injectors = array()) { if (is_array($path)) { // Support View factory $this->injectors['data'] = $path; $this->compileDirectly = true; } else { // Set dir for the view $injectors = array('data' => (array) $data, 'path' => $path) + $injectors + array('dir' => (string) App::self()->get('views'), 'app' => App::self()) + $this->injectors; // Set path $injectors['path'] = ltrim($path, '/'); // If file exists? if (!is_file($injectors['dir'] . '/' . $injectors['path'])) { // Try to load file from absolute path if ($path[0] == '/' && is_file($path)) { $injectors['path'] = $path; $injectors['dir'] = ''; } else { if (!empty($injectors['app']) && ($_path = $injectors['app']->path($injectors['path']))) { $injectors['path'] = $_path; $injectors['dir'] = ''; } else { throw new \Exception('Template file is not exist: ' . $injectors['path']); } } } } // Set data parent::__construct($injectors); }
/** * Dispense the instance * * @param string $name * @return Cache * @throws \InvalidArgumentException */ public static function with($name = 'cache') { if (empty(self::$instances[$name])) { $config = App::self()->get($name); self::$instances[$name] = self::create($config['type'], $config); } return self::$instances[$name]; }
function cpanelextender_clientarea($vars) { $whmcs = \App::self(); $action = $whmcs->get_req_var('action'); if ($action == 'addftpuser') { $serviceId = $whmcs->get_req_var('id'); $ftpUsername = $whmcs->get_req_var('ftp_prefix'); $ftpPassword = $whmcs->get_req_var('ftp_pw'); echo cpanelextender_addFtpAccount($serviceId, $ftpUsername, $ftpPassword); exit; } // If we get here, log an error to the activity log and exit. logActivity("cPanel Extender Addon Module Client Area called for action {$action} and we did not know what to do."); exit; }
/** * Export the config * * @param string $name * @return Config * @throws \InvalidArgumentException */ public static function export($name) { if (!isset(static::$imports[$name])) { throw new \InvalidArgumentException("Load config error with non-exists name \"{$name}\""); } // Check if config already exists? if (static::$imports[$name] instanceof Config) { return static::$imports[$name]; } // Try to load list($path, $type) = static::$imports[$name]; // Check file in path if (!($file = App::self()->path($path))) { throw new \InvalidArgumentException("Can not find file path \"{$path}\""); } return static::$imports[$name] = static::load($file, $type); }
<?php use WHMCS\Input\Sanitize; if (!defined("WHMCS")) { die("This file cannot be accessed directly"); } if (!function_exists('getRegistrarsDropdownMenu')) { require ROOTDIR . '/includes/registrarfunctions.php'; } $whmcs = App::self(); $reportdata["title"] = $aInt->lang('reports', 'domainRenewalEmailsTitle'); $userID = $whmcs->get_req_var('client'); $domain = $whmcs->get_req_var('domain'); $dateFrom = $whmcs->get_req_var('dateFrom') ? toMySQLDate($whmcs->get_req_var('dateFrom')) : ''; $dateTo = $whmcs->get_req_var('dateTo') ? toMySQLDate($whmcs->get_req_var('dateTo')) : ''; $formDateFrom = $dateFrom ? fromMySQLDate($dateFrom) : ''; $formDateTo = $dateTo ? fromMySQLDate($dateTo) : ''; $registrar = $whmcs->get_req_var('registrar'); $print = $whmcs->get_req_var('print'); /** * Replace the "None" string with the "Any" string */ $registrarList = str_replace($aInt->lang('global', 'none'), $aInt->lang('global', 'any'), getRegistrarsDropdownMenu($registrar)); $reportdata["description"] = $aInt->lang('reports', 'domainRenewalEmailsDescription'); $reportHeader = ''; if (!$print) { $reportHeader = <<<REPORT_HEADER <form method="post" action="reports.php?report=domain_renewal_emails"> {$aInt->lang('fields', 'clientid')}: {$aInt->clientsDropDown($userID, '', 'client', true)} {$aInt->lang('fields', 'domain')}: <input type="text" name="domain" value="{$domain}" size="30" /> {$aInt->lang('fields', 'registrar')}: {$registrarList}
/** * Get base path * * @param bool $basename * @return string */ public static function base($basename = null) { return App::self()->input->scriptName($basename); }