function myfab_update_list() { //return; //check if there's a myfab update // Get current CodeIgniter instance //$CI =& get_instance(); $_update_list = array(); /*$_update_check = $CI->nativesession->get('update_check');*/ $_update_check = isset($_SESSION['update_check']) ? $_SESSION['update_check'] : false; if (!$_update_check) { if (is_internet_avaiable()) { $myfab_update = myfab_get_local_version() < myfab_get_remote_version(); $marlin_update = marlin_get_local_version() < marlin_get_remote_version(); if ($myfab_update) { array_push($_update_list, array('name' => 'fabui', 'url' => site_url('updates'), 'description' => 'A new update for FAB UI is avaiable!')); } if ($marlin_update) { array_push($_update_list, array('name' => 'fw', 'url' => site_url('updates'), 'description' => 'A new update for Marlin Firmware is avaiable!')); } } $data = array('update_check' => true, 'update_list' => $_update_list); $_SESSION['update_check'] = true; $_SESSION['update_list'] = $_update_list; /* $CI->nativesession->set('update_check', true); $CI->nativesession->set('update_list', $_update_list); */ } else { //$_update_list = $CI->nativesession->get('update_list'); $_update_list = $_SESSION['update_list']; } return $_update_list; }
public function index() { /** LOAD DATABASE */ $this->load->database(); $this->load->model('tasks'); /* $_fabui_local = myfab_get_local_version(); $_marlin_local = marlin_get_local_version(); $data['fabui_local'] = $_fabui_local; $data['marlin_local'] = $_marlin_local; */ $data['fabui_local'] = $this->_fabui_local; $data['marlin_local'] = $this->_marlin_local; $_SESSION['fabui_version'] = $this->_fabui_local; $_updates = array(); $_updates['number'] = 0; $_updates['time'] = time(); /** GET IF IS RUNNING */ $_task = $this->tasks->get_running('updates'); $_is_running = $_task == false ? false : true; $data['running'] = $_is_running; /** GET TASK INFO IF IS RUNINNG */ if ($_is_running) { $_attributes = json_decode($_task['attributes'], TRUE); $data['update_type'] = $_task['type']; $data['json_uri'] = $_attributes['uri_monitor']; $data['id_task'] = $_task['id']; } $_is_internet_ok = is_internet_avaiable(); $data['fabui'] = false; $data['marlin'] = false; if ($_is_internet_ok) { $_fabui_remote = myfab_get_remote_version(); $_fabui = $_fabui_remote > $this->_fabui_local; $data['fabui'] = $_fabui; $data['fabui_remote'] = $_fabui_remote; if ($_fabui) { $data['fabui_changelog'] = fabui_changelog($_fabui_remote); } $_marlin_remote = marlin_get_remote_version(); $_marlin = $_marlin_remote > $this->_marlin_local; $data['marlin'] = $_marlin; $data['marlin_remote'] = $_marlin_remote; if ($_marlin) { $data['fw_changelog'] = fw_changelog($_marlin_remote); } $data['no_update'] = $this->_fabui_local == $_fabui_remote && $this->_marlin_local == $_marlin_remote; $_updates['number'] += $_fabui ? 1 : 0; $_updates['number'] += $_marlin ? 1 : 0; $_updates['fabui'] = $_fabui; $_updates['fw'] = $_marlin; } $_SESSION['updates'] = $_updates; $js_in_page = $this->load->view('index/js', $data, TRUE); $this->layout->add_js_in_page(array('data' => $js_in_page, 'comment' => 'updates js')); $this->layout->set_compress(false); $data['internet'] = $_is_internet_ok; $this->layout->view('index/index', $data); }
public function updates() { $this->load->helper('update_helper'); $fabui_local = myfab_get_local_version(); $fabui_remote = myfab_get_remote_version(); $fw_local = marlin_get_local_version(); $fw_remote = marlin_get_remote_version(); $data['fabui_update'] = $fabui_local < $fabui_remote; $data['fw_update'] = $fw_local < $fw_remote; $data['fabui_remote'] = $fabui_remote; $data['fw_remote'] = marlin_get_remote_version(); echo $this->load->view('update', $data, TRUE); }
<?php /** FIRST DOWNLOAD FILE */ require_once '/var/www/lib/config.php'; require_once '/var/www/lib/database.php'; require_once '/var/www/lib/utilities.php'; /** GET ARGS FROM COMMAND LINE */ $_task_id = $argv[1]; $_folder = $argv[2]; $_monitor = $argv[3]; $_marlin_local_version = marlin_get_local_version(); $_marlin_remote_version = marlin_get_remote_version(); $_file_name = $_folder . MARLIN_DOWNLOAD_FILE; $_url = MARLIN_DOWNLOAD_URL . $_marlin_remote_version . '/' . MARLIN_DOWNLOAD_FILE; $do_update = $_marlin_local_version < $_marlin_remote_version; $_monitor_items = array(); $do_update = true; if ($do_update) { $_monitor_items['completed'] = 0; $_monitor_items['status'] = 'downloading'; /** CREATE MONITOR FILE */ write_monitor(); sleep(3); $_target_file = fopen($_file_name, 'w+') or die("can't open file"); $start = time(); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $_url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, 'progress'); curl_setopt($ch, CURLOPT_NOPROGRESS, false); // needed to make progress function work
$time_to_check = 60 * 60 * 4; //4 Hours $now = time(); $check = false; $updates = isset($_SESSION["updates"]) ? $_SESSION["updates"] : array(); if (!isset($_SESSION['updates']['time'])) { $_SESSION['updates']['time'] = 0; } //IF IS PASSED MORE THAN TIME TO CHECK SO CHECK AGAIN IF THERE ARE UPDATES AVAIABLES if ($now - $_SESSION['updates']['time'] > $time_to_check) { if (is_internet_avaiable()) { $updates = array(); $updates['number'] = 0; $updates['time'] = time(); $fabui_update = myfab_get_local_version() < myfab_get_remote_version(); $fw_update = marlin_get_local_version() < marlin_get_remote_version(); $updates['number'] += $fabui_update ? 1 : 0; $updates['number'] += $fw_update ? 1 : 0; $updates['fabui'] = $fabui_update; $updates['fw'] = $fw_update; $_SESSION['updates'] = $updates; $check = true; } } /* if (isset($_SESSION['updates'])) { $updates = $_SESSION['updates']; } else { $_SESSION['updates'] = $updates; } *
public function do_login() { if ($this->input->post()) { $this->load->helper('ft_file_helper'); clean_temp('hour', 12); $post = $this->input->post(); //carico X class database $this->load->database(); $this->load->model('user'); $email = $this->input->post('email'); $password = $this->input->post('password'); if ($this->user->login($email, $password) == TRUE) { $user = $this->user->get_user($email); $_settings = json_decode($user->settings, TRUE); $_user_session['id'] = $user->id; $_user_session['first_name'] = $user->first_name; $_user_session['last_name'] = $user->last_name; $_user_session['email'] = $user->email; $_user_session['avatar'] = $_settings['avatar']; $_user_session['theme-skin'] = $_settings['theme-skin']; $_user_session['lock-screen'] = isset($_settings['lock-screen']) ? $_settings['lock-screen'] : 0; $_user_session['layout'] = isset($_settings['layout']) ? $_settings['layout'] : ''; $_SESSION['user'] = $_user_session; $_SESSION['logged_in'] = TRUE; $_SESSION['type'] = 'fabtotum'; $_SESSION['ask_wizard'] = TRUE; /** LOAD HELPER */ $this->load->helper('update_helper'); $_fabui_local = myfab_get_local_version(); $_fw_local = marlin_get_local_version(); $_fabui_update = false; $_fw_update = false; $_updates = array(); $_updates['number'] = 0; $_updates['time'] = time(); if (is_internet_avaiable()) { $_fabui_remote_version = myfab_get_remote_version(); $_fw_remote_version = marlin_get_remote_version(); $_fabui_update = $_fabui_remote_version > $_fabui_local; $_fw_update = $_fw_remote_version > $_fw_local; $_updates['number'] += $_fabui_update ? 1 : 0; $_updates['number'] += $_fw_update ? 1 : 0; $_updates['fabui'] = $_fabui_update; $_updates['fw'] = $_fw_update; } $_SESSION['fabui_version'] = $_fabui_local; $_SESSION['updates'] = $_updates; $this->user->update_login($user->id); redirect('dashboard', 'location'); } else { /** */ $_SESSION['login_failed'] = true; $_SESSION['login_failed_mail'] = $email; redirect('login'); } } }