/var
/www
/html
/site
/controllers
/contact.php
<?php
use Uniform\Form;
return function ($kirby) {
$form = new Form([
'email' => [
'rules' => ['required', 'email'],
'message' => 'Please provide a valid email',
],
'subject' => [],
'message' => [
'rules' => ['required'],
'message' => 'Please enter a message',
],
'captcha' => [
'rules' => ['required', 'num'],
'message' => 'Please fill in the captcha field',
],
]);
if ($kirby->request()->is('POST')) {
$form->honeypotGuard()->calcGuard(['captcha' => 'result'])->emailAction([
'to' => '[email protected]',
'from' => $form->data('email'),
'subject' => 'Affiliaterush.com - Feedback Form '.$form->data('email')
]);
}
return compact('form');
};
/var
/www
/html
/kirby
/src
/Toolkit
/Controller.php
if (isset($data[$name]) === false) {
throw new Exception(sprintf('The "%s" parameter is missing', $name));
}
$args[] = $data[$name];
}
return $args;
}
public function call($bind = null, $data = [])
{
$args = $this->arguments($data);
if ($bind === null) {
return call_user_func($this->function, ...$args);
}
return $this->function->call($bind, ...$args);
}
public static function load(string $file)
{
if (file_exists($file) === false) {
return null;
}
$function = require $file;
if (is_a($function, 'Closure') === false) {
return null;
}
return new static($function);
}
}
/var
/www
/html
/kirby
/src
/Cms
/App.php
*/
public function contentIgnore(): array
{
return $this->options['content']['ignore'] ?? Dir::$ignore;
}
/**
* Calls a page controller by name
* and with the given arguments
*
* @param string $name
* @param array $arguments
* @return array
*/
public function controller(string $name, array $arguments = [], string $contentType = 'html'): array
{
$name = basename(strtolower($name));
if ($controller = $this->controllerLookup($name, $contentType)) {
return (array)$controller->call($this, $arguments);
}
if ($contentType !== 'html') {
// no luck for a specific representation controller?
// let's try the html controller instead
if ($controller = $this->controllerLookup($name)) {
return (array)$controller->call($this, $arguments);
}
}
// still no luck? Let's take the site controller
if ($controller = $this->controllerLookup('site')) {
return (array)$controller->call($this, $arguments);
}
return [];
}
/**
/var
/www
/html
/kirby
/src
/Cms
/Page.php
/**
* Call the page controller
*
* @param array $data
* @param string $contentType
* @return array
*/
public function controller($data = [], $contentType = 'html'): array
{
// create the template data
$data = array_merge($data, [
'kirby' => $kirby = $this->kirby(),
'site' => $site = $this->site(),
'pages' => $site->children(),
'page' => $site->visit($this)
]);
// call the template controller if there's one.
return array_merge($kirby->controller($this->template()->name(), $data, $contentType), $data);
}
/**
* Returns a number indicating how deep the page
* is nested within the content folder
*
* @return integer
*/
public function depth(): int
{
return $this->depth = $this->depth ?? (substr_count($this->id(), '/') + 1);
}
/**
* Sorting number + Slug
*
* @return string
*/
public function dirname(): string
{
/var
/www
/html
/kirby
/src
/Cms
/Page.php
$kirby = $this->kirby();
$cache = $cacheId = $html = null;
// try to get the page from cache
if (empty($data) === true && $this->isCacheable() === true) {
$cache = $kirby->cache('pages');
$cacheId = $this->cacheId($contentType);
$result = $cache->get($cacheId);
$html = $result['html'] ?? null;
$response = $result['response'] ?? [];
// reconstruct the response configuration
if (empty($html) === false && empty($response) === false) {
$kirby->response()->fromArray($response);
}
}
// fetch the page regularly
if ($html === null) {
$kirby->data = $this->controller($data, $contentType);
if ($contentType === 'html') {
$template = $this->template();
} else {
$template = $this->representation($contentType);
}
if ($template->exists() === false) {
throw new NotFoundException([
'key' => 'template.default.notFound'
]);
}
// render the page
$html = $template->render($kirby->data);
// convert the response configuration to an array
$response = $kirby->response()->toArray();
// cache the result
/var
/www
/html
/kirby
/src
/Cms
/App.php
}
// Empty input
if (empty($input) === true) {
return $this->io(new NotFoundException());
}
// Response Configuration
if (is_a($input, 'Kirby\Cms\Responder') === true) {
return $input->send();
}
// Responses
if (is_a($input, 'Kirby\Http\Response') === true) {
return $input;
}
// Pages
if (is_a($input, 'Kirby\Cms\Page')) {
$html = $input->render();
if ($input->isErrorPage() === true) {
if ($response->code() === null) {
$response->code(404);
}
}
return $response->send($html);
}
// Files
if (is_a($input, 'Kirby\Cms\File')) {
return $response->redirect($input->mediaUrl(), 307)->send();
}
// Simple HTML response
if (is_string($input) === true) {
return $response->send($input);
}
/var
/www
/html
/kirby
/src
/Cms
/App.php
$requestUri = '/' . $this->request()->url()->path();
$scriptName = $_SERVER['SCRIPT_NAME'];
$scriptFile = basename($scriptName);
$scriptDir = dirname($scriptName);
$scriptPath = $scriptFile === 'index.php' ? $scriptDir : $scriptName;
$requestPath = preg_replace('!^' . preg_quote($scriptPath) . '!', '', $requestUri);
return $this->setPath($requestPath)->path;
}
/**
* Returns the Response object for the
* current request
*
* @return Response
*/
public function render(string $path = null, string $method = null)
{
return $this->io($this->call($path, $method));
}
/**
* Returns the Request singleton
*
* @return Request
*/
public function request(): Request
{
return $this->request = $this->request ?? new Request;
}
/**
* Path resolver for the router
*
* @param string $path
* @param string|null $language
* @return mixed
*/
public function resolve(string $path = null, string $language = null)
<?php
require __DIR__ . '/kirby/bootstrap.php';
echo (new Kirby)->render();