function parseLinks($str,$encoded=false) { global $db,$replinkcache; $linkcount = 0; if (!$encoded) $regex = "#<(movie|media|person|news|text|event|termine|link)s?\|(\d+)\|([^>]+)>#"; else $regex = "#<(movie|media|person|news|text|events|termine|links)s?\|(\d+)\|((?:[^&]|&[^g]|&g[^t]|>[^;])+)>#"; return preg_replace_callback($regex,function($m){ global $db,$replinkcache,$linkcount; $type=$m[1];$id=$m[2];$name=$m[3]; if (isset($replinkcache[$type][$id])) return "$name"; //print " [$type#$id] "; $linkcount++; switch ($type) { case 'movie': case 'movies': $movie = new movie($id); $media = $movie->getMedia(); if (!$media) break; $replinkcache[$type][$id]['url'] = $media->link; $replinkcache[$type][$id]['title'] = "Filmdetails $media->title"; $replinkcache['media'][$media->id] = "/$media->metatype/$media->id;$media->asci"; return "$name"; break; case 'media': $media = new media($id); $replinkcache[$type][$id]['url'] = $media->link; $replinkcache[$type][$id]['title'] = "Filmdetails $media->title"; return "$name"; break; case 'person': $person = new person($id); $replinkcache[$type][$id]['url'] = $person->link; $replinkcache[$type][$id]['title'] = "Porträt $person->name"; return "$name"; break; case 'news': $news = new news($id); $replinkcache[$type][$id]['url'] = $news->link; $replinkcache[$type][$id]['title'] = $news->title; return "$name"; break; case 'text': $text = new text($id); $replinkcache[$type][$id]['url'] = $text->link; $replinkcache[$type][$id]['title'] = $text->title; return "$name"; break; case 'events': $event = new event($id); $replinkcache[$type][$id]['url'] = $event->link; $replinkcache[$type][$id]['title'] = $event->title; return "$name"; break; case 'termine': $event = new event($id); $replinkcache[$type][$id]['url'] = $event->link; $replinkcache[$type][$id]['title'] = $event->title; return "$name"; break; case 'links': $event = new link($id); $replinkcache[$type][$id]['url'] = $event->link; $replinkcache[$type][$id]['title'] = $event->title; return "$name"; break; } if (testing) return ''.htmlspecialchars("<$type|$id|$name>").''; else return $name; },$str); } function replaceLink($type,$id,$name) { global $db,$replinkcache,$linkcount; if (isset($replinkcache[$type][$id])) return "$name"; //print " [$type#$id] "; $linkcount++; switch ($type) { case 'movie': case 'movies': $movie = new movie($id); $media = $movie->getMedia(); if (!$media) break; $replinkcache[$type][$id]['url'] = $media->link; $replinkcache[$type][$id]['title'] = "Filmdetails $media->title"; $replinkcache['media'][$media->id] = "/$media->metatype/$media->id;$media->asci"; return "$name"; break; case 'media': $media = new media($id); $replinkcache[$type][$id]['url'] = $media->link; $replinkcache[$type][$id]['title'] = "Filmdetails $media->title"; return "$name"; break; case 'person': $person = new person($id); $replinkcache[$type][$id]['url'] = $person->link; $replinkcache[$type][$id]['title'] = "Porträt $person->name"; return "$name"; break; case 'news': $news = new news($id); $replinkcache[$type][$id]['url'] = $news->link; $replinkcache[$type][$id]['title'] = $news->title; return "$name"; break; case 'text': $text = new text($id); $replinkcache[$type][$id]['url'] = $text->link; $replinkcache[$type][$id]['title'] = $text->title; return "$name"; break; case 'events': $event = new event($id); $replinkcache[$type][$id]['url'] = $event->link; $replinkcache[$type][$id]['title'] = $event->title; return "$name"; break; case 'termine': $event = new event($id); $replinkcache[$type][$id]['url'] = $event->link; $replinkcache[$type][$id]['title'] = $event->title; return "$name"; break; case 'links': $event = new link($id); $replinkcache[$type][$id]['url'] = $event->link; $replinkcache[$type][$id]['title'] = $event->title; return "$name"; break; } if (testing) return ''.htmlspecialchars("<$type|$id|$name>").''; else return $name; } function encode($str) { $str = htmlspecialchars($str); $regex[] = "#&\#(\d+);#i"; $replace[] = "&#$1;"; $regex[] = "#<br>#i"; $replace[] = "
"; $regex[] = "#<b>#i"; $replace[] = ""; $regex[] = "#</b>#i"; $replace[] = ""; $regex[] = "#<i>#i"; $replace[] = ""; $regex[] = "#</i>#i"; $replace[] = ""; $regex[] = "#<H1>#i"; $replace[] = "

"; $regex[] = "#</H1>#i"; $replace[] = "

"; $regex[] = "#<H2>#i"; $replace[] = "

"; $regex[] = "#</H2>#i"; $replace[] = "

"; $regex[] = "#<H3>#i"; $replace[] = "

"; $regex[] = "#</H3>#i"; $replace[] = "

"; $regex[] = "#<H4>#i"; $replace[] = "

"; $regex[] = "#</H4>#i"; $replace[] = "

"; $regex[] = "#<UL>#i"; $replace[] = ""; $regex[] = "#<OL>#i"; $replace[] = "
    "; $regex[] = "#</OL>#i"; $replace[] = "
"; $regex[] = "#<LI>#i"; $replace[] = "
  • "; $regex[] = "#</LI>#i"; $replace[] = "
  • "; $regex[] = "#<DIV class="platz">#i"; $replace[] = "
    "; $regex[] = "#<DIV class="typ">#i"; $replace[] = "
    "; $regex[] = "#<DIV class="preis">#i"; $replace[] = "
    "; $regex[] = "#<DIV class="hint">#i"; $replace[] = "
    "; $regex[] = "#<DIV class="clear">#i"; $replace[] = "
    "; $regex[] = "#</DIV>#i"; $replace[] = "
    "; //$regex[] = "#-#"; //$replace[] = "-"; $regex[] = "#<a href="((?:[^&]|&[^q]|&q[^u]|&qu[^o]|&quo[^t]|"[^;])+)"(?:[^&]|&[^g]|&g[^t]|>[^;])*>((?:[^&]|&[^l]|&l[^t]|<[^;])+)</a>#i"; $replace[] = "$2"; return preg_replace($regex,$replace,$str); } function hsc($str) { $str = htmlspecialchars($str); $regex[] = "#&\#(\d+);#i"; $replace[] = "&#$1;"; return preg_replace($regex,$replace,$str); } function closetag($html){ $html_new = $html; preg_match_all ( "#<([a-z]+)( .*)?(?!/)>#iU", $html, $result1); preg_match_all ( "##iU", $html, $result2); $results_start = $result1[1]; $results_end = $result2[1]; foreach($results_start AS $startag){ if(!in_array($startag, $results_end)){ $html_new = str_replace('<'.$startag.'>', '', $html_new); } } foreach($results_end AS $endtag){ if(!in_array($endtag, $results_start)){ $html_new = str_replace('', '', $html_new); } } return $html_new; } function removeAnkers($str) { $regex = "/<[^|]+\|[^|]+\|([^|>]+)>/"; $replace = '$1'; $str = preg_replace($regex,$replace,$str); return $str; } function googleVerify() { if (isUrl('/index.php')) { print "\n"; // rico print ""; // kmunteanu } } /** * Ternary Operator in Smarty Templates * @param $flag Boolean Input true or false as a value is compared within the template * @param $yes_value String Print this value when the comparision is true * @param $no_value String Print this value when the comparision is NOT true. */ function ternary($original_value='', $compare_to_value='', $yes_value='', $no_value='') { return ($original_value==$compare_to_value)?$yes_value:$no_value; }