Сборка REDL: панель на PHP 8, капча-тумблер, закрытые уязвимости, установщики в один клик
- панель работает на PHP 8.4 (оригинал под PHP 7.0): elFinder utf8_encode, apache_get_modules, warnings - капча выключена и управляется из админки (флаг captcha_enable + блок настроек) - закрыты две SQL-инъекции без авторизации (createAuthLog: пароль из POST и CF-Connecting-IP) - убрано хранение паролей в открытом виде в authlog, XSS в поле ref - установщики install-panel.sh и install-node.sh (оригинальный затирал sources.list репозиториями Debian 9) - современный Dockerfile (оригинальный на debian:stretch больше не собирается) - планировщик и автозапуск работают без systemd - брендинг REDL.IO, год 2026, ссылки на redl.io - документация на русском: ИЗМЕНЕНИЯ, БЕЗОПАСНОСТЬ, ИНСТРУКЦИЯ
This commit is contained in:
@@ -0,0 +1,171 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko (https://vk.com/id00v)
|
||||
*/
|
||||
class bonusController extends Controller {
|
||||
public function index() {
|
||||
$this->document->setActiveSection('account');
|
||||
$this->document->setActiveItem('bonus');
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 0) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->model('users');
|
||||
$this->data['bonus1'] = $this->config->bonus1;
|
||||
$this->data['bonus2'] = $this->config->bonus2;
|
||||
$this->data['bonus3'] = $this->config->bonus3;
|
||||
$this->data['bonus4'] = $this->config->bonus4;
|
||||
|
||||
$userid = $this->user->getId();
|
||||
$users = $this->usersModel->getUserById($userid, array(), array());
|
||||
$this->data['users'] = $users;
|
||||
|
||||
$this->getChild(array('common/header', 'common/footer'));
|
||||
return $this->load->view('account/bonus', $this->data);
|
||||
}
|
||||
public function ajax_action_exchange($action = null) {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if($this->user->getAccessLevel() < 1) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$this->data['bonus1'] = $bonus1 = round($this->config->bonus1);
|
||||
$this->data['bonus2'] = $bonus2 = round($this->config->bonus2);
|
||||
$this->data['bonus3'] = $bonus3 = round($this->config->bonus3);
|
||||
$this->data['bonus4'] = $bonus4 = round($this->config->bonus4);
|
||||
|
||||
$this->load->model('users');
|
||||
$this->load->model('waste');
|
||||
|
||||
$userid = $this->user->getId();
|
||||
$users = $this->usersModel->getUserById($userid, array(), array());
|
||||
|
||||
switch($action) {
|
||||
case '100DEB': {
|
||||
$rmoney = $users['bonuses'];
|
||||
$sum = "100";
|
||||
$upsum = $bonus1;
|
||||
if ($rmoney >= $sum){
|
||||
|
||||
$this->usersModel->downUserBalance($userid, $price);
|
||||
$wasteData = array(
|
||||
'user_id' => $userid,
|
||||
'waste_ammount' => $upsum,
|
||||
'waste_status' => 0,
|
||||
'waste_usluga' => "Обменял $sum бонусов на $upsum рублей"
|
||||
);
|
||||
$this->wasteModel->createWaste($wasteData);
|
||||
|
||||
$this->usersModel->upUserBalance($userid, $upsum);
|
||||
$this->usersModel->downUserBonuses($userid, $sum);
|
||||
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Деньги отправлены. Вам начисленно ".$upsum." руб!";
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас недостаточно монет!";
|
||||
}
|
||||
break;
|
||||
}
|
||||
case '300DEB': {
|
||||
$rmoney = $users['bonuses'];
|
||||
$sum = "300";
|
||||
$upsum = $bonus2;
|
||||
if ($rmoney >= $sum){
|
||||
|
||||
$this->usersModel->downUserBalance($userid, $price);
|
||||
$wasteData = array(
|
||||
'user_id' => $userid,
|
||||
'waste_ammount' => $upsum,
|
||||
'waste_status' => 0,
|
||||
'waste_usluga' => "Обменял $sum бонусов на $upsum рублей"
|
||||
);
|
||||
$this->wasteModel->createWaste($wasteData);
|
||||
|
||||
$this->usersModel->upUserBalance($userid, $upsum);
|
||||
$this->usersModel->downUserBonuses($userid, $sum);
|
||||
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Деньги отправлены. Вам начисленно ".$upsum." руб!";
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас недостаточно монет!";
|
||||
}
|
||||
break;
|
||||
}
|
||||
case '600DEB': {
|
||||
$rmoney = $users['bonuses'];
|
||||
$sum = "600";
|
||||
$upsum = $bonus3;
|
||||
if ($rmoney >= $sum){
|
||||
|
||||
$this->usersModel->downUserBalance($userid, $price);
|
||||
$wasteData = array(
|
||||
'user_id' => $userid,
|
||||
'waste_ammount' => $upsum,
|
||||
'waste_status' => 0,
|
||||
'waste_usluga' => "Обменял $sum бонусов на $upsum рублей"
|
||||
);
|
||||
$this->wasteModel->createWaste($wasteData);
|
||||
|
||||
$this->usersModel->upUserBalance($userid, $upsum);
|
||||
$this->usersModel->downUserBonuses($userid, $sum);
|
||||
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Деньги отправлены. Вам начисленно ".$upsum." руб!";
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас недостаточно монет!";
|
||||
}
|
||||
break;
|
||||
}
|
||||
case '1000DEB': {
|
||||
$rmoney = $users['bonuses'];
|
||||
$sum = "1000";
|
||||
$upsum = $bonus4;
|
||||
if ($rmoney >= $sum){
|
||||
|
||||
$this->usersModel->downUserBalance($userid, $price);
|
||||
$wasteData = array(
|
||||
'user_id' => $userid,
|
||||
'waste_ammount' => $upsum,
|
||||
'waste_status' => 0,
|
||||
'waste_usluga' => "Обменял $sum бонусов на $upsum рублей"
|
||||
);
|
||||
$this->wasteModel->createWaste($wasteData);
|
||||
|
||||
$this->usersModel->upUserBalance($userid, $upsum);
|
||||
$this->usersModel->downUserBonuses($userid, $sum);
|
||||
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Деньги отправлены. Вам начисленно ".$upsum." руб!";
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас недостаточно монет!";
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы выбрали несуществующее действие!";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return json_encode($this->data);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko (https://vk.com/id00v)
|
||||
*/
|
||||
class errorController extends Controller {
|
||||
public function index() {
|
||||
$this->document->setActiveSection('account');
|
||||
$this->document->setActiveItem('pay');
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 0) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
$this->load->model('users');
|
||||
$this->load->model('invoices');
|
||||
|
||||
$this->getChild(array('common/header', 'common/footer'));
|
||||
return $this->load->view('account/error', $this->data);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko (https://vk.com/id00v)
|
||||
*/
|
||||
class invoicesController extends Controller {
|
||||
private $limit = 8;
|
||||
public function index($page = 1) {
|
||||
$this->document->setActiveSection('account');
|
||||
$this->document->setActiveItem('invoices');
|
||||
$this->data['title'] = $this->config->title;
|
||||
$this->data['description'] = $this->config->description;
|
||||
$this->data['mail_from'] = $this->config->mail_from;
|
||||
$this->data['homed'] = $this->config->homed;
|
||||
$this->data['city_country'] = $this->config->city_country;
|
||||
$this->data['phone'] = $this->config->phone;
|
||||
$this->data['logo'] = $this->config->logo;
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 0) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->library('pagination');
|
||||
$this->load->model('invoices');
|
||||
$this->load->model('users');
|
||||
$userid = $this->user->getId();
|
||||
$sort = array(
|
||||
'invoice_status' => 'DESC',
|
||||
'invoice_id' => 'DESC'
|
||||
);
|
||||
$getOptions = array(
|
||||
'start' => ($page - 1) * $this->limit,
|
||||
'limit' => $this->limit
|
||||
);
|
||||
|
||||
$total = $this->invoicesModel->getTotalInvoices(array('user_id' => (int)$userid));
|
||||
$invoices = $this->invoicesModel->getInvoices(array('user_id' => (int)$userid), array(), $sort, $getOptions);
|
||||
|
||||
$paginationLib = new paginationLibrary();
|
||||
|
||||
$paginationLib->total = $total;
|
||||
$paginationLib->page = $page;
|
||||
$paginationLib->limit = $this->limit;
|
||||
$paginationLib->url = $this->config->url . 'account/invoices/index/{page}';
|
||||
|
||||
$pagination = $paginationLib->render();
|
||||
|
||||
$this->data['invoices'] = $invoices;
|
||||
$this->data['pagination'] = $pagination;
|
||||
$this->data['user_email'] = $this->user->getEmail();
|
||||
$this->data['user_id'] = $userid;
|
||||
$this->data['user_firstname'] = $this->user->getFirstname();
|
||||
$this->data['user_lastname'] = $this->user->getLastname();
|
||||
$this->data['user_balance'] = $this->user->getBalance();
|
||||
$this->getChild(array('common/header', 'common/footer'));
|
||||
return $this->load->view('account/invoices', $this->data);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,220 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko (https://vk.com/id00v)
|
||||
*/
|
||||
class loginController extends Controller {
|
||||
private $limit = 6;
|
||||
public function index($page = 1) {
|
||||
$this->document->setActiveSection('account');
|
||||
$this->document->setActiveItem('login');
|
||||
$this->data['recaptcha'] = $this->config->recaptcha;
|
||||
$this->data['captcha_enable'] = $this->config->captcha_enable;
|
||||
|
||||
if($this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
$this->load->library('pagination');
|
||||
$this->load->model('news');
|
||||
$sort = array(
|
||||
//'ticket_status' => 'DESC',
|
||||
'news_date_add' => 'DESC'
|
||||
);
|
||||
|
||||
$options = array(
|
||||
'start' => ($page - 1) * $this->limit,
|
||||
'limit' => $this->limit
|
||||
);
|
||||
|
||||
$total = $this->newsModel->getTotalNews();
|
||||
$tickets = $this->newsModel->getNews(array(), array(), $sort, $options);
|
||||
|
||||
$paginationLib = new paginationLibrary();
|
||||
|
||||
$paginationLib->total = $total;
|
||||
$paginationLib->page = $page;
|
||||
$paginationLib->limit = $this->limit;
|
||||
$paginationLib->url = $this->config->url . '/account/login/index/{page}';
|
||||
|
||||
$pagination = $paginationLib->render();
|
||||
|
||||
$this->data['tickets'] = $tickets;
|
||||
$this->data['pagination'] = $pagination;
|
||||
$this->getChild(array('common/loginheader', 'common/loginfooter'));
|
||||
return $this->load->view('account/login', $this->data);
|
||||
}
|
||||
|
||||
//Авторизация через вк
|
||||
public function vk() {
|
||||
if($this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы уже авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$this->load->model('users');
|
||||
$userid = $this->user->getId();
|
||||
|
||||
if($this->request->post['auth']){
|
||||
$id = $this->request->post['response']['session']['user']['id'];
|
||||
|
||||
if($u = $this->usersModel->getUserByUser_vk_id($id, "user_vk_id")){
|
||||
if($u['user_activate'] != '1'){
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Данный аккаунт не активирован!";
|
||||
return json_encode($this->data);
|
||||
} else {
|
||||
if($this->user->loginVk($id)) {
|
||||
$ip=$this->user->getRealIpAdress();
|
||||
$this->usersModel->createAuthLog($u['user_id'],$ip,'1','Auth for VK');
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Вы успешно авторизировались!";
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Неизвестная ошибка!";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->session->data['auth_vk'] = $id;
|
||||
$this->data['status'] = "auth_error";
|
||||
$this->data['auth_error'] = "Внутренняя ошибка!(Либо не привязана учётка)";
|
||||
}
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
if($this->request->post['auth_vk']) {
|
||||
if($user = @file_get_contents("https://api.vk.com/method/users.get?uids={$this->session->data['auth_vk']}&fields=uid,first_name,last_name,email,screen_name,sex,bdate,photo_big"))
|
||||
$this->data['user'] = json_decode($user, true);
|
||||
$email = @$this->request->post['email'];
|
||||
$password = @$this->request->post['password'];
|
||||
}
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
public function ajax() {
|
||||
$this->load->model('users');
|
||||
if($this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
$errorPOST = $this->validatePOST();
|
||||
if(!$errorPOST) {
|
||||
$email = @$this->request->post['email'];
|
||||
$password = @$this->request->post['password'];
|
||||
|
||||
$user = @$this->usersModel->getUserByEmail($email);
|
||||
if($user and $user['user_activate'] !== '1'){
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Данный аккаунт не активирован!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if($this->user->login($email, md5($password))) {
|
||||
$userid=$this->usersModel->getIdByEmail($email);
|
||||
$ip=$this->user->getRealIpAdress();
|
||||
$this->usersModel->createAuthLog($userid['user_id'],$ip,'1','');
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Вы успешно вошли!";
|
||||
} else {
|
||||
|
||||
$userid=$this->usersModel->getIdByEmail($email);
|
||||
$ip=$this->user->getRealIpAdress();
|
||||
$this->usersModel->createAuthLog($userid['user_id'],$ip,'0','');
|
||||
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы ввели не верный логин или пароль!";
|
||||
}
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $errorPOST;
|
||||
}
|
||||
|
||||
}else{
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Не POST запрос";
|
||||
}
|
||||
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
public function activate()
|
||||
{
|
||||
$this->document->setActiveSection('account');
|
||||
$this->document->setActiveItem('activate');
|
||||
|
||||
if ($this->user->isLogged()) {
|
||||
$this->session->data['error'] = 'Вы уже авторизированы!';
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->model('users');
|
||||
$this->data['title'] = $this->config->title;
|
||||
$key = @$this->request->get['key'];
|
||||
$user = @$this->usersModel->getUserByKey($key);
|
||||
if ($key && $user && ($user['user_activate'] == 0)) {
|
||||
$this->usersModel->updateUser($user['user_id'], array('user_activate' => 1, 'key_activate' => 0));
|
||||
$this->data['user'] = $user;
|
||||
}
|
||||
|
||||
$this->getChild(array('common/loginheader', 'common/loginfooter'));
|
||||
return $this->load->view('account/activate', $this->data);
|
||||
}
|
||||
|
||||
public function complete()
|
||||
{
|
||||
$this->document->setActiveSection('account');
|
||||
$this->document->setActiveItem('activate');
|
||||
|
||||
if ($this->user->isLogged()) {
|
||||
$this->session->data['error'] = 'Вы уже авторизированы!';
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->model('users');
|
||||
$this->data['title'] = $this->config->title;
|
||||
|
||||
$this->getChild(array('common/loginheader', 'common/loginfooter'));
|
||||
return $this->load->view('account/complete', $this->data);
|
||||
}
|
||||
|
||||
private function validatePOST() {
|
||||
|
||||
$this->load->library('validate');
|
||||
|
||||
$validateLib = new validateLibrary();
|
||||
|
||||
$result = null;
|
||||
|
||||
$email = @$this->request->post['email'];
|
||||
$password = @$this->request->post['password'];
|
||||
$recaptcha = @$this->request->post['g-recaptcha-response'];
|
||||
|
||||
if(!$validateLib->email($email)) {
|
||||
$result = "Укажите свой реальный E-Mail!";
|
||||
}
|
||||
elseif(!$validateLib->password($password)) {
|
||||
$result = "Пароль должен содержать от 6 до 32 латинских букв, цифр и знаков <i>,.!?_-</i>!";
|
||||
}
|
||||
if($this->config->captcha_enable != '1') return $result;
|
||||
if(!$recaptcha) return 'Подтвердите, что вы не робот!';
|
||||
$url = 'https://www.google.com/recaptcha/api/siteverify';
|
||||
$data = array('secret' => $this->config->secret_recaptcha, 'response' => $recaptcha);
|
||||
$options = array(
|
||||
'http' => array(
|
||||
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
|
||||
'method' => 'POST',
|
||||
'remoteip' => 'remoteip',
|
||||
'content' => http_build_query($data),
|
||||
)
|
||||
);
|
||||
|
||||
$context = stream_context_create($options);
|
||||
$recaptcha_get = json_decode(file_get_contents($url, false, $context))->{'success'};
|
||||
if($recaptcha_get != '1') return 'Проверьте правильность капчи!';
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko (https://vk.com/id00v)
|
||||
*/
|
||||
class logoutController extends Controller {
|
||||
public function index() {
|
||||
$this->load->model('users');
|
||||
$this->document->setActiveSection('account');
|
||||
$this->document->setActiveItem('logout');
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = 'Вы не авторизированы';
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
|
||||
$userid=$this->user->getId();
|
||||
$ip=$this->user->getRealIpAdress();
|
||||
$this->usersModel->createAuthLog($userid,$ip,'2','NONE');
|
||||
|
||||
$this->user->logout();
|
||||
$this->session->data['success'] = 'Вы успешно вышли из своего аккаунта';
|
||||
$this->response->redirect($this->config->url);
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,564 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko (https://vk.com/id00v)
|
||||
*/
|
||||
class payController extends Controller {
|
||||
public function index() {
|
||||
$this->document->setActiveSection('account');
|
||||
$this->document->setActiveItem('pay');
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 0) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
$this->load->model('users');
|
||||
$unitpay = $this->config->unitpay;
|
||||
$enotpay = $this->config->enotpay;
|
||||
$anypay = $this->config->anypay;
|
||||
$litekassa = $this->config->litekassa;
|
||||
$robokassa = $this->config->robokassa;
|
||||
$freekassa = $this->config->freekassa;
|
||||
$interkassa = $this->config->interkassa;
|
||||
$yandexkassa = $this->config->yandexkassa;
|
||||
$qiwi = $this->config->qiwi;
|
||||
$this->data['unitpay'] = $unitpay;
|
||||
$this->data['enotpay'] = $enotpay;
|
||||
$this->data['anypay'] = $anypay;
|
||||
$this->data['litekassa'] = $litekassa;
|
||||
$this->data['robokassa'] = $robokassa;
|
||||
$this->data['freekassa'] = $freekassa;
|
||||
$this->data['interkassa'] = $interkassa;
|
||||
$this->data['yandexkassa'] = $yandexkassa;
|
||||
$this->data['qiwi'] = $qiwi;
|
||||
$this->getChild(array('common/header', 'common/footer'));
|
||||
return $this->load->view('account/pay', $this->data);
|
||||
}
|
||||
|
||||
public function anypay() {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if($this->user->getAccessLevel() < 1) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$this->load->model('invoices');
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
if($this->config->anypay == 1) {
|
||||
$errorPOST = $this->validatePOST();
|
||||
if(!$errorPOST) {
|
||||
$ammount = @$this->request->post['ammount'];
|
||||
|
||||
$server = $this->config->anypay_server;
|
||||
$login = $this->config->anypay_login;
|
||||
$password = $this->config->anypay_password;
|
||||
|
||||
$userid = $this->user->getId();
|
||||
|
||||
$invoiceData = array(
|
||||
'user_id' => $userid,
|
||||
'invoice_ammount' => $ammount,
|
||||
'invoice_status' => 0,
|
||||
'system' => "Anypay"
|
||||
);
|
||||
$invid = $this->invoicesModel->createInvoice($invoiceData);
|
||||
$currency = 'RUB'; // валюта Вашего магазина
|
||||
$signature = md5("$currency:$ammount:$password:$login:$invid");
|
||||
|
||||
$url = "$server";
|
||||
/* Параметры: */
|
||||
$url .= "?merchant_id=$login";
|
||||
$url .= "&amount=$ammount";
|
||||
$url .= "&sign=$signature";
|
||||
$url .= "&desc=Оплата счета ".$invid;
|
||||
$url .= "&pay_id=$invid";
|
||||
|
||||
$this->data['status'] = "success";
|
||||
$this->data['url'] = $url;
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $errorPOST;
|
||||
}
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Данная платежная система отключена!";
|
||||
}
|
||||
}
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
public function enotpay() {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if($this->user->getAccessLevel() < 1) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$this->load->model('invoices');
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
if($this->config->enotpay == 1) {
|
||||
$errorPOST = $this->validatePOST();
|
||||
if(!$errorPOST) {
|
||||
$ammount = @$this->request->post['ammount'];
|
||||
|
||||
$server = $this->config->enot_server;
|
||||
$login = $this->config->enot_login;
|
||||
$password1 = $this->config->enot_password1;
|
||||
|
||||
$userid = $this->user->getId();
|
||||
|
||||
$invoiceData = array(
|
||||
'user_id' => $userid,
|
||||
'invoice_ammount' => $ammount,
|
||||
'invoice_status' => 0,
|
||||
'system' => "Enot"
|
||||
);
|
||||
$invid = $this->invoicesModel->createInvoice($invoiceData);
|
||||
|
||||
$signature = md5("$login:$ammount:$password1:$invid");
|
||||
|
||||
$url = "$server";
|
||||
/* Параметры: */
|
||||
$url .= "?m=$login";
|
||||
$url .= "&oa=$ammount";
|
||||
$url .= "&s=$signature";
|
||||
$url .= "&o=$invid";
|
||||
$url .= "&c=Оплата счета ".$invid;
|
||||
|
||||
$this->data['status'] = "success";
|
||||
$this->data['url'] = $url;
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $errorPOST;
|
||||
}
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Данная платежная система отключена!";
|
||||
}
|
||||
}
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
public function interpay() {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if($this->user->getAccessLevel() < 1) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$this->load->model('invoices');
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
if($this->config->interkassa == 1) {
|
||||
$errorPOST = $this->validatePOST();
|
||||
if(!$errorPOST) {
|
||||
$ammount = @$this->request->post['ammount'];
|
||||
|
||||
$userid = $this->user->getId();
|
||||
|
||||
$invoiceData = array(
|
||||
'user_id' => $userid,
|
||||
'invoice_ammount' => $ammount,
|
||||
'invoice_status' => 0,
|
||||
'system' => "Interkassa"
|
||||
);
|
||||
$invid = $this->invoicesModel->createInvoice($invoiceData);
|
||||
$url = "https://sci.interkassa.com/";
|
||||
/* Параметры: */
|
||||
$url .= "?ik_co_id=57e931c53d1eafce4e8b456d";
|
||||
$url .= "&ik_pm_no=$invid";
|
||||
$url .= "&ik_am=$ammount";
|
||||
$url .= "&ik_cur=RUB";
|
||||
$url .= "&ik_desc=Оплата счета ".$invid;
|
||||
|
||||
$this->data['status'] = "success";
|
||||
$this->data['url'] = $url;
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $errorPOST;
|
||||
}
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Данная платежная система отключена!";
|
||||
}
|
||||
}
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
public function robopay() {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if($this->user->getAccessLevel() < 1) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$this->load->model('invoices');
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
if($this->config->robokassa == 1) {
|
||||
$errorPOST = $this->validatePOST();
|
||||
if(!$errorPOST) {
|
||||
$ammount = @$this->request->post['ammount'];
|
||||
|
||||
$server = $this->config->rk_server;
|
||||
$login = $this->config->rk_login;
|
||||
$password1 = $this->config->rk_password1;
|
||||
|
||||
$userid = $this->user->getId();
|
||||
|
||||
$invoiceData = array(
|
||||
'user_id' => $userid,
|
||||
'invoice_ammount' => $ammount,
|
||||
'invoice_status' => 0,
|
||||
'system' => "Robokassa"
|
||||
);
|
||||
$invid = $this->invoicesModel->createInvoice($invoiceData);
|
||||
|
||||
$signature = md5("$login:$ammount:$invid:$password1");
|
||||
|
||||
$url = "$server/Index.aspx";
|
||||
/* Параметры: */
|
||||
$url .= "?MrchLogin=$login";
|
||||
$url .= "&OutSum=$ammount";
|
||||
$url .= "&InvId=$invid";
|
||||
$url .= "&SignatureValue=$signature";
|
||||
$url .= "&Desc=Оплата счета ".$invid;
|
||||
|
||||
$this->data['status'] = "success";
|
||||
$this->data['url'] = $url;
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $errorPOST;
|
||||
}
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Данная платежная система отключена!";
|
||||
}
|
||||
}
|
||||
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
public function freepay() {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if($this->user->getAccessLevel() < 1) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$this->load->model('invoices');
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
if($this->config->freekassa == 1) {
|
||||
$errorPOST = $this->validatePOST();
|
||||
if(!$errorPOST) {
|
||||
$ammount = @$this->request->post['ammount'];
|
||||
|
||||
$server = $this->config->fk_server;
|
||||
$login = $this->config->fk_login;
|
||||
$password1 = $this->config->fk_password1;
|
||||
|
||||
$userid = $this->user->getId();
|
||||
|
||||
$invoiceData = array(
|
||||
'user_id' => $userid,
|
||||
'invoice_ammount' => $ammount,
|
||||
'invoice_status' => 0,
|
||||
'system' => "Free-Kassa"
|
||||
);
|
||||
$invid = $this->invoicesModel->createInvoice($invoiceData);
|
||||
|
||||
$signature = md5("$login:$ammount:$invid:$password1");
|
||||
|
||||
$url = "$server/Index.aspx";
|
||||
/* Параметры: */
|
||||
$url .= "?MrchLogin=$login";
|
||||
$url .= "&OutSum=$ammount";
|
||||
$url .= "&InvId=$invid";
|
||||
$url .= "&SignatureValue=$signature";
|
||||
$url .= "&Desc=Оплата счета ".$invid;
|
||||
|
||||
$this->data['status'] = "success";
|
||||
$this->data['url'] = $url;
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $errorPOST;
|
||||
}
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Данная платежная система отключена!";
|
||||
}
|
||||
}
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
public function unitpay() {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if($this->user->getAccessLevel() < 1) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$this->load->model('invoices');
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
if($this->config->unitpay == 1) {
|
||||
$errorPOST = $this->validatePOST();
|
||||
if(!$errorPOST) {
|
||||
$ammount = @$this->request->post['ammount'];
|
||||
|
||||
$userid = $this->user->getId();
|
||||
|
||||
$invoiceData = array(
|
||||
'user_id' => $userid,
|
||||
'invoice_ammount' => $ammount,
|
||||
'invoice_status' => 0,
|
||||
'system' => "Unitpay"
|
||||
);
|
||||
$invid = $this->invoicesModel->createInvoice($invoiceData);
|
||||
|
||||
$server = $this->config->unitpay_url;
|
||||
$url = "$server";
|
||||
/* Параметры: */
|
||||
$url .= "?sum=$ammount";
|
||||
$url .= "&account=$invid";
|
||||
$url .= "&desc=Оплата счета ".$invid;
|
||||
|
||||
$this->data['status'] = "success";
|
||||
$this->data['url'] = $url;
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $errorPOST;
|
||||
}
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Данная платежная система отключена!";
|
||||
}
|
||||
}
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
public function yandexkassa() {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if($this->user->getAccessLevel() < 1) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$this->load->model('invoices');
|
||||
$userid = $this->user->getId();
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
if($this->config->yandexkassa == 1) {
|
||||
$errorPOST = $this->validatePOST();
|
||||
if(!$errorPOST) {
|
||||
$ammount = @$this->request->post['ammount'];
|
||||
|
||||
$invoiceData = array(
|
||||
'user_id' => $userid,
|
||||
'invoice_ammount' => $ammount,
|
||||
'invoice_status' => 0,
|
||||
'system' => "Yandex Kassa"
|
||||
);
|
||||
$invid = $this->invoicesModel->createInvoice($invoiceData);
|
||||
|
||||
$url = "https://money.yandex.ru/quickpay/confirm.xml";
|
||||
$url .= "?receiver=".$this->config->yk_login."";
|
||||
$url .= "&quickpay-form=shop";
|
||||
$url .= "&paymentType=PC";
|
||||
$url .= "&paymentType=AC";
|
||||
$url .= "&paymentType=MC";
|
||||
$url .= "&label=$invid";
|
||||
$url .= "&successURL=".$this->config->url."account/success";
|
||||
$url .= "&targets=Оплата счета ".$invid;
|
||||
$url .= "&sum=$ammount";
|
||||
|
||||
$this->data['status'] = "success";
|
||||
$this->data['url'] = $url;
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $errorPOST;
|
||||
}
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Данная платежная система отключена!";
|
||||
}
|
||||
}
|
||||
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
public function litepay() {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if($this->user->getAccessLevel() < 1) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$this->load->model('invoices');
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
if($this->config->litekassa == 1) {
|
||||
$errorPOST = $this->validatePOST();
|
||||
if(!$errorPOST) {
|
||||
$ammount = @$this->request->post['ammount'];
|
||||
|
||||
$server = $this->config->lk_server;
|
||||
$login = $this->config->lk_login;
|
||||
$password = $this->config->lk_password;
|
||||
|
||||
$userid = $this->user->getId();
|
||||
|
||||
$invoiceData = array(
|
||||
'user_id' => $userid,
|
||||
'invoice_ammount' => $ammount,
|
||||
'invoice_status' => 0,
|
||||
'system' => "Lite-Kassa"
|
||||
);
|
||||
$invid = $this->invoicesModel->createInvoice($invoiceData);
|
||||
|
||||
$signature = md5("$login:$ammount:$password:$invid");
|
||||
|
||||
$url = "$server";
|
||||
/* Параметры: */
|
||||
$url .= "?shop=$login";
|
||||
$url .= "&amount=$ammount";
|
||||
$url .= "&order=$invid";
|
||||
$url .= "&sign=$signature";
|
||||
$url .= "&desc=Оплата счета ".$invid;
|
||||
|
||||
$this->data['status'] = "success";
|
||||
$this->data['url'] = $url;
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $errorPOST;
|
||||
}
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Данная платежная система отключена!";
|
||||
}
|
||||
}
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
public function qiwi() {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if($this->user->getAccessLevel() < 1) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$this->load->model('invoices');
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
if($this->config->qiwi == 1) {
|
||||
$errorPOST = $this->validatePOST();
|
||||
if(!$errorPOST) {
|
||||
$ammount = @$this->request->post['ammount'];
|
||||
|
||||
$userid = $this->user->getId();
|
||||
|
||||
$invoiceData = array(
|
||||
'user_id' => $userid,
|
||||
'invoice_ammount' => $ammount,
|
||||
'invoice_status' => 0,
|
||||
'system' => "Qiwi Kassa"
|
||||
);
|
||||
$invid = $this->invoicesModel->createInvoice($invoiceData);
|
||||
|
||||
$params['publicKey'] = $this->config->qiwipublickey;
|
||||
$params['amount'] = number_format(round(floatval($ammount), 2, PHP_ROUND_HALF_DOWN), 2, '.', '');
|
||||
$params['billId'] = $invid;
|
||||
$params['account'] = $userid;
|
||||
$params['comment'] = "Оплата счета ".$invid;
|
||||
$params['successUrl'] = $this->config->url."account/success";
|
||||
if($this->config->qiwi_theme == 1) {
|
||||
$customFields = ['themeCode' => $this->config->qiwi_themecode];
|
||||
$params['customFields'] = $customFields;
|
||||
}
|
||||
|
||||
$this->data['status'] = "success";
|
||||
$this->data['url'] = "https://oplata.qiwi.com/create?".http_build_query($params, '', '&', PHP_QUERY_RFC3986);
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $errorPOST;
|
||||
}
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Данная платежная система отключена!";
|
||||
}
|
||||
}
|
||||
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
private function validatePOST() {
|
||||
|
||||
$this->load->library('validate');
|
||||
|
||||
$validateLib = new validateLibrary();
|
||||
|
||||
$result = null;
|
||||
|
||||
$ammount = @$this->request->post['ammount'];
|
||||
if(!$validateLib->money($ammount)) {
|
||||
$result = "Укажите сумму пополнения в допустимом формате!";
|
||||
}
|
||||
elseif(10 > $ammount || $ammount > 5000) {
|
||||
$result = "Укажите сумму от 10 до 5000 рублей!";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko (https://vk.com/id00v)
|
||||
*/
|
||||
class perevodController extends Controller {
|
||||
public function index() {
|
||||
$this->document->setActiveSection('account');
|
||||
$this->document->setActiveItem('perevod');
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 0) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->getChild(array('common/header', 'common/footer'));
|
||||
return $this->load->view('account/perevod', $this->data);
|
||||
}
|
||||
|
||||
public function ajax() {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if($this->user->getAccessLevel() < 1) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$this->data['userid'] = $userid = $this->user->getId();
|
||||
|
||||
$this->load->model('users');
|
||||
$this->load->model('waste');
|
||||
|
||||
$users = $this->usersModel->getUserById($userid, array(), array());
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
$errorPOST = $this->validate_POST();
|
||||
if(!$errorPOST) {
|
||||
$id = @$this->request->post['userid'];
|
||||
$sum = @$this->request->post['sum'];
|
||||
$balance = $users['user_balance'];
|
||||
|
||||
if ($balance >= $sum){
|
||||
if ($userid == $id){
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы указали свой ID";
|
||||
} else {
|
||||
$wasteData = array(
|
||||
'user_id' => $userid,
|
||||
'waste_ammount' => $sum,
|
||||
'waste_status' => 1,
|
||||
'waste_usluga' => "Перевод средств пользователю ID-".$id."",
|
||||
);
|
||||
$this->wasteModel->createWaste($wasteData);
|
||||
$this->usersModel->upUserBalance($id, $sum);
|
||||
$this->usersModel->downUserBalance($userid, $sum);
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Средства переведены!";
|
||||
}
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас недостаточно средств!";
|
||||
}
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $errorPOST;
|
||||
}
|
||||
}
|
||||
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
private function validate_POST() {
|
||||
$this->load->library('validate');
|
||||
|
||||
$validateLib = new validateLibrary();
|
||||
|
||||
$result = null;
|
||||
|
||||
$id = @$this->request->post['userid'];
|
||||
$sum = @$this->request->post['sum'];
|
||||
|
||||
|
||||
if(!$validateLib->money($sum)) {
|
||||
$result = "Укажите реальное число!";
|
||||
}
|
||||
elseif(!$this->usersModel->getTotalUsers(array('user_id' => $id))) {
|
||||
$result = "Данного ID не сушествует!";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -0,0 +1,181 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko (https://vk.com/id00v)
|
||||
*/
|
||||
class restoreController extends Controller {
|
||||
public function index() {
|
||||
$this->document->setActiveSection('account');
|
||||
$this->document->setActiveItem('restore');
|
||||
$this->data['recaptcha'] = $this->config->recaptcha;
|
||||
|
||||
if($this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы уже авторизированы!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->getChild(array('common/header', 'common/footer'));
|
||||
return $this->load->view('account/restore/index', $this->data);
|
||||
}
|
||||
|
||||
public function complete($userid = null, $restoreKey = null) {
|
||||
$this->document->setActiveSection('account');
|
||||
$this->document->setActiveItem('restore');
|
||||
|
||||
if($this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы уже авторизированы!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->model('users');
|
||||
$this->load->library('mail');
|
||||
|
||||
$error = $this->validate($userid, $restoreKey);
|
||||
if($error) {
|
||||
$this->session->data['error'] = $error;
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$user = $this->usersModel->getUserById($userid);
|
||||
|
||||
$chars="qazxswedcvfrtgbnhyujmkiolp1234567890QAZXSWEDCVFRTGBNHYUJMKIOLP";
|
||||
$max=12;
|
||||
$size=StrLen($chars)-1;
|
||||
$password=null;
|
||||
while($max--)
|
||||
$password.=$chars[rand(0,$size)];
|
||||
|
||||
$mailLib = new mailLibrary();
|
||||
|
||||
$mailLib->setFrom($this->config->mail_from);
|
||||
$mailLib->setSender($this->config->mail_sender);
|
||||
$mailLib->setTo($user['user_email']);
|
||||
$mailLib->setSubject('Новый пароль');
|
||||
|
||||
$mailData = array();
|
||||
|
||||
$mailData['firstname'] = $user['user_firstname'];
|
||||
$mailData['lastname'] = $user['user_lastname'];
|
||||
$mailData['email'] = $user['user_email'];
|
||||
$mailData['password'] = $password;
|
||||
|
||||
$text = $this->load->view('mail/account/newpassword', $mailData);
|
||||
|
||||
$mailLib->setText($text);
|
||||
|
||||
$mailLib->send();
|
||||
|
||||
$this->usersModel->updateUser($userid, array('user_password' => md5($password), 'user_restore_key' => null));
|
||||
$this->data['password'] = $password;
|
||||
|
||||
$this->getChild(array('common/loginheader', 'common/loginfooter'));
|
||||
return $this->load->view('account/restore/complete', $this->data);
|
||||
}
|
||||
|
||||
public function ajax() {
|
||||
if($this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы уже авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$this->load->library('mail');
|
||||
|
||||
$this->load->model('users');
|
||||
|
||||
$ip=$this->user->getRealIpAdress();
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
$errorPOST = $this->validatePOST();
|
||||
if(!$errorPOST) {
|
||||
$email = @$this->request->post['email'];
|
||||
|
||||
$user = $this->usersModel->getUserByEmail($email);
|
||||
|
||||
$restoreKey = md5(microtime());
|
||||
$this->usersModel->updateUser($user['user_id'], array('user_restore_key' => $restoreKey));
|
||||
|
||||
$mailLib = new mailLibrary();
|
||||
|
||||
$mailLib->setFrom($this->config->mail_from);
|
||||
$mailLib->setSender($this->config->mail_sender);
|
||||
$mailLib->setTo($user['user_email']);
|
||||
$mailLib->setSubject('Восстановление пароля');
|
||||
|
||||
$mailData = array();
|
||||
|
||||
$mailData['firstname'] = $user['user_firstname'];
|
||||
$mailData['lastname'] = $user['user_lastname'];
|
||||
$mailData['email'] = $user['user_email'];
|
||||
$mailData['ip'] = $ip;
|
||||
$mailData['restorelink'] = "".$this->config->url."account/restore/complete/".$user['user_id']."/".$restoreKey."";
|
||||
|
||||
$text = $this->load->view('mail/account/restore', $mailData);
|
||||
|
||||
$mailLib->setText($text);
|
||||
|
||||
$mailLib->send();
|
||||
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "На ваш E-Mail отправлена информация для восстановления пароля!";
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $errorPOST;
|
||||
}
|
||||
}
|
||||
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
private function validate($userid, $restoreKey) {
|
||||
$this->load->library('validate');
|
||||
|
||||
$validateLib = new validateLibrary();
|
||||
|
||||
$result = null;
|
||||
|
||||
if(!$validateLib->md5($restoreKey) || !$this->usersModel->getTotalUsers(array('user_id' => (int)$userid, 'user_restore_key' => $restoreKey))) {
|
||||
$result = "Указанный ключ восстановления неверный!";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function validatePOST() {
|
||||
$this->load->library('validate');
|
||||
|
||||
$validateLib = new validateLibrary();
|
||||
|
||||
$result = null;
|
||||
|
||||
$email = @$this->request->post['email'];
|
||||
$recaptcha = @$this->request->post['g-recaptcha-response'];
|
||||
|
||||
if(!$validateLib->email($email)) {
|
||||
$result = "Укажите свой реальный E-Mail!";
|
||||
}
|
||||
elseif($captcha != $captchahash) {
|
||||
$result = "Укажите правильный код с картинки!";
|
||||
}
|
||||
elseif($this->usersModel->getTotalUsers(array('user_email' => $email)) < 1) {
|
||||
$result = "Пользователь с указанным E-Mail не зарегистрирован!";
|
||||
}
|
||||
if(!$recaptcha) return 'Подтвердите, что вы не робот!';
|
||||
$url = 'https://www.google.com/recaptcha/api/siteverify';
|
||||
$data = array('secret' => $this->config->secret_recaptcha, 'response' => $recaptcha);
|
||||
$options = array(
|
||||
'http' => array(
|
||||
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
|
||||
'method' => 'POST',
|
||||
'remoteip' => 'remoteip',
|
||||
'content' => http_build_query($data),
|
||||
)
|
||||
);
|
||||
|
||||
$context = stream_context_create($options);
|
||||
$recaptcha_get = json_decode(file_get_contents($url, false, $context))->{'success'};
|
||||
if($recaptcha_get != '1') return 'Проверьте правильность капчи!';
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko (https://vk.com/id00v)
|
||||
*/
|
||||
class successController extends Controller {
|
||||
public function index() {
|
||||
$this->document->setActiveSection('account');
|
||||
$this->document->setActiveItem('pay');
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 0) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
|
||||
if($this->config->interkassa == 1) {
|
||||
$this->load->model('users');
|
||||
$this->load->model('invoices');
|
||||
$this->load->model('waste');
|
||||
|
||||
$secret_key = $this->config->ik_secretkey;
|
||||
$ik_shop_id = $this->config->ik_shopid;
|
||||
|
||||
$err[1] = 'Ошибка - Неверная сумма платежа!';
|
||||
$err[2] = 'Ошибка - Shop ID!';
|
||||
$err[3] = 'Ошибка - Не верный ID платежа!';
|
||||
$err[3] = 'Ошибка - Данный счет уже оплачен!';
|
||||
|
||||
//Получение информации о платеже от системы Interkassa
|
||||
$post_shop_id = trim(stripslashes($_POST['ik_co_id'])); //Номер сайта продавца (eshopId);
|
||||
$ik_payment_amount = trim(stripslashes($_POST['ik_payment_amount'])); //Сумма платежа (recipientAmount);
|
||||
$ik_payment_id = trim(stripslashes($_POST['ik_payment_id'])); //Идентификатор платежа
|
||||
$ik_pm_no = trim(stripslashes($_POST['ik_pm_no'])); //id
|
||||
$ik_am = trim(stripslashes($_POST['ik_am'])); //im
|
||||
$ik_paysystem_alias = trim(stripslashes($_POST['ik_paysystem_alias'])); //Способ оплаты
|
||||
$ik_baggage_fields = trim(stripslashes($_POST['ik_baggage_fields'])); //пользовательское поле
|
||||
$ik_payment_state = trim(stripslashes($_POST['ik_payment_state'])); //Статус платежа (paymentStatus);
|
||||
$ik_trans_id = trim(stripslashes($_POST['ik_trans_id'])); //внутренний номер платежа
|
||||
$ik_currency_exch = trim(stripslashes($_POST['ik_currency_exch'])); //Валюта платежа (recipientCurrency);
|
||||
$ik_fees_payer = trim(stripslashes($_POST['ik_fees_payer'])); //плательщик комиссии
|
||||
|
||||
$sing_hash_str = $ik_shop_id.':'.
|
||||
$ik_payment_amount.':'.
|
||||
$ik_payment_id.':'.
|
||||
$ik_paysystem_alias.':'.
|
||||
$ik_baggage_fields.':'.
|
||||
$ik_payment_state.':'.
|
||||
$ik_trans_id.':'.
|
||||
$ik_currency_exch.':'.
|
||||
$ik_fees_payer.':'.$secret_key;
|
||||
|
||||
|
||||
$userid = $this->user->getId();
|
||||
$invoice = $this->invoicesModel->getInvoiceById($ik_pm_no);
|
||||
|
||||
if($invoice['invoice_ammount'] == $ik_am) {
|
||||
if($post_shop_id == $ik_shop_id) {
|
||||
if($invoice['invoice_id'] == $ik_pm_no){
|
||||
if($invoice['invoice_status'] == 0) {
|
||||
$this->usersModel->upUserBalance($userid, $ik_am);
|
||||
$this->invoicesModel->updateInvoice($ik_pm_no, array('invoice_status' => 1));
|
||||
|
||||
$userid = $invoice['user_id'];
|
||||
$user = $this->usersModel->getUserById($userid);
|
||||
|
||||
if($ammount > 50){
|
||||
$this->usersModel->updateUser($userid, $userData = array('user_promised_pay' => 0));
|
||||
}
|
||||
|
||||
$wasteData = array(
|
||||
'user_id' => $userid,
|
||||
'waste_ammount' => $ammount,
|
||||
'waste_status' => 0,
|
||||
'waste_usluga' => "Пополнение баланса пользователя",
|
||||
);
|
||||
$this->wasteModel->createWaste($wasteData);
|
||||
|
||||
$this->usersModel->upUserBalance($userid, $ammount);
|
||||
|
||||
$bonus_percent = $this->config->bonus_percent;
|
||||
$getbonus = ($ammount * (1 + $bonus_percent / 100)) - $ammount;
|
||||
$this->usersModel->upUserBonuses($userid, $getbonus);
|
||||
} else {
|
||||
$this->response->redirect($this->config->url . 'account/error');
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $err[4];
|
||||
}
|
||||
} else {
|
||||
$this->response->redirect($this->config->url . 'account/error');
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $err[3];
|
||||
}
|
||||
} else {
|
||||
$this->response->redirect($this->config->url . 'account/error');
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $err[2];
|
||||
}
|
||||
} else {
|
||||
$this->response->redirect($this->config->url . 'account/error');
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $err[1];
|
||||
}
|
||||
}
|
||||
$this->getChild(array('common/header', 'common/footer'));
|
||||
return $this->load->view('account/success', $this->data);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko (https://vk.com/id00v)
|
||||
*/
|
||||
class wasteController extends Controller {
|
||||
private $limit = 20;
|
||||
public function index($page = 1) {
|
||||
$this->document->setActiveSection('account');
|
||||
$this->document->setActiveItem('waste');
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 1) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->library('pagination');
|
||||
$this->load->model('waste');
|
||||
|
||||
$pl = array(
|
||||
'start' => ($page - 1) * $this->limit,
|
||||
);
|
||||
$userid = $this->user->getId();
|
||||
$total = $this->wasteModel->getTotalWaste(array('user_id' => (int)$userid));
|
||||
$waste = $this->wasteModel->getWaste(array('user_id' => (int)$userid), array(), array(), $pl);
|
||||
|
||||
|
||||
$paginationLib = new paginationLibrary();
|
||||
|
||||
$paginationLib->total = $total;
|
||||
$paginationLib->page = $page;
|
||||
$paginationLib->limit = $this->limit;
|
||||
$paginationLib->url = $this->config->url . 'account/waste/index/{page}';
|
||||
|
||||
$pagination = $paginationLib->render();
|
||||
|
||||
$this->data['waste'] = $waste;
|
||||
$this->data['pagination'] = $pagination;
|
||||
|
||||
$this->getChild(array('common/header', 'common/footer'));
|
||||
return $this->load->view('account/waste', $this->data);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class indexController extends Controller {
|
||||
public function index($page = 1) {
|
||||
$this->document->setActiveSection('admin/checksys');
|
||||
$this->document->setActiveItem('index');
|
||||
|
||||
$this->data['token'] = $this->config->token;
|
||||
$this->data['url'] = $this->config->url;
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 2) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->data['user_access_level'] = $this->user->getAccessLevel();
|
||||
|
||||
$this->getChild(array('common/admheader', 'common/footer'));
|
||||
return $this->load->view('admin/checksys/index', $this->data);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class indexController extends Controller {
|
||||
public function index($userid = null) {
|
||||
$this->document->setActiveSection('admin/emailinfo');
|
||||
$this->document->setActiveItem('index');
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 2) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->getChild(array('common/admheader', 'common/footer'));
|
||||
return $this->load->view('admin/emailinfo/index', $this->data);
|
||||
}
|
||||
|
||||
public function ajax($userid = null) {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if($this->user->getAccessLevel() < 3) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$this->load->model('users');
|
||||
$this->load->library('mail');
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
$text = @$this->request->post['text'];
|
||||
$data=$this->usersModel->getUsers();
|
||||
foreach($data as $tmp){
|
||||
$email=$tmp['user_email'];
|
||||
$firstname=$tmp['user_firstname'];
|
||||
$lastname=$tmp['user_lastname'];
|
||||
|
||||
$mailLib = new mailLibrary();
|
||||
$mailLib->setFrom($this->config->mail_from);
|
||||
$mailLib->setSender($this->config->mail_sender);
|
||||
$mailLib->setTo($email);
|
||||
$mailLib->setSubject('Обратите внимание!');
|
||||
|
||||
$mailData = array();
|
||||
$mailData['firstname'] = $firstname;
|
||||
$mailData['lastname'] = $lastname;
|
||||
$mailData['text'] = $text;
|
||||
|
||||
$texts = $this->load->view('mail/info/users', $mailData);
|
||||
|
||||
$mailLib->setText($texts);
|
||||
$mailLib->send();
|
||||
}
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Рассылка успешно завершенна.";
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Не POST данные";
|
||||
}
|
||||
return json_encode($this->data);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,140 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class createController extends Controller {
|
||||
public function index() {
|
||||
$this->document->setActiveSection('admin/games');
|
||||
$this->document->setActiveItem('create');
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 3) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->data['queryDrivers'] = $this->getQueryDrivers();
|
||||
|
||||
$this->getChild(array('common/admheader', 'common/footer'));
|
||||
return $this->load->view('admin/games/create', $this->data);
|
||||
}
|
||||
|
||||
public function ajax() {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if($this->user->getAccessLevel() < 3) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$this->load->model('games');
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
$errorPOST = $this->validatePOST();
|
||||
if(!$errorPOST) {
|
||||
$name = @$this->request->post['name'];
|
||||
$code = @$this->request->post['code'];
|
||||
$query = @$this->request->post['query'];
|
||||
$minslots = @$this->request->post['minslots'];
|
||||
$maxslots = @$this->request->post['maxslots'];
|
||||
$minport = @$this->request->post['minport'];
|
||||
$maxport = @$this->request->post['maxport'];
|
||||
$price = @$this->request->post['price'];
|
||||
$status = @$this->request->post['status'];
|
||||
$cpu = @$this->request->post['cores'];
|
||||
$ram = @$this->request->post['ram'];
|
||||
$ssd = @$this->request->post['ssd'];
|
||||
|
||||
$gameData = array(
|
||||
'game_name' => $name,
|
||||
'game_code' => $code,
|
||||
'game_query' => $query,
|
||||
'game_min_slots' => (int)$minslots,
|
||||
'game_max_slots' => (int)$maxslots,
|
||||
'game_min_port' => (int)$minport,
|
||||
'game_max_port' => (int)$maxport,
|
||||
'game_price' => (float)$price,
|
||||
'game_status' => (int)$status,
|
||||
'game_ram' => (int)$ram,
|
||||
'game_cores' => (float)$cpu,
|
||||
'game_ssd' => (int)$ssd
|
||||
);
|
||||
|
||||
$this->gamesModel->createGame($gameData);
|
||||
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Вы успешно создали игру!";
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $errorPOST;
|
||||
}
|
||||
}
|
||||
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
private function validatePOST() {
|
||||
$this->load->library('validate');
|
||||
|
||||
$validateLib = new validateLibrary();
|
||||
|
||||
$result = null;
|
||||
|
||||
$name = @$this->request->post['name'];
|
||||
$code = @$this->request->post['code'];
|
||||
$query = @$this->request->post['query'];
|
||||
$minslots = @$this->request->post['minslots'];
|
||||
$maxslots = @$this->request->post['maxslots'];
|
||||
$minport = @$this->request->post['minport'];
|
||||
$maxport = @$this->request->post['maxport'];
|
||||
$price = @$this->request->post['price'];
|
||||
$status = @$this->request->post['status'];
|
||||
$cpu = @$this->request->post['cores'];
|
||||
$ram = @$this->request->post['ram'];
|
||||
$ssd = @$this->request->post['ssd'];
|
||||
|
||||
if(mb_strlen($name) < 2 || mb_strlen($name) > 92) {
|
||||
$result = "Название игры должно содержать от 2 до 92 символов!";
|
||||
}
|
||||
elseif(mb_strlen($code) < 2 || mb_strlen($code) > 8) {
|
||||
$result = "Код игры должен содержать от 2 до 8 символов!";
|
||||
}
|
||||
elseif(!in_array($query, $this->getQueryDrivers())) {
|
||||
$result = "Укажите допустимый Query-драйвер.";
|
||||
}
|
||||
elseif(!$validateLib->money($price)) {
|
||||
$result = "Укажите допустимую стоимость!";
|
||||
}
|
||||
elseif(!$validateLib->money($cpu)) {
|
||||
$result = "Укажите допустимое количество ядер!";
|
||||
}
|
||||
elseif(!$validateLib->money($ram)) {
|
||||
$result = "Укажите допустимый объем оперативной памяти!";
|
||||
}
|
||||
elseif(!$validateLib->money($ssd)) {
|
||||
$result = "Укажите допустимую объем жесткого диска!";
|
||||
}
|
||||
elseif($status < 0 || $status > 1) {
|
||||
$result = "Укажите допустимый статус!";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
function getQueryDrivers() {
|
||||
$result = array();
|
||||
$drivers = glob(ENGINE_DIR . 'libs/query/*.driver.php');
|
||||
foreach ($drivers as $filename) {
|
||||
$result[] = basename($filename, ".driver.php");
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,204 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class editController extends Controller {
|
||||
public function index($gameid = null) {
|
||||
$this->document->setActiveSection('admin/games');
|
||||
$this->document->setActiveItem('edit');
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 3) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->model('games');
|
||||
|
||||
$error = $this->validate($gameid);
|
||||
if($error) {
|
||||
$this->session->data['error'] = $error;
|
||||
$this->response->redirect($this->config->url . 'admin/games/index');
|
||||
}
|
||||
|
||||
$game = $this->gamesModel->getGameById($gameid);
|
||||
|
||||
$this->data['game'] = $game;
|
||||
|
||||
$this->data['queryDrivers'] = $this->getQueryDrivers();
|
||||
|
||||
$this->getChild(array('common/admheader', 'common/footer'));
|
||||
return $this->load->view('admin/games/edit', $this->data);
|
||||
}
|
||||
|
||||
public function ajax($gameid = null) {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if($this->user->getAccessLevel() < 3) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$this->load->model('games');
|
||||
|
||||
$error = $this->validate($gameid);
|
||||
if($error) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $error;
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
$errorPOST = $this->validatePOST();
|
||||
if(!$errorPOST) {
|
||||
$name = @$this->request->post['name'];
|
||||
$code = @$this->request->post['code'];
|
||||
$query = @$this->request->post['query'];
|
||||
$minslots = @$this->request->post['minslots'];
|
||||
$maxslots = @$this->request->post['maxslots'];
|
||||
$minport = @$this->request->post['minport'];
|
||||
$maxport = @$this->request->post['maxport'];
|
||||
$price = @$this->request->post['price'];
|
||||
$status = @$this->request->post['status'];
|
||||
$cpu = @$this->request->post['cores'];
|
||||
$ram = @$this->request->post['ram'];
|
||||
$ssd = @$this->request->post['ssd'];
|
||||
|
||||
$gameData = array(
|
||||
'game_name' => $name,
|
||||
'game_code' => $code,
|
||||
'game_query' => $query,
|
||||
'game_min_slots' => (int)$minslots,
|
||||
'game_max_slots' => (int)$maxslots,
|
||||
'game_min_port' => (int)$minport,
|
||||
'game_max_port' => (int)$maxport,
|
||||
'game_price' => (float)$price,
|
||||
'game_status' => (int)$status,
|
||||
'game_ram' => (int)$ram,
|
||||
'game_cores' => (float)$cpu,
|
||||
'game_ssd' => (int)$ssd
|
||||
);
|
||||
|
||||
$this->gamesModel->updateGame($gameid, $gameData);
|
||||
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Вы успешно отредактировали информацию об игре!";
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $errorPOST;
|
||||
}
|
||||
}
|
||||
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
public function delete($gameid = null) {
|
||||
$this->document->setActiveSection('admin');
|
||||
$this->document->setActiveItem('games');
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 3) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->model('games');
|
||||
|
||||
$error = $this->validate($gameid);
|
||||
if($error) {
|
||||
$this->session->data['error'] = $error;
|
||||
$this->response->redirect($this->config->url . 'admin/games/index');
|
||||
}
|
||||
|
||||
$this->gamesModel->deleteGame($gameid);
|
||||
|
||||
$this->session->data['success'] = "Вы успешно удалили игру!";
|
||||
$this->response->redirect($this->config->url . 'admin/games/index');
|
||||
return null;
|
||||
}
|
||||
|
||||
private function validate($gameid) {
|
||||
$result = null;
|
||||
|
||||
if(!$this->gamesModel->getTotalGames(array('game_id' => (int)$gameid))) {
|
||||
$result = "Запрашиваемая игра не существует!";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function validatePOST() {
|
||||
$this->load->library('validate');
|
||||
|
||||
$validateLib = new validateLibrary();
|
||||
|
||||
$result = null;
|
||||
|
||||
$name = @$this->request->post['name'];
|
||||
$code = @$this->request->post['code'];
|
||||
$query = @$this->request->post['query'];
|
||||
$minslots = @$this->request->post['minslots'];
|
||||
$maxslots = @$this->request->post['maxslots'];
|
||||
$minport = @$this->request->post['minport'];
|
||||
$maxport = @$this->request->post['maxport'];
|
||||
$price = @$this->request->post['price'];
|
||||
$status = @$this->request->post['status'];
|
||||
$cpu = @$this->request->post['cores'];
|
||||
$ram = @$this->request->post['ram'];
|
||||
$ssd = @$this->request->post['ssd'];
|
||||
|
||||
if(mb_strlen($name) < 2 || mb_strlen($name) > 92) {
|
||||
$result = "Название игры должно содержать от 2 до 92 символов!";
|
||||
}
|
||||
elseif(mb_strlen($code) < 2 || mb_strlen($code) > 8) {
|
||||
$result = "Код игры должен содержать от 2 до 8 символов!";
|
||||
}
|
||||
elseif(!in_array($query, $this->getQueryDrivers())) {
|
||||
$result = "Укажите допустимый Query-драйвер.";
|
||||
}
|
||||
elseif($maxslots < $minslots)
|
||||
{
|
||||
$result = "Укажите допустимый интервал слотов.";
|
||||
}
|
||||
elseif($maxport < $minport)
|
||||
{
|
||||
$result = "Укажите допустимый интервал портов.";
|
||||
}
|
||||
elseif(!$validateLib->money($price)) {
|
||||
$result = "Укажите допустимую стоимость!";
|
||||
}
|
||||
elseif(!$validateLib->money($cpu)) {
|
||||
$result = "Укажите допустимое количество ядер!";
|
||||
}
|
||||
elseif(!$validateLib->money($ram)) {
|
||||
$result = "Укажите допустимый объем оперативной памяти!";
|
||||
}
|
||||
elseif(!$validateLib->money($ssd)) {
|
||||
$result = "Укажите допустимую объем жесткого диска!";
|
||||
}
|
||||
elseif($status < 0 || $status > 1) {
|
||||
$result = "Укажите допустимый статус!";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
function getQueryDrivers() {
|
||||
$result = array();
|
||||
$drivers = glob(ENGINE_DIR . 'libs/query/*.driver.php');
|
||||
foreach ($drivers as $filename) {
|
||||
$result[] = basename($filename, ".driver.php");
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class indexController extends Controller {
|
||||
private $limit = 20;
|
||||
public function index($page = 1) {
|
||||
$this->document->setActiveSection('admin/games');
|
||||
$this->document->setActiveItem('index');
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 3) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->library('pagination');
|
||||
$this->load->model('games');
|
||||
|
||||
$options = array(
|
||||
'start' => ($page - 1) * $this->limit,
|
||||
'limit' => $this->limit
|
||||
);
|
||||
|
||||
$total = $this->gamesModel->getTotalGames();
|
||||
$games = $this->gamesModel->getGames(array(), array(), $options);
|
||||
|
||||
$paginationUrl = '/admin/games/index/index/{page}';
|
||||
$paginationLib = new paginationLibrary();
|
||||
$paginationLib->total = $total;
|
||||
$paginationLib->page = $page;
|
||||
$paginationLib->limit = $this->limit;
|
||||
$paginationLib->url = $paginationUrl;
|
||||
$pagination = $paginationLib->render();
|
||||
|
||||
$this->data['games'] = $games;
|
||||
$this->data['pagination'] = $pagination;
|
||||
|
||||
$this->getChild(array('common/admheader', 'common/footer'));
|
||||
return $this->load->view('admin/games/index', $this->data);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class indexController extends Controller {
|
||||
public function index() {
|
||||
$this->document->setActiveSection('admin');
|
||||
$this->document->setActiveItem('index');
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 2) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$getlvl = $this->user->getAccessLevel();
|
||||
$this->data['getlvl'] = $getlvl;
|
||||
|
||||
$this->load->model('servers');
|
||||
$this->load->model('tickets');
|
||||
$this->load->model('users');
|
||||
$this->load->model('invoices');
|
||||
$this->load->model('waste');
|
||||
|
||||
$userid = $this->user->getId();
|
||||
|
||||
|
||||
$options = array(
|
||||
'start' => 0,
|
||||
'limit' => 50000
|
||||
);
|
||||
|
||||
$tickets = $this->ticketsModel->getTickets(array(), array('users'), array(), array());
|
||||
$this->data['tickets'] = $tickets;
|
||||
|
||||
$tservers = $this->serversModel->getServers(array(), array('games', 'locations'), array(), array());
|
||||
$this->data['tservers'] = $tservers;
|
||||
|
||||
$invoices = $this->invoicesModel->getInvoices(array(), array('users'), array(), $options);
|
||||
$this->data['invoices'] = $invoices;
|
||||
|
||||
$users = $this->usersModel->getUsers(array(), array(), $options);
|
||||
$this->data['users'] = $users;
|
||||
|
||||
$hostin = array(
|
||||
'waste_date_add' => 'DESC'
|
||||
);
|
||||
$pl = array(
|
||||
'start' => 0,
|
||||
'limit' => 10
|
||||
);
|
||||
$waste = $this->wasteModel->getWaste(array(), array('users'), $hostin, $pl);
|
||||
$this->data['waste'] = $waste;
|
||||
|
||||
$this->getChild(array('common/admheader', 'common/footer'));
|
||||
return $this->load->view('admin/index', $this->data);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class indexController extends Controller {
|
||||
private $limit = 20;
|
||||
public function index($page = 1) {
|
||||
$this->document->setActiveSection('admin/infobox');
|
||||
$this->document->setActiveItem('index');
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 2) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->library('pagination');
|
||||
$this->load->model('mail');
|
||||
|
||||
$getData = array();
|
||||
|
||||
$getSort = array(
|
||||
'status' => 'DESC',
|
||||
'inbox_date_add' => 'DESC'
|
||||
);
|
||||
|
||||
$getOptions = array(
|
||||
'start' => ($page - 1) * $this->limit,
|
||||
'limit' => $this->limit
|
||||
);
|
||||
|
||||
$total = $this->mailModel->getTotalInbox($getData);
|
||||
$this->data['mail'] = $this->mailModel->getInboxs($getData, $getSort, $getOptions);
|
||||
|
||||
$paginationUrl = '/admin/infobox/index/index/{page}';
|
||||
$paginationLib = new paginationLibrary();
|
||||
$paginationLib->total = $total;
|
||||
$paginationLib->page = $page;
|
||||
$paginationLib->limit = $this->limit;
|
||||
$paginationLib->url = $paginationUrl;
|
||||
$pagination = $paginationLib->render();
|
||||
|
||||
$this->data['pagination'] = $pagination;
|
||||
|
||||
$this->getChild(array('common/admheader', 'common/footer'));
|
||||
return $this->load->view('admin/infobox/index', $this->data);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class sendController extends Controller {
|
||||
public function index($id = null) {
|
||||
$this->document->setActiveSection('admin/infobox');
|
||||
$this->document->setActiveItem('send');
|
||||
$this->data['url'] = $this->config->url;
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 3) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->model('mail');
|
||||
$this->data['mail'] = $this->mailModel->getInboxById($id);
|
||||
|
||||
$this->getChild(array('common/admheader', 'common/footer'));
|
||||
return $this->load->view('admin/infobox/send', $this->data);
|
||||
}
|
||||
|
||||
public function sendMForm($id = null) {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if($this->user->getAccessLevel() < 3) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$this->load->model('mail');
|
||||
$this->load->library('mail');
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
if(@$this->request->post['msg'] == ""){
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Введите текст ответа!";
|
||||
}elseif(@$this->request->post['msg'] != ""){
|
||||
$text = @$this->request->post['msg'];
|
||||
$dell = @$this->request->post['dell'];
|
||||
$data = $this->mailModel->getInboxById($id);
|
||||
|
||||
$email = $data['user_email'];
|
||||
$firstname = $data['user_firstname'];
|
||||
$lastname = $data['user_lastname'];
|
||||
|
||||
$mailLib = new mailLibrary();
|
||||
$mailLib->setFrom($this->config->mail_from);
|
||||
$mailLib->setSender($this->config->mail_sender);
|
||||
$mailLib->setTo($email);
|
||||
$mailLib->setSubject('Ответ на ваше сообщение');
|
||||
|
||||
$mailData = array();
|
||||
$mailData['firstname'] = $firstname;
|
||||
$mailData['lastname'] = $lastname;
|
||||
$mailData['text'] = $text;
|
||||
|
||||
$texts = $this->load->view('mail/infobox/user', $mailData);
|
||||
|
||||
$mailLib->setText($texts);
|
||||
$mailLib->send();
|
||||
|
||||
|
||||
if($dell) {
|
||||
$this->mailModel->deleteInbox($id);
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Сообщение отправлено, и удалено!";
|
||||
} else {
|
||||
$this->mailModel->updateInbox($id, array('status' => 0));
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Сообщение отправлено!";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Не POST данные";
|
||||
}
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class indexController extends Controller {
|
||||
private $limit = 20;
|
||||
public function index($page = 1) {
|
||||
$this->document->setActiveSection('admin/invoices');
|
||||
$this->document->setActiveItem('index');
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 2) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->library('pagination');
|
||||
$this->load->model('invoices');
|
||||
|
||||
$userid = @$this->request->get['userid'];
|
||||
|
||||
$getData = array();
|
||||
|
||||
if(!empty($userid)) {
|
||||
$getData['invoices.user_id'] = (int)$userid;
|
||||
}
|
||||
|
||||
$getOptions = array(
|
||||
'start' => ($page - 1) * $this->limit,
|
||||
'limit' => $this->limit
|
||||
);
|
||||
|
||||
$total = $this->invoicesModel->getTotalInvoices($getData);
|
||||
$invoices = $this->invoicesModel->getInvoices($getData, array('users'), array(), $getOptions);
|
||||
|
||||
$paginationUrl = '/admin/invoices/index/index/{page}';
|
||||
if(!empty($userid)) {
|
||||
$paginationUrl .= '&userid=' . $userid;
|
||||
}
|
||||
|
||||
$paginationLib = new paginationLibrary();
|
||||
$paginationLib->total = $total;
|
||||
$paginationLib->page = $page;
|
||||
$paginationLib->limit = $this->limit;
|
||||
$paginationLib->url = $paginationUrl;
|
||||
$pagination = $paginationLib->render();
|
||||
|
||||
$this->data['invoices'] = $invoices;
|
||||
$this->data['pagination'] = $pagination;
|
||||
|
||||
$this->getChild(array('common/admheader', 'common/footer'));
|
||||
return $this->load->view('admin/invoices/index', $this->data);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class createController extends Controller {
|
||||
public function index() {
|
||||
$this->document->setActiveSection('admin/locations');
|
||||
$this->document->setActiveItem('create');
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 3) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->getChild(array('common/admheader', 'common/footer'));
|
||||
return $this->load->view('admin/locations/create', $this->data);
|
||||
}
|
||||
|
||||
public function ajax() {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if($this->user->getAccessLevel() < 3) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$this->load->model('locations');
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
$errorPOST = $this->validatePOST();
|
||||
if(!$errorPOST) {
|
||||
$name = @$this->request->post['name'];
|
||||
$ip = @$this->request->post['ip'];
|
||||
$ip2 = @$this->request->post['ip2'];
|
||||
$user = @$this->request->post['user'];
|
||||
$password = @$this->request->post['password'];
|
||||
$password2 = @$this->request->post['password2'];
|
||||
$status = @$this->request->post['status'];
|
||||
|
||||
$locationData = array(
|
||||
'location_name' => $name,
|
||||
'location_ip' => $ip,
|
||||
'location_ip2' => $ip2,
|
||||
'location_user' => $user,
|
||||
'location_password' => $password,
|
||||
'location_status' => (int)$status
|
||||
);
|
||||
|
||||
$this->locationsModel->createLocation($locationData);
|
||||
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Вы успешно создали локацию!";
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $errorPOST;
|
||||
}
|
||||
}
|
||||
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
private function validatePOST() {
|
||||
$this->load->library('validate');
|
||||
|
||||
$validateLib = new validateLibrary();
|
||||
|
||||
$result = null;
|
||||
|
||||
$name = @$this->request->post['name'];
|
||||
$ip = @$this->request->post['ip'];
|
||||
$ip2 = @$this->request->post['ip2'];
|
||||
$user = @$this->request->post['user'];
|
||||
$password = @$this->request->post['password'];
|
||||
$password2 = @$this->request->post['password2'];
|
||||
$status = @$this->request->post['status'];
|
||||
|
||||
if(mb_strlen($name) < 2 || mb_strlen($name) > 32) {
|
||||
$result = "Название локации должно содержать от 2 до 32 символов!";
|
||||
}
|
||||
elseif(!$validateLib->ip($ip)) {
|
||||
$result = "Укажите допустимый IP!";
|
||||
}
|
||||
elseif(!$validateLib->ip($ip2)) {
|
||||
$result = "Укажите допустимый IP!";
|
||||
}
|
||||
elseif(mb_strlen($user) < 2 || mb_strlen($user) > 32) {
|
||||
$result = "Имя пользователя должно содержать от 2 до 32 символов!";
|
||||
}
|
||||
elseif(!$validateLib->password($password)) {
|
||||
$result = "Пароль должен содержать от 6 до 32 латинских букв, цифр и знаков <i>,.!?_-</i>!";
|
||||
}
|
||||
elseif($password != $password2) {
|
||||
$result = "Введенные вами пароли не совпадают!";
|
||||
}
|
||||
elseif($status < 0 || $status > 1) {
|
||||
$result = "Укажите допустимый статус!";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,171 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class editController extends Controller {
|
||||
public function index($locationid = null) {
|
||||
$this->document->setActiveSection('admin/locations');
|
||||
$this->document->setActiveItem('create');
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 3) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->model('locations');
|
||||
|
||||
$error = $this->validate($locationid);
|
||||
if($error) {
|
||||
$this->session->data['error'] = $error;
|
||||
$this->response->redirect($this->config->url . 'admin/locations/index');
|
||||
}
|
||||
|
||||
$location = $this->locationsModel->getLocationById($locationid);
|
||||
|
||||
$this->data['location'] = $location;
|
||||
|
||||
$this->getChild(array('common/admheader', 'common/footer'));
|
||||
return $this->load->view('admin/locations/edit', $this->data);
|
||||
}
|
||||
|
||||
public function ajax($locationid = null) {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if($this->user->getAccessLevel() < 3) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$this->load->model('locations');
|
||||
|
||||
$error = $this->validate($locationid);
|
||||
if($error) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $error;
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
$errorPOST = $this->validatePOST();
|
||||
if(!$errorPOST) {
|
||||
$name = @$this->request->post['name'];
|
||||
$ip = @$this->request->post['ip'];
|
||||
$ip2 = @$this->request->post['ip2'];
|
||||
$user = @$this->request->post['user'];
|
||||
$password = @$this->request->post['password'];
|
||||
$password2 = @$this->request->post['password2'];
|
||||
$editpassword = @$this->request->post['editpassword'];
|
||||
$status = @$this->request->post['status'];
|
||||
$location_games = @$this->request->post['location_games'];
|
||||
|
||||
$locationData = array(
|
||||
'location_name' => $name,
|
||||
'location_ip' => $ip,
|
||||
'location_ip2' => $ip2,
|
||||
'location_user' => $user,
|
||||
'location_status' => (int)$status,
|
||||
'location_games' => $location_games
|
||||
);
|
||||
|
||||
if($editpassword) {
|
||||
$locationData['location_password'] = $password;
|
||||
}
|
||||
|
||||
$this->locationsModel->updateLocation($locationid, $locationData);
|
||||
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Вы успешно отредактировали локацию!";
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $errorPOST;
|
||||
}
|
||||
}
|
||||
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
public function delete($locationid = null) {
|
||||
$this->document->setActiveSection('admin');
|
||||
$this->document->setActiveItem('locations');
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 3) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->model('locations');
|
||||
|
||||
$error = $this->validate($locationid);
|
||||
if($error) {
|
||||
$this->session->data['error'] = $error;
|
||||
$this->response->redirect($this->config->url . 'admin/locations/index');
|
||||
}
|
||||
|
||||
$this->locationsModel->deleteLocation($locationid);
|
||||
|
||||
$this->session->data['success'] = "Вы успешно удалили локацию!";
|
||||
$this->response->redirect($this->config->url . 'admin/locations/index');
|
||||
return null;
|
||||
}
|
||||
|
||||
private function validate($locationid) {
|
||||
$result = null;
|
||||
|
||||
if(!$this->locationsModel->getTotalLocations(array('location_id' => (int)$locationid))) {
|
||||
$result = "Запрашиваемая локация не существует!";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function validatePOST() {
|
||||
$this->load->library('validate');
|
||||
|
||||
$validateLib = new validateLibrary();
|
||||
|
||||
$result = null;
|
||||
|
||||
$name = @$this->request->post['name'];
|
||||
$ip = @$this->request->post['ip'];
|
||||
$user = @$this->request->post['user'];
|
||||
$editpassword = @$this->request->post['editpassword'];
|
||||
$password = @$this->request->post['password'];
|
||||
$password2 = @$this->request->post['password2'];
|
||||
$status = @$this->request->post['status'];
|
||||
|
||||
if(mb_strlen($name) < 2 || mb_strlen($name) > 32) {
|
||||
$result = "Название локации должно содержать от 2 до 32 символов!";
|
||||
}
|
||||
elseif(!$validateLib->ip($ip)) {
|
||||
$result = "Укажите допустимый IP!";
|
||||
}
|
||||
elseif(mb_strlen($user) < 2 || mb_strlen($user) > 32) {
|
||||
$result = "Имя пользователя должно содержать от 2 до 32 символов!";
|
||||
}
|
||||
elseif($editpassword) {
|
||||
if(!$validateLib->password($password)) {
|
||||
$result = "Пароль должен содержать от 6 до 32 латинских букв, цифр и знаков <i>,.!?_-</i>!";
|
||||
}
|
||||
elseif($password != $password2) {
|
||||
$result = "Введенные вами пароли не совпадают!";
|
||||
}
|
||||
}
|
||||
elseif($status < 0 || $status > 1) {
|
||||
$result = "Укажите допустимый статус!";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class indexController extends Controller {
|
||||
private $limit = 20;
|
||||
public function index($page = 1) {
|
||||
$this->document->setActiveSection('admin/locations');
|
||||
$this->document->setActiveItem('index');
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 3) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->library('pagination');
|
||||
$this->load->model('locations');
|
||||
|
||||
$options = array(
|
||||
'start' => ($page - 1) * $this->limit,
|
||||
'limit' => $this->limit
|
||||
);
|
||||
|
||||
$total = $this->locationsModel->getTotalLocations();
|
||||
$locations = $this->locationsModel->getLocations(array(), array(), $options);
|
||||
|
||||
$paginationUrl = '/admin/locations/index/index/{page}';
|
||||
$paginationLib = new paginationLibrary();
|
||||
$paginationLib->total = $total;
|
||||
$paginationLib->page = $page;
|
||||
$paginationLib->limit = $this->limit;
|
||||
$paginationLib->url = $paginationUrl;
|
||||
$pagination = $paginationLib->render();
|
||||
|
||||
$this->data['locations'] = $locations;
|
||||
$this->data['pagination'] = $pagination;
|
||||
|
||||
$this->getChild(array('common/admheader', 'common/footer'));
|
||||
return $this->load->view('admin/locations/index', $this->data);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class createController extends Controller {
|
||||
public function index() {
|
||||
$this->document->setActiveSection('admin/mods');
|
||||
$this->document->setActiveItem('create');
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 3) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
$this->load->model('games');
|
||||
$options = array(
|
||||
'start' => 0,
|
||||
'limit' => $this->limit
|
||||
);
|
||||
$games = $this->gamesModel->getGames(array(), array(), $options);
|
||||
$this->data['games'] = $games;
|
||||
$this->getChild(array('common/admheader', 'common/footer'));
|
||||
return $this->load->view('admin/mods/create', $this->data);
|
||||
}
|
||||
|
||||
public function ajax() {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if($this->user->getAccessLevel() < 3) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$this->load->model('servers');
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
$errorPOST = $this->validatePOST();
|
||||
if(!$errorPOST) {
|
||||
$name = @$this->request->post['name'];
|
||||
$gameid = @$this->request->post['gameid'];
|
||||
$arch = @$this->request->post['arch'];
|
||||
$textx = @$this->request->post['textx'];
|
||||
$img = @$this->request->post['img'];
|
||||
$status = @$this->request->post['status'];
|
||||
$price = @$this->request->post['price'];
|
||||
|
||||
$uploaddir = (TMP_DIR . 'mods/');
|
||||
$apend = $_FILES['userfile']['name'];
|
||||
$uploadfile = "$uploaddir$apend";
|
||||
|
||||
if($_FILES['userfile']['size'] > 1024*90*1024) {
|
||||
$this->data['error'] = 'Размер файла не должен превышать 90МБ';
|
||||
$this->data['status'] = "error";
|
||||
}
|
||||
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile))
|
||||
$dir = "".$this->config->url."tmp/mods/".$apend."";
|
||||
|
||||
$modsData = array(
|
||||
'game_id' => $gameid,
|
||||
'mod_name' => $name,
|
||||
'mod_url' => $dir,
|
||||
'mod_status' => (int)$status,
|
||||
'mod_textx' => $textx,
|
||||
'mod_img' => $img,
|
||||
'mod_arch' => $apend,
|
||||
'mod_price' => $price
|
||||
);
|
||||
$this->serversModel->createMod($modsData);
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Вы успешно создали мод!";
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $errorPOST;
|
||||
}
|
||||
}
|
||||
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
private function validatePOST() {
|
||||
$this->load->library('validate');
|
||||
|
||||
$validateLib = new validateLibrary();
|
||||
|
||||
$result = null;
|
||||
|
||||
$name = @$this->request->post['name'];
|
||||
$gameid = @$this->request->post['gameid'];
|
||||
$arch = @$this->request->post['arch'];
|
||||
$status = @$this->request->post['status'];
|
||||
$textx = @$this->request->post['textx'];
|
||||
$price = @$this->request->post['price'];
|
||||
|
||||
if(mb_strlen($name) < 2 || mb_strlen($name) > 32) {
|
||||
$result = "Название мода должно содержать от 2 до 32 символов!";
|
||||
}
|
||||
elseif(mb_strlen($textx) < 2 || mb_strlen($textx) > 500) {
|
||||
$result = "Описание должно содержать от 2 до 500 символов!";
|
||||
}
|
||||
elseif($status < 0 || $status > 1) {
|
||||
$result = "Укажите допустимый статус!";
|
||||
}
|
||||
elseif(0 > $price || $price > 5000) {
|
||||
$result = "Укажите сумму от 0 до 5000 рублей!";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,162 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class editController extends Controller {
|
||||
public function index($modid = null) {
|
||||
$this->document->setActiveSection('admin/mods');
|
||||
$this->document->setActiveItem('edit');
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 3) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->model('servers');
|
||||
|
||||
$error = $this->validate($modid);
|
||||
if($error) {
|
||||
$this->session->data['error'] = $error;
|
||||
$this->response->redirect($this->config->url . 'admin/mods/index');
|
||||
}
|
||||
|
||||
$mod = $this->serversModel->getModById($modid);
|
||||
|
||||
$this->data['mod'] = $mod;
|
||||
$this->load->model('games');
|
||||
$options = array(
|
||||
'start' => 0,
|
||||
'limit' => $this->limit
|
||||
);
|
||||
$games = $this->gamesModel->getGames(array(), array(), $options);
|
||||
$this->data['games'] = $games;
|
||||
$this->getChild(array('common/admheader', 'common/footer'));
|
||||
return $this->load->view('admin/mods/edit', $this->data);
|
||||
}
|
||||
|
||||
public function ajax($modid = null) {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if($this->user->getAccessLevel() < 3) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$this->load->model('servers');
|
||||
|
||||
$error = $this->validate($modid);
|
||||
if($error) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $error;
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
$errorPOST = $this->validatePOST();
|
||||
if(!$errorPOST) {
|
||||
$gameid = @$this->request->post['gameid'];
|
||||
$name = @$this->request->post['name'];
|
||||
$url = @$this->request->post['url'];
|
||||
$status = @$this->request->post['status'];
|
||||
$textx = @$this->request->post['textx'];
|
||||
$img = @$this->request->post['img'];
|
||||
$arch = @$this->request->post['arch'];
|
||||
$price = @$this->request->post['price'];
|
||||
|
||||
$modsData = array(
|
||||
'game_id' => $gameid,
|
||||
'mod_name' => $name,
|
||||
'mod_url' => $url,
|
||||
'mod_status' => (int)$status,
|
||||
'mod_textx' => $textx,
|
||||
'mod_img' => $img,
|
||||
'mod_arch' => $arch,
|
||||
'mod_price' => $price
|
||||
);
|
||||
$this->serversModel->updateMod($modid, $modsData);
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Вы успешно отредактировали мод!";
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $errorPOST;
|
||||
}
|
||||
}
|
||||
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
public function delete($modid = null) {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 3) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->model('servers');
|
||||
|
||||
$error = $this->validate($modid);
|
||||
if($error) {
|
||||
$this->session->data['error'] = $error;
|
||||
$this->response->redirect($this->config->url . 'admin/mods/index');
|
||||
}
|
||||
|
||||
$this->serversModel->deleteMod($modid);
|
||||
|
||||
$this->session->data['success'] = "Вы успешно удалили мод!";
|
||||
$this->response->redirect($this->config->url . 'admin/mods/index');
|
||||
return null;
|
||||
}
|
||||
|
||||
private function validate($modid) {
|
||||
$result = null;
|
||||
|
||||
if(!$this->serversModel->getTotalMods(array('mod_id' => (int)$modid))) {
|
||||
$result = "Запрашиваемый мод не существует!";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function validatePOST() {
|
||||
$this->load->library('validate');
|
||||
|
||||
$validateLib = new validateLibrary();
|
||||
|
||||
$result = null;
|
||||
|
||||
$gameid = @$this->request->post['gameid'];
|
||||
$url = @$this->request->post['url'];
|
||||
$arch = @$this->request->post['arch'];
|
||||
$name = @$this->request->post['name'];
|
||||
$status = @$this->request->post['status'];
|
||||
$textx = @$this->request->post['textx'];
|
||||
$img = @$this->request->post['img'];
|
||||
$price = @$this->request->post['price'];
|
||||
|
||||
if(mb_strlen($name) < 2 || mb_strlen($name) > 32) {
|
||||
$result = "Название мода должно содержать от 2 до 32 символов!";
|
||||
}
|
||||
elseif(0 > $price || $price > 5000) {
|
||||
$result = "Укажите сумму от 0 до 5000 рублей!";
|
||||
}
|
||||
elseif(mb_strlen($textx) < 2 || mb_strlen($textx) > 500) {
|
||||
$result = "Описание должно содержать от 2 до 500 символов!";
|
||||
}
|
||||
elseif($status < 0 || $status > 1) {
|
||||
$result = "Укажите допустимый статус!";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class indexController extends Controller {
|
||||
private $limit = 20;
|
||||
public function index($page = 1) {
|
||||
$this->document->setActiveSection('admin/mods');
|
||||
$this->document->setActiveItem('index');
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 3) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->library('pagination');
|
||||
$this->load->model('servers');
|
||||
|
||||
$options = array(
|
||||
'start' => ($page - 1) * $this->limit,
|
||||
'limit' => $this->limit
|
||||
);
|
||||
|
||||
$total = $this->serversModel->getTotalMods();
|
||||
$mods = $this->serversModel->getMods(array(),array('games'),array(), $options);
|
||||
|
||||
$paginationUrl = '/admin/mods/index/index/{page}';
|
||||
$paginationLib = new paginationLibrary();
|
||||
$paginationLib->total = $total;
|
||||
$paginationLib->page = $page;
|
||||
$paginationLib->limit = $this->limit;
|
||||
$paginationLib->url = $paginationUrl;
|
||||
$pagination = $paginationLib->render();
|
||||
|
||||
$this->data['mods'] = $mods;
|
||||
$this->data['pagination'] = $pagination;
|
||||
|
||||
$this->getChild(array('common/admheader', 'common/footer'));
|
||||
return $this->load->view('admin/mods/index', $this->data);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class createController extends Controller {
|
||||
|
||||
public function index($ticketid = null) {
|
||||
$this->document->setActiveSection('admin/news');
|
||||
$this->document->setActiveItem('create');
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 3) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
$this->getChild(array('common/admheader', 'common/footer'));
|
||||
return $this->load->view('admin/news/create', $this->data);
|
||||
}
|
||||
|
||||
public function ajax($ticketid = null) {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if($this->user->getAccessLevel() < 3) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$this->load->model('news');
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
$errorPOST = $this->validatePOST();
|
||||
if(!$errorPOST) {
|
||||
$name = @$this->request->post['name'];
|
||||
$text = @$this->request->post['text'];
|
||||
$userid = $this->user->getId();
|
||||
|
||||
$newsData = array(
|
||||
'user_id' => $userid,
|
||||
'news_title' => $name,
|
||||
'news_text' => $text
|
||||
);
|
||||
$newsid = $this->newsModel->createNews($newsData);
|
||||
|
||||
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Вы успешно создали новость!";
|
||||
$this->data['id'] = $newsid;
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $errorPOST;
|
||||
}
|
||||
}
|
||||
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
private function validatePOST() {
|
||||
$result = null;
|
||||
|
||||
$name = @$this->request->post['name'];
|
||||
$text = @$this->request->post['text'];
|
||||
|
||||
if(mb_strlen($name) < 6 || mb_strlen($name) > 100) {
|
||||
$result = "Название новости должно содержать от 2 до 100 символов!";
|
||||
}
|
||||
elseif(mb_strlen($text) < 10 || mb_strlen($text) > 1000) {
|
||||
$result = "Текст новости должен содержать от 2 до 1000 символов!";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class editController extends Controller {
|
||||
public function index($newid = null) {
|
||||
$this->document->setActiveSection('admin/news');
|
||||
$this->document->setActiveItem('edit');
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 3) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->model('news');
|
||||
|
||||
$error = $this->validate($newid);
|
||||
if($error) {
|
||||
$this->session->data['error'] = $error;
|
||||
$this->response->redirect($this->config->url . 'admin/news/index');
|
||||
}
|
||||
|
||||
$new = $this->newsModel->getNewsById($newid);
|
||||
|
||||
$this->data['new'] = $new;
|
||||
$this->getChild(array('common/admheader', 'common/footer'));
|
||||
return $this->load->view('admin/news/edit', $this->data);
|
||||
}
|
||||
|
||||
public function ajax($newid = null) {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if($this->user->getAccessLevel() < 3) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$this->load->model('news');
|
||||
|
||||
$error = $this->validate($newid);
|
||||
if($error) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $error;
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
$errorPOST = $this->validatePOST();
|
||||
if(!$errorPOST) {
|
||||
$name = @$this->request->post['name'];
|
||||
$text = @$this->request->post['text'];
|
||||
$locationData = array(
|
||||
'news_title' => $name,
|
||||
'news_text' => $text
|
||||
);
|
||||
|
||||
|
||||
$this->newsModel->updateNews($newid, $locationData);
|
||||
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Вы успешно отредактировали новость!";
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $errorPOST;
|
||||
}
|
||||
}
|
||||
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
public function delete($newid = null) {
|
||||
$this->document->setActiveSection('admin');
|
||||
$this->document->setActiveItem('locations');
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 3) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->model('news');
|
||||
|
||||
$error = $this->validate($newid);
|
||||
if($error) {
|
||||
$this->session->data['error'] = $error;
|
||||
$this->response->redirect($this->config->url . 'admin/news/index');
|
||||
}
|
||||
|
||||
$this->newsModel->deleteNews($newid);
|
||||
|
||||
$this->session->data['success'] = "Вы успешно удалили новость!";
|
||||
$this->response->redirect($this->config->url . 'admin/news/index');
|
||||
return null;
|
||||
}
|
||||
|
||||
private function validate($newid) {
|
||||
$result = null;
|
||||
|
||||
if(!$this->newsModel->getTotalNews(array('news_id' => (int)$newid))) {
|
||||
$result = "Запрашиваемая новость не существует!";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function validatePOST() {
|
||||
$this->load->library('validate');
|
||||
|
||||
$validateLib = new validateLibrary();
|
||||
|
||||
$result = null;
|
||||
|
||||
$name = @$this->request->post['name'];
|
||||
$text = @$this->request->post['text'];
|
||||
if(mb_strlen($name) < 2 || mb_strlen($name) > 100) {
|
||||
$result = "Текст должен содержать от 2 до 100 символов!";
|
||||
}
|
||||
if(mb_strlen($text) < 2 || mb_strlen($text) > 1000) {
|
||||
$result = "Текст должен содержать от 2 до 1000 символов!";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class indexController extends Controller {
|
||||
private $limit = 20;
|
||||
public function index($page = 1) {
|
||||
$this->document->setActiveSection('admin/news');
|
||||
$this->document->setActiveItem('index');
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 3) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->library('pagination');
|
||||
$this->load->model('news');
|
||||
$sort = array(
|
||||
'news_date_add' => 'DESC'
|
||||
);
|
||||
$options = array(
|
||||
'start' => ($page - 1) * $this->limit,
|
||||
'limit' => $this->limit
|
||||
);
|
||||
|
||||
$total = $this->newsModel->getTotalNews();
|
||||
$news = $this->newsModel->getNews(array(), array('users'), $sort, $options);
|
||||
|
||||
$paginationUrl = '/admin/news/index/index/{page}';
|
||||
$paginationLib = new paginationLibrary();
|
||||
$paginationLib->total = $total;
|
||||
$paginationLib->page = $page;
|
||||
$paginationLib->limit = $this->limit;
|
||||
$paginationLib->url = $paginationUrl;
|
||||
$pagination = $paginationLib->render();
|
||||
|
||||
$this->data['news'] = $news;
|
||||
$this->data['pagination'] = $pagination;
|
||||
|
||||
$this->getChild(array('common/admheader', 'common/footer'));
|
||||
return $this->load->view('admin/news/index', $this->data);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class createController extends Controller {
|
||||
public function index() {
|
||||
$this->document->setActiveSection('admin/promo');
|
||||
$this->document->setActiveItem('create');
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 3) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->getChild(array('common/admheader', 'common/footer'));
|
||||
return $this->load->view('admin/promo/create', $this->data);
|
||||
}
|
||||
|
||||
public function ajax() {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if($this->user->getAccessLevel() < 3) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$this->load->model('promos');
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
$errorPOST = $this->validatePOST();
|
||||
if(!$errorPOST) {
|
||||
$cod = @$this->request->post['cod'];
|
||||
$uses = @$this->request->post['uses'];
|
||||
$skidka = @$this->request->post['skidka'];
|
||||
|
||||
$locationData = array(
|
||||
'cod' => $cod,
|
||||
'uses' => $uses,
|
||||
'used' => 0,
|
||||
'skidka' => (int)$skidka
|
||||
);
|
||||
|
||||
$this->promosModel->createPromo($locationData);
|
||||
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Вы успешно создали промо-Код!";
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $errorPOST;
|
||||
}
|
||||
}
|
||||
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
private function validatePOST() {
|
||||
$this->load->library('validate');
|
||||
|
||||
$validateLib = new validateLibrary();
|
||||
|
||||
$result = null;
|
||||
|
||||
$cod = @$this->request->post['cod'];
|
||||
$uses = @$this->request->post['uses'];
|
||||
$skidka = @$this->request->post['skidka'];
|
||||
|
||||
if(mb_strlen($cod) < 2 || mb_strlen($cod) > 32) {
|
||||
$result = "Код должен содержать от 2 до 32 символов!";
|
||||
}
|
||||
elseif(mb_strlen($uses) < 1 || mb_strlen($uses) > 10000) {
|
||||
$result = "Введите количество использований от 1 до 10000!";
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,142 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class editController extends Controller {
|
||||
public function index($promoid = null) {
|
||||
$this->document->setActiveSection('admin/promo');
|
||||
$this->document->setActiveItem('edit');
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 3) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->model('promos');
|
||||
|
||||
$error = $this->validate($promoid);
|
||||
if($error) {
|
||||
$this->session->data['error'] = $error;
|
||||
$this->response->redirect($this->config->url . 'admin/promo/index');
|
||||
}
|
||||
|
||||
$promo= $this->promosModel->getpromoById($promoid);
|
||||
|
||||
$this->data['promo'] = $promo;
|
||||
|
||||
$this->getChild(array('common/admheader', 'common/footer'));
|
||||
return $this->load->view('admin/promo/edit', $this->data);
|
||||
}
|
||||
|
||||
public function ajax($promoid = null) {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if($this->user->getAccessLevel() < 3) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$this->load->model('promos');
|
||||
|
||||
$error = $this->validate($promoid);
|
||||
if($error) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $error;
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
$errorPOST = $this->validatePOST();
|
||||
if(!$errorPOST) {
|
||||
$cod = @$this->request->post['cod'];
|
||||
$uses = @$this->request->post['uses'];
|
||||
$skidka = @$this->request->post['skidka'];
|
||||
|
||||
$locationData = array(
|
||||
'cod' => $cod,
|
||||
'uses' => $uses,
|
||||
'skidka' => (int)$skidka
|
||||
);
|
||||
|
||||
|
||||
$this->promosModel->updatepromo($promoid, $locationData);
|
||||
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Вы успешно отредактировали промо-код!";
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $errorPOST;
|
||||
}
|
||||
}
|
||||
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
public function delete($promoid = null) {
|
||||
$this->document->setActiveSection('admin');
|
||||
$this->document->setActiveItem('locations');
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 3) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->model('promos');
|
||||
|
||||
$error = $this->validate($promoid);
|
||||
if($error) {
|
||||
$this->session->data['error'] = $error;
|
||||
$this->response->redirect($this->config->url . 'admin/promo/index');
|
||||
}
|
||||
|
||||
$this->promosModel->deletepromo($promoid);
|
||||
|
||||
$this->session->data['success'] = "Вы успешно удалили промо-код!";
|
||||
$this->response->redirect($this->config->url . 'admin/promo/index');
|
||||
return null;
|
||||
}
|
||||
|
||||
private function validate($promoid) {
|
||||
$result = null;
|
||||
|
||||
if(!$this->promosModel->getTotalpromo(array('id' => (int)$promoid))) {
|
||||
$result = "Запрашиваемый код не существует!";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function validatePOST() {
|
||||
$this->load->library('validate');
|
||||
|
||||
$validateLib = new validateLibrary();
|
||||
|
||||
$result = null;
|
||||
|
||||
$cod = @$this->request->post['cod'];
|
||||
$uses = @$this->request->post['uses'];
|
||||
$skidka = @$this->request->post['skidka'];
|
||||
|
||||
if(mb_strlen($cod) < 2 || mb_strlen($cod) > 32) {
|
||||
$result = "Код должен содержать от 2 до 32 символов!";
|
||||
}
|
||||
elseif(mb_strlen($uses) < 1 || mb_strlen($uses) > 10000) {
|
||||
$result = "Введите количество использований от 1 до 10000!";
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class indexController extends Controller {
|
||||
private $limit = 20;
|
||||
public function index($page = 1) {
|
||||
$this->document->setActiveSection('admin/promo');
|
||||
$this->document->setActiveItem('index');
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 3) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->library('pagination');
|
||||
$this->load->model('promos');
|
||||
|
||||
$options = array(
|
||||
'start' => ($page - 1) * $this->limit,
|
||||
'limit' => $this->limit
|
||||
);
|
||||
|
||||
$total = $this->promosModel->getTotalpromo();
|
||||
$promos = $this->promosModel->getpromo(array(), array(), $options);
|
||||
|
||||
$paginationUrl = '/admin/promo/index/index/{page}';
|
||||
$paginationLib = new paginationLibrary();
|
||||
$paginationLib->total = $total;
|
||||
$paginationLib->page = $page;
|
||||
$paginationLib->limit = $this->limit;
|
||||
$paginationLib->url = $paginationUrl;
|
||||
$pagination = $paginationLib->render();
|
||||
|
||||
$this->data['promos'] = $promos;
|
||||
$this->data['pagination'] = $pagination;
|
||||
|
||||
$this->getChild(array('common/admheader', 'common/footer'));
|
||||
return $this->load->view('admin/promo/index', $this->data);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class createController extends Controller {
|
||||
public function index() {
|
||||
$this->document->setActiveSection('admin/repo');
|
||||
$this->document->setActiveItem('create');
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 3) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
$this->load->model('games');
|
||||
$options = array(
|
||||
'start' => 0,
|
||||
'limit' => $this->limit
|
||||
);
|
||||
$games = $this->gamesModel->getGames(array(), array(), $options);
|
||||
$this->data['games'] = $games;
|
||||
$this->getChild(array('common/admheader', 'common/footer'));
|
||||
return $this->load->view('admin/repo/create', $this->data);
|
||||
}
|
||||
|
||||
public function ajax() {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if($this->user->getAccessLevel() < 3) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$this->load->model('servers');
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
$errorPOST = $this->validatePOST();
|
||||
if(!$errorPOST) {
|
||||
$name = @$this->request->post['name'];
|
||||
$gameid = @$this->request->post['gameid'];
|
||||
$url = @$this->request->post['url'];
|
||||
$textx = @$this->request->post['textx'];
|
||||
$img = @$this->request->post['img'];
|
||||
$status = @$this->request->post['status'];
|
||||
$price = @$this->request->post['price'];
|
||||
|
||||
$repoData = array(
|
||||
'game_id' => $gameid,
|
||||
'repo_name' => $name,
|
||||
'repo_url' => $url,
|
||||
'repo_status' => (int)$status,
|
||||
'repo_textx' => $textx,
|
||||
'repo_img' => $img,
|
||||
'repo_price' => $price
|
||||
);
|
||||
$this->serversModel->createRepo($repoData);
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Вы успешно добавили файл в репозиторий!";
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $errorPOST;
|
||||
}
|
||||
}
|
||||
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
private function validatePOST() {
|
||||
$this->load->library('validate');
|
||||
|
||||
$validateLib = new validateLibrary();
|
||||
|
||||
$result = null;
|
||||
|
||||
$name = @$this->request->post['name'];
|
||||
$gameid = @$this->request->post['gameid'];
|
||||
$status = @$this->request->post['status'];
|
||||
$textx = @$this->request->post['textx'];
|
||||
$price = @$this->request->post['price'];
|
||||
|
||||
if(mb_strlen($name) < 2 || mb_strlen($name) > 32) {
|
||||
$result = "Название файла должно содержать от 2 до 32 символов!";
|
||||
}
|
||||
elseif(mb_strlen($textx) < 2 || mb_strlen($textx) > 500) {
|
||||
$result = "Описание должно содержать от 2 до 500 символов!";
|
||||
}
|
||||
elseif($status < 0 || $status > 1) {
|
||||
$result = "Укажите допустимый статус!";
|
||||
}
|
||||
elseif(0 > $price || $price > 5000) {
|
||||
$result = "Укажите сумму от 0 до 5000 рублей!";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,157 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class editController extends Controller {
|
||||
public function index($repoid = null) {
|
||||
$this->document->setActiveSection('admin/repo');
|
||||
$this->document->setActiveItem('edit');
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 3) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->model('servers');
|
||||
|
||||
$error = $this->validate($repoid);
|
||||
if($error) {
|
||||
$this->session->data['error'] = $error;
|
||||
$this->response->redirect($this->config->url . 'admin/repo/index');
|
||||
}
|
||||
|
||||
$repo = $this->serversModel->getRepoById($repoid);
|
||||
|
||||
$this->data['repo'] = $repo;
|
||||
$this->load->model('games');
|
||||
$options = array(
|
||||
'start' => 0,
|
||||
'limit' => $this->limit
|
||||
);
|
||||
$games = $this->gamesModel->getGames(array(), array(), $options);
|
||||
$this->data['games'] = $games;
|
||||
$this->getChild(array('common/admheader', 'common/footer'));
|
||||
return $this->load->view('admin/repo/edit', $this->data);
|
||||
}
|
||||
|
||||
public function ajax($repoid = null) {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if($this->user->getAccessLevel() < 3) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$this->load->model('servers');
|
||||
|
||||
$error = $this->validate($repoid);
|
||||
if($error) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $error;
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
$errorPOST = $this->validatePOST();
|
||||
if(!$errorPOST) {
|
||||
$name = @$this->request->post['name'];
|
||||
$gameid = @$this->request->post['gameid'];
|
||||
$url = @$this->request->post['url'];
|
||||
$textx = @$this->request->post['textx'];
|
||||
$img = @$this->request->post['img'];
|
||||
$status = @$this->request->post['status'];
|
||||
$price = @$this->request->post['price'];
|
||||
|
||||
$repoData = array(
|
||||
'game_id' => $gameid,
|
||||
'repo_name' => $name,
|
||||
'repo_url' => $url,
|
||||
'repo_status' => (int)$status,
|
||||
'repo_textx' => $textx,
|
||||
'repo_img' => $img,
|
||||
'repo_price' => $price
|
||||
);
|
||||
$this->serversModel->updateRepo($repoid, $repoData);
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Вы успешно отредактировали файл в репозитории!";
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $errorPOST;
|
||||
}
|
||||
}
|
||||
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
public function delete($repoid = null) {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 3) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->model('servers');
|
||||
|
||||
$error = $this->validate($repoid);
|
||||
if($error) {
|
||||
$this->session->data['error'] = $error;
|
||||
$this->response->redirect($this->config->url . 'admin/repo/index');
|
||||
}
|
||||
|
||||
$this->serversModel->deleteRepo($repoid);
|
||||
|
||||
$this->session->data['success'] = "Вы успешно удалили файл с репозитория!";
|
||||
$this->response->redirect($this->config->url . 'admin/repo/index');
|
||||
return null;
|
||||
}
|
||||
|
||||
private function validate($repoid) {
|
||||
$result = null;
|
||||
|
||||
if(!$this->serversModel->getTotalRepos(array('repo_id' => (int)$repoid))) {
|
||||
$result = "Запрашиваемый файл не существует!";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function validatePOST() {
|
||||
$this->load->library('validate');
|
||||
|
||||
$validateLib = new validateLibrary();
|
||||
|
||||
$result = null;
|
||||
|
||||
$name = @$this->request->post['name'];
|
||||
$gameid = @$this->request->post['gameid'];
|
||||
$status = @$this->request->post['status'];
|
||||
$textx = @$this->request->post['textx'];
|
||||
$price = @$this->request->post['price'];
|
||||
|
||||
if(mb_strlen($name) < 2 || mb_strlen($name) > 32) {
|
||||
$result = "Название файла должно содержать от 2 до 32 символов!";
|
||||
}
|
||||
elseif(mb_strlen($textx) < 2 || mb_strlen($textx) > 500) {
|
||||
$result = "Описание должно содержать от 2 до 500 символов!";
|
||||
}
|
||||
elseif($status < 0 || $status > 1) {
|
||||
$result = "Укажите допустимый статус!";
|
||||
}
|
||||
elseif(0 > $price || $price > 5000) {
|
||||
$result = "Укажите сумму от 0 до 5000 рублей!";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class indexController extends Controller {
|
||||
private $limit = 20;
|
||||
public function index($page = 1) {
|
||||
$this->document->setActiveSection('admin/repo');
|
||||
$this->document->setActiveItem('index');
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 3) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->library('pagination');
|
||||
$this->load->model('servers');
|
||||
|
||||
$options = array(
|
||||
'start' => ($page - 1) * $this->limit,
|
||||
'limit' => $this->limit
|
||||
);
|
||||
|
||||
$total = $this->serversModel->getTotalRepos();
|
||||
$repo = $this->serversModel->getRepos(array(),array('games'),array(), $options);
|
||||
|
||||
$paginationUrl = '/admin/repo/index/index/{page}';
|
||||
$paginationLib = new paginationLibrary();
|
||||
$paginationLib->total = $total;
|
||||
$paginationLib->page = $page;
|
||||
$paginationLib->limit = $this->limit;
|
||||
$paginationLib->url = $paginationUrl;
|
||||
$pagination = $paginationLib->render();
|
||||
|
||||
$this->data['repo'] = $repo;
|
||||
$this->data['pagination'] = $pagination;
|
||||
|
||||
$this->getChild(array('common/admheader', 'common/footer'));
|
||||
return $this->load->view('admin/repo/index', $this->data);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,687 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class controlController extends Controller {
|
||||
public function index($serverid = null) {
|
||||
$this->document->setActiveSection('admin/servers');
|
||||
$this->document->setActiveItem('control');
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 2) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->library('query');
|
||||
$this->load->model('servers');
|
||||
|
||||
$error = $this->validate($serverid);
|
||||
if($error) {
|
||||
$this->session->data['error'] = $error;
|
||||
$this->response->redirect($this->config->url . 'admin/servers/index');
|
||||
}
|
||||
|
||||
$server = $this->serversModel->getServerById($serverid, array('users', 'games', 'locations'));
|
||||
$this->data['server'] = $server;
|
||||
|
||||
if($server['server_status'] == 2) {
|
||||
$queryLib = new queryLibrary($server['game_query']);
|
||||
$queryLib->connect($server['location_ip'], $server['server_port']);
|
||||
$query = $queryLib->getInfo();
|
||||
$queryLib->disconnect();
|
||||
|
||||
$this->data['query'] = $query;
|
||||
}
|
||||
|
||||
if($server['server_status'] == 1 AND $server['game_code'] == "cs" || $server['game_code'] == "css" || $server['game_code'] == "csgo") {
|
||||
if($server["game_code"] == "cs") {
|
||||
$fps = array("300", "500", "1100");
|
||||
$this->data["fps"] = $fps;
|
||||
}
|
||||
|
||||
if($server["game_code"] == "csgo") {
|
||||
$tickrate = array("64", "128");
|
||||
$this->data["tickrate"] = $tickrate;
|
||||
}
|
||||
|
||||
if($server["game_code"] == "css") {
|
||||
$tickrate = array("66", "100");
|
||||
$this->data["tickrate"] = $tickrate;
|
||||
}
|
||||
}
|
||||
|
||||
$stats = $this->serversModel->getServerStats($serverid, "NOW() - INTERVAL 1 DAY", "NOW()");
|
||||
$this->data['stats'] = $stats;
|
||||
|
||||
$this->getChild(array('common/admheader', 'common/footer'));
|
||||
return $this->load->view('admin/servers/control', $this->data);
|
||||
}
|
||||
|
||||
public function actionserver($serverid = null, $actionserver = null) {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if($this->user->getAccessLevel() < 2) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$this->load->library('mail');
|
||||
$this->load->library('ssh2');
|
||||
$this->load->model('servers');
|
||||
|
||||
$error = $this->validate($serverid);
|
||||
if($error) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $error;
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$server = $this->serversModel->getServerById($serverid, array('users', 'locations', 'games'));
|
||||
|
||||
if($server['server_status'] == 3) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет установка сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 4) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет переустановка сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 5) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет создание BackUP сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 6) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет восстанновление сервера из BackUP!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 7) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет обновление сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($actionserver == "start" || $actionserver == "stop" || $actionserver == "restart" || $actionserver == "backup" || $actionserver == "unbackup") {
|
||||
if($server["server_status"] == 0) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Сервер заблокирован!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
}
|
||||
|
||||
switch($actionserver) {
|
||||
case "start": {
|
||||
if($server["server_status"] == 1) {
|
||||
$stats = $this->serversModel->getHDD($server['server_id']);
|
||||
if((int)$stats < $server['game_ssd']) {
|
||||
$result = $this->serversModel->action($serverid, 'start');
|
||||
if($result["status"] == "success") {
|
||||
$this->serversModel->deleteTask(array('task_name' => 'enable', 'server_id' => $serverid));
|
||||
$this->serversModel->updateServer($serverid, array("server_status" => 2));
|
||||
$logData = array(
|
||||
'server_id' => $serverid,
|
||||
'reason' => 'Успешный запуск сервера',
|
||||
'status' => 1
|
||||
);
|
||||
$this->serversModel->createLog($logData);
|
||||
$this->data["status"] = "success";
|
||||
$this->data["success"] = "Вы успешно запустили сервер!";
|
||||
} else {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = $result["description"];
|
||||
}
|
||||
} else {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Вы привысили ограничение размера директории на ". round($stats - $server['game_ssd'], 2) ."МБ, запуск сервера невозможен!";
|
||||
}
|
||||
} else {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Сервер должен быть выключен!";
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case "reinstall": {
|
||||
if($server["server_status"] == 1) {
|
||||
$logData = array(
|
||||
'server_id' => $serverid,
|
||||
'reason' => 'Сервер успешно поставлен на переустановку!',
|
||||
'status' => 2
|
||||
);
|
||||
$this->serversModel->createLog($logData);
|
||||
$this->serversModel->updateServer($serverid, array('server_status' => 4, 'server_work' => 0));
|
||||
$this->data["status"] = "success";
|
||||
$this->data["success"] = "Сервер успешно поставлен на переустановку!";
|
||||
} else {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Сервер должен быть выключен!";
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case "restart": {
|
||||
if($server["server_status"] == 2) {
|
||||
$stats = $this->serversModel->getHDD($server['server_id']);
|
||||
if((int)$stats < $server['game_ssd']) {
|
||||
$result = $this->serversModel->action($serverid, 'restart');
|
||||
if($result["status"] == "success") {
|
||||
$this->serversModel->deleteTask(array('task_name' => 'restart', 'server_id' => $serverid));
|
||||
$logData = array(
|
||||
'server_id' => $serverid,
|
||||
'reason' => 'Успешный перезапуск сервера',
|
||||
'status' => 1
|
||||
);
|
||||
$this->serversModel->createLog($logData);
|
||||
$this->data["status"] = "success";
|
||||
$this->data["success"] = "Вы успешно перезапустили сервер!";
|
||||
} else {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = $result["description"];
|
||||
}
|
||||
} else {
|
||||
$result = $this->serversModel->action($serverid, 'stop');
|
||||
if($result['status'] == "success") {
|
||||
$this->serversModel->updateServer($serverid, array('server_status' => 1));
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Вы привысили ограничение размера директории на ". round($stats - $server['game_ssd'], 2) ."МБ, перезагрузка сервера невозможна!";
|
||||
} else {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = $result["description"];
|
||||
}
|
||||
}
|
||||
} else if($server["server_status"] == 2) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Сервер должен быть включен!";
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case "stop": {
|
||||
if($server["server_status"] == 2) {
|
||||
$result = $this->serversModel->action($serverid, 'stop');
|
||||
if($result["status"] == "success") {
|
||||
$this->serversModel->deleteTask(array('task_name' => 'disable', 'server_id' => $serverid));
|
||||
$this->serversModel->deleteTask(array('task_name' => 'restart', 'server_id' => $serverid));
|
||||
$this->serversModel->updateServer($serverid, array("server_status" => 1, 'server_work' => 0));
|
||||
$logData = array(
|
||||
'server_id' => $serverid,
|
||||
'reason' => 'Успешное выключение сервера',
|
||||
'status' => 1
|
||||
);
|
||||
$this->serversModel->createLog($logData);
|
||||
$this->data["status"] = "success";
|
||||
$this->data["success"] = "Вы успешно выключили сервер!";
|
||||
} else {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = $result["description"];
|
||||
}
|
||||
} else {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Сервер должен быть вылючен!";
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case 'backup': {
|
||||
if($server['server_status'] == 1) {
|
||||
$stats = $this->serversModel->getHDD($server['server_id']);
|
||||
if((int)$stats < $server['game_ssd']) {
|
||||
$this->serversModel->deleteTask(array('task_name' => 'restart', 'server_id' => $serverid));
|
||||
$this->serversModel->deleteTask(array('task_name' => 'enable', 'server_id' => $serverid));
|
||||
$this->serversModel->deleteTask(array('task_name' => 'disable', 'server_id' => $serverid));
|
||||
$this->serversModel->updateServer($serverid, array('server_status' => 5, 'server_work' => 0));
|
||||
$logData = array(
|
||||
'server_id' => $serverid,
|
||||
'reason' => 'Успешное начало создания BackUP сервера.',
|
||||
'status' => 1
|
||||
);
|
||||
$this->serversModel->createLog($logData);
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Вы успешно начали создание BackUP сервера!";
|
||||
} else {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Вы привысили ограничение размера директории на ". round($stats - $server['game_ssd'], 2) ."МБ, создание бекапа сервера невозможено!";
|
||||
}
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Сервер должен быть выключен!";
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case 'unbackup': {
|
||||
if($server['server_status'] == 1) {
|
||||
if (file_exists('ssh2.sftp://'.$server['location_user'].':'.$server['location_password'].'@'.$server['location_ip'].':22/home/cp/backups/gs'.$serverid.'.tar')) {
|
||||
$this->serversModel->deleteTask(array('task_name' => 'restart', 'server_id' => $serverid));
|
||||
$this->serversModel->deleteTask(array('task_name' => 'enable', 'server_id' => $serverid));
|
||||
$this->serversModel->deleteTask(array('task_name' => 'disable', 'server_id' => $serverid));
|
||||
$this->serversModel->updateServer($serverid, array('server_status' => 6, 'server_work' => 0));
|
||||
$logData = array(
|
||||
'server_id' => $serverid,
|
||||
'reason' => 'Успешное начало восстановление BackUP сервера.',
|
||||
'status' => 1
|
||||
);
|
||||
$this->serversModel->createLog($logData);
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Вы успешно восстановили BackUP сервера!";
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У сервера нет BackUP!";
|
||||
}
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Сервер должен быть выключен!";
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case 'delete_backup': {
|
||||
if($server['server_status'] == 1) {
|
||||
if (file_exists('ssh2.sftp://'.$server['location_user'].':'.$server['location_password'].'@'.$server['location_ip'].':22/home/cp/backups/gs'.$serverid.'.tar')) {
|
||||
$result = $this->serversModel->action($serverid, 'delete_backup');
|
||||
if($result["status"] == "success") {
|
||||
$logData = array(
|
||||
'server_id' => $serverid,
|
||||
'reason' => 'Успешное удаление BackUP сервера',
|
||||
'status' => 1
|
||||
);
|
||||
$this->serversModel->createLog($logData);
|
||||
$this->data["status"] = "success";
|
||||
$this->data["success"] = "Вы успешно удалили BackUP сервера!";
|
||||
} else {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = $result["description"];
|
||||
}
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У сервера нет BackUP!";
|
||||
}
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Сервер должен быть выключен!";
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case 'block': {
|
||||
if($server['server_status'] == 1) {
|
||||
$this->serversModel->updateServer($serverid, array('server_status' => 0));
|
||||
$this->serversModel->action($serverid, "block");
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Вы успешно заблокировали сервер!";
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Сервер должен быть выключен!";
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'delete': {
|
||||
if($server['server_status'] == 1) {
|
||||
if($this->user->getAccessLevel() == 3){
|
||||
$mailLib = new mailLibrary();
|
||||
$mailLib->setFrom($this->config->mail_from);
|
||||
$mailLib->setSender($this->config->mail_sender);
|
||||
$result = $this->serversModel->action($serverid, 'delete');
|
||||
if($result['status'] == "success") {
|
||||
if($server['server_mysql'] == 1 || $server['server_mysql'] == 2) {
|
||||
$this->serversModel->action($serverid, "delete_mysql");
|
||||
}
|
||||
$this->serversModel->deleteServer($serverid);
|
||||
$this->serversModel->deleteServerStats($serverid);
|
||||
$this->serversModel->deleteserverOwners($serverid);
|
||||
$this->serversModel->deleteLog($serverid);
|
||||
|
||||
$firewall = $this->serversModel->getFirewallsById($serverid);
|
||||
|
||||
if ($firewall) {
|
||||
foreach ($firewall as $item2) {
|
||||
$ssh2Lib = new ssh2Library();
|
||||
$link = $ssh2Lib->connect($server['location_ip'], $server['location_user'], $server['location_password']);
|
||||
|
||||
$ssh2Lib->execute($link, "iptables -D INPUT -s ".$item2['server_ip']." -p udp -d ".$server['location_ip']." --dport ".$server['server_port']." -j DROP;");
|
||||
$ssh2Lib->execute($link, "iptables -D INPUT -s ".$item2['server_ip']." -p tcp -d ".$server['location_ip']." --dport ".$server['server_port']." -j DROP;");
|
||||
|
||||
$ssh2Lib->disconnect($link);
|
||||
|
||||
$this->serversModel->deleteFirewallDB($item2['firewall_id']);
|
||||
}
|
||||
}
|
||||
|
||||
$mailLib->setTo($server['user_email']);
|
||||
$mailLib->setSubject("Удаление сервера администратором #$serverid");
|
||||
|
||||
$mailData = array();
|
||||
$mailData['firstname'] = $server['user_firstname'];
|
||||
$mailData['lastname'] = $server['user_lastname'];
|
||||
$mailData['serverid'] = $serverid;
|
||||
|
||||
$text = $this->load->view('mail/servers/deleted', $mailData);
|
||||
|
||||
$mailLib->setText($text);
|
||||
$mailLib->send();
|
||||
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Вы успешно удалили сервер!";
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $result['description'];
|
||||
}
|
||||
} else {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Сервер должен быть выключен!";
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'unblock': {
|
||||
if($server['server_status'] == 0) {
|
||||
$this->serversModel->updateServer($serverid, array('server_status' => 1));
|
||||
$this->serversModel->action($serverid, "updatepassm");
|
||||
$this->serversModel->action($serverid, "updatepass");
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Вы успешно разблокировали сервер!";
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Сервер должен быть заблокирован!";
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы выбрали несуществующее действие!";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
public function settingStart($serverid = null) {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'news/index');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 2) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->model('servers');
|
||||
|
||||
$server = $this->serversModel->getServerById($serverid, array('games', 'locations'));
|
||||
|
||||
$error = $this->validate($serverid);
|
||||
if($error) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $error;
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
if($server['server_status'] == 3) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет установка сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 4) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет переустановка сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 5) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет создание BackUP сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 6) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет восстанновление сервера из BackUP!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 7) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет обновление сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server["server_status"] == 0) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Сервер заблокирован!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
if($server['server_status'] == 1){
|
||||
if($server["game_code"] == "cs" || $server["game_code"] == "css" || $server["game_code"] == "csgo" || $server["game_query"] == "samp") {
|
||||
$rcon_password = @$this->request->post['rcon_password'];
|
||||
if(mb_strlen($rcon_password) < 2 || mb_strlen($rcon_password) > 18) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "RCON Пароль должен содержать от 2 до 18 символов!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
$this->serversModel->updateServer($serverid, array('rcon_password' => $rcon_password));
|
||||
|
||||
if($server["game_code"] == "cs" || $server["game_code"] == "css" || $server["game_code"] == "csgo") {
|
||||
$vac = @$this->request->post['vac'];
|
||||
if(!in_array($vac, array("0", "1"))) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Статус античита VAC указан неверно!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
$this->serversModel->updateServer($serverid, array('server_vac' => $vac));
|
||||
|
||||
$fastdl = @$this->request->post['fastdl'];
|
||||
if(!in_array($fastdl, array("0", "1"))) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Статус FastDL указан неверно!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
$this->serversModel->updateServer($serverid, array('fastdl_status' => $fastdl));
|
||||
|
||||
if($server["game_code"] == "cs") {
|
||||
$fps = @$this->request->post['fps'];
|
||||
if(!in_array($fps, array("300", "500", "1100"))) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Параметр FPS указан неверно!";
|
||||
return json_encode($this->data);
|
||||
} else {
|
||||
$this->serversModel->updateServer($serverid, array('server_fps' => $fps));
|
||||
}
|
||||
}
|
||||
|
||||
if($server["game_code"] == "csgo") {
|
||||
$tickrate = @$this->request->post['tickrate'];
|
||||
if(!in_array($tickrate, array("64", "128"))) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Параметр Tickrate указан неверно!";
|
||||
return json_encode($this->data);
|
||||
} else {
|
||||
$this->serversModel->updateServer($serverid, array('server_tickrate' => $tickrate));
|
||||
}
|
||||
}
|
||||
|
||||
if($server["game_code"] == "css") {
|
||||
$tickrate = @$this->request->post['tickrate'];
|
||||
if(!in_array($tickrate, array("66", "100"))) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Параметр Tickrate указан неверно!";
|
||||
return json_encode($this->data);
|
||||
} else {
|
||||
$this->serversModel->updateServer($serverid, array('server_tickrate' => $tickrate));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->data["status"] = "success";
|
||||
$this->data["success"] = "Параметры запуска успешно изменены!";
|
||||
} else {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Не для данной игры!";
|
||||
}
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Сервер должен быть выключен!";
|
||||
}
|
||||
}
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
private function validate($serverid) {
|
||||
$result = null;
|
||||
|
||||
if(!$this->serversModel->getTotalServers(array('server_id' => (int)$serverid))) {
|
||||
$result = "Запрашиваемый сервер не существует!";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function validatePOST() {
|
||||
$this->load->library('validate');
|
||||
|
||||
$validateLib = new validateLibrary();
|
||||
|
||||
$result = null;
|
||||
|
||||
$slots = @$this->request->post['slots'];
|
||||
$editpassword = @$this->request->post['editpassword'];
|
||||
$password = @$this->request->post['password'];
|
||||
$password2 = @$this->request->post['password2'];
|
||||
|
||||
if($editpassword) {
|
||||
if(!$validateLib->password($password)) {
|
||||
$result = "Пароль должен содержать от 6 до 32 латинских букв, цифр и знаков <i>,.!?_-</i>!";
|
||||
}
|
||||
elseif($password != $password2) {
|
||||
$result = "Введенные вами пароли не совпадают!";
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function mysqlhostin($serverid = null, $mysqlhostin = null) {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if($this->user->getAccessLevel() < 0) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$this->load->model('servers');
|
||||
|
||||
$error = $this->validate($serverid);
|
||||
if($error) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $error;
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$server = $this->serversModel->getServerById($serverid);
|
||||
switch($mysqlhostin) {
|
||||
case 'mysqlon': {
|
||||
if($server['server_mysql'] == 2) {
|
||||
$this->serversModel->updateServer($serverid, array('server_mysql' => 1));
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Вы успешно включили базу данных gs$serverid!";
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "База данных и так включена либо вы ее еще не создали!";
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'mysqloff': {
|
||||
if($server['server_mysql'] == 1) {
|
||||
$this->serversModel->updateServer($serverid, array('server_mysql' => 2));
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Вы успешно выключили базу данных gs$serverid!";
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "База данных и так выключена!";
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'mysqlcr': {
|
||||
if($server['server_mysql'] == 0) {
|
||||
$result = $this->serversModel->action($serverid, 'create_mysql');
|
||||
if($result["status"] == "success") {
|
||||
$this->serversModel->updateServer($serverid, array('server_mysql' => 2));
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Вы успешно создали базу данных gs$serverid!";
|
||||
} else {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = $result["description"];
|
||||
}
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "База данных и так создана!";
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы выбрали несуществующее действие!";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
public function getData($serverid = null) {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 2) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->model('servers');
|
||||
$this->load->library('query');
|
||||
|
||||
$error = $this->validate($serverid);
|
||||
if($error) {
|
||||
$this->session->data['error'] = $error;
|
||||
$this->response->redirect($this->config->url . 'servers/index');
|
||||
}
|
||||
|
||||
$server = $this->serversModel->getServerById($serverid, array('games', 'locations'));
|
||||
|
||||
if($server['server_status'] == 2) {
|
||||
$queryLib = new queryLibrary($server['game_query']);
|
||||
$queryLib->connect($server['location_ip'], $server['server_port']);
|
||||
$query = $queryLib->getInfo();
|
||||
$queryLib->disconnect();
|
||||
|
||||
$sysload = $this->serversModel->getServerSystemLoad($serverid);
|
||||
$ssd = round($sysload['ssd']);
|
||||
$ssd_all = $server['game_ssd'];
|
||||
$this->data['ssd'] = (int)(($ssd * 100) / $ssd_all);
|
||||
$this->data['cpu'] = $sysload['cpu'] > 100 ? 100 : round($sysload['cpu']);
|
||||
$this->data['ram'] = $sysload['ram'] > 100 ? 100 : round($sysload['ram']);
|
||||
$this->data['players'] = $query['players'];
|
||||
} else if($server['server_status'] == 3 || $server['server_status'] == 4) {
|
||||
$this->data['ssd'] = 'N/A';
|
||||
$this->data['cpu'] = 'N/A';
|
||||
$this->data['ram'] = 'N/A';
|
||||
$this->data['players'] = 'N/A';
|
||||
} else {
|
||||
$ssd = $this->serversModel->getHDD($serverid);
|
||||
$ssd = round($ssd);
|
||||
$ssd_all = $server['game_ssd'];
|
||||
$this->data['ssd'] = (int)(($ssd * 100) / $ssd_all);
|
||||
$this->data['cpu'] = 0;
|
||||
$this->data['ram'] = 0;
|
||||
$this->data['players'] = 0;
|
||||
}
|
||||
|
||||
return json_encode($this->data);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,234 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class indexController extends Controller {
|
||||
private $limit = 22;
|
||||
public function index($page = 1) {
|
||||
$this->document->setActiveSection('admin/servers');
|
||||
$this->document->setActiveItem('index');
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 2) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->library('pagination');
|
||||
$this->load->model('servers');
|
||||
|
||||
$userid = @$this->request->get['userid'];
|
||||
$gameid = @$this->request->get['gameid'];
|
||||
$locationid = @$this->request->get['locationid'];
|
||||
|
||||
$getData = array();
|
||||
|
||||
if(!empty($userid)) {
|
||||
$getData['servers.user_id'] = (int)$userid;
|
||||
}
|
||||
if(!empty($gameid)) {
|
||||
$getData['servers.game_id'] = (int)$gameid;
|
||||
}
|
||||
if(!empty($locationid)) {
|
||||
$getData['servers.location_id'] = (int)$locationid;
|
||||
}
|
||||
|
||||
$getOptions = array(
|
||||
'start' => ($page - 1) * $this->limit,
|
||||
'limit' => $this->limit
|
||||
);
|
||||
|
||||
|
||||
$total = $this->serversModel->getTotalServers($getData);
|
||||
$servers = $this->serversModel->getServers($getData, array('games', 'locations'), array(), $getOptions);
|
||||
|
||||
$paginationUrl = '/admin/servers/index/index/{page}';
|
||||
if(!empty($userid)) {
|
||||
$paginationUrl .= '&userid=' . $userid;
|
||||
}
|
||||
if(!empty($gameid)) {
|
||||
$paginationUrl .= '&gameid=' . $gameid;
|
||||
}
|
||||
if(!empty($locationid)) {
|
||||
$paginationUrl .= '&locationid=' . $locationid;
|
||||
}
|
||||
|
||||
$paginationLib = new paginationLibrary();
|
||||
$paginationLib->total = $total;
|
||||
$paginationLib->page = $page;
|
||||
$paginationLib->limit = $this->limit;
|
||||
$paginationLib->url = $paginationUrl;
|
||||
$pagination = $paginationLib->render();
|
||||
|
||||
$this->data['servers'] = $servers;
|
||||
$this->data['pagination'] = $pagination;
|
||||
|
||||
$this->getChild(array('common/admheader', 'common/footer'));
|
||||
return $this->load->view('admin/servers/index', $this->data);
|
||||
}
|
||||
|
||||
public function action($serverid = null, $action = null) {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if($this->user->getAccessLevel() < 2) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$this->load->model('servers');
|
||||
$this->load->model('serverLog');
|
||||
|
||||
$error = $this->validate($serverid);
|
||||
if($error) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $error;
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$server = $this->serversModel->getServerById($serverid, array('users', 'locations', 'games'));
|
||||
|
||||
if($server['server_status'] == 3) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет установка сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 4) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет переустановка сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 5) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет создание BackUP сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 6) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет восстанновление сервера из BackUP!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 7) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет обновление сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server["server_status"] == 0) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Сервер заблокирован!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
switch($action) {
|
||||
case "start": {
|
||||
if($server["server_status"] == 1) {
|
||||
$stats = $this->serversModel->getHDD($server['server_id']);
|
||||
if((int)$stats < $server['game_ssd']) {
|
||||
$result = $this->serversModel->action($serverid, 'start');
|
||||
if($result["status"] == "success") {
|
||||
$this->serversModel->deleteTask(array('task_name' => 'enable', 'server_id' => $serverid));
|
||||
$this->serversModel->updateServer($serverid, array("server_status" => 2));
|
||||
$logData = array(
|
||||
'server_id' => $serverid,
|
||||
'reason' => 'Успешный запуск сервера',
|
||||
'status' => 1
|
||||
);
|
||||
$this->serversModel->createLog($logData);
|
||||
$this->data["status"] = "success";
|
||||
$this->data["success"] = "Вы успешно запустили сервер!";
|
||||
} else {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = $result["description"];
|
||||
}
|
||||
} else {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Вы привысили ограничение размера директории на ". round($stats - $server['game_ssd'], 2) ."МБ, запуск сервера невозможен!";
|
||||
}
|
||||
} else {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Сервер должен быть выключен!";
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case "restart": {
|
||||
if($server["server_status"] == 2) {
|
||||
$stats = $this->serversModel->getHDD($server['server_id']);
|
||||
if((int)$stats < $server['game_ssd']) {
|
||||
$result = $this->serversModel->action($serverid, 'restart');
|
||||
if($result["status"] == "success") {
|
||||
$this->serversModel->deleteTask(array('task_name' => 'restart', 'server_id' => $serverid));
|
||||
$logData = array(
|
||||
'server_id' => $serverid,
|
||||
'reason' => 'Успешный перезапуск сервера',
|
||||
'status' => 1
|
||||
);
|
||||
$this->serversModel->createLog($logData);
|
||||
$this->data["status"] = "success";
|
||||
$this->data["success"] = "Вы успешно перезапустили сервер!";
|
||||
} else {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = $result["description"];
|
||||
}
|
||||
} else {
|
||||
$result = $this->serversModel->action($serverid, 'stop');
|
||||
if($result['status'] == "success") {
|
||||
$this->serversModel->updateServer($serverid, array('server_status' => 1));
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Вы привысили ограничение размера директории на ". round($stats - $server['game_ssd'], 2) ."МБ, перезагрузка сервера невозможна!";
|
||||
} else {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = $result["description"];
|
||||
}
|
||||
}
|
||||
} else if($server["server_status"] == 2) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Сервер должен быть включен!";
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case "stop": {
|
||||
if($server["server_status"] == 2) {
|
||||
$result = $this->serversModel->action($serverid, 'stop');
|
||||
if($result["status"] == "success") {
|
||||
$this->serversModel->deleteTask(array('task_name' => 'disable', 'server_id' => $serverid));
|
||||
$this->serversModel->deleteTask(array('task_name' => 'restart', 'server_id' => $serverid));
|
||||
$this->serversModel->updateServer($serverid, array("server_status" => 1));
|
||||
$logData = array(
|
||||
'server_id' => $serverid,
|
||||
'reason' => 'Успешное выключение сервера',
|
||||
'status' => 1
|
||||
);
|
||||
$this->serversModel->createLog($logData);
|
||||
$this->data["status"] = "success";
|
||||
$this->data["success"] = "Вы успешно выключили сервер!";
|
||||
} else {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = $result["description"];
|
||||
}
|
||||
} else {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Сервер должен быть вылючен!";
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
private function validate($serverid) {
|
||||
$result = null;
|
||||
|
||||
$userid = $this->user->getId();
|
||||
|
||||
if(!$this->serversModel->getTotalServers(array('server_id' => (int)$serverid, 'user_id' => (int)$userid))) {
|
||||
$result = "Запрашиваемый сервер не существует или у ват нету доступа!";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class settingsController extends Controller {
|
||||
public function index() {
|
||||
$this->document->setActiveSection('admin/settings');
|
||||
$this->document->setActiveItem('index');
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 3) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$userid = $this->user->getId();
|
||||
$this->load->model('users');
|
||||
|
||||
require(APPLICATION_DIR . 'config.php');
|
||||
$this->data['settings'] = $config;
|
||||
unset($config);
|
||||
|
||||
$this->getChild(array('common/admheader', 'common/footer'));
|
||||
return $this->load->view('admin/settings', $this->data);
|
||||
}
|
||||
|
||||
public function ajax() {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if($this->user->getAccessLevel() < 3) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$userid = $this->user->getId();
|
||||
$this->load->model('users');
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
|
||||
|
||||
$file = file_get_contents(APPLICATION_DIR . 'config.php');
|
||||
$file = str_replace(",", "", $file);
|
||||
|
||||
$file = str_replace("<?php", "", $file);
|
||||
$file = str_replace('$config = array(', "", $file);
|
||||
|
||||
$file = str_replace(');', "", $file);
|
||||
$file = str_replace('?>', "", $file);
|
||||
|
||||
$file = explode("\n",$file);
|
||||
|
||||
$file2 = array();
|
||||
foreach($file as $line){
|
||||
if($line !== ''){
|
||||
$file2[] = $line;
|
||||
}
|
||||
}
|
||||
unset($line);
|
||||
$file = $file2;
|
||||
unset($file2);
|
||||
|
||||
$post = array();
|
||||
foreach($this->request->post as $post_string => $post_value){
|
||||
$post[$post_string] = $post_value;
|
||||
if($post_string !== 'close'){
|
||||
$post['close'] = 'off';
|
||||
}
|
||||
}
|
||||
|
||||
foreach($post as $string => $value) {
|
||||
for ($i = 0; $i < count($file); $i++) {
|
||||
if (strpos($file[$i], $string) !== FALSE) {
|
||||
$search_line = $file[$i];
|
||||
$file[$i] = "'".$string."' => '".$value."'";
|
||||
break;
|
||||
}
|
||||
}
|
||||
if($search_line == null) {
|
||||
$file[] = "'".$string."' => '".$value."'";
|
||||
}
|
||||
unset($search_line);
|
||||
}
|
||||
|
||||
|
||||
|
||||
foreach($file as $line => $line2){
|
||||
if($line < count($file)-1 and $file[$line] != "\n"){
|
||||
$file[$line] = $line2.',';
|
||||
}
|
||||
}
|
||||
|
||||
$file = implode("\n", $file);
|
||||
$file = preg_replace('/([\r\n]){2,}/s', '\1', $file);
|
||||
|
||||
$file2 = '<?php';
|
||||
$file2 .= "\n".'$config = array(';
|
||||
$file2 .= "\n".$file;
|
||||
$file2 .= "\n".');';
|
||||
$file2 .= "\n".'?>';
|
||||
|
||||
file_put_contents(APPLICATION_DIR.'config.php', $file2);
|
||||
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Настройки сохранены!";
|
||||
}
|
||||
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class indexController extends Controller {
|
||||
public function index() {
|
||||
$this->document->setActiveSection('admin/statistics');
|
||||
$this->document->setActiveItem('index');
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 2) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$userid = $this->user->getId();
|
||||
$this->load->model('users');
|
||||
|
||||
$this->getChild(array('common/admheader', 'common/footer'));
|
||||
|
||||
|
||||
$this->load->model('invoices');
|
||||
$this->load->model('servers');
|
||||
$get_invoices = $this->invoicesModel->getStatisticsInvStatsById();
|
||||
$get_registers = $this->usersModel->getStatisticsRegistersById();
|
||||
$get_players = $this->serversModel->getStatisticsPlayers();
|
||||
$get_loads = $this->serversModel->getStatisticsLoad();
|
||||
|
||||
$charts = 'var invoices = [ ';
|
||||
foreach($get_invoices as $item){
|
||||
$charts .= '['.(strtotime($item['invoice_date_add']))*1000 .', '.$item['SUM(`invoice_ammount`)'].'], ';
|
||||
}
|
||||
$charts .= '];';
|
||||
|
||||
$charts .= 'var registers = [ ';
|
||||
foreach($get_registers as $item){
|
||||
$charts .= '['.(strtotime($item['mydate']))*1000 .', '.(int)$item['count(user_id)'].'], ';
|
||||
}
|
||||
$charts .= '];';
|
||||
|
||||
$charts .= 'var players = [ ';
|
||||
foreach($get_players as $item){
|
||||
$charts .= '['.(strtotime($item['mydate']))*1000 .', '.(int)$item['sum(`server_stats_players`)'].'], ';
|
||||
}
|
||||
$charts .= '];';
|
||||
|
||||
$charts .= 'var loads1 = [ ';
|
||||
foreach($get_loads as $item){
|
||||
$charts .= '['.(strtotime($item['mydate']))*1000 .', '.(int)$item['sum(`server_stats_cpu`)'].'], ';
|
||||
}
|
||||
$charts .= '];';
|
||||
|
||||
$charts .= 'var loads2 = [ ';
|
||||
foreach($get_loads as $item){
|
||||
$charts .= '['.(strtotime($item['mydate']))*1000 .', '.(int)$item['sum(`server_stats_hdd`)'].'], ';
|
||||
}
|
||||
$charts .= '];';
|
||||
|
||||
$charts .= 'var loads3 = [ ';
|
||||
foreach($get_loads as $item){
|
||||
$charts .= '['.(strtotime($item['mydate']))*1000 .', '.(int)$item['sum(`server_stats_ram`)'].'], ';
|
||||
}
|
||||
$charts .= '];';
|
||||
|
||||
$this->data['charts'] = $charts;
|
||||
|
||||
|
||||
return $this->load->view('admin/statistics/index', $this->data);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class createController extends Controller {
|
||||
public function index() {
|
||||
$this->document->setActiveSection('admin/ticketcategory');
|
||||
$this->document->setActiveItem('create');
|
||||
$this->data['url'] = $this->config->url;
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 3) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
$this->getChild(array('common/admheader', 'common/footer'));
|
||||
return $this->load->view('admin/ticketcategory/create', $this->data);
|
||||
}
|
||||
|
||||
public function ajax() {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if($this->user->getAccessLevel() < 3) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$this->load->model('ticketsCategory');
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
$errorPOST = $this->validatePOST();
|
||||
if(!$errorPOST) {
|
||||
$name = @$this->request->post['name'];
|
||||
$status = @$this->request->post['status'];
|
||||
|
||||
$adapData = array(
|
||||
'category_name' => $name,
|
||||
'category_status' => $status
|
||||
);
|
||||
|
||||
$this->ticketsCategoryModel->createTicketCategory($adapData);
|
||||
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Вы успешно создали категорию!";
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $errorPOST;
|
||||
}
|
||||
}
|
||||
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
private function validatePOST() {
|
||||
$this->load->library('validate');
|
||||
|
||||
$validateLib = new validateLibrary();
|
||||
|
||||
$result = null;
|
||||
|
||||
$name = @$this->request->post['name'];
|
||||
$status = @$this->request->post['status'];
|
||||
|
||||
if(mb_strlen($name) < 2 || mb_strlen($name) > 32) {
|
||||
$result = "Название категории должно содержать от 2 до 32 символов!";
|
||||
}
|
||||
elseif($status < 0 || $status > 1) {
|
||||
$result = "Укажите допустимый статус!";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,138 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class editController extends Controller {
|
||||
public function index($categoryid = null) {
|
||||
$this->document->setActiveSection('admin/ticketcategory');
|
||||
$this->document->setActiveItem('edit');
|
||||
$this->data['url'] = $this->config->url;
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 3) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->model('ticketsCategory');
|
||||
|
||||
$error = $this->validate($categoryid);
|
||||
if($error) {
|
||||
$this->session->data['error'] = $error;
|
||||
$this->response->redirect($this->config->url . 'admin/ticketcategory/index');
|
||||
}
|
||||
|
||||
$category = $this->ticketsCategoryModel->getTicketCategoryById($categoryid);
|
||||
|
||||
$this->data['category'] = $category;
|
||||
$this->getChild(array('common/admheader', 'common/footer'));
|
||||
return $this->load->view('admin/ticketcategory/edit', $this->data);
|
||||
}
|
||||
|
||||
public function ajax($categoryid = null) {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if($this->user->getAccessLevel() < 3) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$this->load->model('ticketsCategory');
|
||||
|
||||
$error = $this->validate($categoryid);
|
||||
if($error) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $error;
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
$errorPOST = $this->validatePOST();
|
||||
if(!$errorPOST) {
|
||||
$name = @$this->request->post['name'];
|
||||
$status = @$this->request->post['status'];
|
||||
|
||||
$adapData = array(
|
||||
'category_name' => $name,
|
||||
'category_status' => (int)$status
|
||||
);
|
||||
|
||||
|
||||
$this->ticketsCategoryModel->updateTicketCategory($categoryid, $adapData);
|
||||
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Вы успешно отредактировали категорию!";
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $errorPOST;
|
||||
}
|
||||
}
|
||||
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
public function delete($categoryid = null) {
|
||||
$this->document->setActiveSection('admin');
|
||||
$this->document->setActiveItem('tickets');
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 3) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->model('ticketsCategory');
|
||||
|
||||
$error = $this->validate($categoryid);
|
||||
if($error) {
|
||||
$this->session->data['error'] = $error;
|
||||
$this->response->redirect($this->config->url . 'admin/ticketcategory/index');
|
||||
}
|
||||
|
||||
$this->ticketsCategoryModel->deleteTicketCategory($categoryid);
|
||||
|
||||
$this->session->data['success'] = "Вы успешно удалили дополнение!";
|
||||
$this->response->redirect($this->config->url . 'admin/ticketcategory/index');
|
||||
return null;
|
||||
}
|
||||
|
||||
private function validate($categoryid) {
|
||||
$result = null;
|
||||
$this->load->model('ticketsCategory');
|
||||
if(!$this->ticketsCategoryModel->getTotalTicketsCategory(array('category_id' => (int)$categoryid))) {
|
||||
$result = "Запрашиваемая категория не существует!";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function validatePOST() {
|
||||
$this->load->library('validate');
|
||||
|
||||
$validateLib = new validateLibrary();
|
||||
|
||||
$result = null;
|
||||
|
||||
$name = @$this->request->post['name'];
|
||||
$status = @$this->request->post['status'];
|
||||
|
||||
if(mb_strlen($name) < 2 || mb_strlen($name) > 32) {
|
||||
$result = "Название категории должно содержать от 2 до 32 символов!";
|
||||
}
|
||||
elseif($status < 0 || $status > 1) {
|
||||
$result = "Укажите допустимый статус!";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class indexController extends Controller {
|
||||
private $limit = 20;
|
||||
public function index($page = 1) {
|
||||
$this->document->setActiveSection('admin/ticketcategory');
|
||||
$this->document->setActiveItem('index');
|
||||
$this->data['url'] = $this->config->url;
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 3) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->library('pagination');
|
||||
$this->load->model('ticketsCategory');
|
||||
|
||||
$options = array(
|
||||
'start' => ($page - 1) * $this->limit,
|
||||
'limit' => $this->limit
|
||||
);
|
||||
|
||||
$total = $this->ticketsCategoryModel->getTotalTicketsCategory();
|
||||
$category = $this->ticketsCategoryModel->getTicketsCategory(array(),array(),array(), $options);
|
||||
|
||||
$paginationUrl = '/admin/ticketcategory/index/index/{page}';
|
||||
$paginationLib = new paginationLibrary();
|
||||
$paginationLib->total = $total;
|
||||
$paginationLib->page = $page;
|
||||
$paginationLib->limit = $this->limit;
|
||||
$paginationLib->url = $paginationUrl;
|
||||
$pagination = $paginationLib->render();
|
||||
|
||||
$this->data['category'] = $category;
|
||||
$this->data['pagination'] = $pagination;
|
||||
|
||||
$this->getChild(array('common/admheader', 'common/footer'));
|
||||
return $this->load->view('admin/ticketcategory/index', $this->data);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class createController extends Controller {
|
||||
public function index($ticketid = null) {
|
||||
$this->document->setActiveSection('admin/tickets');
|
||||
$this->document->setActiveItem('create');
|
||||
$this->data['url'] = $this->config->url;
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 2) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
$this->load->model('users');
|
||||
$userid = $this->user->getId();
|
||||
$this->getChild(array('common/admheader', 'common/footer'));
|
||||
return $this->load->view('admin/tickets/create', $this->data);
|
||||
}
|
||||
|
||||
public function ajax($ticketid = null) {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if($this->user->getAccessLevel() < 1) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$this->load->model('tickets');
|
||||
$this->load->model('ticketsMessages');
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
$errorPOST = $this->validatePOST();
|
||||
if(!$errorPOST) {
|
||||
$name = @$this->request->post['name'];
|
||||
$text = @$this->request->post['text'];
|
||||
$pid = @$this->request->post['pid'];
|
||||
$userid = $this->user->getId();
|
||||
|
||||
$ticketData = array(
|
||||
'user_id' => $pid,
|
||||
'ticket_name' => $name,
|
||||
'ticket_status' => 2
|
||||
);
|
||||
$ticketid = $this->ticketsModel->createTicket($ticketData);
|
||||
|
||||
$messageData = array(
|
||||
'ticket_id' => $ticketid,
|
||||
'user_id' => $userid,
|
||||
'ticket_message' => $text
|
||||
);
|
||||
$this->ticketsMessagesModel->createTicketMessage($messageData);
|
||||
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Вы успешно отправили сообщение пользователю!";
|
||||
$this->data['id'] = $ticketid;
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $errorPOST;
|
||||
}
|
||||
}
|
||||
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
private function validatePOST() {
|
||||
$result = null;
|
||||
|
||||
$name = @$this->request->post['name'];
|
||||
$pid = @$this->request->post['pid'];
|
||||
$text = @$this->request->post['text'];
|
||||
|
||||
if(mb_strlen($name) < 6 || mb_strlen($name) > 32) {
|
||||
$result = "Название тикета должно содержать от 6 до 32 символов!";
|
||||
}
|
||||
elseif(mb_strlen($pid) < 1 || mb_strlen($pid) > 10) {
|
||||
$result = "ID клиента должен быть от 1 до 10 символов!";
|
||||
}
|
||||
elseif(mb_strlen($text) < 1 || mb_strlen($text) > 350) {
|
||||
$result = "Текст тикета должен содержать от 1 до 350 символов!";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class indexController extends Controller {
|
||||
private $limit = 20;
|
||||
public function index($page = 1) {
|
||||
$this->document->setActiveSection('admin/tickets');
|
||||
$this->document->setActiveItem('index');
|
||||
$this->data['url'] = $this->config->url;
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 2) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->library('pagination');
|
||||
$this->load->model('tickets');
|
||||
$this->load->model('users');
|
||||
$userid = $this->user->getId();
|
||||
|
||||
$userid = @$this->request->get['userid'];
|
||||
$status = @$this->request->get['status'];
|
||||
|
||||
$getData = array();
|
||||
|
||||
if(!empty($userid)) {
|
||||
$getData['tickets.user_id'] = (int)$userid;
|
||||
}
|
||||
if(!empty($status)) {
|
||||
$getData['tickets.ticket_status'] = (int)$status;
|
||||
}
|
||||
|
||||
$getSort = array(
|
||||
'ticket_status' => 'DESC',
|
||||
'ticket_date_add' => 'DESC'
|
||||
);
|
||||
|
||||
$getOptions = array(
|
||||
'start' => ($page - 1) * $this->limit,
|
||||
'limit' => $this->limit
|
||||
);
|
||||
|
||||
$total = $this->ticketsModel->getTotalTickets($getData);
|
||||
$tickets = $this->ticketsModel->getTickets($getData, array('users','tickets_category'), $getSort, $getOptions);
|
||||
|
||||
$paginationUrl = '/admin/tickets/index/index/{page}';
|
||||
if(!empty($userid)) {
|
||||
$paginationUrl .= '&userid=' . $userid;
|
||||
}
|
||||
if(!empty($status)) {
|
||||
$paginationUrl .= '&status=' . $status;
|
||||
}
|
||||
|
||||
$paginationLib = new paginationLibrary();
|
||||
$paginationLib->total = $total;
|
||||
$paginationLib->page = $page;
|
||||
$paginationLib->limit = $this->limit;
|
||||
$paginationLib->url = $paginationUrl;
|
||||
$pagination = $paginationLib->render();
|
||||
|
||||
$this->data['tickets'] = $tickets;
|
||||
$this->data['pagination'] = $pagination;
|
||||
|
||||
$this->getChild(array('common/admheader', 'common/footer'));
|
||||
return $this->load->view('admin/tickets/index', $this->data);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,254 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class viewController extends Controller {
|
||||
public function index($ticketid = null) {
|
||||
$this->document->setActiveSection('admin/tickets');
|
||||
$this->document->setActiveItem('view');
|
||||
$this->data['url'] = $this->config->url;
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 2) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->model('tickets');
|
||||
$this->load->model('users');
|
||||
|
||||
$error = $this->validate($ticketid);
|
||||
if($error) {
|
||||
$this->session->data['error'] = $error;
|
||||
$this->response->redirect($this->config->url . 'admin/tickets/index');
|
||||
}
|
||||
|
||||
$ticket = $this->ticketsModel->getTicketById($ticketid, array('users'));
|
||||
$this->data['ticket'] = $ticket;
|
||||
$this->data['user_img'] = $this->user->getUser_img();
|
||||
|
||||
$this->getChild(array('common/admheader', 'common/footer'));
|
||||
return $this->load->view('admin/tickets/view', $this->data);
|
||||
}
|
||||
|
||||
public function ajax($ticketid = null) {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if($this->user->getAccessLevel() < 2) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$this->load->model('tickets');
|
||||
$this->load->model('ticketsMessages');
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
$errorPOST = $this->validatePOST($ticketid);
|
||||
if(!$errorPOST) {
|
||||
$userid = $this->user->getId();
|
||||
$text = @$this->request->post['text'];
|
||||
$ticket = $this->ticketsModel->getTicketById($ticketid, array('users'));
|
||||
if($ticket['ticket_status'] != 0) {
|
||||
$messageData = array(
|
||||
'ticket_id' => $ticketid,
|
||||
'user_id' => $userid,
|
||||
'ticket_message' => $text
|
||||
);
|
||||
$this->ticketsModel->updateTicket($ticketid, array('ticket_status' => 2));
|
||||
$this->ticketsMessagesModel->createTicketMessage($messageData);
|
||||
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Вы успешно отправили сообщение!";
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Данный запрос закрыт, оставить новое сообщение невозможно!";
|
||||
}
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $errorPOST;
|
||||
}
|
||||
}
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
public function action($ticketid = null, $action = null) {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if($this->user->getAccessLevel() < 0) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
$this->load->model('tickets');
|
||||
$this->load->model('ticketsMessages');
|
||||
switch($action) {
|
||||
case 'closed': {
|
||||
$this->ticketsModel->updateTicket($ticketid, array('ticket_status' => 0));
|
||||
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Вы успешно закрыли запрос!";
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы выбрали несуществующее действие!";
|
||||
break;
|
||||
}
|
||||
}
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
public function uploadFile($ticketid = null) {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if($this->user->getAccessLevel() < 2) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$this->load->model('tickets');
|
||||
$this->load->model('ticketsMessages');
|
||||
$this->load->model('users');
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
$uploaddir = "tmp/tickets_img/";
|
||||
$apend=date('YmdHis').rand(100,1000).'.jpg';
|
||||
$uploadfile = "$uploaddir$apend";
|
||||
|
||||
if(move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
|
||||
if($_FILES['userfile']['type'] == 'image/gif' || $_FILES['userfile']['type'] == 'image/jpeg' || $_FILES['userfile']['type'] == 'image/png') {
|
||||
if($_FILES['userfile']['size'] != 0 and $_FILES['userfile']['size'] <= 5120000) {
|
||||
$size = getimagesize($uploadfile);
|
||||
if ($size[0] < 2560 && $size[1] < 1440) {
|
||||
if(round(($_FILES['userfile']['size'] / 1024), 2) > 1500.00) {
|
||||
$message = 'Изображение: ' . $apend . '<br>Размер: ' . round(($_FILES['userfile']['size'] / 1024), 2) . 'КБ<br><a href="/' . $uploadfile . ' target="_blank">Открыть</a>';
|
||||
} else {
|
||||
$message = '<a href="/' . $uploadfile . '" target="_blank"><img height="150" src="/' . $uploadfile . '"></a>';
|
||||
}
|
||||
$userid = $this->user->getId();
|
||||
$messageData = array(
|
||||
'ticket_id' => $ticketid,
|
||||
'user_id' => $userid,
|
||||
'ticket_message' => $message
|
||||
);
|
||||
$this->ticketsModel->updateTicket($ticketid, array('ticket_status' => 1));
|
||||
$this->ticketsMessagesModel->createTicketMessage($messageData);
|
||||
$this->data['status'] = 'success';
|
||||
$this->data['success'] = 'Изображение загружено!';
|
||||
} else {
|
||||
$this->data['error'] = 'Загружаемое изображение превышает допустимые нормы!';
|
||||
$this->data['status'] = "error";
|
||||
unlink($uploadfile);
|
||||
}
|
||||
} else {
|
||||
$this->data['error'] = 'Размер изображения не должено превышать 5120Кб';
|
||||
$this->data['status'] = "error";
|
||||
}
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Можно загружать только изображения в форматах jpg, jpeg и png";
|
||||
}
|
||||
} else {
|
||||
$this->data['error'] = 'Изображение не загружено!';
|
||||
$this->data['status'] = "error";
|
||||
}
|
||||
}
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
public function getMessagess() {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 2) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
$this->load->model('tickets');
|
||||
$this->load->model('ticketsMessages');
|
||||
|
||||
$id = $this->request->post['tid'];
|
||||
|
||||
$url = $this->config->url;
|
||||
$messages = $this->ticketsMessagesModel->getTicketsMessages(array('ticket_id' => $id), array('users'));
|
||||
|
||||
foreach($messages as $item) {
|
||||
$item['ticket_message'] = preg_replace("#(https?|ftp)://\S+[^\s.,>)\];'\"!?]#",'<a href="\\0" target="_blank">\\0</a>', $item['ticket_message']);
|
||||
if($item['user_access_level'] == '1') {
|
||||
echo '<div class="d-flex flex-column mb-5 align-items-start">
|
||||
<div class="d-flex align-items-center">
|
||||
<div class="symbol symbol-circle symbol-40 mr-3">
|
||||
<img alt="Pic" src="'.$url.''.$item['user_img'].'" />
|
||||
</div>
|
||||
<div>
|
||||
<a href="/admin/users/edit/index/'.$item['user_id'] .'" class="text-dark-75 text-hover-primary font-weight-bold font-size-h6">'. $item['user_firstname'] .' '. $item['user_lastname'] .'</a>
|
||||
<span class="text-muted font-size-sm">'. date("d.m.Y в H:i", strtotime($item['ticket_message_date_add'])) .'</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-2 rounded p-5 bg-light-success text-dark-50 font-weight-bold font-size-lg text-left max-w-400px">'. nl2br($item['ticket_message']) .'
|
||||
</div></div>';
|
||||
}
|
||||
|
||||
if($item['user_access_level'] >= '2') {
|
||||
echo '<div class="d-flex flex-column mb-5 align-items-end">
|
||||
<div class="d-flex align-items-center">
|
||||
<div class="symbol symbol-circle symbol-40 mr-3">
|
||||
<img alt="Pic" src="'.$url.''.$item['user_img'].'" />
|
||||
</div>
|
||||
<div>
|
||||
<a href="/admin/users/edit/index/'.$item['user_id'] .'" class="text-dark-75 text-hover-primary font-weight-bold font-size-h6">'. $item['user_firstname'] .' '. $item['user_lastname'] .'</a>
|
||||
<span class="text-muted font-size-sm">'. date("d.m.Y в H:i", strtotime($item['ticket_message_date_add'])) .'</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-2 rounded p-5 bg-light-primary text-dark-50 font-weight-bold font-size-lg text-left max-w-400px">'. nl2br($item['ticket_message']) .'<br>
|
||||
</div></div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function validate($ticketid) {
|
||||
$result = null;
|
||||
|
||||
if(!$this->ticketsModel->getTotalTickets(array('ticket_id' => (int)$ticketid))) {
|
||||
$result = "Запрашиваемый тикет не существует!";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function validatePOST($ticketid) {
|
||||
$result = null;
|
||||
$userid = $this->user->getId();
|
||||
$text = @$this->request->post['text'];
|
||||
$closeticket = @$this->request->post['closeticket'];
|
||||
|
||||
if(!$closeticket) {
|
||||
if (5 <= $this->ticketsModel->spam($userid)) {
|
||||
$result = 'Пожалуйста, подождите 10 секунд.';
|
||||
}
|
||||
else if(mb_strlen($text) < 1 || mb_strlen($text) > 350) {
|
||||
$result = "Текст сообщения должен содержать от 1 до 350 символов.";
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,196 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class editController extends Controller {
|
||||
public function index($userid = null) {
|
||||
$this->data['url'] = $this->config->url;
|
||||
$this->document->setActiveSection('admin/users');
|
||||
$this->document->setActiveItem('edit');
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 2) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->model('users');
|
||||
$this->load->model('servers');
|
||||
|
||||
$error = $this->validate($userid);
|
||||
if($error) {
|
||||
$this->session->data['error'] = $error;
|
||||
$this->response->redirect($this->config->url . 'admin/users/index');
|
||||
}
|
||||
|
||||
$user = $this->usersModel->getUserById($userid);
|
||||
|
||||
$this->data['user'] = $user;
|
||||
$servers = $this->serversModel->getServers(array('user_id' => (int)$userid), array('games', 'locations'), array(), array());
|
||||
$visitors = $this->usersModel->getAuthLog($userid);
|
||||
$this->data['servers'] = $servers;
|
||||
$this->data['visitors'] = $visitors;
|
||||
$this->data['user_img'] = $this->user->getUser_img();
|
||||
$this->data['user_access_level'] = $this->user->getAccessLevel();
|
||||
$this->getChild(array('common/admheader', 'common/footer'));
|
||||
return $this->load->view('admin/users/edit', $this->data);
|
||||
}
|
||||
|
||||
public function ajax($userid = null) {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if($this->user->getAccessLevel() < 3) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$this->load->model('users');
|
||||
|
||||
$error = $this->validate($userid);
|
||||
if($error) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $error;
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
$errorPOST = $this->validatePOST();
|
||||
if(!$errorPOST) {
|
||||
$lastname = @$this->request->post['lastname'];
|
||||
$firstname = @$this->request->post['firstname'];
|
||||
$email = @$this->request->post['email'];
|
||||
$status = @$this->request->post['status'];
|
||||
$balance = @$this->request->post['balance'];
|
||||
$vk_id = @$this->request->post['vk_id'];
|
||||
$test_server = @$this->request->post['test_server'];
|
||||
$user_activate = @$this->request->post['user_activate'];
|
||||
$accesslevel = @$this->request->post['accesslevel'];
|
||||
$editpassword = @$this->request->post['editpassword'];
|
||||
$password = @$this->request->post['password'];
|
||||
|
||||
if (@$firstname) {
|
||||
$firstname = @strtoupper($firstname[0]) . substr($firstname, 1);
|
||||
}
|
||||
|
||||
if (@$lastname) {
|
||||
$lastname = @strtoupper($lastname[0]) . substr($lastname, 1);
|
||||
}
|
||||
|
||||
$userData = array(
|
||||
'user_firstname' => $firstname,
|
||||
'user_lastname' => $lastname,
|
||||
'user_email' => $email,
|
||||
'user_status' => (int)$status,
|
||||
'user_balance' => (float)$balance,
|
||||
'user_vk_id' => (float)$vk_id,
|
||||
'test_server' => (float)$test_server,
|
||||
'user_access_level' => (float)$accesslevel,
|
||||
'user_activate' => (float)$user_activate,
|
||||
);
|
||||
|
||||
if($editpassword) {
|
||||
$userData['user_password'] = md5($password);
|
||||
}
|
||||
|
||||
$this->usersModel->updateUser($userid, $userData);
|
||||
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Изменения сохранены!";
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $errorPOST;
|
||||
}
|
||||
}
|
||||
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
public function delete($user_id = null) {
|
||||
$this->document->setActiveSection('admin');
|
||||
$this->document->setActiveItem('users');
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 3) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->model('users');
|
||||
|
||||
$this->usersModel->deleteUser($user_id);
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Вы успешно удалили пользователя!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
private function validate($userid) {
|
||||
$result = null;
|
||||
|
||||
if(!$this->usersModel->getTotalUsers(array('user_id' => (int)$userid))) {
|
||||
$result = "Запрашиваемый пользователь не существует!";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function validatePOST() {
|
||||
$this->load->library('validate');
|
||||
|
||||
$validateLib = new validateLibrary();
|
||||
|
||||
$result = null;
|
||||
|
||||
$lastname = @$this->request->post['lastname'];
|
||||
$firstname = @$this->request->post['firstname'];
|
||||
$status = @$this->request->post['status'];
|
||||
$balance = @$this->request->post['balance'];
|
||||
$accesslevel = @$this->request->post['accesslevel'];
|
||||
$editpassword = @$this->request->post['editpassword'];
|
||||
$password = @$this->request->post['password'];
|
||||
$password2 = @$this->request->post['password2'];
|
||||
|
||||
if (@$firstname) {
|
||||
$firstname = @strtoupper($firstname[0]) . substr($firstname, 1);
|
||||
}
|
||||
|
||||
if (@$lastname) {
|
||||
$lastname = @strtoupper($lastname[0]) . substr($lastname, 1);
|
||||
}
|
||||
|
||||
if(!$validateLib->check_for_number($lastname)) {
|
||||
$result = "Укажите свою реальную фамилию!";
|
||||
}
|
||||
elseif(!$validateLib->check_for_number($firstname)) {
|
||||
$result = "Укажите свое реальное имя!";
|
||||
}
|
||||
elseif(!$validateLib->userstatus($status)) {
|
||||
$result = "Укажите допустимый статус!";
|
||||
}
|
||||
elseif(!$validateLib->money($balance)) {
|
||||
$result = "Укажите допустимый баланс!";
|
||||
}
|
||||
elseif(!$validateLib->accesslevel($accesslevel)) {
|
||||
$result = "Укажите допустимый уровень доступа!";
|
||||
}
|
||||
elseif($editpassword) {
|
||||
if(!$validateLib->password($password)) {
|
||||
$result = "Пароль должен содержать от 6 до 32 латинских букв, цифр и знаков <i>,.!?_-</i>!";
|
||||
}
|
||||
elseif($password != $password2) {
|
||||
$result = "Введенные вами пароли не совпадают!";
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,232 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class indexController extends Controller {
|
||||
private $limit = 20;
|
||||
public function index($page = 1) {
|
||||
$this->document->setActiveSection('admin/users');
|
||||
$this->document->setActiveItem('index');
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 2) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->library('pagination');
|
||||
$this->load->model('users');
|
||||
|
||||
$getOptions = array(
|
||||
'start' => ($page - 1) * $this->limit,
|
||||
'limit' => $this->limit
|
||||
);
|
||||
|
||||
$total = $this->usersModel->getTotalUsers();
|
||||
$users = $this->usersModel->getUsers(array(), array(), $getOptions);
|
||||
|
||||
$paginationUrl = '/admin/users/index/index/{page}';
|
||||
|
||||
$paginationLib = new paginationLibrary();
|
||||
$paginationLib->total = $total;
|
||||
$paginationLib->page = $page;
|
||||
$paginationLib->limit = $this->limit;
|
||||
$paginationLib->url = $paginationUrl;
|
||||
$pagination = $paginationLib->render();
|
||||
|
||||
$this->data['users'] = $users;
|
||||
$this->data['pagination'] = $pagination;
|
||||
$this->data['user_access_level'] = $this->user->getAccessLevel();
|
||||
|
||||
$this->getChild(array('common/admheader', 'common/footer'));
|
||||
return $this->load->view('admin/users/index', $this->data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function ajax() {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if($this->user->getAccessLevel() < 3) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$this->load->model('users');
|
||||
$this->load->model('news');
|
||||
$users = $this->usersModel->getUsers(array(), array(), array());
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
$errorPOST = $this->validatePOST();
|
||||
if(!$errorPOST) {
|
||||
$minsum = @$this->request->post['minsum'];
|
||||
$maxsum = @$this->request->post['maxsum'];
|
||||
$typesum = @$this->request->post['typesum'];
|
||||
$oneuser = @$this->request->post['oneuser'];
|
||||
$oneuserID = @$this->request->post['oneuserID'];
|
||||
$createnews = @$this->request->post['createnews'];
|
||||
|
||||
if($typesum) {
|
||||
if($oneuser) {
|
||||
$rsum = rand($minsum, $maxsum);
|
||||
|
||||
$this->usersModel->upUserBalance($oneuserID, $rsum);
|
||||
|
||||
$this->data['status'] = "info";
|
||||
$this->data['info'] = "".$rsum." - Реальные деньги выданы пользователю!";
|
||||
} else {
|
||||
if($createnews) {
|
||||
foreach($users as $item) {
|
||||
if($item['user_status'] == 1) {
|
||||
$userid = $item['user_id'];
|
||||
$rsum = rand($minsum, $maxsum);
|
||||
$this->usersModel->upUserBalance($oneuserID, $rsum);
|
||||
}
|
||||
}
|
||||
if(empty($users)) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Критическая ошибка";
|
||||
}
|
||||
|
||||
$today = date("Y-m-d H:i");
|
||||
|
||||
$name = "Выдача бонусных монет всем";
|
||||
$text = "Сегодня ".$today." администрацией была проведена раздача реальных денег, их получили все активированные пользователи! ";
|
||||
$category = "1";
|
||||
$img_preview = "1";
|
||||
$userid = $this->user->getId();
|
||||
|
||||
$newsData = array(
|
||||
'user_id' => $userid,
|
||||
'news_title' => $name,
|
||||
'news_text' => $text,
|
||||
'category_id' => $category,
|
||||
'place' => $place
|
||||
);
|
||||
$this->newsModel->createNews($newsData);
|
||||
|
||||
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Реальные деньги выданы!";
|
||||
} else {
|
||||
foreach($users as $item) {
|
||||
if($item['user_status'] == 1) {
|
||||
$userid = $item['user_id'];
|
||||
$rsum = rand($minsum, $maxsum);
|
||||
$this->usersModel->upUserBalance($oneuserID, $rsum);
|
||||
}
|
||||
}
|
||||
if(empty($users)) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Критическая ошибка";
|
||||
}
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Реальные деньги выданы!";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if($oneuser) {
|
||||
$rsum = rand($minsum, $maxsum);
|
||||
$this->usersModel->upUserRMoney($oneuserID, $rsum);
|
||||
|
||||
$this->data['status'] = "info";
|
||||
$this->data['info'] = "".$rsum." - Бонусные монеты выданы пользователю!";
|
||||
} else {
|
||||
if($createnews) {
|
||||
foreach($users as $item) {
|
||||
if($item['user_status'] == 1) {
|
||||
$userid = $item['user_id'];
|
||||
$rsum = rand($minsum, $maxsum);
|
||||
$this->usersModel->upUserRMoney($userid, $rsum);
|
||||
}
|
||||
}
|
||||
if(empty($users)) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Критическая ошибка";
|
||||
}
|
||||
|
||||
|
||||
$today = date("Y-m-d H:i");
|
||||
|
||||
$name = "Выдача бонусных монет всем";
|
||||
$text = "Сегодня ".$today." администрацией была проведена раздача бонусных монет, их получили все активированные пользователи! ";
|
||||
$category = "1";
|
||||
$place = "1";
|
||||
$userid = $this->user->getId();
|
||||
|
||||
$newsData = array(
|
||||
'user_id' => $userid,
|
||||
'news_title' => $name,
|
||||
'news_text' => $text,
|
||||
'category_id' => $category,
|
||||
'place' => $place
|
||||
);
|
||||
$this->newsModel->createNews($newsData);
|
||||
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Бонусные монеты выданы!";
|
||||
} else {
|
||||
foreach($users as $item) {
|
||||
if($item['user_status'] == 1) {
|
||||
$userid = $item['user_id'];
|
||||
$rsum = rand($minsum, $maxsum);
|
||||
$this->usersModel->upUserRMoney($userid, $rsum);
|
||||
}
|
||||
}
|
||||
if(empty($users)) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Критическая ошибка";
|
||||
}
|
||||
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Бонусные монеты выданы!";
|
||||
}
|
||||
}
|
||||
}
|
||||
// Сюда можно логирование
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $errorPOST;
|
||||
}
|
||||
}
|
||||
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
private function validatePOST() {
|
||||
$this->load->library('validate');
|
||||
|
||||
$validateLib = new validateLibrary();
|
||||
|
||||
$result = null;
|
||||
|
||||
$minsum = @$this->request->post['minsum'];
|
||||
$maxsum = @$this->request->post['maxsum'];
|
||||
$oneuser = @$this->request->post['oneuser'];
|
||||
$oneuserID = @$this->request->post['oneuserID'];
|
||||
|
||||
if(!$validateLib->money($maxsum)) {
|
||||
$result = "Укажите сумму в допустимом формате!";
|
||||
}
|
||||
elseif(1 > $minsum || $minsum > 5000) {
|
||||
$result = "Укажите сумму от 1 до 5000";
|
||||
}
|
||||
|
||||
if($oneuser) {
|
||||
if(!$this->usersModel->getTotalUsers(array('user_id' => (int)$oneuserID))) {
|
||||
$result = "Запрашиваемый пользователь не существует!";
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class indexController extends Controller {
|
||||
private $limit = 20;
|
||||
public function index($page = 1) {
|
||||
$this->document->setActiveSection('admin/waste');
|
||||
$this->document->setActiveItem('index');
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 2) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->library('pagination');
|
||||
$this->load->model('waste');
|
||||
|
||||
$userid = @$this->request->get['userid'];
|
||||
|
||||
$getData = array();
|
||||
|
||||
if(!empty($userid)) {
|
||||
$getData['waste.user_id'] = (int)$userid;
|
||||
}
|
||||
|
||||
$getOptions = array(
|
||||
'start' => ($page - 1) * $this->limit,
|
||||
'limit' => $this->limit
|
||||
);
|
||||
|
||||
$total = $this->wasteModel->getTotalWaste($getData);
|
||||
$waste = $this->wasteModel->getWaste($getData, array('users'), array(), $getOptions);
|
||||
$wastes = $this->wasteModel->getWaste(array(), array('users'), array(), array());
|
||||
|
||||
$paginationUrl = '/admin/waste/index/index/{page}';
|
||||
if(!empty($userid)) {
|
||||
$paginationUrl .= '&userid=' . $userid;
|
||||
}
|
||||
|
||||
$paginationLib = new paginationLibrary();
|
||||
$paginationLib->total = $total;
|
||||
$paginationLib->page = $page;
|
||||
$paginationLib->limit = $this->limit;
|
||||
$paginationLib->url = $paginationUrl;
|
||||
$pagination = $paginationLib->render();
|
||||
|
||||
$this->data['waste'] = $waste;
|
||||
$this->data['wastes'] = $wastes;
|
||||
$this->data['pagination'] = $pagination;
|
||||
|
||||
$this->getChild(array('common/admheader', 'common/footer'));
|
||||
return $this->load->view('admin/waste/index', $this->data);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,185 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class controlController extends Controller {
|
||||
public function index($webid = null) {
|
||||
$this->document->setActiveSection('admin/webhost');
|
||||
$this->document->setActiveItem('control');
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 2) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->model('webhost');
|
||||
|
||||
$error = $this->validate($webid);
|
||||
if($error) {
|
||||
$this->session->data['error'] = $error;
|
||||
$this->response->redirect($this->config->url . 'admin/webhost/index');
|
||||
}
|
||||
|
||||
$webhost = $this->webhostModel->getWebhostById($webid, array('users','web_tarifs','web_locations'));
|
||||
$this->data['webhost'] = $webhost;
|
||||
|
||||
$this->getChild(array('common/admheader', 'common/footer'));
|
||||
return $this->load->view('admin/webhost/control', $this->data);
|
||||
}
|
||||
|
||||
public function ajax($webid = null) {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if($this->user->getAccessLevel() < 2) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
$this->load->model('webhost');
|
||||
|
||||
$error = $this->validate($webid);
|
||||
if($error) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $error;
|
||||
return json_encode($this->data);
|
||||
}
|
||||
$webhost = $this->webhostModel->getWebhostById($webid, array('users', 'web_tarifs'));
|
||||
if($webhost['web_status'] == 0) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Веб-хостинг заблокирован!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
$errorPOST = $this->validatePOST();
|
||||
if(!$errorPOST) {
|
||||
$editpassword = @$this->request->post['editpassword'];
|
||||
$password = @$this->request->post['password'];
|
||||
if($editpassword) {
|
||||
$result = $this->webhostModel->updatepassUser($webid, $password);
|
||||
if($result["status"] == "success") {
|
||||
$this->webhostModel->updateWebhost($webid, array('web_password' => $password));
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Пароль доступа успешно изменен!";
|
||||
} else {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = $result["description"];
|
||||
}
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Ошибка!";
|
||||
}
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $errorPOST;
|
||||
}
|
||||
}
|
||||
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
public function action($webid = null, $action = null) {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if($this->user->getAccessLevel() < 2) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
$this->load->model('webhost');
|
||||
|
||||
$error = $this->validate($webid);
|
||||
if($error) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $error;
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$webhost = $this->webhostModel->getWebhostById($webid, array('users', 'web_tarifs'));
|
||||
|
||||
switch($action) {
|
||||
case 'block': {
|
||||
$result = $this->webhostModel->blockWebhost($webid);
|
||||
if($result["status"] == "success") {
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Вы успешно заблокировали веб-хостинг!";
|
||||
} else {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = $result["description"];
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'unblock': {
|
||||
$result = $this->webhostModel->unblockWebhost($webid);
|
||||
if($result["status"] == "success") {
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Вы успешно разблокировали веб-хостинг!";
|
||||
} else {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = $result["description"];
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'detele_web': {
|
||||
$result = $this->webhostModel->deleteWebhost($webid);
|
||||
if($result["status"] == "success") {
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Вы успешно удалили веб-хостинг!";
|
||||
} else {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = $result["description"];
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы выбрали несуществующее действие!";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
private function validate($webid) {
|
||||
$result = null;
|
||||
|
||||
if(!$this->webhostModel->getTotalWebhosts(array('web_id' => (int)$webid))) {
|
||||
$result = "Запрашиваемый веб-хостинг не существует!";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function validatePOST() {
|
||||
$this->load->library('validate');
|
||||
|
||||
$validateLib = new validateLibrary();
|
||||
|
||||
$result = null;
|
||||
|
||||
$editpassword = @$this->request->post['editpassword'];
|
||||
$password = @$this->request->post['password'];
|
||||
$password2 = @$this->request->post['password2'];
|
||||
|
||||
if($editpassword) {
|
||||
if(!$validateLib->password_web($password)) {
|
||||
$result = "Пароль должен содержать от 8 до 32 латинских букв, цифр и знаков <i>,.!?_-</i>!";
|
||||
}
|
||||
elseif($password != $password2) {
|
||||
$result = "Введенные вами пароли не совпадают!";
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class indexController extends Controller {
|
||||
private $limit = 22;
|
||||
public function index($page = 1) {
|
||||
$this->document->setActiveSection('admin/webhost');
|
||||
$this->document->setActiveItem('index');
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 2) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->library('pagination');
|
||||
$this->load->model('webhost');
|
||||
|
||||
$userid = $this->user->getId();
|
||||
$userid = @$this->request->get['userid'];
|
||||
$tarifid = @$this->request->get['tarifid'];
|
||||
$locationid = @$this->request->get['locationid'];
|
||||
|
||||
$getData = array();
|
||||
|
||||
if(!empty($userid)) {
|
||||
$getData['webhost.user_id'] = (int)$userid;
|
||||
}
|
||||
if(!empty($tarifid)) {
|
||||
$getData['webhost.tarif_id'] = (int)$tarifid;
|
||||
}
|
||||
if(!empty($locationid)) {
|
||||
$getData['webhost.location_id'] = (int)$locationid;
|
||||
}
|
||||
|
||||
$getOptions = array(
|
||||
'start' => ($page - 1) * $this->limit,
|
||||
'limit' => $this->limit
|
||||
);
|
||||
|
||||
$total = $this->webhostModel->getTotalWebhosts($getData);
|
||||
$webhosts = $this->webhostModel->getWebhosts($getData, array('web_tarifs', 'web_locations'), array(), $getOptions);
|
||||
|
||||
$paginationUrl = '/admin/webhost/index/index/{page}';
|
||||
if(!empty($userid)) {
|
||||
$paginationUrl .= '&userid=' . $userid;
|
||||
}
|
||||
if(!empty($tarifid)) {
|
||||
$paginationUrl .= '&tarifid=' . $tarifid;
|
||||
}
|
||||
if(!empty($locationid)) {
|
||||
$paginationUrl .= '&locationid=' . $locationid;
|
||||
}
|
||||
|
||||
$paginationLib = new paginationLibrary();
|
||||
$paginationLib->total = $total;
|
||||
$paginationLib->page = $page;
|
||||
$paginationLib->limit = $this->limit;
|
||||
$paginationLib->url = $paginationUrl;
|
||||
$pagination = $paginationLib->render();
|
||||
|
||||
$this->data['webhosts'] = $webhosts;
|
||||
$this->data['pagination'] = $pagination;
|
||||
|
||||
$this->getChild(array('common/admheader', 'common/footer'));
|
||||
return $this->load->view('admin/webhost/index', $this->data);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class createController extends Controller {
|
||||
public function index() {
|
||||
$this->document->setActiveSection('admin/weblocations');
|
||||
$this->document->setActiveItem('create');
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 3) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->getChild(array('common/admheader', 'common/footer'));
|
||||
return $this->load->view('admin/weblocations/create', $this->data);
|
||||
}
|
||||
|
||||
public function ajax() {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if($this->user->getAccessLevel() < 3) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$this->load->model('webLocations');
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
$errorPOST = $this->validatePOST();
|
||||
if(!$errorPOST) {
|
||||
$name = @$this->request->post['name'];
|
||||
$ip = @$this->request->post['ip'];
|
||||
$url = @$this->request->post['url'];
|
||||
$ns_servers = @$this->request->post['ns_servers'];
|
||||
$user = @$this->request->post['user'];
|
||||
$password = @$this->request->post['password'];
|
||||
$password2 = @$this->request->post['password2'];
|
||||
$status = @$this->request->post['status'];
|
||||
|
||||
$locationData = array(
|
||||
'location_name' => $name,
|
||||
'location_ip' => $ip,
|
||||
'location_url' => $url,
|
||||
'location_user' => $user,
|
||||
'location_password' => $password,
|
||||
'ns_servers' => $ns_servers,
|
||||
'location_status' => (int)$status
|
||||
);
|
||||
|
||||
$this->webLocationsModel->createLocation($locationData);
|
||||
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Вы успешно создали локацию!";
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $errorPOST;
|
||||
}
|
||||
}
|
||||
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
private function validatePOST() {
|
||||
$this->load->library('validate');
|
||||
|
||||
$validateLib = new validateLibrary();
|
||||
|
||||
$result = null;
|
||||
|
||||
$name = @$this->request->post['name'];
|
||||
$ip = @$this->request->post['ip'];
|
||||
$url = @$this->request->post['url'];
|
||||
$user = @$this->request->post['user'];
|
||||
$ns_servers = @$this->request->post['ns_servers'];
|
||||
$password = @$this->request->post['password'];
|
||||
$password2 = @$this->request->post['password2'];
|
||||
$status = @$this->request->post['status'];
|
||||
|
||||
if(mb_strlen($name) < 2 || mb_strlen($name) > 32) {
|
||||
$result = "Название локации должно содержать от 2 до 32 символов!";
|
||||
}
|
||||
elseif(mb_strlen($ns_servers) < 2 || mb_strlen($ns_servers) > 78) {
|
||||
$result = "NS Сервера локации должны содержать от 2 до 78 символов!";
|
||||
}
|
||||
elseif(!$validateLib->ip($ip)) {
|
||||
$result = "Укажите допустимый IP!";
|
||||
}
|
||||
elseif(mb_strlen($url) < 2 || mb_strlen($url) > 32) {
|
||||
$result = "Домен должен содержать от 2 до 32 символов!";
|
||||
}
|
||||
elseif(mb_strlen($user) < 2 || mb_strlen($user) > 32) {
|
||||
$result = "Имя пользователя должно содержать от 2 до 32 символов!";
|
||||
}
|
||||
elseif(!$validateLib->password($password)) {
|
||||
$result = "Пароль должен содержать от 6 до 32 латинских букв, цифр и знаков <i>,.!?_-</i>!";
|
||||
}
|
||||
elseif($password != $password2) {
|
||||
$result = "Введенные вами пароли не совпадают!";
|
||||
}
|
||||
elseif($status < 0 || $status > 1) {
|
||||
$result = "Укажите допустимый статус!";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,180 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class editController extends Controller {
|
||||
public function index($locationid = null) {
|
||||
$this->document->setActiveSection('admin/weblocations');
|
||||
$this->document->setActiveItem('edit');
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 3) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->model('webLocations');
|
||||
|
||||
$error = $this->validate($locationid);
|
||||
if($error) {
|
||||
$this->session->data['error'] = $error;
|
||||
$this->response->redirect($this->config->url . 'admin/weblocations/index');
|
||||
}
|
||||
|
||||
$location = $this->webLocationsModel->getLocationById($locationid);
|
||||
|
||||
$this->data['location'] = $location;
|
||||
|
||||
$this->getChild(array('common/admheader', 'common/footer'));
|
||||
return $this->load->view('admin/weblocations/edit', $this->data);
|
||||
}
|
||||
|
||||
public function ajax($locationid = null) {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if($this->user->getAccessLevel() < 3) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$this->load->model('webLocations');
|
||||
|
||||
$error = $this->validate($locationid);
|
||||
if($error) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $error;
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
$errorPOST = $this->validatePOST();
|
||||
if(!$errorPOST) {
|
||||
$name = @$this->request->post['name'];
|
||||
$ip = @$this->request->post['ip'];
|
||||
$url = @$this->request->post['url'];
|
||||
$user = @$this->request->post['user'];
|
||||
$ns_servers = @$this->request->post['ns_servers'];
|
||||
$password = @$this->request->post['password'];
|
||||
$password2 = @$this->request->post['password2'];
|
||||
$editpassword = @$this->request->post['editpassword'];
|
||||
$status = @$this->request->post['status'];
|
||||
$location_tarifs = @$this->request->post['location_tarifs'];
|
||||
|
||||
$locationData = array(
|
||||
'location_name' => $name,
|
||||
'location_ip' => $ip,
|
||||
'location_url' => $url,
|
||||
'ns_servers' => $ns_servers,
|
||||
'location_user' => $user,
|
||||
'location_status' => (int)$status,
|
||||
'location_tarifs' => $location_tarifs
|
||||
);
|
||||
|
||||
if($editpassword) {
|
||||
$locationData['location_password'] = $password;
|
||||
}
|
||||
|
||||
$this->webLocationsModel->updateLocation($locationid, $locationData);
|
||||
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Вы успешно отредактировали локацию!";
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $errorPOST;
|
||||
}
|
||||
}
|
||||
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
public function delete($locationid = null) {
|
||||
$this->document->setActiveSection('admin');
|
||||
$this->document->setActiveItem('weblocations');
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 3) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->model('webLocations');
|
||||
|
||||
$error = $this->validate($locationid);
|
||||
if($error) {
|
||||
$this->session->data['error'] = $error;
|
||||
$this->response->redirect($this->config->url . 'admin/weblocations/index');
|
||||
}
|
||||
|
||||
$this->webLocationsModel->deleteLocation($locationid);
|
||||
|
||||
$this->session->data['success'] = "Вы успешно удалили локацию!";
|
||||
$this->response->redirect($this->config->url . 'admin/weblocations/index');
|
||||
return null;
|
||||
}
|
||||
|
||||
private function validate($locationid) {
|
||||
$result = null;
|
||||
|
||||
if(!$this->webLocationsModel->getTotalLocations(array('location_id' => (int)$locationid))) {
|
||||
$result = "Запрашиваемая локация не существует!";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function validatePOST() {
|
||||
$this->load->library('validate');
|
||||
|
||||
$validateLib = new validateLibrary();
|
||||
|
||||
$result = null;
|
||||
|
||||
$name = @$this->request->post['name'];
|
||||
$ip = @$this->request->post['ip'];
|
||||
$url = @$this->request->post['url'];
|
||||
$user = @$this->request->post['user'];
|
||||
$ns_servers = @$this->request->post['ns_servers'];
|
||||
$password = @$this->request->post['password'];
|
||||
$password2 = @$this->request->post['password2'];
|
||||
$status = @$this->request->post['status'];
|
||||
|
||||
if(mb_strlen($name) < 2 || mb_strlen($name) > 32) {
|
||||
$result = "Название локации должно содержать от 2 до 32 символов!";
|
||||
}
|
||||
elseif(mb_strlen($ns_servers) < 2 || mb_strlen($ns_servers) > 78) {
|
||||
$result = "NS Сервера локации должны содержать от 2 до 78 символов!";
|
||||
}
|
||||
elseif(!$validateLib->ip($ip)) {
|
||||
$result = "Укажите допустимый IP!";
|
||||
}
|
||||
elseif(mb_strlen($url) < 2 || mb_strlen($url) > 32) {
|
||||
$result = "Домен должен содержать от 2 до 32 символов!";
|
||||
}
|
||||
elseif(mb_strlen($user) < 2 || mb_strlen($user) > 32) {
|
||||
$result = "Имя пользователя должно содержать от 2 до 32 символов!";
|
||||
}
|
||||
elseif($editpassword) {
|
||||
if(!$validateLib->password($password)) {
|
||||
$result = "Пароль должен содержать от 6 до 32 латинских букв, цифр и знаков <i>,.!?_-</i>!";
|
||||
}
|
||||
elseif($password != $password2) {
|
||||
$result = "Введенные вами пароли не совпадают!";
|
||||
}
|
||||
}
|
||||
elseif($status < 0 || $status > 1) {
|
||||
$result = "Укажите допустимый статус!";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class indexController extends Controller {
|
||||
private $limit = 20;
|
||||
public function index($page = 1) {
|
||||
$this->document->setActiveSection('admin/weblocations');
|
||||
$this->document->setActiveItem('index');
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 3) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->library('pagination');
|
||||
$this->load->model('webLocations');
|
||||
|
||||
$options = array(
|
||||
'start' => ($page - 1) * $this->limit,
|
||||
'limit' => $this->limit
|
||||
);
|
||||
|
||||
$total = $this->webLocationsModel->getTotalLocations();
|
||||
$locations = $this->webLocationsModel->getLocations(array(), array(), $options);
|
||||
|
||||
$paginationUrl = '/admin/weblocations/index/index/{page}';
|
||||
$paginationLib = new paginationLibrary();
|
||||
$paginationLib->total = $total;
|
||||
$paginationLib->page = $page;
|
||||
$paginationLib->limit = $this->limit;
|
||||
$paginationLib->url = $paginationUrl;
|
||||
$pagination = $paginationLib->render();
|
||||
|
||||
$this->data['locations'] = $locations;
|
||||
$this->data['pagination'] = $pagination;
|
||||
|
||||
$this->getChild(array('common/admheader', 'common/footer'));
|
||||
return $this->load->view('admin/weblocations/index', $this->data);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class createController extends Controller {
|
||||
public function index() {
|
||||
$this->document->setActiveSection('admin/webtarifs');
|
||||
$this->document->setActiveItem('create');
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 3) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->getChild(array('common/admheader', 'common/footer'));
|
||||
return $this->load->view('admin/webtarifs/create', $this->data);
|
||||
}
|
||||
|
||||
public function ajax() {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if($this->user->getAccessLevel() < 3) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$this->load->model('webhostTarifs');
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
$errorPOST = $this->validatePOST();
|
||||
if(!$errorPOST) {
|
||||
$name = @$this->request->post['name'];
|
||||
$package = @$this->request->post['package'];
|
||||
$price = @$this->request->post['price'];
|
||||
$status = @$this->request->post['status'];
|
||||
|
||||
$tarifData = array(
|
||||
'tarif_name' => $name,
|
||||
'package' => $package,
|
||||
'tarif_price' => (float)$price,
|
||||
'tarif_status' => (int)$status
|
||||
);
|
||||
|
||||
$this->webhostTarifsModel->createTarif($tarifData);
|
||||
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Вы успешно создали тариф!";
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $errorPOST;
|
||||
}
|
||||
}
|
||||
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
private function validatePOST() {
|
||||
$this->load->library('validate');
|
||||
|
||||
$validateLib = new validateLibrary();
|
||||
|
||||
$result = null;
|
||||
|
||||
$name = @$this->request->post['name'];
|
||||
$package = @$this->request->post['package'];
|
||||
$price = @$this->request->post['price'];
|
||||
$status = @$this->request->post['status'];
|
||||
|
||||
if(mb_strlen($name) < 2 || mb_strlen($name) > 32) {
|
||||
$result = "Название тарифа должно содержать от 2 до 32 символов!";
|
||||
}
|
||||
elseif(mb_strlen($package) < 1 || mb_strlen($package) > 32) {
|
||||
$result = "Название пакета должно содержать от 2 до 32 символов!";
|
||||
}
|
||||
elseif(!$validateLib->money($price)) {
|
||||
$result = "Укажите допустимую стоимость!";
|
||||
}
|
||||
elseif($status < 0 || $status > 1) {
|
||||
$result = "Укажите допустимый статус!";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,149 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class editController extends Controller {
|
||||
public function index($tarifid = null) {
|
||||
$this->document->setActiveSection('admin/webtarifs');
|
||||
$this->document->setActiveItem('edit');
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 3) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->model('webhostTarifs');
|
||||
|
||||
$error = $this->validate($tarifid);
|
||||
if($error) {
|
||||
$this->session->data['error'] = $error;
|
||||
$this->response->redirect($this->config->url . 'admin/webtarifs/index');
|
||||
}
|
||||
|
||||
$tarif = $this->webhostTarifsModel->getTarifById($tarifid);
|
||||
|
||||
$this->data['tarif'] = $tarif;
|
||||
|
||||
$this->getChild(array('common/admheader', 'common/footer'));
|
||||
return $this->load->view('admin/webtarifs/edit', $this->data);
|
||||
}
|
||||
|
||||
public function ajax($tarifid = null) {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if($this->user->getAccessLevel() < 3) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$this->load->model('webhostTarifs');
|
||||
|
||||
$error = $this->validate($tarifid);
|
||||
if($error) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $error;
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
$errorPOST = $this->validatePOST();
|
||||
if(!$errorPOST) {
|
||||
$name = @$this->request->post['name'];
|
||||
$package = @$this->request->post['package'];
|
||||
$price = @$this->request->post['price'];
|
||||
$status = @$this->request->post['status'];
|
||||
|
||||
$tarifData = array(
|
||||
'tarif_name' => $name,
|
||||
'package' => $package,
|
||||
'tarif_price' => (float)$price,
|
||||
'tarif_status' => (int)$status
|
||||
);
|
||||
|
||||
$this->webhostTarifsModel->updateTarif($tarifid, $tarifData);
|
||||
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Вы успешно отредактировали тариф!";
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $errorPOST;
|
||||
}
|
||||
}
|
||||
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
public function delete($tarifid = null) {
|
||||
$this->document->setActiveSection('admin');
|
||||
$this->document->setActiveItem('tarifid');
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 3) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->model('webhostTarifs');
|
||||
|
||||
$error = $this->validate($tarifid);
|
||||
if($error) {
|
||||
$this->session->data['error'] = $error;
|
||||
$this->response->redirect($this->config->url . 'admin/tarifid/index');
|
||||
}
|
||||
|
||||
$this->webhostTarifsModel->deleteTarif($tarifid);
|
||||
|
||||
$this->session->data['success'] = "Вы успешно удалили тариф!";
|
||||
$this->response->redirect($this->config->url . 'admin/tarifid/index');
|
||||
return null;
|
||||
}
|
||||
|
||||
private function validate($tarifid) {
|
||||
$result = null;
|
||||
|
||||
if(!$this->webhostTarifsModel->getTotalTarifs(array('tarif_id' => (int)$tarifid))) {
|
||||
$result = "Запрашиваеммый тариф не существует!";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function validatePOST() {
|
||||
$this->load->library('validate');
|
||||
|
||||
$validateLib = new validateLibrary();
|
||||
|
||||
$result = null;
|
||||
|
||||
$name = @$this->request->post['name'];
|
||||
$package = @$this->request->post['package'];
|
||||
$price = @$this->request->post['price'];
|
||||
$status = @$this->request->post['status'];
|
||||
|
||||
if(mb_strlen($name) < 2 || mb_strlen($name) > 32) {
|
||||
$result = "Название тарифа должно содержать от 2 до 32 символов!";
|
||||
}
|
||||
elseif(mb_strlen($package) < 1 || mb_strlen($package) > 32) {
|
||||
$result = "Название пакета должно содержать от 2 до 32 символов!";
|
||||
}
|
||||
elseif(!$validateLib->money($price)) {
|
||||
$result = "Укажите допустимую стоимость!";
|
||||
}
|
||||
elseif($status < 0 || $status > 1) {
|
||||
$result = "Укажите допустимый статус!";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class indexController extends Controller {
|
||||
private $limit = 20;
|
||||
public function index($page = 1) {
|
||||
$this->document->setActiveSection('admin/webtarifs');
|
||||
$this->document->setActiveItem('index');
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 3) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->library('pagination');
|
||||
$this->load->model('webhostTarifs');
|
||||
|
||||
$options = array(
|
||||
'start' => ($page - 1) * $this->limit,
|
||||
'limit' => $this->limit
|
||||
);
|
||||
|
||||
$total = $this->webhostTarifsModel->getTotalTarifs();
|
||||
$tarifs = $this->webhostTarifsModel->getTarifs(array(), array(), $options);
|
||||
|
||||
$paginationUrl = '/admin/webtarifs/index/index/{page}';
|
||||
$paginationLib = new paginationLibrary();
|
||||
$paginationLib->total = $total;
|
||||
$paginationLib->page = $page;
|
||||
$paginationLib->limit = $this->limit;
|
||||
$paginationLib->url = $paginationUrl;
|
||||
$pagination = $paginationLib->render();
|
||||
|
||||
$this->data['tarifs'] = $tarifs;
|
||||
$this->data['pagination'] = $pagination;
|
||||
|
||||
$this->getChild(array('common/admheader', 'common/footer'));
|
||||
return $this->load->view('admin/webtarifs/index', $this->data);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class admheaderController extends Controller {
|
||||
public function index() {
|
||||
$this->data['activesection'] = $this->document->getActiveSection();
|
||||
$this->data['activeitem'] = $this->document->getActiveItem();
|
||||
$this->data['title'] = $this->config->title;
|
||||
$this->data['description'] = $this->config->description;
|
||||
$this->data['keywords'] = $this->config->keywords;
|
||||
$this->data['logo'] = $this->config->logo;
|
||||
$this->data['url'] = $this->config->url;
|
||||
$this->data['webhost'] = $this->config->webhost;
|
||||
$this->data['public'] = $this->config->public;
|
||||
$this->data['oplata_status'] = $this->config->oplata_status;
|
||||
$this->data['oplatahostinpl'] = $this->config->oplatahostinpl;
|
||||
$this->data['status_hostinpl'] = $this->config->status_hostinpl;
|
||||
|
||||
if($this->user->isLogged()) {
|
||||
$this->data['logged'] = true;
|
||||
$this->data['user_email'] = $this->user->getEmail();
|
||||
$this->data['user_firstname'] = $this->user->getFirstname();
|
||||
$this->data['user_lastname'] = $this->user->getLastname();
|
||||
$this->data['user_balance'] = $this->user->getBalance();
|
||||
$this->data['user_access_level'] = $this->user->getAccessLevel();
|
||||
$this->data['user_img'] = $this->user->getUser_img();
|
||||
} else {
|
||||
$this->data['logged'] = false;
|
||||
$this->data['user_access_level'] = 0;
|
||||
}
|
||||
|
||||
$logged = $this->data['logged'];
|
||||
$this->data['logged'] = $logged;
|
||||
if(isset($this->session->data['error'])) {
|
||||
$this->data['error'] = $this->session->data['error'];
|
||||
unset($this->session->data['error']);
|
||||
}
|
||||
|
||||
if(isset($this->session->data['warning'])) {
|
||||
$this->data['warning'] = $this->session->data['warning'];
|
||||
unset($this->session->data['warning']);
|
||||
}
|
||||
|
||||
if(isset($this->session->data['success'])) {
|
||||
$this->data['success'] = $this->session->data['success'];
|
||||
unset($this->session->data['success']);
|
||||
}
|
||||
|
||||
|
||||
$this->load->model('tickets');
|
||||
$this->load->model('ticketsMessages');
|
||||
$this->load->model('users');
|
||||
$userid = $this->user->getId();
|
||||
|
||||
$sort = array(
|
||||
'ticket_status' => 'DESC',
|
||||
'ticket_date_add' => 'DESC'
|
||||
);
|
||||
|
||||
$tickets = $this->ticketsModel->getTickets(array('user_id' => (int)$userid), array(), $sort, array());
|
||||
|
||||
$this->data['tickets'] = $tickets;
|
||||
$visitors = $this->usersModel->getAuthLog($userid);
|
||||
$this->data['visitors'] = $visitors;
|
||||
|
||||
$offline = $this->config->offline;
|
||||
|
||||
if($offline == 1){
|
||||
if($this->user->getAccessLevel() == 1) {
|
||||
$result = $this->config->offline_res;
|
||||
header ("Location: /offline?result=".$result."");
|
||||
return;
|
||||
}
|
||||
if($this->user->getAccessLevel() == 2) {
|
||||
$result = $this->config->offline_res;
|
||||
header ("Location: /offline?result=".$result."");
|
||||
return;
|
||||
}
|
||||
if($this->user->getAccessLevel() == 3) {
|
||||
return $this->load->view('common/admheader', $this->data);
|
||||
}
|
||||
} else{
|
||||
return $this->load->view('common/admheader', $this->data);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class footerController extends Controller {
|
||||
public function index() {
|
||||
$this->data['title'] = $this->config->title;
|
||||
$this->data['description'] = $this->config->description;
|
||||
$this->data['public'] = $this->config->public;
|
||||
|
||||
return $this->load->view('common/footer', $this->data);
|
||||
}
|
||||
|
||||
public function getstatus($action) {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if($this->user->getAccessLevel() < 1) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$userid = $this->user->getId();
|
||||
|
||||
$this->load->model('users');
|
||||
|
||||
switch($action) {
|
||||
case 'online': {
|
||||
$LastTime = time() - 105;
|
||||
|
||||
$online = 0;
|
||||
foreach($this->usersModel->getUsers() as $line) {
|
||||
if ($line['user_online_date'] > $LastTime) {
|
||||
$online++;
|
||||
}
|
||||
}
|
||||
|
||||
$this->usersModel->updateUser($userid, array('user_online_date'=> time()));
|
||||
$this->data['status'] = "online";
|
||||
$this->data['online'] = "USERID ".$userid." ".$this->user->getFirstname()." UPD-DATE ".date("Y-m-d H:i:s")." | ".$LastTime." LVL ".$this->user->getAccessLevel()." ST.OK";
|
||||
$this->data['online_usr'] = $online;
|
||||
break;
|
||||
}
|
||||
case 'online_sup': {
|
||||
$LastTime = time() - 105;
|
||||
|
||||
$online_sup = 0;
|
||||
foreach($this->usersModel->getUsers() as $line) {
|
||||
if($line['user_access_level'] > 1) {
|
||||
if ($line['user_online_date'] > $LastTime) {
|
||||
$online_sup++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($online_sup > 0) {
|
||||
$this->data['sup_status'] = "Online";
|
||||
} else {
|
||||
$this->data['sup_status'] = "Offline";
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы выбрали несуществующее действие!";
|
||||
break;
|
||||
}
|
||||
}
|
||||
return json_encode($this->data);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class headerController extends Controller {
|
||||
public function index() {
|
||||
$this->data['title'] = $this->config->title;
|
||||
$this->data['description'] = $this->config->description;
|
||||
$this->data['keywords'] = $this->config->keywords;
|
||||
$this->data['activesection'] = $this->document->getActiveSection();
|
||||
$this->data['activeitem'] = $this->document->getActiveItem();
|
||||
$this->data['logo'] = $this->config->logo;
|
||||
$this->data['url'] = $this->config->url;
|
||||
$this->data['public'] = $this->config->public;
|
||||
$this->data['webhost'] = $this->config->webhost;
|
||||
$this->data['oplata_status'] = $this->config->oplata_status;
|
||||
$this->data['oplatahostinpl'] = $this->config->oplatahostinpl;
|
||||
$this->data['status_hostinpl'] = $this->config->status_hostinpl;
|
||||
|
||||
if($this->user->isLogged()) {
|
||||
$this->data['logged'] = true;
|
||||
$this->data['user_email'] = $this->user->getEmail();
|
||||
$this->data['user_firstname'] = $this->user->getFirstname();
|
||||
$this->data['user_lastname'] = $this->user->getLastname();
|
||||
$this->data['user_balance'] = $this->user->getBalance();
|
||||
$this->data['user_access_level'] = $this->user->getAccessLevel();
|
||||
$this->data['user_img'] = $this->user->getUser_img();
|
||||
} else {
|
||||
$this->data['logged'] = false;
|
||||
$this->data['user_access_level'] = 0;
|
||||
}
|
||||
|
||||
$logged = $this->data['logged'];
|
||||
$this->data['logged'] = $logged;
|
||||
if(isset($this->session->data['error'])) {
|
||||
$this->data['error'] = $this->session->data['error'];
|
||||
unset($this->session->data['error']);
|
||||
}
|
||||
|
||||
if(isset($this->session->data['warning'])) {
|
||||
$this->data['warning'] = $this->session->data['warning'];
|
||||
unset($this->session->data['warning']);
|
||||
}
|
||||
|
||||
if(isset($this->session->data['success'])) {
|
||||
$this->data['success'] = $this->session->data['success'];
|
||||
unset($this->session->data['success']);
|
||||
}
|
||||
|
||||
|
||||
$this->load->model('tickets');
|
||||
$this->load->model('ticketsMessages');
|
||||
$this->load->model('users');
|
||||
$userid = $this->user->getId();
|
||||
|
||||
$sort = array(
|
||||
'ticket_status' => 'DESC',
|
||||
'ticket_date_add' => 'DESC'
|
||||
);
|
||||
|
||||
$tickets = $this->ticketsModel->getTickets(array('user_id' => (int)$userid), array(), $sort, array());
|
||||
|
||||
$this->data['tickets'] = $tickets;
|
||||
$visitors = $this->usersModel->getAuthLog($userid);
|
||||
$this->data['visitors'] = $visitors;
|
||||
|
||||
$offline = $this->config->offline;
|
||||
|
||||
if($offline == 1){
|
||||
if($this->user->getAccessLevel() == 1) {
|
||||
$result = $this->config->offline_res;
|
||||
header ("Location: /offline?result=".$result."");
|
||||
return;
|
||||
}
|
||||
if($this->user->getAccessLevel() == 2) {
|
||||
$result = $this->config->offline_res;
|
||||
header ("Location: /offline?result=".$result."");
|
||||
return;
|
||||
}
|
||||
if($this->user->getAccessLevel() == 3) {
|
||||
return $this->load->view('common/header', $this->data);
|
||||
}
|
||||
} else{
|
||||
return $this->load->view('common/header', $this->data);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class loginfooterController extends Controller {
|
||||
public function index() {
|
||||
return $this->load->view('common/loginfooter', $this->data);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,300 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class loginheaderController extends Controller {
|
||||
public function index() {
|
||||
$this->data['title'] = $this->config->title;
|
||||
$this->data['description'] = $this->config->description;
|
||||
$this->data['keywords'] = $this->config->keywords;
|
||||
$this->data['logo'] = $this->config->logo;
|
||||
$this->data['public'] = $this->config->public;
|
||||
$this->data['count'] = $this->config->count;
|
||||
$this->data['vk_id'] = $this->config->vk_id;
|
||||
$this->data['vk_stat'] = $this->config->vk_stat;
|
||||
$this->data['recaptcha'] = $this->config->recaptcha;
|
||||
$this->data['captcha_enable'] = $this->config->captcha_enable;
|
||||
|
||||
if(isset($this->session->data['error'])) {
|
||||
$this->data['error'] = $this->session->data['error'];
|
||||
unset($this->session->data['error']);
|
||||
}
|
||||
|
||||
if(isset($this->session->data['warning'])) {
|
||||
$this->data['warning'] = $this->session->data['warning'];
|
||||
unset($this->session->data['warning']);
|
||||
}
|
||||
|
||||
if(isset($this->session->data['success'])) {
|
||||
$this->data['success'] = $this->session->data['success'];
|
||||
unset($this->session->data['success']);
|
||||
}
|
||||
$this->load->model('users');
|
||||
$userid = $this->user->getId();
|
||||
|
||||
$user = $this->usersModel->getUserById(isset($_GET['ref']) ? (int)$_GET['ref'] : 0, array(), array(), array());
|
||||
$this->data['user'] = $user;
|
||||
|
||||
return $this->load->view('common/loginheader', $this->data);
|
||||
}
|
||||
|
||||
public function ajax() {
|
||||
if($this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы уже авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
$this->load->library('mail');
|
||||
$this->load->model('users');
|
||||
$this->load->model('waste');
|
||||
|
||||
$errorPOST = $this->validatePOST();
|
||||
if(!$errorPOST) {
|
||||
$lastname = @$this->request->get['lastname'];
|
||||
$firstname = @$this->request->get['firstname'];
|
||||
$email = @$this->request->get['email'];
|
||||
$password = @$this->request->get['password'];
|
||||
$ref = @$this->request->get['ref'];
|
||||
|
||||
if (@$firstname) {
|
||||
$firstname = @strtoupper($firstname[0]) . substr($firstname, 1);
|
||||
}
|
||||
|
||||
if (@$lastname) {
|
||||
$lastname = @strtoupper($lastname[0]) . substr($lastname, 1);
|
||||
}
|
||||
|
||||
if ($this->config->register) {
|
||||
$random = md5(uniqid(rand(), true));
|
||||
$user_activate = 0;
|
||||
}
|
||||
else {
|
||||
$random = 0;
|
||||
$user_activate = 1;
|
||||
}
|
||||
|
||||
$random = md5(uniqid(rand(),true));
|
||||
|
||||
$userData = array(
|
||||
'user_email' => $email,
|
||||
'user_password' => md5($password),
|
||||
'user_firstname' => $firstname,
|
||||
'user_lastname' => $lastname,
|
||||
'user_status' => 1,
|
||||
'user_balance' => 0,
|
||||
'user_access_level' => 1,
|
||||
'rmoney' => 0,
|
||||
'user_activate' => $this->config->register,
|
||||
'key_activate' => $random
|
||||
);
|
||||
$userid = $this->usersModel->createUser($userData);
|
||||
if($userid != $ref) {
|
||||
if($ref != 0) {
|
||||
$this->usersModel->upUserBalance($ref, 0.25);
|
||||
$this->usersModel->upUserRMoney($ref, 0.25);
|
||||
$userData = array(
|
||||
'ref' => $ref
|
||||
);
|
||||
$this->usersModel->updateUser($userid, $userData);
|
||||
|
||||
$wasteData = array(
|
||||
'user_id' => $ref,
|
||||
'waste_ammount' => 0.25,
|
||||
'waste_status' => 0,
|
||||
'waste_usluga' => "Бонус за приглашенного реферала ID-$userid"
|
||||
);
|
||||
$this->wasteModel->createWaste($wasteData);
|
||||
}
|
||||
}
|
||||
$mailLib = new mailLibrary();
|
||||
|
||||
$mailLib->setFrom($this->config->mail_from);
|
||||
$mailLib->setSender($this->config->mail_sender);
|
||||
$mailLib->setTo($email);
|
||||
$mailLib->setSubject('Регистрация аккаунта');
|
||||
|
||||
$mailData = array();
|
||||
|
||||
$mailData['firstname'] = $firstname;
|
||||
$mailData['lastname'] = $lastname;
|
||||
$mailData['email'] = $email;
|
||||
$mailData['password'] = $password;
|
||||
$mailData['key'] = $random;
|
||||
$mailData['url'] = $this->config->url;
|
||||
$mailData['title'] = $this->config->title;
|
||||
|
||||
if ($this->config->register) {
|
||||
$text = $this->load->view('mail/account/register', $mailData);
|
||||
}
|
||||
else {
|
||||
$text = $this->load->view('mail/account/register_activate', $mailData);
|
||||
}
|
||||
|
||||
$mailLib->setText($text);
|
||||
$mailLib->send();
|
||||
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Вы успешно зарегистрировались!";
|
||||
$this->data['user_activate'] = $user_activate;
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $errorPOST;
|
||||
}
|
||||
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
private function validatePOST() {
|
||||
$this->load->library('validate');
|
||||
|
||||
$validateLib = new validateLibrary();
|
||||
|
||||
$result = null;
|
||||
|
||||
$lastname = @$this->request->get['lastname'];
|
||||
$firstname = @$this->request->get['firstname'];
|
||||
$email = @$this->request->get['email'];
|
||||
$password = @$this->request->get['password'];
|
||||
$password2 = @$this->request->get['password2'];
|
||||
$recaptcha = @$this->request->get['g-recaptcha-response'];
|
||||
|
||||
if (@$firstname) {
|
||||
$firstname = @strtoupper($firstname[0]) . substr($firstname, 1);
|
||||
}
|
||||
|
||||
if (@$lastname) {
|
||||
$lastname = @strtoupper($lastname[0]) . substr($lastname, 1);
|
||||
}
|
||||
|
||||
if(!$validateLib->check_for_number($lastname)) {
|
||||
$result = "Укажите свою реальную фамилию!";
|
||||
}
|
||||
elseif(!$validateLib->check_for_number($firstname)) {
|
||||
$result = "Укажите свое реальное имя!";
|
||||
}
|
||||
elseif(!$validateLib->email($email)) {
|
||||
$result = "Укажите свой реальный E-Mail!";
|
||||
}
|
||||
elseif(!$validateLib->password($password)) {
|
||||
$result = "Пароль должен содержать от 6 до 32 латинских букв, цифр и знаков <i>,.!?_-</i>!";
|
||||
}
|
||||
elseif($password != $password2) {
|
||||
$result = "Введенные вами пароли не совпадают!";
|
||||
}
|
||||
elseif($captcha != $captchahash) {
|
||||
$result = "Укажите правильный код с картинки! Попробуйте нажать на картинку, чтобы обновить ее.";
|
||||
}
|
||||
elseif($this->usersModel->getTotalUsers(array('user_email' => $email))) {
|
||||
$result = "Указанный E-Mail уже зарегистрирован!";
|
||||
}
|
||||
|
||||
if($this->config->captcha_enable != '1') return $result;
|
||||
if(!$recaptcha) return 'Подтвердите, что вы не робот!';
|
||||
$url = 'https://www.google.com/recaptcha/api/siteverify';
|
||||
$data = array('secret' => $this->config->secret_recaptcha, 'response' => $recaptcha);
|
||||
$options = array(
|
||||
'http' => array(
|
||||
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
|
||||
'method' => 'POST',
|
||||
'remoteip' => 'remoteip',
|
||||
'content' => http_build_query($data),
|
||||
)
|
||||
);
|
||||
|
||||
$context = stream_context_create($options);
|
||||
$recaptcha_get = json_decode(file_get_contents($url, false, $context))->{'success'};
|
||||
if($recaptcha_get != '1') return 'Проверьте правильность капчи!';
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function ajax_infobox() {
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
$errorPOST = $this->validatePOSTInfo();
|
||||
if(!$errorPOST) {
|
||||
if(@$this->request->post['msg'] == ""){
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Введите команду!";
|
||||
}elseif(@$this->request->post['msg'] != ""){
|
||||
$this->load->model('mail');
|
||||
$firstname = @$this->request->post['firstname'];
|
||||
$lastname = @$this->request->post['lastname'];
|
||||
$email = @$this->request->post['email'];
|
||||
$subject = @$this->request->post['subject'];
|
||||
$msg = @$this->request->post['msg'];
|
||||
$msgData = array(
|
||||
'user_email' => $email,
|
||||
'user_firstname' => $firstname,
|
||||
'user_lastname' => $lastname,
|
||||
'category' => $subject,
|
||||
'text' => $msg,
|
||||
'status' => 1
|
||||
);
|
||||
|
||||
$msg_id = $this->mailModel->createInbox($msgData);
|
||||
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Ваше письмо отправлено! Номер IN".$msg_id."";
|
||||
}
|
||||
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $errorPOST;
|
||||
}
|
||||
}
|
||||
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
private function validatePOSTInfo() {
|
||||
$this->load->library('validate');
|
||||
|
||||
$validateLib = new validateLibrary();
|
||||
|
||||
$result = null;
|
||||
|
||||
$firstname = @$this->request->post['firstname'];
|
||||
$lastname = @$this->request->post['lastname'];
|
||||
$email = @strtolower($this->request->post['email']);
|
||||
$subject = @$this->request->post['subject'];
|
||||
$msg = @$this->request->post['msg'];
|
||||
$recaptcha = @$this->request->post['g-recaptcha-response'];
|
||||
|
||||
if (@$firstname) {
|
||||
$firstname = @strtoupper($firstname[0]) . substr($firstname, 1);
|
||||
}
|
||||
|
||||
if (@$lastname) {
|
||||
$lastname = @strtoupper($lastname[0]) . substr($lastname, 1);
|
||||
}
|
||||
|
||||
if(!$validateLib->check_for_number($lastname)) {
|
||||
$result = "Укажите свою реальную фамилию!";
|
||||
}
|
||||
elseif(!$validateLib->check_for_number($firstname)) {
|
||||
$result = "Укажите свое реальное имя!";
|
||||
}
|
||||
elseif(!$validateLib->email($email)) {
|
||||
$result = "Укажите свой реальный E-Mail!";
|
||||
}
|
||||
|
||||
if($this->config->captcha_enable != '1') return $result;
|
||||
if(!$recaptcha) return 'Подтвердите, что вы не робот!';
|
||||
$url = 'https://www.google.com/recaptcha/api/siteverify';
|
||||
$data = array('secret' => $this->config->secret_recaptcha, 'response' => $recaptcha);
|
||||
$options = array(
|
||||
'http' => array(
|
||||
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
|
||||
'method' => 'POST',
|
||||
'remoteip' => 'remoteip',
|
||||
'content' => http_build_query($data),
|
||||
)
|
||||
);
|
||||
|
||||
$context = stream_context_create($options);
|
||||
$recaptcha_get = json_decode(file_get_contents($url, false, $context))->{'success'};
|
||||
if($recaptcha_get != '1') return 'Проверьте правильность капчи!';
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
$this->data['title'] = $this->config->title;
|
||||
$this->data['description'] = $this->config->description;
|
||||
$this->data['keywords'] = $this->config->keywords;
|
||||
$this->data['logo'] = $this->config->logo;
|
||||
$this->data['url'] = $this->config->url;
|
||||
$this->data['public'] = $this->config->public;
|
||||
$this->data['oplata_status'] = $this->config->oplata_status;
|
||||
$this->data['oplatahostinpl'] = $this->config->oplatahostinpl;
|
||||
$this->data['status_hostinpl'] = $this->config->status_hostinpl;
|
||||
|
||||
if($this->user->isLogged()) {
|
||||
$this->data['logged'] = true;
|
||||
$this->data['user_email'] = $this->user->getEmail();
|
||||
$this->data['user_firstname'] = $this->user->getFirstname();
|
||||
$this->data['user_lastname'] = $this->user->getLastname();
|
||||
$this->data['user_balance'] = $this->user->getBalance();
|
||||
$this->data['user_access_level'] = $this->user->getAccessLevel();
|
||||
$this->data['user_img'] = $this->user->getUser_img();
|
||||
} else {
|
||||
$this->data['logged'] = false;
|
||||
$this->data['user_access_level'] = 0;
|
||||
}
|
||||
|
||||
$logged = $this->data['logged'];
|
||||
$this->data['logged'] = $logged;
|
||||
if(isset($this->session->data['error'])) {
|
||||
$this->data['error'] = $this->session->data['error'];
|
||||
unset($this->session->data['error']);
|
||||
}
|
||||
|
||||
if(isset($this->session->data['warning'])) {
|
||||
$this->data['warning'] = $this->session->data['warning'];
|
||||
unset($this->session->data['warning']);
|
||||
}
|
||||
|
||||
if(isset($this->session->data['success'])) {
|
||||
$this->data['success'] = $this->session->data['success'];
|
||||
unset($this->session->data['success']);
|
||||
}
|
||||
|
||||
|
||||
$this->load->model('tickets');
|
||||
$this->load->model('ticketsMessages');
|
||||
$this->load->model('users');
|
||||
$userid = $this->user->getId();
|
||||
|
||||
$sort = array(
|
||||
'ticket_status' => 'DESC',
|
||||
'ticket_date_add' => 'DESC'
|
||||
);
|
||||
|
||||
$tickets = $this->ticketsModel->getTickets(array('user_id' => (int)$userid), array(), $sort, array());
|
||||
|
||||
$this->data['tickets'] = $tickets;
|
||||
$visitors = $this->usersModel->getAuthLog($userid);
|
||||
$this->data['visitors'] = $visitors;
|
||||
|
||||
$offline = $this->config->offline;
|
||||
?>
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko (https://vk.com/id00v)
|
||||
*/
|
||||
class indexController extends Controller {
|
||||
private $limit = 20;
|
||||
public function index() {
|
||||
$this->document->setActiveSection('contacts');
|
||||
$this->document->setActiveItem('index');
|
||||
$this->data['url'] = $this->config->url;
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 0) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
|
||||
$this->load->model('users');
|
||||
$users = $this->usersModel->getUsers(array(), array(), array());
|
||||
$this->data['users'] = $users;
|
||||
|
||||
$this->getChild(array('common/header', 'common/footer'));
|
||||
return $this->load->view('contacts/index', $this->data);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,428 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class accController extends Controller {
|
||||
public function index() {
|
||||
$this->data['vk_id'] = $this->config->vk_id;
|
||||
$this->data['url'] = $this->config->url;
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 0) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->data['logged'] = true;
|
||||
$this->data['user_email'] = $this->user->getEmail();
|
||||
$this->data['user_id'] = $this->user->getId();
|
||||
$this->data['user_firstname'] = $this->user->getFirstname();
|
||||
$this->data['user_lastname'] = $this->user->getLastname();
|
||||
$this->data['user_balance'] = $this->user->getBalance();
|
||||
$this->data['user_img'] = $this->user->getUser_img();
|
||||
$this->data['user_balance'] = $this->user->getBalance();
|
||||
|
||||
$this->load->model('waste');
|
||||
$this->load->model('tickets');
|
||||
$this->load->model('users');
|
||||
$this->load->model('servers');
|
||||
|
||||
$userid = $this->user->getId();
|
||||
|
||||
$waste = $this->wasteModel->getWaste(array('user_id' => (int)$userid), array(), array('waste_date_add' => 'DESC'), array('start' => 0,'limit' => 10));
|
||||
$this->data['waste'] = $waste;
|
||||
|
||||
$this->data['user'] = array('firstname' => $this->user->getFirstname(), 'lastname' => $this->user->getLastname(), 'user_email' => $this->user->getEmail());
|
||||
$users = $this->usersModel->getUserById($userid, array(), array(), array());
|
||||
$this->data['users'] = $users;
|
||||
|
||||
$userg = $this->usersModel->getUsers(array('servers'), array(), array());
|
||||
$this->data['userg'] = $userg;
|
||||
|
||||
$visitors = $this->usersModel->getAuthLog($userid);
|
||||
$this->data['visitors'] = $visitors;
|
||||
|
||||
$auths = $this->usersModel->getAuths(array('user_id' => $userid), array(), array('auth_id' => 'DESC'));
|
||||
$this->data['auths'] = $auths;
|
||||
|
||||
$servers = $this->serversModel->getServers(array('user_id' => (int)$userid), array('games', 'locations'), array(), array());
|
||||
$this->data['servers'] = $servers;
|
||||
|
||||
$tickets = $this->ticketsModel->getTickets(array('user_id' => (int)$userid), array(), array(), array());
|
||||
$this->data['tickets'] = $tickets;
|
||||
|
||||
$row['date'] = strtotime($users['user_date_reg']);
|
||||
$now = time();
|
||||
$seconds = $now - $row['date'];
|
||||
$days = floor($seconds / (24*60*60));
|
||||
$this->data['user_date_reg'] = $days;
|
||||
$res = $this->pluralForm($days, 'день', 'дней', 'дня');
|
||||
$this->data['user_date'] = $res;
|
||||
|
||||
$this->getChild(array('common/header', 'common/footer'));
|
||||
return $this->load->view('main/acc', $this->data);
|
||||
}
|
||||
|
||||
public function action($action = null) {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if($this->user->getAccessLevel() < 1) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$userid = $this->user->getId();
|
||||
|
||||
$this->load->model('users');
|
||||
$this->load->model('waste');
|
||||
|
||||
switch($action) {
|
||||
case 'setVk': {
|
||||
if($this->request->post['auth']){
|
||||
$Uid = $this->request->post['response']['session']['user']['id'];
|
||||
|
||||
if($this->usersModel->getTotalUsers(array('user_vk_id' => $Uid))) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Данный профиль уже привязан к другому аккаунту!";
|
||||
} else {
|
||||
if (!$this->user->getUser_vk_id()) {
|
||||
$this->usersModel->updateUser($userid, array('user_vk_id' => $Uid));
|
||||
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Профиль привязан!";
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Данный аккаунт уже привязан!";
|
||||
}
|
||||
}
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
if($this->request->post['auth_vk']) {
|
||||
if($user = @file_get_contents("https://api.vk.com/method/users.get?uids={$this->session->data['auth_vk']}&fields=uid,first_name,last_name,screen_name,sex,bdate,photo_big"))
|
||||
$this->data['user'] = json_decode($user, true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'unsetVk': {
|
||||
if ($this->user->getUser_vk_id()) {
|
||||
$this->usersModel->updateUser($userid, array('user_vk_id' => 0));
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Вы успешно отвязали VK!";
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "На данный момент у Вас не привязан VK!";
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'closeSession': {
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
$auth_id = $this->request->post['auth_id'];
|
||||
$auths = $this->usersModel->getAuths(array('auth_id' => $auth_id, 'user_id' => $userid));
|
||||
if(empty($auths)) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Сеанс не найден!";
|
||||
} else {
|
||||
$auth = $auths[0];
|
||||
|
||||
if($auth['auth_key'] != @$_COOKIE['uid']) {
|
||||
$this->usersModel->deleteAuth($auth['auth_id']);
|
||||
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Сеанс успешно завершён!";
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не можете завершить текущий сеанс!";
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы выбрали несуществующее действие!";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
public function ajax() {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if($this->user->getAccessLevel() < 1) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$this->load->model('users');
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
$errorPOST = $this->validatePOST();
|
||||
if(!$errorPOST) {
|
||||
$lastname = @$this->request->post['lastname'];
|
||||
$firstname = @$this->request->post['firstname'];
|
||||
$editpassword = @$this->request->post['editpassword'];
|
||||
$password = @$this->request->post['password'];
|
||||
|
||||
$userid = $this->user->getId();
|
||||
|
||||
if (@$firstname) {
|
||||
$firstname = @strtoupper($firstname[0]) . substr($firstname, 1);
|
||||
}
|
||||
|
||||
if (@$lastname) {
|
||||
$lastname = @strtoupper($lastname[0]) . substr($lastname, 1);
|
||||
}
|
||||
|
||||
$userData = array(
|
||||
'user_firstname' => $firstname,
|
||||
'user_lastname' => $lastname
|
||||
);
|
||||
|
||||
if($editpassword) {
|
||||
$userData['user_password'] = md5($password);
|
||||
}
|
||||
|
||||
$this->usersModel->updateUser($userid, $userData);
|
||||
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Изменения сохранены!";
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $errorPOST;
|
||||
}
|
||||
}
|
||||
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
public function change_email() {
|
||||
if (!$this->user->isLogged()) {
|
||||
$this->data['status'] = 'error';
|
||||
$this->data['error'] = 'Вы не авторизированы!';
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
if ($this->user->getAccessLevel() < 1) {
|
||||
$this->data['status'] = 'error';
|
||||
$this->data['error'] = 'У вас нет доступа к данному разделу!';
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
if ($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
$errorPOST_email = $this->validatePOST_email();
|
||||
|
||||
if (!$errorPOST_email) {
|
||||
$email = @$this->request->post['email'];
|
||||
$userid = $this->user->getId();
|
||||
$this->load->model('users');
|
||||
|
||||
if ($this->usersModel->getTotalUsers(array('user_email' => $email))) {
|
||||
$this->data['status'] = 'error';
|
||||
$this->data['error'] = 'Указанный E-Mail уже используется!';
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$random = md5(uniqid(rand(), true));
|
||||
$this->usersModel->updateUser($userid, array('user_new_email' => $email . '|' . $random));
|
||||
$user = $this->usersModel->getUserById($userid);
|
||||
|
||||
$this->load->library('mail');
|
||||
|
||||
$mailLib = new mailLibrary();
|
||||
$mailLib->setFrom($this->config->mail_from);
|
||||
$mailLib->setSender($this->config->mail_sender);
|
||||
$mailLib->setTo($user['user_email']);
|
||||
$mailLib->setSubject("Смена E-Mail");
|
||||
$mailData = array();
|
||||
$mailData['firstname'] = $user['user_firstname'];
|
||||
$mailData['lastname'] = $user['user_lastname'];
|
||||
$mailData['email'] = $user['user_email'];
|
||||
$mailData['new_email'] = $email;
|
||||
$mailData['userid'] = $userid;
|
||||
$mailData['key'] = $random;
|
||||
$mailData['url'] = $this->config->url;
|
||||
$mailData['title'] = $this->config->title;
|
||||
$text = $this->load->view('mail/account/change_email', $mailData);
|
||||
|
||||
$mailLib->setText($text);
|
||||
$mailLib->send();
|
||||
|
||||
$this->data['status'] = 'success';
|
||||
$this->data['success'] = 'На текущий E-Mail \'' . $user['user_email'] . '\' Отправлена инструкция с дальнейшими действиями!';
|
||||
}
|
||||
else {
|
||||
$this->data['status'] = 'error';
|
||||
$this->data['error'] = $errorPOST_email;
|
||||
}
|
||||
}
|
||||
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
public function change_email_verifity($userid = null, $key = null)
|
||||
{
|
||||
if (!$userid || !$key) {
|
||||
$this->session->data['error'] = 'Ошибка! Повторите действие.';
|
||||
$this->response->redirect('/main/index');
|
||||
return null;
|
||||
}
|
||||
|
||||
$this->load->model('users');
|
||||
$user = @$this->usersModel->getUserById($userid);
|
||||
if ($user && (@explode('|', $user['user_new_email'])[1] == $key)) {
|
||||
if ($this->usersModel->getTotalUsers(array('user_email' => @explode('|', $user['user_new_email'])[0]))) {
|
||||
exit('Указанный E-Mail уже используется!');
|
||||
}
|
||||
|
||||
$this->usersModel->updateUser($userid, array('user_new_email' => null, 'user_email' => @explode('|', $user['user_new_email'])[0]));
|
||||
$this->session->data['success'] = 'E-Mail Сменен!';
|
||||
} else {
|
||||
$this->session->data['error'] = 'Ошибка! Повторите действие.';
|
||||
}
|
||||
|
||||
$this->response->redirect('/account/login');
|
||||
}
|
||||
|
||||
public function img() {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if($this->user->getAccessLevel() < 1) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$this->load->model('users');
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
$uploaddir = 'tmp/avatar/';
|
||||
$apend=date('YmdHis').rand(100,1000).'.jpg';
|
||||
$uploadfile = "$uploaddir$apend";
|
||||
|
||||
if(move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
|
||||
if($_FILES['userfile']['type'] == 'image/gif' || $_FILES['userfile']['type'] == 'image/jpeg' || $_FILES['userfile']['type'] == 'image/png') {
|
||||
if($_FILES['userfile']['size'] != 0 and $_FILES['userfile']['size'] <= 512000) {
|
||||
$size = getimagesize($uploadfile);
|
||||
if ($size[0] <= 512 && $size[1] <= 512) {
|
||||
$userid = $this->user->getId();
|
||||
$this->usersModel->updateUser($userid, array('user_img' => $uploadfile));
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Аватар успешно был загружен!";
|
||||
} else {
|
||||
$this->data['error'] = 'Загружаемое изображение превышает допустимые нормы!';
|
||||
$this->data['status'] = "error";
|
||||
unlink($uploadfile);
|
||||
}
|
||||
} else {
|
||||
$this->data['error'] = 'Размер изображения не должено превышать 512Кб';
|
||||
$this->data['status'] = "error";
|
||||
}
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Можно загружать только изображения в форматах jpg, jpeg и png";
|
||||
}
|
||||
} else {
|
||||
$this->data['error'] = 'Изображение не загружено!';
|
||||
$this->data['status'] = "error";
|
||||
}
|
||||
}
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
private function validatePOST() {
|
||||
|
||||
$this->load->library('validate');
|
||||
|
||||
$validateLib = new validateLibrary();
|
||||
|
||||
$result = null;
|
||||
|
||||
$lastname = @$this->request->post['lastname'];
|
||||
$firstname = @$this->request->post['firstname'];
|
||||
$editpassword = @$this->request->post['editpassword'];
|
||||
$password = @$this->request->post['password'];
|
||||
$password2 = @$this->request->post['password2'];
|
||||
|
||||
if (@$firstname) {
|
||||
$firstname = @strtoupper($firstname[0]) . substr($firstname, 1);
|
||||
}
|
||||
|
||||
if (@$lastname) {
|
||||
$lastname = @strtoupper($lastname[0]) . substr($lastname, 1);
|
||||
}
|
||||
|
||||
if(!$validateLib->check_for_number($lastname)) {
|
||||
$result = "Укажите свою реальную фамилию!";
|
||||
}
|
||||
elseif(!$validateLib->check_for_number($firstname)) {
|
||||
$result = "Укажите свое реальное имя!";
|
||||
}
|
||||
elseif($editpassword) {
|
||||
if(!$validateLib->password($password)) {
|
||||
$result = "Пароль должен содержать от 6 до 32 латинских букв, цифр и знаков <i>,.!?_-</i>!";
|
||||
}
|
||||
elseif($password != $password2) {
|
||||
$result = "Введенные вами пароли не совпадают!";
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function validatePOST_email()
|
||||
{
|
||||
$this->load->library('validate');
|
||||
$validateLib = new validateLibrary();
|
||||
$result = NULL;
|
||||
$email = @$this->request->post['email'];
|
||||
|
||||
if (!$validateLib->email($email)) {
|
||||
$result = 'Укажите свой реальный E-Mail!';
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function validatePOST_VK() {
|
||||
$this->load->library('validate');
|
||||
|
||||
$validateLib = new validateLibrary();
|
||||
|
||||
$result = null;
|
||||
|
||||
$id = @strtolower($this->request->post['id']);
|
||||
|
||||
if($this->usersModel->getTotalUsers(array('user_vk_id' => $id))) {
|
||||
$result = "Указанный ID-".$id." уже привязан!";
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function pluralForm($n, $form1, $form2,$form5) {
|
||||
$n = abs($n) % 100;
|
||||
$n1 = $n % 10;
|
||||
if ($n1 >= 5 && $n1 <= 4) return $form2;
|
||||
if ($n >= 10 && $n <= 20) return $form2;
|
||||
if ($n1 >= 2 && $n1 <= 4) return $form5;
|
||||
if ($n1 == 1) return $form1;
|
||||
if ($n == 0) return $form2;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,661 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class cronController extends Controller {
|
||||
public function index() {
|
||||
$token = @$this->request->get['token'];
|
||||
if($this->config->token != $token) {
|
||||
return "Access Denied";
|
||||
}
|
||||
|
||||
$this->load->library('mail');
|
||||
$this->load->library('ssh2');
|
||||
$this->load->model('webhost');
|
||||
$this->load->model('servers');
|
||||
$this->load->model('invoices');
|
||||
|
||||
$mailLib = new mailLibrary();
|
||||
$mailLib->setFrom($this->config->mail_from);
|
||||
$mailLib->setSender($this->config->mail_sender);
|
||||
|
||||
$servers = $this->serversModel->getServers(array(), array('users'));
|
||||
$webhosts = $this->webhostModel->getWebhosts(array(), array('users'));
|
||||
|
||||
$datenow = date_create('now');
|
||||
|
||||
foreach($servers as $item) {
|
||||
$operation = false;
|
||||
$serverid = $item['server_id'];
|
||||
$dateend = date_create($item['server_date_end']);
|
||||
$diff = date_diff($datenow, $dateend);
|
||||
|
||||
if($diff->invert) {
|
||||
if($diff->days >= 1) {
|
||||
if($this->serversModel->action($serverid, 'delete')["status"] != "success") {
|
||||
$operation = true;
|
||||
echo "Игровой сервер: gs" . $serverid . " - удаление не удалось.". PHP_EOL;
|
||||
}
|
||||
|
||||
if(!$operation) {
|
||||
if($item['server_mysql'] == 1 || $item['server_mysql'] == 2) {
|
||||
$this->serversModel->action($serverid, "delete_mysql");
|
||||
}
|
||||
$this->serversModel->deleteServer($serverid);
|
||||
$this->serversModel->deleteServerStats($serverid);
|
||||
$this->serversModel->deleteserverOwners($serverid);
|
||||
$this->serversModel->deleteLog($serverid);
|
||||
|
||||
$firewall = $this->serversModel->getFirewallsById($serverid);
|
||||
|
||||
if ($firewall) {
|
||||
foreach ($firewall as $item2) {
|
||||
$ssh2Lib = new ssh2Library();
|
||||
$link = $ssh2Lib->connect($item['location_ip'], $item['location_user'], $item['location_password']);
|
||||
|
||||
$ssh2Lib->execute($link, "iptables -D INPUT -s ".$item2['server_ip']." -p udp -d ".$item['location_ip']." --dport ".$item['server_port']." -j DROP;");
|
||||
$ssh2Lib->execute($link, "iptables -D INPUT -s ".$item2['server_ip']." -p tcp -d ".$item['location_ip']." --dport ".$item['server_port']." -j DROP;");
|
||||
|
||||
$ssh2Lib->disconnect($link);
|
||||
|
||||
$this->serversModel->deleteFirewallDB($item2['firewall_id']);
|
||||
}
|
||||
}
|
||||
|
||||
$mailLib->setTo($item['user_email']);
|
||||
$mailLib->setSubject("Удаление сервера #$serverid");
|
||||
|
||||
$mailData = array();
|
||||
$mailData['firstname'] = $item['user_firstname'];
|
||||
$mailData['lastname'] = $item['user_lastname'];
|
||||
$mailData['serverid'] = $serverid;
|
||||
|
||||
$text = $this->load->view('mail/servers/deleted', $mailData);
|
||||
|
||||
$mailLib->setText($text);
|
||||
$mailLib->send();
|
||||
|
||||
echo "Игровой сервер: gs" . $serverid . " - удален.". PHP_EOL;
|
||||
}
|
||||
} else if($item['server_status'] != 0) {
|
||||
if($this->serversModel->action($serverid, "stop")["status"] == "success") {
|
||||
$this->serversModel->updateServer($serverid, array('server_status' => 0));
|
||||
$this->serversModel->action($serverid, "block");
|
||||
} else {
|
||||
$operation = true;
|
||||
echo "Игровой сервер: gs" . $serverid . " - блокировка не удалась.". PHP_EOL;
|
||||
}
|
||||
|
||||
if(!$operation) {
|
||||
$mailLib->setTo($item['user_email']);
|
||||
$mailLib->setSubject("Блокировка сервера #$serverid");
|
||||
|
||||
$mailData = array();
|
||||
$mailData['firstname'] = $item['user_firstname'];
|
||||
$mailData['lastname'] = $item['user_lastname'];
|
||||
$mailData['serverid'] = $serverid;
|
||||
|
||||
$text = $this->load->view('mail/servers/lock', $mailData);
|
||||
|
||||
$mailLib->setText($text);
|
||||
$mailLib->send();
|
||||
|
||||
echo "Игровой сервер: gs" . $serverid . " - заблокирован.". PHP_EOL;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if($diff->days < 3) {
|
||||
$mailLib->setTo($item['user_email']);
|
||||
$mailLib->setSubject("Завершение оплаченного периода сервера #$serverid");
|
||||
|
||||
$mailData = array();
|
||||
$mailData['firstname'] = $item['user_firstname'];
|
||||
$mailData['lastname'] = $item['user_lastname'];
|
||||
$mailData['serverid'] = $serverid;
|
||||
$mailData['days'] = $diff->days;
|
||||
|
||||
$text = $this->load->view('mail/servers/needPay', $mailData);
|
||||
|
||||
$mailLib->setText($text);
|
||||
$mailLib->send();
|
||||
|
||||
echo "Игровой сервер: gs" . $serverid . " - отправлено уведомление.". PHP_EOL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach($webhosts as $item) {
|
||||
$operation = false;
|
||||
$webid = $item['web_id'];
|
||||
$dateend = date_create($item['web_date_end']);
|
||||
$diff = date_diff($datenow, $dateend);
|
||||
|
||||
if($diff->invert) {
|
||||
if($diff->days >= 3) {
|
||||
$this->webhostModel->unblockWebhost($webid);
|
||||
$this->webhostModel->deleteWebhost($webid);
|
||||
|
||||
$mailLib->setTo($item['user_email']);
|
||||
$mailLib->setSubject("Удаление веб-хостинга #$webid");
|
||||
|
||||
$mailData = array();
|
||||
$mailData['firstname'] = $item['user_firstname'];
|
||||
$mailData['lastname'] = $item['user_lastname'];
|
||||
$mailData['webid'] = $webid;
|
||||
|
||||
$text = $this->load->view('mail/webhost/deleted', $mailData);
|
||||
|
||||
$mailLib->setText($text);
|
||||
$mailLib->send();
|
||||
|
||||
echo "Веб-хостинг: ws" . $webid . " - удален.". PHP_EOL;
|
||||
} else if($item['web_status'] != 0) {
|
||||
$this->webhostModel->blockWebhost($webid);
|
||||
|
||||
$mailLib->setTo($item['user_email']);
|
||||
$mailLib->setSubject("Блокировка веб-хостинга #$webid");
|
||||
|
||||
$mailData = array();
|
||||
$mailData['firstname'] = $item['user_firstname'];
|
||||
$mailData['lastname'] = $item['user_lastname'];
|
||||
$mailData['webid'] = $webid;
|
||||
|
||||
$text = $this->load->view('mail/webhost/lock', $mailData);
|
||||
|
||||
$mailLib->setText($text);
|
||||
$mailLib->send();
|
||||
|
||||
echo "Веб-хостинг: ws" . $webid . " - заблокирован.". PHP_EOL;
|
||||
}
|
||||
} else {
|
||||
if($diff->days < 3) {
|
||||
$mailLib->setTo($item['user_email']);
|
||||
$mailLib->setSubject("Завершение оплаченного периода веб-хостинга #$webid");
|
||||
|
||||
$mailData = array();
|
||||
$mailData['firstname'] = $item['user_firstname'];
|
||||
$mailData['lastname'] = $item['user_lastname'];
|
||||
$mailData['webid'] = $webid;
|
||||
$mailData['days'] = $diff->days;
|
||||
|
||||
$text = $this->load->view('mail/webhost/needPay', $mailData);
|
||||
|
||||
$mailLib->setText($text);
|
||||
$mailLib->send();
|
||||
|
||||
echo "Веб-хостинг: ws" . $webid . " - отправлено уведомление.". PHP_EOL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$invoices = $this->invoicesModel->getInvoices(array('invoice_status' => 0), array(), array(), array());
|
||||
foreach($invoices as $item) {
|
||||
$this->invoicesModel->deleteInvoice($item['invoice_id']);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function gameServers() {
|
||||
$token = @$this->request->get['token'];
|
||||
if($this->config->token != $token) {
|
||||
return "Access Denied";
|
||||
}
|
||||
|
||||
$this->load->model('servers');
|
||||
$servers = $this->serversModel->getServers(array(), array('games', 'users', 'locations'));
|
||||
|
||||
foreach($servers as $item) {
|
||||
$serverid = $item['server_id'];
|
||||
if($item['server_status'] == 3 AND $item['server_work'] == 1) {
|
||||
$this->serversModel->updateServer($serverid, array('server_work' => 0));
|
||||
$result = $this->serversModel->action($serverid, "install");
|
||||
if($result['status'] == "success") {
|
||||
echo "Игровой сервер: gs" . $serverid . " - успешная установка.". PHP_EOL;
|
||||
$logData = array(
|
||||
'server_id' => $serverid,
|
||||
'reason' => 'Успешная установка сервера.',
|
||||
'status' => 1
|
||||
);
|
||||
$this->serversModel->createLog($logData);
|
||||
} else {
|
||||
echo "Игровой сервер: gs" . $serverid . " - неудачная установка.". PHP_EOL;
|
||||
}
|
||||
}
|
||||
if($item['server_status'] == 4 AND $item['server_work'] == 1) {
|
||||
$this->serversModel->updateServer($serverid, array('server_work' => 0));
|
||||
$result = $this->serversModel->action($serverid, "reinstall");
|
||||
if($result['status'] == "success") {
|
||||
echo "Игровой сервер: gs" . $serverid . " - успешная переустановка.". PHP_EOL;
|
||||
$logData = array(
|
||||
'server_id' => $serverid,
|
||||
'reason' => 'Успешная переустановка сервера.',
|
||||
'status' => 1
|
||||
);
|
||||
$this->serversModel->createLog($logData);
|
||||
} else {
|
||||
echo "Игровой сервер: gs" . $serverid . " - неудачная переустановка.". PHP_EOL;
|
||||
}
|
||||
}
|
||||
if($item['server_status'] == 5 AND $item['server_work'] == 1) {
|
||||
$this->serversModel->updateServer($serverid, array('server_work' => 0));
|
||||
$result = $this->serversModel->action($serverid, 'createbackup');
|
||||
if($result['status'] == "success") {
|
||||
echo "Игровой сервер: gs" . $serverid . " - успешный бекап сервера.". PHP_EOL;
|
||||
$logData = array(
|
||||
'server_id' => $serverid,
|
||||
'reason' => 'Успешное создание BackUP.',
|
||||
'status' => 1
|
||||
);
|
||||
$this->serversModel->createLog($logData);
|
||||
} else {
|
||||
echo "Игровой сервер: gs" . $serverid . " - неудачный бекап сервера.". PHP_EOL;
|
||||
}
|
||||
}
|
||||
if($item['server_status'] == 6 AND $item['server_work'] == 1) {
|
||||
$this->serversModel->updateServer($serverid, array('server_work' => 0));
|
||||
$result = $this->serversModel->action($serverid, "installbackup");
|
||||
if($result['status'] == "success") {
|
||||
echo "Игровой сервер: gs" . $serverid . " - успешное восстановление из бекапа.". PHP_EOL;
|
||||
$logData = array(
|
||||
'server_id' => $serverid,
|
||||
'reason' => 'Успешное восстановление из BackUP.',
|
||||
'status' => 1
|
||||
);
|
||||
$this->serversModel->createLog($logData);
|
||||
} else {
|
||||
echo "Игровой сервер: gs" . $serverid . " - неудачное восстановление из бекапа.". PHP_EOL;
|
||||
}
|
||||
}
|
||||
if($item['server_status'] == 7 AND $item['server_work'] == 1) {
|
||||
if($item['game_code'] == 'mine' || $item['game_code'] == 'mcpe') {
|
||||
$this->serversModel->updateServer($serverid, array('server_work' => 0));
|
||||
$result = $this->serversModel->action($serverid, 'sendcommand', array('command' => 'installNewCore'));
|
||||
if($result['status'] == "success") {
|
||||
echo "Игровой сервер: gs" . $serverid . " - успешная смена ядра.". PHP_EOL;
|
||||
$logData = array(
|
||||
'server_id' => $serverid,
|
||||
'reason' => 'Успешная смена ядра.',
|
||||
'status' => 1
|
||||
);
|
||||
$this->serversModel->createLog($logData);
|
||||
} else {
|
||||
echo "Игровой сервер: gs" . $serverid . " - неудачная смена ядра.". PHP_EOL;
|
||||
}
|
||||
} else if($item['game_code'] == 'cs') {
|
||||
$this->serversModel->updateServer($serverid, array('server_work' => 0));
|
||||
$result = $this->serversModel->action($serverid, 'sendcommand', array('command' => 'installNewBuild'));
|
||||
if($result['status'] == "success") {
|
||||
echo "Игровой сервер: gs" . $serverid . " - успешная смена билда.". PHP_EOL;
|
||||
$logData = array(
|
||||
'server_id' => $serverid,
|
||||
'reason' => 'Успешная смена билда.',
|
||||
'status' => 1
|
||||
);
|
||||
$this->serversModel->createLog($logData);
|
||||
} else {
|
||||
echo "Игровой сервер: gs" . $serverid . " - неудачная смена билда.". PHP_EOL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function updateStatsLocations() {
|
||||
$token = @$this->request->get['token'];
|
||||
if($this->config->token != $token) {
|
||||
return "Access Denied";
|
||||
}
|
||||
|
||||
$this->load->model('locations');
|
||||
$locations = $this->locationsModel->getLocations(array());
|
||||
|
||||
foreach($locations as $item) {
|
||||
$today = date("Y-m-d H:i:s");
|
||||
if($item['location_status'] == 1) {
|
||||
$this->load->library('ssh2');
|
||||
$ssh2Lib = new ssh2Library();
|
||||
$link = $ssh2Lib->connect($item['location_ip'], $item['location_user'], $item['location_password']);
|
||||
|
||||
$cpu = (int) $ssh2Lib->execute($link, 'echo $[100-$(vmstat 1 2|tail -1|awk \'{print $15}\')]');
|
||||
|
||||
$hdd_used = (int) $ssh2Lib->execute($link, 'df -h -B 1M $HOME | grep dev | awk \'{print $3}\'');
|
||||
$hdd_all = (int) $ssh2Lib->execute($link, 'df -h -B 1M $HOME | grep dev | awk \'{print $2}\'');
|
||||
|
||||
$ram_all = (int) $ssh2Lib->execute($link, 'cat /proc/meminfo | grep MemTotal | awk \'{print $2}\'');
|
||||
$ram_free = (int) $ssh2Lib->execute($link, 'cat /proc/meminfo | grep MemAvailable | awk \'{print $2}\'');
|
||||
$ram_used = (int) $ram_all - (int) $ram_free;
|
||||
|
||||
$swap_all = (int) $ssh2Lib->execute($link, 'cat /proc/meminfo | grep SwapTotal | awk \'{print $2}\'');
|
||||
$swap_free = (int) $ssh2Lib->execute($link, 'cat /proc/meminfo | grep SwapFree | awk \'{print $2}\'');
|
||||
$swap_used = (int) $swap_all - (int) $swap_free;
|
||||
|
||||
$ssh2Lib->disconnect($link);
|
||||
|
||||
$cpu = $cpu > 100 ? 100 : round($cpu);
|
||||
$ram_used = round($ram_used * 0.000977, 0);
|
||||
$ram_all = round($ram_all * 0.000977, 0);
|
||||
$swap_used = round($swap_used * 0.000977, 0);
|
||||
$swap_all = round($swap_all * 0.000977, 0);
|
||||
|
||||
$hdd_end = (($hdd_used * 100) / $hdd_all);
|
||||
$hdd_end = $hdd_end > 100 ? 100 : round($hdd_end);
|
||||
|
||||
$ram_swap_save = ((($ram_used + $swap_used) * 100) / ($ram_all + $swap_all));
|
||||
$ram_swap_save = $ram_swap_save > 100 ? 100 : round($ram_swap_save);
|
||||
|
||||
$locationData = array(
|
||||
'location_cpu' => $cpu,
|
||||
'location_ram' => $ram_swap_save,
|
||||
'location_hdd' => $hdd_end,
|
||||
'location_upd' => $today
|
||||
);
|
||||
$this->locationsModel->updateLocation($item['location_id'], $locationData);
|
||||
|
||||
echo "Статистика игровой локации #". $item['location_id'] ." успешно обновлена (CPU: ".$cpu."%, RAM: ".$ram_swap_save."%, SSD: ".$hdd_end."%)" . PHP_EOL;
|
||||
} else {
|
||||
$locationData = array(
|
||||
'location_cpu' => 0,
|
||||
'location_ram' => 0,
|
||||
'location_hdd' => 0,
|
||||
'location_upd' => $today
|
||||
);
|
||||
$this->locationsModel->updateLocation($item['location_id'], $locationData);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function updateStats() {
|
||||
$this->load->library('query');
|
||||
$this->load->model('servers');
|
||||
|
||||
$token = @$this->request->get['token'];
|
||||
if($this->config->token != $token) {
|
||||
return "Access Denied";
|
||||
}
|
||||
|
||||
$servers = $this->serversModel->getServers(array(), array('games', 'locations'));
|
||||
|
||||
$this->serversModel->clearServersStats();
|
||||
|
||||
foreach($servers as $item) {
|
||||
$serverid = $item['server_id'];
|
||||
|
||||
if($item['server_status'] == 2) {
|
||||
$queryLib = new queryLibrary($item['game_query']);
|
||||
$queryLib->connect($item['location_ip'], $item['server_port']);
|
||||
$query = $queryLib->getInfo();
|
||||
$queryLib->disconnect();
|
||||
|
||||
$sysload = $this->serversModel->getServerSystemLoad($serverid);
|
||||
$ssd = round($sysload['ssd']);
|
||||
$ssd_all = $item['game_ssd'];
|
||||
$ssd_end = (int)(($ssd * 100) / $ssd_all);
|
||||
$cpu = $sysload['cpu'] > 100 ? 100 : round($sysload['cpu']);
|
||||
$ram = $sysload['ram'] > 100 ? 100 : round($sysload['ram']);
|
||||
|
||||
$this->serversModel->createServerStats(array(
|
||||
'server_id' => $serverid,
|
||||
'server_stats_players' => $query['players'],
|
||||
'server_stats_cpu' => $cpu,
|
||||
'server_stats_ram' => $ram,
|
||||
'server_stats_hdd' => $ssd_end
|
||||
));
|
||||
echo "Статистика игрового сервера gs" . $serverid . " успешно сохранена (CPU: ".$cpu."%, RAM: ".$ram."%, SSD: ".$ssd_end."%)" . PHP_EOL;
|
||||
}
|
||||
|
||||
if($item['server_status'] == 1) {
|
||||
$ssd = $this->serversModel->getHDD($serverid);
|
||||
$ssd = round($ssd);
|
||||
$ssd_all = $item['game_ssd'];
|
||||
$ssd_end = (int)(($ssd * 100) / $ssd_all);
|
||||
|
||||
$this->serversModel->createServerStats(array(
|
||||
'server_id' => $serverid,
|
||||
'server_stats_players' => 0,
|
||||
'server_stats_cpu' => 0,
|
||||
'server_stats_ram' => 0,
|
||||
'server_stats_hdd' => $ssd_end
|
||||
));
|
||||
echo "Статистика игрового сервера gs" . $serverid . " успешно сохранена (CPU: 0%, RAM: 0%, SSD: ".$ssd_end."%)" . PHP_EOL;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function stopServers() {
|
||||
$token = @$this->request->get['token'];
|
||||
if($this->config->token != $token) {
|
||||
return "Access Denied";
|
||||
}
|
||||
|
||||
$this->load->model('servers');
|
||||
|
||||
$servers = $this->serversModel->getServers(array(), array('games', 'locations'));
|
||||
|
||||
foreach($servers as $item) {
|
||||
$serverid = $item['server_id'];
|
||||
|
||||
if($item['server_status'] == 2) {
|
||||
$hdd = $this->serversModel->getHDD($serverid);
|
||||
$hdd = round($hdd);
|
||||
if($hdd > $item['game_ssd']){
|
||||
$connect = $this->serversModel->action($serverid, 'stop');
|
||||
if($connect['status'] == "success") {
|
||||
$this->serversModel->deleteTask(array('task_name' => 'restart', 'server_id' => $serverid));
|
||||
$this->serversModel->deleteTask(array('task_name' => 'enable', 'server_id' => $serverid));
|
||||
$this->serversModel->deleteTask(array('task_name' => 'disable', 'server_id' => $serverid));
|
||||
$this->serversModel->updateServer($serverid, array('server_status' => 1));
|
||||
$logData = array(
|
||||
'server_id' => $serverid,
|
||||
'reason' => "Остановка сервера: OVERLOAD-ssd = ".$hdd."/".$item['game_ssd']."МБ",
|
||||
'status' => 1
|
||||
);
|
||||
$this->serversModel->createLog($logData);
|
||||
echo "Остановка сервера: OVERLOAD-ssd = ".$hdd."/".$item['game_ssd']."МБ" . PHP_EOL;
|
||||
} else {
|
||||
echo "Ошибка остановки сервера gs$item[server_id]" . PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function stopServersQuery() {
|
||||
$token = @$this->request->get['token'];
|
||||
if($this->config->token != $token) {
|
||||
return "Access Denied";
|
||||
}
|
||||
|
||||
$this->load->library('query');
|
||||
$this->load->model('servers');
|
||||
|
||||
$servers = $this->serversModel->getServers(array(), array('games', 'locations'));
|
||||
|
||||
foreach($servers as $item) {
|
||||
$serverid = $item['server_id'];
|
||||
|
||||
if($item['server_status'] == 2) {
|
||||
$queryLib = new queryLibrary($item['game_query']);
|
||||
$queryLib->connect($item['location_ip'], $item['server_port']);
|
||||
$query = $queryLib->getInfo();
|
||||
$queryLib->disconnect();
|
||||
|
||||
if($query['players'] > ($item['server_slots']+1)){
|
||||
$connect = $this->serversModel->action($serverid, 'stop');
|
||||
if($connect['status'] == "success") {
|
||||
$this->serversModel->deleteTask(array('task_name' => 'restart', 'server_id' => $serverid));
|
||||
$this->serversModel->deleteTask(array('task_name' => 'enable', 'server_id' => $serverid));
|
||||
$this->serversModel->deleteTask(array('task_name' => 'disable', 'server_id' => $serverid));
|
||||
$this->serversModel->updateServer($serverid, array('server_status' => 1));
|
||||
$logData = array(
|
||||
'server_id' => $serverid,
|
||||
'reason' => "Остановка сервера: Чрезмерное кол.во игроков на сервере, игроков ".$query['players']." слотов ".$item['server_slots']."",
|
||||
'status' => 1
|
||||
);
|
||||
$this->serversModel->createLog($logData);
|
||||
echo "Остановка сервера: Чрезмерное кол.во игроков на сервере, игроков ".$query['players']." слотов ".$item['server_slots']."" . PHP_EOL;
|
||||
} else {
|
||||
echo "Ошибка остановки сервера gs$item[server_id]" . PHP_EOL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function serverReloader() {
|
||||
$token = @$this->request->get['token'];
|
||||
if($this->config->token != $token) {
|
||||
return "Access Denied";
|
||||
}
|
||||
|
||||
$this->load->model('servers');
|
||||
$this->load->model('locations');
|
||||
|
||||
$locations = $this->locationsModel->getLocations(array());
|
||||
|
||||
foreach($locations as $location) {
|
||||
echo PHP_EOL . 'Локация ('.$location['location_id'].') '.$location['location_name'].'' . PHP_EOL;
|
||||
$servers = $this->serversModel->getServers(array('server_status' => '2', 'location_id' => $location['location_id']));
|
||||
if($servers){
|
||||
foreach($servers as $item) {
|
||||
$serverid = $item['server_id'];
|
||||
$result_status = $this->serversModel->action($serverid, 'server_status');
|
||||
|
||||
if($result_status == 1) {
|
||||
$result = $this->serversModel->action($serverid, 'restart');
|
||||
if($result["status"] == "success") {
|
||||
$logData = array(
|
||||
'server_id' => $serverid,
|
||||
'reason' => 'Сервер был восcтановлен после падения',
|
||||
'status' => 1
|
||||
);
|
||||
$this->serversModel->createLog($logData);
|
||||
echo "Игровой сервер gs$item[server_id] - Поднят.". PHP_EOL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private $deletedTasks = array();
|
||||
|
||||
public function tasks() {
|
||||
$token = @$this->request->get['token'];
|
||||
if($this->config->token != $token) {
|
||||
return "Access Denied";
|
||||
}
|
||||
|
||||
$this->load->model('servers');
|
||||
$tasks = $this->serversModel->getTasks(array(), array('servers'));
|
||||
$datenow = date_create('now');
|
||||
|
||||
foreach($tasks as $item) {
|
||||
$serverid = $item['server_id'];
|
||||
|
||||
if(!in_array($item['task_name'], $this->deletedTasks)) {
|
||||
if(strtotime($item['task_lead_time']) <= strtotime(date("Y-m-d H:i:s"))) {
|
||||
if($item['task_name'] == "enable") {
|
||||
if($item['server_status'] == 1) {
|
||||
$result = $this->serversModel->action($serverid, "start");
|
||||
if($result["status"] == "success") {
|
||||
$this->serversModel->updateServer($serverid, array("server_status" => 2));
|
||||
array_push($this->deletedTasks, 'enable');
|
||||
$logData = array(
|
||||
'server_id' => $serverid,
|
||||
'reason' => '[Планировщик] Успешный запуск сервера',
|
||||
'status' => 1
|
||||
);
|
||||
$this->serversModel->createLog($logData);
|
||||
echo 'Задача ' . $item['task_name'] . ' для сервера #' . $item['server_id'] . ' выполнена!' . PHP_EOL;
|
||||
}
|
||||
}
|
||||
$this->serversModel->deleteTask(array('task_id' => $item['task_id']));
|
||||
} else if($item['task_name'] == "disable") {
|
||||
if($item['server_status'] == 2) {
|
||||
$result = $this->serversModel->action($serverid, "stop");
|
||||
if($result["status"] == "success") {
|
||||
$this->serversModel->updateServer($serverid, array("server_status" => 1));
|
||||
array_push($this->deletedTasks, 'disable');
|
||||
array_push($this->deletedTasks, 'restart');
|
||||
array_push($this->deletedTasks, 'enable');
|
||||
$logData = array(
|
||||
'server_id' => $serverid,
|
||||
'reason' => '[Планировщик] Успешное выключение сервера',
|
||||
'status' => 1
|
||||
);
|
||||
$this->serversModel->createLog($logData);
|
||||
echo 'Задача ' . $item['task_name'] . ' для сервера #' . $item['server_id'] . ' выполнена!' . PHP_EOL;
|
||||
}
|
||||
}
|
||||
$this->serversModel->deleteTask(array('task_id' => $item['task_id']));
|
||||
} else if($item['task_name'] == "restart") {
|
||||
if($item['server_status'] == 2) {
|
||||
$result = $this->serversModel->action($serverid, "restart");
|
||||
if($result["status"] == "success") {
|
||||
array_push($this->deletedTasks, 'enable');
|
||||
$logData = array(
|
||||
'server_id' => $serverid,
|
||||
'reason' => '[Планировщик] Успешный перезапуск сервера',
|
||||
'status' => 1
|
||||
);
|
||||
$this->serversModel->createLog($logData);
|
||||
echo 'Задача ' . $item['task_name'] . ' для сервера #' . $item['server_id'] . ' выполнена!' . PHP_EOL;
|
||||
}
|
||||
}
|
||||
if($item['task_type'] == 'single') {
|
||||
$this->serversModel->deleteTask(array('task_id' => $item['task_id']));
|
||||
} else {
|
||||
if($item['task_time'] == '15min') {
|
||||
$lead_time = date('Y-m-d H:i:s', strtotime("+15 minutes"));
|
||||
} else if($item['task_time'] == '30min') {
|
||||
$lead_time = date('Y-m-d H:i:s', strtotime("+30 minutes"));
|
||||
} else if($item['task_time'] == '1hour') {
|
||||
$lead_time = date('Y-m-d H:i:s', strtotime("+1 hour"));
|
||||
} else if($item['task_time'] == '12hours') {
|
||||
$lead_time = date('Y-m-d H:i:s', strtotime("+12 hours"));
|
||||
} else if($item['task_time'] == '24hours') {
|
||||
$lead_time = date('Y-m-d H:i:s', strtotime("+1 day"));
|
||||
}
|
||||
$this->serversModel->updateTask($item['task_id'], array('task_lead_time' => $lead_time));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function clearLogs() {
|
||||
$token = @$this->request->get['token'];
|
||||
if($this->config->token != $token) {
|
||||
return "Access Denied";
|
||||
}
|
||||
|
||||
$this->load->model('servers');
|
||||
|
||||
$serverLogs = $this->serversModel->getLogs();
|
||||
|
||||
$datenow = date_create('now');
|
||||
|
||||
foreach($serverLogs as $item) {
|
||||
$diff = date_diff($datenow, date_create($item['date']));
|
||||
|
||||
if($diff->invert) {
|
||||
if($diff->days >= 7) {
|
||||
$this->serversModel->deleteLog($item['log_id']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko (https://vk.com/id00v)
|
||||
*/
|
||||
class indexController extends Controller {
|
||||
private $limit = 5;
|
||||
public function index($page = 1) {
|
||||
$this->document->setActiveSection('main');
|
||||
$this->document->setActiveItem('index');
|
||||
$this->data['public'] = $this->config->public;
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 0) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->library('pagination');
|
||||
$this->load->model('news');
|
||||
|
||||
$sort = array(
|
||||
'news_date_add' => 'DESC'
|
||||
);
|
||||
|
||||
$options = array(
|
||||
'start' => ($page - 1) * $this->limit,
|
||||
'limit' => $this->limit
|
||||
);
|
||||
|
||||
$total = $this->newsModel->getTotalNews();
|
||||
$news = $this->newsModel->getNews(array(), array(), $sort, $options);
|
||||
|
||||
$paginationLib = new paginationLibrary();
|
||||
|
||||
$paginationLib->total = $total;
|
||||
$paginationLib->page = $page;
|
||||
$paginationLib->limit = $this->limit;
|
||||
$paginationLib->url = $this->config->url . 'news/index/index/{page}';
|
||||
|
||||
$pagination = $paginationLib->render();
|
||||
$this->data['news'] = $news;
|
||||
$this->data['pagination'] = $pagination;
|
||||
|
||||
$this->getChild(array('common/header', 'common/footer'));
|
||||
return $this->load->view('main/index', $this->data);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko (https://vk.com/id00v)
|
||||
*/
|
||||
class indexController extends Controller {
|
||||
private $limit = 5;
|
||||
public function index($page = 1) {
|
||||
$this->document->setActiveSection('news');
|
||||
$this->document->setActiveItem('index');
|
||||
$this->data['vk_id'] = $this->config->vk_id;
|
||||
$this->data['url'] = $this->config->url;
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 0) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->library('pagination');
|
||||
$this->load->model('news');
|
||||
$userid = $this->user->getId();
|
||||
|
||||
$sort = array(
|
||||
//'ticket_status' => 'DESC',
|
||||
'news_date_add' => 'DESC'
|
||||
);
|
||||
|
||||
$options = array(
|
||||
'start' => ($page - 1) * $this->limit,
|
||||
'limit' => $this->limit
|
||||
);
|
||||
|
||||
$total = $this->newsModel->getTotalNews();
|
||||
$news = $this->newsModel->getNews(array(), array(), $sort, $options);
|
||||
|
||||
$paginationLib = new paginationLibrary();
|
||||
|
||||
$paginationLib->total = $total;
|
||||
$paginationLib->page = $page;
|
||||
$paginationLib->limit = $this->limit;
|
||||
$paginationLib->url = $this->config->url . 'news/index/index/{page}';
|
||||
|
||||
$pagination = $paginationLib->render();
|
||||
$this->data['news'] = $news;
|
||||
$this->data['pagination'] = $pagination;
|
||||
|
||||
$this->getChild(array('common/header', 'common/footer'));
|
||||
return $this->load->view('news/index', $this->data);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko (https://vk.com/id00v)
|
||||
*/
|
||||
class viewController extends Controller {
|
||||
public function index($newid = null) {
|
||||
$this->data['vk_id'] = $this->config->vk_id;
|
||||
$this->data['url'] = $this->config->url;
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 0) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->model('news');
|
||||
$this->load->model('newsMessages');
|
||||
|
||||
$error = $this->validate($newid);
|
||||
if($error) {
|
||||
$this->session->data['error'] = $error;
|
||||
$this->response->redirect($this->config->url . 'news/index');
|
||||
}
|
||||
|
||||
$userid = $this->user->getId();
|
||||
|
||||
$new = $this->newsModel->getNewsById($newid, array('users'));
|
||||
$messages = $this->newsMessagesModel->getNewsMessages(array('news_id' => $newid), array('users'));
|
||||
$this->data['new'] = $new;
|
||||
$this->data['messages'] = $messages;
|
||||
$this->data['user_img'] = $this->user->getUser_img();
|
||||
|
||||
$nq = $new['look']+1;
|
||||
$this->newsModel->updateNews($newid, array('look' => $nq));
|
||||
|
||||
$this->getChild(array('common/header', 'common/footer'));
|
||||
return $this->load->view('news/view', $this->data);
|
||||
}
|
||||
|
||||
public function ajax($newid = null) {
|
||||
$this->load->model('news');
|
||||
$this->load->model('newsMessages');
|
||||
|
||||
$error = $this->validate($newid);
|
||||
if($error) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $error;
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
$errorPOST = $this->validatePOST($newid);
|
||||
if(!$errorPOST) {
|
||||
$text = @$this->request->post['text'];
|
||||
|
||||
$userid = $this->user->getId();
|
||||
|
||||
$messageData = array(
|
||||
'news_id' => $newid,
|
||||
'user_id' => $userid,
|
||||
'news_message' => $text
|
||||
);
|
||||
$this->newsMessagesModel->createNewsMessage($messageData);
|
||||
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Вы успешно создали коментарий!";
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $errorPOST;
|
||||
}
|
||||
}
|
||||
|
||||
return json_encode($this->data);
|
||||
}
|
||||
private function validate($newid) {
|
||||
$result = null;
|
||||
if(!$this->newsModel->getTotalNews(array('news_id' => (int)$newid))) {
|
||||
$result = "Запрашиваемая новость не существует!";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function validatePOST($newid) {
|
||||
$result = null;
|
||||
|
||||
$text = @$this->request->post['text'];
|
||||
if(mb_strlen($text) < 10 || mb_strlen($text) > 128) {
|
||||
$result = "Текст коментариф должен содержать от 10 до 128 символов.";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class indexController extends Controller {
|
||||
public function index() {
|
||||
$this->data['result'] = $this->request->get['result'];
|
||||
$this->data['public'] = $this->config->public;
|
||||
|
||||
return $this->load->view('offline/index', $this->data);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class anypayController extends Controller {
|
||||
public function index() {
|
||||
$this->load->model('users');
|
||||
$this->load->model('invoices');
|
||||
$this->load->model('waste');
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
$errorPOST = $this->validatePOST();
|
||||
if(!$errorPOST) {
|
||||
$ammount = $this->request->post['amount'];
|
||||
$invid = $this->request->post['pay_id'];
|
||||
$signature = $this->request->post['sign'];
|
||||
|
||||
$invoice = $this->invoicesModel->getInvoiceById($invid);
|
||||
$userid = $invoice['user_id'];
|
||||
$user = $this->usersModel->getUserById($userid);
|
||||
|
||||
if($ammount > 50){
|
||||
$this->usersModel->updateUser($userid, $userData = array('user_promised_pay' => 0));
|
||||
}
|
||||
|
||||
$wasteData = array(
|
||||
'user_id' => $userid,
|
||||
'waste_ammount' => $ammount,
|
||||
'waste_status' => 0,
|
||||
'waste_usluga' => "Пополнение баланса пользователя",
|
||||
);
|
||||
$this->wasteModel->createWaste($wasteData);
|
||||
|
||||
$this->usersModel->upUserBalance($userid, $ammount);
|
||||
|
||||
$bonus_percent = $this->config->bonus_percent;
|
||||
$getbonus = ($ammount * (1 + $bonus_percent / 100)) - $ammount;
|
||||
$this->usersModel->upUserBonuses($userid, $getbonus);
|
||||
|
||||
$this->invoicesModel->updateInvoice($invid, array('invoice_status' => 1));
|
||||
return "OK$invid\n";
|
||||
} else {
|
||||
return "Error: $errorPOST";
|
||||
}
|
||||
} else {
|
||||
return "Error: Invalid request!";
|
||||
}
|
||||
}
|
||||
|
||||
private function validatePOST() {
|
||||
$result = null;
|
||||
|
||||
$ammount = $this->request->post['amount'];
|
||||
$invid = $this->request->post['pay_id'];
|
||||
$signature = $this->request->post['sign'];
|
||||
|
||||
$login = $this->config->anypay_login;
|
||||
$password = $this->config->anypay_password;
|
||||
|
||||
if(!$this->invoicesModel->getTotalInvoices(array('invoice_id' => (int)$invid))) {
|
||||
$result = "Invalid invoice!";
|
||||
}
|
||||
elseif(strtoupper($signature) != strtoupper(md5("$login:$ammount:$invid:$password"))) {
|
||||
$result = "Invalid signature!";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class enotController extends Controller {
|
||||
public function index() {
|
||||
$this->load->model('users');
|
||||
$this->load->model('invoices');
|
||||
$this->load->model('waste');
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
$errorPOST = $this->validatePOST();
|
||||
if(!$errorPOST) {
|
||||
$ammount = $this->request->post['amount'];
|
||||
$invid = $this->request->post['merchant_id'];
|
||||
$signature = $this->request->post['sign_2'];
|
||||
|
||||
$invoice = $this->invoicesModel->getInvoiceById($invid);
|
||||
$userid = $invoice['user_id'];
|
||||
$user = $this->usersModel->getUserById($userid);
|
||||
|
||||
if($ammount > 50){
|
||||
$this->usersModel->updateUser($userid, $userData = array('user_promised_pay' => 0));
|
||||
}
|
||||
|
||||
$wasteData = array(
|
||||
'user_id' => $userid,
|
||||
'waste_ammount' => $ammount,
|
||||
'waste_status' => 0,
|
||||
'waste_usluga' => "Пополнение баланса пользователя",
|
||||
);
|
||||
$this->wasteModel->createWaste($wasteData);
|
||||
|
||||
$this->usersModel->upUserBalance($userid, $ammount);
|
||||
|
||||
$bonus_percent = $this->config->bonus_percent;
|
||||
$getbonus = ($ammount * (1 + $bonus_percent / 100)) - $ammount;
|
||||
$this->usersModel->upUserBonuses($userid, $getbonus);
|
||||
|
||||
$this->invoicesModel->updateInvoice($invid, array('invoice_status' => 1));
|
||||
return "OK$invid\n";
|
||||
} else {
|
||||
return "Error: $errorPOST";
|
||||
}
|
||||
} else {
|
||||
return "Error: Invalid request!";
|
||||
}
|
||||
}
|
||||
|
||||
private function validatePOST() {
|
||||
$result = null;
|
||||
|
||||
$ammount = $this->request->post['amount'];
|
||||
$invid = $this->request->post['merchant_id'];
|
||||
$signature = $this->request->post['sign_2'];
|
||||
|
||||
$login = $this->config->enot_login;
|
||||
$password2 = $this->config->enot_password2;
|
||||
|
||||
if(!$this->invoicesModel->getTotalInvoices(array('invoice_id' => (int)$invid))) {
|
||||
$result = "Invalid invoice!";
|
||||
}
|
||||
elseif(strtoupper($signature) != strtoupper(md5("$login:$ammount:$password2:$invid"))) {
|
||||
$result = "Invalid signature!";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class freekassaController extends Controller {
|
||||
public function index() {
|
||||
$this->load->model('users');
|
||||
$this->load->model('invoices');
|
||||
$this->load->model('waste');
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
$errorPOST = $this->validatePOST();
|
||||
if(!$errorPOST) {
|
||||
$ammount = $this->request->post['OutSum'];
|
||||
$invid = $this->request->post['InvId'];
|
||||
$signature = $this->request->post['SignatureValue'];
|
||||
|
||||
$invoice = $this->invoicesModel->getInvoiceById($invid);
|
||||
$userid = $invoice['user_id'];
|
||||
|
||||
if($ammount > 50){
|
||||
$this->usersModel->updateUser($userid, $userData = array('user_promised_pay' => 0));
|
||||
}
|
||||
|
||||
$wasteData = array(
|
||||
'user_id' => $userid,
|
||||
'waste_ammount' => $ammount,
|
||||
'waste_status' => 0,
|
||||
'waste_usluga' => "Пополнение баланса пользователя",
|
||||
);
|
||||
$this->wasteModel->createWaste($wasteData);
|
||||
|
||||
$this->usersModel->upUserBalance($userid, $ammount);
|
||||
|
||||
$bonus_percent = $this->config->bonus_percent;
|
||||
$getbonus = ($ammount * (1 + $bonus_percent / 100)) - $ammount;
|
||||
$this->usersModel->upUserBonuses($userid, $getbonus);
|
||||
|
||||
$this->invoicesModel->updateInvoice($invid, array('invoice_status' => 1));
|
||||
return "OK$invid\n";
|
||||
} else {
|
||||
return "Error: $errorPOST";
|
||||
}
|
||||
} else {
|
||||
return "Error: Invalid request!";
|
||||
}
|
||||
}
|
||||
|
||||
private function validatePOST() {
|
||||
$result = null;
|
||||
|
||||
$ammount = $this->request->post['OutSum'];
|
||||
$invid = $this->request->post['InvId'];
|
||||
$signature = $this->request->post['SignatureValue'];
|
||||
|
||||
$password2 = $this->config->fk_password2;
|
||||
|
||||
if(!$this->invoicesModel->getTotalInvoices(array('invoice_id' => (int)$invid))) {
|
||||
$result = "Invalid invoice!";
|
||||
}
|
||||
elseif(strtoupper($signature) != strtoupper(md5("$ammount:$invid:$password2"))) {
|
||||
|
||||
$result = "Invalid signature!";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class litekassaController extends Controller {
|
||||
public function index() {
|
||||
$this->load->model('users');
|
||||
$this->load->model('invoices');
|
||||
$this->load->model('waste');
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
$errorPOST = $this->validatePOST();
|
||||
if(!$errorPOST) {
|
||||
$ammount = $this->request->post['AMOUNT'];
|
||||
$invid = $this->request->post['ORDER_ID'];
|
||||
$signature = $this->request->post['SIGN'];
|
||||
|
||||
$invoice = $this->invoicesModel->getInvoiceById($invid);
|
||||
$userid = $invoice['user_id'];
|
||||
|
||||
if($ammount > 50){
|
||||
$this->usersModel->updateUser($userid, $userData = array('user_promised_pay' => 0));
|
||||
}
|
||||
|
||||
$wasteData = array(
|
||||
'user_id' => $userid,
|
||||
'waste_ammount' => $ammount,
|
||||
'waste_status' => 0,
|
||||
'waste_usluga' => "Пополнение баланса пользователя",
|
||||
);
|
||||
$this->wasteModel->createWaste($wasteData);
|
||||
|
||||
$this->usersModel->upUserBalance($userid, $ammount);
|
||||
|
||||
$bonus_percent = $this->config->bonus_percent;
|
||||
$getbonus = ($ammount * (1 + $bonus_percent / 100)) - $ammount;
|
||||
$this->usersModel->upUserBonuses($userid, $getbonus);
|
||||
|
||||
$this->invoicesModel->updateInvoice($invid, array('invoice_status' => 1));
|
||||
return "OK$invid\n";
|
||||
} else {
|
||||
return "Error: $errorPOST";
|
||||
}
|
||||
} else {
|
||||
return "Error: Invalid request!";
|
||||
}
|
||||
}
|
||||
|
||||
private function validatePOST() {
|
||||
$result = null;
|
||||
|
||||
$ammount = $this->request->post['AMOUNT'];
|
||||
$invid = $this->request->post['ORDER_ID'];
|
||||
$signature = $this->request->post['SIGN'];
|
||||
|
||||
$password = $this->config->lk_password;
|
||||
$login = $this->config->lk_login;
|
||||
|
||||
if(!$this->invoicesModel->getTotalInvoices(array('invoice_id' => (int)$invid))) {
|
||||
$result = "Invalid invoice!";
|
||||
}
|
||||
elseif(strtoupper($signature) != strtoupper(md5("$login:$ammount:$password:$invid"))) {
|
||||
|
||||
$result = "Invalid signature!";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class qiwiController extends Controller {
|
||||
public function index() {
|
||||
$this->load->model('users');
|
||||
$this->load->model('invoices');
|
||||
$this->load->model('waste');
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
$errorPOST = $this->validatePOST();
|
||||
if(!$errorPOST) {
|
||||
$jsonPaymentData = json_decode(file_get_contents('php://input'), true);
|
||||
$ammount = $jsonPaymentData['bill']['amount']['value'];
|
||||
$invid = $jsonPaymentData['bill']['billId'];
|
||||
$signature = $jsonPaymentData['bill']['siteId'];
|
||||
|
||||
$invoice = $this->invoicesModel->getInvoiceById($invid);
|
||||
$userid = $invoice['user_id'];
|
||||
$user = $this->usersModel->getUserById($userid);
|
||||
|
||||
if($ammount > 50){
|
||||
$this->usersModel->updateUser($userid, $userData = array('user_promised_pay' => 0));
|
||||
}
|
||||
|
||||
$wasteData = array(
|
||||
'user_id' => $userid,
|
||||
'waste_ammount' => $ammount,
|
||||
'waste_status' => 0,
|
||||
'waste_usluga' => "Пополнение баланса пользователя",
|
||||
);
|
||||
$this->wasteModel->createWaste($wasteData);
|
||||
|
||||
$this->usersModel->upUserBalance($userid, $ammount);
|
||||
|
||||
$bonus_percent = $this->config->bonus_percent;
|
||||
$getbonus = ($ammount * (1 + $bonus_percent / 100)) - $ammount;
|
||||
$this->usersModel->upUserBonuses($userid, $getbonus);
|
||||
|
||||
$this->invoicesModel->updateInvoice($invid, array('invoice_status' => 1));
|
||||
return "OK$invid\n";
|
||||
} else {
|
||||
return "Error: $errorPOST";
|
||||
}
|
||||
} else {
|
||||
return "Error: Invalid request!";
|
||||
}
|
||||
}
|
||||
|
||||
private function checkNotificationSignature($signature, array $notificationBody, $merchantSecret) {
|
||||
$notificationBody = array_replace_recursive(
|
||||
[
|
||||
'bill' => [
|
||||
'billId' => null,
|
||||
'amount' => [
|
||||
'value' => null,
|
||||
'currency' => null,
|
||||
],
|
||||
'siteId' => null,
|
||||
'status' => ['value' => null],
|
||||
],
|
||||
],
|
||||
$notificationBody
|
||||
);
|
||||
|
||||
$processedNotificationData = [
|
||||
'billId' => (string) $notificationBody['bill']['billId'],
|
||||
'amount.value' => number_format(round(floatval($notificationBody['bill']['amount']['value']), 2, PHP_ROUND_HALF_DOWN), 2, '.', ''),
|
||||
'amount.currency' => (string) $notificationBody['bill']['amount']['currency'],
|
||||
'siteId' => (string) $notificationBody['bill']['siteId'],
|
||||
'status' => (string) $notificationBody['bill']['status']['value'],
|
||||
];
|
||||
ksort($processedNotificationData);
|
||||
$processedNotificationDataKeys = join('|', $processedNotificationData);
|
||||
$hash = hash_hmac('SHA256', $processedNotificationDataKeys, $merchantSecret);
|
||||
|
||||
return $hash === $signature;
|
||||
}
|
||||
|
||||
private function validatePOST() {
|
||||
$result = null;
|
||||
|
||||
$jsonPaymentData = json_decode(file_get_contents('php://input'), true);
|
||||
$invid = $jsonPaymentData['bill']['billId'];
|
||||
$signature = array_key_exists('HTTP_X_API_SIGNATURE_SHA256', $_SERVER) ? stripslashes($this->request->server['HTTP_X_API_SIGNATURE_SHA256']) : '';
|
||||
|
||||
if(!$this->invoicesModel->getTotalInvoices(array('invoice_id' => (int)$invid))) {
|
||||
$result = "Invalid invoice!";
|
||||
}elseif(!$this->checkNotificationSignature($signature, $jsonPaymentData, $this->config->qiwisecretkey)) {
|
||||
$result = "Invalid signature!";
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class robokassaController extends Controller {
|
||||
public function index() {
|
||||
$this->load->model('users');
|
||||
$this->load->model('invoices');
|
||||
$this->load->model('waste');
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
$errorPOST = $this->validatePOST();
|
||||
if(!$errorPOST) {
|
||||
$ammount = $this->request->post['OutSum'];
|
||||
$invid = $this->request->post['InvId'];
|
||||
$signature = $this->request->post['SignatureValue'];
|
||||
|
||||
$invoice = $this->invoicesModel->getInvoiceById($invid);
|
||||
$userid = $invoice['user_id'];
|
||||
|
||||
if($ammount > 50){
|
||||
$this->usersModel->updateUser($userid, $userData = array('user_promised_pay' => 0));
|
||||
}
|
||||
|
||||
$wasteData = array(
|
||||
'user_id' => $userid,
|
||||
'waste_ammount' => $ammount,
|
||||
'waste_status' => 0,
|
||||
'waste_usluga' => "Пополнение баланса пользователя",
|
||||
);
|
||||
$this->wasteModel->createWaste($wasteData);
|
||||
|
||||
$this->usersModel->upUserBalance($userid, $ammount);
|
||||
|
||||
$bonus_percent = $this->config->bonus_percent;
|
||||
$getbonus = ($ammount * (1 + $bonus_percent / 100)) - $ammount;
|
||||
$this->usersModel->upUserBonuses($userid, $getbonus);
|
||||
|
||||
$this->invoicesModel->updateInvoice($invid, array('invoice_status' => 1));
|
||||
return "OK$invid\n";
|
||||
} else {
|
||||
return "Error: $errorPOST";
|
||||
}
|
||||
} else {
|
||||
return "Error: Invalid request!";
|
||||
}
|
||||
}
|
||||
|
||||
private function validatePOST() {
|
||||
$result = null;
|
||||
|
||||
$ammount = $this->request->post['OutSum'];
|
||||
$invid = $this->request->post['InvId'];
|
||||
$signature = $this->request->post['SignatureValue'];
|
||||
|
||||
$password2 = $this->config->rk_password2;
|
||||
|
||||
if(!$this->invoicesModel->getTotalInvoices(array('invoice_id' => (int)$invid))) {
|
||||
$result = "Invalid invoice!";
|
||||
}
|
||||
elseif(strtoupper($signature) != strtoupper(md5("$ammount:$invid:$password2"))) {
|
||||
|
||||
$result = "Invalid signature!";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class unitpayController extends Controller {
|
||||
public function index() {
|
||||
$this->load->model('users');
|
||||
$this->load->model('invoices');
|
||||
$this->load->model('waste');
|
||||
|
||||
error_reporting(0);
|
||||
function md5sign($params, $secretKey) {
|
||||
ksort($params);
|
||||
unset($params['sign']);
|
||||
|
||||
return md5(join(null, $params).$secretKey);
|
||||
}
|
||||
|
||||
function responseError($message) {
|
||||
$error = array(
|
||||
"jsonrpc" => "2.0",
|
||||
"error" => array(
|
||||
"code" => -32000,
|
||||
"message" => $message
|
||||
),
|
||||
'id' => 1
|
||||
);
|
||||
echo json_encode($error); exit();
|
||||
}
|
||||
|
||||
function responseSuccess($message) {
|
||||
$success = array(
|
||||
"jsonrpc" => "2.0",
|
||||
"result" => array(
|
||||
"message" => $message
|
||||
),
|
||||
'id' => 1
|
||||
);
|
||||
echo json_encode($success); exit();
|
||||
}
|
||||
|
||||
$secretKey = $this->config->unitpay_secret;
|
||||
$method = $_GET['method'];
|
||||
$params = $_GET['params'];
|
||||
|
||||
if ($params['sign'] != md5($params, $secretKey)) {
|
||||
responseError("Не соответсвие MD5 хешей");
|
||||
}
|
||||
|
||||
switch($method) {
|
||||
case 'check':
|
||||
if (!$this->link = @mysqli_connect($this->config->db_hostname, $this->config->db_username, $this->config->db_password, $this->config->database)) {
|
||||
die('Ошибка: Не удалось соединиться с сервером базы данных!');
|
||||
}
|
||||
break;
|
||||
case 'pay':
|
||||
if (!$this->link = @mysqli_connect($this->config->db_hostname, $this->config->db_username, $this->config->db_password, $this->config->database)) {
|
||||
die('Ошибка: Не удалось соединиться с сервером базы данных!');
|
||||
}
|
||||
|
||||
$invid = $_GET['params']['account'];
|
||||
|
||||
if(!$this->invoicesModel->getTotalInvoices(array('invoice_id' => (int)$invid))) {
|
||||
responseError("Invalid invoice!");
|
||||
}
|
||||
|
||||
$ammount = $_GET['params']['sum'];
|
||||
|
||||
$invoice = $this->invoicesModel->getInvoiceById($invid);
|
||||
$userid = $invoice['user_id'];
|
||||
$user = $this->usersModel->getUserById($userid);
|
||||
|
||||
if($invoice['invoice_ammount'] == $ammount){
|
||||
if($ammount > 50){
|
||||
$this->usersModel->updateUser($userid, $userData = array('user_promised_pay' => 0));
|
||||
}
|
||||
|
||||
$wasteData = array(
|
||||
'user_id' => $userid,
|
||||
'waste_ammount' => $ammount,
|
||||
'waste_status' => 0,
|
||||
'waste_usluga' => "Пополнение баланса пользователя",
|
||||
);
|
||||
$this->wasteModel->createWaste($wasteData);
|
||||
|
||||
$this->usersModel->upUserBalance($userid, $ammount);
|
||||
|
||||
$bonus_percent = $this->config->bonus_percent;
|
||||
$getbonus = ($ammount * (1 + $bonus_percent / 100)) - $ammount;
|
||||
$this->usersModel->upUserBonuses($userid, $getbonus);
|
||||
|
||||
$this->invoicesModel->updateInvoice($invid, array('invoice_status' => 1));
|
||||
}
|
||||
break;
|
||||
case 'error':
|
||||
responseError("Ошибка,{$params['errorMessage']}"); exit;
|
||||
break;
|
||||
default:
|
||||
responseError("Только: check, pay"); exit;
|
||||
}
|
||||
responseSuccess("Успех");
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class yandexkassaController extends Controller {
|
||||
public function index() {
|
||||
$this->load->model('users');
|
||||
$this->load->model('invoices');
|
||||
$this->load->model('waste');
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
$errorPOST = $this->validatePOST();
|
||||
if(!$errorPOST) {
|
||||
$ammount = $this->request->post['amount'];
|
||||
$invid = $this->request->post['label'];
|
||||
|
||||
$invoice = $this->invoicesModel->getInvoiceById($invid);
|
||||
$userid = $invoice['user_id'];
|
||||
|
||||
if($ammount > 50){
|
||||
$this->usersModel->updateUser($userid, $userData = array('user_promised_pay' => 0));
|
||||
}
|
||||
|
||||
$wasteData = array(
|
||||
'user_id' => $userid,
|
||||
'waste_ammount' => $ammount,
|
||||
'waste_status' => 0,
|
||||
'waste_usluga' => "Пополнение баланса пользователя",
|
||||
);
|
||||
$this->wasteModel->createWaste($wasteData);
|
||||
|
||||
$this->usersModel->upUserBalance($userid, $ammount);
|
||||
|
||||
$bonus_percent = $this->config->bonus_percent;
|
||||
$getbonus = ($ammount * (1 + $bonus_percent / 100)) - $ammount;
|
||||
$this->usersModel->upUserBonuses($userid, $getbonus);
|
||||
|
||||
$this->invoicesModel->updateInvoice($invid, array('invoice_status' => 1));
|
||||
return "OK$invid\n";
|
||||
} else {
|
||||
return "Error: $errorPOST";
|
||||
}
|
||||
} else {
|
||||
return "Error: Invalid request!";
|
||||
}
|
||||
}
|
||||
|
||||
private function validatePOST() {
|
||||
$result = null;
|
||||
|
||||
$ammount = $this->request->post['amount'];
|
||||
$invoiceid = $this->request->post['label'];
|
||||
$signature = $this->request->post['sha1_hash'];
|
||||
$notification_type = $this->request->post['notification_type'];
|
||||
$operation_id = $this->request->post['operation_id'];
|
||||
$amount = $this->request->post['amount'];
|
||||
$currency = $this->request->post['currency'];
|
||||
$datetime = $this->request->post['datetime'];
|
||||
$sender = $this->request->post['sender'];
|
||||
$codepro = $this->request->post['codepro'];
|
||||
$unaccepted = $this->request->post['unaccepted'];
|
||||
|
||||
$password = $this->config->yk_password1;
|
||||
|
||||
if(!$this->invoicesModel->getTotalInvoices(array('invoice_id' => (int)$invoiceid))) {
|
||||
$result = "Invalid invoice!";
|
||||
}elseif($signature != sha1($notification_type.'&'.$operation_id.'&'.$amount.'&'.$currency.'&'.$datetime.'&'.$sender.'&'.$codepro.'&'.$password.'&'.$invoiceid)) {
|
||||
$result = "Invalid signature!";
|
||||
}elseif($codepro === true) {
|
||||
$result = "Invalid codepro!";
|
||||
}elseif($unaccepted === true) {
|
||||
$result = "Invalid unaccepted!";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,260 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class autoinstallController extends Controller {
|
||||
public function index($serverid = null) {
|
||||
$this->document->setActiveSection('servers');
|
||||
$this->document->setActiveItem('autoinstall');
|
||||
$this->data['activesection'] = $this->document->getActiveSection();
|
||||
$this->data['activeitem'] = $this->document->getActiveItem();
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 0) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->model('servers');
|
||||
$this->load->model('users');
|
||||
|
||||
$error = $this->validate($serverid);
|
||||
if($error) {
|
||||
$this->session->data['error'] = $error;
|
||||
$this->response->redirect($this->config->url . 'servers/index');
|
||||
}
|
||||
|
||||
$userid = $this->user->getId();
|
||||
|
||||
$server = $this->serversModel->getServerById($serverid, array('games', 'locations'));
|
||||
$this->data['server'] = $server;
|
||||
|
||||
$mods = $this->serversModel->getMods(array('mod_status' => 1),array('games'),array(), array());
|
||||
$this->data['usermods'] = $this->usersModel->getUserMods($userid);
|
||||
$this->data['mods'] = $mods;
|
||||
|
||||
include_once 'application/controllers/common/main.php';
|
||||
|
||||
$this->getChild(array('common/header', 'common/footer'));
|
||||
return $this->load->view('servers/autoinstall', $this->data);
|
||||
}
|
||||
|
||||
public function action($serverid = null, $action = null) {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if($this->user->getAccessLevel() < 0) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
$userid = $this->user->getId();
|
||||
$this->load->model('servers');
|
||||
$this->load->library('ssh2');
|
||||
$this->load->model('users');
|
||||
$this->load->model('waste');
|
||||
$ssh2Lib = new ssh2Library();
|
||||
|
||||
$error = $this->validate($serverid);
|
||||
if($error) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $error;
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$error = $this->validateMode($action);
|
||||
if($error) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $error;
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$balance = $this->user->getBalance();
|
||||
$server = $this->serversModel->getServerById($serverid, array('users', 'locations', 'games'));
|
||||
|
||||
if($server['server_status'] == 3) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет установка сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 4) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет переустановка сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 5) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет создание BackUP сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 6) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет восстанновление сервера из BackUP!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 7) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет обновление сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server["server_status"] == 0) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Сервер заблокирован!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$mod = $this->serversModel->getModById($action);
|
||||
|
||||
if($mod["mod_status"] != 1) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Данный мод не доступен для установки!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
if($server['server_mysql'] == 0) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Создайте базу MySQL и включите ее!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
if($server['server_status'] != 1) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Сервер должен быть выключен!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$stats = $this->serversModel->getHDD($server['server_id']);
|
||||
if($stats > $server['game_ssd']) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Вы привысили ограничение размера директории на ". round($stats - $server['game_ssd'], 2) ."МБ, установка мода невозможна!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
$this->serversModel->deleteTask(array('task_name' => 'restart', 'server_id' => $serverid));
|
||||
$this->serversModel->deleteTask(array('task_name' => 'enable', 'server_id' => $serverid));
|
||||
$this->serversModel->deleteTask(array('task_name' => 'disable', 'server_id' => $serverid));
|
||||
if($mod['mod_price'] > 0) {
|
||||
if($this->usersModel->checkFreeMode($userid, $mod['mod_id'])){
|
||||
$free_mode = 1;
|
||||
}
|
||||
$price = $mod['mod_price'];
|
||||
if(($balance < $price) and $free_mode != 1){
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Недостаточно средств";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
}
|
||||
$this->serversModel->action($serverid, 'reinstall');
|
||||
$host = $server['location_ip'];
|
||||
$uname = "gs$serverid";
|
||||
$dbpass = $server['db_pass'];
|
||||
$database = "gs$serverid";
|
||||
$conn = new mysqli($host, $uname, $dbpass, $database);
|
||||
$op_data = '';
|
||||
if ($mresult = $conn->query("SHOW TABLES"))
|
||||
{
|
||||
while($row = $mresult->fetch_array(MYSQLI_NUM))
|
||||
{
|
||||
$conn->query('DROP TABLE IF EXISTS '.$row[0]);
|
||||
}
|
||||
}
|
||||
$FILE = "scriptfiles/mysql_settings.ini";
|
||||
$link = $ssh2Lib->connect($server['location_ip'], $server['location_user'], $server['location_password']);
|
||||
$ssh2Lib->execute($link,
|
||||
"
|
||||
cd /home/gs$serverid;
|
||||
rm server.cfg;
|
||||
rm -rf gamemodes;
|
||||
rm -rf filterscripts;
|
||||
rm -rf include;
|
||||
rm -rf npcmodes;
|
||||
rm -rf scriptfiles;
|
||||
wget ".$mod['mod_url'].";
|
||||
tar -xf ".$mod['mod_arch'].";
|
||||
rm ".$mod['mod_arch'].";
|
||||
mysql -h".$server['location_ip']." -u gs$serverid -p".$server['db_pass']." gs$serverid < dump.sql;
|
||||
rm dump.sql;
|
||||
echo 'host = ".$server['location_ip']."'>>".$FILE.";
|
||||
echo 'username = gs$serverid'>>".$FILE.";
|
||||
echo 'password = ".$server['db_pass']."'>>".$FILE.";
|
||||
echo 'database = gs$serverid'>>".$FILE.";
|
||||
sudo chown -R gs". $server['server_id'] .":gameservers /home/gs". $server['server_id'] ."
|
||||
"
|
||||
);
|
||||
$ssh2Lib->disconnect($link);
|
||||
if($mod['mod_price'] > 0) {
|
||||
if($free_mode != 1){
|
||||
$userid = $this->user->getId();
|
||||
$wasteData = array(
|
||||
'user_id' => $userid,
|
||||
'waste_ammount' => $price,
|
||||
'waste_status' => 1,
|
||||
'waste_usluga' => "Установка мода ".$mod['mod_name'].""
|
||||
);
|
||||
$this->wasteModel->createWaste($wasteData);
|
||||
$this->usersModel->downUserBalance($userid, $price);
|
||||
$freeData = array(
|
||||
'user_id' => $userid,
|
||||
'mod_id' => "".$mod['mod_id'].""
|
||||
);
|
||||
$this->usersModel->addMode($freeData);
|
||||
|
||||
$user = $this->usersModel->getUserById($userid, array(), array(), array());
|
||||
|
||||
if($user['ref'] != 0) {
|
||||
$ref_percent = $this->config->ref_percent;
|
||||
$getpref = ($price * (1 + $ref_percent / 100)) - $price;
|
||||
$this->usersModel->upUserBalance($user['ref'], $getpref);
|
||||
$this->usersModel->upUserRMoney($user['ref'], $getpref);
|
||||
|
||||
$wasteData = array(
|
||||
'user_id' => $user['ref'],
|
||||
'waste_ammount' => $getpref,
|
||||
'waste_status' => 0,
|
||||
'waste_usluga' => "Бонус с реферала ID-$userid"
|
||||
);
|
||||
$this->wasteModel->createWaste($wasteData);
|
||||
}
|
||||
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Мод ".$mod['mod_name']." успешно был установлен,с вашего счёта снято ".$mod['mod_price']." р! Запускаем игровой сервер, пожалуйста, подождите...";
|
||||
} else{
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Мод ".$mod['mod_name']." успешно был установлен. Запускаем игровой сервер, пожалуйста, подождите...";
|
||||
}
|
||||
} else {
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Мод ".$mod['mod_name']." успешно был установлен. Запускаем игровой сервер, пожалуйста, подождите...";
|
||||
}
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Не POST запрос!";
|
||||
}
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
private function validate($serverid) {
|
||||
$result = null;
|
||||
|
||||
$userid = $this->user->getId();
|
||||
|
||||
if(!$this->serversModel->getTotalServerOwners(array('server_id' => (int)$serverid, 'user_id' => (int)$userid, 'owner_status' => 1))) {
|
||||
if(!$this->serversModel->getTotalServers(array('server_id' => (int)$serverid, 'user_id' => (int)$userid))) {
|
||||
$result = "Запрашиваемый сервер не существует!";
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function validateMode($modid) {
|
||||
$result = null;
|
||||
|
||||
if(!$this->serversModel->getTotalMods(array('mod_id' => (int)$modid))) {
|
||||
$result = "Запрашиваемый мод не существует!";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,168 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class configController extends Controller {
|
||||
public function index($serverid = null) {
|
||||
$this->document->setActiveSection('servers');
|
||||
$this->document->setActiveItem('config');
|
||||
$this->data['activesection'] = $this->document->getActiveSection();
|
||||
$this->data['activeitem'] = $this->document->getActiveItem();
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
|
||||
if($this->user->getAccessLevel() < 0) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->model('servers');
|
||||
|
||||
$error = $this->validate($serverid);
|
||||
if($error) {
|
||||
$this->session->data['error'] = $error;
|
||||
$this->response->redirect($this->config->url . 'servers/index');
|
||||
}
|
||||
|
||||
$server = $this->serversModel->getServerById($serverid, array('games', 'locations'));
|
||||
$this->data['server'] = $server;
|
||||
|
||||
if($server['server_status'] == 1 || $server['server_status'] == 2) {
|
||||
if($server['game_query'] == 'samp') {
|
||||
$file = "/server.cfg";
|
||||
} else if($server['game_query'] == 'mtasa') {
|
||||
$file = "/mods/deathmatch/mtaserver.conf";
|
||||
} else if($server['game_code'] == 'cs') {
|
||||
$file = "/cstrike/server.cfg";
|
||||
} else if($server['game_code'] == 'css') {
|
||||
$file = "/cstrike/cfg/server.cfg";
|
||||
} else if($server['game_code'] == 'csgo') {
|
||||
$file = "/csgo/cfg/server.cfg";
|
||||
} else if($server['game_query'] == 'mine') {
|
||||
$file = "/server.properties";
|
||||
} else if($server['game_code'] == 'ragemp') {
|
||||
$file = "/conf.json";
|
||||
}
|
||||
|
||||
$this->load->library('sftp');
|
||||
$sftpLib = new sftpLibrary();
|
||||
$sftpLink = $sftpLib->connect($server['location_ip'], $server['location_user'], $server['location_password']);
|
||||
$config = $sftpLib->open($sftpLink, '/home/gs' . $serverid . '/' . $file);
|
||||
$this->data['config'] = $config;
|
||||
} else {
|
||||
$config = "В данном статусе не доступно редактирование конфигурации!";
|
||||
$this->data['config'] = $config;
|
||||
}
|
||||
|
||||
include_once 'application/controllers/common/main.php';
|
||||
|
||||
$this->getChild(array('common/header', 'common/footer'));
|
||||
return $this->load->view('servers/config', $this->data);
|
||||
}
|
||||
|
||||
public function send_config($serverid = null)
|
||||
{
|
||||
if (!$this->user->isLogged()) {
|
||||
$this->data['status'] = 'error';
|
||||
$this->data['error'] = 'Вы не авторизированы!';
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
if ($this->user->getAccessLevel() < 0) {
|
||||
$this->data['status'] = 'error';
|
||||
$this->data['error'] = 'У вас нет доступа к данному разделу!';
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$this->load->model('servers');
|
||||
|
||||
$error = $this->validate($serverid);
|
||||
if($error) {
|
||||
$this->session->data['error'] = $error;
|
||||
$this->response->redirect($this->config->url . 'servers/index');
|
||||
}
|
||||
|
||||
$server = $this->serversModel->getServerById($serverid, array('users', 'locations', 'games'));
|
||||
|
||||
if($server['server_status'] == 3) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет установка сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 4) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет переустановка сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 5) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет создание BackUP сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 6) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет восстанновление сервера из BackUP!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 7) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет обновление сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server["server_status"] == 0) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Сервер заблокирован!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
if($server['server_status'] == 1 || $server['server_status'] == 2) {
|
||||
$config = htmlspecialchars_decode($this->request->post['config']);
|
||||
if($server['game_query'] == 'samp') {
|
||||
$file = "/server.cfg";
|
||||
} else if($server['game_query'] == 'mtasa') {
|
||||
$file = "/mods/deathmatch/mtaserver.conf";
|
||||
} else if($server['game_code'] == 'cs') {
|
||||
$file = "/cstrike/server.cfg";
|
||||
} else if($server['game_code'] == 'css') {
|
||||
$file = "/cstrike/cfg/server.cfg";
|
||||
} else if($server['game_code'] == 'csgo') {
|
||||
$file = "/csgo/cfg/server.cfg";
|
||||
} else if($server['game_query'] == 'mine') {
|
||||
$file = "/server.properties";
|
||||
} else if($server['game_code'] == 'ragemp') {
|
||||
$file = "/conf.json";
|
||||
}
|
||||
|
||||
$this->load->library('sftp');
|
||||
$sftpLib = new sftpLibrary();
|
||||
$sftpLink = $sftpLib->connect($server['location_ip'], $server['location_user'], $server['location_password']);
|
||||
$sftpLib->write($sftpLink, '/home/gs' . $serverid . '/' . $file, $config);
|
||||
$this->data['status'] = 'success';
|
||||
$this->data['success'] = 'Конфигурационный файл отредактирован!';
|
||||
}
|
||||
}
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
function validate($serverid) {
|
||||
$result = null;
|
||||
$this->user->getId( );
|
||||
$userid = $this->user->getId();
|
||||
|
||||
if(!$this->serversModel->getTotalServerOwners(array('server_id' => (int)$serverid, 'user_id' => (int)$userid, 'owner_status' => 1))) {
|
||||
if(!$this->serversModel->getTotalServers(array('server_id' => (int)$serverid, 'user_id' => (int)$userid))) {
|
||||
$result = "Запрашиваемый сервер не существует!";
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function validatePOST() {
|
||||
|
||||
$this->load->library('validate');
|
||||
|
||||
$validateLib = new validateLibrary();
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,371 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class consoleController extends Controller {
|
||||
public function index($serverid = null) {
|
||||
$this->document->setActiveSection('servers');
|
||||
$this->document->setActiveItem('console');
|
||||
$this->data['activesection'] = $this->document->getActiveSection();
|
||||
$this->data['activeitem'] = $this->document->getActiveItem();
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 0) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
if(isset($this->request->get['open'])) {
|
||||
$this->data['fileid'] = $this->request->get['open'];
|
||||
}
|
||||
|
||||
$this->load->model('servers');
|
||||
|
||||
$error = $this->validate($serverid);
|
||||
if($error) {
|
||||
$this->session->data['error'] = $error;
|
||||
$this->response->redirect($this->config->url . 'servers/index');
|
||||
}
|
||||
|
||||
$server = $this->serversModel->getServerById($serverid, array('games', 'locations'));
|
||||
$this->data['server'] = $server;
|
||||
|
||||
if(isset($_COOKIE["data-theme-console"])){
|
||||
$this->data['theme'] = $_COOKIE['data-theme-console'];
|
||||
} else{
|
||||
$this->data['theme'] = "color: white; background-color: black; font-family: Inconsolata; resize: none; min-height: 300px;";
|
||||
}
|
||||
|
||||
include_once 'application/controllers/common/main.php';
|
||||
|
||||
$this->getChild(array('common/header', 'common/footer'));
|
||||
return $this->load->view('servers/console', $this->data);
|
||||
}
|
||||
|
||||
public function getconsole($serverid = null, $file = null) {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if($this->user->getAccessLevel() < 1) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$this->load->model('servers');
|
||||
$this->load->library('ssh2');
|
||||
|
||||
$server = $this->serversModel->getServerById($serverid, array('games', 'locations'));
|
||||
|
||||
$error = $this->validate($serverid);
|
||||
if($error) {
|
||||
$this->session->data['error'] = $error;
|
||||
$this->response->redirect($this->config->url . 'servers/index');
|
||||
}
|
||||
|
||||
switch($file) {
|
||||
default: {
|
||||
if($server["game_query"] == "samp") {
|
||||
$fileLog = "server_log.txt";
|
||||
} elseif($server["game_query"] == "mtasa") {
|
||||
$fileLog = "mods/deathmatch/logs/server.log";
|
||||
} elseif($server["game_code"] == "mcpe") {
|
||||
$fileLog = "server.log";
|
||||
} else {
|
||||
$fileLog = "screenlog.0";
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'screenlog': {
|
||||
$fileLog = "screenlog.0";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if($server['server_status'] == 3) {
|
||||
$result = "Идет установка сервера!";
|
||||
} else if($server['server_status'] == 4) {
|
||||
$result = "Идет переустановка сервера!";
|
||||
} else if($server['server_status'] == 5) {
|
||||
$result = "Идет создание BackUP сервера!";
|
||||
} else if($server['server_status'] == 6) {
|
||||
$result = "Идет восстанновление сервера из BackUP!";
|
||||
} else if($server['server_status'] == 7) {
|
||||
$result = "Идет обновление сервера!";
|
||||
} else if($server["server_status"] == 0) {
|
||||
$result = "Сервер заблокирован!";
|
||||
} else if($server["server_status"] == 1) {
|
||||
$result = "Сервер должен быть включен!";
|
||||
} else if($server["server_status"] == 2) {
|
||||
$ssh = new ssh2Library();
|
||||
$connect = $ssh->connect($server['location_ip'], $server['location_user'], $server['location_password']);
|
||||
if($server["game_query"] == "ragemp" || $server["game_query"] == "valve") {
|
||||
$logs = $ssh->execute($connect, "tail -n 500 /home/gs" . $serverid . "/" . $fileLog. " | iconv -t utf8");
|
||||
} else {
|
||||
$logs = $ssh->execute($connect, "tail -n 500 /home/gs" . $serverid . "/" . $fileLog. " | iconv -f cp1251 -t utf8");
|
||||
}
|
||||
$logs = str_replace("", "", $logs);
|
||||
$logs = str_replace(">[2K", "", $logs);
|
||||
$logs = str_replace(">", "", $logs);
|
||||
$logs = str_replace("[1mnull[22m", "", $logs);
|
||||
if(!empty($logs)) {
|
||||
$result = $logs;
|
||||
} else {
|
||||
$result = 'Список логов пуст :(';
|
||||
}
|
||||
$ssh->disconnect($connect);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function sendconsole($serverid = null) {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if($this->user->getAccessLevel() < 1) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$this->load->model('servers');
|
||||
$this->load->library('ssh2');
|
||||
|
||||
$server = $this->serversModel->getServerById($serverid, array('games', 'locations'));
|
||||
|
||||
$error = $this->validate($serverid);
|
||||
if($error) {
|
||||
$this->session->data['error'] = $error;
|
||||
$this->response->redirect($this->config->url . 'servers/index');
|
||||
}
|
||||
|
||||
if($server['server_status'] == 3) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет установка сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 4) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет переустановка сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 5) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет создание BackUP сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 6) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет восстанновление сервера из BackUP!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 7) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет обновление сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server["server_status"] == 0) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Сервер заблокирован!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$command = @$this->request->post['cmd'];
|
||||
|
||||
if($server['server_status'] == 2){
|
||||
if($command == ""){
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Введите команду!";
|
||||
}elseif($command != ""){
|
||||
if($server['game_query'] == "samp") {
|
||||
$this->load->library('SampRconAPI');
|
||||
$SampRcon = new SampRconAPI($server['location_ip'], $server['server_port'], $server['rcon_password']);
|
||||
if ($SampRcon->connect()) {
|
||||
$SampRcon->call($command, false);
|
||||
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Команда успешно отправлена!";
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Ошибка подключения к rcon!";
|
||||
}
|
||||
$SampRcon->close();
|
||||
} else {
|
||||
$exec = str_replace("'", "'", $command);
|
||||
$this->serversModel->action($serverid, 'sendcommand', array('command' => $exec));
|
||||
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Команда успешно отправлена!";
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Сервер должен быть включён!";
|
||||
}
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
public function clearcon($serverid = null) {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if($this->user->getAccessLevel() < 1) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$this->load->model('servers');
|
||||
$this->load->library('ssh2');
|
||||
|
||||
$server = $this->serversModel->getServerById($serverid, array('games','locations'));
|
||||
|
||||
$error = $this->validate($serverid);
|
||||
if($error) {
|
||||
$this->session->data['error'] = $error;
|
||||
$this->response->redirect($this->config->url . 'servers/index');
|
||||
}
|
||||
|
||||
if($server['server_status'] == 3) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет установка сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 4) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет переустановка сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 5) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет создание BackUP сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 6) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет восстанновление сервера из BackUP!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 7) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет обновление сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server["server_status"] == 0) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Сервер заблокирован!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
if($server['server_status'] == 2) {
|
||||
$ssh2Lib = new ssh2Library();
|
||||
$link = $ssh2Lib->connect($server['location_ip'], $server['location_user'], $server['location_password']);
|
||||
if($server['game_query'] == 'samp') {
|
||||
$ssh2Lib->execute($link, "cat /dev/null > /home/gs$serverid/server_log.txt;");
|
||||
$ssh2Lib->execute($link, "cat /dev/null > /home/gs$serverid/screenlog.0;");
|
||||
} elseif($server['game_code'] == 'mcpe') {
|
||||
$ssh2Lib->execute($link, "cat /dev/null > /home/gs$serverid/server.log;");
|
||||
} elseif($server['game_query'] == 'mtasa') {
|
||||
$ssh2Lib->execute($link, "cat /dev/null > /home/gs$serverid/mods/deathmatch/logs/server.log;");
|
||||
} else {
|
||||
$ssh2Lib->execute($link, "cat /dev/null > /home/gs$serverid/screenlog.0;");
|
||||
}
|
||||
$ssh2Lib->disconnect($link);
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Консоль успешно очищена!";
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Сервер должен быть включен!";
|
||||
}
|
||||
}
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
public function action_theme_console($action = null) {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if($this->user->getAccessLevel() < 1) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
switch($action) {
|
||||
case 'default': {
|
||||
$name = 'color: white; background-color: black; font-family: Inconsolata; resize: none; min-height: 300px;';
|
||||
setcookie('data-theme-console',$name,time() + (86400 * 5), '/' );
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Тема установлена!";
|
||||
break;
|
||||
}
|
||||
case 'Amethyst': {
|
||||
$name = 'color: #323e42; background-color: #a48ad4; font-family: Inconsolata; resize: none; min-height: 300px;';
|
||||
setcookie('data-theme-console',$name,time() + (86400 * 5), '/' );
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Тема установлена!";
|
||||
break;
|
||||
}
|
||||
case 'City': {
|
||||
$name = 'color: #323e42; background-color: #ff6b6b; font-family: Inconsolata; resize: none; min-height: 300px;';
|
||||
setcookie('data-theme-console',$name,time() + (86400 * 5), '/' );
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Тема установлена!";
|
||||
break;
|
||||
}
|
||||
case 'Flat': {
|
||||
$name = 'color: #323e42; background-color: #44b4a6; font-family: Inconsolata; resize: none; min-height: 300px;';
|
||||
setcookie('data-theme-console',$name,time() + (86400 * 5), '/' );
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Тема установлена!";
|
||||
break;
|
||||
}
|
||||
case 'Modern': {
|
||||
$name = 'color: #323e42; background-color: #14adc4; font-family: Inconsolata; resize: none; min-height: 300px;';
|
||||
setcookie('data-theme-console',$name,time() + (86400 * 5), '/' );
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Тема установлена!";
|
||||
break;
|
||||
}
|
||||
case 'Smooth': {
|
||||
$name = 'color: #323e42; background-color: #ff6c9d; font-family: Inconsolata; resize: none; min-height: 300px;';
|
||||
setcookie('data-theme-console',$name,time() + (86400 * 5), '/' );
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Тема установлена!";
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы выбрали несуществующее действие!";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
function validate($serverid) {
|
||||
$result = null;
|
||||
$this->user->getId( );
|
||||
$userid = $this->user->getId();
|
||||
|
||||
if(!$this->serversModel->getTotalServerOwners(array('server_id' => (int)$serverid, 'user_id' => (int)$userid, 'owner_status' => 1))) {
|
||||
if(!$this->serversModel->getTotalServers(array('server_id' => (int)$serverid, 'user_id' => (int)$userid))) {
|
||||
$result = "Запрашиваемый сервер не существует!";
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function validatePOST() {
|
||||
$this->load->library('validate');
|
||||
|
||||
$validateLib = new validateLibrary();
|
||||
|
||||
$result = null;
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,233 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class firewallController extends Controller {
|
||||
public function index($serverid = null) {
|
||||
$this->document->setActiveSection('servers');
|
||||
$this->document->setActiveItem('firewall');
|
||||
$this->data['activesection'] = $this->document->getActiveSection();
|
||||
$this->data['activeitem'] = $this->document->getActiveItem();
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
|
||||
if($this->user->getAccessLevel() < 0) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->model('servers');
|
||||
|
||||
$error = $this->validate($serverid);
|
||||
if($error) {
|
||||
$this->session->data['error'] = $error;
|
||||
$this->response->redirect($this->config->url . 'servers/index');
|
||||
}
|
||||
|
||||
$this->data['server'] = $this->serversModel->getServerById($serverid, array('games', 'locations'));
|
||||
$this->data['Firewalls'] = $this->serversModel->getFirewallsById($serverid);
|
||||
|
||||
include_once 'application/controllers/common/main.php';
|
||||
|
||||
$this->getChild(array('common/header', 'common/footer'));
|
||||
return $this->load->view('servers/firewall', $this->data);
|
||||
}
|
||||
|
||||
public function ajax($serverid = null) {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
if($this->user->getAccessLevel() < 1) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$this->load->model('servers');
|
||||
|
||||
$server = $this->serversModel->getServerById($serverid);
|
||||
|
||||
$error = $this->validate($serverid);
|
||||
if($error) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $error;
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
if($server['server_status'] == 3) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет установка сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 4) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет переустановка сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 5) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет создание BackUP сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 6) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет восстанновление сервера из BackUP!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 7) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет обновление сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server["server_status"] == 0) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Сервер заблокирован!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
$ipmask = @$this->request->post['address'];
|
||||
|
||||
if (!$ipmask) {
|
||||
$this->data['status'] = 'error';
|
||||
$this->data['error'] = 'Вы не ввели IP';
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$ip = explode('/', $ipmask)[0];
|
||||
$net = explode('/', $ipmask)[1];
|
||||
|
||||
if (($ipmask !== str_replace('/', '', $ipmask)) && !$net) {
|
||||
$this->data['status'] = 'error';
|
||||
$this->data['error'] = 'Не введены данные после "/"';
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
if (!filter_var($ip, FILTER_VALIDATE_IP)) {
|
||||
$this->data['status'] = 'error';
|
||||
$this->data['error'] = 'Введен неверный IP';
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if ($net) {
|
||||
if (is_numeric($net)) {
|
||||
if (2 < mb_strlen($net)) {
|
||||
$this->data['status'] = 'error';
|
||||
$this->data['error'] = 'Не больше двух цифр после "/"';
|
||||
return json_encode($this->data);
|
||||
|
||||
if (!filter_var($net, FILTER_VALIDATE_IP)) {
|
||||
$this->data['status'] = 'error';
|
||||
$this->data['error'] = 'Введены неверные данные после "/"';
|
||||
return json_encode($this->data);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$this->data['status'] = 'error';
|
||||
$this->data['error'] = 'Введены неверные данные после "/"';
|
||||
return json_encode($this->data);
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->serversModel->getTotalFirewalls(array('server_ip' => $ipmask, 'server_id' => $serverid))) {
|
||||
$this->data['status'] = 'error';
|
||||
$this->data['error'] = 'Данное правило уже добавлено!';
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$firewallData = array(
|
||||
'server_id' => $serverid,
|
||||
'server_ip' => $ipmask
|
||||
);
|
||||
$firewallid = $this->serversModel->createFirewall($firewallData);
|
||||
|
||||
$this->serversModel->addFirewall($firewallid);
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Вы успешно заблокировали ".$ipmask."!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
}
|
||||
|
||||
public function action($action = null, $serverid = null, $firewallid = null) {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if($this->user->getAccessLevel() < 1) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$this->load->model('servers');
|
||||
|
||||
$server = $this->serversModel->getServerById($serverid);
|
||||
|
||||
$error = $this->validate($serverid);
|
||||
if($error) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $error;
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
if($server['server_status'] == 3) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет установка сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 4) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет переустановка сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 5) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет создание BackUP сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 6) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет восстанновление сервера из BackUP!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 7) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет обновление сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server["server_status"] == 0) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Сервер заблокирован!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
switch($action) {
|
||||
case 'delete': {
|
||||
$this->serversModel->deleteFirewall($firewallid);
|
||||
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Вы успешно разблокировали IP!";
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы выбрали несуществующее действие!";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
private function validate($serverid) {
|
||||
$result = null;
|
||||
$userid = $this->user->getId();
|
||||
|
||||
if(!$this->serversModel->getTotalServerOwners(array('server_id' => (int)$serverid, 'user_id' => (int)$userid, 'owner_status' => 1))) {
|
||||
if(!$this->serversModel->getTotalServers(array('server_id' => (int)$serverid, 'user_id' => (int)$userid))) {
|
||||
$result = "Запрашиваемый сервер не существует!";
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,344 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class ftpController extends Controller {
|
||||
public function index($serverid = null) {
|
||||
$this->document->setActiveSection('servers');
|
||||
$this->document->setActiveItem('ftp');
|
||||
$this->data['activesection'] = $this->document->getActiveSection();
|
||||
$this->data['activeitem'] = $this->document->getActiveItem();
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
|
||||
if($this->user->getAccessLevel() < 0) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->model('servers');
|
||||
|
||||
$error = $this->validate($serverid);
|
||||
if($error) {
|
||||
$this->session->data['error'] = $error;
|
||||
$this->response->redirect($this->config->url . 'servers/index');
|
||||
}
|
||||
|
||||
$server = $this->serversModel->getServerById($serverid, array('games', 'locations'));
|
||||
$this->data['server'] = $server;
|
||||
|
||||
if(isset($_COOKIE["data-theme-ftp"])){
|
||||
$this->data['theme'] = $_COOKIE['data-theme-ftp'];
|
||||
} else{
|
||||
$this->data['theme'] = "/application/public/css/elfinderT/default/css/theme.css";
|
||||
}
|
||||
|
||||
include_once 'application/controllers/common/main.php';
|
||||
|
||||
$this->getChild(array('common/header', 'common/footer'));
|
||||
return $this->load->view('servers/ftp', $this->data);
|
||||
}
|
||||
|
||||
public function ajax($serverid = null) {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if($this->user->getAccessLevel() < 1) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
$this->load->model('servers');
|
||||
$server = $this->serversModel->getServerById($serverid, array('games', 'locations'));
|
||||
|
||||
$error = $this->validate($serverid);
|
||||
if($error) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $error;
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
if($server['server_status'] == 3) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет установка сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 4) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет переустановка сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 5) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет создание BackUP сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 6) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет восстанновление сервера из BackUP!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 7) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет обновление сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server["server_status"] == 0) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Сервер заблокирован!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
$errorPOST = $this->validatePOST();
|
||||
if(!$errorPOST) {
|
||||
$editpassword = @$this->request->post['editpassword'];
|
||||
$password = @$this->request->post['password'];
|
||||
if($editpassword) {
|
||||
$this->serversModel->updateServer($serverid, array('server_password' => $password));
|
||||
$result = $this->serversModel->action($serverid, "updatepass");
|
||||
if($result["status"] == "success") {
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Пароль FTP успешно изменен!!";
|
||||
} else {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = $result["description"];
|
||||
}
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Ошибка!";
|
||||
}
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $errorPOST;
|
||||
}
|
||||
}
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
public function action_theme_ftp($action = null) {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
if($this->user->getAccessLevel() < 1) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$this->load->model('servers');
|
||||
|
||||
switch($action) {
|
||||
case 'default': {
|
||||
$name = '/application/public/css/elfinderT/default/css/theme.css';
|
||||
setcookie('data-theme-ftp',$name,time() + (86400 * 5), '/' );
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Тема Default успешно установлена!";
|
||||
break;
|
||||
}
|
||||
case 'material': {
|
||||
$name = '/application/public/css/elfinderT/Material/css/theme.css';
|
||||
setcookie('data-theme-ftp',$name,time() + (86400 * 5), '/' );
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Тема Material успешно установлена!";
|
||||
break;
|
||||
}
|
||||
case 'materialgray': {
|
||||
$name = '/application/public/css/elfinderT/Material/css/theme-gray.css';
|
||||
setcookie('data-theme-ftp',$name,time() + (86400 * 5), '/' );
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Тема Material gray успешно установлена!";
|
||||
break;
|
||||
}
|
||||
case 'materiallight': {
|
||||
$name = '/application/public/css/elfinderT/Material/css/theme-light.css';
|
||||
setcookie('data-theme-ftp',$name,time() + (86400 * 5), '/' );
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Тема Material light успешно установлена!";
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы выбрали несуществующее действие!";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
private function validate($serverid) {
|
||||
$result = null;
|
||||
|
||||
$userid = $this->user->getId();
|
||||
|
||||
if(!$this->serversModel->getTotalServerOwners(array('server_id' => (int)$serverid, 'user_id' => (int)$userid, 'owner_status' => 1))) {
|
||||
if(!$this->serversModel->getTotalServers(array('server_id' => (int)$serverid, 'user_id' => (int)$userid))) {
|
||||
$result = "Запрашиваемый сервер не существует!";
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getftp($serverid = null) {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 0) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->model('servers');
|
||||
|
||||
$error = $this->validate($serverid);
|
||||
if($error) {
|
||||
$this->session->data['error'] = $error;
|
||||
$this->response->redirect($this->config->url . 'servers/index');
|
||||
}
|
||||
|
||||
$server = $this->serversModel->getServerById($serverid, array('games', 'locations'));
|
||||
|
||||
if($server['server_status'] == 3) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет установка сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 4) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет переустановка сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 5) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет создание BackUP сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 6) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет восстанновление сервера из BackUP!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 7) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет обновление сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server["server_status"] == 0) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Сервер заблокирован!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
include_once ENGINE_DIR . 'engine_ftp/elFinderConnector.class.php';
|
||||
include_once ENGINE_DIR . 'engine_ftp/elFinder.class.php';
|
||||
include_once ENGINE_DIR . 'engine_ftp/elFinderVolumeDriver.class.php';
|
||||
include_once ENGINE_DIR . 'engine_ftp/elFinderVolumeLocalFileSystem.class.php';
|
||||
include_once ENGINE_DIR . 'engine_ftp/elFinderVolumeFTP.class.php';
|
||||
|
||||
function access($attr, $path, $data, $volume) {
|
||||
return strpos(basename($path), '.') === 0
|
||||
? !($attr == 'read' || $attr == 'write')
|
||||
: null;
|
||||
}
|
||||
|
||||
function logger($cmd, $result, $args, $elfinder) {
|
||||
$log = sprintf('[%s] %s:', date('r'), strtoupper($cmd));
|
||||
foreach ($result as $key => $value) {
|
||||
if (empty($value)) {
|
||||
continue;
|
||||
}
|
||||
$data = array();
|
||||
if (in_array($key, array('error', 'warning'))) {
|
||||
array_push($data, implode(' ', $value));
|
||||
} else {
|
||||
if (is_array($value)) {
|
||||
foreach ($value as $file) {
|
||||
$filepath = (isset($file['realpath']) ? $file['realpath'] : $elfinder->realpath($file['hash']));
|
||||
array_push($data, $filepath);
|
||||
}
|
||||
} else {
|
||||
array_push($data, $value);
|
||||
}
|
||||
}
|
||||
$log .= sprintf(' %s(%s)', $key, implode(', ', $data));
|
||||
}
|
||||
$log .= "\n";
|
||||
|
||||
$logfile = 'files/log.txt';
|
||||
$dir = dirname($logfile);
|
||||
if (!is_dir($dir) && !mkdir($dir)) {
|
||||
return;
|
||||
}
|
||||
if (($fp = fopen($logfile, 'a'))) {
|
||||
fwrite($fp, $log);
|
||||
fclose($fp);
|
||||
}
|
||||
}
|
||||
|
||||
$opts = array(
|
||||
'roots' => array(
|
||||
array(
|
||||
'driver' => 'FTP',
|
||||
'URL' => 'ftp://gs'.$server['server_id'].':'.$server['server_password'].'@'.$server['location_ip'].':21/',
|
||||
'host' => $server['location_ip'],
|
||||
'user' => 'gs'.$server['server_id'],
|
||||
'pass' => $server['server_password'],
|
||||
'port' => 21,
|
||||
'mode' => 'passive',
|
||||
'path' => '/',
|
||||
'read' => true,
|
||||
'write' => true,
|
||||
'utf8fix' => true,
|
||||
'bind' => array(
|
||||
'mkdir mkfile rename duplicate upload rm paste' => 'logger'
|
||||
),
|
||||
'rootAlias'=>'Server Root',
|
||||
'fileURL'=>True,
|
||||
'dotFiles'=>True,
|
||||
'dirSize'=>True,
|
||||
'fileMode'=>0644,
|
||||
'dirMode'=>0775,
|
||||
'imgLib'=>False,
|
||||
'tmbDir'=>'.tmb',
|
||||
'tmbAtOnce'=>5,
|
||||
'debug'=>True
|
||||
),
|
||||
'attributes' => array(
|
||||
array(
|
||||
'pattern' => '~/\.~',
|
||||
'read' => true,
|
||||
'write' => true,
|
||||
'hidden' => true
|
||||
),
|
||||
|
||||
)
|
||||
)
|
||||
);
|
||||
$connector = new elFinderConnector(new elFinder($opts));
|
||||
$connector->run();
|
||||
}
|
||||
|
||||
private function validatePOST() {
|
||||
$this->load->library('validate');
|
||||
|
||||
$validateLib = new validateLibrary();
|
||||
|
||||
$result = null;
|
||||
|
||||
$editpassword = @$this->request->post['editpassword'];
|
||||
$password = @$this->request->post['password'];
|
||||
$password2 = @$this->request->post['password2'];
|
||||
if($editpassword) {
|
||||
if(!$validateLib->password($password)) {
|
||||
$result = "Пароль должен содержать от 6 до 32 латинских букв, цифр и знаков <i>,.!?_-</i>!";
|
||||
}
|
||||
elseif($password != $password2) {
|
||||
$result = "Введенные вами пароли не совпадают!";
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,208 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class indexController extends Controller {
|
||||
private $limit = 10;
|
||||
public function index($page = 1) {
|
||||
$this->document->setActiveSection('servers');
|
||||
$this->document->setActiveItem('index');
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 0) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->library('pagination');
|
||||
$this->load->model('servers');
|
||||
|
||||
$userid = $this->user->getId();
|
||||
|
||||
$options = array(
|
||||
'start' => ($page - 1) * $this->limit,
|
||||
'limit' => $this->limit
|
||||
);
|
||||
|
||||
$this->data['servers'] = $this->serversModel->getServers(array('user_id' => (int)$userid), array('games', 'locations'), array(), $options);
|
||||
$this->data['serversOwners'] = $this->serversModel->getOwners(array('servers_owners.user_id' => $userid), array('servers', 'games', 'locations'));
|
||||
|
||||
$paginationLib = new paginationLibrary();
|
||||
|
||||
$paginationLib->total = $this->serversModel->getTotalServers(array('user_id' => (int)$userid));
|
||||
$paginationLib->page = $page;
|
||||
$paginationLib->limit = $this->limit;
|
||||
$paginationLib->url = $this->config->url . 'servers/index/index/{page}';
|
||||
|
||||
$this->data['pagination'] = $paginationLib->render();
|
||||
|
||||
$this->getChild(array('common/header', 'common/footer'));
|
||||
return $this->load->view('servers/index', $this->data);
|
||||
}
|
||||
|
||||
public function action($serverid = null, $action = null) {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if($this->user->getAccessLevel() < 1) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$this->load->model('servers');
|
||||
|
||||
$error = $this->validate($serverid);
|
||||
if($error) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $error;
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$server = $this->serversModel->getServerById($serverid, array('users', 'locations', 'games'));
|
||||
|
||||
if($server['server_status'] == 3) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет установка сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 4) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет переустановка сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 5) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет создание BackUP сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 6) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет восстанновление сервера из BackUP!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 7) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет обновление сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server["server_status"] == 0) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Сервер заблокирован!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
switch($action) {
|
||||
case "start": {
|
||||
if($server["server_status"] == 1) {
|
||||
$stats = $this->serversModel->getHDD($server['server_id']);
|
||||
if((int)$stats < $server['game_ssd']) {
|
||||
$result = $this->serversModel->action($serverid, 'start');
|
||||
if($result["status"] == "success") {
|
||||
$this->serversModel->deleteTask(array('task_name' => 'enable', 'server_id' => $serverid));
|
||||
$this->serversModel->updateServer($serverid, array("server_status" => 2));
|
||||
$logData = array(
|
||||
'server_id' => $serverid,
|
||||
'reason' => 'Успешный запуск сервера',
|
||||
'status' => 1
|
||||
);
|
||||
$this->serversModel->createLog($logData);
|
||||
$this->data["status"] = "success";
|
||||
$this->data["success"] = "Вы успешно запустили сервер!";
|
||||
} else {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = $result["description"];
|
||||
}
|
||||
} else {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Вы привысили ограничение размера директории на ". round($stats - $server['game_ssd'], 2) ."МБ, запуск сервера невозможен!";
|
||||
}
|
||||
} else {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Сервер должен быть выключен!";
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case "restart": {
|
||||
if($server["server_status"] == 2) {
|
||||
$stats = $this->serversModel->getHDD($server['server_id']);
|
||||
if((int)$stats < $server['game_ssd']) {
|
||||
$result = $this->serversModel->action($serverid, 'restart');
|
||||
if($result["status"] == "success") {
|
||||
$this->serversModel->deleteTask(array('task_name' => 'restart', 'server_id' => $serverid));
|
||||
$logData = array(
|
||||
'server_id' => $serverid,
|
||||
'reason' => 'Успешный перезапуск сервера',
|
||||
'status' => 1
|
||||
);
|
||||
$this->serversModel->createLog($logData);
|
||||
$this->data["status"] = "success";
|
||||
$this->data["success"] = "Вы успешно перезапустили сервер!";
|
||||
} else {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = $result["description"];
|
||||
}
|
||||
} else {
|
||||
$result = $this->serversModel->action($serverid, 'stop');
|
||||
if($result['status'] == "success") {
|
||||
$this->serversModel->updateServer($serverid, array('server_status' => 1));
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Вы привысили ограничение размера директории на ". round($stats - $server['game_ssd'], 2) ."МБ, перезагрузка сервера невозможна!";
|
||||
} else {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = $result["description"];
|
||||
}
|
||||
}
|
||||
} else if($server["server_status"] == 2) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Сервер должен быть включен!";
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case "stop": {
|
||||
if($server["server_status"] == 2) {
|
||||
$result = $this->serversModel->action($serverid, 'stop');
|
||||
if($result["status"] == "success") {
|
||||
$this->serversModel->deleteTask(array('task_name' => 'disable', 'server_id' => $serverid));
|
||||
$this->serversModel->deleteTask(array('task_name' => 'restart', 'server_id' => $serverid));
|
||||
$this->serversModel->updateServer($serverid, array("server_status" => 1));
|
||||
$logData = array(
|
||||
'server_id' => $serverid,
|
||||
'reason' => 'Успешное выключение сервера',
|
||||
'status' => 1
|
||||
);
|
||||
$this->serversModel->createLog($logData);
|
||||
$this->data["status"] = "success";
|
||||
$this->data["success"] = "Вы успешно выключили сервер!";
|
||||
} else {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = $result["description"];
|
||||
}
|
||||
} else {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Сервер должен быть вылючен!";
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
private function validate($serverid) {
|
||||
$result = null;
|
||||
|
||||
$userid = $this->user->getId();
|
||||
|
||||
if(!$this->serversModel->getTotalServerOwners(array('server_id' => (int)$serverid, 'user_id' => (int)$userid, 'owner_status' => 1))) {
|
||||
if(!$this->serversModel->getTotalServers(array('server_id' => (int)$serverid, 'user_id' => (int)$userid))) {
|
||||
$result = "Запрашиваемый сервер не существует!";
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,246 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class mysqlController extends Controller {
|
||||
public function index($serverid = null) {
|
||||
$this->document->setActiveSection('servers');
|
||||
$this->document->setActiveItem('mysql');
|
||||
$this->data['activesection'] = $this->document->getActiveSection();
|
||||
$this->data['activeitem'] = $this->document->getActiveItem();
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 0) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->model('servers');
|
||||
|
||||
$error = $this->validate($serverid);
|
||||
if($error) {
|
||||
$this->session->data['error'] = $error;
|
||||
$this->response->redirect($this->config->url . 'servers/index');
|
||||
}
|
||||
|
||||
$server = $this->serversModel->getServerById($serverid, array('games', 'locations'));
|
||||
$this->data['server'] = $server;
|
||||
|
||||
include_once 'application/controllers/common/main.php';
|
||||
|
||||
$this->getChild(array('common/header', 'common/footer'));
|
||||
return $this->load->view('servers/mysql', $this->data);
|
||||
}
|
||||
|
||||
public function action($serverid = null, $action = null) {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
if($this->user->getAccessLevel() < 0) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$this->load->model('servers');
|
||||
|
||||
$error = $this->validate($serverid);
|
||||
if($error) {
|
||||
$this->session->data['error'] = $error;
|
||||
$this->response->redirect($this->config->url . 'servers/index');
|
||||
}
|
||||
|
||||
$server = $this->serversModel->getServerById($serverid);
|
||||
|
||||
if($server['server_status'] == 3) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет установка сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 4) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет переустановка сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 5) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет создание BackUP сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 6) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет восстанновление сервера из BackUP!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 7) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет обновление сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server["server_status"] == 0) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Сервер заблокирован!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
switch($action) {
|
||||
case 'mysqlon': {
|
||||
if($server['server_mysql'] == 2) {
|
||||
$this->serversModel->updateServer($serverid, array('server_mysql' => 1));
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Вы успешно включили базу данных gs$serverid!";
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "База данных и так включена либо вы ее еще не создали!";
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'mysqloff': {
|
||||
if($server['server_mysql'] == 1) {
|
||||
$this->serversModel->updateServer($serverid, array('server_mysql' => 2));
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Вы успешно выключили базу данных gs$serverid!";
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "База данных и так выключена!";
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'mysqlcr': {
|
||||
if($server['server_mysql'] == 0) {
|
||||
$result = $this->serversModel->action($serverid, 'create_mysql');
|
||||
if($result["status"] == "success") {
|
||||
$this->serversModel->updateServer($serverid, array('server_mysql' => 2));
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Вы успешно создали базу данных gs$serverid!";
|
||||
} else {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = $result["description"];
|
||||
}
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "База данных и так создана!";
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы выбрали несуществующее действие!";
|
||||
break;
|
||||
}
|
||||
}
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
|
||||
private function validate($serverid) {
|
||||
$result = null;
|
||||
|
||||
$userid = $this->user->getId();
|
||||
|
||||
if(!$this->serversModel->getTotalServerOwners(array('server_id' => (int)$serverid, 'user_id' => (int)$userid, 'owner_status' => 1))) {
|
||||
if(!$this->serversModel->getTotalServers(array('server_id' => (int)$serverid, 'user_id' => (int)$userid))) {
|
||||
$result = "Запрашиваемый сервер не существует!";
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function ajax($serverid = null) {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if($this->user->getAccessLevel() < 1) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
$this->load->model('servers');
|
||||
$server = $this->serversModel->getServerById($serverid, array('games', 'locations'));
|
||||
|
||||
$error = $this->validate($serverid);
|
||||
if($error) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $error;
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
if($server['server_status'] == 3) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет установка сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 4) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет переустановка сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 5) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет создание BackUP сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 6) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет восстанновление сервера из BackUP!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 7) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет обновление сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server["server_status"] == 0) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Сервер заблокирован!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
$errorPOST = $this->validatePOST();
|
||||
if(!$errorPOST) {
|
||||
$editpassword = @$this->request->post['editpassword'];
|
||||
$password = @$this->request->post['password'];
|
||||
if($editpassword) {
|
||||
$this->serversModel->updateServer($serverid, array('db_pass' => $password));
|
||||
$result = $this->serversModel->action($serverid, "updatepassm");
|
||||
if($result["status"] == "success") {
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Пароль MySql успешно изменен!!";
|
||||
} else {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = $result["description"];
|
||||
}
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Ошибка!";
|
||||
}
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $errorPOST;
|
||||
}
|
||||
}
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
private function validatePOST() {
|
||||
$this->load->library('validate');
|
||||
|
||||
$validateLib = new validateLibrary();
|
||||
|
||||
$result = null;
|
||||
|
||||
$editpassword = @$this->request->post['editpassword'];
|
||||
$password = @$this->request->post['password'];
|
||||
$password2 = @$this->request->post['password2'];
|
||||
if($editpassword) {
|
||||
if(!$validateLib->password($password)) {
|
||||
$result = "Пароль должен содержать от 6 до 32 латинских букв, цифр и знаков <i>,.!?_-</i>!";
|
||||
}
|
||||
elseif($password != $password2) {
|
||||
$result = "Введенные вами пароли не совпадают!";
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,281 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class orderController extends Controller {
|
||||
public function index() {
|
||||
$this->data['serv_test'] = $this->config->serv_test;
|
||||
$this->document->setActiveSection('servers');
|
||||
$this->document->setActiveItem('order');
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 0) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->model('games');
|
||||
$this->load->model('locations');
|
||||
|
||||
$games = $this->gamesModel->getGames(array('game_status' => 1));
|
||||
$locations = $this->locationsModel->getLocations(array('location_status' => 1));
|
||||
|
||||
$this->data['games'] = $games;
|
||||
$this->data['locations'] = $locations;
|
||||
|
||||
$this->getChild(array('common/header', 'common/footer'));
|
||||
return $this->load->view('servers/order', $this->data);
|
||||
}
|
||||
|
||||
public function promo() {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if($this->user->getAccessLevel() < 1) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$this->load->model('users');
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
$code = $this->request->post['code'];
|
||||
$skidka = $this->usersModel->getSkidkaByCode($code, false);
|
||||
$kofficent=(100-$skidka['skidka'])/100;
|
||||
if($skidka['skidka'] == NULL){
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Данного кода не существует";
|
||||
}else{
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Вы активировали скидку ".$skidka['skidka']."%";
|
||||
$this->data['skidka'] = $kofficent;
|
||||
}
|
||||
}
|
||||
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
public function ajax() {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
if($this->user->getAccessLevel() < 1) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$this->load->model('waste');
|
||||
$this->load->model('users');
|
||||
$this->load->model('games');
|
||||
$this->load->model('locations');
|
||||
$this->load->model('servers');
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
$errorPOST = $this->validatePOST();
|
||||
if(!$errorPOST) {
|
||||
$gameid = $this->request->post['gameid'];
|
||||
$locationid = $this->request->post['locationid'];
|
||||
$slots = $this->request->post['slots'];
|
||||
$days = $this->request->post['days'];
|
||||
$password = $this->request->post['password'];
|
||||
|
||||
$location = $this->locationsModel->getLocationById($locationid);
|
||||
$location_games = explode(" ", $location['location_games']);
|
||||
|
||||
if(!in_array($gameid, $location_games)) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Данная игра не доступна для указанной локации!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
|
||||
$userid = $this->user->getId();
|
||||
$balance = $this->user->getBalance();
|
||||
$firstname = $this->user->getFirstname();
|
||||
$lastname = $this->user->getLastname();
|
||||
$email = $this->user->getEmail();
|
||||
$test_server = $this->user->getTest_server();
|
||||
|
||||
$game = $this->gamesModel->getGameById($gameid);
|
||||
$port = $this->serversModel->getServerNewPort($locationid, $game['game_min_port'], $game['game_max_port']);
|
||||
$user = $this->usersModel->getUserById($userid, array(), array(), array());
|
||||
$code = $this->request->post['promo'];
|
||||
$skidka = $this->usersModel->getSkidkaByCode($code,true);$kofficent=(100-$skidka['skidka'])/100;
|
||||
if($port) {
|
||||
$price = $slots * $game['game_price'];
|
||||
|
||||
switch($days) {
|
||||
case "0":
|
||||
$test_periud = true;
|
||||
break;
|
||||
case "15":
|
||||
$price = $price / 2;
|
||||
$test_periud = false;
|
||||
break;
|
||||
case "30":
|
||||
$test_periud = false;
|
||||
break;
|
||||
case "60":
|
||||
$price = $price * 2;
|
||||
$test_periud = false;
|
||||
break;
|
||||
case "90":
|
||||
$price = 3 * $price * 0.95;
|
||||
$test_periud = false;
|
||||
break;
|
||||
case "180":
|
||||
$price = 6 * $price * 0.90;
|
||||
$test_periud = false;
|
||||
break;
|
||||
case "360":
|
||||
$price = 12 * $price * 0.85;
|
||||
$test_periud = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if($skidka['skidka'] != NULL){
|
||||
$price = $price * $kofficent;
|
||||
}
|
||||
if($test_periud == true){
|
||||
if($this->config->serv_test == 1) {
|
||||
if($test_server == 1){
|
||||
$serverData = array(
|
||||
'user_id' => $userid,
|
||||
'game_id' => $gameid,
|
||||
'location_id' => $locationid,
|
||||
'server_mysql' => 0,
|
||||
'server_slots' => $slots,
|
||||
'server_port' => $port,
|
||||
'server_password' => $password,
|
||||
'server_status' => 3,
|
||||
'test_periud' => $test_periud,
|
||||
'server_days' => $days
|
||||
);
|
||||
|
||||
$serverid = $this->serversModel->createServer($serverData);
|
||||
$this->usersModel->downUserBalance($userid, $price);
|
||||
$wasteData = array(
|
||||
'user_id' => $userid,
|
||||
'waste_ammount' => $price,
|
||||
'waste_status' => 1,
|
||||
'waste_usluga' => "Заказ тестового сервера gs$serverid"
|
||||
);
|
||||
$this->wasteModel->createWaste($wasteData);
|
||||
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Сервер успешно поставлен в очередь на установку.";
|
||||
$this->data['id'] = $serverid;
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы уже брали тестовый период, либо у вас нет одобрения администратора!";
|
||||
}
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Тестовый период отключен на хостинге!";
|
||||
}
|
||||
}elseif($balance >= $price AND $test_periud == false) {
|
||||
$serverData = array(
|
||||
'user_id' => $userid,
|
||||
'game_id' => $gameid,
|
||||
'location_id' => $locationid,
|
||||
'server_mysql' => 0,
|
||||
'server_slots' => $slots,
|
||||
'server_port' => $port,
|
||||
'server_password' => $password,
|
||||
'server_status' => 3,
|
||||
'test_periud' => $test_periud,
|
||||
'server_days' => $days
|
||||
);
|
||||
|
||||
$serverid = $this->serversModel->createServer($serverData);
|
||||
$this->usersModel->downUserBalance($userid, $price);
|
||||
$wasteData = array(
|
||||
'user_id' => $userid,
|
||||
'waste_ammount' => $price,
|
||||
'waste_status' => 1,
|
||||
'waste_usluga' => "Заказ сервера gs$serverid"
|
||||
);
|
||||
$this->wasteModel->createWaste($wasteData);
|
||||
|
||||
if($user['ref'] != 0) {
|
||||
$ref_percent = $this->config->ref_percent;
|
||||
$getpref = ($price * (1 + $ref_percent / 100)) - $price;
|
||||
$this->usersModel->upUserBalance($user['ref'], $getpref);
|
||||
$this->usersModel->upUserRMoney($user['ref'], $getpref);
|
||||
|
||||
$wasteData = array(
|
||||
'user_id' => $user['ref'],
|
||||
'waste_ammount' => $getpref,
|
||||
'waste_status' => 0,
|
||||
'waste_usluga' => "Бонус с реферала ID-$userid"
|
||||
);
|
||||
$this->wasteModel->createWaste($wasteData);
|
||||
}
|
||||
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Сервер успешно поставлен в очередь на установку.";
|
||||
$this->data['id'] = $serverid;
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "На Вашем счету недостаточно средств";
|
||||
}
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "На выбранной Вами локации нет свободных портов для данной игры";
|
||||
}
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $errorPOST;
|
||||
}
|
||||
}
|
||||
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
private function validatePOST() {
|
||||
$this->load->library('validate');
|
||||
|
||||
$validateLib = new validateLibrary();
|
||||
|
||||
$result = null;
|
||||
|
||||
$gameid = @$this->request->post['gameid'];
|
||||
$locationid = @$this->request->post['locationid'];
|
||||
$slots = @$this->request->post['slots'];
|
||||
$days = @$this->request->post['days'];
|
||||
$password = @$this->request->post['password'];
|
||||
$password2 = @$this->request->post['password2'];
|
||||
|
||||
if(!$this->gamesModel->getTotalGames(array('game_id' => (int)$gameid, 'game_status' => 1))) {
|
||||
$result = "Вы указали несуществующую игру!";
|
||||
}
|
||||
elseif(!$this->locationsModel->getTotalLocations(array('location_id' => (int)$locationid, 'location_status' => 1))) {
|
||||
$result = "Вы указали несуществующую локацию!";
|
||||
}
|
||||
elseif($days != "30" && $days != "60" && $days != "90" && $days != "180" && $days != "360" && $days != "15" && $days != "0") {
|
||||
$result = "Вы указали недопустимый период оплаты!";
|
||||
}
|
||||
elseif(!$this->gamesModel->validateSlots($gameid, $slots)) {
|
||||
$result = "Вы указали недопустимое количество слотов!";
|
||||
}
|
||||
elseif(!$validateLib->password($password)) {
|
||||
$result = "Пароль должен содержать от 6 до 32 латинских букв, цифр и знаков <i>,.!?_-</i>!";
|
||||
}
|
||||
elseif($password != $password2) {
|
||||
$result = "Введенные вами пароли не совпадают!";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,210 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class ownerController extends Controller {
|
||||
public function index($serverid = null) {
|
||||
$this->document->setActiveSection('servers');
|
||||
$this->document->setActiveItem('owner');
|
||||
$this->data['activesection'] = $this->document->getActiveSection();
|
||||
$this->data['activeitem'] = $this->document->getActiveItem();
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
|
||||
if($this->user->getAccessLevel() < 0) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->model('servers');
|
||||
|
||||
$error = $this->validate($serverid);
|
||||
if($error) {
|
||||
$this->session->data['error'] = $error;
|
||||
$this->response->redirect($this->config->url . 'servers/index');
|
||||
}
|
||||
|
||||
$this->data['server'] = $this->serversModel->getServerById($serverid, array('games', 'locations'));
|
||||
$this->data['serversOwners'] = $this->serversModel->getOwners(array('server_id' => $serverid), array('users'));
|
||||
|
||||
include_once 'application/controllers/common/main.php';
|
||||
|
||||
$this->getChild(array('common/header', 'common/footer'));
|
||||
return $this->load->view('servers/owner', $this->data);
|
||||
}
|
||||
|
||||
public function create($serverid = null) {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
if($this->user->getAccessLevel() < 1) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$this->load->model('users');
|
||||
$this->load->model('servers');
|
||||
|
||||
$server = $this->serversModel->getServerById($serverid);
|
||||
|
||||
$error = $this->validate($serverid);
|
||||
if($error) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $error;
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
if($server['server_status'] == 3) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет установка сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 4) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет переустановка сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 5) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет создание BackUP сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 6) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет восстанновление сервера из BackUP!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 7) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет обновление сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server["server_status"] == 0) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Сервер заблокирован!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
if(!$this->validatePOST($serverid)) {
|
||||
$ownerid = @$this->request->post['ownerid'];
|
||||
|
||||
$ownerData = array(
|
||||
'server_id' => $serverid,
|
||||
'user_id' => $ownerid,
|
||||
'owner_status' => 1
|
||||
);
|
||||
$this->serversModel->createOwner($ownerData);
|
||||
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Вы успешно добавили друга!";
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $this->validatePOST($serverid);
|
||||
}
|
||||
}
|
||||
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
|
||||
public function delete($serverid = null, $ownerid = null) {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
if($this->user->getAccessLevel() < 1) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$this->load->model('users');
|
||||
$this->load->model('servers');
|
||||
|
||||
$server = $this->serversModel->getServerById($serverid);
|
||||
|
||||
$error = $this->validate($serverid);
|
||||
if($error) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $error;
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
if($server['server_status'] == 3) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет установка сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 4) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет переустановка сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 5) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет создание BackUP сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 6) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет восстанновление сервера из BackUP!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 7) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет обновление сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server["server_status"] == 0) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Сервер заблокирован!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
if($this->serversModel->getTotalServerOwners(array('server_id' => $serverid, 'owner_id' => $ownerid))) {
|
||||
$this->serversModel->deleteOwner($ownerid);
|
||||
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Вы успешно удалили друга!";
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Ошибка!";
|
||||
}
|
||||
}
|
||||
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
private function validate($serverid) {
|
||||
$result = null;
|
||||
$userid = $this->user->getId();
|
||||
|
||||
if (!$this->serversModel->getTotalServers( array( 'server_id' => (int)$serverid, 'user_id' => (int)$userid ) )) {
|
||||
$result = 'Вы не являетесь владельцем сервера. У вас нет доступа к разделу!';
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function validatePOST($serverid) {
|
||||
$result = null;
|
||||
$this->load->library('validate');
|
||||
|
||||
$validateLib = new validateLibrary();
|
||||
$ownerid = @$this->request->post['ownerid'];
|
||||
$userid = $this->user->getId();
|
||||
|
||||
if(!$validateLib->money($ownerid)) {
|
||||
$result = "Вы указали недоступный ID пользователя!";
|
||||
}elseif(!$this->usersModel->getTotalUsers(array('user_id' => $ownerid))) {
|
||||
$result = "Запрашиваемый пользователь не существует!";
|
||||
}elseif($this->serversModel->getTotalServerOwners(array('server_id' => $serverid, 'user_id' => $ownerid))) {
|
||||
$result = "Запрашиваемый пользователь уже добавлен!";
|
||||
}elseif($userid == $ownerid) {
|
||||
$result = "Запрашиваемый пользователь является владельцем сервера!";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,183 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class repoController extends Controller {
|
||||
public function index($serverid = null) {
|
||||
$this->document->setActiveSection('servers');
|
||||
$this->document->setActiveItem('repo');
|
||||
$this->data['activesection'] = $this->document->getActiveSection();
|
||||
$this->data['activeitem'] = $this->document->getActiveItem();
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 0) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->model('servers');
|
||||
$this->load->model('users');
|
||||
|
||||
$error = $this->validate($serverid);
|
||||
if($error) {
|
||||
$this->session->data['error'] = $error;
|
||||
$this->response->redirect($this->config->url . 'servers/index');
|
||||
}
|
||||
|
||||
$userid = $this->user->getId();
|
||||
|
||||
$server = $this->serversModel->getServerById($serverid, array('games', 'locations'));
|
||||
$this->data['server'] = $server;
|
||||
|
||||
$repos = $this->serversModel->getRepos(array('repo_status' => 1),array('games'),array(), array());
|
||||
$this->data['userrepos'] = $this->usersModel->getUserRepos($userid);
|
||||
$this->data['repos'] = $repos;
|
||||
|
||||
include_once 'application/controllers/common/main.php';
|
||||
|
||||
$this->getChild(array('common/header', 'common/footer'));
|
||||
return $this->load->view('servers/repo', $this->data);
|
||||
}
|
||||
|
||||
public function action($serverid = null, $action = null) {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if($this->user->getAccessLevel() < 0) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
$userid = $this->user->getId();
|
||||
$this->load->model('servers');
|
||||
$this->load->model('users');
|
||||
$this->load->model('waste');
|
||||
|
||||
$error = $this->validate($serverid);
|
||||
if($error) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $error;
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$error = $this->validateRepo($action);
|
||||
if($error) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $error;
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$balance = $this->user->getBalance();
|
||||
$server = $this->serversModel->getServerById($serverid, array('users', 'locations', 'games'));
|
||||
|
||||
if($server['server_status'] == 3) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет установка сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 4) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет переустановка сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 5) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет создание BackUP сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 6) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет восстанновление сервера из BackUP!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 7) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет обновление сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server["server_status"] == 0) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Сервер заблокирован!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$repo = $this->serversModel->getRepoById($action);
|
||||
|
||||
if($repo["repo_status"] != 1) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Данный файл не доступен!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
$price = $repo['repo_price'];
|
||||
if($balance < $price){
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Недостаточно средств";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
$userid = $this->user->getId();
|
||||
$wasteData = array(
|
||||
'user_id' => $userid,
|
||||
'waste_ammount' => $price,
|
||||
'waste_status' => 1,
|
||||
'waste_usluga' => "Покупка файла ".$repo['repo_id'].""
|
||||
);
|
||||
$this->wasteModel->createWaste($wasteData);
|
||||
$this->usersModel->downUserBalance($userid, $price);
|
||||
$freeData = array(
|
||||
'user_id' => $userid,
|
||||
'repo_id' => "".$repo['repo_id'].""
|
||||
);
|
||||
$this->usersModel->addRepos($freeData);
|
||||
|
||||
$user = $this->usersModel->getUserById($userid, array(), array(), array());
|
||||
|
||||
if($user['ref'] != 0) {
|
||||
$ref_percent = $this->config->ref_percent;
|
||||
$getpref = ($price * (1 + $ref_percent / 100)) - $price;
|
||||
$this->usersModel->upUserBalance($user['ref'], $getpref);
|
||||
$this->usersModel->upUserRMoney($user['ref'], $getpref);
|
||||
|
||||
$wasteData = array(
|
||||
'user_id' => $user['ref'],
|
||||
'waste_ammount' => $getpref,
|
||||
'waste_status' => 0,
|
||||
'waste_usluga' => "Бонус с реферала ID-$userid"
|
||||
);
|
||||
$this->wasteModel->createWaste($wasteData);
|
||||
}
|
||||
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Файл ".$repo['repo_name']." успешно был приобретен, с вашего счёта снято ".$repo['repo_price']." р!";
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Не POST запрос!";
|
||||
}
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
private function validate($serverid) {
|
||||
$result = null;
|
||||
|
||||
$userid = $this->user->getId();
|
||||
|
||||
if(!$this->serversModel->getTotalServerOwners(array('server_id' => (int)$serverid, 'user_id' => (int)$userid, 'owner_status' => 1))) {
|
||||
if(!$this->serversModel->getTotalServers(array('server_id' => (int)$serverid, 'user_id' => (int)$userid))) {
|
||||
$result = "Запрашиваемый сервер не существует!";
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function validateRepo($repoid) {
|
||||
$result = null;
|
||||
|
||||
if(!$this->serversModel->getRepoById(array('repo_id' => (int)$repoid))) {
|
||||
$result = "Запрашиваемый файл не существует!";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class statisticsController extends Controller {
|
||||
public function index($serverid = null) {
|
||||
$this->document->setActiveSection('servers');
|
||||
$this->document->setActiveItem('statistic');
|
||||
$this->data['activesection'] = $this->document->getActiveSection();
|
||||
$this->data['activeitem'] = $this->document->getActiveItem();
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 0) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->model('servers');
|
||||
|
||||
$error = $this->validate($serverid);
|
||||
if($error) {
|
||||
$this->session->data['error'] = $error;
|
||||
$this->response->redirect($this->config->url . 'servers/index');
|
||||
}
|
||||
|
||||
$server = $this->serversModel->getServerById($serverid, array('games', 'locations'));
|
||||
$logs = $this->serversModel->getLogs(array(), array('servers'), array(), array());
|
||||
$stats = $this->serversModel->getServerStats($serverid, "NOW() - INTERVAL 31 DAY", "NOW()");
|
||||
|
||||
$this->data['server'] = $server;
|
||||
$this->data['logs'] = $logs;
|
||||
$this->data['stats'] = $stats;
|
||||
|
||||
include_once 'application/controllers/common/main.php';
|
||||
|
||||
$this->getChild(array('common/header', 'common/footer'));
|
||||
return $this->load->view('servers/statistics', $this->data);
|
||||
}
|
||||
|
||||
public function getData($serverid = null) {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 0) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->model('servers');
|
||||
$this->load->library('query');
|
||||
|
||||
$error = $this->validate($serverid);
|
||||
if($error) {
|
||||
$this->session->data['error'] = $error;
|
||||
$this->response->redirect($this->config->url . 'servers/index');
|
||||
}
|
||||
|
||||
$server = $this->serversModel->getServerById($serverid, array('games', 'locations'));
|
||||
|
||||
if($server['server_status'] == 2) {
|
||||
$queryLib = new queryLibrary($server['game_query']);
|
||||
$queryLib->connect($server['location_ip'], $server['server_port']);
|
||||
$query = $queryLib->getInfo();
|
||||
$queryLib->disconnect();
|
||||
|
||||
$sysload = $this->serversModel->getServerSystemLoad($serverid);
|
||||
$ssd = round($sysload['ssd']);
|
||||
$ssd_all = $server['game_ssd'];
|
||||
$this->data['ssd'] = (int)(($ssd * 100) / $ssd_all);
|
||||
$this->data['cpu'] = $sysload['cpu'] > 100 ? 100 : round($sysload['cpu']);
|
||||
$this->data['ram'] = $sysload['ram'] > 100 ? 100 : round($sysload['ram']);
|
||||
$this->data['players'] = $query['players'];
|
||||
} else if($server['server_status'] == 3 || $server['server_status'] == 4) {
|
||||
$this->data['ssd'] = 'N/A';
|
||||
$this->data['cpu'] = 'N/A';
|
||||
$this->data['ram'] = 'N/A';
|
||||
$this->data['players'] = 'N/A';
|
||||
} else {
|
||||
$ssd = $this->serversModel->getHDD($serverid);
|
||||
$ssd = round($ssd);
|
||||
$ssd_all = $server['game_ssd'];
|
||||
$this->data['ssd'] = (int)(($ssd * 100) / $ssd_all);
|
||||
$this->data['cpu'] = 0;
|
||||
$this->data['ram'] = 0;
|
||||
$this->data['players'] = 0;
|
||||
}
|
||||
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
private function validate($serverid) {
|
||||
$result = null;
|
||||
|
||||
$userid = $this->user->getId();
|
||||
|
||||
if(!$this->serversModel->getTotalServerOwners(array('server_id' => (int)$serverid, 'user_id' => (int)$userid, 'owner_status' => 1))) {
|
||||
if(!$this->serversModel->getTotalServers(array('server_id' => (int)$serverid, 'user_id' => (int)$userid))) {
|
||||
$result = "Запрашиваемый сервер не существует!";
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,216 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class tasksController extends Controller {
|
||||
public function index($serverid = null) {
|
||||
$this->document->setActiveSection('servers');
|
||||
$this->document->setActiveItem('tasks');
|
||||
$this->data['activesection'] = $this->document->getActiveSection();
|
||||
$this->data['activeitem'] = $this->document->getActiveItem();
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 0) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->model('servers');
|
||||
|
||||
$error = $this->validate($serverid);
|
||||
if($error) {
|
||||
$this->session->data['error'] = $error;
|
||||
$this->response->redirect($this->config->url . 'servers/index');
|
||||
}
|
||||
|
||||
$server = $this->serversModel->getServerById($serverid, array('games', 'locations'));
|
||||
$this->data['server'] = $server;
|
||||
|
||||
$tasks = $this->serversModel->getTasks(array("server_id" => $serverid, "isSystemTask" => 0), array(), array("task_id" => "DESC"));
|
||||
$this->data["tasks"] = $tasks;
|
||||
|
||||
include_once 'application/controllers/common/main.php';
|
||||
|
||||
$this->getChild(array('common/header', 'common/footer'));
|
||||
return $this->load->view('servers/tasks', $this->data);
|
||||
}
|
||||
|
||||
public function createTask($serverid = null) {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'news/index');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 0) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->model('servers');
|
||||
|
||||
$server = $this->serversModel->getServerById($serverid, array('games', 'locations'));
|
||||
|
||||
$error = $this->validate($serverid);
|
||||
if($error) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $error;
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
if($server['server_status'] == 3) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет установка сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 4) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет переустановка сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 5) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет создание BackUP сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 6) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет восстанновление сервера из BackUP!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 7) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет обновление сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server["server_status"] == 0) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Сервер заблокирован!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
$tasks = $this->serversModel->getTasks(array("server_id" => $serverid));
|
||||
if(count($tasks) < 4) {
|
||||
$task = @$this->request->post['task'];
|
||||
$type = @$this->request->post['type'];
|
||||
$time = @$this->request->post['time'];
|
||||
if(!in_array($task, array("enable", "disable", "restart"))) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Вы указали несуществующую задачу!";
|
||||
} else if(($task == 'enable' && $server['server_status'] != 1) || ($task == 'diable' && $server['server_status'] != 2) || ($task == 'restart' && $server['server_status'] != 2)) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Вы не можете создать данную задачу!";
|
||||
} else if(!empty($this->serversModel->getTasks(array("server_id" => $serverid, "task_name" => $task)))) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Данная задача уже создана!";
|
||||
} else if(!in_array($type, array('repeating', 'single'))) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Вы указали несуществующий тип задачи!";
|
||||
} else if($task == 'repeating' && ($task == 'enable' || $task == 'diable')) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Данный тип задачи недоступен для задачи!";
|
||||
} else if(!in_array($time, array("15min", "30min", "1hour", "12hours", "24hours"))) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Вы указали недопустимое время выполнения!";
|
||||
} else {
|
||||
if($time == '15min') {
|
||||
$lead_time = "NOW() + INTERVAL 15 MINUTE";
|
||||
} else if($time == '30min') {
|
||||
$lead_time = "NOW() + INTERVAL 30 MINUTE";
|
||||
} else if($time == '1hour') {
|
||||
$lead_time = "NOW() + INTERVAL 1 HOUR";
|
||||
} else if($time == '12hours') {
|
||||
$lead_time = "NOW() + INTERVAL 12 HOUR";
|
||||
} else if($time == '24hours') {
|
||||
$lead_time = "NOW() + INTERVAL 24 HOUR";
|
||||
}
|
||||
$task = $this->serversModel->getTaskById($this->serversModel->createTask(array("server_id" => $serverid, "task_name" => $task, "task_type" => $type, "task_time" => $time, "task_lead_time" => $lead_time)));
|
||||
|
||||
$this->data['task'] = array("task_id" => $task['task_id'], "task_name" => $task['task_name'], "task_type" => $task['task_type'], "task_time" => $task['task_time'], "task_lead_time" => date("d.m.Y в H:i", strtotime($task['task_lead_time'])));
|
||||
|
||||
$this->data["status"] = "success";
|
||||
$this->data["success"] = "Задача успешно создана!";
|
||||
}
|
||||
} else {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Вы не можете создавать больше 4-х задач!";
|
||||
}
|
||||
}
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
public function deleteTask($serverid = null) {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'news/index');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 0) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->model('servers');
|
||||
|
||||
$server = $this->serversModel->getServerById($serverid, array('games', 'locations'));
|
||||
|
||||
$error = $this->validate($serverid);
|
||||
if($error) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $error;
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
if($server['server_status'] == 3) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет установка сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 4) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет переустановка сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 5) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет создание BackUP сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 6) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет восстанновление сервера из BackUP!";
|
||||
return json_encode($this->data);
|
||||
} else if($server['server_status'] == 7) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Идет обновление сервера!";
|
||||
return json_encode($this->data);
|
||||
} else if($server["server_status"] == 0) {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Сервер заблокирован!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
$task_id = @$this->request->post['task_id'];
|
||||
$task = $this->serversModel->getTaskById($serverid);
|
||||
if($task['server_id'] == $server_id) {
|
||||
$this->serversModel->deleteTask(array('task_id' => $task_id));
|
||||
$this->data["status"] = "success";
|
||||
$this->data["success"] = "Задача успешно удалена!";
|
||||
} else {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = "Задача не найдена!";
|
||||
}
|
||||
}
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
|
||||
private function validate($serverid) {
|
||||
$result = null;
|
||||
|
||||
$userid = $this->user->getId();
|
||||
|
||||
if(!$this->serversModel->getTotalServerOwners(array('server_id' => (int)$serverid, 'user_id' => (int)$userid, 'owner_status' => 1))) {
|
||||
if(!$this->serversModel->getTotalServers(array('server_id' => (int)$serverid, 'user_id' => (int)$userid))) {
|
||||
$result = "Запрашиваемый сервер не существует!";
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko (https://vk.com/id00v)
|
||||
*/
|
||||
class indexController extends Controller {
|
||||
public function index() {
|
||||
$this->document->setActiveSection('status');
|
||||
$this->document->setActiveItem('index');
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 0) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->model('servers');
|
||||
$this->load->model('tickets');
|
||||
$this->load->model('users');
|
||||
$this->load->model('invoices');
|
||||
$this->load->model('games');
|
||||
$this->load->model('locations');
|
||||
$this->load->model('promos');
|
||||
$this->load->model('news');
|
||||
$userid = $this->user->getId();
|
||||
$ticketsSort = array(
|
||||
'ticket_status' => 'DESC',
|
||||
'ticket_date_add' => 'DESC'
|
||||
);
|
||||
$getData = array();
|
||||
if(isset($this->request->get['gameid'])) {
|
||||
$getData['servers.game_id'] = (int)$this->request->get['gameid'];
|
||||
}
|
||||
|
||||
if(isset($this->request->get['locationid'])) {
|
||||
$getData['servers.location_id'] = (int)$this->request->get['locationid'];
|
||||
}
|
||||
|
||||
$options = array(
|
||||
'start' => 0,
|
||||
'limit' => 100000
|
||||
);
|
||||
$getOptions = array(
|
||||
'start' => 0,
|
||||
'limit' => 100000
|
||||
);
|
||||
|
||||
$total = $this->ticketsModel->getTotalTickets($getData);
|
||||
$tickets = $this->ticketsModel->getTickets($getData, array('users'), array(), $getOptions);
|
||||
$servers = $this->serversModel->getServers(array('user_id' => (int)$userid), array('games', 'locations'), array(), $options);
|
||||
$total = $this->serversModel->getTotalServers($getData);
|
||||
$tservers = $this->serversModel->getServers($getData, array('games', 'locations'), array(), $getOptions);
|
||||
$total = $this->invoicesModel->getTotalInvoices($getData);
|
||||
$invoices = $this->invoicesModel->getInvoices($getData, array('users'), array(), $options);
|
||||
$users = $this->usersModel->getUsers(array(), array(), $options);
|
||||
$games = $this->gamesModel->getGames(array(), array(), $options);
|
||||
$locations = $this->locationsModel->getLocations(array('location_status' => 1), array(), $options);
|
||||
$promos = $this->promosModel->getpromo(array(), array(), $options);
|
||||
$news = $this->newsModel->getNews(array(), array(), array(),$options);
|
||||
$this->data['games'] = $games;
|
||||
$this->data['users'] = $users;
|
||||
$this->data['tservers'] = $tservers;
|
||||
$this->data['tickets'] = $tickets;
|
||||
$this->data['servers'] = $servers;
|
||||
$this->data['invoices'] = $invoices;
|
||||
$this->data['locations'] = $locations;
|
||||
$this->data['promos'] = $promos;
|
||||
$this->data['news'] = $news;
|
||||
$this->getChild(array('common/header', 'common/footer'));
|
||||
return $this->load->view('status/index', $this->data);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,131 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko (https://vk.com/id00v)
|
||||
*/
|
||||
class createController extends Controller {
|
||||
public function index($ticketid = null) {
|
||||
$this->document->setActiveSection('tickets');
|
||||
$this->document->setActiveItem('create');
|
||||
$this->data['url'] = $this->config->url;
|
||||
$this->data['recaptcha'] = $this->config->recaptcha;
|
||||
$this->data['captcha_enable'] = $this->config->captcha_enable;
|
||||
|
||||
if($this->user->isLogged()) {
|
||||
$this->data['logged'] = true;
|
||||
$this->data['user_email'] = $this->user->getEmail();
|
||||
$this->data['user_firstname'] = $this->user->getFirstname();
|
||||
$this->data['user_lastname'] = $this->user->getLastname();
|
||||
$this->data['user_balance'] = $this->user->getBalance();
|
||||
$this->data['user_access_level'] = $this->user->getAccessLevel();
|
||||
$this->data['user_img'] = $this->user->getUser_img();
|
||||
} else {
|
||||
$this->data['logged'] = false;
|
||||
$this->data['user_access_level'] = 0;
|
||||
}
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 0) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
$this->load->model('ticketsCategory');
|
||||
$this->load->model('users');
|
||||
$category = @$this->request->post['category'];
|
||||
$category = $this->ticketsCategoryModel->getTicketsCategory(array('category_status' => 1));
|
||||
$userid = $this->user->getId();
|
||||
|
||||
$this->data['category'] = $category;
|
||||
$this->getChild(array('common/header', 'common/footer'));
|
||||
return $this->load->view('tickets/create', $this->data);
|
||||
}
|
||||
|
||||
public function ajax($ticketid = null) {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if($this->user->getAccessLevel() < 1) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$this->load->model('tickets');
|
||||
$this->load->model('ticketsMessages');
|
||||
$this->load->model('ticketsCategory');
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
$errorPOST = $this->validatePOST();
|
||||
if(!$errorPOST) {
|
||||
$name = @$this->request->post['name'];
|
||||
$text = @$this->request->post['text'];
|
||||
$category = @$this->request->post['category'];
|
||||
$userid = $this->user->getId();
|
||||
$ticketData = array(
|
||||
'user_id' => $userid,
|
||||
'ticket_name' => $name,
|
||||
'ticket_status' => 1,
|
||||
'category_id' => $category
|
||||
);
|
||||
$ticketid = $this->ticketsModel->createTicket($ticketData);
|
||||
$messageData = array(
|
||||
'ticket_id' => $ticketid,
|
||||
'user_id' => $userid,
|
||||
'ticket_message' => $text
|
||||
);
|
||||
$this->ticketsMessagesModel->createTicketMessage($messageData);
|
||||
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Вы успешно создали запрос!";
|
||||
$this->data['id'] = $ticketid;
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $errorPOST;
|
||||
}
|
||||
}
|
||||
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
private function validatePOST() {
|
||||
$result = null;
|
||||
|
||||
$name = @$this->request->post['name'];
|
||||
$text = @$this->request->post['text'];
|
||||
$recaptcha = @$this->request->post['g-recaptcha-response'];
|
||||
$this->load->model('tickets');
|
||||
$userid = $this->user->getId();
|
||||
|
||||
if(mb_strlen($name) < 6 || mb_strlen($name) > 32) {
|
||||
$result = "Название тикета должно содержать от 6 до 32 символов!";
|
||||
}
|
||||
elseif(mb_strlen($text) < 10 || mb_strlen($text) > 10000) {
|
||||
$result = "Текст тикета должен содержать от 10 до 350 символов!";
|
||||
}
|
||||
elseif (3 <= $this->ticketsModel->dateCreateInfo($userid)) {
|
||||
$result = 'Нельзя создать тикет, так как за сегодня вы создали больше 3 тикетов.';
|
||||
}
|
||||
if($this->config->captcha_enable != '1') return $result;
|
||||
if(!$recaptcha) return 'Подтвердите, что вы не робот!';
|
||||
$url = 'https://www.google.com/recaptcha/api/siteverify';
|
||||
$data = array('secret' => $this->config->secret_recaptcha, 'response' => $recaptcha);
|
||||
$options = array(
|
||||
'http' => array(
|
||||
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
|
||||
'method' => 'POST',
|
||||
'remoteip' => 'remoteip',
|
||||
'content' => http_build_query($data),
|
||||
)
|
||||
);
|
||||
|
||||
$context = stream_context_create($options);
|
||||
$recaptcha_get = json_decode(file_get_contents($url, false, $context))->{'success'};
|
||||
if($recaptcha_get != '1') return 'Проверьте правильность капчи!';
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko (https://vk.com/id00v)
|
||||
*/
|
||||
class faqController extends Controller {
|
||||
public function index() {
|
||||
$this->document->setActiveSection('tickets');
|
||||
$this->document->setActiveItem('faq');
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 0) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
|
||||
$this->data['user_img'] = $this->user->getUser_img();
|
||||
$this->data['url'] = $this->config->url;
|
||||
|
||||
$userid = $this->user->getId();
|
||||
|
||||
$this->data['logged'] = true;
|
||||
$this->data['user_email'] = $this->user->getEmail();
|
||||
$this->data['user_id'] = $userid;
|
||||
$this->data['user_firstname'] = $this->user->getFirstname();
|
||||
$this->data['user_lastname'] = $this->user->getLastname();
|
||||
$this->data['user_balance'] = $this->user->getBalance();
|
||||
$this->data['user_access_level'] = $this->user->getAccessLevel();
|
||||
|
||||
$this->getChild(array('common/header', 'common/footer'));
|
||||
return $this->load->view('tickets/faq', $this->data);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko (https://vk.com/id00v)
|
||||
*/
|
||||
class indexController extends Controller {
|
||||
private $limit = 10;
|
||||
public function index($page = 1) {
|
||||
$this->document->setActiveSection('tickets');
|
||||
$this->document->setActiveItem('index');
|
||||
$this->data['url'] = $this->config->url;
|
||||
|
||||
if($this->user->isLogged()) {
|
||||
$this->data['logged'] = true;
|
||||
$this->data['user_email'] = $this->user->getEmail();
|
||||
$this->data['user_firstname'] = $this->user->getFirstname();
|
||||
$this->data['user_lastname'] = $this->user->getLastname();
|
||||
$this->data['user_balance'] = $this->user->getBalance();
|
||||
$this->data['user_access_level'] = $this->user->getAccessLevel();
|
||||
$this->data['user_img'] = $this->user->getUser_img();
|
||||
} else {
|
||||
$this->data['logged'] = false;
|
||||
$this->data['user_access_level'] = 0;
|
||||
}
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 0) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->library('pagination');
|
||||
$this->load->model('tickets');
|
||||
$this->load->model('ticketsCategory');
|
||||
$this->load->model('users');
|
||||
|
||||
$userid = $this->user->getId();
|
||||
$sort = array(
|
||||
'ticket_status' => 'DESC',
|
||||
'ticket_date_add' => 'DESC'
|
||||
);
|
||||
$options = array(
|
||||
'start' => ($page - 1) * $this->limit,
|
||||
'limit' => $this->limit
|
||||
);
|
||||
|
||||
$total = $this->ticketsModel->getTotalTickets(array('user_id' => (int)$userid));
|
||||
$tickets = $this->ticketsModel->getTickets(array('user_id' => (int)$userid), array('tickets_category'), $sort, $options);
|
||||
|
||||
$paginationLib = new paginationLibrary();
|
||||
|
||||
$paginationLib->total = $total;
|
||||
$paginationLib->page = $page;
|
||||
$paginationLib->limit = $this->limit;
|
||||
$paginationLib->url = $this->config->url . 'tickets/index/index/{page}';
|
||||
$pagination = $paginationLib->render();
|
||||
$this->data['tickets'] = $tickets;
|
||||
$this->data['pagination'] = $pagination;
|
||||
$this->data['user_firstname'] = $this->user->getFirstname();
|
||||
$this->data['user_lastname'] = $this->user->getLastname();
|
||||
$this->data['user_access_level'] = $this->user->getAccessLevel();
|
||||
$this->data['user_img'] = $this->user->getUser_img();
|
||||
$this->getChild(array('common/header', 'common/footer'));
|
||||
return $this->load->view('tickets/index', $this->data);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,297 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko (https://vk.com/id00v)
|
||||
*/
|
||||
class viewController extends Controller {
|
||||
public function index($ticketid = null) {
|
||||
$this->document->setActiveSection('tickets');
|
||||
$this->document->setActiveItem('index');
|
||||
$this->data['url'] = $this->config->url;
|
||||
|
||||
if($this->user->isLogged()) {
|
||||
$this->data['logged'] = true;
|
||||
$this->data['user_email'] = $this->user->getEmail();
|
||||
$this->data['user_firstname'] = $this->user->getFirstname();
|
||||
$this->data['user_lastname'] = $this->user->getLastname();
|
||||
$this->data['user_balance'] = $this->user->getBalance();
|
||||
$this->data['user_access_level'] = $this->user->getAccessLevel();
|
||||
$this->data['user_img'] = $this->user->getUser_img();
|
||||
} else {
|
||||
$this->data['logged'] = false;
|
||||
$this->data['user_access_level'] = 0;
|
||||
}
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 0) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->model('tickets');
|
||||
$this->load->model('users');
|
||||
|
||||
$error = $this->validate($ticketid);
|
||||
if($error) {
|
||||
$this->session->data['error'] = $error;
|
||||
$this->response->redirect($this->config->url . 'tickets/index');
|
||||
}
|
||||
|
||||
$ticket = $this->ticketsModel->getTicketById($ticketid, array('users'));
|
||||
$this->data['ticket'] = $ticket;
|
||||
$this->data['user_img'] = $this->user->getUser_img();
|
||||
|
||||
$LastTime = time() - 105;
|
||||
$online_sup = 0;
|
||||
foreach($this->usersModel->getUsers() as $line) {
|
||||
if($line['user_access_level'] > 1) {
|
||||
if ($line['user_online_date'] > $LastTime) {
|
||||
$online_sup++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if($online_sup > 0) {
|
||||
$this->data['sup_status'] = '<span class="label label-dot label-success"></span><span class="font-weight-bold text-muted font-size-sm"> В сети</span>';
|
||||
} else {
|
||||
$this->data['sup_status'] = '<span class="label label-dot label-danger"></span><span class="font-weight-bold text-muted font-size-sm"> Не в сети</span>';
|
||||
}
|
||||
|
||||
$this->getChild(array('common/header', 'common/footer'));
|
||||
return $this->load->view('tickets/view', $this->data);
|
||||
}
|
||||
|
||||
public function action($ticketid = null, $action = null) {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if($this->user->getAccessLevel() < 0) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
$this->load->model('tickets');
|
||||
switch($action) {
|
||||
case 'closed': {
|
||||
$this->ticketsModel->updateTicket($ticketid, array('ticket_status' => 0));
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Вы успешно закрыли запрос!";
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы выбрали несуществующее действие!";
|
||||
break;
|
||||
}
|
||||
}
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
public function ajax($ticketid = null) {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if($this->user->getAccessLevel() < 1) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$this->load->model('tickets');
|
||||
$this->load->model('ticketsMessages');
|
||||
|
||||
$error = $this->validate($ticketid);
|
||||
if($error) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $error;
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
$errorPOST = $this->validatePOST($ticketid);
|
||||
if(!$errorPOST) {
|
||||
$userid = $this->user->getId();
|
||||
$text = @$this->request->post['text'];
|
||||
$ticket = $this->ticketsModel->getTicketById($ticketid, array('users'));
|
||||
if($ticket['ticket_status'] != 0) {
|
||||
$messageData = array(
|
||||
'ticket_id' => $ticketid,
|
||||
'user_id' => $userid,
|
||||
'ticket_message' => $text
|
||||
);
|
||||
$this->ticketsModel->updateTicket($ticketid, array('ticket_status' => 1));
|
||||
$this->ticketsMessagesModel->createTicketMessage($messageData);
|
||||
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Вы успешно отправили сообщение!";
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Данный запрос закрыт, оставить новое сообщение невозможно!";
|
||||
}
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $errorPOST;
|
||||
}
|
||||
}
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
public function uploadFile($ticketid = null) {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if($this->user->getAccessLevel() < 1) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$this->load->model('tickets');
|
||||
$this->load->model('ticketsMessages');
|
||||
$this->load->model('users');
|
||||
|
||||
$error = $this->validate($ticketid);
|
||||
if ($error) {
|
||||
$this->session->data['error'] = $error;
|
||||
}
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
$uploaddir = "tmp/tickets_img/";
|
||||
$apend=date('YmdHis').rand(100,1000).'.jpg';
|
||||
$uploadfile = "$uploaddir$apend";
|
||||
|
||||
if(move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
|
||||
if($_FILES['userfile']['type'] == 'image/gif' || $_FILES['userfile']['type'] == 'image/jpeg' || $_FILES['userfile']['type'] == 'image/png') {
|
||||
if($_FILES['userfile']['size'] != 0 and $_FILES['userfile']['size'] <= 5120000) {
|
||||
$size = getimagesize($uploadfile);
|
||||
if ($size[0] < 2560 && $size[1] < 1440) {
|
||||
if(round(($_FILES['userfile']['size'] / 1024), 2) > 1500.00) {
|
||||
$message = 'Изображение: ' . $apend . '<br>Размер: ' . round(($_FILES['userfile']['size'] / 1024), 2) . 'КБ<br><a href="/' . $uploadfile . ' target="_blank">Открыть</a>';
|
||||
} else {
|
||||
$message = '<a href="/' . $uploadfile . '" target="_blank"><img height="150" src="/' . $uploadfile . '"></a>';
|
||||
}
|
||||
$userid = $this->user->getId();
|
||||
$messageData = array(
|
||||
'ticket_id' => $ticketid,
|
||||
'user_id' => $userid,
|
||||
'ticket_message' => $message
|
||||
);
|
||||
$this->ticketsModel->updateTicket($ticketid, array('ticket_status' => 1));
|
||||
$this->ticketsMessagesModel->createTicketMessage($messageData);
|
||||
$this->data['status'] = 'success';
|
||||
$this->data['success'] = 'Изображение загружено!';
|
||||
} else {
|
||||
$this->data['error'] = 'Загружаемое изображение превышает допустимые нормы!';
|
||||
$this->data['status'] = "error";
|
||||
unlink($uploadfile);
|
||||
}
|
||||
} else {
|
||||
$this->data['error'] = 'Размер изображения не должено превышать 5120Кб';
|
||||
$this->data['status'] = "error";
|
||||
}
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Можно загружать только изображения в форматах jpg, jpeg и png";
|
||||
}
|
||||
} else {
|
||||
$this->data['error'] = 'Изображение не загружено!';
|
||||
$this->data['status'] = "error";
|
||||
}
|
||||
}
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
public function getMessagess() {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 0) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
$this->load->model('tickets');
|
||||
$this->load->model('ticketsMessages');
|
||||
|
||||
$id = $this->request->post['tid'];
|
||||
|
||||
$error = $this->validate($id);
|
||||
if($error) {
|
||||
$this->session->data['error'] = $error;
|
||||
}
|
||||
|
||||
$url = $this->config->url;
|
||||
$messages = $this->ticketsMessagesModel->getTicketsMessages(array('ticket_id' => $id), array('users'));
|
||||
|
||||
foreach($messages as $item) {
|
||||
$item['ticket_message'] = preg_replace("#(https?|ftp)://\S+[^\s.,>)\];'\"!?]#",'<a href="\\0" target="_blank">\\0</a>', $item['ticket_message']);
|
||||
if($item['user_access_level'] == '1') {
|
||||
echo '<div class="d-flex flex-column mb-5 align-items-start">
|
||||
<div class="d-flex align-items-center">
|
||||
<div class="symbol symbol-circle symbol-40 mr-3">
|
||||
<img alt="Pic" src="'.$url.''.$item['user_img'].'" />
|
||||
</div>
|
||||
<div>
|
||||
<a href="javascript:;" class="text-dark-75 text-hover-primary font-weight-bold font-size-h6">'. $item['user_firstname'] .' '. $item['user_lastname'] .'</a>
|
||||
<span class="text-muted font-size-sm">'. date("d.m.Y в H:i", strtotime($item['ticket_message_date_add'])) .'</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-2 rounded p-5 bg-light-success text-dark-50 font-weight-bold font-size-lg text-left max-w-400px">'. nl2br($item['ticket_message']) .'
|
||||
</div></div>';
|
||||
}
|
||||
|
||||
if($item['user_access_level'] >= '2') {
|
||||
echo '<div class="d-flex flex-column mb-5 align-items-end">
|
||||
<div class="d-flex align-items-center">
|
||||
<div class="symbol symbol-circle symbol-40 mr-3">
|
||||
<img alt="Pic" src="'.$url.''.$item['user_img'].'" />
|
||||
</div>
|
||||
<div>
|
||||
<a href="javascript:;" class="text-dark-75 text-hover-primary font-weight-bold font-size-h6">'. $item['user_firstname'] .' '. $item['user_lastname'] .'</a>
|
||||
<span class="text-muted font-size-sm">'. date("d.m.Y в H:i", strtotime($item['ticket_message_date_add'])) .'</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-2 rounded p-5 bg-light-primary text-dark-50 font-weight-bold font-size-lg text-left max-w-400px">'. nl2br($item['ticket_message']) .'<br>
|
||||
</div></div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function validate($ticketid) {
|
||||
$result = null;
|
||||
$userid = $this->user->getId();
|
||||
if(!$this->ticketsModel->getTotalTickets(array('ticket_id' => (int)$ticketid, 'user_id' => (int)$userid))) {
|
||||
$result = "Запрашиваемый запрос не существует!";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function validatePOST($ticketid) {
|
||||
$result = null;
|
||||
|
||||
$this->load->model('tickets');
|
||||
$userid = $this->user->getId();
|
||||
|
||||
$text = @$this->request->post['text'];
|
||||
|
||||
if (5 <= $this->ticketsModel->spam($userid)) {
|
||||
$result = 'Пожалуйста, подождите 10 секунд.';
|
||||
}
|
||||
else if(mb_strlen($text) < 1 || mb_strlen($text) > 350) {
|
||||
$result = "Текст сообщения должен содержать от 1 до 350 символов.";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,223 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class controlController extends Controller {
|
||||
public function index($webid = null) {
|
||||
$this->document->setActiveSection('webhost');
|
||||
$this->document->setActiveItem('control');
|
||||
$this->data['activesection'] = $this->document->getActiveSection();
|
||||
$this->data['activeitem'] = $this->document->getActiveItem();
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 0) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->model('webhost');
|
||||
|
||||
$error = $this->validate($webid);
|
||||
if($error) {
|
||||
$this->session->data['error'] = $error;
|
||||
$this->response->redirect($this->config->url . 'webhost/index');
|
||||
}
|
||||
|
||||
$webhost = $this->webhostModel->getWebhostById($webid, array('users','web_tarifs','web_locations'));
|
||||
$this->data['webhost'] = $webhost;
|
||||
|
||||
include_once 'application/controllers/common/main.php';
|
||||
|
||||
$this->getChild(array('common/header', 'common/footer'));
|
||||
return $this->load->view('webhost/control', $this->data);
|
||||
}
|
||||
|
||||
public function ajax($webid = null) {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if($this->user->getAccessLevel() < 1) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
$this->load->model('webhost');
|
||||
|
||||
$error = $this->validate($webid);
|
||||
if($error) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $error;
|
||||
return json_encode($this->data);
|
||||
}
|
||||
$webhost = $this->webhostModel->getWebhostById($webid, array('web_tarifs'));
|
||||
if($webhost['web_status'] == 0) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Веб-хостинг заблокирован!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
$errorPOST = $this->validatePOST();
|
||||
if(!$errorPOST) {
|
||||
$editpassword = @$this->request->post['editpassword'];
|
||||
$password = @$this->request->post['password'];
|
||||
if($editpassword) {
|
||||
$result = $this->webhostModel->updatepassUser($webid, $password);
|
||||
if($result["status"] == "success") {
|
||||
$this->webhostModel->updateWebhost($webid, array('web_password' => $password));
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Пароль доступа успешно изменен!";
|
||||
} else {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = $result["description"];
|
||||
}
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Ошибка!";
|
||||
}
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $errorPOST;
|
||||
}
|
||||
}
|
||||
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
public function buy_months($webid = null) {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if($this->user->getAccessLevel() < 1) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$this->load->model('users');
|
||||
$this->load->model('webhost');
|
||||
$this->load->model('waste');
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
$days = @$this->request->post['days'];
|
||||
if($days != "30" && $days != "60" && $days != "90" && $days != "180" && $days != "360" && $days != "15") {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы указали недопустимый период оплаты!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$userid = $this->user->getId();
|
||||
$balance = $this->user->getBalance();
|
||||
$webhost = $this->webhostModel->getWebhostById($webid, array('web_tarifs'));
|
||||
|
||||
$price = $webhost['tarif_price'];
|
||||
switch($days) {
|
||||
case "15":
|
||||
$price = $price / 2;
|
||||
break;
|
||||
case "30":
|
||||
break;
|
||||
case "60":
|
||||
$price = $price * 2;
|
||||
break;
|
||||
case "90":
|
||||
$price = 3 * $price * 0.95;
|
||||
break;
|
||||
case "180":
|
||||
$price = 6 * $price * 0.90;
|
||||
break;
|
||||
case "360":
|
||||
$price = 12 * $price * 0.85;
|
||||
break;
|
||||
}
|
||||
|
||||
if($balance >= $price) {
|
||||
if($webhost['web_status'] == 0) {
|
||||
$this->webhostModel->extendWebhost($webid,$days,false);
|
||||
$result = $this->webhostModel->unblockWebhost($webid);
|
||||
if($result["status"] != "success") {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = $result["description"];
|
||||
}
|
||||
} else {
|
||||
$this->webhostModel->extendWebhost($webid,$days,false);
|
||||
}
|
||||
|
||||
$wasteData = array(
|
||||
'user_id' => $userid,
|
||||
'waste_ammount' => $price,
|
||||
'waste_status' => 1,
|
||||
'waste_usluga' => "Продление веб-хостинга ws$webid на $days дней"
|
||||
);
|
||||
$this->wasteModel->createWaste($wasteData);
|
||||
|
||||
$this->usersModel->downUserBalance($userid, $price);
|
||||
|
||||
$user = $this->usersModel->getUserById($userid, array(), array(), array());
|
||||
if($user['ref'] != 0) {
|
||||
$ref_percent = $this->config->ref_percent;
|
||||
$getpref = ($price * (1 + $ref_percent / 100)) - $price;
|
||||
$this->usersModel->upUserBalance($user['ref'], $getpref);
|
||||
$this->usersModel->upUserRMoney($user['ref'], $getpref);
|
||||
|
||||
$wasteData = array(
|
||||
'user_id' => $user['ref'],
|
||||
'waste_ammount' => $getpref,
|
||||
'waste_status' => 0,
|
||||
'waste_usluga' => "Бонус с реферала ID-$userid"
|
||||
);
|
||||
$this->wasteModel->createWaste($wasteData);
|
||||
}
|
||||
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Вы успешно оплатили веб-хостинг на $days дней. С Вашего счета снято ".(round($price, 2))." руб";
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "На Вашем счету не хватает ".(round($price-$balance, 2))." руб";
|
||||
}
|
||||
}
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
private function validate($webid) {
|
||||
$result = null;
|
||||
|
||||
$userid = $this->user->getId();
|
||||
|
||||
if(!$this->webhostModel->getTotalWebhosts(array('web_id' => (int)$webid, 'user_id' => (int)$userid))) {
|
||||
$result = "Запрашиваемый веб-хостинг не существует!";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function validatePOST() {
|
||||
$this->load->library('validate');
|
||||
|
||||
$validateLib = new validateLibrary();
|
||||
|
||||
$result = null;
|
||||
|
||||
$editpassword = @$this->request->post['editpassword'];
|
||||
$password = @$this->request->post['password'];
|
||||
$password2 = @$this->request->post['password2'];
|
||||
|
||||
if($editpassword) {
|
||||
if(!$validateLib->password_web($password)) {
|
||||
$result = "Пароль должен содержать от 8 до 32 латинских букв, цифр и знаков <i>,.!?_-</i>!";
|
||||
}
|
||||
elseif($password != $password2) {
|
||||
$result = "Введенные вами пароли не совпадают!";
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class indexController extends Controller {
|
||||
private $limit = 10;
|
||||
public function index($page = 1) {
|
||||
$this->document->setActiveSection('webhost');
|
||||
$this->document->setActiveItem('index');
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не залогинены!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 0) {
|
||||
$this->session->data['error'] = "Нет доступа!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
|
||||
$this->load->library('pagination');
|
||||
$this->load->model('webhost');
|
||||
|
||||
$userid = $this->user->getId();
|
||||
|
||||
$options = array(
|
||||
'start' => ($page - 1) * $this->limit,
|
||||
'limit' => $this->limit
|
||||
);
|
||||
|
||||
$total = $this->webhostModel->getTotalWebhosts(array('user_id' => (int)$userid));
|
||||
$webhosts = $this->webhostModel->getWebhosts(array('user_id' => (int)$userid), array('web_tarifs', 'web_locations'), array(), $options);
|
||||
|
||||
$paginationLib = new paginationLibrary();
|
||||
|
||||
$paginationLib->total = $total;
|
||||
$paginationLib->page = $page;
|
||||
$paginationLib->limit = $this->limit;
|
||||
$paginationLib->url = $this->config->url . 'webhost/index/index/{page}';
|
||||
|
||||
$pagination = $paginationLib->render();
|
||||
|
||||
$this->data['webhosts'] = $webhosts;
|
||||
$this->data['pagination'] = $pagination;
|
||||
|
||||
$this->getChild(array('common/header', 'common/footer'));
|
||||
return $this->load->view('webhost/index', $this->data);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,216 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2020 HOSTINPL (HOSTING-RUS) https://vk.com/hosting_rus
|
||||
Developed by Samir Shelenko and Alexander Zemlyanoy (https://vk.com/id00v / https://vk.com/mrsasha082)
|
||||
*/
|
||||
class orderController extends Controller {
|
||||
public function index() {
|
||||
$this->document->setActiveSection('webhost');
|
||||
$this->document->setActiveItem('order');
|
||||
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->session->data['error'] = "Вы не авторизированы!";
|
||||
$this->response->redirect($this->config->url . 'account/login');
|
||||
}
|
||||
if($this->user->getAccessLevel() < 0) {
|
||||
$this->session->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
$this->response->redirect($this->config->url);
|
||||
}
|
||||
$this->load->model('webhostTarifs');
|
||||
$this->load->model('webLocations');
|
||||
$tarifs = $this->webhostTarifsModel->getTarifs(array('tarif_status' => 1));
|
||||
$locations = $this->webLocationsModel->getLocations(array('location_status' => 1));
|
||||
$this->data['tarifs'] = $tarifs;
|
||||
$this->data['locations'] = $locations;
|
||||
$this->getChild(array('common/header', 'common/footer'));
|
||||
return $this->load->view('webhost/order', $this->data);
|
||||
}
|
||||
|
||||
public function promo() {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if($this->user->getAccessLevel() < 1) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$this->load->model('users');
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
$code = $this->request->post['code'];
|
||||
$skidka = $this->usersModel->getSkidkaByCode($code, false);$kofficent=(100-$skidka['skidka'])/100;
|
||||
if($skidka['skidka'] == NULL){
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Данного кода не существует";
|
||||
}else{
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Вы активировали скидку ".$skidka['skidka']."%";
|
||||
$this->data['skidka'] = $kofficent;
|
||||
}
|
||||
}
|
||||
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
public function ajax() {
|
||||
if(!$this->user->isLogged()) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Вы не авторизированы!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
if($this->user->getAccessLevel() < 1) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "У вас нет доступа к данному разделу!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$this->load->model('users');
|
||||
$this->load->model('waste');
|
||||
$this->load->model('webhost');
|
||||
$this->load->model('webhostTarifs');
|
||||
$this->load->model('webLocations');
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
if($this->config->webhost == 1) {
|
||||
$errorPOST = $this->validatePOST();
|
||||
if(!$errorPOST) {
|
||||
$tarifid = $this->request->post['tarifid'];
|
||||
$days = $this->request->post['days'];
|
||||
$locationid = $this->request->post['locationid'];
|
||||
|
||||
$location = $this->webLocationsModel->getLocationById($locationid);
|
||||
$location_tarifs = explode(" ", $location['location_tarifs']);
|
||||
|
||||
if(!in_array($tarifid, $location_tarifs)) {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Данный тариф не доступен для указанной локации!";
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
$chars="qazxswedcvfrtgbnhyujmkiolp1234567890QAZXSWEDCVFRTGBNHYUJMKIOLP";
|
||||
$max=14;
|
||||
$size=StrLen($chars)-1;
|
||||
$password=null;
|
||||
while($max--)
|
||||
$password.=$chars[rand(0,$size)];
|
||||
|
||||
$userid = $this->user->getId();
|
||||
$balance = $this->user->getBalance();
|
||||
$tarif = $this->webhostTarifsModel->getTarifById($tarifid);
|
||||
$code = $this->request->post['promo'];
|
||||
$skidka = $this->usersModel->getSkidkaByCode($code,true);$kofficent=(100-$skidka['skidka'])/100;
|
||||
$price = $tarif['tarif_price'];
|
||||
|
||||
switch($days) {
|
||||
case "15":
|
||||
$price = $price / 2;
|
||||
break;
|
||||
case "30":
|
||||
break;
|
||||
case "60":
|
||||
$price = $price * 2;
|
||||
break;
|
||||
case "90":
|
||||
$price = 3 * $price * 0.95;
|
||||
break;
|
||||
case "180":
|
||||
$price = 6 * $price * 0.90;
|
||||
break;
|
||||
case "360":
|
||||
$price = 12 * $price * 0.85;
|
||||
break;
|
||||
}
|
||||
|
||||
if($skidka['skidka'] != NULL){
|
||||
$price = $price * $kofficent;
|
||||
}
|
||||
|
||||
if($balance >= $price) {
|
||||
$webData = array(
|
||||
'user_id' => $userid,
|
||||
'location_id' => $locationid,
|
||||
'web_password' => $password,
|
||||
'tarif_id' => $tarifid,
|
||||
'web_status' => 1,
|
||||
'web_days' => $days
|
||||
);
|
||||
$package = $tarif['package'];
|
||||
$webid = $this->webhostModel->createWebhost($webData);
|
||||
$result = $this->webhostModel->installWebhost($webid,$password,$package);
|
||||
if($result["status"] == "success") {
|
||||
$this->usersModel->downUserBalance($userid, $price);
|
||||
$wasteData = array(
|
||||
'user_id' => $userid,
|
||||
'waste_ammount' => $price,
|
||||
'waste_status' => 1,
|
||||
'waste_usluga' => "Заказ веб-хостинга ws$webid"
|
||||
);
|
||||
$this->wasteModel->createWaste($wasteData);
|
||||
|
||||
$user = $this->usersModel->getUserById($userid, array(), array(), array());
|
||||
if($user['ref'] != 0) {
|
||||
$ref_percent = $this->config->ref_percent;
|
||||
$getpref = ($price * (1 + $ref_percent / 100)) - $price;
|
||||
$this->usersModel->upUserBalance($user['ref'], $getpref);
|
||||
$this->usersModel->upUserRMoney($user['ref'], $getpref);
|
||||
|
||||
$wasteData = array(
|
||||
'user_id' => $user['ref'],
|
||||
'waste_ammount' => $getpref,
|
||||
'waste_status' => 0,
|
||||
'waste_usluga' => "Бонус с реферала ID-$userid"
|
||||
);
|
||||
$this->wasteModel->createWaste($wasteData);
|
||||
}
|
||||
$this->data['status'] = "success";
|
||||
$this->data['success'] = "Веб-хостинг №".$webid." успешно заказан.";
|
||||
$this->data['id'] = $webid;
|
||||
} else {
|
||||
$this->data["status"] = "error";
|
||||
$this->data["error"] = $result["description"];
|
||||
}
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "На Вашем счету не хватает ".(round($price-$balance, 2))." руб";
|
||||
}
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = $errorPOST;
|
||||
}
|
||||
} else {
|
||||
$this->data['status'] = "error";
|
||||
$this->data['error'] = "Веб.хостинг не доступен для заказа!";
|
||||
}
|
||||
}
|
||||
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
private function validatePOST() {
|
||||
$this->load->library('validate');
|
||||
|
||||
$validateLib = new validateLibrary();
|
||||
|
||||
$result = null;
|
||||
$tarifid = @$this->request->post['tarifid'];
|
||||
$months = @$this->request->post['months'];
|
||||
$locationid = @$this->request->post['locationid'];
|
||||
$days = @$this->request->post['days'];
|
||||
|
||||
if(!$this->webhostTarifsModel->getTotalTarifs(array('tarif_id' => (int)$tarifid, 'tarif_status' => 1))) {
|
||||
$result = "Вы указали несуществующий тариф!";
|
||||
}
|
||||
elseif(!$this->webLocationsModel->getTotalLocations(array('location_id' => (int)$locationid, 'location_status' => 1))) {
|
||||
$result = "Вы указали несуществующую локацию!";
|
||||
}
|
||||
elseif($days != "30" && $days != "60" && $days != "90" && $days != "180" && $days != "360" && $days != "15") {
|
||||
$result = "Вы указали недопустимый период оплаты!";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user