fix PHP8
This commit is contained in:
1 parent
818c83a99d
commit
ac67ba5b4e
7 files changed
+1626
-20
No files matched your search
+25
-18
@@ -13,7 +13,7 @@
|
|||||||
action: a=login a=logout a=r[on|off] a=p[minute|hour|day|week|month|quarter|semester]
|
action: a=login a=logout a=r[on|off] a=p[minute|hour|day|week|month|quarter|semester]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require (__DIR__ . "/lib/attach-setup.php");
|
require_once (__DIR__ . "/lib/attach-setup.php");
|
||||||
|
|
||||||
$modeText = ['none' => "sans", 'footer' => "pied de page", 'attachment' => "pièce jointe", 'both' => "les deux"];
|
$modeText = ['none' => "sans", 'footer' => "pied de page", 'attachment' => "pièce jointe", 'both' => "les deux"];
|
||||||
$trackText = ['on' => "oui", 'off' => "non"];
|
$trackText = ['on' => "oui", 'off' => "non"];
|
||||||
@@ -44,7 +44,7 @@ if (isset ($_REQUEST [A_MODE]) && !empty ($_REQUEST [A_MODE])) {
|
|||||||
// ========================================
|
// ========================================
|
||||||
if (isset ($_REQUEST [A_RECORD]) && !empty ($_REQUEST [A_RECORD])) {
|
if (isset ($_REQUEST [A_RECORD]) && !empty ($_REQUEST [A_RECORD])) {
|
||||||
if (!preg_match ("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/i", $_REQUEST [A_RECORD]))
|
if (!preg_match ("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/i", $_REQUEST [A_RECORD]))
|
||||||
$content = false.NL;
|
$content = NL;
|
||||||
else
|
else
|
||||||
$content = isSenderTrack ($_REQUEST [A_RECORD]).NL;
|
$content = isSenderTrack ($_REQUEST [A_RECORD]).NL;
|
||||||
header ('HTTP/1.0 200 OK');
|
header ('HTTP/1.0 200 OK');
|
||||||
@@ -142,7 +142,7 @@ function rmSenderTrack ($sender) {
|
|||||||
unlink (VAR_TRACKS.$sender);
|
unlink (VAR_TRACKS.$sender);
|
||||||
}
|
}
|
||||||
function isSenderTrack ($sender) {
|
function isSenderTrack ($sender) {
|
||||||
return $sender && file_exists (VAR_TRACKS.$sender);
|
return isset ($sender) && file_exists (VAR_TRACKS.$sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========================================
|
// ========================================
|
||||||
@@ -240,11 +240,16 @@ function getArchiveCacheFromSender ($sender) {
|
|||||||
return $archives;
|
return $archives;
|
||||||
$dir = scandir (VAR_CACHE.$sender);
|
$dir = scandir (VAR_CACHE.$sender);
|
||||||
foreach ($dir as $hash) {
|
foreach ($dir as $hash) {
|
||||||
$p = s2p ($hash);
|
$l = jirafeau_get_link ($hash);
|
||||||
$lines = file (VAR_FILES . $p . $hash);
|
if (empty ($l))
|
||||||
if (!$lines)
|
|
||||||
continue;
|
continue;
|
||||||
$archives [] = readArchiveFromLines ($lines);
|
$archives [] = readArchiveFromLink ($l);
|
||||||
|
|
||||||
|
// $p = s2p ($hash);
|
||||||
|
// $lines = file (VAR_FILES . $p . $hash);
|
||||||
|
// if (!$lines)
|
||||||
|
// continue;
|
||||||
|
// $archives [] = readArchiveFromLines ($lines);
|
||||||
}
|
}
|
||||||
return $archives;
|
return $archives;
|
||||||
}
|
}
|
||||||
@@ -278,7 +283,7 @@ function updateArchiveCacheUpTo ($period) {
|
|||||||
if (!isKazArchive ($l))
|
if (!isKazArchive ($l))
|
||||||
continue;
|
continue;
|
||||||
$archiveInfo = readArchiveFromLink ($l);
|
$archiveInfo = readArchiveFromLink ($l);
|
||||||
if (!$archiveInfo [T_SENDER])
|
if (!isset ($archiveInfo [T_SENDER]) || empty ($archiveInfo [T_SENDER]))
|
||||||
continue;
|
continue;
|
||||||
if (!file_exists (VAR_CACHE.$archiveInfo [T_SENDER]))
|
if (!file_exists (VAR_CACHE.$archiveInfo [T_SENDER]))
|
||||||
mkdir (VAR_CACHE.$archiveInfo [T_SENDER], 0755);
|
mkdir (VAR_CACHE.$archiveInfo [T_SENDER], 0755);
|
||||||
@@ -292,13 +297,14 @@ function updateArchiveCacheUpTo ($period) {
|
|||||||
function readArchiveFromLink ($link) {
|
function readArchiveFromLink ($link) {
|
||||||
$p = s2p ($link ['hash']);
|
$p = s2p ($link ['hash']);
|
||||||
$lines = file (VAR_FILES . $p . $link ['hash']);
|
$lines = file (VAR_FILES . $p . $link ['hash']);
|
||||||
if ($lines)
|
if (empty ($lines)) {
|
||||||
return readArchiveFromLines ($lines);
|
|
||||||
global $message;
|
global $message;
|
||||||
$message .= "can't read {$linkName}".NL;
|
$message .= "can't read {$linkName}".NL;
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
function readArchiveFromLines ($lines) {
|
// return readArchiveFromLines ($lines);
|
||||||
|
// }
|
||||||
|
// function readArchiveFromLines ($lines) {
|
||||||
$archive = [];
|
$archive = [];
|
||||||
$error = false;
|
$error = false;
|
||||||
foreach ($lines as $line) {
|
foreach ($lines as $line) {
|
||||||
@@ -332,6 +338,7 @@ function readArchiveFromLines ($lines) {
|
|||||||
global $message, $admin;
|
global $message, $admin;
|
||||||
if ($error && $admin)
|
if ($error && $admin)
|
||||||
$message .= "readArchiveFromLines <pre>".print_r ($lines, true)."</pre>";
|
$message .= "readArchiveFromLines <pre>".print_r ($lines, true)."</pre>";
|
||||||
|
$archiveInfo ['maxtime'] = $link ['time'];
|
||||||
return $error ? [] : $archive;
|
return $error ? [] : $archive;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -854,7 +861,7 @@ echo
|
|||||||
'Je veux que mes futurs envois soient dépollués en plaçant les liens de téléchargements '.
|
'Je veux que mes futurs envois soient dépollués en plaçant les liens de téléchargements '.
|
||||||
'<select name="'.A_ACTION.'" style="width: auto !important;">';
|
'<select name="'.A_ACTION.'" style="width: auto !important;">';
|
||||||
foreach ($modeText as $item => $text)
|
foreach ($modeText as $item => $text)
|
||||||
echo ' <option value="'.A_MODE.$item.'"'.$defaultChecked [$item].'>'.$text.'</option>';
|
echo ' <option value="'.A_MODE.$item.'"'.($defaultChecked [$item] ?? "").'>'.$text.'</option>';
|
||||||
echo
|
echo
|
||||||
'</select> '.
|
'</select> '.
|
||||||
'<button type="submit">'."valider".'</button>'.
|
'<button type="submit">'."valider".'</button>'.
|
||||||
@@ -864,7 +871,7 @@ echo
|
|||||||
'<input type="hidden" name="'.A_SENDER.'" value="'.$sender.'"/>'.
|
'<input type="hidden" name="'.A_SENDER.'" value="'.$sender.'"/>'.
|
||||||
'<input type="hidden" name="'.A_TOKEN.'" value="'.$token.'"/>';
|
'<input type="hidden" name="'.A_TOKEN.'" value="'.$token.'"/>';
|
||||||
foreach ($trackText as $item => $text)
|
foreach ($trackText as $item => $text)
|
||||||
echo '<input type="radio" name="'.A_ACTION.'" value="'.A_RECORD.$item.'"'.$defaultChecked [$item].'>'.$text.' ';
|
echo '<input type="radio" name="'.A_ACTION.'" value="'.A_RECORD.$item.'"'.($defaultChecked [$item] ?? "").'>'.$text.' ';
|
||||||
echo
|
echo
|
||||||
'<button type="submit">'."valider".'</button>'.
|
'<button type="submit">'."valider".'</button>'.
|
||||||
'</form>'.
|
'</form>'.
|
||||||
@@ -872,7 +879,7 @@ echo
|
|||||||
'Je veux que mes futurs envois soient accessibles pendant au moins un·e '.
|
'Je veux que mes futurs envois soient accessibles pendant au moins un·e '.
|
||||||
'<select name="'.A_ACTION.'" style="width: auto !important;">';
|
'<select name="'.A_ACTION.'" style="width: auto !important;">';
|
||||||
foreach ($periodText as $item => $text)
|
foreach ($periodText as $item => $text)
|
||||||
echo ' <option value="'.A_PERIOD.$item.'"'.$defaultChecked [$item].'>'.$text.'</option>';
|
echo ' <option value="'.A_PERIOD.$item.'"'.($defaultChecked [$item] ?? "").'>'.$text.'</option>';
|
||||||
echo
|
echo
|
||||||
'</select> '.
|
'</select> '.
|
||||||
'<button type="submit">'."valider".'</button>'.
|
'<button type="submit">'."valider".'</button>'.
|
||||||
@@ -881,7 +888,7 @@ echo
|
|||||||
'Je préfère envoyer mes messages en langue '.
|
'Je préfère envoyer mes messages en langue '.
|
||||||
'<select name="'.A_ACTION.'" style="width: auto !important;">';
|
'<select name="'.A_ACTION.'" style="width: auto !important;">';
|
||||||
foreach ($langText as $item => $text)
|
foreach ($langText as $item => $text)
|
||||||
echo ' <option value="'.A_LANG.$item.'"'.$defaultChecked [$item].'>'.$text.'</option>';
|
echo ' <option value="'.A_LANG.$item.'"'.($defaultChecked [$item] ?? "").'>'.$text.'</option>';
|
||||||
echo
|
echo
|
||||||
'</select> '.
|
'</select> '.
|
||||||
'<button type="submit">'."valider".'</button>'.
|
'<button type="submit">'."valider".'</button>'.
|
||||||
@@ -944,8 +951,8 @@ if ($archives) {
|
|||||||
}
|
}
|
||||||
$archEntry =
|
$archEntry =
|
||||||
'<div class="frame" width="100%" >';
|
'<div class="frame" width="100%" >';
|
||||||
$la = $archiveInfo ['link'];
|
$la = $archiveInfo ['link'] ?? '';
|
||||||
$ka = $archiveInfo ['key'];
|
$ka = $archiveInfo ['key'] ?? '';
|
||||||
$archEntry .=
|
$archEntry .=
|
||||||
'<a data-tooltip="voir" href="javascript:getKazArchive (\''.$la.'\', \''.$ka.'\');"> 👁 </a>'.
|
'<a data-tooltip="voir" href="javascript:getKazArchive (\''.$la.'\', \''.$ka.'\');"> 👁 </a>'.
|
||||||
'<a data-tooltip="voir le lien" href="javascript:showLink (\''.$la.'\', \''.$ka.'\');"> 🔗 </a>';
|
'<a data-tooltip="voir le lien" href="javascript:showLink (\''.$la.'\', \''.$ka.'\');"> 🔗 </a>';
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ define ('VAR_TRACKS', $cfg ['var_root'].'tracks/');
|
|||||||
define ('VAR_PERIOD', $cfg ['var_root'].'period/');
|
define ('VAR_PERIOD', $cfg ['var_root'].'period/');
|
||||||
define ('VAR_LANG', $cfg ['var_root'].'lang/');
|
define ('VAR_LANG', $cfg ['var_root'].'lang/');
|
||||||
define ('VAR_FAKE', $cfg ['var_root'].'fake/');
|
define ('VAR_FAKE', $cfg ['var_root'].'fake/');
|
||||||
|
define ('VAR_CACHE', $cfg ['var_root'].'trackCache/');
|
||||||
|
define ('FILE_LAST_CACHE', VAR_CACHE . 'lastupdate');
|
||||||
define ('VAR_ADMIN', $cfg ['var_root'].'admin/');
|
define ('VAR_ADMIN', $cfg ['var_root'].'admin/');
|
||||||
define ('VAR_CONFIG', $cfg ['var_root'].'config/');
|
define ('VAR_CONFIG', $cfg ['var_root'].'config/');
|
||||||
define ('VAR_CLOUD', $cfg['var_root'].'cloud/');
|
define ('VAR_CLOUD', $cfg['var_root'].'cloud/');
|
||||||
@@ -127,6 +129,7 @@ define ('A_OPEN_TOKEN', 'o'); // ask token
|
|||||||
define ('A_TOKEN', 't'); // session token
|
define ('A_TOKEN', 't'); // session token
|
||||||
define ('A_UPDATE', 'u'); // update perriod for file or archive
|
define ('A_UPDATE', 'u'); // update perriod for file or archive
|
||||||
define ('A_MODE', 'm'); // get mode status
|
define ('A_MODE', 'm'); // get mode status
|
||||||
|
define ('A_CACHE', 'c'); // get mode status
|
||||||
define ('A_RECORD', 'r'); // get track status
|
define ('A_RECORD', 'r'); // get track status
|
||||||
define ('A_PERIOD', 'p'); // get period status
|
define ('A_PERIOD', 'p'); // get period status
|
||||||
define ('A_LANG', 'l'); // get lang status
|
define ('A_LANG', 'l'); // get lang status
|
||||||
@@ -372,7 +375,8 @@ if (isset ($_REQUEST [A_TOKEN]) && !empty ($_REQUEST [A_TOKEN])) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$refToken = getToken ($sender);
|
$refToken = getToken ($sender);
|
||||||
$urlBase = $_SERVER ['HTTP_X_FORWARDED_PROTO']."://".$_SERVER ['HTTP_HOST'];
|
$protocol = $_SERVER['HTTP_X_FORWARDED_PROTO'] ?? 'https';
|
||||||
|
$urlBase = $protocol . "://" . $_SERVER['HTTP_HOST'];
|
||||||
if (isset ($_REQUEST [A_ACTION]) && $_REQUEST [A_ACTION] == T_LOGIN && $sender) {
|
if (isset ($_REQUEST [A_ACTION]) && $_REQUEST [A_ACTION] == T_LOGIN && $sender) {
|
||||||
displayHeadPage ("Erreur");
|
displayHeadPage ("Erreur");
|
||||||
if (getSenderFake ($sender))
|
if (getSenderFake ($sender))
|
||||||
|
|||||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,126 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* Jirafeau, your web file repository
|
||||||
|
* Copyright (C) 2015 Jerome Jutteau <jerome@jutteau.fr>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function t($string_id)
|
||||||
|
{
|
||||||
|
$lang_config = $GLOBALS['cfg']['lang'];
|
||||||
|
if ($lang_config != "auto") {
|
||||||
|
$r = t_in($string_id, $lang_config);
|
||||||
|
if ($r === false || $r === "") {
|
||||||
|
return "FIX ME";
|
||||||
|
}
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
|
|
||||||
|
$visitor_langs = t_visitor_langs();
|
||||||
|
foreach ($visitor_langs as $lang) {
|
||||||
|
$r = t_in($string_id, $lang);
|
||||||
|
if ($r === false || $r === "") {
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "FIX ME";
|
||||||
|
}
|
||||||
|
|
||||||
|
function t_visitor_langs()
|
||||||
|
{
|
||||||
|
$visitor_langs = t_parse_accept_language();
|
||||||
|
array_push($visitor_langs, "en");
|
||||||
|
return $visitor_langs;
|
||||||
|
}
|
||||||
|
|
||||||
|
function t_parse_accept_language()
|
||||||
|
{
|
||||||
|
if (!isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
// Example: fr-CH, fr;q=0.9, en;q=0.8, de;q=0.7, *;q=0.5
|
||||||
|
$langs = [];
|
||||||
|
$cols = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
|
||||||
|
foreach ($cols as $i => $semicols) {
|
||||||
|
$lang = explode(';', $semicols);
|
||||||
|
if (count($lang) === 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
array_push($langs, $lang[0]);
|
||||||
|
}
|
||||||
|
return $langs;
|
||||||
|
}
|
||||||
|
|
||||||
|
function t_in($string_id, $lang)
|
||||||
|
{
|
||||||
|
$trans = t_get_json($lang);
|
||||||
|
if ($trans === false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!array_key_exists($string_id, $trans)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return $trans[$string_id];
|
||||||
|
}
|
||||||
|
|
||||||
|
function t_get_raw_json($lang)
|
||||||
|
{
|
||||||
|
$filename = str_replace("-", "_", $lang);
|
||||||
|
if (preg_match('/[^A-Za-z_\w]/', $filename)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$p = JIRAFEAU_ROOT . "lib/locales/$filename.json";
|
||||||
|
if (!file_exists($p)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$json = file_get_contents($p);
|
||||||
|
if ($json === false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return $json;
|
||||||
|
}
|
||||||
|
|
||||||
|
function t_get_json($lang)
|
||||||
|
{
|
||||||
|
$raw_j = t_get_raw_json($lang);
|
||||||
|
$array = json_decode($raw_j, true);
|
||||||
|
if ($array === null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return $array;
|
||||||
|
}
|
||||||
|
|
||||||
|
function json_lang_generator($lang)
|
||||||
|
{
|
||||||
|
$r = false;
|
||||||
|
if ($lang === null) {
|
||||||
|
$lang_config = $GLOBALS['cfg']['lang'];
|
||||||
|
if ($lang_config != "auto") {
|
||||||
|
$r = t_get_raw_json($lang_config);
|
||||||
|
} else {
|
||||||
|
foreach (t_visitor_langs() as $lang) {
|
||||||
|
$r = t_get_raw_json($lang);
|
||||||
|
if (!($r === false)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$r = t_get_raw_json($lang);
|
||||||
|
}
|
||||||
|
return $r === false ? "{}" : $r;
|
||||||
|
}
|
||||||
@@ -51,7 +51,7 @@ define('VAR_ASYNC', $cfg['var_root'] . 'async/');
|
|||||||
// helping variable to build absolute link to
|
// helping variable to build absolute link to
|
||||||
// root of the domain without handling the URL scheme
|
// root of the domain without handling the URL scheme
|
||||||
$absPrefix = parse_url($cfg['web_root'], PHP_URL_PATH);
|
$absPrefix = parse_url($cfg['web_root'], PHP_URL_PATH);
|
||||||
if (empty($absPrefix)) {
|
if (true === empty($absPrefix)) {
|
||||||
// fallback if installation isnt done yet: relative links to same level on the current page
|
// fallback if installation isnt done yet: relative links to same level on the current page
|
||||||
$absPrefix = './';
|
$absPrefix = './';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<p>La limite des téléversements est actuellement de <?php echo ini_get("post_max_size"); ?></p>
|
||||||
|
<div id="copyright">
|
||||||
|
<p>
|
||||||
|
<!-- Project links -->
|
||||||
|
<?php
|
||||||
|
echo t('MADE_WITH') .
|
||||||
|
' <a href="https://gitlab.com/mojo42/Jirafeau" target="_blank" rel="noopener noreferrer">' . t('JI_PROJECT') . '</a>' .
|
||||||
|
' (<a href="https://www.gnu.org/licenses/agpl.html" target="_blank" rel="noopener noreferrer"><abbr title="GNU Affero General Public License v3">AGPL-3.0</abbr></a>)';
|
||||||
|
?>
|
||||||
|
<!-- Installation dependend links -->
|
||||||
|
<?php
|
||||||
|
if (false === empty($cfg['installation_done'])) {
|
||||||
|
echo ' <span>|</span> ';
|
||||||
|
echo '<a href="tos.php" target="_blank" rel="noopener noreferrer">' . t('TOS') . '</a>';
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="kaz">
|
||||||
|
<div id="jyraphe">
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
header('Content-Type: text/html; charset=utf-8');
|
||||||
|
header('x-ua-compatible: ie=edge');
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title><?php echo (true === empty($cfg['title']))? t('JI_WEB_RE') : $cfg['title']; ?></title>
|
||||||
|
<link rel="shortcut icon" href="<?php echo 'media/' . $cfg['style'] . '/favicon.ico'; ?>">
|
||||||
|
<link href="<?php echo 'media/' . $cfg['style'] . '/style.css.php'; ?>" rel="stylesheet" type="text/css" />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<script type="text/javascript" src="<?php echo 'lib/functions.js.php'; ?>"></script>
|
||||||
|
<div id="content">
|
||||||
|
<h1>
|
||||||
|
<a href="./">
|
||||||
|
<?php echo (true === empty($cfg['title']))? t('JI_WEB_RE') : $cfg['title']; ?>
|
||||||
|
</a>
|
||||||
|
</h1>
|
||||||
Reference in new issue
Block a user