Exemplo n.º 1
0
 public static function selfupgrade()
 {
     $upgrader = new Upgrader();
     if (!Installer::isGravInstance(GRAV_ROOT)) {
         return false;
     }
     if (is_link(GRAV_ROOT . DS . 'index.php')) {
         Installer::setError(Installer::IS_LINK);
         return false;
     }
     $update = $upgrader->getAssets()['grav-update'];
     $tmp = CACHE_DIR . 'tmp/Grav-' . uniqid();
     $file = self::_downloadSelfupgrade($update, $tmp);
     Installer::install($file, GRAV_ROOT, ['sophisticated' => true, 'overwrite' => true, 'ignore_symlinks' => true]);
     $errorCode = Installer::lastErrorCode();
     Folder::delete($tmp);
     if ($errorCode & (Installer::ZIP_OPEN_ERROR | Installer::ZIP_EXTRACT_ERROR)) {
         return false;
     }
     return true;
 }
Exemplo n.º 2
0
 public static function selfupgrade()
 {
     $upgrader = new Upgrader();
     if (!Installer::isGravInstance(GRAV_ROOT)) {
         return false;
     }
     if (is_link(GRAV_ROOT . DS . 'index.php')) {
         Installer::setError(Installer::IS_LINK);
         return false;
     }
     if (!$upgrader->meetsRequirements()) {
         $error = [];
         $error[] = '<p>Grav has increased the minimum PHP requirement.<br />';
         $error[] = 'You are currently running PHP <strong>' . PHP_VERSION . '</strong>';
         $error[] = ', but PHP <strong>' . GRAV_PHP_MIN . '</strong> is required.</p>';
         $error[] = '<p><a href="http://getgrav.org/blog/changing-php-requirements-to-5.5" class="button button-small secondary">Additional information</a></p>';
         Installer::setError(implode("\n", $error));
         return false;
     }
     $update = $upgrader->getAssets()['grav-update'];
     $tmp = CACHE_DIR . 'tmp/Grav-' . uniqid();
     $file = self::_downloadSelfupgrade($update, $tmp);
     Installer::install($file, GRAV_ROOT, ['sophisticated' => true, 'overwrite' => true, 'ignore_symlinks' => true]);
     $errorCode = Installer::lastErrorCode();
     Folder::delete($tmp);
     if ($errorCode & (Installer::ZIP_OPEN_ERROR | Installer::ZIP_EXTRACT_ERROR)) {
         return false;
     }
     return true;
 }