Skip to content

Commit

Permalink
Error correction, update functional
Browse files Browse the repository at this point in the history
  • Loading branch information
denis-skripnik committed Aug 20, 2022
1 parent d37c531 commit 102574d
Show file tree
Hide file tree
Showing 14 changed files with 135 additions and 32 deletions.
43 changes: 43 additions & 0 deletions .htaccess
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
php_flag display_startup_errors off
php_flag display_errors off
php_flag html_errors off
php_flag log_errors on
php_flag ignore_repeated_errors off
php_flag ignore_repeated_source off
php_flag report_memleaks on
php_flag track_errors on
php_value docref_root 0
php_value docref_ext 0
php_value error_log /home/s/scadens/dpos.space/public_html/PHP_errors.log
php_value error_reporting 2047
php_value log_errors_max_len 0


<Files "PHP_errors.log">
Require all denied
Expand All @@ -8,6 +22,16 @@
#php_flag html_errors off
#php_value max_execution_time 120000

#редирект для поддомена api
RewriteCond %{HTTP_HOST} ^(www\.)?api\.dpos\.space$ [NC]
RewriteCond %{REQUEST_URI} !^/api/
RewriteRule ^(.*)$ api/$1 [L]

#редрект для поддомена viz
RewriteCond %{HTTP_HOST} ^(www\.)?viz\.dpos\.space$ [NC]
RewriteCond %{REQUEST_URI} !^/viz-manual/
RewriteRule ^(.*)$ viz-manual/$1 [L]

#Редирект на https
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule (.*) https://%{HTTP_HOST}/$1 [L,R=301]
Expand All @@ -30,6 +54,25 @@ RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

Options +FollowSymLinks
RedirectPermanent /golos-top https://dpos.space/golos/top
RedirectPermanent /golos-donates https://dpos.space/golos/donates
RedirectPermanent /viz/buy https://dpos.space/viz/exchanges
RedirectPermanent /viz-top https://dpos.space/viz/top
RedirectPermanent /golos-polls https://dpos.space/golos/polls
RedirectPermanent /randomblockchain https://dpos.space/viz/randomblockchain
RedirectPermanent /dev https://dpos.space
RedirectMatch 301 ^/calc/(.*) https://dpos.space/$1/calc
RedirectMatch 301 ^/post/(.*) https://dpos.space/$1/post
RedirectMatch 301 ^/backup/(.*) https://dpos.space/$1/backup
RedirectMatch 301 ^/profiles/(.*)/(.*) https://dpos.space/$2/profiles/$1/

RewriteCond %{QUERY_STRING} chain=(.*) [NC]
RewriteCond %{QUERY_STRING} block1=(.*) [NC]
RewriteCond %{QUERY_STRING} block2=(.*) [NC]
RewriteCond %{QUERY_STRING} participants=(.*) [NC]
RewriteRule ^(.*)$ /(.*)/? [R=301,L]
</IfModule>

