a.php delete link

This commit is contained in:
francois committed 2026-11-15 14:48:38 +01:00
1 parent 7c06eda643
commit 891e7a35e2
2 files changed
+166 -181

No files matched your search

+154 -172
View File
@@ -1,16 +1,27 @@
<?php <?php
/* /*
* Kaz addon (see https://git.kaz.bzh/KAZ/depollueur for information) * Kaz addon (see https://git.kaz.bzh/KAZ/depollueur for information)
* create un archive for a set of file or update file deadline * create an archive for a set of file or update file deadline
a.php?r=email => track a.php?time=[month|...]&key={password} + POST file => upload
a.php?p=email => period a.php?g={linkHash}~{key} => zip
a.php?u=month&h=HHHHHHHH => update deadline a.php?c=[minute|hour|day|week|month|quarter|semester] => update track cache => cron
a.php?g=l~k => zip a.php?u=[month|...]&h={linkHash} => update deadline
a.php?time=month&key=password + POST file => upload a.php?r={email} => track status
a.php?s=mel@domain.org => form a.php?p={email} => period status
a.php?s=mel@domain.org&t=password + [action] => manage account a.php?l={email} => lang status
action: a=login a=logout a=r[on|off] a=p[minute|hour|day|week|month|quarter|semester] a.php?s={mel@domain} => form
a.php?s={mel@domain}&t={token}&{action} => manage account
action:
| a=login => login
| a=logout => logout
| a=m[none|footer|attachment|both] => set mode
| a=c[minute|hour|day|week|month|quarter|semester] => update track cache
| a=r[on|off] => set followed email
| a=p[minute|hour|day|week|month|quarter|semester] => set perriod
| a=l[fr|en|br] => set lang
| d={linkHash} => delete link
*/ */
require_once (__DIR__ . "/lib/attach-setup.php"); require_once (__DIR__ . "/lib/attach-setup.php");
@@ -18,12 +29,12 @@ require_once (__DIR__ . "/lib/attach-setup.php");
$modeText = ['none' => "sans", 'footer' => "pied de page", 'attachment' => "pi&egrave;ce jointe", 'both' => "les deux"]; $modeText = ['none' => "sans", 'footer' => "pied de page", 'attachment' => "pi&egrave;ce jointe", 'both' => "les deux"];
$trackText = ['on' => "oui", 'off' => "non"]; $trackText = ['on' => "oui", 'off' => "non"];
$periodText = ['minute' => "minute", 'hour' => "heure", 'day' => "jour", 'week' => "semaine", 'month' => "mois", 'quarter' => "trimestre", "semester" => "semestre"]; $periodText = ['minute' => "minute", 'hour' => "heure", 'day' => "jour", 'week' => "semaine", 'month' => "mois", 'quarter' => "trimestre", "semester" => "semestre"];
$periodButton = ['hour' => ["&#128336;", ">1 heure"], // 1F550 $periodButton = ['hour' => ["&#128336;", "garantir 1 heure"], // 1F550
'day' => ["&#128337;", ">1 jour"], // 1F551 'day' => ["&#128337;", "garantir 1 jour"], // 1F551
'week' => ["&#128338;", "> 1 semaine"], // 1F552 'week' => ["&#128338;", "garantir 1 semaine"], // 1F552
'month' => ["&#128339;", "> 1 mois"], // 1F553 'month' => ["&#128339;", "garantir 1 mois"], // 1F553
'quarter' => ["&#128340;", "> 1 trimestre"], // 1F554 'quarter' => ["&#128340;", "garantir 1 trimestre"], // 1F554
'semester' => ["&#128341;", "> 1 semestre"] // 1F555 'semester' => ["&#128341;", "garantir 1 semestre"] // 1F555
]; ];
$langText = ['fr' => "Francais", 'br' => "Breton", 'en' => "english"]; $langText = ['fr' => "Francais", 'br' => "Breton", 'en' => "english"];
$doLogout = ''; $doLogout = '';
@@ -91,6 +102,11 @@ if (isset ($_REQUEST [A_GET]) && !empty ($_REQUEST [A_GET])) {
$doDownload = true; $doDownload = true;
} }
$doCache = false;
if (isset ($_REQUEST [A_CACHE]) && !empty ($_REQUEST [A_CACHE])) {
$doCache = true;
}
// ======================================== // ========================================
function returnError ($msg) { function returnError ($msg) {
displayHeadPage ("Gestion des pièces jointes"); displayHeadPage ("Gestion des pièces jointes");
@@ -243,58 +259,83 @@ function getArchiveCacheFromSender ($sender) {
$l = jirafeau_get_link ($hash); $l = jirafeau_get_link ($hash);
if (empty ($l)) if (empty ($l))
continue; continue;
$archives [] = readArchiveFromLink ($l); $archives [] = readArchiveFromLink ($l, $hash);
// $p = s2p ($hash);
// $lines = file (VAR_FILES . $p . $hash);
// if (!$lines)
// continue;
// $archives [] = readArchiveFromLines ($lines);
} }
return $archives; return $archives;
} }
function cleanArchiveCache () {
global $message, $admin;
if (!file_exists (VAR_CACHE))
return;
$listSender = scandir (VAR_CACHE);
foreach ($listSender as $cacheSender) {
if (strcmp ($cacheSender, '.') === 0 || strcmp ($cacheSender, '..') === 0 ||
preg_match ('/\.tmp/i', "$cacheSender")) {
continue;
}
if (! is_dir (VAR_CACHE.$cacheSender))
continue;
$listLink = scandir (VAR_CACHE.$cacheSender.'/');
foreach ($listLink as $cacheLink) {
if (strcmp ($cacheLink, '.') === 0 || strcmp ($cacheLink, '..') === 0 ||
preg_match ('/\.tmp/i', "$cacheLink")) {
continue;
}
$link = VAR_LINKS . s2p("$cacheLink") . $cacheLink;
if (!file_exists($link)) {
if ($admin)
$message .= "Remove ".$cacheSender."/".$cacheLink."<br/>";
unlink (VAR_CACHE.$cacheSender."/".$cacheLink);
}
}
}
}
function updateArchiveCacheUpTo ($period) { function updateArchiveCacheUpTo ($period) {
global $message;
cleanArchiveCache ();
if (!file_exists (VAR_CACHE)) if (!file_exists (VAR_CACHE))
mkdir (VAR_CACHE, 0755); mkdir (VAR_CACHE, 0755);
$minTime = getArchiveCacheLastUpdate (); $minTime = getArchiveCacheLastUpdate ();
$maxTime = time ()-period2seconds ($period); $maxTime = time ()-period2seconds ($period);
$stack = array (VAR_LINKS); $stack = array (VAR_LINKS);
while ( ($d = array_shift ($stack)) && $d != null) { while ( ($dirName = array_shift ($stack)) && $dirName != null) {
$dir = scandir ($d); $list = scandir ($dirName);
foreach ($dir as $dirName) { foreach ($list as $fileName) {
if (strcmp ($dirName, '.') === 0 || strcmp ($dirName, '..') === 0 || if (strcmp ($fileName, '.') === 0 || strcmp ($fileName, '..') === 0 ||
preg_match ('/\.tmp/i', "$dirName")) { preg_match ('/\.tmp/i', "$fileName")) {
continue; continue;
} }
if (is_dir ($d . $dirName)) { if (is_dir ($dirName . $fileName)) {
// Push new found directory. // Push new found directory.
$stack [] = $d . $dirName . '/'; $stack [] = $dirName . $fileName . '/';
continue; continue;
} }
$time = filemtime ($d . $dirName); $time = filemtime ($dirName . $fileName);
if ($time < $minTime || $time >= $maxTime) if ($time < $minTime || $time >= $maxTime)
continue; continue;
// Read link informations. // Read link informations.
$l = jirafeau_get_link ($dirName); $l = jirafeau_get_link ($fileName);
if (!count ($l)) if (!count ($l))
continue; continue;
if (!isKazArchive ($l)) if (!isKazArchive ($l))
continue; continue;
$archiveInfo = readArchiveFromLink ($l); $archiveInfo = readArchiveFromLink ($l, $fileName);
if (!isset ($archiveInfo [T_SENDER]) || empty ($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);
touch (VAR_CACHE.$archiveInfo [T_SENDER]."/".$l ['hash']); touch (VAR_CACHE.$archiveInfo [T_SENDER]."/".$fileName);
} }
} }
setArchiveCacheLastUpdate ($maxTime); setArchiveCacheLastUpdate ($maxTime);
$message .= "Cache mise &agrave; jour ({$period}).";
} }
// ======================================== // ========================================
function readArchiveFromLink ($link) { function readArchiveFromLink ($link, $linkName) {
$p = s2p ($link ['hash']); $p = s2p ($link ['hash']);
$lines = file (VAR_FILES . $p . $link ['hash']); $lines = file (VAR_FILES . $p . $link ['hash']);
if (empty ($lines)) { if (empty ($lines)) {
@@ -302,9 +343,6 @@ function readArchiveFromLink ($link) {
$message .= "can't read {$linkName}".NL; $message .= "can't read {$linkName}".NL;
return []; return [];
} }
// return readArchiveFromLines ($lines);
// }
// function readArchiveFromLines ($lines) {
$archive = []; $archive = [];
$error = false; $error = false;
foreach ($lines as $line) { foreach ($lines as $line) {
@@ -315,9 +353,7 @@ function readArchiveFromLink ($link) {
case preg_match ("/^\s*time:\s*(\d{4}([:-]\d{2}){5})\s*$/i", $line, $matches): case preg_match ("/^\s*time:\s*(\d{4}([:-]\d{2}){5})\s*$/i", $line, $matches):
$archive [T_TIME] = $matches [1]; $archive [T_TIME] = $matches [1];
break; break;
// XXX case preg_match ("/^\s*sender:\s*(([a-z0-9_=+-]+)(\.[a-z0-9_=+-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6})\s*$/i", $line, $matches):
//case preg_match ("/^\s*sender:\s*(([a-z0-9_+-]+)(\.[a-z0-9_+-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6})\s*$/i", $line, $matches):
case preg_match ("/^\s*sender:\s*(([a-z0-9_=+-]+)(\.[a-z0-9_=+-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6})\s*$/i", $line, $matches):
$archive [T_SENDER] = $matches [1]; $archive [T_SENDER] = $matches [1];
break; break;
// XXX issue ")" // XXX issue ")"
@@ -335,11 +371,13 @@ function readArchiveFromLink ($link) {
break; break;
} }
} }
global $message, $admin; if ($error)
if ($error && $admin) return [];
$message .= "readArchiveFromLines <pre>".print_r ($lines, true)."</pre>"; $archive ['maxtime'] = $link ['time'];
$archiveInfo ['maxtime'] = $link ['time']; $archive ['hash'] = $link ['hash'];
return $error ? [] : $archive; $archive ['key'] = $link ['key'];
$archive ['link'] = $linkName;
return $archive;
} }
// ======================================== // ========================================
@@ -398,27 +436,41 @@ function isAdmin ($sender) {
} }
// ======================================== // ========================================
function deleteLinkAndCache ($linkName, $fileName) {
global $sender, $message;
jirafeau_delete_link ($linkName);
$cacheToDelete = VAR_CACHE.$sender."/".$linkName;
if (file_exists ($cacheToDelete)) {
if (!empty ($fileName))
$message .= "<br/>Remove " . jirafeau_escape ($fileName) . " (".$linkName.")</br>";
unlink ($cacheToDelete);
}
}
function deleteAction ($linkName) { function deleteAction ($linkName) {
global $sender, $token, $message, $doLogout; global $sender, $message;
$link = jirafeau_get_link ($linkName); $link = jirafeau_get_link ($linkName);
//$message .= "ln: ".$linkName." l: "."<pre>".print_r ($link, 1)."</pre> mt: ".getTimeFile ($link ['hash'])."</br>"; //$message .= "ln: ".$linkName." l: "."<pre>".print_r ($link, 1)."</pre> mt: ".getTimeFile ($link ['hash'])."</br>";
if (!count ($link)) if (!count ($link))
return; return;
if (isKazArchive ($link)) { if (isKazArchive ($link)) {
// Acrhive
$dirName = $linkName; $dirName = $linkName;
$dirLink = $link; $dirLink = $link;
$dirTime = $dirLink ['upload_date']; $dirTime = $dirLink ['upload_date'];
$archiveInfo = readArchiveFromLink ($dirLink); $archiveInfo = readArchiveFromLink ($dirLink, $linkName);
if (! count ($archiveInfo)) if (! count ($archiveInfo)) {
$message .= "Archive introuvable ({$dirName})</br>";
return; return;
}
if ($sender != $archiveInfo [T_SENDER]) { if ($sender != $archiveInfo [T_SENDER]) {
setSenderFake ("rmdir: not owner", $sender, $archiveInfo [T_SENDER], $dirLink, null); setSenderFake ("rmdir: not owner", $sender, $archiveInfo [T_SENDER], $dirLink, null);
$message .= "Tentative de supprimer un envoi dont vous n'&ecirc;tes pas le propri&eacute;taire"; $message .= "Tentative de supprimer un envoi dont vous n'&ecirc;tes pas le propri&eacute;taire";
return; return;
} }
$fileToDelete = false; $fileToDelete = false;
if ($archiveInfo [T_NEWKAZ]) if (isset ($archiveInfo [T_NEWKAZ]) && count ($archiveInfo [T_NEWKAZ]))
foreach ($archiveInfo [T_NEWKAZ] as [$fileName, $cryptKey]) { foreach ($archiveInfo [T_NEWKAZ] as [$fileName, $cryptKey]) {
$fileLink = jirafeau_get_link ($fileName); $fileLink = jirafeau_get_link ($fileName);
if (! count ($fileLink)) if (! count ($fileLink))
@@ -427,8 +479,8 @@ function deleteAction ($linkName) {
if (! valideTime ($dirTime, $fileTime)) { if (! valideTime ($dirTime, $fileTime)) {
setSenderFake ("rmdir: newfile not same time", $sender, null, $dirLink, $fileLink); setSenderFake ("rmdir: newfile not same time", $sender, null, $dirLink, $fileLink);
$message .= "Cet envoi a &eacute;t&eacute; forg&eacute;e". $message .= "Cet envoi a &eacute;t&eacute; forg&eacute;e".
str_replace (["___FILENAME___", "___DIRTIME___", "___FILETIME___"], str_replace (["___FILENAME___", "___DIRTIME___", "___FILETIME___"],
[$fileLink ['file_name'], $dirTime , $fileTime], M_INCONSISTENT_DATES); [$fileLink ['file_name'], $dirTime , $fileTime], M_INCONSISTENT_DATES);
return; return;
} }
$fileToDelete = true; $fileToDelete = true;
@@ -436,90 +488,21 @@ function deleteAction ($linkName) {
$message .= "l'envoi ".$archiveInfo [T_TIME]." est supprim&eacute;"; $message .= "l'envoi ".$archiveInfo [T_TIME]." est supprim&eacute;";
if ($fileToDelete) if ($fileToDelete)
$message .= " avec<ul>"; $message .= " avec<ul>";
if ($archiveInfo [T_NEWKAZ]) if (isset ($archiveInfo [T_NEWKAZ]) && count ($archiveInfo [T_NEWKAZ]))
foreach ($archiveInfo [T_NEWKAZ] as [$fileName, $cryptKey]) { foreach ($archiveInfo [T_NEWKAZ] as [$fileName, $cryptKey]) {
$fileLink = jirafeau_get_link ($fileName); $fileLink = jirafeau_get_link ($fileName);
if (! count ($fileLink)) if (! count ($fileLink))
continue; continue;
$message .= "<li>".jirafeau_escape ($fileLink ['file_name'])."</li>"; $message .= "<li>".jirafeau_escape ($fileLink ['file_name'])."</li>";
jirafeau_delete_link ($fileName); deleteLinkAndCache ($fileName, $fileLink ['file_name']);
} }
jirafeau_delete_link ($dirName);
$message .= $fileToDelete ? "</ul>" : "."; $message .= $fileToDelete ? "</ul>" : ".";
deleteLinkAndCache ($dirName, '');
return; return;
} }
$fileName = $linkName;
$fileLink = $link;
$fileTime = $fileLink ['upload_date'];
// XXX // only file
$stack = array (VAR_LINKS); deleteLinkAndCache ($linkName, $link ['file_name']);
while (($d = array_shift ($stack)) && $d != null) {
if (!file_exists ($d))
continue;
$dir = scandir ($d);
foreach ($dir as $dirName) {
if (strcmp ($dirName, '.') === 0 || strcmp ($dirName, '..') === 0 ||
preg_match ('/\.tmp/i', "$dirName")) {
continue;
}
if (is_dir ($d . $dirName)) {
$stack [] = $d . $dirName . '/';
continue;
}
$dirLink = jirafeau_get_link ($dirName);
//$dirTime = getTimeFile ($dirLink ['hash']);
$dirTime = $dirLink ['upload_date'];
if (!count ($dirLink))
continue;
if (!isKazArchive ($dirLink))
continue;
$archiveInfo = readArchiveFromLink ($dirLink);
if (! count ($archiveInfo))
return;
if ($archiveInfo [T_NEWKAZ])
foreach ($archiveInfo [T_NEWKAZ] as [$newName, $cryptKey]) {
if ($fileName != $newName)
continue;
if ($sender == $archiveInfo [T_SENDER]) {
if (valideTime ($dirTime, $fileTime)) {
jirafeau_delete_link ($fileName);
$message .= jirafeau_escape ($fileLink ['file_name'])." est supprim&eacute;";
// check empty dir
$empty = true;
foreach ([T_OLD, T_NEWKAZ] as $cat)
if ($empty && isset ($archiveInfo [$cat]))
foreach ($archiveInfo [$cat] as [$l, $c])
if (count (jirafeau_get_link ($l))) {
$empty = false;
break;
}
if ($empty) {
$message .= " ainsi que l'envoie ".$archiveInfo [T_TIME]." qui est vide.";
jirafeau_delete_link ($dirName);
} else
$message .= ".";
break;
}
setSenderFake ("rm: dir not same time", $sender, null, $dirLink, $fileLink);
$message .= "Cet envoi a &eacute;t&eacute; forg&eacute;e. ".
str_replace (["___FILENAME___", "___DIRTIME___", "___FILETIME___"],
[$fileLink ['file_name'], $dirTime , $fileTime], M_INCONSISTENT_DATES);
break;
}
if (valideTime ($dirTime, $fileTime)) {
setSenderFake ("rm: not owner", $sender, $archiveInfo [T_SENDER], $dirLink, $fileLink);
$message .= "Tentative de supprimer un envoi dont vous n'&ecirc;tes pas le propri&eacute;taire.".
str_replace (["___FILENAME___", "___DIRTIME___", "___FILETIME___"],
[$fileLink ['file_name'], $dirTime , $fileTime], M_INCONSISTENT_DATES);
break;
}
setSenderFake ("rm: find not owner", $archiveInfo [T_SENDER], $sender, $dirLink, $fileLink);
$message .= "Quelqu'un av&eacute;tait revandiqu&eacute; cet envoi. (".$sender." != ".$archiveInfo [T_SENDER].")";
break;
}
}
}
} }
// ======================================== // ========================================
@@ -538,7 +521,7 @@ if ($doUpdate) {
$content = '' . $time . NL; $content = '' . $time . NL;
if (isKazArchive ($link)) { if (isKazArchive ($link)) {
$archiveInfo = readArchiveFromLink ($l); $archiveInfo = readArchiveFromLink ($l, $linkName);
if (count ($archiveInfo)) { if (count ($archiveInfo)) {
foreach ([T_OLD, T_NEWKAZ] as $cat) foreach ([T_OLD, T_NEWKAZ] as $cat)
if (isset ($archiveInfo [$cat])) if (isset ($archiveInfo [$cat]))
@@ -553,6 +536,16 @@ if ($doUpdate) {
exit; exit;
} }
if ($doCache) {
global $message;
updateArchiveCacheUpTo ($_REQUEST [A_CACHE]);
displayHeadPage ("Gestion des pièces jointes");
echo '<div class="message-success">' . $message . '</div>';
displayFootPage ();
exit;
}
// ======================================== // ========================================
if ($doDownload) { if ($doDownload) {
// check archive exist // check archive exist
@@ -570,7 +563,9 @@ if ($doDownload) {
if ($key && (empty ($cryptKey) || $key != $cryptKey)) if ($key && (empty ($cryptKey) || $key != $cryptKey))
returnError (t ('BAD_PSW')); returnError (t ('BAD_PSW'));
$archiveInfo = readArchiveFromLink ($link); $archiveInfo = readArchiveFromLink ($link, $linkName);
if (! count ($archiveInfo))
returnError (t ('FILE_404'));
// check entries // check entries
$archiveContent = []; $archiveContent = [];
@@ -624,7 +619,7 @@ if ($doDownload) {
// build zip // build zip
$dirname = M_NO_SENDER.(isset ($archiveInfo [T_TIME]) && !empty ($archiveInfo [T_TIME])) ? $dirname = M_NO_SENDER.(isset ($archiveInfo [T_TIME]) && !empty ($archiveInfo [T_TIME])) ?
$archiveInfo [T_TIME] : date ("Y-m-d-H:i:s"); $archiveInfo [T_TIME] : date ("Y-m-d-H:i:s");
$dirname = str_replace (":", "_", $dirname); $dirname = str_replace (":", "_", $dirname);
$tmpFileName = tempnam (sys_get_temp_dir (), $dirname."-"); $tmpFileName = tempnam (sys_get_temp_dir (), $dirname."-");
$zip = new ZipArchive; $zip = new ZipArchive;
@@ -672,19 +667,6 @@ if ($doDownload) {
} }
$zip->close (); $zip->close ();
if (false) {
// log
$message .= print_r ($archiveInfo, 1);
$message .= print_r ($archiveContent, 1);
header ('HTTP/1.0 200 OK');
header ('Content-Length: ' . strlen ($message));
header ('Content-Type: text/plain');
echo $message;
exit;
}
if (!is_file ($tmpFileName.T_ZIP_EXT,)) if (!is_file ($tmpFileName.T_ZIP_EXT,))
returnError (E_OPEN_ZIP); returnError (E_OPEN_ZIP);
@@ -720,7 +702,7 @@ if (! ($sender && $token && $token == $refToken &&
$message .= '<div class="message-error">'.M_TOO_LONG_LOGGED.'</div>'.NL; $message .= '<div class="message-error">'.M_TOO_LONG_LOGGED.'</div>'.NL;
if ($message) if ($message)
echo $message; echo $message;
displayLogin (M_LOGIN_CONFIG); displayLogin (M_LOGIN_CONFIG);
displayFootPage (); displayFootPage ();
@@ -781,10 +763,8 @@ if (isset ($_REQUEST [A_ACTION])) {
setSenderLang ($sender, $matches [1]); setSenderLang ($sender, $matches [1]);
$message .= "Votre lang &agrave; &eacute;t&eacute; mise &agrave; jour."; $message .= "Votre lang &agrave; &eacute;t&eacute; mise &agrave; jour.";
break; break;
case preg_match ("/^".A_CACHE."(".implode ("|", array_keys ($periodText)).")$/i", $_REQUEST [A_ACTION], $matches): case preg_match ("/^".A_CACHE."(".implode ("|", array_keys ($periodText)).")$/i", $_REQUEST [A_ACTION], $matches):
updateArchiveCacheUpTo ($matches [1]); updateArchiveCacheUpTo ($matches [1]);
$message .= "Cache mise &agrave; jour {$matches [1]}.";
break; break;
} }
} }
@@ -796,6 +776,7 @@ displayHeadPage ("Gestion des pièces jointes");
echo str_replace (["___SENDER___", "___ADMIN___", "___DATE___"], echo str_replace (["___SENDER___", "___ADMIN___", "___DATE___"],
[$sender, ($admin ? " (admin)" : ""), jirafeau_get_datetimefield (time ())], [$sender, ($admin ? " (admin)" : ""), jirafeau_get_datetimefield (time ())],
M_WELCOME); M_WELCOME);
if ($message) if ($message)
echo '<div class="message-success">Info : '.$message.'</div>'; echo '<div class="message-success">Info : '.$message.'</div>';
echo '<script type="text/javascript">'; echo '<script type="text/javascript">';
@@ -851,13 +832,13 @@ div.frame {border: 1px; border-style: solid; padding: 1em; margin: 1em;}
[data-tooltip]:not([data-tooltip-persistent]):before {pointer-events: none;} [data-tooltip]:not([data-tooltip-persistent]):before {pointer-events: none;}
--></style> --></style>
<?php <?php
$defaultChecked = []; $defaultChecked = [];
$defaultChecked [getSenderMode ($sender)] = ' selected="selected"'; $defaultChecked [getSenderMode ($sender)] = ' selected="selected"';
$defaultChecked [isSenderTrack ($sender) ? "on" : "off"] = ' checked="checked"'; $defaultChecked [isSenderTrack ($sender) ? "on" : "off"] = ' checked="checked"';
$defaultChecked [getSenderPeriod ($sender)] = ' selected="selected"'; $defaultChecked [getSenderPeriod ($sender)] = ' selected="selected"';
$defaultChecked [getSenderLang ($sender)] = ' selected="selected"'; $defaultChecked [getSenderLang ($sender)] = ' selected="selected"';
echo echo
'<form method="post">'. '<br/><form method="post">'.
'Je veux que mes futurs envois soient d&eacute;pollu&eacute;s en pla&ccedil;ant les liens de t&eacute;l&eacute;chargements '. 'Je veux que mes futurs envois soient d&eacute;pollu&eacute;s en pla&ccedil;ant les liens de t&eacute;l&eacute;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)
@@ -866,7 +847,7 @@ echo
'</select> '. '</select> '.
'<button type="submit">'."valider".'</button>'. '<button type="submit">'."valider".'</button>'.
'</form>'. '</form>'.
'<form method="post">'. '<br/><form method="post">'.
'Je veux que Kaz suive tous mes futurs envois: '. 'Je veux que Kaz suive tous mes futurs envois: '.
'<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.'"/>';
@@ -875,7 +856,7 @@ foreach ($trackText as $item => $text)
echo echo
'<button type="submit">'."valider".'</button>'. '<button type="submit">'."valider".'</button>'.
'</form>'. '</form>'.
'<form method="post">'. '<br/><form method="post">'.
'Je veux que mes futurs envois soient accessibles pendant au moins un&middot;e '. 'Je veux que mes futurs envois soient accessibles pendant au moins un&middot;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)
@@ -884,7 +865,7 @@ echo
'</select> '. '</select> '.
'<button type="submit">'."valider".'</button>'. '<button type="submit">'."valider".'</button>'.
'</form>'. '</form>'.
'<form method="post">'. '<br/><form method="post">'.
'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)
@@ -893,7 +874,7 @@ echo
'</select> '. '</select> '.
'<button type="submit">'."valider".'</button>'. '<button type="submit">'."valider".'</button>'.
'</form>'. '</form>'.
'<form method="post">'. '<br/><form method="post">'.
'Je veux '. 'Je veux '.
'<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.'"/>'.
@@ -902,17 +883,18 @@ echo
if ($admin) { if ($admin) {
echo echo
'<form method="post">'. '<br/><form method="post">'.
'Mettre &agrave; jour le cache jusqu\'&agrave; '. 'Mettre &agrave; jour le cache jusqu\'&agrave; '.
'<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.'"/>'.
'<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_CACHE.$item.'">'.$text.'</option>'; echo ' <option value="'.A_CACHE.$item.'"'.($defaultChecked [$item] ?? "").'>'.$text.'</option>';
echo echo
'</select> '. '</select> '.
'<button type="submit">'."valider".'</button>'. '<button type="submit">'."valider".'</button>'.
'.</form><br/>'; '.</form><br/>';
//href="javascript:ajaxUpdate (\''.$item.'\', \''.$la.'\');"
} }
$userSise = 0; $userSise = 0;
@@ -922,7 +904,7 @@ if ($archives) {
$contentSize = 0; $contentSize = 0;
$archContent = ''; $archContent = '';
foreach ([T_NEWKAZ, T_OLD] as $cat) { foreach ([T_NEWKAZ, T_OLD] as $cat) {
$liStyle = $cat == T_NEWKAZ ? "font-weight: bold;" : "font-style: italic;"; $linkStyle = ($cat == T_NEWKAZ) ? "font-weight: bold;" : "font-style: italic;";
if (isset ($archiveInfo [$cat])) if (isset ($archiveInfo [$cat]))
foreach ($archiveInfo [$cat] as [$linkName, $cryptKey]) { foreach ($archiveInfo [$cat] as [$linkName, $cryptKey]) {
$link = jirafeau_get_link ($linkName); $link = jirafeau_get_link ($linkName);
@@ -933,38 +915,38 @@ if ($archives) {
$lf = $linkName; $lf = $linkName;
$kf = $link ['key']; $kf = $link ['key'];
$archContent .= $archContent .=
'<li style="list-style:none; '.$liStyle.'">'. '<li style="list-style:none">'.
'<a data-tooltip="voir" href="javascript:getKazFile (\''.$lf.'\', \''.$kf.'\');"> &#128065; </a>'. '<a data-tooltip="voir le document" href="javascript:getKazFile (\''.$lf.'\', \''.$kf.'\');"> &#128065; </a>'.
'<a data-tooltip="voir le lien" href="javascript:showLink (\''.$lf.'\', \''.$kf.'\');"> &#128279; </a>'; '<a data-tooltip="voir le lien du document" href="javascript:showLink (\''.$lf.'\', \''.$kf.'\');"> &#128279; </a>';
// foreach ($periodButton as $item => $bt) // foreach ($periodButton as $item => $bt)
// echo '<a data-tooltip="'.$bt[1].'" href="javascript:ajaxUpdate (\''.$lf.'\', \''.$kf.'\');"> '.$bt[0].' </a>'; // echo '<a data-tooltip="'.$bt[1].'" href="javascript:ajaxUpdate (\''.$lf.'\', \''.$kf.'\');"> '.$bt[0].' </a>';
$archContent .= $archContent .= '<span style="'.$linkStyle.'">'.
jirafeau_escape ($link ['file_name']). jirafeau_escape ($link ['file_name']).
' ('.jirafeau_escape ($link ['mime_type']). ' ('.jirafeau_escape ($link ['mime_type']).
' '.jirafeau_human_size ($link ['file_size']).')'; ' '.jirafeau_human_size ($link ['file_size']).')</span>';
if ($cat == T_NEWKAZ) if ($cat == T_NEWKAZ)
$archContent .= $archContent .=
'<a data-tooltip="supprimer" href="javascript:rmFile (\''.$lf.'\');"> &#9850; </a>'; '<a data-tooltip="supprimer" href="javascript:rmFile (\''.$lf.'\');"> &#9850; </a>';
$archContent .= $archContent .=
'</li>'; '</li>';
} }
} }
$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.'\');"> &#128065; </a>'. '<a data-tooltip="t&eacute;l&eacute;charger l\'archive" href="javascript:getKazArchive (\''.$la.'\', \''.$ka.'\');"> &#128065; </a>'.
'<a data-tooltip="voir le lien" href="javascript:showLink (\''.$la.'\', \''.$ka.'\');"> &#128279; </a>'; '<a data-tooltip="voir le lien de l\'archive" href="javascript:showLink (\''.$la.'\', \''.$ka.'\');"> &#128279; </a>';
foreach ($periodButton as $item => $bt) foreach ($periodButton as $item => $bt)
$archEntry .= $archEntry .=
'<a data-tooltip="'.$bt[1].'" href="javascript:ajaxUpdate (\''.$item.'\', \''.$la.'\');"> '.$bt[0].' </a>'; '<a data-tooltip="'.$bt[1].'" href="javascript:ajaxUpdate (\''.$item.'\', \''.$la.'\');"> '.$bt[0].' </a>';
$archEntry .= $archEntry .=
'<strong>'.$archiveInfo [T_TIME].' ('.jirafeau_human_size ($contentSize).')</strong>'. '<strong>'.$archiveInfo [T_TIME].' ('.jirafeau_human_size ($contentSize).')</strong>'.
'<a data-tooltip="supprimer tous" href="javascript:rmFile (\''.$la.'\');"> &#9850; </a>'. '<a data-tooltip="supprimer tous" href="javascript:rmFile (\''.$la.'\');"> &#9850; </a>'.
'<br/>=> '. ($archiveInfo ['maxtime'] == -1 ? '∞' : jirafeau_get_datetimefield ($archiveInfo ['maxtime'])).'<ul>'. '<br/>=> '. ($archiveInfo ['maxtime'] == -1 ? '∞' : jirafeau_get_datetimefield ($archiveInfo ['maxtime'])).'<ul>'.
$archContent. $archContent.
'</div>'; '</div>';
$userSise += $contentSize; $userSise += $contentSize;
$userTab [getTimeFile ($archiveInfo ['hash'])] = $archEntry; $userTab [getTimeFile ($archiveInfo ['hash'])] = $archEntry;
} }
@@ -973,7 +955,7 @@ if ($archives) {
echo echo
'<span>Votre compte occupe <b>'.jirafeau_human_size ($userSise).'</b>.</span>'. '<span>Votre compte occupe <b>'.jirafeau_human_size ($userSise).'</b>.</span>'.
'<form method="post">'. '<br/><form method="post">'.
'Je veux me '. 'Je veux me '.
'<input type="hidden" name="'.A_ACTION.'" value="'.T_LOGOUT.'" />'. '<input type="hidden" name="'.A_ACTION.'" value="'.T_LOGOUT.'" />'.
'<input type="hidden" name="'.A_SENDER.'" value="'.$sender.'"/>'. '<input type="hidden" name="'.A_SENDER.'" value="'.$sender.'"/>'.
+12 -9
View File
@@ -27,13 +27,13 @@ function s2p($s)
{ {
$block_size = 8; $block_size = 8;
$p = ''; $p = '';
for ($i = 0; $i < strlen($s); $i++) { for ($i = 0; $i < strlen($s ?? ''); $i++) {
$p .= $s[$i]; $p .= $s[$i];
if (($i + 1) % $block_size === 0) { if (($i + 1) % $block_size === 0) {
$p .= '/'; $p .= '/';
} }
} }
if (strlen($s) % $block_size !== 0) { if (strlen($s ?? '') % $block_size !== 0) {
$p .= '/'; $p .= '/';
} }
return $p; return $p;
@@ -66,7 +66,7 @@ function base_16_to_64($num)
$b = ''; $b = '';
$i = 0; $i = 0;
# Convert long hex string to bin. # Convert long hex string to bin.
$size = strlen($num); $size = strlen($num ?? '');
for ($i = 0; $i < $size; $i++) { for ($i = 0; $i < $size; $i++) {
$b .= $hex2bin[hexdec($num[$i])]; $b .= $hex2bin[hexdec($num[$i])];
} }
@@ -130,8 +130,11 @@ function jirafeau_human_size($octets)
// Convert UTC timestamp to a datetime field // Convert UTC timestamp to a datetime field
function jirafeau_get_datetimefield($timestamp) function jirafeau_get_datetimefield($timestamp)
{ {
return '<span class="datetime" data-datetime="' . (new DateTime())->setTimestamp($timestamp)->format('Y-m-d H:i') . '">' if (isset ($timestamp) && !empty ($timestamp))
. (new DateTime())->setTimestamp($timestamp)->format('Y-m-d H:i') . ' (GMT)</span>'; $date = new DateTime ()->setTimestamp ($timestamp) -> format ('Y-m-d H:i');
else
$date ="???";
return '<span class="datetime" data-datetime="{$date}">'.$date.' (GMT)</span>';
} }
function jirafeau_fatal_error($errorText, $cfg = array()) function jirafeau_fatal_error($errorText, $cfg = array())
@@ -154,7 +157,7 @@ function jirafeau_clean_rm_link($link)
&& count($scan) === 2 // '.' and '..' folders => empty. && count($scan) === 2 // '.' and '..' folders => empty.
&& basename($parse) !== basename(VAR_LINKS)) { && basename($parse) !== basename(VAR_LINKS)) {
rmdir($parse); rmdir($parse);
$parse = substr($parse, 0, strlen($parse) - strlen(basename($parse)) - 1); $parse = substr($parse, 0, strlen($parse ?? '') - strlen(basename($parse ?? '')) - 1);
} }
} }
@@ -175,7 +178,7 @@ function jirafeau_clean_rm_file($hash)
&& count($scan) === 2 // '.' and '..' folders => empty. && count($scan) === 2 // '.' and '..' folders => empty.
&& basename($parse) !== basename(VAR_FILES)) { && basename($parse) !== basename(VAR_FILES)) {
rmdir($parse); rmdir($parse);
$parse = substr($parse, 0, strlen($parse) - strlen(basename($parse)) - 1); $parse = substr($parse, 0, strlen($parse ?? '') - strlen(basename($parse ?? '')) - 1);
} }
} }
@@ -833,7 +836,7 @@ function jirafeau_async_delete($ref)
&& count($scan) === 2 // '.' and '..' folders => empty. && count($scan) === 2 // '.' and '..' folders => empty.
&& basename($parse) !== basename(VAR_ASYNC)) { && basename($parse) !== basename(VAR_ASYNC)) {
rmdir($parse); rmdir($parse);
$parse = substr($parse, 0, strlen($parse) - strlen(basename($parse)) - 1); $parse = substr($parse, 0, strlen($parse ?? '') - strlen(basename($parse ?? '')) - 1);
} }
} }
@@ -1027,7 +1030,7 @@ function jirafeau_async_end($ref, $code, $crypt, $link_name_length, $file_hash_m
function jirafeau_crypt_create_iv($base, $size) function jirafeau_crypt_create_iv($base, $size)
{ {
$iv = ''; $iv = '';
while (strlen($iv) < $size) { while (strlen($iv ?? '') < $size) {
$iv .= $base; $iv .= $base;
} }
return substr($iv, 0, $size); return substr($iv, 0, $size);