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.96.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/models/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/git/sms.edl.codes.solutions/application/models/Archive_model.php
<?php
if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Archive_model extends CI_Model {

    function __construct() {
        parent::__construct();
        $this->load->model('crud_model');
    }
    function archive_course($id){
      $this->db->set('Archived','1');
      $this->db->where('ID',$id);
      $this->db->update('course_new');
      return ture;
    }
    function unarchive_course($id){
      $this->db->set('Archived','2');
      $this->db->where('ID',$id);
      $this->db->update('course_new');
      return ture;
    }
    function archive_courses() {
        $this->db->order_by('ID', 'DESC');
        $query = $this->db->get('course_new');
        $query = $query->result_array();

        foreach ($query as $row) {
          $endDate = $this->crud_model->get_course_end($row['ID']);
          if(($this->checkArchived($endDate,"courses"))&&(!$this->checkArchiveState("ucourse",$row['ID']))){
            $this->db->set('Archived','1');
            $this->db->where('ID',$row['ID']);
            $this->db->update('course_new');
          }
          elseif ((!$this->checkArchived($endDate,"courses"))&&(!$this->checkArchiveState("ucourse",$row['ID']))) {
            $this->db->set('Archived','0');
            $this->db->where('ID',$row['ID']);
            $this->db->update('course_new');
          }
        }
        return true;
    }
    function archive_parents(){
        $this->db->from('parent');
        $this->db->order_by("parent_id", "desc");
        $query = $this->db->get();
        $query = $query->result_array();

          $currentId = "";
          foreach ($query as $row) {
            $childs = $this->crud_model->get_child_list($row['parent_id']);
            if(!empty($childs)){
              foreach($childs as $child){
                $history = $this->crud_model->getLastAssignedS($child['student_id']);
                $creation = $this->crud_model->getCreation($child['student_id']);

                if($history != null){
                  if($this->checkArchived($history,"student")){
                    if ($currentId != $row['parent_id']){
                      $this->db->set('Archived','1');
                      $this->db->where('user_id',$row['parent_id']);
                      $this->db->update('user');
                      $currentId = $row['parent_id'];
                    }
                  }
                }
                else{
                  if($this->checkArchived($creation,"student")){
                      if ($currentId != $row['parent_id']){
                        $this->db->set('Archived','1');
                        $this->db->where('user_id',$row['parent_id']);
                        $this->db->update('user');
                        $currentId = $row['parent_id'];
                      }
                  }
                }
              }
            }
            else{
                $creation = $this->crud_model->getCreation($row['parent_id']);
                if($this->checkArchived($creation,"student")){ //exception on parent rule
                    $this->db->set('Archived','1');
                    $this->db->where('user_id',$row['parent_id']);
                    $this->db->update('user');
                }
            }
          }

          return true;
    }
    function archive_teachers(){
      $this->db->from('teacher');
      $this->db->order_by("teacher_id", "desc");
      $query = $this->db->get();
      $query = $query->result_array();

      $result = array();
      foreach ($query as $row) {
        $history = $this->crud_model->getLastAssignedT($row['teacher_id']);
        $creation = $this->crud_model->getCreation($row['teacher_id']);

        if($history != null){
          if($this->checkArchived($history,"teacher")){
            $this->db->set('Archived','1');
            $this->db->where('user_id',$row['teacher_id']);
            $this->db->update('user');
          }
        }
        else{
          if($this->checkArchived($creation,"teacher")){
            $this->db->set('Archived','1');
            $this->db->where('user_id',$row['student_id']);
            $this->db->update('user');
          }
        }
      }
      return true;
    }
    function archive_student(){
        $query = $this->db->query("SELECT `student_id`,`dob` FROM `student` UNION SELECT `group_id`,`dob` FROM `group` ORDER BY `student_id`");
        $query = $query->result_array();

        $result = array();
        foreach ($query as $row) {
            $history = $this->crud_model->getLastAssignedS($row['student_id']);
            $creation = $this->crud_model->getCreation($row['student_id']);

            if($history != null){
              if($this->checkArchived($history,"student")){
                $this->db->set('Archived','1');
                $this->db->where('user_id',$row['student_id']);
                $this->db->update('user');
              }
            }
            else{
              if($this->checkArchived($creation,"student")){
                $this->db->set('Archived','1');
                $this->db->where('user_id',$row['student_id']);
                $this->db->update('user');
              }
            }
          }
        return true;
    }
    function get_archived_courses() {
        $this->db->order_by('ID', 'DESC');
        $query = $this->db->get('course_new');
        $query = $query->result_array();

        $result = array();
        foreach ($query as $row) {
          if($this->checkArchiveState($row['ID'],"courses")){
            array_push($result,$row);
          }
        }
        return $result;
    }

    function checkArchived($date,$param){

      if($date == "n/a"){
        return false;
      }
      $end = date("d-m-Y",strtotime(str_replace("/","-",$date)));

      if(strtotime($end) >= strtotime($this->archivedTime($param))){
         return false;
      }
      else{
         return true;
      }
    }

    function archivedTime($param){
      $query = $this->db->get_where('admin_archive',array('Archived_param'=>$param));
      $query = $query->result_array();
      foreach ($query as $row) {
        return date("d-m-Y", strtotime("-".$row['Archived_period']." months"));
      }
    }

    function checkArchiveState($id,$param){
      if($param == "courses"){
          $query = $this->db->get_where('course_new', array('ID' => $id));
          $query = $query->result_array();
          foreach ($query as $row) {
            if($row['Archived'] == 1){
              return true;
            }
            else{
              return false;
            }
          }
        }
        elseif($param == "ucourses"){
            $query = $this->db->get_where('course_new', array('ID' => $id));
            $query = $query->result_array();
            foreach ($query as $row) {
              if($row['Archived'] == 2){
                return true; // return true if already unarchived
              }
              else{
                return false;
              }
            }
          }
        elseif($param == "user"){
            $query = $this->db->get_where('user', array('user_id' => $id));
            $query = $query->result_array();
            foreach ($query as $row) {
              if($row['Archived'] == 1){
                return true;
              }
              else{
                return false;
              }
            }
          }
          else{
            return false;
          }
      }
}

Youez - 2016 - github.com/yon3zu
LinuXploit