<IfModule mod_expires.c>
Expand Down
7 changes: 2 additions & 5 deletions blockchains/cyber/apps/explorer/content.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php if (!defined('NOTLOAD')) exit('No direct script access allowed');
function node($params) {
$html = file_get_contents('https://deimos.cybernode.ai/'.$params);
$html = file_get_contents('https://rpc.cyber.posthuman.digital/'.$params);
$data = json_decode($html, true);
return $data['result'];
}
Expand Down Expand Up @@ -36,10 +36,7 @@ function node($params) {
<li>Номер последнего блока: '.$status['sync_info']['latest_block_height'].'</li>
<li>Дата и время последнего блока: '.$status['sync_info']['latest_block_time'].'</li>
<li>Адрес валидатора: '.$status['validator_info']['address'].'</li>
<li>тип публичного ключа: '.$status['validator_info']['pub_key']['type'].', ключ: '.$status['validator_info']['pub_key']['value'].'</li>';
$index_stats = node('index_stats?');
$content .= '<li>Число ссылок: '.$index_stats['linksCount'].'</li>
<li>Число аккаунтов: '.$index_stats['accountsCount'].'</li>
<li>тип публичного ключа: '.$status['validator_info']['pub_key']['type'].', ключ: '.$status['validator_info']['pub_key']['value'].'</li>
</ul>
<p align="center"><a href="#contents">К оглавлению</a></p>';
return $content;
Expand Down
2 changes: 1 addition & 1 deletion blockchains/cyber/apps/explorer/pages/block/content.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function convert_operation_data($arr, $site_url) {
}

function node($params) {
$html = file_get_contents('https://deimos.cybernode.ai/'.$params);
$html = file_get_contents('https://rpc.cyber.posthuman.digital/'.$params);
$data = json_decode($html, true);
return $data['result'];
}
Expand Down
2 changes: 1 addition & 1 deletion blockchains/cyber/apps/explorer/pages/tx/content.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function convert_operation_data($arr, $site_url) {
return $result;
}

$html = file_get_contents('https://lcd.cyber.cybernode.ai/txs/'.$datas);
$html = file_get_contents('https://rpc.cyber.posthuman.digital/txs/'.$datas);
$tx = json_decode($html, true);

date_default_timezone_set('UTC');
Expand Down
2 changes: 1 addition & 1 deletion blockchains/cyber/node.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
$url = $_SERVER['REQUEST_URI'];
$url = explode('/', $url);
$html = file_get_contents('https://deimos.cybernode.ai/'.$url[4]);
$html = file_get_contents('https://rpc.bostrom.cybernode.ai/'.$url[4]);
echo $html;
?>
2 changes: 1 addition & 1 deletion blockchains/minter/content.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<p class="p-main">Сервисы смотрите в меню.</p>
<p class="p-main">Minter - блокчейн, в котором можно создать токен с обеспечением в BIP или без обеспечения. Где можно обменивать их через пулы ликвидности, добавлять лликвидность и создавать новые пулы.<br>
<p class="p-main">Minter - блокчейн, в котором можно создать токен с обеспечением в BIP или без обеспечения. Где можно обменивать их через пулы ликвидности, добавлять ликвидность и создавать новые пулы.<br>
Также можно конвертировать любые монеты с резервом между собой.</p>p>
<p>BIP - основной токен Минтера.</p>
5 changes: 2 additions & 3 deletions content.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@


<div class="container-bg"> </div>
<div class="container-text-content">
<h1 class="p-main2">Opensource проект для приложений, работающих с блокчейнами.</h1>
<p class="p-main">Здесь представлены блокчейны, а также приложения для них. Список БЧ смотрите в меню.</p>
<p class="p-main">Opensource проект для приложений, работающих с блокчейнами.
Список блокчейнов и приложений к ним представлен в меню.</p>
</div>
<div class="container-banner1"> <img src="/template/images/02.jpg" class="banner" alt="hive bunner" width="500px"></div>
<div class="container-banner3"> <img src="/template/images/03.jpg" class="banner" alt="minter bunner" width="350px" ></div>
Expand Down
54 changes: 53 additions & 1 deletion functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ function pageUrl() {
в противном случае - выдать ошибку 404
*/
setlocale(LC_ALL, "ru_RU.UTF-8");
if (preg_match ("/([^a-zA-Z0-9а-яА-Я\.\/\-\_\?\&\=\#]u)/", $chpu)) {
setlocale(LC_NUMERIC, 'en_US.UTF8');
if (preg_match ("/([^a-zA-Z0-9а-яА-Я\.\/\-\_\?\&\=\#]u)/", $chpu)) {

header("HTTP/1.0 404 Not Found");
echo "Недопустимые символы в URL";
Expand Down Expand Up @@ -269,4 +270,55 @@ function get404Page() {
require_once 'template/404.php';
return $data;
}

function getPage($url) {
$cache_url = 'caches/'.urlencode(basename($url));
if (strpos($url, 'coingecko') !== false && strpos($url, '/markets') !== false) {
$parameters = explode('?', $url)[1];
$param = explode('&', $parameters);
$vs_currency = explode('=', $param[0])[1];
$symbol = explode('=', $param[1])[1];
$cache_url = 'caches/markets-'.$vs_currency.'-'.$symbol;
} else if (strpos($url, 'coingecko') !== false && strpos($url, '/ohlc') !== false) {
$coin = explode('/', $url)[6];
$vs_currency_with = explode('?vs_currency=', $url)[1];
$vs_currency = explode('&days=', $vs_currency_with)[0];
$cache_url = 'caches/ohlc-'.$coin.'_'.$vs_currency;
} else if (substr_count($url, '.') === 3) {
$service = explode('/', $url)[3];
[$name, $params] = explode('?', $service);
$params = str_replace('&', '-', $params);
$params = str_replace('=', '', $params);
$cache_url = 'caches/'.$name.'-'.$params;
}

$cache_file = $cache_url.'.cache';
if(file_exists($cache_file)) {
if (strpos($url, 'cbr.ru') !== false && time() - filemtime($cache_file) > 43200) {
$cache = file_get_contents($url);
$t=explode("<Sell>", $cache);
$t=explode("</Sell>", $t[1]);
$count = count($t);
if (isset($t) && $t[0]<>0 || $count > 14) {
return;
} else {
file_put_contents($cache_file, $cache);
}
} else if (strpos($url, 'golos-api?service=top') !== false && time() - filemtime($cache_file) > 1800) {
$cache = file_get_contents($url);
file_put_contents($cache_file, $cache);
} else if(time() - filemtime($cache_file) > 60) {
// too old , re-fetch
$cache = file_get_contents($url);
file_put_contents($cache_file, $cache);
} else {
$cache = file_get_contents($cache_url.'.cache');
}
} else {
// no cache, create one
$cache = file_get_contents($url);
file_put_contents($cache_file, $cache);
}
return $cache;
}
?>
1 change: 1 addition & 0 deletions helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ function getWord($number, $suffix)
$keys = array(2, 0, 1, 1, 1, 2);
$mod = $number % 100;
$suffix_key = ($mod > 7 && $mod < 20) ? 2 : $keys[min($mod % 10, 5)];
if ($suffix_key < 0) $suffix_key = 0;
return $suffix[$suffix_key];
}

Expand Down
16 changes: 12 additions & 4 deletions index.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
<?php
if (session_status() == PHP_SESSION_NONE) session_start();
if (session_status() == PHP_SESSION_NONE) session_start();
ini_set('session.gc_maxlifetime', 12000000960);
ini_set('session.cookie_lifetime', 12000000960);
define('NOTLOAD', 1); // для защиты от прямого запуска php-файлов
require_once 'functions.php';
if (isset(pageUrl()[1]) && pageUrl()[1] === 'api' && isset(pageUrl()[2])) {
if (!isset($_GET)) {
require_once(__DIR__.'/blockchains/'.pageUrl()[0].'/apps/api/pages/'.pageUrl()[2].'.php');
} else {
$page = explode('?', pageUrl()[2])[0];
require_once(__DIR__.'/blockchains/'.pageUrl()[0].'/apps/api/pages/'.$page.'.php');
}
return;
}

function myHandler($level, $message, $file, $line, $context) {
// в зависимости от типа ошибки формируем заголовок сообщения
Expand Down Expand Up @@ -32,9 +43,6 @@ function myHandler($level, $message, $file, $line, $context) {
// регистрируем наш обработчик, он будет срабатывать на для всех типов ошибок
set_error_handler('myHandler', E_ALL);

define('NOTLOAD', 1); // для защиты от прямого запуска php-файлов

require_once 'functions.php';
$conf = configs("config.json");
if (!empty($_POST)) {
$_POST = array_map('trim', $_POST);
Expand Down
2 changes: 1 addition & 1 deletion menu.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"steem":{"name":"Steem","services":{"no_category":{"name":"","explorer":"Explorer","profiles":"Профили","post":"Редактор","manage":"Управление"},"tools":{"name":"Инструменты","swap":"Swap","backup":"Бекап постов","calc":"Калькулятор"}}},"viz":{"services":{"tools":{"name":"Инструменты","awards":"Награждение","search":"Viz-links","exchange":"Обмен","calc":"Калькулятор","manage":"Управление","polls":"Опросы","randomblockchain":"ГСЧ"},"info":{"name":"Информация","help":"Справка","exchanges":"Обмен VIZ","explorer":"Explorer","analytics":"Аналитика"},"no_category":{"name":"","projects":"Проекты","profiles":"Профили","wallet":"Кошелёк","accounts":"Аккаунты"},"reytings":{"name":"Рейтинги","top":"Пользователи"}},"name":"Viz"},"minter":{"services":{"no_category":{"name":"","long":"LONG","validators":"Валидаторы","swap":"Swap","wallet":"кошелёк","explorer":"Explorer","my-coin":"Моя монета","profiles":"Профили","accounts":"Аккаунты"},"tools":{"name":"Инструменты","2022":"Minter2022","broadcast":"Broadcast"}},"name":"Minter"},"cyber":{"name":"Cyber","services":{"no_category":{"name":"","accounts":"Аккаунты","profiles":"Профили","explorer":"Explorer","wallet":"Кошелёк","validators":"Валидаторы"},"tools":{"name":"Инструменты","linker":"Линкер","ipfs":"IPFS","randomblockchain":"ГСЧ"}}},"golos":{"name":"Golos","services":{"reytings":{"name":"Рейтинги","top":"Пользователи","activities":"Активность","referrers":"Рефереры","donates":"Донаты","witnesses-rewards":"Делегаты"},"tools":{"name":"Инструменты","post":"Редактор","swap":"Swap","escrow":"Escrow","donate":"Донат","calc":"Калькулятор","manage":"Управление","polls":"Опросы","backup":"Бекап постов"},"no_category":{"name":"","wallet":"кошелёк","profiles":"Профили","help":"Справка","explorer":"Explorer","accounts":"Аккаунты"},"games":{"name":"Игры","stakebot":"Stake_bot"}}},"serey":{"services":{"reytings":{"name":"Рейтинги","top":"Пользователи","activities":"Активность","witnesses-rewards":"Делегаты"},"no_category":{"name":"","wallet":"Кошелёк","profiles":"Профили","manage":"Управление","accounts":"Аккаунты"},"tools":{"name":"Инструменты","calc":"Калькулятор","randomblockchain":"ГСЧ"}},"name":"Serey"},"hive":{"services":{"no_category":{"name":"","manage":"Управление","post":"Редактор","accounts":"Аккаунты","profiles":"Профили","wallet":"Кошелёк"},"tools":{"name":"Инструменты","swap":"Swap","backup":"Бекап постов","calc":"Калькулятор"}},"name":"Hive"},"decimal":{"name":"decimal","services":{"no_category":{"name":"","profiles":"Профили","explorer":"Explorer","validators":"Валидаторы","randomblockchain":"ГСЧ","accounts":"Аккаунты"}}}}
{"steem":{"name":"Steem","services":{"no_category":{"name":"","explorer":"Explorer","profiles":"Профили","post":"Редактор","manage":"Управление","accounts":"Аккаунты","wallet":"Кошелёк","help":"Справка"},"tools":{"name":"Инструменты","swap":"Swap","backup":"Бекап постов","calc":"Калькулятор","randomblockchain":"ГСЧ"}}},"viz":{"services":{"tools":{"name":"Инструменты","awards":"Награждение","search":"Viz-links","exchange":"Обмен","calc":"Калькулятор","manage":"Управление","polls":"Опросы","randomblockchain":"ГСЧ","custom-generator":"JSON-генератор"},"info":{"name":"Информация","help":"Справка","exchanges":"Обмен VIZ","explorer":"Explorer","analytics":"Аналитика"},"no_category":{"name":"","projects":"Проекты","profiles":"Профили","wallet":"Кошелёк","accounts":"Аккаунты"},"reytings":{"name":"Рейтинги","top":"Пользователи","witnesses-rewards":"Делегаты"}},"name":"Viz"},"minter":{"services":{"no_category":{"name":"","long":"LONG","validators":"Валидаторы","swap":"Swap","wallet":"кошелёк","explorer":"Explorer","my-coin":"Моя монета","profiles":"Профили","accounts":"Аккаунты","randomblockchain":"ГСЧ","help":"Справка"},"tools":{"name":"Инструменты","2022":"Minter2022","broadcast":"Broadcast"}},"name":"Minter"},"cyber":{"name":"Cyber","services":{"no_category":{"name":"","accounts":"Аккаунты","profiles":"Профили","explorer":"Explorer","wallet":"Кошелёк","validators":"Валидаторы","help":"Справка"},"tools":{"name":"Инструменты","linker":"Линкер","ipfs":"IPFS","randomblockchain":"ГСЧ"}}},"golos":{"name":"Golos","services":{"reytings":{"name":"Рейтинги","top":"Пользователи","activities":"Активность","referrers":"Рефереры","donates":"Донаты","witnesses-rewards":"Делегаты"},"tools":{"name":"Инструменты","post":"Редактор","swap":"Swap","escrow":"Escrow","donate":"Донат","calc":"Калькулятор","manage":"Управление","polls":"Опросы","backup":"Бекап постов","randomblockchain":"ГСЧ","api":"API"},"no_category":{"name":"","wallet":"кошелёк","profiles":"Профили","help":"Справка","explorer":"Explorer","accounts":"Аккаунты"},"games":{"name":"Игры","stakebot":"Stake_bot"}}},"serey":{"services":{"reytings":{"name":"Рейтинги","top":"Пользователи","activities":"Активность","witnesses-rewards":"Делегаты"},"no_category":{"name":"","wallet":"Кошелёк","profiles":"Профили","manage":"Управление","accounts":"Аккаунты"},"tools":{"name":"Инструменты","calc":"Калькулятор","randomblockchain":"ГСЧ","backup":"Бекап постов"}},"name":"Serey"},"hive":{"services":{"no_category":{"name":"","manage":"Управление","post":"Редактор","accounts":"Аккаунты","profiles":"Профили","wallet":"Кошелёк"},"tools":{"name":"Инструменты","swap":"Swap","backup":"Бекап постов","calc":"Калькулятор","randomblockchain":"ГСЧ"}},"name":"Hive"},"decimal":{"name":"decimal","services":{"no_category":{"name":"","profiles":"Профили","explorer":"Explorer","validators":"Валидаторы","randomblockchain":"ГСЧ","accounts":"Аккаунты","wallet":"кошелёк"}}}}
23 changes: 13 additions & 10 deletions template/main.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
<?php if (!defined('NOTLOAD')) exit('No direct script access allowed'); ?>
<?php if (!defined('NOTLOAD')) exit('No direct script access allowed');
$page = pageUrl();
$title_text = '';
if (isset($page[0])) $title_text .= $page[0].' | ';
if (isset($page[0]) && !isset($page[1])) {
$title_text .= 'Страница блокчейна';
} else if (isset($page[0]) && isset($page[1])) {
$title_text .= $data['title'];
} else if (!isset($page[0])) {
$title_text = 'Главная';
}
?>

<!DOCTYPE html>
<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!--[if lt IE 9]><script src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script><![endif]-->
<title><?= $data['title']; ?> | <?= $conf['siteName']; ?></title>
<title><?= $title_text; ?> | <?= $conf['siteName']; ?></title>
<meta name="description" content="<?= $data['description']; ?>">
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-W7BPJPZ');</script>
<!-- End Google Tag Manager -->

<link href="<?= $conf['siteUrl']; ?>template/css/famaly-Rubik.css" rel="stylesheet">
<link href="<?= $conf['siteUrl']; ?>template/css/normalize.css" rel="stylesheet">
<link href="<?= $conf['siteUrl']; ?>template/css/style.css" rel="stylesheet">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ class VizHttpJsonRpcConnector extends HttpJsonRpcConnectorAbstract
*
* @var string
*/
protected static $nodeURL = ['https://viz-node.dpos.space', 'https://solox.world'];
protected static $nodeURL = ['https://viz.lexai.host'];
}
6 changes: 3 additions & 3 deletions viz-manual/textolite/conf.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ lang = en,ru

password = b8f5854767559b3d7fa4b610f6ccb457c3d5c138

session = 8af46dc418ee5ea4b97bd8826a29704b040b4777
session = 43a51e05e68eb6250b13201265eb5df3e641a395

pass_complexity = 500000

pass_complexity_js = 14941
pass_complexity_js = 14940

auth_time = 1624466770
auth_time = 1639057789

auth_error_time = 1600191185

Expand Down

0 comments on commit 102574d

Please sign in to comment.