Skip to content

Commit

Permalink
Update core to v 1.2.2
Browse files Browse the repository at this point in the history
New router
Fix more bags
New class for db
Templates
And more..
  • Loading branch information
FlamesONE committed May 7, 2021
1 parent 7eb4c38 commit bac7ca7
Show file tree
Hide file tree
Showing 839 changed files with 13,561 additions and 20,801 deletions.
12 changes: 0 additions & 12 deletions .github/FUNDING.yml

This file was deleted.

Binary file removed .github/authors.png
Binary file not shown.
Binary file removed .github/fastest.png
Binary file not shown.
Binary file removed .github/flags.png
Binary file not shown.
Binary file removed .github/full_adaptation.png
Binary file not shown.
Binary file removed .github/interface.png
Binary file not shown.
Binary file removed .github/just_themes.png
Binary file not shown.
Binary file removed .github/logo.png
Binary file not shown.
Binary file not shown.
Binary file removed .github/modules/module_block_main_stats.png
Binary file not shown.
Binary file removed .github/modules/module_block_main_top.png
Binary file not shown.
Binary file removed .github/modules/module_page_bans.png
Binary file not shown.
Binary file removed .github/modules/module_page_comms.png
Binary file not shown.
Binary file removed .github/modules/module_page_profiles.png
Binary file not shown.
Binary file removed .github/modules/module_page_rankstats.png
Binary file not shown.
Binary file removed .github/modules/module_page_toppoints.png
Binary file not shown.
Binary file removed .github/multi_lingual.png
Binary file not shown.
Binary file removed .github/profile.png
Binary file not shown.
8 changes: 8 additions & 0 deletions .htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
AddDefaultCharset utf-8
DirectoryIndex index.php index.html index.htm
Options -Indexes
RewriteEngine On
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_URI} !\.
RewriteRule ^(.*) %{REQUEST_URI}/ [L,R=301]
RewriteRule !.(gif|jpg|png|ico|css|js|svg|js_controller.php)$ index.php
1,553 changes: 912 additions & 641 deletions README.md

Large diffs are not rendered by default.

308 changes: 308 additions & 0 deletions app/ext/AltoRouter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,308 @@
<?php
/*
MIT License
Copyright (c) 2012 Danny van Kooten <[email protected]>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

namespace app\ext;

class AltoRouter
{

/**
* @var array Array of all routes (incl. named routes).
*/
protected $routes = [];

/**
* @var array Array of all named routes.
*/
protected $namedRoutes = [];

/**
* @var string Can be used to ignore leading part of the Request URL (if main file lives in subdirectory of host)
*/
protected $basePath = '';

/**
* @var array Array of default match types (regex helpers)
*/
protected $matchTypes = [
'i' => '[0-9]++',
'a' => '[0-9A-Za-z]++',
'h' => '[0-9A-Fa-f]++',
'*' => '.+?',
'**' => '.++',
'' => '[^/\.]++'
];

/**
* Create router in one call from config.
*
* @param array $routes
* @param string $basePath
* @param array $matchTypes
* @throws Exception
*/
public function __construct(array $routes = [], $basePath = '', array $matchTypes = [])
{
$this->addRoutes($routes);
$this->setBasePath($basePath);
$this->addMatchTypes($matchTypes);
}

//Поиск роута в массиве
public function SearchRoute()
{
$server = $_SERVER['REQUEST_URI'];
$replace = substr($server, strlen($this->basePath));
$match = explode("/", $replace);
return $match[0];
}

/**
* Retrieves all routes.
* Useful if you want to process or display routes.
* @return array All routes.
*/
public function getRoutes()
{
return $this->routes;
}

/**
* Add multiple routes at once from array in the following format:
*
* $routes = [
* [$method, $route, $target, $name]
* ];
*
* @param array $routes
* @return void
* @author Koen Punt
* @throws Exception
*/
public function addRoutes($routes)
{
if (!is_array($routes) && !$routes instanceof Traversable) {
throw new RuntimeException('Routes should be an array or an instance of Traversable');
}
foreach ($routes as $route) {
call_user_func_array([$this, 'map'], $route);
}
}

