]> git.mxchange.org Git - friendica.git/commitdiff
Merge pull request #3874 from tobiasd/20171009-checkversion
authorHypolite Petovan <mrpetovan@gmail.com>
Mon, 6 Nov 2017 18:59:49 +0000 (13:59 -0500)
committerGitHub <noreply@github.com>
Mon, 6 Nov 2017 18:59:49 +0000 (13:59 -0500)
check upstream version

doc/Settings.md
include/checkversion.php [new file with mode: 0644]
include/cron.php
mod/admin.php
view/templates/admin_site.tpl

index e30b4892976bb6de6dac6c8ecfe956a85e5e5674..a0b33d76d27ee3f41d92b60e48287c83e1b25b8d 100644 (file)
@@ -164,6 +164,12 @@ However these aren't looked upon favourably in the security community because th
 If you wish, you can turn on strict certificate checking.
 This will mean you cannot connect (at all) to self-signed SSL sites.
 
+#### Check upstream version
+
+If this option is enabled your Friendica node will check the upstream version once per day from the github repository.
+You can select if the stable version or the development version should be checked out.
+If there is a new version published, you will get notified in the admin panel summary page.
+
 ### Auto Discovered Contact Directory
 
 ### Performance
diff --git a/include/checkversion.php b/include/checkversion.php
new file mode 100644 (file)
index 0000000..7d3c2de
--- /dev/null
@@ -0,0 +1,46 @@
+<?php
+
+/**
+ * @file include/checkversion.php
+ *
+ * @brief save Friendica upstream version to the DB
+ **/
+
+use Friendica\Core\Config;
+
+/**
+ * @brief check the git repository VERSION file and save the version to the DB
+ *
+ * Checking the upstream version is optional (opt-in) and can be done to either
+ * the master or the develop branch in the repository.
+ */
+function checkversion_run () {
+       global $a;
+
+       logger('checkversion: start');
+
+       $checkurl = Config::get('system', 'check_new_version_url', 'none');
+
+       switch ($checkurl) {
+       case 'master': 
+               $checked_url = 'https://raw.githubusercontent.com/friendica/friendica/master/VERSION'; 
+               break;
+       case 'develop': 
+               $checked_url = 'https://raw.githubusercontent.com/friendica/friendica/develop/VERSION'; 
+               break;
+       default: 
+               // don't check
+               return;
+}
+       logger("Checking VERSION from: ".$checked_url, LOGGER_DEBUG);
+
+       // fetch the VERSION file
+       $gitversion = dbesc(trim(fetch_url($checked_url)));
+       logger("Upstream VERSION is: ".$gitversion, LOGGER_DEBUG);
+
+       Config::set('system', 'git_friendica_version', $gitversion);
+
+       logger('checkversion: end');
+
+       return;
+}
index 260b143c5b76fc9e785d890b853d340831d2e34d..d4d19d8c86dc7e6f6a81418e2fd7f85e4a67826d 100644 (file)
@@ -80,6 +80,9 @@ function cron_run(&$argv, &$argc){
 
                // Delete all done workerqueue entries
                dba::delete('workerqueue', array('`done` AND `executed` < UTC_TIMESTAMP() - INTERVAL 12 HOUR'));
+
+               // check upstream version?
+               Worker::add(PRIORITY_LOW, 'checkversion');
        }
 
        // Poll contacts
index 144539dcef5198d57eb06d36034e53dcd41502a2..ae7118664d1c8bd9c918d5f0230037997a27e122 100644 (file)
@@ -616,6 +616,15 @@ function admin_page_summary(App $a) {
                $showwarning = true;
                $warningtext[] = sprintf(t('Your DB still runs with MyISAM tables. You should change the engine type to InnoDB. As Friendica will use InnoDB only features in the future, you should change this! See <a href="%s">here</a> for a guide that may be helpful converting the table engines. You may also use the command <tt>php include/dbstructure.php toinnodb</tt> of your Friendica installation for an automatic conversion.<br />'), 'https://dev.mysql.com/doc/refman/5.7/en/converting-tables-to-innodb.html');
        }
