X-Git-Url: https://git.p6c8.net/jirafeau_mojo42.git/blobdiff_plain/deeb1323362ec6750535865e1e18ca37fe7728fc..39a36cda14d2445dc4dfd66c6650f7211fadd36a:/lib/functions.php?ds=sidebyside diff --git a/lib/functions.php b/lib/functions.php index 5c0c45f..6c9c832 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -403,7 +403,7 @@ jirafeau_upload ($file, $one_time_download, $key, $time, $ip, $crypt, $link_name $handle = fopen ($link_tmp_name, 'w'); fwrite ($handle, $name . NL. $mime_type . NL. $size . NL. $password . NL. $time . - NL . $md5. NL . ($one_time_download ? 'O' : 'R') . NL . date ('U') . + NL . $md5. NL . ($one_time_download ? 'O' : 'R') . NL . time () . NL . $ip . NL. $delete_link_code . NL . ($crypted ? 'C' : 'O')); fclose ($handle); $md5_link = substr(base_16_to_64 (md5_file ($link_tmp_name)), 0, $link_name_length); @@ -730,7 +730,7 @@ jirafeau_admin_clean_async () if (!count ($a)) continue; /* Delete transferts older than 1 hour. */ - if (date ('U') - $a['last_edited'] > 3600) + if (time () - $a['last_edited'] > 3600) { jirafeau_async_delete (basename ($node)); $count++; @@ -830,7 +830,7 @@ jirafeau_async_init ($filename, $type, $one_time, $key, $time, $ip) str_replace (NL, '', trim ($filename)) . NL . str_replace (NL, '', trim ($type)) . NL . $password . NL . $time . NL . ($one_time ? 'O' : 'R') . NL . $ip . NL . - date ('U') . NL . $code . NL); + time () . NL . $code . NL); fclose ($handle); return $ref . NL . $code ; @@ -894,7 +894,7 @@ jirafeau_async_push ($ref, $data, $code, $max_file_size) fwrite ($handle, $a['file_name'] . NL. $a['mime_type'] . NL. $a['key'] . NL . $a['time'] . NL . $a['onetime'] . NL . $a['ip'] . NL . - date ('U') . NL . $code . NL); + time () . NL . $code . NL); fclose ($handle); return $code; } @@ -959,7 +959,7 @@ jirafeau_async_end ($ref, $code, $crypt, $link_name_length) fwrite ($handle, $a['file_name'] . NL . $a['mime_type'] . NL . $size . NL . $a['key'] . NL . $a['time'] . NL . $md5 . NL . $a['onetime'] . NL . - date ('U') . NL . $a['ip'] . NL . $delete_link_code . NL . ($crypted ? 'C' : 'O')); + time () . NL . $a['ip'] . NL . $delete_link_code . NL . ($crypted ? 'C' : 'O')); fclose ($handle); $md5_link = substr(base_16_to_64 (md5_file ($link_tmp_name)), 0, $link_name_length); $l = s2p ("$md5_link"); @@ -1250,7 +1250,7 @@ jirafeau_alias_create ($alias, $destination, $password, $ip) fwrite ($handle, $md5_password . NL . $ip . NL . - date ('U') . NL . + time () . NL . $destination . NL); fclose ($handle); @@ -1297,7 +1297,7 @@ jirafeau_alias_update ($alias, $destination, $password, fwrite ($handle, $p . NL . $ip . NL . - date ('U') . NL . + time () . NL . $destination . NL); fclose ($handle); return 'Ok'; @@ -1359,3 +1359,33 @@ jirafeau_alias_delete ($alias, $password) return 'Ok'; } +/** + * Replace markers in templates. + * + * Available markers have the scheme "###MARKERNAME###". + * + * @param $content string Template text with markers + * @param $htmllinebreaks boolean Convert linebreaks to BR-Tags + * @return Template with replaced markers + */ +function +jirafeau_replace_markers ($content, $htmllinebreaks = false) +{ + $patterns = array( + '/###ORGANISATION###/', + '/###CONTACTPERSON###/', + '/###WEBROOT###/' + ); + $replacements = array( + $GLOBALS['cfg']['organisation'], + $GLOBALS['cfg']['contactperson'], + $GLOBALS['cfg']['web_root'] + ); + $content = preg_replace($patterns, $replacements, $content); + + if (true === $htmllinebreaks) { + $content = nl2br($content); + } + + return $content; +} \ No newline at end of file