Beispiel #1
0
 public static function check($debug = false)
 {
     if (UPDATE_TYPE <= 0) {
         if ($debug) {
             ErrorHelper::logDebug('Update checking disabled in config');
         }
         return false;
     }
     $data = LoadHelper::loadCached(UpdateHelper::url, UPDATE_FREQUENCY);
     if (!$data) {
         if ($debug) {
             ErrorHelper::logDebug('No version data loaded from server');
         }
         return false;
     }
     $data = json_decode($data);
     if ($data == null) {
         if ($debug) {
             ErrorHelper::logDebug('No data returned from GitHub.');
         }
         return false;
     }
     if (isset($data->message) && $data->message) {
         if ($debug) {
             ErrorHelper::logDebug('Error from GitHub: ' . $data->message);
         }
         return false;
     }
     foreach ($data as $tag) {
         if (UpdateHelper::$new == null || UpdateHelper::isRemoteNewer(UpdateHelper::$new->name, $tag->name)) {
             UpdateHelper::$new = $tag;
         }
     }
     if (UpdateHelper::$new == null) {
         if ($debug) {
             ErrorHelper::logDebug('No tags loaded from server');
         }
         return false;
     }
     if ($debug) {
         ErrorHelper::logDebug('Newest server version is: ' . UpdateHelper::$new->name);
     }
     if ($debug) {
         ErrorHelper::logDebug('Local version is: ' . VERSION);
     }
     UpdateHelper::$newVersion = UpdateHelper::$new->name;
     UpdateHelper::$hasUpdate = UpdateHelper::isRemoteNewer(VERSION, UpdateHelper::$new->name);
     if ($debug) {
         ErrorHelper::logDebug(UpdateHelper::$hasUpdate ? "Remote newer" : "Local newer or same");
     }
     if (UPDATE_TYPE <= 1 || !UpdateHelper::$hasUpdate) {
         return false;
     }
     $installedUpdate = UpdateHelper::install($debug);
     return $installedUpdate;
 }