+       // Check if github.com/friendica/master/VERSION is higher then
+       // the local version of Friendica. Check is opt-in, source may be master or devel branch
+       if (Config::get('system', 'check_new_version_url', 'none') != 'none' ) {
+               $gitversion = Config::get('system','git_friendica_version');
+               if (version_compare(FRIENDICA_VERSION, $gitversion) < 0) {
+                       $warningtext[] = t('There is a new version of Friendica available for download.');
+                       $showwarning = true;
+               }
+       }
 
        if (Config::get('system', 'dbupdate', DB_UPDATE_NOT_CHECKED) == DB_UPDATE_NOT_CHECKED) {
                require_once("include/dbstructure.php");
@@ -848,6 +857,7 @@ function admin_page_site_post(App $a) {
        $proxy_disabled         =       ((x($_POST,'proxy_disabled'))           ? True                                          : False);
        $only_tag_search        =       ((x($_POST,'only_tag_search'))          ? True                                          : False);
        $rino                   =       ((x($_POST,'rino'))                     ? intval($_POST['rino'])                        : 0);
+       $check_new_version_url  =       ((x($_POST, 'check_new_version_url'))   ?       notags(trim($_POST['check_new_version_url']))   : 'none');
        $worker_queues          =       ((x($_POST,'worker_queues'))            ? intval($_POST['worker_queues'])               : 4);
        $worker_dont_fork       =       ((x($_POST,'worker_dont_fork'))         ? True                                          : False);
        $worker_fastlane        =       ((x($_POST,'worker_fastlane'))          ? True                                          : False);
@@ -968,6 +978,7 @@ function admin_page_site_post(App $a) {
        set_config('system', 'enotify_no_content', $enotify_no_content);
        set_config('system', 'disable_embedded', $disable_embedded);
        set_config('system', 'allow_users_remote_self', $allow_users_remote_self);
+       set_config('system', 'check_new_version_url', $check_new_version_url);
 
        set_config('system', 'block_extended_register', $no_multi_reg);
        set_config('system', 'no_openid', $no_openid);
@@ -1137,6 +1148,12 @@ function admin_page_site(App $a) {
                SSL_POLICY_SELFSIGN => t("Self-signed certificate, use SSL for local links only (discouraged)")
        );
 
+       $check_git_version_choices = array(
+               "none" => t("Don't check"),
+               "master" => t("check the stable version"),
+               "develop" => t("check the development version")
+       );
+
        if ($a->config['hostname'] == "") {
                $a->config['hostname'] = $a->get_hostname();
        }
@@ -1231,6 +1248,7 @@ function admin_page_site(App $a) {
 
                '$nodeinfo'             => array('nodeinfo', t("Publish server information"), get_config('system','nodeinfo'), t("If enabled, general server and usage data will be published. The data contains the name and version of the server, number of users with public profiles, number of posts and the activated protocols and connectors. See <a href='http://the-federation.info/'>the-federation.info</a> for details.")),
 
+               '$check_new_version_url' => array('check_new_version_url', t("Check upstream version"), get_config('system', 'check_new_version_url'), t("Enables checking for new Friendica versions at github. If there is a new version, you will be informed in the admin panel overview."), $check_git_version_choices),
                '$suppress_tags'        => array('suppress_tags', t("Suppress Tags"), get_config('system','suppress_tags'), t("Suppress showing a list of hashtags at the end of the posting.")),
                '$itemcache'            => array('itemcache', t("Path to item cache"), get_config('system','itemcache'), t("The item caches buffers generated bbcode and external images.")),
                '$itemcache_duration'   => array('itemcache_duration', t("Cache duration in seconds"), get_config('system','itemcache_duration'), t("How long should the cache files be hold? Default value is 86400 seconds (One day). To disable the item cache, set the value to -1.")),
index 715b422defbb4ee63256fd4776ce3bac998adcb7..9f25ac085d95b18c5515506460a41018095f22b7 100644 (file)
        {{include file="field_input.tpl" field=$basepath}}
        {{include file="field_checkbox.tpl" field=$suppress_tags}}
        {{include file="field_checkbox.tpl" field=$nodeinfo}}
+       {{include file="field_select.tpl" field=$check_new_version_url}}
        <div class="submit"><input type="submit" name="page_site" value="{{$submit|escape:'html'}}" /></div>
 
        <h3>{{$portable_contacts}}</h3>