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 :  D:/wamp/www/simbada_2017/application/modules/auth/models/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : D:/wamp/www/simbada_2017/application/modules/auth/models/menu_model.php
<?php
class Menu_model extends Base_Model {

  var $fieldmap_menu;
  var $data;

   function __construct()
  {
    parent::__construct();

    $this->fieldmap_menu = array(
      'id' => 'ID',
      'pid' => 'PARENT_ID',
      'judul' => 'TITLE',
      'link' => 'LINK',
      'aktif'  => 'AKTIF',
      'urut' => 'ORDER_BY',
    );
  }

  function recurse_fill($menu, $id_parent)
  {
    $data = array();
    $child = array();
    for ($i = 0; $i < count($menu); $i++)
    {
      $data[] = array(
        'ID' => $menu[$i]->id,
        'PARENT_ID' => $id_parent,
        'TITLE' => $menu[$i]->title,
        'LINK' => $menu[$i]->link,
        'AKTIF' => $menu[$i]->aktif,
        'ORDER_BY' => $i,
      );

      if (isset($menu[$i]->children) && count($menu[$i]->children) > 0)
      {
        $child = $this->recurse_fill($menu[$i]->children, $menu[$i]->id);
        foreach($child as $child_menu)
        {
          array_push($data, $child_menu);
        }
      }
    }
    return $data;
  }

  function fill_data()
  {
    $this->data = array();
    $menu = $this->input->post('menu');
    if ($menu)
    {
      $menu = json_decode($menu);
      $this->data = $this->recurse_fill($menu, 0);
    }
  }
  
  /* Simpan data Menu */
  function insert_menu()
  {
    if (count($this->data) == 0) return FALSE;
    $oldid = '';

    /* hapus dulu menu yang ada */
    $this->db->where('a.appid', $this->app_id);
    $this->db->delete('menu a');

    $cache = array();
    /* simpan semua menu */
    foreach($this->data as $menu)
    {
      /* cek dalam cache apakah parent_id perlu di update */
      foreach($cache as $key)
      {
        if ($key['old'] === $menu['PARENT_ID'])
        {
          $menu['PARENT_ID'] = $key['new'];
          break;
        }
      }      
      
      /* jika ada menu baru dan belum punya id */
      $isnew = strpos($menu['ID'], 'new');
      if ($isnew !== false)
      {
        $oldid = $menu['ID'];
        $menu['ID'] = NULL;
      }

      $menu['APPID'] = $this->app_id;
      $this->db->insert('menu', $menu);
      
      /* simpan id kedalam cache */
      if ($isnew !== false)
      {
        $result = $this->db->select('max(id) id')->get('menu')->row_array();
        
        $cache[] = array(
            'old' => $oldid,
            'new' => $result['ID'],
        );
      }
    }
  }

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

  function get_menu($id_parent = 0)
  {
    $this->db->where('parent_id', $id_parent);
    $this->db->where('id <>','1');
    $this->db->where('appid', $this->app_id);
    $this->db->order_by('order_by');
    $result = $this->db->get('menu');

    $x = 0;
    $menu = array();
    $res_menu   = $result->result();
    foreach($res_menu as $hasil){
      $menu[$x]['ID'] = $hasil->ID;
      $menu[$x]['TITLE'] = $hasil->TITLE;
      $menu[$x]['LINK'] = $hasil->LINK;
      $menu[$x]['AKTIF'] = $hasil->AKTIF;
      $menu[$x]['PARENT_ID'] = $hasil->PARENT_ID;
      $menu[$x]['ORDER_BY'] = $hasil->ORDER_BY;
      $menu[$x]['child'] = $this->get_menu($hasil->ID); //ambil menu anak
      $x++;
    }
    return $menu;
  }

}

Youez - 2016 - github.com/yon3zu
LinuXploit