update() 공개 메소드

Update to the latest version
public update ( boolean $simulateInstall = true, boolean $deleteDownload = true ) : mixed
$simulateInstall boolean Check for directory and file permissions before copying files (Default: true)
$deleteDownload boolean Delete download after update (Default: true)
리턴 mixed integer|bool
예제 #1
0
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 {
        echo 'Update simulation failed: ' . $result . '!<br>';
        if ($result = AutoUpdate::ERROR_SIMULATE) {
            echo '<pre>';
            var_dump($update->getSimulationResults());
            echo '</pre>';
        }
    }
} else {
    echo 'Current Version is up to date<br>';
}
echo 'Log:<br>';
echo nl2br(file_get_contents(__DIR__ . '/update.log'));
예제 #2
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');
 }
예제 #3
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);
 }