PluginProbe ʕ •ᴥ•ʔ
JetBackup – Backup, Restore & Migrate / 3.1.22.4
JetBackup – Backup, Restore & Migrate v3.1.22.4
3.1.22.4 3.1.22.3 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.8.1 1.4.9 1.5.0 1.5.1 1.5.1.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.6.0 1.6.10 1.6.11 1.6.12 1.6.13 1.6.15 1.6.5.1 1.6.8.8 1.6.9 1.6.9.1 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7.5 2.0.8.7 2.0.9.11 2.0.9.14 2.0.9.15 2.0.9.6 2.0.9.7 2.0.9.9 3.1.10.7 3.1.11.1 3.1.12.3 3.1.13.4 3.1.14.17 3.1.15.4 3.1.16.1 3.1.17.5 3.1.18.10 3.1.18.8 3.1.18.9 3.1.19.8 3.1.20.3 3.1.21.3 3.1.7.9 3.1.9.2 trunk 1.1.90 1.1.91 1.2.0 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2
backup / src / JetBackup / Ajax / aAjax.php
backup / src / JetBackup / Ajax Last commit date
Calls 1 week ago .htaccess 1 year ago Ajax.php 1 week ago ListRecord.php 1 year ago aAjax.php 1 year ago iAjax.php 1 year ago index.html 1 year ago web.config 1 year ago
aAjax.php
111 lines
1 <?php
2
3 namespace JetBackup\Ajax;
4
5 use JetBackup\Exception\AjaxException;
6 use JetBackup\Exception\UserInputException;
7 use JetBackup\UserInput\UserInput;
8
9 if (!defined( '__JETBACKUP__')) die('Direct access is not allowed');
10
11 abstract class aAjax implements iAjax {
12
13 protected UserInput $_data;
14 private bool $_is_cli=false;
15 private string $_response_message='';
16 private array $_response_data=[];
17 private array $_response_cli=[];
18
19 public function __construct() {
20 $this->_data = new UserInput();
21 }
22
23 /**
24 * @param array $data
25 *
26 * @return void
27 */
28 public function setData(array $data=[]):void {
29 unset($data['actionType']);
30 $this->_data->setData($data);
31 }
32
33 /**
34 * @param bool $cli
35 *
36 * @return void
37 */
38 public function setCLI(bool $cli):void {
39 $this->_is_cli = $cli;
40 }
41
42 /**
43 * @return bool
44 */
45 public function isCLI(): bool {
46 return $this->_is_cli;
47 }
48
49 /**
50 * @param array $data
51 *
52 * @return void
53 */
54 public function setResponseCLI(array $data):void { $this->_response_cli = $data; }
55
56 /**
57 * @return array
58 */
59 public function getResponseCLI(): array { return $this->_response_cli ?? []; }
60
61 /**
62 * @param array $data
63 *
64 * @return void
65 */
66 public function setResponseData(array $data):void { $this->_response_data = $data; }
67
68 /**
69 * @return array
70 */
71 public function getResponseData(): array { return $this->_response_data ?? []; }
72
73 /**
74 * @param string $message
75 *
76 * @return void
77 */
78 public function setResponseMessage(string $message):void { $this->_response_message = $message; }
79
80 /**
81 * @return string
82 */
83 public function getResponseMessage(): string { return $this->_response_message ?? ''; }
84
85 /**
86 * @param string $key
87 *
88 * @return bool
89 */
90 public function isset(string $key):bool {
91 $fields = $this->_data->getData();
92 return isset($fields[$key]);
93 }
94
95 /**
96 * @param string $key
97 * @param $default
98 * @param int $type
99 * @param int $subType
100 *
101 * @return array|bool|float|int|mixed|object
102 * @throws AjaxException
103 */
104 public function getUserInput(string $key, $default, int $type, int $subType = 0) {
105 try {
106 return $this->_data->getValidated($key, $default, $type, $subType);
107 } catch(UserInputException $e) {
108 throw new AjaxException($e->getMessage(), $e->getData());
109 }
110 }
111 }