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
+149 -164

No files matched your search

+137 -155
View File
@@ -1,16 +1,27 @@
<?php
/*
* 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?p=email => period
a.php?u=month&h=HHHHHHHH => update deadline
a.php?g=l~k => zip
a.php?time=month&key=password + POST file => upload
a.php?s=mel@domain.org => form
a.php?s=mel@domain.org&t=password + [action] => manage account
action: a=login a=logout a=r[on|off] a=p[minute|hour|day|week|month|quarter|semester]
a.php?time=[month|...]&key={password} + POST file => upload
a.php?g={linkHash}~{key} => zip
a.php?c=[minute|hour|day|week|month|quarter|semester] => update track cache => cron
a.php?u=[month|...]&h={linkHash} => update deadline
a.php?r={email} => track status
a.php?p={email} => period status
a.php?l={email} => lang status
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");
@@ -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"];
$trackText = ['on' => "oui", 'off' => "non"];
$periodText = ['minute' => "minute", 'hour' => "heure", 'day' => "jour", 'week' => "semaine", 'month' => "mois", 'quarter' => "trimestre", "semester" => "semestre"];
$periodButton = ['hour' => ["&#128336;", ">1 heure"], // 1F550
'day' => ["&#128337;", ">1 jour"], // 1F551
'week' => ["&#128338;", "> 1 semaine"], // 1F552
'month' => ["&#128339;", "> 1 mois"], // 1F553
'quarter' => ["&#128340;", "> 1 trimestre"], // 1F554
'semester' => ["&#128341;", "> 1 semestre"] // 1F555
$periodButton = ['hour' => ["&#128336;", "garantir 1 heure"], // 1F550
'day' => ["&#128337;", "garantir 1 jour"], // 1F551
'week' => ["&#128338;", "garantir 1 semaine"], // 1F552
'month' => ["&#128339;", "garantir 1 mois"], // 1F553
'quarter' => ["&#128340;", "garantir 1 trimestre"], // 1F554
'semester' => ["&#128341;", "garantir 1 semestre"] // 1F555
];
$langText = ['fr' => "Francais", 'br' => "Breton", 'en' => "english"];
$doLogout = '';
@@ -91,6 +102,11 @@ if (isset ($_REQUEST [A_GET]) && !empty ($_REQUEST [A_GET])) {
$doDownload = true;
}
$doCache = false;
if (isset ($_REQUEST [A_CACHE]) && !empty ($_REQUEST [A_CACHE])) {
$doCache = true;
}
// ========================================
function returnError ($msg) {
displayHeadPage ("Gestion des pièces jointes");
@@ -243,58 +259,83 @@ function getArchiveCacheFromSender ($sender) {
$l = jirafeau_get_link ($hash);
if (empty ($l))
continue;
$archives [] = readArchiveFromLink ($l);
// $p = s2p ($hash);
// $lines = file (VAR_FILES . $p . $hash);
// if (!$lines)
// continue;
// $archives [] = readArchiveFromLines ($lines);
$archives [] = readArchiveFromLink ($l, $hash);
}
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) {
global $message;
cleanArchiveCache ();
if (!file_exists (VAR_CACHE))
mkdir (VAR_CACHE, 0755);
$minTime = getArchiveCacheLastUpdate ();
$maxTime = time ()-period2seconds ($period);
$stack = array (VAR_LINKS);
while ( ($d = array_shift ($stack)) && $d != null) {
$dir = scandir ($d);
foreach ($dir as $dirName) {
if (strcmp ($dirName, '.') === 0 || strcmp ($dirName, '..') === 0 ||
preg_match ('/\.tmp/i', "$dirName")) {
while ( ($dirName = array_shift ($stack)) && $dirName != null) {
$list = scandir ($dirName);
foreach ($list as $fileName) {
if (strcmp ($fileName, '.') === 0 || strcmp ($fileName, '..') === 0 ||
preg_match ('/\.tmp/i', "$fileName")) {
continue;
}
if (is_dir ($d . $dirName)) {
if (is_dir ($dirName . $fileName)) {
// Push new found directory.
$stack [] = $d . $dirName . '/';
$stack [] = $dirName . $fileName . '/';
continue;
}
$time = filemtime ($d . $dirName);
$time = filemtime ($dirName . $fileName);
if ($time < $minTime || $time >= $maxTime)
continue;
// Read link informations.
$l = jirafeau_get_link ($dirName);
$l = jirafeau_get_link ($fileName);
if (!count ($l))
continue;
if (!isKazArchive ($l))
continue;
$archiveInfo = readArchiveFromLink ($l);
$archiveInfo = readArchiveFromLink ($l, $fileName);
if (!isset ($archiveInfo [T_SENDER]) || empty ($archiveInfo [T_SENDER]))
continue;
if (!file_exists (VAR_CACHE.$archiveInfo [T_SENDER]))
mkdir (VAR_CACHE.$archiveInfo [T_SENDER], 0755);
touch (VAR_CACHE.$archiveInfo [T_SENDER]."/".$l ['hash']);
touch (VAR_CACHE.$archiveInfo [T_SENDER]."/".$fileName);
}
}
setArchiveCacheLastUpdate ($maxTime);
$message .= "Cache mise &agrave; jour ({$period}).";
}
// ========================================
function readArchiveFromLink ($link) {
function readArchiveFromLink ($link, $linkName) {
$p = s2p ($link ['hash']);
$lines = file (VAR_FILES . $p . $link ['hash']);
if (empty ($lines)) {
@@ -302,9 +343,6 @@ function readArchiveFromLink ($link) {
$message .= "can't read {$linkName}".NL;
return [];
}
// return readArchiveFromLines ($lines);
// }
// function readArchiveFromLines ($lines) {
$archive = [];
$error = false;
foreach ($lines as $line) {
@@ -315,8 +353,6 @@ function readArchiveFromLink ($link) {
case preg_match ("/^\s*time:\s*(\d{4}([:-]\d{2}){5})\s*$/i", $line, $matches):
$archive [T_TIME] = $matches [1];
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):
$archive [T_SENDER] = $matches [1];
break;
@@ -335,11 +371,13 @@ function readArchiveFromLink ($link) {
break;
}
}
global $message, $admin;
if ($error && $admin)
$message .= "readArchiveFromLines <pre>".print_r ($lines, true)."</pre>";
$archiveInfo ['maxtime'] = $link ['time'];
return $error ? [] : $archive;
if ($error)
return [];
$archive ['maxtime'] = $link ['time'];
$archive ['hash'] = $link ['hash'];
$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) {
global $sender, $token, $message, $doLogout;
global $sender, $message;
$link = jirafeau_get_link ($linkName);
//$message .= "ln: ".$linkName." l: "."<pre>".print_r ($link, 1)."</pre> mt: ".getTimeFile ($link ['hash'])."</br>";
if (!count ($link))
return;
if (isKazArchive ($link)) {
// Acrhive
$dirName = $linkName;
$dirLink = $link;
$dirTime = $dirLink ['upload_date'];
$archiveInfo = readArchiveFromLink ($dirLink);
if (! count ($archiveInfo))
$archiveInfo = readArchiveFromLink ($dirLink, $linkName);
if (! count ($archiveInfo)) {
$message .= "Archive introuvable ({$dirName})</br>";
return;
}
if ($sender != $archiveInfo [T_SENDER]) {
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";
return;
}
$fileToDelete = false;
if ($archiveInfo [T_NEWKAZ])
if (isset ($archiveInfo [T_NEWKAZ]) && count ($archiveInfo [T_NEWKAZ]))
foreach ($archiveInfo [T_NEWKAZ] as [$fileName, $cryptKey]) {
$fileLink = jirafeau_get_link ($fileName);
if (! count ($fileLink))
@@ -436,90 +488,21 @@ function deleteAction ($linkName) {
$message .= "l'envoi ".$archiveInfo [T_TIME]." est supprim&eacute;";
if ($fileToDelete)
$message .= " avec<ul>";
if ($archiveInfo [T_NEWKAZ])
if (isset ($archiveInfo [T_NEWKAZ]) && count ($archiveInfo [T_NEWKAZ]))
foreach ($archiveInfo [T_NEWKAZ] as [$fileName, $cryptKey]) {
$fileLink = jirafeau_get_link ($fileName);
if (! count ($fileLink))
continue;
$message .= "<li>".jirafeau_escape ($fileLink ['file_name'])."</li>";
jirafeau_delete_link ($fileName);
deleteLinkAndCache ($fileName, $fileLink ['file_name']);
}
jirafeau_delete_link ($dirName);
$message .= $fileToDelete ? "</ul>" : ".";
deleteLinkAndCache ($dirName, '');
return;
}
$fileName = $linkName;
$fileLink = $link;
$fileTime = $fileLink ['upload_date'];
// XXX
$stack = array (VAR_LINKS);
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;
}
}
}
// only file
deleteLinkAndCache ($linkName, $link ['file_name']);
}
// ========================================
@@ -538,7 +521,7 @@ if ($doUpdate) {
$content = '' . $time . NL;
if (isKazArchive ($link)) {
$archiveInfo = readArchiveFromLink ($l);
$archiveInfo = readArchiveFromLink ($l, $linkName);
if (count ($archiveInfo)) {
foreach ([T_OLD, T_NEWKAZ] as $cat)
if (isset ($archiveInfo [$cat]))
@@ -553,6 +536,16 @@ if ($doUpdate) {
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) {
// check archive exist
@@ -570,7 +563,9 @@ if ($doDownload) {
if ($key && (empty ($cryptKey) || $key != $cryptKey))
returnError (t ('BAD_PSW'));
$archiveInfo = readArchiveFromLink ($link);
$archiveInfo = readArchiveFromLink ($link, $linkName);
if (! count ($archiveInfo))
returnError (t ('FILE_404'));
// check entries
$archiveContent = [];
@@ -672,19 +667,6 @@ if ($doDownload) {
}
$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,))
returnError (E_OPEN_ZIP);
@@ -781,10 +763,8 @@ if (isset ($_REQUEST [A_ACTION])) {
setSenderLang ($sender, $matches [1]);
$message .= "Votre lang &agrave; &eacute;t&eacute; mise &agrave; jour.";
break;
case preg_match ("/^".A_CACHE."(".implode ("|", array_keys ($periodText)).")$/i", $_REQUEST [A_ACTION], $matches):
updateArchiveCacheUpTo ($matches [1]);
$message .= "Cache mise &agrave; jour {$matches [1]}.";
break;
}
}
@@ -796,6 +776,7 @@ displayHeadPage ("Gestion des pièces jointes");
echo str_replace (["___SENDER___", "___ADMIN___", "___DATE___"],
[$sender, ($admin ? " (admin)" : ""), jirafeau_get_datetimefield (time ())],
M_WELCOME);
if ($message)
echo '<div class="message-success">Info : '.$message.'</div>';
echo '<script type="text/javascript">';
@@ -857,7 +838,7 @@ $defaultChecked [isSenderTrack ($sender) ? "on" : "off"] = ' checked="checked"';
$defaultChecked [getSenderPeriod ($sender)] = ' selected="selected"';
$defaultChecked [getSenderLang ($sender)] = ' selected="selected"';
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 '.
'<select name="'.A_ACTION.'" style="width: auto !important;">';
foreach ($modeText as $item => $text)
@@ -866,7 +847,7 @@ echo
'</select> '.
'<button type="submit">'."valider".'</button>'.
'</form>'.
'<form method="post">'.
'<br/><form method="post">'.
'Je veux que Kaz suive tous mes futurs envois: '.
'<input type="hidden" name="'.A_SENDER.'" value="'.$sender.'"/>'.
'<input type="hidden" name="'.A_TOKEN.'" value="'.$token.'"/>';
@@ -875,7 +856,7 @@ foreach ($trackText as $item => $text)
echo
'<button type="submit">'."valider".'</button>'.
'</form>'.
'<form method="post">'.
'<br/><form method="post">'.
'Je veux que mes futurs envois soient accessibles pendant au moins un&middot;e '.
'<select name="'.A_ACTION.'" style="width: auto !important;">';
foreach ($periodText as $item => $text)
@@ -884,7 +865,7 @@ echo
'</select> '.
'<button type="submit">'."valider".'</button>'.
'</form>'.
'<form method="post">'.
'<br/><form method="post">'.
'Je préfère envoyer mes messages en langue '.
'<select name="'.A_ACTION.'" style="width: auto !important;">';
foreach ($langText as $item => $text)
@@ -893,7 +874,7 @@ echo
'</select> '.
'<button type="submit">'."valider".'</button>'.
'</form>'.
'<form method="post">'.
'<br/><form method="post">'.
'Je veux '.
'<input type="hidden" name="'.A_SENDER.'" value="'.$sender.'"/>'.
'<input type="hidden" name="'.A_TOKEN.'" value="'.$token.'"/>'.
@@ -902,17 +883,18 @@ echo
if ($admin) {
echo
'<form method="post">'.
'<br/><form method="post">'.
'Mettre &agrave; jour le cache jusqu\'&agrave; '.
'<input type="hidden" name="'.A_SENDER.'" value="'.$sender.'"/>'.
'<input type="hidden" name="'.A_TOKEN.'" value="'.$token.'"/>'.
'<select name="'.A_ACTION.'" style="width: auto !important;">';
foreach ($periodText as $item => $text)
echo ' <option value="'.A_CACHE.$item.'">'.$text.'</option>';
echo ' <option value="'.A_CACHE.$item.'"'.($defaultChecked [$item] ?? "").'>'.$text.'</option>';
echo
'</select> '.
'<button type="submit">'."valider".'</button>'.
'.</form><br/>';
//href="javascript:ajaxUpdate (\''.$item.'\', \''.$la.'\');"
}
$userSise = 0;
@@ -922,7 +904,7 @@ if ($archives) {
$contentSize = 0;
$archContent = '';
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]))
foreach ($archiveInfo [$cat] as [$linkName, $cryptKey]) {
$link = jirafeau_get_link ($linkName);
@@ -933,15 +915,15 @@ if ($archives) {
$lf = $linkName;
$kf = $link ['key'];
$archContent .=
'<li style="list-style:none; '.$liStyle.'">'.
'<a data-tooltip="voir" href="javascript:getKazFile (\''.$lf.'\', \''.$kf.'\');"> &#128065; </a>'.
'<a data-tooltip="voir le lien" href="javascript:showLink (\''.$lf.'\', \''.$kf.'\');"> &#128279; </a>';
'<li style="list-style:none">'.
'<a data-tooltip="voir le document" href="javascript:getKazFile (\''.$lf.'\', \''.$kf.'\');"> &#128065; </a>'.
'<a data-tooltip="voir le lien du document" href="javascript:showLink (\''.$lf.'\', \''.$kf.'\');"> &#128279; </a>';
// foreach ($periodButton as $item => $bt)
// 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 ['mime_type']).
' '.jirafeau_human_size ($link ['file_size']).')';
' '.jirafeau_human_size ($link ['file_size']).')</span>';
if ($cat == T_NEWKAZ)
$archContent .=
'<a data-tooltip="supprimer" href="javascript:rmFile (\''.$lf.'\');"> &#9850; </a>';
@@ -954,8 +936,8 @@ if ($archives) {
$la = $archiveInfo ['link'] ?? '';
$ka = $archiveInfo ['key'] ?? '';
$archEntry .=
'<a data-tooltip="voir" href="javascript:getKazArchive (\''.$la.'\', \''.$ka.'\');"> &#128065; </a>'.
'<a data-tooltip="voir le lien" href="javascript:showLink (\''.$la.'\', \''.$ka.'\');"> &#128279; </a>';
'<a data-tooltip="t&eacute;l&eacute;charger l\'archive" href="javascript:getKazArchive (\''.$la.'\', \''.$ka.'\');"> &#128065; </a>'.
'<a data-tooltip="voir le lien de l\'archive" href="javascript:showLink (\''.$la.'\', \''.$ka.'\');"> &#128279; </a>';
foreach ($periodButton as $item => $bt)
$archEntry .=
'<a data-tooltip="'.$bt[1].'" href="javascript:ajaxUpdate (\''.$item.'\', \''.$la.'\');"> '.$bt[0].' </a>';
@@ -973,7 +955,7 @@ if ($archives) {
echo
'<span>Votre compte occupe <b>'.jirafeau_human_size ($userSise).'</b>.</span>'.
'<form method="post">'.
'<br/><form method="post">'.
'Je veux me '.
'<input type="hidden" name="'.A_ACTION.'" value="'.T_LOGOUT.'" />'.
'<input type="hidden" name="'.A_SENDER.'" value="'.$sender.'"/>'.
+12 -9
View File
@@ -27,13 +27,13 @@ function s2p($s)
{
$block_size = 8;
$p = '';
for ($i = 0; $i < strlen($s); $i++) {
for ($i = 0; $i < strlen($s ?? ''); $i++) {
$p .= $s[$i];
if (($i + 1) % $block_size === 0) {
$p .= '/';
}
}
if (strlen($s) % $block_size !== 0) {
if (strlen($s ?? '') % $block_size !== 0) {
$p .= '/';
}
return $p;
@@ -66,7 +66,7 @@ function base_16_to_64($num)
$b = '';
$i = 0;
# Convert long hex string to bin.
$size = strlen($num);
$size = strlen($num ?? '');
for ($i = 0; $i < $size; $i++) {
$b .= $hex2bin[hexdec($num[$i])];
}
@@ -130,8 +130,11 @@ function jirafeau_human_size($octets)
// Convert UTC timestamp to a datetime field
function jirafeau_get_datetimefield($timestamp)
{
return '<span class="datetime" data-datetime="' . (new DateTime())->setTimestamp($timestamp)->format('Y-m-d H:i') . '">'
. (new DateTime())->setTimestamp($timestamp)->format('Y-m-d H:i') . ' (GMT)</span>';
if (isset ($timestamp) && !empty ($timestamp))
$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())
@@ -154,7 +157,7 @@ function jirafeau_clean_rm_link($link)
&& count($scan) === 2 // '.' and '..' folders => empty.
&& basename($parse) !== basename(VAR_LINKS)) {
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.
&& basename($parse) !== basename(VAR_FILES)) {
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.
&& basename($parse) !== basename(VAR_ASYNC)) {
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)
{
$iv = '';
while (strlen($iv) < $size) {
while (strlen($iv ?? '') < $size) {
$iv .= $base;
}
return substr($iv, 0, $size);