/**
* Set the base path.
* Useful if you are running your application from a subdirectory.
* @param string $basePath
*/
public function setBasePath($basePath)
{
$this->basePath = $basePath;
}

/**
* Add named match types. It uses array_merge so keys can be overwritten.
*
* @param array $matchTypes The key is the name and the value is the regex.
*/
public function addMatchTypes(array $matchTypes)
{
$this->matchTypes = array_merge($this->matchTypes, $matchTypes);
}

/**
* Map a route to a target
*
* @param string $method One of 5 HTTP Methods, or a pipe-separated list of multiple HTTP Methods (GET|POST|PATCH|PUT|DELETE)
* @param string $route The route regex, custom regex must start with an @. You can use multiple pre-set regex filters, like [i:id]
* @param mixed $target The target where this route should point to. Can be anything.
* @param string $name Optional name of this route. Supply if you want to reverse route this url in your application.
* @throws Exception
*/
public function map($method, $route, $target, $name = null)
{

$this->routes[] = [$method, $route, $target, $name];

if ($name) {
if (isset($this->namedRoutes[$name])) {
throw new RuntimeException("Can not redeclare route '{$name}'");
}
$this->namedRoutes[$name] = $route;
}

return;
}

/**
* Reversed routing
*
* Generate the URL for a named route. Replace regexes with supplied parameters
*
* @param string $routeName The name of the route.
* @param array @params Associative array of parameters to replace placeholders with.
* @return string The URL of the route with named parameters in place.
* @throws Exception
*/
public function generate($routeName, array $params = [])
{

// Check if named route exists
if (!isset($this->namedRoutes[$routeName])) {
throw new RuntimeException("Route '{$routeName}' does not exist.");
}

// Replace named parameters
$route = $this->namedRoutes[$routeName];

// prepend base path to route url again
$url = $this->basePath . $route;

if (preg_match_all('`(/|\.|)\[([^:\]]*+)(?::([^:\]]*+))?\](\?|)`', $route, $matches, PREG_SET_ORDER)) {
foreach ($matches as $index => $match) {
list($block, $pre, $type, $param, $optional) = $match;

if ($pre) {
$block = substr($block, 1);
}

if (isset($params[$param])) {
// Part is found, replace for param value
$url = str_replace($block, $params[$param], $url);
} elseif ($optional && $index !== 0) {
// Only strip preceding slash if it's not at the base
$url = str_replace($pre . $block, '', $url);
} else {
// Strip match block
$url = str_replace($block, '', $url);
}
}
}

return $url;
}

/**
* Match a given Request Url against stored routes
* @param string $requestUrl
* @param string $requestMethod
* @return array|boolean Array with route information on success, false on failure (no match).
*/
public function match($requestUrl = null, $requestMethod = null)
{

$params = [];

// set Request Url if it isn't passed as parameter
if ($requestUrl === null) {
$requestUrl = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '/';
}

// strip base path from request url
$requestUrl = substr($requestUrl, strlen($this->basePath));

// Strip query string (?a=b) from Request Url
if (($strpos = strpos($requestUrl, '?')) !== false) {
$requestUrl = substr($requestUrl, 0, $strpos);
}

$lastRequestUrlChar = $requestUrl ? $requestUrl[strlen($requestUrl)-1] : '';

// set Request Method if it isn't passed as a parameter
if ($requestMethod === null) {
$requestMethod = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : 'GET';
}

foreach ($this->routes as $handler) {
list($methods, $route, $target, $name) = $handler;

$method_match = (stripos($methods, $requestMethod) !== false);

// Method did not match, continue to next route.
if (!$method_match) {
continue;
}

if ($route === '*') {
// * wildcard (matches all)
$match = true;
} elseif (isset($route[0]) && $route[0] === '@') {
// @ regex delimiter
$pattern = '`' . substr($route, 1) . '`u';
$match = preg_match($pattern, $requestUrl, $params) === 1;
} elseif (($position = strpos($route, '[')) === false) {
// No params in url, do string comparison
$match = strcmp($requestUrl, $route) === 0;
} else {
// Compare longest non-param string with url before moving on to regex
// Check if last character before param is a slash, because it could be optional if param is optional too (see https://github.com/dannyvankooten/AltoRouter/issues/241)
if (strncmp($requestUrl, $route, $position) !== 0 && ($lastRequestUrlChar === '/' || $route[$position-1] !== '/')) {
continue;
}

$regex = $this->compileRoute($route);
$match = preg_match($regex, $requestUrl, $params) === 1;
}
if ($match) {
if ($params) {
foreach ($params as $key => $value) {
if (is_numeric($key)) {
unset($params[$key]);
}
}
}

return [
'target' => $target,
'params' => $params,
'name' => $name
];
}
}

return false;
}

