Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
mathsgod committed Dec 29, 2020
1 parent 9457b0c commit 441b968
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,23 +213,26 @@ public function getFolder(string $path = "")
}
}

return function () {
return function ($options) {

if (substr($this->context->route->path, 0, 5) == "_i18n") {

//acl
if (!isset($_SERVER['PHP_AUTH_USER'])) {
header('WWW-Authenticate: Basic realm="puxt i18n"');
header('HTTP/1.0 401 Unauthorized');
exit;
}

if ($_SERVER['PHP_AUTH_USER'] != $options["username"] && $_SERVER['PHP_AUTH_PW'] != $options["password"]) {
header('WWW-Authenticate: Basic realm="puxt i18n"');
header('HTTP/1.0 401 Unauthorized');
exit;
}

$path = substr($this->context->route->path, 6);
$app = new App($this->root, $this->config["i18n"], $path);
$app->run();
die();
}

if ($i18n = $this->config["i18n"]) {
$this->i18n = new stdClass();
$this->context->i18n->locale = $i18n["defaultLocale"];

$paths = explode("/", $this->context->route->path);
if (in_array($paths[0], $i18n["locales"])) {
$this->context->i18n->locale = array_shift($paths);
$this->context->route->path = implode("/", $paths);
}
}
};

0 comments on commit 441b968

Please sign in to comment.