Merge pull request #3874 from tobiasd/20171009-checkversion

check upstream version
This commit is contained in:
Hypolite Petovan 2017-11-06 13:59:49 -05:00 committed by GitHub
commit c847a2f9cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 74 additions and 0 deletions

View 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

46
include/checkversion.php Normal file
View File

@ -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;
}

View 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

View 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.")),

View File

@ -126,6 +126,7 @@
{{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>