/home/cookqozi/public_html/src/Page/views/search.twig
{% endfor %}
{% if P > 0 %} {% for searchP in searchPost %}
<div class="search-result-post">
<div class="row">
<div class="col-md-12 noStyle">
<span class="pull-left"><a href="{{ path('blog.show', {slug: searchP.slug}) }}">{{ searchP.name | toTags(search.q) }}</a></span><span class="comment-action-link pull-right"><i class="icon icon-comment-o"></i> {{ searchP.nbComments | default("0") }} {{ trad('_COMMENTS') }}</span>
<p class="spacetop30">{{ searchP.content | excerpt(250) | toTags(search.q) }}</p>
</div>
<div class="col-md-12 tags">
{% set tags = searchP.tags | split(',') %}
{% set i = 0 %}
{% for tag in tags %}
{% if i == 10 %}{% set i = 1 %}{% else %}{% set i = i + 1 %}{% endif %}
<span class="price-tag tags-color{{ i }}"><a href="{{ url('search?q='~ tag) }}">{{ tag }}</a></span>
{% endfor %}
</div>
</div>
<section class="comments">
<div class="col-md-12 noStyle">
<span class="comment-date pull-left" title="{{ searchP.created.date }}">{{ searchP.created | ago }}</span>
<p><a class="alink pull-right" href="{{ path('blog.show', {slug: searchP.slug}) }}">{{ trad('_SAVOIRPLUS') }}</a></p>
</div>
<div class="col-md-12 noStyle"><hr></div>
</section>
</div>
{% endfor %} {% endif %}
{% endif %}
{{ paginate('search', search.total, search.pageCurrent, search.page, '', {'q' : search.q}) }}
<!-- end: SEARCH RESULT -->
</div>
<div class="col-md-12 hidden">
<p>{{ trad('_KEYSEARCHTEAM1') }}</p>
<p>{{ trad('_KEYSEARCHTEAM2') }}</p>
</div>
</div></div>
</div></section>
{% endblock %}
/home/cookqozi/public_html/vendor/twig/twig/src/Extension/CoreExtension.php
throw new RuntimeError($message, $lineno, $source);
}
if ($object instanceof Template) {
throw new RuntimeError('Accessing \Twig\Template attributes is forbidden.', $lineno, $source);
}
// object property
if (/* Template::METHOD_CALL */ 'method' !== $type) {
if (isset($object->$item) || \array_key_exists((string) $item, (array) $object)) {
if ($isDefinedTest) {
return true;
}
if ($sandboxed) {
$env->getExtension(SandboxExtension::class)->checkPropertyAllowed($object, $item, $lineno, $source);
}
return $object->$item;
}
}
static $cache = [];
$class = \get_class($object);
// object method
// precedence: getXxx() > isXxx() > hasXxx()
if (!isset($cache[$class])) {
$methods = get_class_methods($object);
sort($methods);
$lcMethods = array_map(function ($value) { return strtr($value, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'); }, $methods);
$classCache = [];
foreach ($methods as $i => $method) {
$classCache[$method] = $method;
$classCache[$lcName = $lcMethods[$i]] = $method;
if ('g' === $lcName[0] && 0 === strpos($lcName, 'get')) {
$name = substr($method, 3);
/home/cookqozi/public_html/vendor/twig/twig/src/Extension/CoreExtension.php
throw new RuntimeError($message, $lineno, $source);
}
if ($object instanceof Template) {
throw new RuntimeError('Accessing \Twig\Template attributes is forbidden.', $lineno, $source);
}
// object property
if (/* Template::METHOD_CALL */ 'method' !== $type) {
if (isset($object->$item) || \array_key_exists((string) $item, (array) $object)) {
if ($isDefinedTest) {
return true;
}
if ($sandboxed) {
$env->getExtension(SandboxExtension::class)->checkPropertyAllowed($object, $item, $lineno, $source);
}
return $object->$item;
}
}
static $cache = [];
$class = \get_class($object);
// object method
// precedence: getXxx() > isXxx() > hasXxx()
if (!isset($cache[$class])) {
$methods = get_class_methods($object);
sort($methods);
$lcMethods = array_map(function ($value) { return strtr($value, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'); }, $methods);
$classCache = [];
foreach ($methods as $i => $method) {
$classCache[$method] = $method;
$classCache[$lcName = $lcMethods[$i]] = $method;
if ('g' === $lcName[0] && 0 === strpos($lcName, 'get')) {
$name = substr($method, 3);
/home/cookqozi/public_html/tmp/views/5f/5f7d3d2f1e4650c72fe87750094834eb.php
echo "\t\t\t\t\t\t\t\t\t<span class=\"price-tag tags-color";
echo twig_escape_filter($this->env, ($context["i"] ?? null), "html", null, true);
echo "\"><a href=\"";
echo twig_escape_filter($this->env, $this->extensions['Framework\Twig\RouterTwigExtension']->urlFor(("search?q=" . $context["tag"])), "html", null, true);
echo "\">";
echo twig_escape_filter($this->env, $context["tag"], "html", null, true);
echo "</a></span>
\t\t\t\t\t\t\t\t";
}
$_parent = $context['_parent'];
unset($context['_seq'], $context['_iterated'], $context['_key'], $context['tag'], $context['_parent'], $context['loop']);
$context = array_intersect_key($context, $_parent) + $_parent;
// line 41
echo "\t\t\t\t\t\t\t</div>
\t\t\t\t\t\t</div>
\t\t\t\t\t\t<section class=\"comments\">
\t\t\t\t\t\t\t<div class=\"col-md-12 noStyle\">\t\t
\t\t\t\t\t\t\t\t<span class=\"comment-date pull-left\" title=\"";
// line 45
echo twig_escape_filter($this->env, twig_get_attribute($this->env, $this->source, twig_get_attribute($this->env, $this->source, $context["searchP"], "created", [], "any", false, false, false, 45), "date", [], "any", false, false, false, 45), "html", null, true);
echo "\">";
echo $this->extensions['Framework\Twig\TimeExtension']->ago(twig_get_attribute($this->env, $this->source, $context["searchP"], "created", [], "any", false, false, false, 45));
echo "</span>
\t\t\t\t\t\t\t\t<p><a class=\"alink pull-right\" href=\"";
// line 46
echo twig_escape_filter($this->env, $this->extensions['Framework\Twig\RouterTwigExtension']->pathFor("blog.show", ["slug" => twig_get_attribute($this->env, $this->source, $context["searchP"], "slug", [], "any", false, false, false, 46)]), "html", null, true);
echo "\">";
echo $this->extensions['Framework\Twig\TextExtension']->toTrad("_SAVOIRPLUS");
echo "</a></p>
\t\t\t\t\t\t\t</div>
\t\t\t\t\t\t\t<div class=\"col-md-12 noStyle\"><hr></div>
\t\t\t\t\t\t</section>
\t\t\t\t\t</div>
\t\t\t\t";
}
$_parent = $context['_parent'];
unset($context['_seq'], $context['_iterated'], $context['_key'], $context['searchP'], $context['_parent'], $context['loop']);
$context = array_intersect_key($context, $_parent) + $_parent;
// line 51
echo " ";
/home/cookqozi/public_html/vendor/twig/twig/src/Template.php
{
if ($useBlocks && isset($blocks[$name])) {
$template = $blocks[$name][0];
$block = $blocks[$name][1];
} elseif (isset($this->blocks[$name])) {
$template = $this->blocks[$name][0];
$block = $this->blocks[$name][1];
} else {
$template = null;
$block = null;
}
// avoid RCEs when sandbox is enabled
if (null !== $template && !$template instanceof self) {
throw new \LogicException('A block must be a method on a \Twig\Template instance.');
}
if (null !== $template) {
try {
$template->$block($context, $blocks);
} catch (Error $e) {
if (!$e->getSourceContext()) {
$e->setSourceContext($template->getSourceContext());
}
// this is mostly useful for \Twig\Error\LoaderError exceptions
// see \Twig\Error\LoaderError
if (-1 === $e->getTemplateLine()) {
$e->guess();
}
throw $e;
} catch (\Exception $e) {
$e = new RuntimeError(sprintf('An exception has been thrown during the rendering of a template ("%s").', $e->getMessage()), -1, $template->getSourceContext(), $e);
$e->guess();
throw $e;
}
} elseif (false !== $parent = $this->getParent($context)) {
$parent->displayBlock($name, $context, array_merge($this->blocks, $blocks), false, $templateContext ?? $this);
/home/cookqozi/public_html/tmp/views/f7/f7dd10ac70f34f2f101e1c084c530e1c.php
<html lang=\"";
// line 2
echo twig_escape_filter($this->env, twig_get_attribute($this->env, $this->source, ($context["visitor"] ?? null), "lang", [], "any", false, false, false, 2), "html", null, true);
echo "\">
\t";
// line 3
$this->displayBlock('head', $context, $blocks);
// line 4
echo "\t<body>
\t\t";
// line 5
$this->displayBlock('header', $context, $blocks);
// line 6
echo "\t\t<div class=\"content-wrap\">
\t\t\t";
// line 7
$this->loadTemplate("flash.twig", "default.twig", 7)->display($context);
// line 8
echo "\t\t\t";
$this->displayBlock('content', $context, $blocks);
// line 9
echo "\t\t\t<div class=\"hidden\">";
echo twig_escape_filter($this->env, twig_get_attribute($this->env, $this->source, ($context["seo"] ?? null), "keyword", [], "any", false, false, false, 9), "html", null, true);
echo "</div>
\t\t</div>
\t\t";
// line 11
$this->displayBlock('footer', $context, $blocks);
// line 12
echo "\t\t<!-- ScrollUp button start -->
\t\t<div class=\"scrollup\"><span class=\"go-top\"><i class=\"icon icon-angle-up\"></i></span></div>
\t\t<!-- ScrollUp button end -->
\t\t";
// line 15
$this->displayBlock('script', $context, $blocks);
// line 16
echo "\t</body>
</html>";
}
/home/cookqozi/public_html/vendor/twig/twig/src/Template.php
} else {
ob_start(function () { return ''; });
}
try {
$this->display($context);
} catch (\Throwable $e) {
while (ob_get_level() > $level) {
ob_end_clean();
}
throw $e;
}
return ob_get_clean();
}
protected function displayWithErrorHandling(array $context, array $blocks = [])
{
try {
$this->doDisplay($context, $blocks);
} catch (Error $e) {
if (!$e->getSourceContext()) {
$e->setSourceContext($this->getSourceContext());
}
// this is mostly useful for \Twig\Error\LoaderError exceptions
// see \Twig\Error\LoaderError
if (-1 === $e->getTemplateLine()) {
$e->guess();
}
throw $e;
} catch (\Exception $e) {
$e = new RuntimeError(sprintf('An exception has been thrown during the rendering of a template ("%s").', $e->getMessage()), -1, $this->getSourceContext(), $e);
$e->guess();
throw $e;
}
}
/home/cookqozi/public_html/vendor/twig/twig/src/Template.php
{
return $this;
}
/**
* Returns all blocks.
*
* This method is for internal use only and should never be called
* directly.
*
* @return array An array of blocks
*/
public function getBlocks()
{
return $this->blocks;
}
public function display(array $context, array $blocks = [])
{
$this->displayWithErrorHandling($this->env->mergeGlobals($context), array_merge($this->blocks, $blocks));
}
public function render(array $context)
{
$level = ob_get_level();
if ($this->env->isDebug()) {
ob_start();
} else {
ob_start(function () { return ''; });
}
try {
$this->display($context);
} catch (\Throwable $e) {
while (ob_get_level() > $level) {
ob_end_clean();
}
throw $e;
}
/home/cookqozi/public_html/tmp/views/5f/5f7d3d2f1e4650c72fe87750094834eb.php
'content' => [$this, 'block_content'],
];
}
protected function doGetParent(array $context)
{
// line 3
return "default.twig";
}
protected function doDisplay(array $context, array $blocks = [])
{
$macros = $this->macros;
// line 1
$context["titlePage"] = (($this->extensions['Framework\Twig\TextExtension']->toTrad("_SEARCH") . " : ") . twig_get_attribute($this->env, $this->source, ($context["search"] ?? null), "q", [], "any", false, false, false, 1));
// line 2
$context["descriptionPage"] = ((twig_get_attribute($this->env, $this->source, ($context["search"] ?? null), "q", [], "any", false, false, false, 2) . " => ") . $this->extensions['Framework\Twig\TextExtension']->toTrad("_DESDEFAULTSEARCH"));
// line 3
$this->parent = $this->loadTemplate("default.twig", "@page/search.twig", 3);
$this->parent->display($context, array_merge($this->blocks, $blocks));
}
// line 4
public function block_content($context, array $blocks = [])
{
$macros = $this->macros;
// line 5
echo "<section class=\"section primary-section\"><div class=\"contain\">
\t<div class=\"content\"><div class=\"row\">
\t\t<div class=\"title centered\">
\t\t\t<h1>";
// line 8
echo $this->extensions['Framework\Twig\TextExtension']->toTrad("_SEARCH0");
echo " ";
if (twig_get_attribute($this->env, $this->source, ($context["search"] ?? null), "q", [], "any", false, false, false, 8)) {
echo " ";
echo twig_escape_filter($this->env, ($this->extensions['Framework\Twig\TextExtension']->toTrad("_SEARCH1") . twig_get_attribute($this->env, $this->source, ($context["search"] ?? null), "q", [], "any", false, false, false, 8)), "html", null, true);
}
echo "</h1>
\t\t</div>
/home/cookqozi/public_html/vendor/twig/twig/src/Template.php
} else {
ob_start(function () { return ''; });
}
try {
$this->display($context);
} catch (\Throwable $e) {
while (ob_get_level() > $level) {
ob_end_clean();
}
throw $e;
}
return ob_get_clean();
}
protected function displayWithErrorHandling(array $context, array $blocks = [])
{
try {
$this->doDisplay($context, $blocks);
} catch (Error $e) {
if (!$e->getSourceContext()) {
$e->setSourceContext($this->getSourceContext());
}
// this is mostly useful for \Twig\Error\LoaderError exceptions
// see \Twig\Error\LoaderError
if (-1 === $e->getTemplateLine()) {
$e->guess();
}
throw $e;
} catch (\Exception $e) {
$e = new RuntimeError(sprintf('An exception has been thrown during the rendering of a template ("%s").', $e->getMessage()), -1, $this->getSourceContext(), $e);
$e->guess();
throw $e;
}
}
/home/cookqozi/public_html/vendor/twig/twig/src/Template.php
{
return $this;
}
/**
* Returns all blocks.
*
* This method is for internal use only and should never be called
* directly.
*
* @return array An array of blocks
*/
public function getBlocks()
{
return $this->blocks;
}
public function display(array $context, array $blocks = [])
{
$this->displayWithErrorHandling($this->env->mergeGlobals($context), array_merge($this->blocks, $blocks));
}
public function render(array $context)
{
$level = ob_get_level();
if ($this->env->isDebug()) {
ob_start();
} else {
ob_start(function () { return ''; });
}
try {
$this->display($context);
} catch (\Throwable $e) {
while (ob_get_level() > $level) {
ob_end_clean();
}
throw $e;
}
/home/cookqozi/public_html/vendor/twig/twig/src/Template.php
public function getBlocks()
{
return $this->blocks;
}
public function display(array $context, array $blocks = [])
{
$this->displayWithErrorHandling($this->env->mergeGlobals($context), array_merge($this->blocks, $blocks));
}
public function render(array $context)
{
$level = ob_get_level();
if ($this->env->isDebug()) {
ob_start();
} else {
ob_start(function () { return ''; });
}
try {
$this->display($context);
} catch (\Throwable $e) {
while (ob_get_level() > $level) {
ob_end_clean();
}
throw $e;
}
return ob_get_clean();
}
protected function displayWithErrorHandling(array $context, array $blocks = [])
{
try {
$this->doDisplay($context, $blocks);
} catch (Error $e) {
if (!$e->getSourceContext()) {
$e->setSourceContext($this->getSourceContext());
}
/home/cookqozi/public_html/vendor/twig/twig/src/TemplateWrapper.php
private $env;
private $template;
/**
* This method is for internal use only and should never be called
* directly (use Twig\Environment::load() instead).
*
* @internal
*/
public function __construct(Environment $env, Template $template)
{
$this->env = $env;
$this->template = $template;
}
public function render(array $context = []): string
{
// using func_get_args() allows to not expose the blocks argument
// as it should only be used by internal code
return $this->template->render($context, \func_get_args()[1] ?? []);
}
public function display(array $context = [])
{
// using func_get_args() allows to not expose the blocks argument
// as it should only be used by internal code
$this->template->display($context, \func_get_args()[1] ?? []);
}
public function hasBlock(string $name, array $context = []): bool
{
return $this->template->hasBlock($name, $context);
}
/**
* @return string[] An array of defined template block names
*/
public function getBlockNames(array $context = []): array
{
return $this->template->getBlockNames($context);
/home/cookqozi/public_html/vendor/twig/twig/src/Environment.php
*/
public function getTemplateClass(string $name, int $index = null): string
{
$key = $this->getLoader()->getCacheKey($name).$this->optionsHash;
return $this->templateClassPrefix.hash(\PHP_VERSION_ID < 80100 ? 'sha256' : 'xxh128', $key).(null === $index ? '' : '___'.$index);
}
/**
* Renders a template.
*
* @param string|TemplateWrapper $name The template name
*
* @throws LoaderError When the template cannot be found
* @throws SyntaxError When an error occurred during compilation
* @throws RuntimeError When an error occurred during rendering
*/
public function render($name, array $context = []): string
{
return $this->load($name)->render($context);
}
/**
* Displays a template.
*
* @param string|TemplateWrapper $name The template name
*
* @throws LoaderError When the template cannot be found
* @throws SyntaxError When an error occurred during compilation
* @throws RuntimeError When an error occurred during rendering
*/
public function display($name, array $context = []): void
{
$this->load($name)->display($context);
}
/**
* Loads a template.
*
* @param string|TemplateWrapper $name The template name
/home/cookqozi/public_html/src/Framework/Renderer/TwigRenderer.php
* @param string $namespace
* @param string $path
*/
public function addPath(string $namespace, string $path = ''): void
{
$this->twig->getLoader()->addPath($path, $namespace);
}
/**
* Permet de rendre une vue
* Le chemin peut être précisé avec des namespace rajoutés via addPath()
* $this->render('@blog/view');
* $this->render('view');
* @param string $view
* @param array $params
* @return string
*/
public function render(string $view, array $params = []): string
{
return $this->twig->render($view . '.twig', $params);
}
/**
* Permet de rajouter des variables globales à toutes les vues
*
* @param string $key
* @param mixed $value
*/
public function addGlobal(string $key, $value): void
{
$this->twig->addGlobal($key, $value);
}
/**
* @return Twig_Environment
*/
public function getTwig(): Twig_Environment
{
return $this->twig;
}
/home/cookqozi/public_html/src/Page/Actions/SearchAction.php
$perPage = 8;
$pageCurrent = $params['p'] ?? 1;
$q = $params['q'] ?? '';
$searchPost = $this->postTable
->findSearch($q)
->paginate($perPage, $pageCurrent);
$offset = $pageCurrent * $perPage - $perPage;
$totalPost = $this->postTable->findSearch($q)->count();
$total = max($totalPost, 0);
$page = ceil($total / $perPage);
$search = [
'q' => $q,
'totalPost' => $totalPost,
'total' => $total,
'pageCurrent' => $pageCurrent,
'page' => $page,
];
return $this->renderer->render(
'@page/search',
compact('search', 'searchPost')
);
}
}
/home/cookqozi/public_html/src/Framework/Middleware/CombinedMiddlewareDelegate.php
public function __construct(
ContainerInterface $container,
array $middlewares,
RequestHandlerInterface $handler
) {
$this->middlewares = $middlewares;
$this->container = $container;
$this->handler = $handler;
}
public function handle(ServerRequestInterface $request): ResponseInterface
{
$middleware = $this->getMiddleware();
if (is_null($middleware)) {
return $this->handler->handle($request);
} elseif (is_callable($middleware)) {
$response = call_user_func_array($middleware, [
$request,
[$this, 'handle'],
]);
if (is_string($response)) {
return new Response(200, [], $response);
}
return $response;
} elseif ($middleware instanceof MiddlewareInterface) {
return $middleware->process($request, $this);
}
}
/**
* @return object
*/
private function getMiddleware()
{
if (array_key_exists($this->index, $this->middlewares)) {
if (is_string($this->middlewares[$this->index])) {
$middleware = $this->container->get(
$this->middlewares[$this->index]
);
/home/cookqozi/public_html/src/Framework/Middleware/CombinedMiddlewareDelegate.php
public function __construct(
ContainerInterface $container,
array $middlewares,
RequestHandlerInterface $handler
) {
$this->middlewares = $middlewares;
$this->container = $container;
$this->handler = $handler;
}
public function handle(ServerRequestInterface $request): ResponseInterface
{
$middleware = $this->getMiddleware();
if (is_null($middleware)) {
return $this->handler->handle($request);
} elseif (is_callable($middleware)) {
$response = call_user_func_array($middleware, [
$request,
[$this, 'handle'],
]);
if (is_string($response)) {
return new Response(200, [], $response);
}
return $response;
} elseif ($middleware instanceof MiddlewareInterface) {
return $middleware->process($request, $this);
}
}
/**
* @return object
*/
private function getMiddleware()
{
if (array_key_exists($this->index, $this->middlewares)) {
if (is_string($this->middlewares[$this->index])) {
$middleware = $this->container->get(
$this->middlewares[$this->index]
);
/home/cookqozi/public_html/src/Framework/Middleware/CombinedMiddleware.php
private $middlewares;
public function __construct(
ContainerInterface $container,
array $middlewares
) {
$this->container = $container;
$this->middlewares = $middlewares;
}
public function process(
ServerRequestInterface $request,
RequestHandlerInterface $handler
): ResponseInterface {
$handler = new CombinedMiddlewareDelegate(
$this->container,
$this->middlewares,
$handler
);
return $handler->handle($request);
}
}
/home/cookqozi/public_html/src/Framework/Middleware/DispatcherMiddleware.php
public function __construct(ContainerInterface $container)
{
$this->container = $container;
}
public function process(
ServerRequestInterface $request,
RequestHandlerInterface $handler
): ResponseInterface {
$route = $request->getAttribute(Route::class);
if (is_null($route)) {
return $handler->handle($request);
}
$callback = $route->getCallback();
if (!is_array($callback)) {
$callback = [$callback];
}
return (new CombinedMiddleware($this->container, $callback))->process(
$request,
$handler
);
}
}
/home/cookqozi/public_html/src/Framework/Middleware/CombinedMiddlewareDelegate.php
$this->container = $container;
$this->handler = $handler;
}
public function handle(ServerRequestInterface $request): ResponseInterface
{
$middleware = $this->getMiddleware();
if (is_null($middleware)) {
return $this->handler->handle($request);
} elseif (is_callable($middleware)) {
$response = call_user_func_array($middleware, [
$request,
[$this, 'handle'],
]);
if (is_string($response)) {
return new Response(200, [], $response);
}
return $response;
} elseif ($middleware instanceof MiddlewareInterface) {
return $middleware->process($request, $this);
}
}
/**
* @return object
*/
private function getMiddleware()
{
if (array_key_exists($this->index, $this->middlewares)) {
if (is_string($this->middlewares[$this->index])) {
$middleware = $this->container->get(
$this->middlewares[$this->index]
);
} else {
$middleware = $this->middlewares[$this->index];
}
$this->index++;
return $middleware;
}
return null;
/home/cookqozi/public_html/src/Framework/Middleware/RouterMiddleware.php
}
public function process(
ServerRequestInterface $request,
RequestHandlerInterface $handler
): ResponseInterface {
$route = $this->router->match($request);
if (is_null($route)) {
return $handler->handle($request);
}
$params = $route->getParams();
$request = array_reduce(
array_keys($params),
function ($request, $key) use ($params) {
return $request->withAttribute($key, $params[$key]);
},
$request
);
$request = $request->withAttribute(get_class($route), $route);
return $handler->handle($request);
}
}
/home/cookqozi/public_html/src/Framework/Middleware/CombinedMiddlewareDelegate.php
$this->container = $container;
$this->handler = $handler;
}
public function handle(ServerRequestInterface $request): ResponseInterface
{
$middleware = $this->getMiddleware();
if (is_null($middleware)) {
return $this->handler->handle($request);
} elseif (is_callable($middleware)) {
$response = call_user_func_array($middleware, [
$request,
[$this, 'handle'],
]);
if (is_string($response)) {
return new Response(200, [], $response);
}
return $response;
} elseif ($middleware instanceof MiddlewareInterface) {
return $middleware->process($request, $this);
}
}
/**
* @return object
*/
private function getMiddleware()
{
if (array_key_exists($this->index, $this->middlewares)) {
if (is_string($this->middlewares[$this->index])) {
$middleware = $this->container->get(
$this->middlewares[$this->index]
);
} else {
$middleware = $this->middlewares[$this->index];
}
$this->index++;
return $middleware;
}
return null;
/home/cookqozi/public_html/src/Framework/Middleware/CsrfMiddleware.php
if (in_array($request->getMethod(), ['POST', 'PUT', 'DELETE'])) {
if ($request->getUri()->getPath() == '/cspReport') {
return $handler->handle($request);
}
$params = $request->getParsedBody() ?: [];
if (!array_key_exists($this->formKey, $params)) {
$this->reject();
} else {
$csrfList = $this->session[$this->sessionKey] ?? [];
if (in_array($params[$this->formKey], $csrfList)) {
if (!isset($params['ajax'])) {
$this->useToken($params[$this->formKey]);
}
return $handler->handle($request);
} else {
$this->reject();
}
}
} else {
return $handler->handle($request);
}
}
public function generateToken(): string
{
$token = bin2hex(random_bytes(16));
$csrfList = $this->session[$this->sessionKey] ?? [];
$csrfList[] = $token;
$this->session[$this->sessionKey] = $csrfList;
$this->limitTokens();
return $token;
}
private function reject(): void
{
throw new CsrfInvalidException();
}
private function useToken($token): void
{
/home/cookqozi/public_html/src/Framework/Middleware/CombinedMiddlewareDelegate.php
$this->container = $container;
$this->handler = $handler;
}
public function handle(ServerRequestInterface $request): ResponseInterface
{
$middleware = $this->getMiddleware();
if (is_null($middleware)) {
return $this->handler->handle($request);
} elseif (is_callable($middleware)) {
$response = call_user_func_array($middleware, [
$request,
[$this, 'handle'],
]);
if (is_string($response)) {
return new Response(200, [], $response);
}
return $response;
} elseif ($middleware instanceof MiddlewareInterface) {
return $middleware->process($request, $this);
}
}
/**
* @return object
*/
private function getMiddleware()
{
if (array_key_exists($this->index, $this->middlewares)) {
if (is_string($this->middlewares[$this->index])) {
$middleware = $this->container->get(
$this->middlewares[$this->index]
);
} else {
$middleware = $this->middlewares[$this->index];
}
$this->index++;
return $middleware;
}
return null;
/home/cookqozi/public_html/src/Framework/Middleware/ForbiddenCsrfMiddleware.php
*/
private $flashService;
public function __construct(FlashService $flashService)
{
$this->flashService = $flashService;
}
/**
* @param ServerRequestInterface $request
* @param RequestHandlerInterface $handler
* @return ResponseInterface
* @throws \TypeError
*/
public function process(
ServerRequestInterface $request,
RequestHandlerInterface $handler
): ResponseInterface {
try {
return $handler->handle($request);
} catch (CsrfInvalidException $exception) {
$this->flashService->error(_CSRFINVALID);
return new RedirectResponse('/');
} catch (\TypeError $error) {
throw $error;
}
}
}
/home/cookqozi/public_html/src/Framework/Middleware/CombinedMiddlewareDelegate.php
$this->container = $container;
$this->handler = $handler;
}
public function handle(ServerRequestInterface $request): ResponseInterface
{
$middleware = $this->getMiddleware();
if (is_null($middleware)) {
return $this->handler->handle($request);
} elseif (is_callable($middleware)) {
$response = call_user_func_array($middleware, [
$request,
[$this, 'handle'],
]);
if (is_string($response)) {
return new Response(200, [], $response);
}
return $response;
} elseif ($middleware instanceof MiddlewareInterface) {
return $middleware->process($request, $this);
}
}
/**
* @return object
*/
private function getMiddleware()
{
if (array_key_exists($this->index, $this->middlewares)) {
if (is_string($this->middlewares[$this->index])) {
$middleware = $this->container->get(
$this->middlewares[$this->index]
);
} else {
$middleware = $this->middlewares[$this->index];
}
$this->index++;
return $middleware;
}
return null;
/home/cookqozi/public_html/src/Framework/Middleware/RendererRequestMiddleware.php
public function __construct(RendererInterface $renderer)
{
$this->renderer = $renderer;
}
public function process(
ServerRequestInterface $request,
RequestHandlerInterface $handler
): ResponseInterface {
$domain = sprintf(
'%s://%s%s',
$request->getUri()->getScheme(),
$request->getUri()->getHost(),
$request->getUri()->getPort()
? ':' . $request->getUri()->getPort()
: ''
);
$this->renderer->addGlobal('domain', $domain);
return $handler->handle($request);
}
}
/home/cookqozi/public_html/src/Framework/Middleware/CombinedMiddlewareDelegate.php
$this->container = $container;
$this->handler = $handler;
}
public function handle(ServerRequestInterface $request): ResponseInterface
{
$middleware = $this->getMiddleware();
if (is_null($middleware)) {
return $this->handler->handle($request);
} elseif (is_callable($middleware)) {
$response = call_user_func_array($middleware, [
$request,
[$this, 'handle'],
]);
if (is_string($response)) {
return new Response(200, [], $response);
}
return $response;
} elseif ($middleware instanceof MiddlewareInterface) {
return $middleware->process($request, $this);
}
}
/**
* @return object
*/
private function getMiddleware()
{
if (array_key_exists($this->index, $this->middlewares)) {
if (is_string($this->middlewares[$this->index])) {
$middleware = $this->container->get(
$this->middlewares[$this->index]
);
} else {
$middleware = $this->middlewares[$this->index];
}
$this->index++;
return $middleware;
}
return null;
/home/cookqozi/public_html/src/Framework/Middleware/MethodMiddleware.php
use Psr\Http\Server\MiddlewareInterface;
use Psr\Http\Server\RequestHandlerInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\ResponseInterface;
class MethodMiddleware implements MiddlewareInterface
{
public function process(
ServerRequestInterface $request,
RequestHandlerInterface $handler
): ResponseInterface {
$parsedBody = $request->getParsedBody();
if (
array_key_exists('_method', $parsedBody) &&
in_array($parsedBody['_method'], ['DELETE', 'PUT'])
) {
$request = $request->withMethod($parsedBody['_method']);
}
return $handler->handle($request);
}
}
/home/cookqozi/public_html/src/Framework/Middleware/CombinedMiddlewareDelegate.php
$this->container = $container;
$this->handler = $handler;
}
public function handle(ServerRequestInterface $request): ResponseInterface
{
$middleware = $this->getMiddleware();
if (is_null($middleware)) {
return $this->handler->handle($request);
} elseif (is_callable($middleware)) {
$response = call_user_func_array($middleware, [
$request,
[$this, 'handle'],
]);
if (is_string($response)) {
return new Response(200, [], $response);
}
return $response;
} elseif ($middleware instanceof MiddlewareInterface) {
return $middleware->process($request, $this);
}
}
/**
* @return object
*/
private function getMiddleware()
{
if (array_key_exists($this->index, $this->middlewares)) {
if (is_string($this->middlewares[$this->index])) {
$middleware = $this->container->get(
$this->middlewares[$this->index]
);
} else {
$middleware = $this->middlewares[$this->index];
}
$this->index++;
return $middleware;
}
return null;
/home/cookqozi/public_html/src/Framework/Middleware/RoutePrefixedMiddleware.php
$this->container = $container;
$this->prefix = $prefix;
$this->middleware = $middleware;
}
public function process(
ServerRequestInterface $request,
RequestHandlerInterface $handler
): ResponseInterface {
$path = $request->getUri()->getPath();
if (strpos($path, $this->prefix) === 0) {
if (is_string($this->middleware)) {
return $this->container
->get($this->middleware)
->process($request, $handler);
} else {
return $this->middleware->process($request, $handler);
}
}
return $handler->handle($request);
}
}
/home/cookqozi/public_html/src/Framework/Middleware/CombinedMiddlewareDelegate.php
$this->container = $container;
$this->handler = $handler;
}
public function handle(ServerRequestInterface $request): ResponseInterface
{
$middleware = $this->getMiddleware();
if (is_null($middleware)) {
return $this->handler->handle($request);
} elseif (is_callable($middleware)) {
$response = call_user_func_array($middleware, [
$request,
[$this, 'handle'],
]);
if (is_string($response)) {
return new Response(200, [], $response);
}
return $response;
} elseif ($middleware instanceof MiddlewareInterface) {
return $middleware->process($request, $this);
}
}
/**
* @return object
*/
private function getMiddleware()
{
if (array_key_exists($this->index, $this->middlewares)) {
if (is_string($this->middlewares[$this->index])) {
$middleware = $this->container->get(
$this->middlewares[$this->index]
);
} else {
$middleware = $this->middlewares[$this->index];
}
$this->index++;
return $middleware;
}
return null;
/home/cookqozi/public_html/src/Framework/Middleware/ForbiddenMiddleware.php
) {
$this->adminPrefix = $adminPrefix;
$this->accountPrefix = $accountPrefix;
$this->loginPath = $loginPath;
$this->session = $session;
$this->auth = $auth;
}
/**
* @param ServerRequestInterface $request
* @param RequestHandlerInterface $handler
* @return ResponseInterface
* @throws \TypeError
*/
public function process(
ServerRequestInterface $request,
RequestHandlerInterface $handler
): ResponseInterface {
try {
return $handler->handle($request);
} catch (ForbiddenException $exception) {
return $this->redirectLogin($request);
} catch (\TypeError $error) {
if (strpos($error->getMessage(), User::class) !== false) {
return $this->redirectLogin($request);
}
throw $error;
}
}
public function redirectLogin(
ServerRequestInterface $request
): ResponseInterface {
$user = $this->auth->getUser();
$uri = $request->getUri()->getPath();
$this->session->set('auth.redirect', $uri);
$flashService = new FlashService($this->session);
if ($user === null) {
$flashService->error(_NOLOG);
return new RedirectResponse($this->loginPath);
/home/cookqozi/public_html/src/Framework/Middleware/CombinedMiddlewareDelegate.php
$this->container = $container;
$this->handler = $handler;
}
public function handle(ServerRequestInterface $request): ResponseInterface
{
$middleware = $this->getMiddleware();
if (is_null($middleware)) {
return $this->handler->handle($request);
} elseif (is_callable($middleware)) {
$response = call_user_func_array($middleware, [
$request,
[$this, 'handle'],
]);
if (is_string($response)) {
return new Response(200, [], $response);
}
return $response;
} elseif ($middleware instanceof MiddlewareInterface) {
return $middleware->process($request, $this);
}
}
/**
* @return object
*/
private function getMiddleware()
{
if (array_key_exists($this->index, $this->middlewares)) {
if (is_string($this->middlewares[$this->index])) {
$middleware = $this->container->get(
$this->middlewares[$this->index]
);
} else {
$middleware = $this->middlewares[$this->index];
}
$this->index++;
return $middleware;
}
return null;
/home/cookqozi/public_html/src/Framework/Middleware/TrackerMiddleware.php
public function __construct(ContainerInterface $container)
{
$this->container = $container;
}
public function process(
ServerRequestInterface $request,
RequestHandlerInterface $handler
): ResponseInterface {
$this->session = $this->container->get(SessionInterface::class);
$this->validSession($this->session);
$visitor = $this->container->get(Visitor::class);
$visitor->track(
$this->session,
$this->sessionKey,
$request,
$this->container
);
return $handler->handle($request);
}
private function validSession($session)
{
if (!is_array($session) && !$session instanceof \ArrayAccess) {
throw new \TypeError(
tradDynamic([_ERRORMIDDLEWARESESSION], 'Tracker')
);
}
}
}
/home/cookqozi/public_html/src/Framework/Middleware/CombinedMiddlewareDelegate.php
$this->container = $container;
$this->handler = $handler;
}
public function handle(ServerRequestInterface $request): ResponseInterface
{
$middleware = $this->getMiddleware();
if (is_null($middleware)) {
return $this->handler->handle($request);
} elseif (is_callable($middleware)) {
$response = call_user_func_array($middleware, [
$request,
[$this, 'handle'],
]);
if (is_string($response)) {
return new Response(200, [], $response);
}
return $response;
} elseif ($middleware instanceof MiddlewareInterface) {
return $middleware->process($request, $this);
}
}
/**
* @return object
*/
private function getMiddleware()
{
if (array_key_exists($this->index, $this->middlewares)) {
if (is_string($this->middlewares[$this->index])) {
$middleware = $this->container->get(
$this->middlewares[$this->index]
);
} else {
$middleware = $this->middlewares[$this->index];
}
$this->index++;
return $middleware;
}
return null;
/home/cookqozi/public_html/src/Framework/Middleware/TrailingSlashMiddleware.php
use Psr\Http\Server\MiddlewareInterface;
use Psr\Http\Server\RequestHandlerInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\ResponseInterface;
use GuzzleHttp\Psr7\Response;
class TrailingSlashMiddleware implements MiddlewareInterface
{
public function process(
ServerRequestInterface $request,
RequestHandlerInterface $handler
): ResponseInterface {
$uri = $request->getUri()->getPath();
if (!empty($uri) && $uri !== '/' && $uri[-1] === '/') {
return (new Response())
->withStatus(301)
->withHeader('Location', substr($uri, 0, -1));
}
return $handler->handle($request);
}
}
/home/cookqozi/public_html/src/Framework/Middleware/CombinedMiddlewareDelegate.php
$this->container = $container;
$this->handler = $handler;
}
public function handle(ServerRequestInterface $request): ResponseInterface
{
$middleware = $this->getMiddleware();
if (is_null($middleware)) {
return $this->handler->handle($request);
} elseif (is_callable($middleware)) {
$response = call_user_func_array($middleware, [
$request,
[$this, 'handle'],
]);
if (is_string($response)) {
return new Response(200, [], $response);
}
return $response;
} elseif ($middleware instanceof MiddlewareInterface) {
return $middleware->process($request, $this);
}
}
/**
* @return object
*/
private function getMiddleware()
{
if (array_key_exists($this->index, $this->middlewares)) {
if (is_string($this->middlewares[$this->index])) {
$middleware = $this->container->get(
$this->middlewares[$this->index]
);
} else {
$middleware = $this->middlewares[$this->index];
}
$this->index++;
return $middleware;
}
return null;
/home/cookqozi/public_html/vendor/middlewares/whoops/src/Whoops.php
$whoops->sendHttpCode(false);
//Catch errors means register whoops globally
if ($this->catchErrors) {
$whoops->register();
$shutdown = function () use ($whoops) {
$whoops->allowQuit(true);
$whoops->writeToOutput(true);
$whoops->sendHttpCode(true);
$method = Run::SHUTDOWN_HANDLER;
$whoops->$method();
};
register_shutdown_function($shutdown);
}
try {
$response = $handler->handle($request);
} catch (\Throwable $exception) {
$response = $this->responseFactory->createResponse(500);
$response->getBody()->write($whoops->$method($exception));
$response = self::updateResponseContentType($response, $whoops);
} finally {
while (ob_get_level() >= $level) {
ob_end_clean();
}
}
if ($this->catchErrors) {
$whoops->unregister();
}
return $response;
}
/**
* Returns the whoops instance or create one.
*/
/home/cookqozi/public_html/src/Framework/Middleware/CombinedMiddlewareDelegate.php
$this->container = $container;
$this->handler = $handler;
}
public function handle(ServerRequestInterface $request): ResponseInterface
{
$middleware = $this->getMiddleware();
if (is_null($middleware)) {
return $this->handler->handle($request);
} elseif (is_callable($middleware)) {
$response = call_user_func_array($middleware, [
$request,
[$this, 'handle'],
]);
if (is_string($response)) {
return new Response(200, [], $response);
}
return $response;
} elseif ($middleware instanceof MiddlewareInterface) {
return $middleware->process($request, $this);
}
}
/**
* @return object
*/
private function getMiddleware()
{
if (array_key_exists($this->index, $this->middlewares)) {
if (is_string($this->middlewares[$this->index])) {
$middleware = $this->container->get(
$this->middlewares[$this->index]
);
} else {
$middleware = $this->middlewares[$this->index];
}
$this->index++;
return $middleware;
}
return null;
/home/cookqozi/public_html/src/Framework/Middleware/CombinedMiddleware.php
private $middlewares;
public function __construct(
ContainerInterface $container,
array $middlewares
) {
$this->container = $container;
$this->middlewares = $middlewares;
}
public function process(
ServerRequestInterface $request,
RequestHandlerInterface $handler
): ResponseInterface {
$handler = new CombinedMiddlewareDelegate(
$this->container,
$this->middlewares,
$handler
);
return $handler->handle($request);
}
}
/home/cookqozi/public_html/src/Framework/App.php
$this->middlewares[] = new RoutePrefixedMiddleware(
$this->getContainer(),
$routePrefix,
$middleware
);
}
return $this;
}
public function handle(ServerRequestInterface $request): ResponseInterface
{
$this->index++;
if ($this->index > 1) {
throw new \Exception();
}
$middleware = new CombinedMiddleware(
$this->getContainer(),
$this->middlewares
);
return $middleware->process($request, $this);
}
public function run(ServerRequestInterface $request): ResponseInterface
{
foreach ($this->modules as $module) {
$this->getContainer()->get($module);
}
return $this->handle($request);
}
/**
* @return ContainerInterface
*/
public function getContainer(): ContainerInterface
{
if ($this->container === null) {
$builder = new ContainerBuilder();
$env = getenv('ENV') ?: 'production';
switch ($env) {
case 'development':
/home/cookqozi/public_html/src/Framework/App.php
public function handle(ServerRequestInterface $request): ResponseInterface
{
$this->index++;
if ($this->index > 1) {
throw new \Exception();
}
$middleware = new CombinedMiddleware(
$this->getContainer(),
$this->middlewares
);
return $middleware->process($request, $this);
}
public function run(ServerRequestInterface $request): ResponseInterface
{
foreach ($this->modules as $module) {
$this->getContainer()->get($module);
}
return $this->handle($request);
}
/**
* @return ContainerInterface
*/
public function getContainer(): ContainerInterface
{
if ($this->container === null) {
$builder = new ContainerBuilder();
$env = getenv('ENV') ?: 'production';
switch ($env) {
case 'development':
case 'staging':
break;
case 'testing':
case 'production':
if (version_compare(PHP_VERSION, '5.3', '>=')) {
error_reporting(
E_ALL &
/home/cookqozi/public_html/webroot/index.php
$container->get(Router::class)->get('/', IndexAction::class, 'home');
$app
->pipe(Whoops::class)
->pipe(TrailingSlashMiddleware::class)
->pipe(TrackerMiddleware::class)
->pipe(ForbiddenMiddleware::class)
->pipe(
$container->get('admin.prefix'),
$container->get(RoleMiddlewareFactory::class)->makeForRole('admin')
)
->pipe(MethodMiddleware::class)
->pipe(RendererRequestMiddleware::class)
->pipe(ForbiddenCsrfMiddleware::class)
->pipe(CsrfMiddleware::class)
->pipe(RouterMiddleware::class)
->pipe(DispatcherMiddleware::class)
->pipe(NotFoundMiddleware::class);
if (php_sapi_name() !== 'cli') {
$response = $app->run(ServerRequest::fromGlobals());
send($response);
}
/**
* Send an HTTP response
*
* @return void
*/
function send(ResponseInterface $response)
{
$http_line = sprintf(
'HTTP/%s %s %s',
$response->getProtocolVersion(),
$response->getStatusCode(),
$response->getReasonPhrase()
);
header($http_line, true, $response->getStatusCode());
foreach ($response->getHeaders() as $name => $values) {