X-Git-Url: https://git.p6c8.net/jirafeau_mojo42.git/blobdiff_plain/b1ae88cfb28f1946b8d3afea9882e352938292b5..0a4f3d86b718987e4c25896a75df0b96947044b0:/lib/functions.php 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