/**
* Compile the regex for a given route (EXPENSIVE)
* @param $route
* @return string
*/
protected function compileRoute($route)
{
if (preg_match_all('`(/|\.|)\[([^:\]]*+)(?::([^:\]]*+))?\](\?|)`', $route, $matches, PREG_SET_ORDER)) {
$matchTypes = $this->matchTypes;
foreach ($matches as $match) {
list($block, $pre, $type, $param, $optional) = $match;

if (isset($matchTypes[$type])) {
$type = $matchTypes[$type];
}
if ($pre === '.') {
$pre = '\.';
}

$optional = $optional !== '' ? '?' : null;

//Older versions of PCRE require the 'P' in (?P<named>)
$pattern = '(?:'
. ($pre !== '' ? $pre : null)
. '('
. ($param !== '' ? "?P<$param>" : null)
. $type
. ')'
. $optional
. ')'
. $optional;

$route = str_replace($block, $pattern, $route);
}
}
return "`^$route$`u";
}
}
34 changes: 30 additions & 4 deletions web_dev/app/ext/Auth.php → app/ext/Auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,39 @@ function __construct( $General, $Db ) {
endif;

// Работа со Steam авторизацией.
isset( $_GET["auth"] ) && $this->General->arr_general['steam_auth'] == 1 && $_GET["auth"] == 'login' && require 'app/includes/auth/steam.php';
if(isset( $_GET["auth"] ))
{
if($this->General->arr_general['steam_auth'] == 1 && $_GET["auth"] == 'login') require 'app/includes/auth/steam.php';
}

// Работа с No-Steam авторизацией
isset( $_POST['log_in'] ) && ! empty( $_POST['_login'] ) && ! empty( $_POST['_pass'] ) && $this->General->arr_general['steam_only_authorization'] === 0 && $this->authorization_no_steam();

// Выход пользователя из аккаунта.
isset( $_GET["auth"] ) && $_GET["auth"] == 'logout' && require 'app/includes/auth/steam.php';

( $General->arr_general['auth_cock'] == 1 && !empty($_SESSION) && empty($_COOKIE['session']) ) && $this->check_cookie();

( $General->arr_general['auth_cock'] == 1 && empty($_SESSION) && !empty($_COOKIE['session']) ) && $this->auth_cookie();

if( $General->arr_general['auth_cock'] == 0 && !empty( $_COOKIE['session'] ) )
unset($_COOKIE['session']);
}

// Запись в куки данных о сессии
private function check_cookie()
{
foreach ($_SESSION as $key => $val)
{
setcookie("session[".$key."]", $val, strtotime('+1 day'));
}
}

// Авторизация пользователя с помощью куки
private function auth_cookie()
{
$_SESSION = $_COOKIE['session'];
refresh();
}

/**
Expand Down Expand Up @@ -168,13 +194,13 @@ public function authorization_no_steam() {
// Сверка результата запроса.
if ( ! empty( $result ) ):
// Пользователь. Общее значение - Steam ID 32.
$_SESSION['steamid'] = $result['steamid'];
$_SESSION['steamid'] = con_steam64to32( $result['steamid'] );

// Пользователь. Steam ID 32.
$_SESSION['steamid32'] = $result['steamid'];
$_SESSION['steamid32'] = con_steam64to32( $result['steamid'] );

// Пользователь. Steam ID 64.
$_SESSION['steamid64'] = con_steam32to64( $result['steamid'] );
$_SESSION['steamid64'] = con_steam32to64 ($result['steamid'] );

// Пользователь. Заголовок User-Agent.
$_SESSION['USER_AGENT'] = $_SERVER['HTTP_USER_AGENT'];
Expand Down
Loading

0 comments on commit bac7ca7

Please sign in to comment.