2019-02-25 19:33:23 +03:00
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @package Kleeja
|
2020-04-11 22:45:48 +02:00
|
|
|
* @copyright (c) 2007 Kleeja.net
|
2019-02-25 19:33:23 +03:00
|
|
|
* @license ./docs/license.txt
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* We are in serve.php file, useful for exceptions
|
|
|
|
|
*/
|
|
|
|
|
define('IN_SERVE', true);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Defaults rewrite rules
|
|
|
|
|
*/
|
2019-05-03 23:52:08 +03:00
|
|
|
$rules = [
|
|
|
|
|
'^index.html$' => ['file' => 'index.php'],
|
|
|
|
|
'^download([0-9]*).html$' => ['file' => 'do.php', 'args' => 'id=$1'],
|
|
|
|
|
'^downloadf-(.*)-([a-zA-Z0-9_-]*).html$' => ['file' => 'do.php', 'args' =>'filename=$1&x=$2'],
|
|
|
|
|
'^down-([0-9]*).html$' => ['file' => 'do.php', 'args' => 'down=$1'],
|
|
|
|
|
'^downf-(.*)-([a-zA-Z0-9_-]*).html$' => ['file' => 'do.php', 'args' => 'downf=$1&x=$2'],
|
|
|
|
|
'^downex-([0-9]*).html$' => ['file' => 'do.php', 'args' => 'down=$1'],
|
|
|
|
|
'^downexf-(.*)-([a-zA-Z0-9_-]*).html$' => ['file' =>'do.php', 'args' => 'downexf=$1&x=$2'],
|
|
|
|
|
'^thumb([0-9]*).html$' => ['file' => 'do.php', 'args' => 'thmb=$1'],
|
|
|
|
|
'^imagef-(.*)-([a-zA-Z0-9_-]*).html$' => ['file' =>'do.php', 'args' => 'imgf=$1&x=$2'],
|
|
|
|
|
'^thumbf-(.*)-([a-zA-Z0-9_-]*).html$' => ['file' => 'do.php', 'args' => 'thmbf=$1&x=$2'],
|
|
|
|
|
'^image([0-9]*).html$' => ['file' => 'do.php', 'args' => 'img=$1'],
|
|
|
|
|
'^del([a-zA-Z0-9_-]*).html$' => ['file' => 'go.php', 'args' => 'go=del&cd=$1'],
|
|
|
|
|
'^(call|guide|rules|stats|report).html$' => ['file' =>'go.php', 'args' => 'go=$1'],
|
|
|
|
|
'^report[_-]([0-9]*).html$' => ['file' => 'go.php', 'args' => 'go=report&id=$1'],
|
2019-02-25 19:33:23 +03:00
|
|
|
'^(filecp|profile|fileuser|register|login|logout).html$' => ['file' => 'ucp.php', 'args' => 'go=$1'],
|
2019-05-03 23:52:08 +03:00
|
|
|
'^fileuser[_-]([0-9]+).html$' => ['file' => 'ucp.php', 'args' => 'go=fileuser&id=$1'],
|
|
|
|
|
'^fileuser[_-]([0-9]+)-([0-9]+).html$' => ['file' => 'ucp.php', 'args' => 'go=fileuser&id=$1&page=$2'],
|
2019-02-25 19:33:23 +03:00
|
|
|
// #for future plugins
|
|
|
|
|
'^go-(.*).html$' => ['file' => 'go.php', 'args' => 'go=$1'],
|
2019-05-03 23:52:08 +03:00
|
|
|
];
|
2019-02-25 19:33:23 +03:00
|
|
|
|
2019-05-18 16:58:43 +03:00
|
|
|
|
|
|
|
|
if (file_exists('plugins_rules.php'))
|
|
|
|
|
{
|
|
|
|
|
$plugins_rules = include_once 'plugins_rules.php';
|
2019-05-25 00:30:55 +03:00
|
|
|
$rules = array_merge($rules, $plugins_rules);
|
2019-05-18 16:58:43 +03:00
|
|
|
}
|
|
|
|
|
|
2019-08-21 16:37:34 +03:00
|
|
|
$base_folder = str_replace('/serve.php', '', parse_url('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'], PHP_URL_PATH));
|
2024-10-07 17:15:05 +01:00
|
|
|
$request_uri = preg_replace('/^' . preg_quote($base_folder, '/') . '\//', '', strtok($_SERVER['REQUEST_URI'], '?'));
|
2019-02-25 19:33:23 +03:00
|
|
|
|
2019-05-03 23:52:08 +03:00
|
|
|
foreach ($rules as $rule_regex => $rule_result)
|
2019-02-25 19:33:23 +03:00
|
|
|
{
|
2019-05-03 23:52:08 +03:00
|
|
|
if (preg_match("/{$rule_regex}/", $request_uri, $matches))
|
2019-02-25 19:33:23 +03:00
|
|
|
{
|
2019-05-03 23:52:08 +03:00
|
|
|
if (! empty($rule_result['args']))
|
2019-02-25 19:33:23 +03:00
|
|
|
{
|
|
|
|
|
parse_str($rule_result['args'], $args);
|
|
|
|
|
|
2019-05-03 23:52:08 +03:00
|
|
|
foreach ($args as $arg_key => $arg_value)
|
2019-02-25 19:33:23 +03:00
|
|
|
{
|
2019-05-03 23:52:08 +03:00
|
|
|
if (preg_match('/^\$/', $arg_value))
|
2019-02-25 19:33:23 +03:00
|
|
|
{
|
|
|
|
|
$match_number = ltrim($arg_value, '$');
|
|
|
|
|
|
2019-05-03 23:52:08 +03:00
|
|
|
if (isset($matches[$match_number]))
|
2019-02-25 19:33:23 +03:00
|
|
|
{
|
|
|
|
|
$_GET[$arg_key] = $matches[$match_number];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
$_GET[$arg_key] = $arg_value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
include $rule_result['file'];
|
2019-05-03 23:52:08 +03:00
|
|
|
|
2019-02-25 19:33:23 +03:00
|
|
|
exit;
|
|
|
|
|
}
|
2019-02-25 19:55:13 +03:00
|
|
|
}
|
|
|
|
|
|
2019-05-03 23:52:08 +03:00
|
|
|
//fallback
|
2019-02-25 19:55:13 +03:00
|
|
|
define('SERVE_FALLBACK', true);
|
2019-05-03 23:52:08 +03:00
|
|
|
include 'go.php';
|