403Webshell
Server IP : 127.0.0.1  /  Your IP : 192.168.99.1
Web Server : Apache/2.4.35 (Win64) OpenSSL/1.1.1b mod_fcgid/2.3.9
System : Windows NT WIN-JEJMB9EN0L0 10.0 build 14393 (Windows Server 2016) AMD64
User : Administrator ( 0)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /wamp/www/sipapbd_2019_perubahan/application/modules/lokasi/models/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /wamp/www/sipapbd_2019_perubahan/application/modules/lokasi/models/lokasi_model.php
<?php
class Lokasi_model extends Base_Model {

  var $data;
  var $fieldmap_lokasi;
  var $fieldmap_daftar;
  var $fieldmap_filter;

  function __construct()
  {
    // Call the Model constructor
    parent::__construct();

    $this->fieldmap_lokasi = array(
      'id' => 'ID_LOKASI',
      'idparent' => 'ID_PARENT_LOKASI',
      'lokasi' => 'LOKASI',
      'level' => 'LEVEL_LOKASI',
      'last_changed' => 'LAST_CHANGED',
    );

    $this->fieldmap_daftar = array(
      'ID_LOKASI',
      'LOKASI',
      'LEVEL_LOKASI',
      'ID_PARENT_LOKASI',
      'LAST_CHANGED'
    );

    $this->fieldmap_filter = array(
      'lokasi' => 'lokasi',
    );
  }

  function fill_data()
  {
    foreach($this->fieldmap_lokasi as $key => $value){
      switch ($key){
      case 'last_changed' : $$key = date('d.m.Y.H.i.s');  break;
      default : $$key = $this->input->post($key) ? $this->input->post($key) : NULL;
    }

    if(isset($$key))
    $this->data[$value] = $$key;
    }
  }

  // ----- search advance ---- >>
  function get_data_fields()
  {
    $fields = array(
      'lokasi' => array('name' => 'Nama Lokasi', 'kategori'=>'string'),
    );
    return $fields;
  }

