/home/kornich/htdocs/kornich.com/framework/Response.php
throw new \Exception("Template not found: $path");
}
$content = file_get_contents($templatePath);
$content = str_replace("__DIR__", '"' . dirname($templatePath) . '"', $content);
self::ensureDirectories([dirname(self::$_thonem_cached_template)]);
file_put_contents(self::$_thonem_cached_template, OutputProcessor($content));
}
/**
* Compile template with layout
* @param string $template
*/
private static function compileTemplateWithLayout(string $template): void
{
$templatePath = self::getTemplate($template, self::$interface);
if (!file_exists($templatePath)) {
throw new \Exception("Template not found: $template");
}
$layoutPath = self::getTemplate("layout/" . self::$layout, self::$interface);
$templateContent = file_get_contents($templatePath);
$content = file_exists($layoutPath)
? str_replace('{layout}', $templateContent, file_get_contents($layoutPath))
: $templateContent;
$content = str_replace("__DIR__", '"' . dirname($templatePath) . '"', $content);
self::ensureDirectories([dirname(self::$_thonem_cached_template)]);
file_put_contents(self::$_thonem_cached_template, ($content));
}
/**
* Render compiled template
* @param array|null $data
* @return string
*/
/home/kornich/htdocs/kornich.com/framework/Response.php
if ($interface) {
self::$interface = $interface;
}
if ($module) {
self::$module = $module;
}
self::$_thonem_data = array_merge($data, [
"config" => (object)\Library\Configurations::$data,
"prop" => (object)self::$props,
"template_folder" => self::$interface ?: "general"
]);
$cacheKey = str_replace("/", "*", $template) . '$' . md5($template);
self::$_thonem_cached_template = TEMPLATES_CACHE_PATH . self::$_thonem_data["template_folder"] . "/" . $cacheKey . ".template";
if (!file_exists(self::$_thonem_cached_template) || DEBUG) {
self::loadThemeAssets();
self::compileTemplateWithLayout($template);
}
$buffer = self::renderTemplate();
if ($return) {
self::$interface = $originalInterface;
return $buffer;
}
self::sendOutput($buffer);
if (PROFILER && self::$layout !== "ajax") {
Timeline::mark('Fully rendered');
Debugger::render();
}
self::$interface = $originalInterface;
return null;
}
/home/kornich/htdocs/kornich.com/modules/realestate/controllers/Search.php
"order_by" => ["properties.property_id" => "DESC"]
];
if (get("q")) {
$filter["grouped_or_like"]["title"] = get("q");
}
$config['url'] = url('search/index');
$config['total'] = $model->find($filter, true);
$config['limit'] = config('limit');
$config['reuse_query_string'] = true;
$config['offset'] = $offset;
$pagination = new \Library\Pagination($config);
$this->data['pagination'] = $pagination->create_links();
$this->data["items"] = $model->find($filter);
$this->data["total"] = $config['total'];
$this->data["items"] = prepareProperties($this->data["items"], LANG);
return \Response::render(strtolower(__CLASS__) . '/index', $this->data);
}
}
/home/kornich/htdocs/kornich.com/framework/Router.php
$controllerInstance = new $Route['controller'];
// GET ACTION TO RUN (DEFAULT TO 'index' IF NOT PROVIDED)
$method = isset($this->segments[$Route['method'] + 1]) ? $this->segments[$Route['method'] + 1] : 'index';
// If the method doesn't exist, try 'index' by default
if (!method_exists($controllerInstance, $method)) {
if (method_exists($controllerInstance, 'index')) {
$method = 'index';
} else {
\Thonem::error404();
}
}
// GET PARAMS
$params = array_slice($this->segments, $Route['method'] + 2, count($this->segments) - 1);
// RUN THE CONTROLLER METHOD
return $controllerInstance->{$method}(...$params);
}
/**
* Search for the controller
* @param $segment
* @return array|bool
*/
private function getController($segment = 0)
{
global $ThonemMap;
if (count($this->segments) - 1 < $segment)
return false;
if (isset($this->segments[$segment + 1])) {
if (isset($ThonemMap->Controller->{$this->segments[$segment] . '/' . ucfirst($this->segments[$segment + 1])})) {
$suggestController = $ThonemMap->Controller->{$this->segments[$segment] . '/' . ucfirst($this->segments[$segment + 1])};
if ($suggestController) {
return [
/home/kornich/htdocs/kornich.com/framework/Router.php
foreach ($this->route as $pattern => $real_route) {
// Use the built-in delimiter and avoid manually adding slashes
$pattern = "#^" . str_replace(array_keys($this->replace), array_values($this->replace), $pattern) . "$#u";
// Check if $real_route is an array or a string
if (preg_match($pattern, $this->current, $match)) {
if (is_array($real_route)) {
// If $real_route is an array, decide how to handle it (e.g., join into a string)
// Example: join the array into a string, or handle appropriately for your use case
$real_route_string = implode('/', $real_route); // Example: You can change this logic
$this->segments = explode('/', preg_replace($pattern, $real_route_string, $this->current));
} else {
// If $real_route is already a string, just proceed
$this->segments = explode('/', preg_replace($pattern, $real_route, $this->current));
}
}
}
return $this->detect();
}
/**
* DETECT THE CURRENT ROUTE
*/
public function detect()
{
// IT'S NOT THE DEFAULT ROUTE, FIND THE MENTIONED CONTROLLER
$Route = $this->getController();
if (isset($Route["module"]))
define("MODULE", $Route["module"]);
else
define("MODULE", false);
if (!$Route)
\Thonem::error404();
if (preg_match("/" . str_replace(['/', '*'], ['\\' . '/', '([a-zA-Z0-9_-]+)'], MODULES_PATH . "*/controllers/") . "/", $Route['path'], $res)) {
\Thonem::$currentModule = $res[1];
/home/kornich/htdocs/kornich.com/framework/Thonem.php
/**
* Main function of the framework to run
*/
public static function run()
{
if(DEBUG){
self::add(new Debug());
}
self::add(new Loader());
self::get("Loader")->boot();
(new \Library\Ban())->run();
// self::get("Router")->get('/blog/', 'Blog@index');
// self::get("Router") ->post('/submit', 'FormController@submit');
// self::get("Router")->dispatch(Request::$URI, Request::$METHOD);
self::get("Router")->run();
}
public static function ao($object, $path, $default_value = null){
foreach(explode(".", $path) as $key) {
if(is_object($object)) {
if(!isset($object->$key))
return $default_value;
$object = $object->$key;
}
if(is_array($object)) {
if(!isset($object[$key]))
return $default_value;
$object = $object[$key];
}
}
return $object;
}
public static function getMap(){
/home/kornich/htdocs/kornich.com/framework/Request.php
// Finalize URI processing
self::$URI = trim($uri, '/');
// Set request method and headers
self::$METHOD = $_SERVER['REQUEST_METHOD'] ?? 'GET';
self::$HEADERS = self::getAllHeaders();
// Check for maintenance mode
if (CLOSE && !DEBUG) {
Thonem::underMaintenance(1010);
}
// Process JSON input
self::processJsonInput();
// Load composer autoload if exists
self::loadVendorAutoload();
// Run the application
(new \Thonem())->run();
define('THONEM_END_TIME', microtime(true));
}
private static function validateHost(): void {
if (!CLI_MODE && parse_url(URL, PHP_URL_HOST) != ($_SERVER["HTTP_HOST"] ?? '')) {
header("location: ".URL);
exit;
}
}
// private static function determineUri(): string {
// if (CLI_MODE) {
// return $_SERVER['argv'][1] ?? '/';
// }
//
// // Determine routing path
// self::$ROUTING_PATH = strtoupper($_ENV["ROUTING_PATH"] ?? '');
//
// if (self::$ROUTING_PATH == "AUTO") {
/home/kornich/htdocs/kornich.com/Bootstrap.php
}
});
try {
if(PROFILER){
Debugger::init();
Timeline::mark('Bootstrap Start');
}
header_remove("Server");
header("Server: Thonem v". VERSION);
header("X-Powered-By: Thonem");
header("Powered-By: Thonem");
header("Thonem-Version:". VERSION);
header("Thonem-Token:". rand(000000,999999));
if(PROFILER){
Timeline::mark('Controller Invoked');
$_SERVER['REQUEST_TIME_FLOAT'] = microtime(true);
}
Request::run();
} catch (Exception $e) {
$error = [
"message" => $e->getMessage(),
"file" => $e->getFile(),
"line" => $e->getLine(),
"code" => $e->getCode(),
"trace" => $e->getTrace()
];
if (DEBUG) {
if(PROFILER)
Debugger::addPanel(new ErrorPanel());
$prettyHandler = new Whoops\Handler\PrettyPageHandler();
$whoops = new \Whoops\Run;
$whoops->allowQuit(false);
$whoops->writeToOutput(false);
$whoops->pushHandler(function ($e, $inspector, $run) {
if(PROFILER)
ErrorPanel::capture($e);
/home/kornich/htdocs/kornich.com/index.php
<?php
declare(strict_types=1);
if(isset($_SERVER['REQUEST_URI'])) {
$clean_uri = strtok($_SERVER['REQUEST_URI'], '?');
$_SERVER['REQUEST_URI'] = $clean_uri;
}
define("THONEM_IDX", __DIR__.'/');
require_once __DIR__."/Bootstrap.php";