示例#1
0
文件: plugin.php 项目: kino3d/FAB-UI
 public function add()
 {
     $this->load->helper('update_helper');
     $data['_internet'] = is_internet_avaiable();
     if ($data['_internet'] == true) {
         $css_in_page = $this->load->view('add/css', '', TRUE);
         $this->layout->add_css_in_page(array('data' => $css_in_page, 'comment' => 'add css'));
         $this->load->database();
         $this->load->model('configuration');
         //echo $this->configuration->get_config_value('plugin_respository');
         /** LOAD SAVED REPOSITORY */
         $_repository = json_decode($this->configuration->get_config_value('plugin_respository'), TRUE);
         $_plugins = array();
         /** LOAD PLUGIN LIST */
         foreach ($_repository as $_repo) {
             //echo $_repo['url'].PHP_EOL;
             $ch = curl_init($_repo['url']);
             curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3);
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
             $result = curl_exec($ch);
             $info = curl_getinfo($ch);
             curl_close($ch);
             if ($info['http_code'] == 200) {
                 $_temp = $_repo;
                 $_temp['plugins'] = json_decode($result, true);
                 $_plugins[] = $_temp;
             }
         }
         $data['_plugins'] = $_plugins;
     }
     $this->layout->view('add/index', $data);
 }
示例#2
0
 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 getInternet($data = '')
 {
     $this->_type = 'internet';
     $this->_data = is_internet_avaiable();
     return $this->returnResponse();
 }
示例#4
0
session_start();
require_once $_SERVER['DOCUMENT_ROOT'] . '/lib/config.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/lib/utilities.php';
//$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'])) {
示例#5
0
function fw_changelog($version)
{
    $CI =& get_instance();
    $CI->config->load('myfab', TRUE);
    if (is_internet_avaiable()) {
        $_remote_url = $CI->config->item('fw_remote_download_url', 'myfab');
        $_fw_changelog = $CI->config->item('fw_changelog', 'myfab');
        $ch = curl_init($_remote_url . $version . '/' . $_fw_changelog);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        $changelog = curl_exec($ch);
        $info = curl_getinfo($ch);
        curl_close($ch);
        return $changelog;
    }
    return "";
}
示例#6
0
<?php

/** CHECK IF MENU HAVE TO BE FREEZED */
require_once $_SERVER['DOCUMENT_ROOT'] . '/lib/config.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/lib/database.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/lib/utilities.php';
$_internet = is_internet_avaiable();
$_tasks['items'] = array();
/** LOAD DB */
$db = new Database();
/** GET ALL RUNNING TASKS */
$_tasks_rows = $db->query('select * from sys_tasks where status="running"');
/** CLOSE DB CONNECTION */
$_tasks_number = $db->get_num_rows();
$db->close();
$_tasks['number'] = $_tasks_number;
if ($_tasks_rows) {
    $_tasks['number'] = $_tasks_number;
    if ($_tasks_number > 1) {
        foreach ($_tasks_rows as $_t) {
            $_tasks['items'][] = $_t;
        }
    }
    if ($_tasks_number == 1) {
        $_tasks['items'][] = $_tasks_rows;
    }
}
$_response_items = array();
//$_response_items['updates']  = $_updates;
$_response_items['tasks'] = $_tasks;
$_response_items['internet'] = $_internet;
示例#7
0
文件: login.php 项目: pardoc/FAB-UI
 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');
         }
     }
 }