From 74f2a4d59757bb7aaefd0020360f61a240fedfb9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 9 Oct 2016 20:19:24 +0200 Subject: [PATCH] Enable feature to check online signature --- htdocs/admin/system/filecheck.php | 37 +++++++++++++++++++------------ htdocs/langs/en_US/admin.lang | 1 + 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/htdocs/admin/system/filecheck.php b/htdocs/admin/system/filecheck.php index 428c3fde2d8..5bea1b521ac 100644 --- a/htdocs/admin/system/filecheck.php +++ b/htdocs/admin/system/filecheck.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2005-2016 Laurent Destailleur * Copyright (C) 2007 Rodolphe Quiedeville * Copyright (C) 2007-2012 Regis Houssin * Copyright (C) 2015 Frederic France @@ -25,6 +25,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; $langs->load("admin"); @@ -77,32 +78,37 @@ $file_list = array('missing' => array(), 'updated' => array()); $xmlshortfile = '/install/filelist-'.DOL_VERSION.'.xml'; $xmlfile = DOL_DOCUMENT_ROOT.$xmlshortfile; $xmlremote = 'https://www.dolibarr.org/files/stable/signatures/filelist-'.DOL_VERSION.'.xml'; - -$enableremotecheck = False; + + +// Test if remote test is ok +$enableremotecheck = True; +if (preg_match('/beta|alpha/i', DOL_VERSION)) $enableremotecheck=False; + print '
'; print $langs->trans("MakeIntegrityAnalysisFrom").':
'; if (dol_is_file($xmlfile)) { - print ' '.$langs->trans("LocalSignature").' = '.$xmlshortfile.'
'; + print ' '.$langs->trans("LocalSignature").' = '.$xmlshortfile.'
'; } else { - print ' '.$langs->trans("LocalSignature").' = '.$xmlshortfile.' ('.$langs->trans("AvailableOnlyOnPackagedVersions").')
'; + print ' '.$langs->trans("LocalSignature").' = '.$xmlshortfile.' ('.$langs->trans("AvailableOnlyOnPackagedVersions").')
'; } if ($enableremotecheck) { - print ' '.$langs->trans("RemoteSignature").' = '.$xmlremote.'
'; + print ' '.$langs->trans("RemoteSignature").' = '.$xmlremote.'
'; } else { - print ' '.$langs->trans("RemoteSignature").' = '.$xmlremote.' ('.$langs->trans("FeatureNotYetAvailable").')
'; + print ' '.$langs->trans("RemoteSignature").' = '.$xmlremote.' ('.$langs->trans("FeatureAvailableOnlyOnStable").')
'; } print '
'; print '
'; print '
'; +print '
'; -if (GETPOST('local')) +if (GETPOST('target') == 'local') { if (dol_is_file($xmlfile)) { @@ -114,17 +120,20 @@ if (GETPOST('local')) $error++; } } -if (GETPOST('remote')) +if (GETPOST('target') == 'remote') { - // TODO - //$xmlfile = ; - if (1 == 1) + $xmlarray = getURLContent($xmlremote); + + // Return array('content'=>response,'curl_error_no'=>errno,'curl_error_msg'=>errmsg...) + if (! $xmlarray['curl_error_no'] && $xmlarray['http_code'] != '404') { - //$xml = simplexml_load_file($xmlfile); + $xmlfile = $xmlarray['content']; + $xml = simplexml_load_file($xmlfile); } else { - print $langs->trans('XmlNotFound') . ': ' . $xmlfile; + $errormsg=$langs->trans('XmlNotFound') . ': ' . $xmlremote.' - '.$xmlarray['http_code'].' '.$xmlarray['curl_error_no'].' '.$xmlarray['curl_error_msg']; + setEventMessages($errormsg, null, 'errors'); $error++; } } diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 407b5ebdfd6..0acf8faf9dd 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -181,6 +181,7 @@ EncodeBinariesInHexa=Encode binary data in hexadecimal IgnoreDuplicateRecords=Ignore errors of duplicate records (INSERT IGNORE) AutoDetectLang=Autodetect (browser language) FeatureDisabledInDemo=Feature disabled in demo +FeatureAvailableOnlyOnStable=Feature only available on official stable versions Rights=Permissions BoxesDesc=Widgets are components showing some information that you can add to personalize some pages. You can choose between showing the widget or not by selecting target page and clicking 'Activate', or by clicking the dustbin to disable it. OnlyActiveElementsAreShown=Only elements from enabled modules are shown.