Uname:Linux EDL-STRETCH 4.19.0-27-amd64 #1 SMP Debian 4.19.316-1 (2024-06-25) x86_64

403WebShell
403Webshell
Server IP : 188.114.97.2  /  Your IP : 104.23.197.231
Web Server : Apache/2.4.59 (Debian)
System : Linux EDL-STRETCH 4.19.0-27-amd64 #1 SMP Debian 4.19.316-1 (2024-06-25) x86_64
User : edlftp ( 1002)
PHP Version : 7.4.33
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/git/sms.edl.codes.solutions/application/controllers/BO/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/git/sms.edl.codes.solutions/application/controllers/BO/Lesson.php
<?php
/*********************
 *********************
Template : "lesson.php"
Controller : "Lesson.php"

 Creation 08/05/2019
 Aernout Guillaume
 http://codes.solutions
 *********************
 *********************/
 if (!defined('BASEPATH'))
   exit('No direct script access allowed');

  class Lesson extends NS_Controller {

    function __construct() {
      parent::__construct(array('no_cache'=>1));

      if ($this->session->userdata('admin_login') != 1){
        $this->error('restricted admin');
        //$this->redirect(base_url(), 'refresh');
      }
       $this->load->helper('generator');
       $this->load->model('lesson_model');
       $this->load->model('form_model');
       //$this->load->model('lesson_model');
       $this->load->database();
    }
    ////////////////////////
    // Fonction controller
    ////////////////////////
    function index($arg) {
        $this->load->helper('url');
        $param = $this->uri->segment(3);
        if($param == "edit"){
          $data['edit'] = $this->uri->segment(4);
        }
        else if($param == "conf"){
          $data['confirm_c'] = $this->uri->segment(4);
          $data['confirm_l'] = $this->uri->segment(5);
        }
        else if($param == "assign_s"){
          $data['assign_s_c'] = $this->uri->segment(4);
          $data['assign_s_l'] = $this->uri->segment(5);
        }
        else if($param == "assign_t"){
          $data['assign_t_c'] = $this->uri->segment(4);
          $data['assign_t_l'] = $this->uri->segment(5);
        }
        else if($param == "presence"){
          $data['presence_c'] = $this->uri->segment(4);
          $data['presence_l'] = $this->uri->segment(5);
          //echo "======\>".$this->uri->segment(4);
        }
        else{
        //no param
        }
        $data['page_name'] = 'lesson';
        $data['page_title'] = get_phrase('lesson');
        $data['course_list'] = $this->crud_model->get_courses();
        if ($this->session->userdata('login_type') == "teacher"){
          $data['lesson_list'] = $this->crud_model->get_lessons();
        }
        $this->load->view('backend/index', $data);
    }
    //
    function refresh(){
      $this->continueIfAllowed(array('allowed'=>array('admin')));
      $lesson_list = $data['lesson_list'] = $this->crud_model->get_lessons();
      $data = array();
      $c0 = 0;

      foreach($lesson_list as $lesson){

           $teacherList = $this->crud_model->get_lesson_teacher($lesson['ID']);

           $c1 = "<span class='btn btn-default redirect'  onclick='location.replace(\"/courses/index/".$lesson['CourseID']."\")'>".$this->crud_model->get_course_name($lesson['CourseID'])."</span>";
           $c2 = date("d/m/Y", strtotime($lesson['LessonDate']))."<br> [ ".substr($lesson['LessonStart'],0,5)." - ".substr($lesson['LessonEnd'],0,5)." ]";

           $c3 = "";
           if(!empty($teacherList)){
           foreach($teacherList as $teacher):
              $c3_sub = "<a class='btn btn-default redirect' href=''/teacher/index/edit/".$teacher.">".$this->crud_model->get_teacher_name($teacher)."</a>";
              $c3 = $c3.$c3_sub;
           endforeach;
           }
           else{
             $c3 = "<a class='btn btn-danger'>N/A</a>";
            }
           $c3 = $c3 . "<span class='entypo-feather btn btn-info' onclick='displayAssignT(\"".$lesson['CourseID']."\",\"".$lesson['ID']."\")'></span>";

           $c4 = "";
           if(!empty($studentList)){
           foreach($studentList as $student):
              $c4_sub = "<a class='btn btn-default redirect' href='/student/index/edit/".$student.">".$this->crud_model->get_student_name($student)."</a>";
              $c4 = $c4.$c4_sub;
           endforeach;
           }
           else{
             $c4 = "<a class='btn btn-danger'>N/A</a>";
            }
           $c4 = $c4 . "<span class='entypo-feather btn btn-info' onclick='displayAssignS(\"".$lesson['CourseID']."\",\"".$lesson['ID']."\")'></span>";

           $c5 = $this->crud_model->get_students_count_lesson($lesson['ID']);
           $c6 = $this->crud_model->get_students_age_interval_lesson($lesson['ID']);
           $c7 = "<span class='btn btn-info entypo-cog' onclick='displayEdit(".$lesson['CourseID'].")'></span>";
           $c7 = $c7 .  "<span class='btn btn-primary entypo-lock-open' onclick='displayConfirm(\"".$lesson['CourseID']."\",\"".$lesson['ID']."\")'></span>";



        $subData = array(
          'c0' => $c0,
          'c1' => $c1,
          'c2' => $c2,
          'c3' => $c3,
          'c4' => $c4,
          'c5' => $c5,
          'c6' => $c6,
          'c7' => $c7,

        );
        array_push($data,$subData);
        $c0++;
      }
      //array_push($data,$subData);
      echo json_encode($data);
    }
    //
    ////////////////////////
    //    Statuts
    ////////////////////////
    //
    function lessonSubStatus(){
      $this->continueIfAllowed(array('allowed'=>array('admin','teacher')));
      $id = $this->input->post('id');
      //$id = '3';
      $this->db->order_by('LessonDate', 'DESC');
      $query = $this->db->get_where('course_scheduled_new', array('ID' => $id));
      $res = $query->result_array();
      echo json_encode($res);
    }
    function lessonPresenceSubStatus(){
        $this->continueIfAllowed(array('allowed'=>array('teacher')));
        $id = $this->input->post('id');
        $this->db->order_by('LessonDate', 'DESC');
        $query = $this->db->get_where('course_scheduled_new', array('ID' => $id));
        $res = $query->result_array();

        $lessonList = array();
          foreach ($res as $row){
            if(new Date($row['LessonDate']) <= new Date()){
              $lessonInfo = array();
              $lessonInfo['ID'] = $row['ID'];
              $lessonInfo['CourseID'] = $row['CourseID'];
              $lessonInfo['LessonDate'] = $row['LessonDate'];
              $lessonInfo['LessonStart'] = $row['LessonStart'];
              $lessonInfo['LessonEnd'] = $row['LessonEnd'];
              $lessonInfo['LessonDone'] = $row['LessonDone'];
              array_push($lessonList,$lessonInfo);
            }
          }
          echo json_encode($lessonList);
    }
    function lessonSubAssigned(){
      $this->continueIfAllowed(array('allowed'=>array('admin','teacher')));
      $data = $this->input->post(array('id','role'));
      //$data['role'] = 'teacher';
      //$data['id'] = '1';

      if($data['role'] == "teacher"){
        $query = $this->db->get_where('course_teacher', array('lesson_id' => $data['id']));
        $res = $query->result_array();
        $teacher_list = array();

        foreach ($res as $row){
          $teacher_info = array();
          $teacher_info[0] = $row['teacher_id'];
          $teacher_info[1] = $this->crud_model->get_teacher_name($row['teacher_id']);
          $teacher_info[2] = $this->crud_model->get_lesson_info($data['id']);
          $teacher_info[3] = $data['id'];
          array_push($teacher_list,$teacher_info);
        }
        echo json_encode($teacher_list);
      }
      else if($data['role'] == "student"){
        $query = $this->db->get_where('course_student_new', array('lesson_id' => $data['id']));
        $res = $query->result_array();
        $student_list = array();

        foreach ($res as $row){
          $student_info = array();
          $student_info[0] = $row['student_id'];
          $student_info[1] = $this->crud_model->get_student_name($row['student_id']);
          $student_info[2] = $this->crud_model->get_lesson_info($data['id']);
          $student_info[3] = $data['id'];
          array_push($student_list,$student_info);
        }
        echo json_encode($student_list);
      }
      else{
        echo "-1";
      }

    }
    function lessonSubPresence(){
      $this->continueIfAllowed(array('allowed'=>array('admin','teacher')));
      $data = $this->input->post('id');
    //  $data = "462";
        $query = $this->db->get_where('course_student_new', array('lesson_id' => $data));
        $res = $query->result_array();
      //  print_r($this->db->last_query());
      //  var_dump($res);
        $student_list = array();

        foreach ($res as $row){
          $student_info = array();
          $student_info[0] = $row['student_id'];
          $student_info[1] = $this->crud_model->get_student_name($row['student_id']);
          $student_info[2] = $row['status_id'];
          array_push($student_list,$student_info);
        }
        echo json_encode($student_list);
    }

    function lessonCollision(){
      	 $this->continueIfAllowed(array('allowed'=>array('admin','teacher')));
         $data = $this->input->post(array('courseID','date','hourS','hourE'));
        // echo ">>>".$data['courseID'].$data['date'].$data['hourS'].$data['hourE'];
        // var_dump($this->lesson_model->check_collision($data['courseID'],$data['date'],$data['hourS'],$data['hourE']));
         if($this->lesson_model->check_collision($data['courseID'],$data['date'],$data['hourS'],$data['hourE'])){
           echo "-1";
           return true;
         }
    }
    //
    function lessonStatut(){
			 $this->continueIfAllowed(array('allowed'=>array('admin','teacher')));
			 $id = $this->input->post('id');
       //$id = 1;
			 $hours = $this->crud_model->get_course_scheduled($id);

			 $jsonHours = "";
			 foreach ($hours as $key => $row) {
         $duration = ((strtotime($row['LessonEnd']) - strtotime($row['LessonStart']))/60);
         if($row['LessonDone'] != 1){
			 	 $jsonHours = $jsonHours ."{\"id\":".$row['ID'].",\"title\":\"".substr($row['LessonStart'],0,5)." - ".substr($row['LessonEnd'],0,5)." |".$row['LessonName']."\",\"start\":\"".$row['LessonDate']."T".$row['LessonStart']."\",\"end\":\"".$row['LessonDate']."T".$row['LessonEnd']."\",\"duration\": $duration,\"description\": \"duration: ".($duration/60)." H\"},";
        }
			 }
			 $jsonHours = "[".rtrim($jsonHours,',')."]";
			 $this->error(print_r($jsonHours));
		 }
    //
    function courseStatut(){
      $this->continueIfAllowed(array('allowed'=>array('admin','teacher')));
      $id = $this->input->post('id');
      $data = $this->crud_model->get_course($id);
      $jsonData = "{ \"id\":\"".$id."\",\"name\" :\"".$data[0]['CourseName']."\",\"certificate\" :\"".$data[0]['CourseCertificate']."\"";
			$jsonData = $jsonData .", \"lan\" : ".$data[0]['CourseLanguage'].", \"lvl\" : ".$data[0]['CourseLevel'];
			$jsonData = $jsonData .", \"type\" : ".$data[0]['CourseType'].",\"contract\" : ".$data[0]['CourseContract'];
			$jsonData = $jsonData .",\"desc\" : \"".$data[0]['CourseDescription']."\",\"price\" : \"".$data[0]['CoursePrice']."\"}";
			echo $jsonData;
    }
    ////////////////////////
    //    Interactions
    ////////////////////////
    function save(){
      $this->continueIfAllowed(array('allowed'=>array('admin','teacher')));
      $data = $this->input->post(array('courseID','date','hourS','hourE','name'));
      //var_dump($this->lesson_model->approve_creation($data['date']));

      if(($this->userInfo['role'] == "teacher") && ($this->lesson_model->approve_creation($data['date']) != true)){
        //echo "-1";
        //return true; // bypass the teachear security
      }
      $lessonSql = array(
					 'ID' => '',
					 'CourseID' => $data['courseID'],
           'LessonName'=> $data['name'],
					 'LessonDate' => $data['date'],
					 'LessonStart' => $data['hourS'],
					 'LessonEnd' => $data['hourE']
				 );
         //var_dump($lessonSql);

      $this->db->insert('course_scheduled_new',$lessonSql);
      $id = $this->db->insert_id();

      if(($this->userInfo['role'] == "teacher") && ($this->lesson_model->approve_creation($data['date']) != true)){
        echo "-1";
        //return true; // bypass the teachear security
      }
      else{
              echo $id;
      }
    }
    //
    function update(){
      $this->continueIfAllowed(array('allowed'=>array('admin','teacher')));
      $data = $this->input->post(array('lessonID','date','hourS','hourE'));
      //var_dump($this->lesson_model->approve_creation($data['date']));
      //var_dump($data);

      $lessonSql = array(
           'LessonDate' => $data['date'],
           'LessonStart' => $data['hourS'],
           'LessonEnd' => $data['hourE']
         );
         //var_dump($lessonSql);
      $this->db->set($lessonSql);
      $this->db->where('ID',$data['lessonID']);
      $this->db->update('course_scheduled_new');
      //$id = $this->db->insert_id();
      echo "true";

    }
    //
    function delete(){
      $this->continueIfAllowed(array('allowed'=>array('admin','teacher')));
      $data = $this->input->post(array('courseID','date'));
      $this->db->where('id', $data['courseID']);
      //var_dump($this->lesson_model->approve_suppression($data['date']));
      /*
      if(($this->userInfo['role'] == "teacher") && ($this->lesson_model->approve_creation($data['date']) != true)){
          echo "-1";
          //return true;
        }
        */
      if($this->db->delete('course_scheduled_new')){

        if(($this->userInfo['role'] == "teacher") && ($this->lesson_model->approve_creation($data['date']) != true)){
            echo "-1";
            //return true;
          }
          else {
            echo "1";
          }
      }
      else{
        echo "0";
      }
      //$this->db->insert('course_scheduled_new',$lessonSql);

    }
    //
    function assign(){
      $this->continueIfAllowed(array('allowed'=>array('admin')));
      $data = $this->input->post(array('courseID','lessonID','userID','role'));

      if($data['role']== "teacher"){
        $sql = array(
  					 'id' => '',
  					 'course_id' => $data['courseID'],
             'lesson_id'=> $data['lessonID'],
  					 'teacher_id' => $data['userID'],
             'status_id' => ''
  				 );
        if(!$this->crud_model->check_assigned_t($data['courseID'],$data['lessonID'],$data['userID'])){
        $this->db->insert('course_teacher',$sql);
        $id = $this->db->insert_id();
        echo "$id";
        }
        else{
          echo "duplicate id";
        }
      }
      else if($data['role'] == "student"){
        $sql = array(
  					 'id' => '',
  					 'course_id' => $data['courseID'],
             'lesson_id'=> $data['lessonID'],
  					 'student_id' => $data['userID'],
             'status_id' => ''
  				 );
          // var_dump($sql);
      //  $this->db->insert('course_teacher',$sql);
        if(!$this->crud_model->check_assigned_s($data['courseID'],$data['lessonID'],$data['userID'])){
          $this->db->insert('course_student_new',$sql);
          $id = $this->db->insert_id();
          $this->form_model->remove_pending_s($id);
          echo "$id";
        }
        else{
          echo "duplicate id";
        }
      }
      else{
        echo "error on role selection";
      }

    }
    //
    function presence(){
      $this->continueIfAllowed(array('allowed'=>array('admin','teacher')));
      $data = $this->input->post(array('courseID','lessonID','userID','presenceID'));

        $sql = array(
  					 'course_id' => $data['courseID'],
             'lesson_id'=> $data['lessonID'],
  					 'student_id' => $data['userID']
  			      );
          //  var_dump($sql);
          //echo ">>>".$data['presenceID'];
        try {
          $this->db->set('status_id',$data['presenceID']);
          $this->db->where($sql);
          $this->db->update('course_student_new');
          //$id = $this->db->insert_id();
          echo 1;
        } catch (Exception $e) {
          echo 'Error : ',  $e->getMessage(), "\n";
        }
      //print_r($this->db->last_query());
    }
    //
    function removeAssign(){
      $this->continueIfAllowed(array('allowed'=>array('admin')));
      $data = $this->input->post(array('userId','lessonId','role'));
      //echo ">".$data['lessonId'].">".$data['userId']."|";
      if($data['role']=="teacher"){
        $clause = array('lesson_id'=>$data['lessonId'],'teacher_id'=>$data['userId']);
        $this->db->where($clause);
        if($this->db->delete('course_teacher')){
          echo "1";
        }
        else{
          echo "-1";
        }
      }
      else if($data['role']=="student"){
        $clause = array('lesson_id'=>$data['lessonId'],'student_id'=>$data['userId']);
        $this->db->where($clause);
        if($this->db->delete('course_student_new')){
          echo "1";
        }
        else{
          echo "-1";
        }
      }
      else{
        echo "error";
      }

    }
    //
    function confirm(){
      $this->continueIfAllowed(array('allowed'=>array('admin','teacher')));
      $data = $this->input->post(array('id','status','comment'));
       if(isset($data)){
         $sql = array(
        'LessonDone' => $data['status'],
        'LessonComment' => $data['comment']
          );
          //$this->error(var_dump($sql));
         $this->db->set($sql);
         $this->db->where('ID',$data['id']);
         $this->db->update('course_scheduled_new');
         echo "1";
       }
       else{
         echo "please re-select the course";
       }
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit