/var/www/html/szablon1/vendor/eftec/bladeone/lib/BladeOne.php
/**
* Evaluates a compiled file using the current variables
*
* @param string $compiledFile full path of the compile file.
* @param array $variables
* @return string
* @throws Exception
*/
protected function evaluatePath($compiledFile, $variables): string
{
\ob_start();
// note, the variables are extracted locally inside this method,
// they are not global variables :-3
\extract($variables);
// We'll evaluate the contents of the view inside a try/catch block, so we can
// flush out any stray output that might get out before an error occurs or
// an exception is thrown. This prevents any partial views from leaking.
try {
include $compiledFile;
} catch (Exception $e) {
$this->handleViewException($e);
}
return \ltrim(\ob_get_clean());
}
/**
* @param array $views array of views
* @param array $value
* @return string
* @throws Exception
*/
public function includeFirst($views = [], $value = []): string
{
foreach ($views as $view) {
if ($this->templateExist($view)) {
return $this->runChild($view, $value);
}
}
return '';
/var/www/html/szablon1/vendor/eftec/bladeone/lib/BladeOne.php
/**
* Evaluates a compiled file using the current variables
*
* @param string $compiledFile full path of the compile file.
* @param array $variables
* @return string
* @throws Exception
*/
protected function evaluatePath($compiledFile, $variables): string
{
\ob_start();
// note, the variables are extracted locally inside this method,
// they are not global variables :-3
\extract($variables);
// We'll evaluate the contents of the view inside a try/catch block, so we can
// flush out any stray output that might get out before an error occurs or
// an exception is thrown. This prevents any partial views from leaking.
try {
include $compiledFile;
} catch (Exception $e) {
$this->handleViewException($e);
}
return \ltrim(\ob_get_clean());
}
/**
* @param array $views array of views
* @param array $value
* @return string
* @throws Exception
*/
public function includeFirst($views = [], $value = []): string
{
foreach ($views as $view) {
if ($this->templateExist($view)) {
return $this->runChild($view, $value);
}
}
return '';
/var/www/html/szablon1/vendor/eftec/bladeone/lib/BladeOne.php
//$this->variablesGlobal = []; // used so we delete it.
} else {
$this->variables = $variables;
}
if (!$runFast) {
// a) if the "compile" is forced then we compile the original file, then save the file.
// b) if the "compile" is not forced then we read the datetime of both file, and we compared.
// c) in both cases, if the compiled doesn't exist then we compile.
if ($view) {
$this->fileName = $view;
}
$result = $this->compile($view, $forced);
if (!$this->isCompiled) {
return $this->evaluateText($result, $this->variables);
}
} elseif ($view) {
$this->fileName = $view;
}
$this->isRunFast = $runFast;
return $this->evaluatePath($this->getCompiledFile(), $this->variables);
}
protected function evalComposer($view): void
{
foreach ($this->composerStack as $viewKey => $fn) {
if ($this->wildCardComparison($view, $viewKey)) {
if (is_callable($fn)) {
$fn($this);
} elseif ($this->methodExistsStatic($fn, 'composer')) {
// if the method exists statically then $fn is the class and 'composer' is the name of the method
$fn::composer($this);
} elseif (is_object($fn) || class_exists($fn)) {
// if $fn is an object, or it is a class and the class exists.
$instance = (is_object($fn)) ? $fn : new $fn();
if (method_exists($instance, 'composer')) {
// and the method exists inside the instance.
$instance->composer($this);
} else {
if ($this->mode === self::MODE_DEBUG) {
$this->showError('evalComposer', "BladeOne: composer() added an incorrect method [$fn]", true, true);
/var/www/html/szablon1/vendor/eftec/bladeone/lib/BladeOne.php
public function run($view = null, $variables = []): string
{
$mode = $this->getMode();
if ($view === null) {
$view = $this->viewStack;
}
$this->viewStack = null;
if ($view === null) {
$this->showError('run', 'BladeOne: view not set', true);
return '';
}
$forced = $mode & 1; // mode=1 forced:it recompiles no matter if the compiled file exists or not.
$runFast = $mode & 2; // mode=2 runfast: the code is not compiled neither checked, and it runs directly the compiled
$this->sections = [];
if ($mode == 3) {
$this->showError('run', "we can't force and run fast at the same time", true);
}
return $this->runInternal($view, $variables, $forced, true, $runFast);
}
/**
* It sets the current view<br>
* This value is cleared when it is used (method run).<br>
* <b>Example:<b><br>
* <pre>
* $this->setView('folder.view')->share(['var1'=>20])->run(); // or $this->run('folder.view',['var1'=>20]);
* </pre>
*
* @param string $view
* @return BladeOne
*/
public function setView($view): BladeOne
{
$this->viewStack = $view;
return $this;
}
/**
/var/www/html/szablon1/index.php
<?php
/**
* Created with love by: Patryk Vizauer (wizjoner.dev)
* Date: 02.11.2022 13:50
* Using: PhpStorm
*/
require_once __DIR__ . '/vendor/autoload.php';
$config = require_once __DIR__ . '/app/config.php';
require_once __DIR__ . '/app/WhoopsHandler.php';
require_once __DIR__ . '/app/Routing/routes.php';
$blade = new \eftec\bladeone\BladeOne(__DIR__ . '/views', __DIR__ . '/views_cache', \eftec\bladeone\BladeOne::MODE_AUTO);
function view(string $view, array $variables = [])
{
global $blade, $config;
return $blade->run($view, $variables + ['config' => $config]);
}
date_default_timezone_set('Europe/Warsaw');
session_name('spaceis-v4-template-session');
session_start();
echo $router->handle($_SERVER, $config);
/var/www/html/szablon1/app/Controllers/VoucherController.php
<?php
/**
* Created with love by: Patryk Vizauer (wizjoner.dev)
* Date: 02.11.2022 16:17
* Using: PhpStorm
*/
namespace App\Controllers;
use App\Validation\Validator;
class VoucherController extends BaseController
{
public function getFrontend()
{
return view('voucher');
}
public function execute()
{
Validator::make([
'nick' => 'required|minecraftNick',
'code' => 'required',
], $_POST);
$apiRequest = $this->apiRequest('voucher', 'POST', [
'nick' => $_POST['nick'],
'code' => $_POST['code'],
], false);
$status = $apiRequest->getStatusCode();
$json = json_decode($apiRequest->getBody());
if ($status == 200) {
return redirect('/transaction_status/' . $json->data->transactionId);
} else if ($status == 403) {
$_SESSION['error'] = 'Voucher został już wykorzystany.';
} else {
$_SESSION['error'] = 'Błędny kod vouchera.';
/var/www/html/szablon1/app/Routing/Router.php
if(empty($_POST['_token']) || $_POST['_token'] != getCsrf()) {
$_SESSION['error'] = 'Błędny token CSRF';
return redirect($route);
}
}
try {
[$controller, $args] = $this->routeManager->resolve($httpMethod, $route);
[$controllerName, $function] = $controller;
$controller = new $controllerName;
if (!$controller instanceof BaseController) {
throw new \LogicException(sprintf('%s must be an instance of BaseController', $controllerName));
}
$controller->setConfig($config);
return $controller->$function(...$args);
} catch (RouteNotFoundException) {
http_response_code(404);
return view('404');
}
}
}
/var/www/html/szablon1/index.php
* Date: 02.11.2022 13:50
* Using: PhpStorm
*/
require_once __DIR__ . '/vendor/autoload.php';
$config = require_once __DIR__ . '/app/config.php';
require_once __DIR__ . '/app/WhoopsHandler.php';
require_once __DIR__ . '/app/Routing/routes.php';
$blade = new \eftec\bladeone\BladeOne(__DIR__ . '/views', __DIR__ . '/views_cache', \eftec\bladeone\BladeOne::MODE_AUTO);
function view(string $view, array $variables = [])
{
global $blade, $config;
return $blade->run($view, $variables + ['config' => $config]);
}
date_default_timezone_set('Europe/Warsaw');
session_name('spaceis-v4-template-session');
session_start();
echo $router->handle($_SERVER, $config);