<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Update extends CI_Controller {
	function __construct() {
		parent::__construct();
		 $this->load->model('app_model');
	}
	public function update_versi() {
		if ($this->session->userdata('admin_valid') == FALSE ) {
			redirect("admin/login");
		}
				$now_versi 	= mod()->app_vers;
		$app_versi 	= title();
		$status		= $this->input->get('update');
		if($status == 'cek'){
		if($this->app_model->get_http_response_code(mod()->server) != TRUE){
		die ("<h1>Tidak Bisa Menjangkau Server Update</h1>");}
		else {	
		$new_versi	= $this->app_model->get_info_update(mod()->server,mod()->app_name,NULL,$app_versi);
		$new_fitur	= $this->app_model->get_info_update(mod()->server,mod()->app_name,'txt');
		$data = array(
		'new_versi' => $new_versi,
		'new_fitur' => $new_fitur
		);}}
		else if($status == 'proses'){
		$new_versi	= $this->app_model->get_info_update(mod()->server,mod()->app_name,NULL,$app_versi);
		$data['pesan'] = $this->app_model->proses_update(mod()->server,mod()->app_name,$new_versi);	}
		$data['status'] 	= $status;
		$data['now_versi'] 	= $now_versi;
		$data['judul'] 		= 'Perubahan';
		$data['page']		= "versi/update";
		
		$this->load->view('admin/home_menu', $data);
	}
	

	//login
	public function login() {
		$this->load->view('admin/login');
	}
	
	
}
