KGRKJGETMRETU895U-589TY5MIGM5JGB5SDFESFREWTGR54TY
Server : Apache/2.4.41 (Ubuntu)
System : Linux vmi1525618.contaboserver.net 5.4.0-105-generic #119-Ubuntu SMP Mon Mar 7 18:49:24 UTC 2022 x86_64
User : www-data ( 33)
PHP Version : 8.2.12
Disable Function : NONE
Directory :  /var/www/parasoffline.edukrypt.in/application/modules/admin/controllers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //var/www/parasoffline.edukrypt.in/application/modules/admin/controllers/Liveserver.php
<?php
defined('BASEPATH') or exit('No direct script access allowed');
date_default_timezone_set('Asia/Kolkata');

class Liveserver extends Admin_Controller
{
	public function __construct()
	{
		parent::__construct();
		$this->load->model("Schedule_model");
	}

	public function chat($id)
	{
		$this->mViewData['chatid'] = $id;
		$this->mViewData['f_name'] = "Paras Institute";
		$this->mViewData['admin_email'] = "parasinstitutewindows@gmail.com";
		$this->mTitle .= 'Live Chat';
		$this->load->view('chat/chat', $this->mViewData);
	}

	public function add()
	{
		$admin_id = $this->session->userdata('user_id');
		if ($_SERVER['REQUEST_METHOD'] == 'POST') {
			if (!empty($_POST['stream_url']) && !empty($_POST['stream_key']) && !empty($_POST['name']) && !empty($_POST['host'])) {

				$data = array(
					'name' => $this->input->post('name'),
					'host' => $this->input->post('host'),
					'stream_url' => $this->input->post('stream_url'),
					'stream_key' => $this->input->post('stream_key'),
					'admin_id' => $admin_id
				);
				$this->db->insert('livestream', $data);
				$this->session->set_flashdata('message', '<div class="alert alert-success" role="alert">Stream credentials saved!</div>');
				$this->render('liveserver/add');
			}
		} else {
			$this->mTitle .= 'Add Live Streams';
			$this->render('liveserver/add');
		}
	}

	public function index()
	{
		$admin_id = $this->session->userdata('user_id');

		$query_c  = $this->db->where('admin_id', $admin_id)->order_by('id', 'asc')->get('livestream');
		$this->mViewData['streams'] = $query_c;

		$this->mTitle .= 'Live Streams';
		$this->render('liveserver/index');
	}

	public function schedule_live()
	{
		$admin_id = $this->session->userdata('user_id');
		// Courses
		$livestream = $this->db->where('admin_id', $this->session->userdata('user_id'))->get('livestream');
		$this->mViewData['livestream'] = $livestream;
		// tags
		$query2 = $this->db->where('admin_id', $this->session->userdata('user_id'))->get('tags');
		$this->mViewData['groups']  = $query2->result();
		// Users
		$clients = $this->db->where('admin_id', $this->session->userdata('user_id'))->get('users');
		$this->mViewData['client'] = $clients->result();

		$this->mScripts['foot'] = array(
			'assets_dt/datatables/jquery.dataTables.min.js',
			'assets_dt/datatables/dataTables.bootstrap.js'
		);

		$query_c  = $this->db->where('admin_id', $admin_id)->order_by('id', 'asc')->get('live_schedule');
		$this->mViewData['streams'] = $query_c;
		
		// Chat Session
		$this->mViewData['chatid'] = "";
		$chatSession = $this->db->order_by('id', 'desc')->get('chat_session', 1);
		if ($chatSession->num_rows() > 0) {
			$this->mViewData['chatid'] = $chatSession->row()->id;
		} else {
			$this->db->insert('chat_session', array());
			$chatSession = $this->db->order_by('id', 'desc')->get('chat_session', 1);
			$this->mViewData['chatid'] = $chatSession->row()->id;
		}

		$this->mTitle .= 'Add Live Schedule';
		$this->render('liveserver/add_schedule_live');
	}

	// ADD POST
	public function add_live_schedule()
	{
		$admin_id = $this->session->userdata('user_id');
		if ($_SERVER['REQUEST_METHOD'] == 'POST') {
			$users = $this->input->post('users');
			$chatid = $this->input->post('chatid');
			$stream_id = $this->input->post('stream_id');
			$start_date = $this->input->post('str_dt');
			$end_date = $this->input->post('end_dt');
			$subject = $this->input->post('subject');

			if (count($users) < 1) {
				$this->session->set_flashdata('message', '<div class="alert alert-danger">Please select users!</div>');
				redirect('admin/liveserver/schedule_live');
			}

			if (empty($stream_id)) {
				$this->session->set_flashdata('message', '<div class="alert alert-danger">Please select server!</div>');
				redirect('admin/liveserver/schedule_live');
			}

			if (empty($start_date)) {
				$this->session->set_flashdata('message', '<div class="alert alert-danger">Please select start date!</div>');
				redirect('admin/liveserver/schedule_live');
			}

			if (empty($end_date)) {
				$this->session->set_flashdata('message', '<div class="alert alert-danger">Please select end date!</div>');
				redirect('admin/liveserver/schedule_live');
			}

			$getStreamURL = $this->db->where('id', $stream_id)->get('livestream', 1)->result();
			$URL = $getStreamURL[0]->host;
			$schedules = array();

			// Delete Duplicate Schedule
			$this->db->where('stream_id', $stream_id);
			$this->db->where_in('user_id', $users);
			$this->db->delete('live_schedule');

			foreach ($users as $user) {
				$BASE_URL = $URL . "/hls/stream.m3u8";
				$data = array(
					'user_id' 		=> $user,
					'admin_id' 		=> $admin_id,
					'chat_id'		=> $chatid,
					'stream_id' 	=> $stream_id,
					'stream_url' 	=> base64_encode($BASE_URL),
					'subject' 		=> $subject,
					'str_dt' 			=> $start_date,
					'end_dt' 			=> $end_date,
				);
				array_push($schedules, $data);
			}

			$this->db->insert_batch('live_schedule', $schedules);
			$this->session->set_flashdata('message', '<div class="alert alert-success">Schedule added successfully!</div>');
			redirect('admin/liveserver/schedule_live');
		}
		$this->session->set_flashdata('message', '<div class="alert alert-danger">All fields are required!</div>');
		redirect('admin/liveserver/schedule_live');
	}

