24if (!defined(
'NOTOKENRENEWAL')) {
25 define(
'NOTOKENRENEWAL',
'1');
27if (!defined(
'NOREQUIREMENU')) {
28 define(
'NOREQUIREMENU',
'1');
30if (!defined(
'NOREQUIREHTML')) {
31 define(
'NOREQUIREHTML',
'1');
33if (!defined(
'NOREQUIREAJAX')) {
34 define(
'NOREQUIREAJAX',
'1');
38require
'../../main.inc.php';
45require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
46require_once DOL_DOCUMENT_ROOT.
'/core/lib/geturl.lib.php';
48$langs->loadLangs(array(
"admin",
"errors"));
50if (!$user->admin && !$user->hasRight(
'bockedlog',
'read')) {
54$file =
GETPOST(
'file',
'alphanohtml');
56$expectedhash =
GETPOST(
'expectedhash',
'aZ09');
58if (!in_array($algo, array(
'md5',
'sha256'),
true)) {
78 while ($start < $na && $start < $nb && $a[$start] === $b[$start]) {
84 while ($enda >= $start && $endb >= $start && $a[$enda] === $b[$endb]) {
90 for ($i = 0; $i < $start; $i++) {
91 $result[] = array(
' ', $a[$i]);
94 $midA = array_slice($a, $start, $enda - $start + 1);
95 $midB = array_slice($b, $start, $endb - $start + 1);
101 for ($i = $enda + 1; $i < $na; $i++) {
102 $result[] = array(
' ', $a[$i]);
119 $a = array_values($a);
120 $b = array_values($b);
124 if ($na == 0 || $nb == 0) {
126 foreach ($a as $line) {
127 $result[] = array(
'-', $line);
129 foreach ($b as $line) {
130 $result[] = array(
'+', $line);
136 if ($na * $nb <= 1000000) {
142 if ($anchor !==
null) {
145 array(array(
' ', $a[$anchor[0]])),
152 foreach ($a as $line) {
153 $result[] = array(
'-', $line);
155 foreach ($b as $line) {
156 $result[] = array(
'+', $line);
172 foreach ($a as $line) {
173 $countA[$line] = (isset($countA[$line]) ? $countA[$line] : 0) + 1;
177 foreach ($b as $j => $line) {
178 $countB[$line] = (isset($countB[$line]) ? $countB[$line] : 0) + 1;
182 $middle = (int) (count($a) / 2);
185 foreach ($a as $i => $line) {
186 if ($countA[$line] == 1 && isset($countB[$line]) && $countB[$line] == 1) {
187 $dist = abs($i - $middle);
188 if ($bestdist < 0 || $dist < $bestdist) {
190 $best = array($i, $posB[$line]);
212 for ($i = 0; $i <= $na; $i++) {
213 $lcs[$i] = array_fill(0, $nb + 1, 0);
215 for ($i = $na - 1; $i >= 0; $i--) {
216 for ($j = $nb - 1; $j >= 0; $j--) {
217 if ($a[$i] === $b[$j]) {
218 $lcs[$i][$j] = $lcs[$i + 1][$j + 1] + 1;
220 $lcs[$i][$j] = max($lcs[$i + 1][$j], $lcs[$i][$j + 1]);
229 while ($i < $na && $j < $nb) {
230 if ($a[$i] === $b[$j]) {
231 $result[] = array(
' ', $a[$i]);
234 } elseif ($lcs[$i + 1][$j] >= $lcs[$i][$j + 1]) {
235 $result[] = array(
'-', $a[$i]);
238 $result[] = array(
'+', $b[$j]);
243 $result[] = array(
'-', $a[$i]);
247 $result[] = array(
'+', $b[$j]);
264 $keep = array_fill(0, $n,
false);
265 for ($i = 0; $i < $n; $i++) {
266 if ($diff[$i][0] !==
' ') {
268 $to_line = min($n - 1, $i +
$context);
269 for ($k = $from_line; $k <= $to_line; $k++) {
277 for ($i = 0; $i < $n; $i++) {
279 $result[] = $diff[$i];
282 $result[] = array(
'@',
'');
293print
'<!-- filecheck_diff.php fragment -->'.
"\n";
298if (empty($file) || $file[0] !==
'/' || strpos($file,
'..') !==
false || !preg_match(
'/^[A-Za-z0-9_\/.\-]+$/', $file)) {
299 $errormsg = $langs->trans(
"ErrorBadValueForParameter",
dol_escape_htmltag($file),
"file");
302if (empty($errormsg)) {
303 $reallocal = realpath(DOL_DOCUMENT_ROOT.$file);
304 if ($reallocal ===
false || strpos($reallocal, realpath(DOL_DOCUMENT_ROOT).
'/') !== 0 || !is_file($reallocal)) {
305 $errormsg = $langs->trans(
"ErrorFileNotFound", $file);
309if (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)) {
310 $errormsg = $langs->trans(
"DiffNotAvailableForBinaryFiles");
313if (!empty($errormsg)) {
314 print
'<div class="warning">'.$errormsg.
'</div>';
321$baseurl =
getDolGlobalString(
'MAIN_FILECHECK_DIFF_BASEURL',
'https://raw.githubusercontent.com/Dolibarr/dolibarr');
322if (preg_match(
'/alpha|beta|rc/i', DOL_VERSION)) {
328$originurl = $baseurl.
'/'.$ref.
'/htdocs'.$file;
330$res =
getURLContent($originurl,
'GET',
'', 1, array(), array(
'http',
'https'), 0);
331if (!empty($res[
'curl_error_no']) || (isset($res[
'http_code']) && !in_array((
int) $res[
'http_code'], array(0, 200),
true))) {
332 print
'<div class="warning">'.$langs->trans(
"CouldNotFetchOriginalFile").
': '.
dol_escape_htmltag($originurl);
333 print
' ('.dol_escape_htmltag((
string) (empty($res[
'http_code']) ? $res[
'curl_error_msg'] : $res[
'http_code'])).
')</div>';
337$origincontent = (
string) $res[
'content'];
338$localcontent = (
string) file_get_contents($reallocal);
342if (!empty($expectedhash)) {
343 $verified = (hash($algo, $origincontent) === $expectedhash);
346 print
'<div class="warning">'.$langs->trans(
"OriginalFileChecksumMismatch").
'</div>';
349if ($origincontent === $localcontent) {
350 print
'<div class="opacitymedium">'.$langs->trans(
"NoDifferenceFound").
'</div>';
354$diff =
filecheckLineDiff(explode(
"\n", $origincontent), explode(
"\n", $localcontent));
357print
'<div class="opacitymedium" style="margin-bottom:4px">';
361print
'<table class="filecheckdiff" style="width:100%;border-collapse:collapse;font-family:monospace;font-size:0.85em">';
362foreach ($diff as $line) {
365 print
'<tr><td style="background:#eef;color:#888;padding:1px 6px">…</td></tr>'.
"\n";
371 $bg =
'background:#e6ffed';
373 } elseif ($type ===
'-') {
374 $bg =
'background:#ffeef0';
377 print
'<tr><td style="white-space:pre-wrap;word-break:break-all;padding:0 6px;'.$bg.
'">';
379 print
'</td></tr>'.
"\n";
394 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.