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 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); }
public function __construct() { parent::__construct(); $this->load->helper('print_helper'); /** IF PRINTER IS BUSY I CANT CHANGE SETTINGS */ if (is_printer_busy()) { redirect('dashboard'); } $this->lang->load($_SESSION['language']['name'], $_SESSION['language']['name']); /** LOAD HELPER */ $this->load->helper('update_helper'); $this->_fabui_local = myfab_get_local_version(); $this->_marlin_local = marlin_get_local_version(); }
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'); $this->load->helper('serial_helper'); $_fabui_local = myfab_get_local_version(); /*$_fw_local = firmware_version(); */ $_fabui_update = false; $_fw_update = false; $_updates = array(); $_SESSION['fabui_version'] = $_fabui_local; //$_SESSION['hardware']['id'] = hardware_id(); $_SESSION['updates'] = $_updates; $this->user->update_login($user->id); redirect('dashboard', 'location'); } else { /** */ $_SESSION['login_failed'] = true; $_SESSION['login_failed_mail'] = $email; redirect('login'); } } }
//$time_to_check = 60; $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; }
<?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]; $_myfab_local_version = myfab_get_local_version(); $_myfab_remote_version = myfab_get_remote_version(); $_file_name = $_folder . 'fabui' . '.zip'; $_url = MYFAB_DOWNLOAD_URL . $_myfab_remote_version . '/' . MYFAB_DOWNLOAD_FILE; //$_monitor = MYFAB_UPDATE_MONITOR_FILE; //$do_update = $_myfab_local_version <= $_myfab_remote_version ; $do_update = true; $_monitor_items = array(); if ($do_update) { $_monitor_items['completed'] = 0; $_monitor_items['status'] = 'downloading'; /** CREATE MONITOR FILE */ write_monitor(); $_target_file = fopen($_file_name, 'w+') or die("can't open file"); $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 curl_setopt($ch, CURLOPT_HEADER, 0);