-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ddf6d13
Showing
153 changed files
with
11,899 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
AddType application/x-httpd-php .htm .htmlAddDefaultCharset utf-8 | ||
|
||
RewriteEngine on | ||
RewriteBase / | ||
|
||
RewriteCond %{REQUEST_FILENAME} !-f | ||
RewriteCond %{REQUEST_FILENAME} !-d | ||
RewriteCond %{REQUEST_FILENAME} !-s | ||
|
||
RewriteRule ^(.*)$ index.php | ||
|
||
#RewriteCond %{SERVER_PORT} 80 | ||
#RewriteRule ^(.*)$ https://insiders.com.ua/$1 [R,L] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0"?> | ||
<users> | ||
<user>129617C2D347AE8A4A784BA747C43AD4</user> | ||
</users> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
spl_autoload_register(function ($class) { | ||
|
||
// Массив папок, в которых могут находиться необходимые классы | ||
$array_paths = array( | ||
'/models/', | ||
'/components/', | ||
'/controllers/', | ||
); | ||
|
||
foreach ($array_paths as $path) { | ||
$path = ROOT . $path . $class . '.php'; | ||
|
||
if (is_file($path)) { | ||
include_once $path; | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
class Db { | ||
public static function getConnection() | ||
{ | ||
// Получаем параметры подключения из файла | ||
$paramsPath = ROOT . '/config/db_connect.php'; | ||
$params = include($paramsPath); | ||
|
||
// Устанавливаем соединение | ||
$dsn = "mysql:host={$params['host']};dbname={$params['dbname']}"; | ||
$db = new PDO($dsn, $params['user'], $params['password']); | ||
|
||
// Задаем кодировку | ||
$db->exec("set names utf8"); | ||
|
||
return $db; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?php | ||
|
||
class Router { | ||
|
||
private $routes; | ||
private $result; | ||
private $matches; | ||
|
||
public function __construct() { | ||
// Путь к файлу с роутами | ||
$routesPath = ROOT . '/config/routes.php'; | ||
|
||
// Получаем роуты из файла | ||
$this->routes = include($routesPath); | ||
} | ||
|
||
private function getURI() { | ||
if (!empty($_SERVER['REQUEST_URI'])) { | ||
return parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH); | ||
} | ||
} | ||
|
||
public function run() { | ||
|
||
$uri = $this->getURI(); | ||
|
||
foreach ($this->routes as $uriPattern => $path) { | ||
|
||
if (preg_match("~$uriPattern~", $uri, $this->matches)) { | ||
array_shift($this->matches); | ||
$class = $path['class']; | ||
$action = $path['method']; | ||
$params = isset($this->matches) ? $this->matches : []; | ||
|
||
if ($class == 'HomeController' && $uri !== '/') { | ||
$content = false; | ||
header("HTTP/1.0 404 Not Found"); | ||
require_once(ROOT . '/views/templates/page_errors.php'); | ||
exit(); | ||
} | ||
|
||
$controllerFile = ROOT . '/controllers/' . $class . '.php'; | ||
|
||
include_once($controllerFile); | ||
|
||
$controllerObj = new $class; | ||
|
||
$this->result = call_user_func_array([$controllerObj, $action], $params); | ||
|
||
if ($this->result != null) { | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
|
||
public function cache() { | ||
$uri = $this->getURI(); | ||
$link_parts = explode('/', $uri); | ||
$slug = array_pop($link_parts); | ||
$category = array_pop($link_parts); | ||
$cache_filename = CACHE_DIR . $category . '_' . $slug . '.html'; | ||
if (file_exists($cache_filename)) { | ||
require_once $cache_filename; | ||
exit; | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
return array( | ||
'host' => 'insiders.mysql.ukraine.com.ua', | ||
'dbname' => 'insiders_new', | ||
'user' => 'insiders_new', | ||
'password' => 'a56f27br', | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
return array( | ||
//кеширование | ||
'build/cache' => ['class' => 'FrontController', 'method' => 'buildCache'], | ||
// карта сайта | ||
'build/sitemap' => ['class' => 'FrontController', 'method' => 'actionSitemap'], | ||
// загрузка внешних скриптов | ||
'download/external-js' => ['class' => 'FrontController', 'method' => 'actionDownloadJS'], | ||
// parsing | ||
'parsing/catalogue' => ['class' => 'CatalogueController', 'method' => 'actionParsing'], | ||
'parsing/currency' => ['class' => 'CurrencyController', 'method' => 'actionParsing'], | ||
'parsing/crediti' => ['class' => 'CreditController', 'method' => 'actionParsingCredit'], | ||
'parsing/banks' => ['class' => 'BankController', 'method' => 'actionParsingBanks'], | ||
|
||
// ajax | ||
'currency/history' => ['class' => 'CurrencyController', 'method' => 'actionAjaxCurrency'], | ||
'credit/send' => ['class' => 'CreditController', 'method' => 'actionAjaxSendQuery'], | ||
'bank/review' => ['class' => 'BanksReviewsController', 'method' => 'actionReview'], | ||
'banks/raitings' => ['class' => 'BanksRatingController', 'method' => 'actionAjaxContent'], | ||
'catalogue/glossary' => ['class' => 'CatalogueController', 'method' => 'actionAjaxGlossary'], | ||
//все формы модулей | ||
'module-form/([A-z-]+)' => ['class' => 'ModuleController', 'method' => 'formsProcessing'], | ||
|
||
//динамическа подгрузка | ||
'dynamic/loading' => ['class' => 'FrontController', 'method' => 'dynamicLoadingContent'], | ||
|
||
'banki/rejting-bankov-ukraini/([A-z-0-9]+)' => ['class' => 'BanksRatingController', 'method' => 'actionView'], | ||
'banki/rejting-bankov-ukraini' => ['class' => 'BanksRatingController', 'method' => 'actionContent'], | ||
'banki/otzyvy-o-bankakh/([A-z-0-9]+)' => ['class' => 'BanksReviewsController', 'method' => 'actionView'], | ||
'banki/otzyvy-o-bankakh' => ['class' => 'BanksReviewsController', 'method' => 'actionContent'], | ||
'banki/([A-z-]+)/([A-z-0-9]+)' => ['class' => 'BankController', 'method' => 'actionView'], | ||
'banki/([A-z-]+)' => ['class' => 'BankController', 'method' => 'actionContent'], | ||
|
||
'kursy-valyut/([A-z-]+)' => ['class' => 'CurrencyController', 'method' => 'actionContent'], | ||
|
||
'spravochnik/bankovskie-terminy/([A-z-0-9]+)' => ['class' => 'CatalogueController', 'method' => 'actionContent'], | ||
'spravochnik/bankovskie-terminy' => ['class' => 'CatalogueController', 'method' => 'actionList'], | ||
'spravochnik/([A-z-]+)' => ['class' => 'CatalogueController', 'method' => 'actionContent'], | ||
|
||
'depozity/([A-z-]+)' => ['class' => 'DepositController', 'method' => 'actionContent'], | ||
|
||
'kredity/([A-z-]+)/([A-z-0-9]+)' => ['class' => 'CreditController', 'method' => 'actionView'], | ||
'kredity/([A-z-]+)' => ['class' => 'CreditController', 'method' => 'actionContent'], | ||
|
||
// '' => ['class' => 'HomeController', 'method' => 'actionContent'], | ||
'/' => ['class' => 'HomeController', 'method' => 'actionContent'], | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
class BankController extends FrontController { | ||
|
||
public function __construct() { | ||
parent::__construct(); | ||
$this->table = 'banks'; | ||
} | ||
|
||
public function actionContent($slug) { | ||
$content = Bank::getContent($slug, $this->table); | ||
$list = Bank::getList($this->table, ' category LIKE ' . '"' . $slug . '"'); | ||
require_once(ROOT . '/views/templates/page_banks_view.php'); | ||
|
||
return true; | ||
} | ||
|
||
public function actionView($category, $slug) { | ||
$content = Bank::getContent($slug, $this->table); | ||
$reviews = BanksReviews::getBankRewiev($content['id']); | ||
$rating_bank = BanksReviews::getRatingData($content['id']); | ||
$bank_data = json_decode($content['table_data'], true); | ||
$finrez = $bank_data['finrez_all']; | ||
if(isset($finrez) && !empty($finrez)) | ||
$date_finrez = $finrez['Активы']['date']; | ||
unset($bank_data['Название']); | ||
unset($bank_data['finrez_all']); | ||
$banks_list = Bank::getBanksList(); | ||
require_once(ROOT . '/views/templates/page_bank.php'); | ||
return true; | ||
} | ||
|
||
public function actionParsingBanks() { | ||
$dir = 'data/banks/'; | ||
//var_dump(BanksRating::bankFinRez(2)); | ||
$out = parent::actionParsings($dir, $this->table); | ||
foreach ($out as $id => $slug){ | ||
$finrez = BanksRating::bankFinRez($id); | ||
$content = Front::getContent($slug, $this->table); | ||
$table_data = json_decode($content['table_data'], true); | ||
$table_data['finrez_all'] = $finrez; | ||
$table_data = json_encode($table_data); | ||
Front::updateContent($this->table, $id, null, $slug, null, null, null, null, null, $table_data); | ||
} | ||
|
||
BanksRating::updateTop10Data(); // обновляем топ 10 в общем рейтинге | ||
|
||
return true; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
|
||
class BanksRatingController extends FrontController { | ||
|
||
public function __construct() { | ||
parent::__construct(); | ||
$this->table = 'banks_rating'; | ||
} | ||
|
||
public function actionContent() { | ||
$content = BanksRating::getContent('rejting-bankov-ukraini', $this->table); | ||
$table = json_decode($content['table_data'], true); | ||
$top_10_aktiv = BanksRating::buildTop10Table($table, 'aktivi'); | ||
$top_10_dfl = BanksRating::buildTop10Table($table, 'dfl'); | ||
$top_10_sk = BanksRating::buildTop10Table($table, 'sk'); | ||
$top_10_profit = BanksRating::buildTop10Table($table, 'profit'); | ||
$top_10_loss = BanksRating::buildTop10Table($table, 'loss'); | ||
$chart_aktiv = BanksRating::chartData($table, 'aktivi'); | ||
$chart_dfl = BanksRating::chartData($table, 'dfl'); | ||
$arr1 = ['{$top_10_aktiv}', '{$top_10_dfl}', '{$top_10_sk}', '{$top_10_profit}', '{$top_10_loss}']; | ||
$arr2 = [$top_10_aktiv, $top_10_dfl, $top_10_sk, $top_10_profit, $top_10_loss]; | ||
$content['text'] = str_replace($arr1, $arr2, $content['text']); | ||
|
||
//$arr = BanksRating::updateTop10Data(); | ||
require_once(ROOT . '/views/templates/page_raitings_banks_all.php'); | ||
|
||
return true; | ||
} | ||
|
||
public function actionView($slug) { | ||
$content = BanksRating::getContent($slug, $this->table); | ||
|
||
switch ($slug) { | ||
case "rejting-bankov-nbu": | ||
$latest_file = BanksRating::getLatestFile(); | ||
$table = FrontController::parseCSVTable($latest_file['filename']); | ||
$attributes = BanksRating::tableAttributes(); | ||
require_once(ROOT . '/views/templates/page_raiting_banks.php'); | ||
break; | ||
case "rejting-bankov-aub": | ||
require_once(ROOT . '/views/templates/page_empty.php'); | ||
break; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
public function actionAjaxContent() { | ||
$dir = 'data/raiting_nbu/'; | ||
$indicator = $_POST['indicator']; | ||
$year = $_POST['year']; | ||
$quarter = $_POST['quarter']; | ||
$filename = $indicator . '_' . $quarter . '_' . $year . '.csv'; | ||
$attributes = BanksRating::tableAttributes(); | ||
$file_name = BanksRating::fileName($indicator, $quarter, $year); | ||
if (false === $table = FrontController::parseCSVTable($dir . $filename)) | ||
die('<div class="alert alert-danger" role="alert">' | ||
. 'Нет данных на выбранную дату' | ||
. '</div>'); | ||
$responce = require_once(ROOT . '/views/templates/page_raiting_table.php'); | ||
die($responce); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
class BanksReviewsController extends FrontController { | ||
|
||
public function __construct() { | ||
parent::__construct(); | ||
$this->table = 'bank_reviews'; | ||
} | ||
|
||
public function actionContent() { | ||
$content = BanksReviews::getContent('otzyvy-o-bankakh', $this->table, ''); | ||
$reviews_list = BanksReviews::getList($this->table, ' category = "otzyvy-o-bankakh"', 'date_add', 'DESC'); | ||
foreach ($reviews_list as $key => $list){ | ||
$bank_data = Bank::getBankData ($list['bank']); | ||
$reviews_list[$key]['bank_name'] = $bank_data['title']; | ||
$reviews_list[$key]['bank_link'] = $bank_data['slug']; | ||
} | ||
|
||
$banks_list = Bank::getBanksList(); | ||
require_once(ROOT . '/views/templates/page_banks_reviews.php'); | ||
|
||
return true; | ||
} | ||
|
||
public function actionView($slug){ | ||
$content = Credit::getContent($slug, $this->table); | ||
$rating_bank = BanksReviews::getRatingData($content['bank']); | ||
$bank_data = Bank::getBankData ($content['bank']); | ||
require_once(ROOT . '/views/templates/page_review.php'); | ||
return TRUE; | ||
} | ||
|
||
public function actionReview() { | ||
$title = $_POST['subject']; | ||
$bank = $_POST['bank']; | ||
$name = $_POST['name']; | ||
$text = $_POST['review']; | ||
if(isset($_POST['rating'])) | ||
$rating = $_POST['rating']; | ||
else | ||
$rating = 0; | ||
|
||
if (BanksReviews::insertReview($title, $bank, $name, $text, $rating)) | ||
die('<div class="alert alert-success" role="alert">Ваш отзыв успешно добавлен</div>'); | ||
else | ||
die('<div class="alert alert-danger" role="alert">Возникла ошибка. Попробуйте позже</div>'); | ||
} | ||
|
||
} |
Oops, something went wrong.