/**
  * Test the trailing slash method.
  */
 public function testTrailingSlashes()
 {
     $dir = DIRECTORY_SEPARATOR . 'test';
     $this->assertEquals(DIRECTORY_SEPARATOR . 'test' . DIRECTORY_SEPARATOR, $this->_update->addTrailingSlash($dir));
     $dir = DIRECTORY_SEPARATOR . 'test' . DIRECTORY_SEPARATOR;
     $this->assertEquals(DIRECTORY_SEPARATOR . 'test' . DIRECTORY_SEPARATOR, $this->_update->addTrailingSlash($dir));
 }
Esempio n. 2
0
 /**
  * Ensure that no new master version is available
  */
 public function testBranchMaster()
 {
     $this->_update->setUpdateFile('noUpdateAvailable.json');
     $this->_update->setBranch('master');
     $response = $this->_update->checkUpdate();
     $this->assertEquals(AutoUpdate::NO_UPDATE_AVAILABLE, $response);
 }
Esempio n. 3
0
 public function upgrade()
 {
     $this->start(3);
     $update = new AutoUpdate(__DIR__ . '/temp', __DIR__ . '/../../', 60);
     $update->setCurrentVersion($this->version);
     // Current version of your application. This value should be from a database or another file which will be updated with the installation of a new version
     $update->setUpdateUrl('http://www.phpback.org/upgrade/');
     //Replace the url with your server update url
     $update->checkUpdate();
     // Check if new update is available
     if ($update->newVersionAvailable()) {
         //Install new update
         $result = $update->update();
         if ($result !== true) {
             echo 'Update failed: ' . $result . '!<br>';
             if ($result = AutoUpdate::ERROR_SIMULATE) {
                 echo '<pre>';
                 var_dump($update->getSimulationResults());
                 echo '</pre>';
             }
         }
         @(include __DIR__ . '../config/update.php');
         @unlink(__DIR__ . '../config/update.php');
     }
     header('Location: ' . base_url() . 'admin/system');
 }
Esempio n. 4
0
<?php

