Enable feature to check online signature

This commit is contained in:
Laurent Destailleur 2016-10-09 20:19:24 +02:00
parent 0803084cc4
commit 74f2a4d597
2 changed files with 24 additions and 14 deletions

View File

@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2005-2015 Laurent Destailleur <eldy@users.sourceforge.net>
/* Copyright (C) 2005-2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2007-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2015 Frederic France <frederic.france@free.fr>
@ -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 '<form name="check" action="'.$_SERVER["PHP_SELF"].'">';
print $langs->trans("MakeIntegrityAnalysisFrom").':<br>';
if (dol_is_file($xmlfile))
{
print '<input type="checkbox" name="local" checked> '.$langs->trans("LocalSignature").' = '.$xmlshortfile.'<br>';
print '<input type="radio" name="target" value="local"'.((! GETPOST('target') || GETPOST('target') == 'local') ? 'checked="checked"':'').'"> '.$langs->trans("LocalSignature").' = '.$xmlshortfile.'<br>';
}
else
{
print '<input type="checkbox" name="local"> '.$langs->trans("LocalSignature").' = '.$xmlshortfile.' <span class="warning">('.$langs->trans("AvailableOnlyOnPackagedVersions").')</span><br>';
print '<input type="radio" name="target" value="local"> '.$langs->trans("LocalSignature").' = '.$xmlshortfile.' <span class="warning">('.$langs->trans("AvailableOnlyOnPackagedVersions").')</span><br>';
}
if ($enableremotecheck)
{
print '<input type="checkbox" name="remote"> '.$langs->trans("RemoteSignature").' = '.$xmlremote.'<br>';
print '<input type="radio" name="target" value="remote"'.(GETPOST('target') == 'remote' ? 'checked="checked"':'').'> '.$langs->trans("RemoteSignature").' = '.$xmlremote.'<br>';
}
else
{
print '<input type="checkbox" name="remote" disabled> '.$langs->trans("RemoteSignature").' = '.$xmlremote.' <span class="warning">('.$langs->trans("FeatureNotYetAvailable").')</span><br>';
print '<input type="radio" name="target" value="remote" disabled="disabled"> '.$langs->trans("RemoteSignature").' = '.$xmlremote.' <span class="warning">('.$langs->trans("FeatureAvailableOnlyOnStable").')</span><br>';
}
print '<br><div class="center"><input type="submit" name="check" class="button" value="'.$langs->trans("Check").'"></div>';
print '</form>';
print '<br>';
print '<br>';
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++;
}
}

View File

@ -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 <a href="%s">enabled modules</a> are shown.