',$text);
-
- $text = str_replace('[cid]',$_base_path.'content.php?cid='.$_SESSION['s_cid'],$text);
-
- global $sequence_links;
- if (isset($sequence_links['previous']) && $sequence_links['previous']['url']) {
- $text = str_replace('[pid]', $sequence_links['previous']['url'], $text);
- }
- if (isset($sequence_links['next']) && $sequence_links['next']['url']) {
- $text = str_replace('[nid]', $sequence_links['next']['url'], $text);
- }
- if (isset($sequence_links['resume']) && $sequence_links['resume']['url']) {
- $text = str_replace('[nid]', $sequence_links['resume']['url'], $text);
- }
- if (isset($sequence_links['first']) && $sequence_links['first']['url']) {
- $text = str_replace('[fid]', $sequence_links['first']['url'], $text);
- }
-
- /* contributed by Thomas M. Duffey */
- $html = !$html ? 0 : 1;
- $text = preg_replace("/\[code\]\s*(.*)\s*\[\\/code\]/Usei", "highlight_code(fix_quotes('\\1'), $html)", $text);
-
- return $text;
-}
-
-/* contributed by Thomas M. Duffey */
-function highlight_code($code, $html) {
- // XHTMLize PHP highlight_string output until it gets fixed in PHP
- static $search = array(
- ' ',
- '',
- 'color="');
-
- static $replace = array(
- ' ',
- '',
- 'style="color:');
- if (!$html) {
- $code = str_replace('<', '<', $code);
- $code = str_replace("\r", '', $code);
- }
-
- return str_replace($search, $replace, highlight_string($code, true));
-}
-
-/* contributed by Thomas M. Duffey */
-function fix_quotes($text){
- return str_replace('\\"', '"', $text);
-}
-
-function embed_media($text) {
- if (preg_match("/\[media(\|[0-9]+\|[0-9]+)?\]*/", $text)==0){
- return $text;
- }
-
- $media_matches = Array();
-
- /*
- First, we search though the text for all different kinds of media defined by media tags and store the results in $media_matches.
-
- Then the different replacements for the different media tags are stored in $media_replace.
-
- Lastly, we loop through all $media_matches / $media_replaces. (We choose $media_replace as index because $media_matches is multi-dimensioned.) It is important that for each $media_matches there is a $media_replace with the same index. For each media match we check the width/height, or we use the default value of 425x350. We then replace the height/width/media1/media2 parameter placeholders in $media_replace with the correct ones, before running a str_replace on $text, replacing the given media with its correct replacement.
-
- */
-
- // youtube videos
- preg_match_all("#\[media[0-9a-z\|]*\]http://([a-z0-9\.]*)?youtube.com/watch\?v=([a-z0-9_-]+)\[/media\]#i",$text,$media_matches[1],PREG_SET_ORDER);
- $media_replace[1] = '';
-
- // .mpg
- preg_match_all("#\[media[0-9a-z\|]*\]([.\w\d]+[^\s\"]+).mpg\[/media\]#i",$text,$media_matches[2],PREG_SET_ORDER);
- $media_replace[2] = "";
-
- // .avi
- preg_match_all("#\[media[0-9a-z\|]*\]([.\w\d]+[^\s\"]+).avi\[/media\]#i",$text,$media_matches[3],PREG_SET_ORDER);
- $media_replace[3] = "";
-
- // .wmv
- preg_match_all("#\[media[0-9a-z\|]*\]([.\w\d]+[^\s\"]+).wmv\[/media\]#i",$text,$media_matches[4],PREG_SET_ORDER);
- $media_replace[4] = "";
-
- // .mov
- preg_match_all("#\[media[0-9a-z\|]*\]([.\w\d]+[^\s\"]+).mov\[/media\]#i",$text,$media_matches[5],PREG_SET_ORDER);
- $media_replace[5] = "";
-
- // .swf
- preg_match_all("#\[media[0-9a-z\|]*\]([.\w\d]+[^\s\"]+).swf\[/media\]#i",$text,$media_matches[6],PREG_SET_ORDER);
- $media_replace[6] = "##MEDIA1##.swf";
-
- // .mp3
- preg_match_all("#\[media[0-9a-z\|]*\](.+[^\s\"]+).mp3\[/media\]#i",$text,$media_matches[7],PREG_SET_ORDER);
- $media_replace[7] = "##MEDIA1##.mp3";
-
- // .wav
- preg_match_all("#\[media[0-9a-z\|]*\](.+[^\s\"]+).wav\[/media\]#i",$text,$media_matches[8],PREG_SET_ORDER);
- $media_replace[8] ="##MEDIA1##.wav";
-
- // .ogg
- preg_match_all("#\[media[0-9a-z\|]*\](.+[^\s\"]+).ogg\[/media\]#i",$text,$media_matches[9],PREG_SET_ORDER);
- $media_replace[9] ="##MEDIA1##.ogg";
-
- // .mid
- preg_match_all("#\[media[0-9a-z\|]*\](.+[^\s\"]+).mid\[/media\]#i",$text,$media_matches[10],PREG_SET_ORDER);
- $media_replace[10] ="##MEDIA1##.mid";
-
- $text = preg_replace("#\[media[0-9a-z\|]*\](.+[^\s\"]+).mid\[/media\]#i", "\\1.mid", $text);
-
- // Executing the replace
- for ($i=1;$i<=count($media_replace);$i++){
- foreach($media_matches[$i] as $media)
- {
-
- //find width and height for each matched media
- if (preg_match("/\[media\|([0-9]*)\|([0-9]*)\]*/", $media[0], $matches))
- {
- $width = $matches[1];
- $height = $matches[2];
- }
- else
- {
- $width = 425;
- $height = 350;
- }
-
- //replace media tags with embedded media for each media tag
- $media_input = $media_replace[$i];
- $media_input = str_replace("##WIDTH##","$width",$media_input);
- $media_input = str_replace("##HEIGHT##","$height",$media_input);
- $media_input = str_replace("##MEDIA1##","$media[1]",$media_input);
- $media_input = str_replace("##MEDIA2##","$media[2]",$media_input);
- $text = str_replace($media[0],$media_input,$text);
- }
- }
-
- return $text;
-}
-
-function make_clickable($text) {
- $text = embed_media($text);
-
- // The next 3 preg_replace convert plain text URL to clickable URL.
- // limited conversion. It doesn't cover the case when the stuff in front of the URL is not a word. For example:
- //
http://google.ca
- // "http://google.ca"
- // 1. remove the spaces in [media] tag, otherwise, the next line converts URL inside [media] into tag
- $text = preg_replace("/(\[media\])([\s]*)(.*)(\[\/media\])/", '$1$3$4', $text);
- $text = preg_replace("/(\[media\])(.*)([\s]*)(\[\/media\])/U", '$1$2$4', $text);
- // 2. convert URL
- $text = preg_replace('/(^|[\n ])([\w]*?[\"]*)((?$3', $text);
-
- // convert email address to clickable URL that pops up "send email" interface with the address filled in
- $text = preg_replace('/(?|(.*)<\/a>'
- .'|((((([_a-zA-Z0-9\-]+(\.[_a-zA-Z0-9\-]+)*'.'\@'
- .'[_a-zA-Z0-9\-]+(\.[_a-zA-Z0-9\-]+)*'.'(\.[a-zA-Z]{1,6})+))))))/i',
- "\\5",
- $text);
-
- return $text;
-}
-
-function image_replace($text) {
- /* image urls do not require http:// */
-
- $text = preg_replace("/\[image(\|)?([a-zA-Z0-9\s]*)\]".
- "[\s]*".
- "([a-zA-Z0-9\#\?\/\&\=\:\\\"\'\_\.\-]+)[\s]*".
- "((\[\/image\])|(.*\[\/image\]))/i",
- "",
- $text);
-
- return $text;
-}
-
-function formTR_final_output($text, $nl2br = true) {
- global $_base_path;
-
- $text = str_replace('CONTENT_DIR/', '', $text);
-
- if ($nl2br) {
- return nl2br(image_replace(make_clickable(myCodes(' '.$text, false))));
- }
- return image_replace(make_clickable(myCodes(' '.$text, true)));
-}
-
-/****************************************************************************************/
-/* @See: ./user/search.php & ./index.php */
-function highlight($input, $var) {//$input is the string, $var is the text to be highlighted
- if ($var != "") {
- $xtemp = "";
- $i=0;
- /*
- The following 'if' statement is a check to ensure that the search term is not part of the tag, ''. Words within this string are avoided in case a previously highlighted string is used for the haystack, $input. To avoid any html breaks in the highlighted string, the search word is avoided completely.
- */
- if (strpos('', $var) !== false) {
- return $input;
- }
- while($i';
- $i += strlen($var);
- }
- else {
- $xtemp .= $input{$i};
- $i++;
- }
- }
- $input = $xtemp;
- }
- return $input;
-}
-
-
-/* @See: ./index.php */
-function formTR_content($input, $html = 0, $glossary, $simple = false) {
- global $_base_path, $_config_defaults;
-
- if (!$html) {
- $input = str_replace('<', '<', $input);
- $input = str_replace('<?php', ' $v) {
- $k = urldecode($k);
- $v = str_replace("\n", ' ', $v);
- $v = str_replace("\r", '', $v);
-
- /* escape special characters */
- $k = preg_quote($k);
-
- $k = str_replace('<', '<', $k);
- $k = str_replace('/', '\/', $k);
-
- $original_term = $k;
- $term = $original_term;
-
- $term = '(\s*'.$term.'\s*)';
- $term = str_replace(' ','(( )*\s*)', $term);
-
- $def = htmlspecialchars($v);
- if ($simple) {
- $input = preg_replace
- ("/(\[\?\])$term(\[\/\?\])/i",
- '\\2',
- $input);
- } else {
- $input = preg_replace
- ("/(\[\?\])$term(\[\/\?\])/i",
- '\\2?',
- $input);
- }
- }
- } else if (!$user_glossary) {
- $input = str_replace(array('[?]','[/?]'), '', $input);
- }
-
- $input = str_replace('CONTENT_DIR', '', $input);
-
- if (isset($_config_defaults['latex_server']) && $_config_defaults['latex_server']) {
- // see: http://www.forkosh.com/mimetex.html
- $input = preg_replace('/\[tex\](.*?)\[\/tex\]/sie', "''", $input);
- }
-
- if ($html) {
- $x = formTR_final_output($input, false);
- return $x;
- }
-
- $output = formTR_final_output($input);
-
- $output = '
'.$output.'
';
-
- return $output;
-}
-
-/***********************************************************************
- @See /include/Classes/Message/Message.class.php
- Jacek Materna
-*/
-
-/**
-* Take a code as input and grab its language specific message. Also cache the resulting
-* message. Return the message. Same as get_message but key value in cache is string
-* @access public
-* @param string $codes Message Code to translate - > 'term' field in DB
-* @return string The translated language specific message for code $code
-* @author Jacek Materna
-*/
-function getTranslatedCodeStr($codes) {
-
- /* this is where we want to get the msgs from the database inside a static variable */
- global $_cache_msgs_new;
- static $_msgs_new;
-
- if (!isset($_msgs_new)) {
- if ( !($lang_et = cache(120, 'msgs_new', $_SESSION['lang'])) ) {
- global $db, $_base_path;
-
- $parent = Language::getParentCode($_SESSION['lang']);
-
- /* get $_msgs_new from the DB */
- $sql = 'SELECT * FROM '.TABLE_PREFIX.'language_text WHERE variable="_msgs" AND (language_code="'.$_SESSION['lang'].'" OR language_code="'.$parent.'")';
- $result = @mysql_query($sql, $db);
- $i = 1;
- while ($row = @mysql_fetch_assoc($result)) {
- // do not cache key as a digit (no contstant(), use string)
- $_cache_msgs_new[$row['term']] = str_replace('SITE_URL/', $_base_path, $row['text']);
- if (TR_DEVEL) {
- $_cache_msgs_new[$row['term']] .= ' ('.$row['term'].')';
- }
- }
-
- cache_variable('_cache_msgs_new');
- endcache(true, false);
- }
- $_msgs_new = $_cache_msgs_new;
- }
-
- if (is_array($codes)) {
- /* this is an array with terms to replace */
- $code = array_shift($codes);
-
- $message = $_msgs_new[$code];
- $terms = $codes;
-
- /* replace the tokens with the terms */
- $message = vsprintf($message, $terms);
-
- } else {
- $message = $_msgs_new[$codes];
-
- if ($message == '') {
- /* the language for this msg is missing: */
-
- $sql = 'SELECT * FROM '.TABLE_PREFIX.'language_text WHERE variable="_msgs"';
- $result = @mysql_query($sql, $db);
- $i = 1;
- while ($row = @mysql_fetch_assoc($result)) {
- if (($row['term']) === $codes) {
- $message = '['.$row['term'].']';
- break;
- }
- }
- }
- $code = $codes;
- }
- return $message;
-}
-
function html_get_list($array) {
$list = '';
foreach ($array as $value) {
--
2.17.1