23if (!defined(
'NOTOKENRENEWAL')) {
24 define(
'NOTOKENRENEWAL',
'1');
26if (!defined(
'NOREQUIREMENU')) {
27 define(
'NOREQUIREMENU',
'1');
29if (!defined(
'NOREQUIREHTML')) {
30 define(
'NOREQUIREHTML',
'1');
32if (!defined(
'NOREQUIREAJAX')) {
33 define(
'NOREQUIREAJAX',
'1');
37require
'../../main.inc.php';
44require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
45require_once DOL_DOCUMENT_ROOT.
'/core/lib/geturl.lib.php';
47$langs->loadLangs(array(
"admin",
"errors"));
49if (!$user->admin && !$user->hasRight(
'bockedlog',
'read')) {
53$file =
GETPOST(
'file',
'alphanohtml');
55$expectedhash =
GETPOST(
'expectedhash',
'aZ09');
57if (!in_array($algo, array(
'md5',
'sha256'),
true)) {
77 while ($start < $na && $start < $nb && $a[$start] === $b[$start]) {
83 while ($enda >= $start && $endb >= $start && $a[$enda] === $b[$endb]) {
89 for ($i = 0; $i < $start; $i++) {
90 $result[] = array(
' ', $a[$i]);
93 $midA = array_slice($a, $start, $enda - $start + 1);
94 $midB = array_slice($b, $start, $endb - $start + 1);
100 for ($i = $enda + 1; $i < $na; $i++) {
101 $result[] = array(
' ', $a[$i]);
118 $a = array_values($a);
119 $b = array_values($b);
123 if ($na == 0 || $nb == 0) {
125 foreach ($a as $line) {
126 $result[] = array(
'-', $line);
128 foreach ($b as $line) {
129 $result[] = array(
'+', $line);
135 if ($na * $nb <= 1000000) {
141 if ($anchor !==
null) {
144 array(array(
' ', $a[$anchor[0]])),
151 foreach ($a as $line) {
152 $result[] = array(
'-', $line);
154 foreach ($b as $line) {
155 $result[] = array(
'+', $line);
171 foreach ($a as $line) {
172 $countA[$line] = (isset($countA[$line]) ? $countA[$line] : 0) + 1;
176 foreach ($b as $j => $line) {
177 $countB[$line] = (isset($countB[$line]) ? $countB[$line] : 0) + 1;
181 $middle = (int) (count($a) / 2);
184 foreach ($a as $i => $line) {
185 if ($countA[$line] == 1 && isset($countB[$line]) && $countB[$line] == 1) {
186 $dist = abs($i - $middle);
187 if ($bestdist < 0 || $dist < $bestdist) {
189 $best = array($i, $posB[$line]);
211 for ($i = 0; $i <= $na; $i++) {
212 $lcs[$i] = array_fill(0, $nb + 1, 0);
214 for ($i = $na - 1; $i >= 0; $i--) {
215 for ($j = $nb - 1; $j >= 0; $j--) {
216 if ($a[$i] === $b[$j]) {
217 $lcs[$i][$j] = $lcs[$i + 1][$j + 1] + 1;
219 $lcs[$i][$j] = max($lcs[$i + 1][$j], $lcs[$i][$j + 1]);
228 while ($i < $na && $j < $nb) {
229 if ($a[$i] === $b[$j]) {
230 $result[] = array(
' ', $a[$i]);
233 } elseif ($lcs[$i + 1][$j] >= $lcs[$i][$j + 1]) {
234 $result[] = array(
'-', $a[$i]);
237 $result[] = array(
'+', $b[$j]);
242 $result[] = array(
'-', $a[$i]);
246 $result[] = array(
'+', $b[$j]);
263 $keep = array_fill(0, $n,
false);
264 for ($i = 0; $i < $n; $i++) {
265 if ($diff[$i][0] !==
' ') {
268 for ($k = $from; $k <= $to; $k++) {
276 for ($i = 0; $i < $n; $i++) {
278 $result[] = $diff[$i];
281 $result[] = array(
'@',
'');
292print
'<!-- filecheck_diff.php fragment -->'.
"\n";
297if (empty($file) || $file[0] !==
'/' || strpos($file,
'..') !==
false || !preg_match(
'/^[A-Za-z0-9_\/.\-]+$/', $file)) {
298 $errormsg = $langs->trans(
"ErrorBadValueForParameter",
dol_escape_htmltag($file),
"file");
301if (empty($errormsg)) {
302 $reallocal = realpath(DOL_DOCUMENT_ROOT.$file);
303 if ($reallocal ===
false || strpos($reallocal, realpath(DOL_DOCUMENT_ROOT).
'/') !== 0 || !is_file($reallocal)) {
304 $errormsg = $langs->trans(
"ErrorFileNotFound", $file);
308if (empty($errormsg) && preg_match(
'/\.(jpg|jpeg|png|gif|ico|svg|eot|woff|woff2|ttf|mp3|mp4|wav|mkv|z|gz|zip|rar|tar)$/i', $file)) {
309 $errormsg = $langs->trans(
"DiffNotAvailableForBinaryFiles");
312if (!empty($errormsg)) {
313 print
'<div class="warning">'.$errormsg.
'</div>';
320$baseurl =
getDolGlobalString(
'MAIN_FILECHECK_DIFF_BASEURL',
'https://raw.githubusercontent.com/Dolibarr/dolibarr');
321if (preg_match(
'/alpha|beta|rc/i', DOL_VERSION)) {
327$originurl = $baseurl.
'/'.$ref.
'/htdocs'.$file;
329$res =
getURLContent($originurl,
'GET',
'', 1, array(), array(
'http',
'https'), 0);
330if (!empty($res[
'curl_error_no']) || (isset($res[
'http_code']) && !in_array((
int) $res[
'http_code'], array(0, 200),
true))) {
331 print
'<div class="warning">'.$langs->trans(
"CouldNotFetchOriginalFile").
': '.
dol_escape_htmltag($originurl);
332 print
' ('.dol_escape_htmltag((
string) (empty($res[
'http_code']) ? $res[
'curl_error_msg'] : $res[
'http_code'])).
')</div>';
336$origincontent = (
string) $res[
'content'];
337$localcontent = (
string) file_get_contents($reallocal);
341if (!empty($expectedhash)) {
342 $verified = (hash($algo, $origincontent) === $expectedhash);
345 print
'<div class="warning">'.$langs->trans(
"OriginalFileChecksumMismatch").
'</div>';
348if ($origincontent === $localcontent) {
349 print
'<div class="opacitymedium">'.$langs->trans(
"NoDifferenceFound").
'</div>';
353$diff =
filecheckLineDiff(explode(
"\n", $origincontent), explode(
"\n", $localcontent));
356print
'<div class="opacitymedium" style="margin-bottom:4px">';
360print
'<table class="filecheckdiff" style="width:100%;border-collapse:collapse;font-family:monospace;font-size:0.85em">';
361foreach ($diff as $line) {
364 print
'<tr><td style="background:#eef;color:#888;padding:1px 6px">…</td></tr>'.
"\n";
370 $bg =
'background:#e6ffed';
372 } elseif ($type ===
'-') {
373 $bg =
'background:#ffeef0';
376 print
'<tr><td style="white-space:pre-wrap;word-break:break-all;padding:0 6px;'.$bg.
'">';
378 print
'</td></tr>'.
"\n";
393 if (is_object(
$db)) {
filecheckCollapseContext($diff, $context=3)
Collapse long runs of unchanged context lines, keeping a few lines around each change.
llxFooterFragment()
Close the fragment output and stop the script.
if(!in_array( $algo, array( 'md5', 'sha256'), true)) filecheckLineDiff($a, $b)
Compute a line based diff between two arrays of lines, restricted to the changed region (common prefi...
filecheckMiddleDiff($a, $b)
Diff of the changed region.
filecheckLcs($a, $b)
Diff of two small arrays of lines using a classic LCS dynamic programming matrix.
filecheckFindAnchor($a, $b)
Find a line that appears exactly once in both arrays (a unique common "anchor"), choosing the candida...
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
getURLContent($url, $postorget='GET', $param='', $followlocation=1, $addheaders=array(), $allowedschemes=array('http', 'https'), $localurl=0, $ssl_verifypeer=-1, $timeoutconnect=0, $timeoutresponse=0, $otherCurlOptions=array(), $morelogsuffix='')
Function to get a content from an URL (use proxy if proxy defined).
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
if(!defined( 'NOREQUIREMENU')) if(!empty(GETPOST('seteventmessages', 'alpha'))) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.
$context
@method int call_trigger(string $triggerName, ?User $user)
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.