  function get_data($param, $isCount=FALSE, $CompileOnly=False)
  {
    isset($param['limit']) && $param['limit'] ? $this->db->limit($param['limit']['end'], $param['limit']['start']) : '';

    if ((empty($param['search_mode'])) || ($param['search_mode'] == 'ss' && empty($param['q'])) || ($param['search_mode'] == 'as' && empty($param['q'])))
    {
      $query = $this->db->query("
          with recursive t as (
            select id_lokasi, lokasi, level_lokasi, id_parent_lokasi, last_changed, 0 param from lokasi where id_parent_lokasi is null
            union all
            select t1.id_lokasi, t1.lokasi, t1.level_lokasi, t1.id_parent_lokasi, t1.last_changed, 0 param from t join lokasi t1 on (t1.id_parent_lokasi = t.id_lokasi)
          )
          select * from t
      ");
      $ada = $query->result_array();
    }
    else {
      $this->db->select("r.id_lokasi, r.lokasi, r.level_lokasi, r.id_parent_lokasi, r.last_changed");
      $this->db->from('lokasi r');
      $this->db->where('r.id_lokasi <>',0);
    }

    // proses parameter pencarian, jika ada
    if (isset($param['search_mode']) && $param['search_mode'] !=='' )
    {
      // proses pencarian singkat (simple search)
      if ($param['search_mode'] == 'ss')
      {
        foreach($this->fieldmap_filter as $key => $value){
          $flt[$key] = array('search_str' => $param['q'], 'search_op' => 'cn');
        }
        if (count($flt) > 0)
        {
          $swhere = get_where_str($flt, $this->fieldmap_filter);
          if ($swhere) {
            $swhere = build_or_where($swhere);
            $this->db->where($swhere);
          }
        }
      }
      // proses pencarian lanjut (advanced search)
      else if ($param['search_mode'] == 'as') {
        $fields = $this->get_data_fields();
        if (is_array($param['q']) && count($param['q']) > 0)
        {
          foreach ($param['q'] as $key=>$val) {
            $kolom = $val['c'];
            $search_str = isset($val['s']) ? $val['s'] : '';
            $search_str2 = isset($val['s2']) ? $val['s2'] : '';

            $flt[$kolom] = array(
            'search_str' => $search_str,
            'search_str2' => $search_str2,
            'search_op' => $val['o'],
            'search_datatype' => $fields[$kolom]['kategori'],
            );
          }
          //print_r($flt);
          if (count($flt) > 0)
          {
            $wh = get_where_str($flt, $this->fieldmap_filter);
            $this->db->where($wh);
          }
        }
      }
    }

    // proses jika ada pengurutan
    if (isset($param['sort_by']) && $param['sort_by'] != null && !$isCount && $ob = get_order_by_str($param['sort_by'], $this->fieldmap_filter))
    {
      $this->db->order_by($ob, $param['sort_direction']);
    }

    if ($isCount) {
      if ((empty($param['search_mode'])) || ($param['search_mode'] == 'ss' && empty($param['q'])) || ($param['search_mode'] == 'as' && empty($param['q'])))  $result = count($ada);
      else $result = $this->db->count_all_results();
      return $result;
    }
    else
    {

      if ($CompileOnly)
      {
        if ((empty($param['search_mode'])) || ($param['search_mode'] == 'ss' && empty($param['q'])) || ($param['search_mode'] == 'as' && empty($param['q'])))
        return $this->db->last_query();
        else return $this->db->get_compiled_select();
      }
      else
      {
        if ((empty($param['search_mode'])) || ($param['search_mode'] == 'ss' && empty($param['q'])) || ($param['search_mode'] == 'as' && empty($param['q'])))$result = $ada;
        else $result = $this->db->get()->result_array();
        return $result;
      }
    }
  }

  // Lokasi hanya boleh dipakai sekali
  function check_duplikasi_lokasi()
  {
    $id = $this->input->post('id') ? $this->input->post('id') : NULL;
    $lokasi = $this->input->post('lokasi') ? $this->input->post('lokasi') : NULL;
    $idparent = $this->input->post('idparent') ? $this->input->post('idparent') : NULL;
    $level = $this->input->post('level') ? $this->input->post('level') : NULL;

    $this->db->select('count(1) dup')
    ->where('a.lokasi', $lokasi)
    ->where('a.id_parent_lokasi', $idparent)
    ->where('a.id_lokasi <>', $id);
    $rs = $this->db->get('lokasi a')->row_array();

    return (integer) $rs['DUP'] < 1;
  }

  /* Simpan data Lokasi */
  function insert_lokasi()
  {
    $id = $this->data['ID_LOKASI'];

    $this->db->select('1')->from('lokasi')->where('id_lokasi', $id);
    $rs = $this->db->get()->row_array();

    if ($rs)
    {
      $this->db->where('id_lokasi', $id);
      $this->db->update('lokasi', $this->data);
      $this->check_trans_status('update lokasi failed');
    }
    else
    {
      $id = $this->get_id('g_id_lokasi');
      $this->data['ID_LOKASI'] = $id;
      $this->db->insert('lokasi', $this->data);
      $this->check_trans_status('insert lokasi failed');
    }
    $this->id = $id;
    $this->last_changed = $this->get_last_changed('lokasi','id_lokasi',$id);
  }

  function save_detail()
  {
    $this->insert_lokasi();
  }

  /* query hapus */
  function build_query_hapus($id=0)
  {
    $this->db->where('id_lokasi', $id)->delete('lokasi');
    $this->check_trans_status('delete lokasi failed');
  }

  function check_dependency($id)
  {
    $this->db->select("
      (select count(b.ID_LOKASI) from LOKASI_KEGIATAN b where b.ID_LOKASI = a.ID_LOKASI) LOKASI_KEGIATAN_PAKAI,
    ");
    $this->db->where('a.ID_LOKASI', $id);
    $result = $this->db->get('LOKASI a')->row_array();

    return !($result['LOKASI_KEGIATAN_PAKAI'] > 0);
  }

  function cek_exist()
  {
    if($this->input->post('id') > 0){
      $this->db->select('count(fa.id_lokasi) lokasi_exists');
      $this->db->from('lokasi fa');
      $this->db->where('fa.id_lokasi',$this->input->post('id'));
      $result = $this->db->get()->row_array();
      if($result && $result['LOKASI_EXISTS'] > 0)
      {
        return 1;
      }
      else{
        return 0;
      }
    }
    else{
      return 1;
    }

  }

  function cek_changed()
  {
    if($this->input->post('id') > 0 || $this->input->post('last_changed') !=''){
      $this->db->select('fa.last_changed');
      $this->db->from('lokasi fa');
      $this->db->where('fa.id_lokasi',$this->input->post('id'));
      $result = $this->db->get()->row_array();
      if($result)
      {
        if($result['LAST_CHANGED'] <= $this->input->post('last_changed')){
          return 1;
        }
        else{
          return $result['LAST_CHANGED'];
        }
      }
      else{
        return 1;
      }
    }
    else{
      return 1;
    }

  }
}
?>

Youez - 2016 - github.com/yon3zu
LinuXploit