Skip to content

Commit 2142ed3

Browse files
committed
added getMethod to request
1 parent 0e0cbd9 commit 2142ed3

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

admin/controller/user/login.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ function index() {
9797
$this->view->redir = $this->request->get['module'];
9898
}
9999

100-
if (($this->request->method == 'POST') &&
100+
$method = $this->request->getMethod();
101+
102+
if (($method == 'post') &&
101103
($this->view->errors = $validator->validate($this->request->post)) === true) {
102104
$user = $this->request->post['user'];
103105

system/core/request.php

+7-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class Request {
3535

3636
public $server = [];
3737

38-
public $method;
38+
private $method;
3939

4040
protected static $instance;
4141

@@ -47,7 +47,7 @@ public static function getInstance() {
4747
return static::$instance;
4848
}
4949

50-
private function __construct() {
50+
final private function __construct() {
5151
$this->get = &$_GET;
5252
$this->post = &$_POST;
5353
$this->request = &$_REQUEST;
@@ -60,7 +60,7 @@ private function __construct() {
6060
$this->request = $this->filter($this->request);
6161
$this->cookie = $this->filter($this->cookie);
6262
$this->files = $this->filter($this->files);
63-
$this->method = $_SERVER['REQUEST_METHOD'] ?? 'GET';
63+
$this->method = strtolower($_SERVER['REQUEST_METHOD'] ?? 'GET');
6464

6565
$this->request = array_merge($this->request, $this->get, $this->post);
6666
}
@@ -85,6 +85,10 @@ public function filter($data, $filterText = true) {
8585
return $data;
8686
}
8787

88+
public function getMethod() {
89+
return $this->method;
90+
}
91+
8892
public function isAjax() {
8993
return isset($this->server['HTTP_X_REQUESTED_WITH']) && $this->server['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest';
9094
}

0 commit comments

Comments
 (0)