Beispiel #1
0
 }
 if (init('action') == 'update') {
     jeedom::update();
     ajax::success();
 }
 if (init('action') == 'clearDate') {
     $cache = cache::byKey('jeedom::lastDate');
     $cache->remove();
     ajax::success();
 }
 if (init('action') == 'backup') {
     jeedom::backup(true, init('noCloudUpload'));
     ajax::success();
 }
 if (init('action') == 'restore') {
     jeedom::restore(init('backup'), true);
     ajax::success();
 }
 if (init('action') == 'restoreCloud') {
     market::retoreBackup(init('backup'));
     ajax::success();
 }
 if (init('action') == 'getUpdateLog') {
     ajax::success(log::get('update', 0, 3000));
 }
 if (init('action') == 'getBackupLog') {
     ajax::success(log::get('backup', 0, 3000));
 }
 if (init('action') == 'getRestoreLog') {
     ajax::success(log::get('restore', 0, 3000));
 }
Beispiel #2
0
         throw new Exception('Repertoire de téléversement non trouvé : ' . $uploaddir);
     }
     $_file = $_FILES['file'];
     $extension = strtolower(strrchr($_file['name'], '.'));
     if (!in_array($extension, array('.tar.gz', '.gz', '.tar'))) {
         throw new Exception('Extension du fichier non valide (autorisé .tar.gz, .tar et .gz) : ' . $extension);
     }
     if (filesize($_file['tmp_name']) > 50000000) {
         throw new Exception('La taille du fichier est trop importante (maximum 50Mo)');
     }
     $bakcup_name = 'backup-' . jeedom::version() . '-' . date("d-m-Y-H\\hi") . '.tar.gz';
     $uploadfile = $uploaddir . '/' . $bakcup_name;
     if (!move_uploaded_file($_file['tmp_name'], $uploadfile)) {
         throw new Exception('Impossible de téléverser le fichier');
     }
     jeedom::restore($uploadfile, true);
     $jsonrpc->makeSuccess('ok');
 }
 if ($jsonrpc->getMethod() == 'jeeNetwork::backup') {
     jeedom::backup(true);
     $jsonrpc->makeSuccess('ok');
 }
 /*             * ************************Log*************************** */
 if ($jsonrpc->getMethod() == 'log::get') {
     $jsonrpc->makeSuccess(log::get($params['log'], $params['start'], $params['nbLine']));
 }
 if ($jsonrpc->getMethod() == 'log::list') {
     $jsonrpc->makeSuccess(log::liste());
 }
 if ($jsonrpc->getMethod() == 'log::empty') {
     $jsonrpc->makeSuccess(log::clear($params['log']));
Beispiel #3
0
 public static function retoreBackup($_backup)
 {
     $url = config::byKey('market::address') . "/core/php/downloadBackup.php?backup=" . $_backup . '&hwkey=' . jeedom::getHardwareKey() . '&username='******'market::username')) . '&password='******'market::password') . '&password_type=sha1';
     $tmp_dir = dirname(__FILE__) . '/../../tmp';
     $tmp = $tmp_dir . '/' . $_backup;
     file_put_contents($tmp, fopen($url, 'r'));
     if (!file_exists($tmp)) {
         throw new Exception(__('Impossible de télécharger la sauvegarde : ', __FILE__) . $url . '.');
     }
     if (!file_exists(dirname(__FILE__) . '/../../backup/')) {
         mkdir(dirname(__FILE__) . '/../../backup/');
     }
     $backup_path = dirname(__FILE__) . '/../../backup/' . $_backup;
     if (!copy($tmp, $backup_path)) {
         throw new Exception(__('Impossible de copier le fichier de  : ', __FILE__) . $tmp . '.');
     }
     if (!file_exists($backup_path)) {
         throw new Exception(__('Impossible de trouver le fichier : ', __FILE__) . $backup_path . '.');
     }
     jeedom::restore('backup/' . $_backup, true);
 }
Beispiel #4
0
                config::save('cronSleepTime', 60);
            }
        } else {
            config::save('cronSleepTime', 60);
        }
        config::save('logLevel', $logLevel);
        echo "OK\n";
        echo 'Installation de socket.io et express (peut etre très long > 30min)';
        echo shell_exec('cd ' . dirname(__FILE__) . '/../core/nodeJS;sudo npm install socket.io;npm install express');
        echo "OK\n";
    }
    config::save('version', jeedom::version());
} catch (Exception $e) {
    if ($update) {
        if ($backup_ok && $update_begin) {
            jeedom::restore();
        }
        jeedom::start();
    }
    echo __('Erreur durant l\'installation : ', __FILE__) . $e->getMessage();
    echo __('Details : ', __FILE__) . print_r($e->getTrace());
    echo "[END UPDATE ERROR]\n";
    throw $e;
}
echo "[END UPDATE SUCCESS]\n";
function incrementVersion($_version)
{
    $version = explode('.', $_version);
    if ($version[2] < 500) {
        $version[2]++;
    } else {