- /* Extract key and iv. */
- $ex = explode (".", $k);
- $key = $ex[0];
- $iv = base64_decode($ex[1]);
- /* Init module */
- $m = mcrypt_module_open('rijndael-256', '', 'ofb', '');
- mcrypt_generic_init($m, $key, $iv);
- /* Decrypt file. */
- $r = fopen ($fp_src, 'r');
- $w = fopen ($fp_dst, 'c');
- while (!feof ($r))
- {
- $dec = mdecrypt_generic($m, fread ($r, 1024));
- if (fwrite ($w, $dec) === false)
- return false;
+/**
+ * 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);