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_2019/application/modules/update_aplikasi/controllers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : D:/wamp/www/simbada_2019/application/modules/update_aplikasi/controllers/update_aplikasi.php
<?php
class update_aplikasi extends Admin_Controller {
  var $appconfig;
  var $config_file;

  public function __construct()
  {
    parent::__construct();
    $this->modul_name = 'update_aplikasi';
    $this->modul_display = 'Pembaruan Aplikasi';
    $this->view_daftar = 'update_aplikasi_view';
    $this->load->model('update_aplikasi_model', 'data_model');
    $this->load->helper('download');

    $this->appconfig = 'appconfig';
    $this->config_file = APPPATH.'config/appconfig.php';
  }

  public function index()
  {
    $this->daftar();
  }

  public function daftar()
  {
    $this->load->model('auth/login_model', 'auth');
    $data['modul'] = $this->modul_name;
    $data['modul_display'] = $this->modul_display;
    $data['akses'] = $this->auth->get_level_akses($this->uri->slash_segment(1));

    $data['main_content'] = $this->view_daftar;
    $this->load->view('layout/template_admin',$data);
  }

  function check_update()
  {
    $server_version =  $this->data_model->get_server_version();
    $local_version = get_app_version();

    if ($server_version)
    {
      if ($server_version->current > $local_version) echo $server_version->current;
    }
  }

  function get_version() /** cek versi **/
  {
    $server_version =  $this->data_model->get_server_version();
    $local_version = get_app_version();

    $response = (object) NULL;
    if ($server_version == TRUE) {
      $response->isSuccess = TRUE;
      $response->server = $server_version->current;
      $response->local = $local_version;
      if ($server_version->current <= $local_version) {
        $response->cek = FALSE;
        $response->message = 'Selamat, Anda telah menggunakan versi terbaru.';
      } else {
        $response->cek = TRUE;
        $response->message = 'Versi terbaru telah tersedia. Silahkan melakukan pembaruan aplikasi.';
      }
    }
    else {
      $response->cek = FALSE;
      $response->isSuccess = FALSE;
      $response->server = 'Tidak diketahui';
      $response->local = $local_version;
      $response->message = 'Gagal melakukan koneksi';
    }

    echo json_encode($response);
  }

  /** update **/
  function get_backup_aplikasi()
  {
    $result = $this->data_model->backup_aplikasi();

    $response = (object) NULL;
    if ($result == TRUE)
    {
      $response->isSuccess = TRUE;
      $response->dir = $this->data_model->dst_aplikasi;
      $response->message = 'Proses backup aplikasi berhasil disalin ke '.$this->data_model->dst_aplikasi;
    }
    else
    {
      $response->isSuccess = FALSE;
      $response->dir = $this->data_model->dst_aplikasi;
      $response->message = 'Proses backup aplikasi gagal';
    }

    echo json_encode($response);
  }

  function get_backup_db()
  {
    $response = (object) NULL;
    $result = $this->data_model->backup_db();

    $response = (object) NULL;
    if ($result == TRUE)
    {
      $response->isSuccess = TRUE;
      $response->message = 'Proses backup database berhasil disalin ke '.$this->data_model->dst_db;
    }
    else
    {
      $response->isSuccess = FALSE;
      $response->message = 'Proses backup database gagal';
    }

    echo json_encode($response);
  }

  function get_file()
  {
    $result = $this->data_model->check_file_update_exist();
    $response = (object) NULL;

    switch($result) {
      case 'empty'  : $response->isSuccess = FALSE;
                      $response->message = 'Proses mendapatkan file gagal. File update tidak ditemukan.';
                      break;
      case 'incomplete' : $response->isSuccess = FALSE;
                      $response->message = 'Proses mendapatkan file gagal. File update kurang lengkap, ada file yang tidak ada dalam sebuah versi.';
                      break;
      case 'corrupt' : $response->isSuccess = FALSE;
                      $response->message = 'Proses mendapatkan file gagal. File update corrupt.';
                      break;
      case 'failed' : $response->isSuccess = FALSE;
                      $response->message = 'Proses mendapatkan file gagal. File update tidak lengkap, ada versi yang kurang.';
                      break;
      case 'ok'     : $response->isSuccess = TRUE;
                      $response->message = 'Proses mendapatkan file berhasil.';
                      break;
      default       : $response->isSuccess = FALSE;
                      $response->message = 'Proses mendapatkan file gagal. File update tidak ditemukan.';
    }

    echo json_encode($response);

  }

