Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d78a82c14c
|
||
|
|
d504f1d5bb
|
||
|
|
5534f10cee
|
||
|
|
c1fe1bb0e0
|
No files matched your search
@@ -4,6 +4,8 @@ use SokoWeb\Interfaces\Database\IConnection;
|
|||||||
use SokoWeb\Interfaces\Database\IResultSet;
|
use SokoWeb\Interfaces\Database\IResultSet;
|
||||||
use SokoWeb\Interfaces\Database\IStatement;
|
use SokoWeb\Interfaces\Database\IStatement;
|
||||||
use mysqli;
|
use mysqli;
|
||||||
|
use DateTime;
|
||||||
|
use DateTimeZone;
|
||||||
|
|
||||||
class Connection implements IConnection
|
class Connection implements IConnection
|
||||||
{
|
{
|
||||||
@@ -109,5 +111,16 @@ class Connection implements IConnection
|
|||||||
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
|
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
|
||||||
$this->connection = new mysqli($this->host, $this->user, $this->password, $this->db, $this->port, $this->socket);
|
$this->connection = new mysqli($this->host, $this->user, $this->password, $this->db, $this->port, $this->socket);
|
||||||
$this->connection->set_charset('utf8mb4');
|
$this->connection->set_charset('utf8mb4');
|
||||||
|
$this->connection->query('SET time_zone = \'' . $this->getTimeZone() . '\'');
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getTimeZone(): string {
|
||||||
|
$tz = new DateTimeZone(date_default_timezone_get());
|
||||||
|
$offset = $tz->getOffset(new DateTime('now', new DateTimeZone('UTC')));
|
||||||
|
|
||||||
|
$hours = intdiv($offset, 3600);
|
||||||
|
$minutes = abs(($offset % 3600) / 60);
|
||||||
|
|
||||||
|
return sprintf("%+03d:%02d", $hours, $minutes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -170,7 +170,7 @@ class HttpResponse
|
|||||||
$this->request->session()->set('redirect_after_login', $this->rawUrl);
|
$this->request->session()->set('redirect_after_login', $this->rawUrl);
|
||||||
$response = new Redirect(
|
$response = new Redirect(
|
||||||
$this->routeCollection->getRoute($this->appConfig['loginRouteId'])
|
$this->routeCollection->getRoute($this->appConfig['loginRouteId'])
|
||||||
->generateLink(['redirect_after_login' => urlencode($this->rawUrl)]),
|
->generateLink(['redirect_after_login' => $this->rawUrl]),
|
||||||
IRedirect::TEMPORARY);
|
IRedirect::TEMPORARY);
|
||||||
header('Location: ' . $this->getRedirectUrl($response), true, $response->getHttpCode());
|
header('Location: ' . $this->getRedirectUrl($response), true, $response->getHttpCode());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ class Route implements IRoute
|
|||||||
foreach ($this->pattern as $fragment) {
|
foreach ($this->pattern as $fragment) {
|
||||||
if (preg_match('/^{(\\w+)(\\?)?}$/', $fragment, $matches) === 1) {
|
if (preg_match('/^{(\\w+)(\\?)?}$/', $fragment, $matches) === 1) {
|
||||||
if (isset($parameters[$matches[1]])) {
|
if (isset($parameters[$matches[1]])) {
|
||||||
$link[] = $parameters[$matches[1]];
|
$link[] = rawurlencode($parameters[$matches[1]]);
|
||||||
unset($parameters[$matches[1]]);
|
unset($parameters[$matches[1]]);
|
||||||
} elseif (!isset($matches[2])) {//TODO: why? parameter not found but not optional
|
} elseif (!isset($matches[2])) {//TODO: why? parameter not found but not optional
|
||||||
$link[] = $fragment;
|
$link[] = $fragment;
|
||||||
@@ -53,7 +53,7 @@ class Route implements IRoute
|
|||||||
$queryParams[$key] = $value;
|
$queryParams[$key] = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = count($queryParams) > 0 ? '?' . http_build_query($queryParams) : '';
|
$query = count($queryParams) > 0 ? '?' . http_build_query($queryParams, encoding_type: PHP_QUERY_RFC3986) : '';
|
||||||
|
|
||||||
return '/' . implode('/', $link) . $query;
|
return '/' . implode('/', $link) . $query;
|
||||||
}
|
}
|
||||||
@@ -64,7 +64,7 @@ class Route implements IRoute
|
|||||||
|
|
||||||
foreach ($path as $i => $fragment) {
|
foreach ($path as $i => $fragment) {
|
||||||
if (preg_match('/^{(\\w+)(?:\\?)?}$/', $this->pattern[$i], $matches) === 1) {
|
if (preg_match('/^{(\\w+)(?:\\?)?}$/', $this->pattern[$i], $matches) === 1) {
|
||||||
$parameters[$matches[1]] = $fragment;
|
$parameters[$matches[1]] = rawurldecode($fragment);
|
||||||
} elseif ($fragment != $this->pattern[$i]) {
|
} elseif ($fragment != $this->pattern[$i]) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user