Viewing file: Panel.php (13.31 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
defined('BASEPATH') or exit('No direct script access allowed');
class Panel extends CI_Controller {
function __construct()
{
parent::__construct();
$this->load->model('panel_model');
$this->lang->load('panel');
$this->user = $this->panel_model->getUserByEmail($this->session->login);
if (!$this->session->userdata("login") || !isset($this->user["id"])) {
redirect('/login');
die(); }
$this->panel_model->db->set('last_active', time())->where('id', $this->user['id'])->update('users'); }
function sendTelegram($Content) {
if ($this->config->item('telegram_notifications') == 1) {
$params = [
'chat_id' => $this->config->item('telegram_chat_id'),
'text' => str_replace(['<br>', '<br/>'], PHP_EOL, $Content),
'parse_mode' => 'HTML'
];
$ch = curl_init('https://api.telegram.org/bot' . $this->config->item('telegram_bot_token') . '/sendMessage');
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, ($params));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$result = curl_exec($ch);
curl_close($ch); } }
public function index()
{
$data["title"] = $this->lang->line("home_page") . " - " . $this->config->item("site_name");
$data["page"] = "home";
$data["categories"] = $this->panel_model->getCategories();
$data["announcements"] = $this->panel_model->getAnnouncements();
$data["user"] = $this->user;
$data["used_number_count"] = $this->panel_model->usedNumberCount($data["user"]["id"]);
$data["user_ticket_count"] = $this->panel_model->supportTicketCount($data["user"]["id"]); $data["last_activations"] = $this->panel_model->db->query('SELECT activations.time, activations.status, services.name as service_name, categories.name as category_name FROM activations INNER JOIN services ON services.id = activations.service_id INNER JOIN categories ON categories.id = services.category ORDER BY activations.id DESC LIMIT 10')->result_array();
$this->load->view('theme-' . $this->config->item("theme") . '/panel/header', $data);
$this->load->view('theme-' . $this->config->item("theme") . '/panel/index', $data);
$this->load->view('theme-' . $this->config->item("theme") . '/panel/footer'); } public function rent($page = null) { $api = false; include './application/libraries/rent_module.php'; if ($this->config->item('number_rent_enable') != 1) { header('Location: ' . base_url()); die; } $data["is_module_licensed"] = $is_module_licensed; $data["title"] = $this->lang->line("rent_number") . " - " . $this->config->item("site_name");
$data["page"] = "rent";
$data["user"] = $this->user;
$data["current_page"] = $page;
$this->load->view('theme-' . $this->config->item("theme") . '/panel/header', $data);
$this->load->view('theme-' . $this->config->item("theme") . '/panel/rent', $data);
$this->load->view('theme-' . $this->config->item("theme") . '/panel/footer'); } public function activations() {
$data["title"] = $this->lang->line("my_numbers") . " - " . $this->config->item("site_name");
$data["page"] = "numbers";
$data["user"] = $this->user;
$this->load->view('theme-' . $this->config->item("theme") . '/panel/header', $data);
$this->load->view('theme-' . $this->config->item("theme") . '/panel/numbers', $data);
$this->load->view('theme-' . $this->config->item("theme") . '/panel/footer'); }
public function balance() {
$data["title"] = $this->lang->line("add_balance") . " - " . $this->config->item("site_name");
$data["page"] = "balance";
$data["user"] = $this->user;
$data["banks"] = $this->panel_model->db->get_where('banks')->result_array();
if (isset($_POST['bank'])) {
$s = false;
foreach ($data["banks"] as $bank) {
if ($bank['bank_name'] == $_POST['bank']) {
$s = true;
break; } }
if ($s) {
$this->panel_model->db->insert('payments', array(
'amount' => intval($_POST['amount']),
'method' => 'bank',
'user' => $this->user['id'],
'bank' => json_encode(['name' => strip_tags($_POST['name']), 'bank' => $_POST['bank']]),
'status' => 0,
'time' => time()
));
header('Location: ' . base_url('panel/balance?sent')); exit; } }
$this->load->view('theme-' . $this->config->item("theme") . '/panel/header', $data);
$this->load->view('theme-' . $this->config->item("theme") . '/panel/balance', $data);
$this->load->view('theme-' . $this->config->item("theme") . '/panel/footer'); }
public function support() {
$data["title"] = $this->lang->line("support") . " - " . $this->config->item("site_name");
$data["page"] = "support";
$data["user"] = $this->user;
$data["tickets"] = $this->panel_model->getUserTickets($this->user["id"]);
$this->load->view('theme-' . $this->config->item("theme") . '/panel/header', $data);
$this->load->view('theme-' . $this->config->item("theme") . '/panel/support', $data);
$this->load->view('theme-' . $this->config->item("theme") . '/panel/footer'); }
public function support_ticket($ticket_id) {
$data["title"] = $this->lang->line("support_ticket") . ": " . $ticket_id . " - " . $this->config->item("site_name");
$data["page"] = "";
$data["user"] = $this->user;
$data["ticket"] = $this->panel_model->getTicket($ticket_id, $this->user["id"]);
if (isset($data["ticket"]["id"])) {
$data["ticket_replies"] = $this->panel_model->getTicketReplies($ticket_id);
$this->load->view('theme-' . $this->config->item("theme") . '/panel/header', $data);
$this->load->view('theme-' . $this->config->item("theme") . '/panel/support_ticket', $data);
$this->load->view('theme-' . $this->config->item("theme") . '/panel/footer'); } else {
header("Location: /panel/support"); } }
public function profile() {
$data["title"] = $this->lang->line("my_profile") . " - " . $this->config->item("site_name");
$data["page"] = "profile";
$data["user"] = $this->user;
$this->load->view('theme-' . $this->config->item("theme") . '/panel/header', $data);
$this->load->view('theme-' . $this->config->item("theme") . '/panel/profile', $data);
$this->load->view('theme-' . $this->config->item("theme") . '/panel/footer'); }
public function transactions() {
$data["title"] = $this->lang->line("transaction_logs") . " - " . $this->config->item("site_name");
$data["page"] = "transactions";
$data["user"] = $this->user;
$data["transactions"] = $this->panel_model->getUserTransactions($this->user["id"]);
$this->load->view('theme-' . $this->config->item("theme") . '/panel/header', $data);
$this->load->view('theme-' . $this->config->item("theme") . '/panel/transactions', $data);
$this->load->view('theme-' . $this->config->item("theme") . '/panel/footer'); }
public function page($page_name) {
$data["title"] = $this->lang->line($page_name) . " - " . $this->config->item("site_name");
$data["page"] = $page_name;
$data["user"] = $this->user;
$data["page_name"] = $this->lang->line($page_name);
$data["content"] = $this->panel_model->getPageContent($page_name);
$this->load->view('theme-' . $this->config->item("theme") . '/panel/header', $data);
$this->load->view('theme-' . $this->config->item("theme") . '/panel/page', $data);
$this->load->view('theme-' . $this->config->item("theme") . '/panel/footer'); }
public function logout() {
$this->session->sess_destroy();
header("Location: /"); }
public function create_support_ticket() {
if ($this->input->post('name') && $this->input->post('message')) {
$title = strip_tags($this->input->post('name'));
$message = strip_tags($this->input->post('message'));
$user = $this->user;
if (isset($user["id"])) {
if ($this->panel_model->insertSupportTicket($title, $message, $user["id"])) {
$this->sendTelegram($this->lang->line('new_ticket_message') . '<a href="' . base_url('admin/tickets') . '">' . base_url('admin/tickets') . '</a>');
echo json_encode(array(
"success" => true,
"title" => $this->lang->line("support_ticket_created"),
"message" => $this->lang->line("support_ticket_created_message")
)); } else {
echo json_encode(array(
"success" => false,
"title" => $this->lang->line("support_ticket_error"),
"message" => $this->lang->line("support_ticket_error_message")
)); } } } }
public function reply_support_ticket() {
if ($this->input->post('id') && $this->input->post('message')) {
$message = strip_tags($this->input->post('message'));
$user = $this->user;
if (isset($user["id"])) {
$this->sendTelegram($this->lang->line('new_ticket_reply') . '<a href="' . base_url('admin/tickets') . '">' . base_url('admin/tickets') . '</a>');
$this->panel_model->insertSupportTicketMessage($this->input->post('id'), strip_tags($this->input->post('message')), $user["id"]);
header("Location: " . $_SERVER["HTTP_REFERER"]); } } }
public function update_profile() {
if ($this->input->post("name")) {
$user = $this->user;
$this->panel_model->updateProfile(strip_tags($this->input->post("name")), $this->input->post("city"), $this->input->post("address"), $user["id"]);
if ($this->input->post("password") && $this->input->post("password") != "") {
if (strlen($this->input->post("password")) > 5) {
$this->panel_model->updatePassword($this->input->post("password"), $user["id"]);
echo json_encode(array(
"success" => true,
"title" => $this->lang->line("profile_updated"),
"message" => $this->lang->line("profile_updated_message")
)); } else {
echo json_encode(array(
"success" => false,
"title" => $this->lang->line("password_too_short"),
"message" => $this->lang->line("password_too_short_message")
)); } } else {
echo json_encode(array(
"success" => true,
"title" => $this->lang->line("profile_updated"),
"message" => $this->lang->line("profile_updated_message")
)); } } }
public function use_coupon() {
if ($this->input->post("code")) {
$coupon = $this->panel_model->getCoupon($this->input->post("code"));
if (isset($coupon["id"]) && $coupon["used"] < $coupon["max_use"] && time() < $coupon["valid_until"]) {
if (!$this->panel_model->checkUserUsedCoupon($coupon["code"], $this->user["id"])) {
$this->panel_model->useCoupon($coupon["code"], $coupon["amount"], $this->user["id"]);
echo (json_encode(array(
"success" => true,
"title" => $this->lang->line("coupon_used"),
"message" => $this->lang->line("coupon_used_message")
))); } else {
echo (json_encode(array(
"success" => false,
"title" => $this->lang->line("coupon_already_used"),
"message" => $this->lang->line("coupon_already_used_message")
))); } } else {
echo (json_encode(array(
"success" => false,
"title" => $this->lang->line("coupon_invalid"),
"message" => $this->lang->line("coupon_invalid_message")
))); } } }
public function reset_api_key() {
$user = $this->panel_model->getUserByEmail($this->session->userdata('login'));
if (isset($user["email"])) {
$this->panel_model->resetApiKey($user["id"]); }
header("Location: /panel/profile"); } }
|