require __DIR__ . '/../../../vendor/autoload.php';
use VisualAppeal\AutoUpdate;
$update = new AutoUpdate(__DIR__ . '/temp', __DIR__ . '/../', 60);
$update->setCurrentVersion('0.1.0');
$update->setUpdateUrl('http://php-auto-update.app/server');
//Replace with your server update directory
// Optional:
$update->addLogHandler(new Monolog\Handler\StreamHandler(__DIR__ . '/update.log'));
$update->setCache(new Desarrolla2\Cache\Adapter\File(__DIR__ . '/cache'), 3600);
//Check for a new update
if ($update->checkUpdate() === false) {
    die('Could not check for updates! See log file for details.');
}
if ($update->newVersionAvailable()) {
    //Install new update
    echo 'New Version: ' . $update->getLatestVersion() . '<br>';
    echo 'Installing Updates: <br>';
    echo '<pre>';
    var_dump(array_map(function ($version) {
        return (string) $version;
    }, $update->getVersionsToUpdate()));
    echo '</pre>';
    // This call will only simulate an update.
    // Set the first argument (simulate) to "false" to install the update
    // i.e. $update->update(false);
    $result = $update->update();
    if ($result === true) {
        echo 'Update simulation successful<br>';
    } else {
Esempio n. 5
0
 function update($name = 'admin')
 {
     require APPPATH . 'third_party/update/vierbergenlars/SemVer/expression.php';
     require APPPATH . 'third_party/update/vierbergenlars/SemVer/version.php';
     require APPPATH . 'third_party/update/Psr/Log/LoggerInterface.php';
     require APPPATH . 'third_party/update/Monolog/Logger.php';
     require APPPATH . 'third_party/update/Monolog/Formatter/FormatterInterface.php';
     require APPPATH . 'third_party/update/Monolog/Formatter/NormalizerFormatter.php';
     require APPPATH . 'third_party/update/Monolog/Formatter/LineFormatter.php';
     require APPPATH . 'third_party/update/Monolog/Handler/HandlerInterface.php';
     require APPPATH . 'third_party/update/Monolog/Handler/AbstractHandler.php';
     require APPPATH . 'third_party/update/Monolog/Handler/AbstractProcessingHandler.php';
     require APPPATH . 'third_party/update/Monolog/Handler/StreamHandler.php';
     require APPPATH . 'third_party/update/Monolog/Handler/NullHandler.php';
     require APPPATH . 'third_party/update/Desarrolla2/CacheInterface.php';
     require APPPATH . 'third_party/update/Desarrolla2/Adapter/AdapterInterface.php';
     require APPPATH . 'third_party/update/Desarrolla2/Adapter/AbstractAdapter.php';
     require APPPATH . 'third_party/update/Desarrolla2/Adapter/NotCache.php';
     require APPPATH . 'third_party/update/Desarrolla2/Adapter/File.php';
     require APPPATH . 'third_party/update/Desarrolla2/Cache.php';
     require APPPATH . 'third_party/update/AutoUpdate.php';
     // Config
     $this->lang->load('system/sys_config', $this->Lang);
     if ($name == 'admin') {
         $RootDir = './';
         $UpdateUrl = 'http://www.ksphp.com/update/admin';
         $Cache = 'update/cache_admin';
         $LogFile = 'update/update_admin.log';
         $VersionName = 'version_admin';
         $Version = $this->config->config[$VersionName];
         $data['Name'] = $name;
         $data['Title'] = $this->lang->line('sys_config_admin');
     } elseif ($name == 'themes') {
         $RootDir = '../themes/';
         $UpdateUrl = 'http://www.ksphp.com/update/themes';
         $Cache = 'update/cache_themes';
         $LogFile = 'update/update_themes.log';
         $VersionName = 'version_themes';
         $Version = $this->config->config[$VersionName];
         $data['Name'] = $name;
         $data['Title'] = $this->lang->line('sys_config_themes');
     } elseif ($name == 'webmis') {
         $RootDir = '../webmis/';
         $UpdateUrl = 'http://www.ksphp.com/update/webmis';
         $Cache = 'update/cache_webmis';
         $LogFile = 'update/update_webmis.log';
         $VersionName = 'version_webmis';
         $Version = $this->config->config[$VersionName];
         $data['Name'] = $name;
         $data['Title'] = $this->lang->line('sys_config_webmis');
     } elseif ($name == 'CodeIgniter') {
         $RootDir = '../system/';
         $UpdateUrl = 'http://www.ksphp.com/update/CodeIgniter';
         $Cache = 'update/cache_CodeIgniter';
         $LogFile = 'update/update_CodeIgniter.log';
         $VersionName = 'version_CodeIgniter';
         $Version = $this->config->config[$VersionName];
         $data['Name'] = $name;
         $data['Title'] = $this->lang->line('sys_config_CodeIgniter');
     }
     $update = new AutoUpdate('update/temp', $RootDir, 60);
     $update->setCurrentVersion($Version);
     $update->setUpdateUrl($UpdateUrl);
     $update->addLogHandler(new Monolog\Handler\StreamHandler($LogFile));
     $update->setCache(new Desarrolla2\Cache\Adapter\File($Cache), 3600);
     // Check for a new update
     if ($update->checkUpdate() === false) {
         // die('Could not check for updates! See log file for details.');
         $data['checkUpdate'] = '<span class="red"><b>' . $this->lang->line('sys_config_update_nofind') . '</b></span>';
     } else {
         if ($update->newVersionAvailable()) {
             // var_dump(array_map(function($version) {return (string) $version;}, $update->getVersionsToUpdate()));
             $data['checkUpdate'] = '-> <b style="font-size: 14px; color: #666;">' . $update->getLatestVersion() . '</b> <input type="submit" id="editSub" name="update" value="' . $this->lang->line('sys_config_update_sub') . '" />';
         } else {
             $data['checkUpdate'] = '<span class="green"><b>' . $this->lang->line('sys_config_update_new') . '</b></span>';
         }
     }
     // Update
     $sub = $this->input->post('update');
     $data['Msg'] = '';
     if (isset($sub)) {
         $result = $update->update();
         if ($result === true) {
             $result = $this->_Cinfig(array($VersionName => $update->getLatestVersion()));
             $data['Msg'] = '<span class="green"><b>' . $this->lang->line('sys_config_update_suc') . '</b></span>';
             redirect('sys_config/update/' . $name);
         } else {
             $data['Msg'] = '<span class="red"><b>' . $this->lang->line('sys_config_update_err') . ' : ' . $result . '</b></span>';
             // if ($result = AutoUpdate::ERROR_SIMULATE) {var_dump($update->getSimulationResults());}
         }
     }
     // View
     $this->load->library('inc');
     $data['LoadJS'] = array('system/sys_config.js');
     $data['Log'] = nl2br(file_get_contents($LogFile));
     $data['LogFile'] = str_replace('./', '', $LogFile);
     $data['VersionName'] = $VersionName;
     $data['Menus'] = $this->inc->getMenuAdmin($this);
     $this->inc->adminView($this, 'system/config/update', $data);
 }
Esempio n. 6
0
 public function system()
 {
     $this->start(3);
     $data = array();
     $data['settings'] = $this->get->get_all_settings();
     $data['adminusers'] = $this->get->get_admin_users();
     $data['categories'] = $this->get->getCategories();
     $data['version'] = $this->version;
     $update = new AutoUpdate(__DIR__ . '/temp', __DIR__ . '/../../', 60);
     $update->setCurrentVersion($this->version);
     // Current version of your application. This value should be from a database or another file which will be updated with the installation of a new version
     $update->setUpdateUrl('http://www.phpback.org/upgrade/');
     //Replace the url with your server update url
     $update->checkUpdate();
     $data['lastVersion'] = $update->getLatestVersion();
     $data['version'] = $this->version;
     $data['isLastVersion'] = !$update->newVersionAvailable();
     $this->load->view('admin/dashboard/header', $data);
     $this->load->view('admin/dashboard/system', $data);
 }