	public function schedule_list()
	{
		$this->mTitle .= 'Live Schedules';
		$this->render('liveserver/schedule_list');
	}
	
	public function change_chat_id()
	{
		$this->db->insert('chat_session', array('id' => ''));
		$chatSession = $this->db->order_by('id', 'desc')->get('chat_session', 1);
		echo $chatSession->row()->id;
	}


	// AJAX
	public function check_schedule_posts()
	{
		$columns = array(
			0 => 'id',
			1 => 'admin_id',
			2 => 'chat_id',
			3 => 'user_id',
			4 => 'stream_id',
			5 => 'stream_url',
			6 => 'str_dt',
			7 => 'end_dt',
			8 => 'created'
		);

		if ($this->session->userdata('user_id') == 1) {
			$admin_id = null;
		} else {
			$admin_id = $this->session->userdata('user_id');
		}

		$limit = $this->input->post('length');
		$start = $this->input->post('start');
		$order = $columns[0];
		$dir   = 'DESC';

		// Total
		$totalData	= $this->Schedule_model->check_permission_posts_count($admin_id);
		$totalFiltered = $totalData;

		if (empty($this->input->post('search')['value'])) {
			$posts = $this->Schedule_model->check_permission_posts($limit, $start, $order, $dir, $admin_id);
		} else {
			$search = $this->input->post('search')['value'];
			$posts =  $this->Schedule_model->check_permission_posts_search($limit, $start, $search, $order, $dir, $admin_id);
			$totalFiltered = $this->Schedule_model->check_permission_posts_search_count($search, $admin_id);
		}

		$data = array();

		if (!empty($posts)) {
			$i = 1;

			foreach ($posts as $post) {
				$nestedData['id'] = '<input type="checkbox" class="_check_in" value="' . $post->id . '">';
				$i++;

				$nestedData['sid']       = '<span style="font-size: 12px;">' . $post->id . '</span>';
				$nestedData['server']       = '<span style="font-size: 12px;">' . $post->server . '</span>';
				$nestedData['user_id']       = '<span style="font-size: 12px;">' . $post->user_id . '</span>';
				$nestedData['chat_id']       = '<span style="font-size: 12px;">' . $post->chat_id . '</span>';
				$nestedData['user']       = '<span style="font-size: 12px;">' . $post->user . '</span>';
				$nestedData['chat']       = '<a href="' . base_url() . 'admin/liveserver/chat/' . $post->chat_id . '"><i class="fa fa-lg fa-whatsapp"></i></a>';
				$nestedData['str_date'] = '<span style="font-size: 12px;">' . $post->str_dt . '</span>';
				$nestedData['end_date'] = '<span style="font-size: 12px;">' . $post->end_dt . '</span>';

				$nestedData['Actions'] = "<button class='btn btn-danger btn-sm delete' data-href='" . base_url('admin/liveserver/delete_schedule/' . $post->id) . "'  title='Delete'><i class='fa fa-trash-o'></i></button>";

				$data[] = $nestedData;
			}
		}

		$json_data = array(
			"draw"            => intval($this->input->post('draw')),
			"recordsTotal"    => intval($totalData),
			"recordsFiltered" => intval($totalFiltered),
			"data"            => $data
		);

		echo json_encode($json_data);
	}

    // Delete one
	public function delete_schedule($id)
	{
		$this->db->where('id', $id);
		$this->db->delete('live_schedule');

		if ($this->db->affected_rows() > 0) {
			$this->session->set_flashdata('message', '<div class="alert alert-success" role="alert">Schedule deleted successfully!</div>');
		} else {
			$this->session->set_flashdata('message', '<div class="alert alert-info" role="alert">Something went wrong, Please try again.</div>');
		}
		redirect('admin/liveserver/schedule_list');
	}

	// Delete ALL
	public function delete_schedule_all()
	{
		$arr = [];

		if (empty($this->session->userdata('user_id'))) {
			$arr['status']      = 0;
			$arr['message']     = '<div class="alert alert-danger" role="alert">You session has expired!,/div>';
			$arr['redirect_to'] = base_url('admin/login');

			goto D_L_A;
		}

		if ($this->session->userdata('user_id') == 1) {
			$admin_id = null;
		} else {
			$admin_id = $this->session->userdata('user_id');
		}

		$users = $this->input->post('id');

		if ($users) {
			$affected_rows = 0;

			foreach ($users as $user_id) {
				$this->db->where('live_schedule.id', $user_id);
				if (!empty($admin_id)) {
					$this->db->where('live_schedule.admin_id', $admin_id);
				}
				$this->db->delete('live_schedule');
				$affected_rows += $this->db->affected_rows();
			}

			if ($affected_rows > 0) {
				$arr['status']      = 1;
				$arr['message']     = '';

				$this->session->set_flashdata('message', '<div class="alert alert-success" role="alert">' . $affected_rows . ' record successfully deleted!</div>');

				goto D_L_A;
			}

			$arr['status']      = 0;
			$arr['message']     = '<div class="alert alert-danger" role="alert">Something went wrong!/div>';
		}

		D_L_A:
		echo json_encode($arr);
	}
}

Anon7 - 2021