  function get_unduhan()
  {
    $result = $this->data_model->get_download_file($this->data_model->get_server_version()->current);

    $response = (object) NULL;
    switch($result) {
      case 'failed' : $response->isSuccess = FALSE;
                      $response->message = 'Proses unduh file gagal';
                      break;
      case 'can\'t change' :  $response->isSuccess = FALSE;
                              $response->message = 'Proses unduh file gagal, tidak dapat merubah mode file';
                              break;
      case 'corrupt' :  $response->isSuccess = FALSE;
                        $response->message = 'Proses unduh file gagal, file corrupt';
                        break;
      case 'ok' : $response->isSuccess = TRUE;
                  $response->message = 'Proses unduh file berhasil';
                  break;
    }

    echo json_encode($response);
  }

  function get_ekstrak()
  {
    $result = $this->data_model->ekstrak();
    $response = (object) NULL;

    if ($result == TRUE)
    {
      $response->isSuccess = TRUE;
      $response->message = 'Proses ekstrak file berhasil';
    }
    else
    {
      $response->isSuccess = FALSE;
      $response->message = 'Proses ekstrak file gagal';
    }

    echo json_encode($response);
  }

  function cek_maintenance()
  {
    $maintenance = isset( $this->app_config['maintenance'] ) ? $this->app_config['maintenance'] : 0;

    return $maintenance;
  }

  public function cek_aplikasi()
  {
    $respon = (object) NULL;
    $config_file = @file_get_contents($this->config_file);
    $patterns = "/^.*maintenance.*\$/m";
    if(preg_match_all($patterns, $config_file, $matches)){
      $config = array(
        'maintenance' => $this->input->post('maintenance')
      );
      foreach($config as $key => $val)
      {
        $val = '\''.$val.'\'';
        $pattern = '%(config\[\''.$key.'\'\] = )(\'?.*\'?)(;)%';
        $config_file = preg_replace($pattern, '${1}'.$val. '${3}', $config_file );
      }
      $ret = @file_put_contents($this->config_file, $config_file);
      if (!$ret)
      {
        $respon->isSuccess = FALSE;
        $respon->message = "Gagal menghidupkan mode maintenance";
      }
      else{
        if ($this->cek_maintenance()=='1') {
          $respon->isSuccess = TRUE;
          $respon->message = "Mode maintenance dimatikan";
        }
        else{
          $respon->isSuccess = TRUE;
          $respon->message = "Mode maintenance dihidupkan";
        }
      }
    }
    else{
      $isi = '$config[\'maintenance\'] = \'0\';';
      $ket = @file_put_contents($this->config_file,$isi."\n",FILE_APPEND);
      if (!$ket)
      {
        $respon->isSuccess = FALSE;
        $respon->message = "Gagal mematikan mode maintenance";
      }
      else{
        if($this->input->post('maintenance')=='0'){
          $respon->isSuccess = TRUE;
          $respon->message = "Mode maintenance dimatikan";
        }
        else{
          $config_file = @file_get_contents($this->config_file);
          $config = array(
            'maintenance' => $this->input->post('maintenance')
          );
          foreach($config as $key => $val)
          {
            $val = '\''.$val.'\'';
            $pattern = '%(config\[\''.$key.'\'\] = )(\'?.*\'?)(;)%';
            $config_file = preg_replace($pattern, '${1}'.$val. '${3}', $config_file );
          }
          $ret = @file_put_contents($this->config_file, $config_file);
          if (!$ret)
          {
            $respon->isSuccess = FALSE;
            $respon->message = "Data gagal disimpan..";
          }
          else{
            if ($this->cek_maintenance()=='1') {
              $respon->isSuccess = TRUE;
              $respon->message = "Mode maintenance dimatikan";
            }
            else{
              $respon->isSuccess = TRUE;
              $respon->message = "Mode Maintenance dihidupkan";
            }
          }
        }
      }
    }

    echo json_encode($respon);
  }

}

Youez - 2016 - github.com/yon3zu
LinuXploit