<commit_before><?php
function get_all_combined_html(){
   $html = "";
   $html .= get_combined_stylesheet_html();
   $html .= "\r\n";
   $html .= combined_script_html();
   $html .= "\r\n";
   return $html;
}

function all_combined_html(){
   echo all_comined_html();
}

function get_type(){
     if (! $page)
         $page = get_requested_pagename ();
     $result = "";
     $sql = "SELECT `type` FROM " . tbname ("content") . " WHERE systemname='" . db_escape ($page) . "'  AND language='" . db_escape ($_SESSION ["language"]) . "'";
     $query = db_query ($sql);
     if (db_num_rows ($query) > 0){
         $result = db_fetch_object ($query);
         $result = $result -> type;
         }
     if (empty ($result))
         $result = "page";
     return $result;
    }
function get_parent(){
     if (! $page)
         $page = get_requested_pagename ();
     $result = "";
     $sql = "SELECT `parent` FROM " . tbname ("content") . " WHERE systemname='" . db_escape ($page) . "'  AND language='" . db_escape ($_SESSION ["language"]) . "'";
     $query = db_query ($sql);
     if (db_num_rows ($query) > 0){
         $result = db_fetch_object ($query);
         $result = $result -> parent;
         }
     if (empty ($result))
         $result = null;
     return $result;
    }
function get_custom_data($page = null){
     if (! $page)
         $page = get_requested_pagename ();
    
     $sql = "SELECT `custom_data` FROM " . tbname ("content") . " WHERE systemname='" . db_escape ($page) . "'  AND language='" . db_escape ($_SESSION ["language"]) . "'";
     $query = db_query ($sql);
     if (db_num_rows ($query) > 0){
         $result = db_fetch_object ($query);
         return json_decode ($result -> custom_data, true);
         }
     return null;
    }
function include_jquery(){
     $disabled_on_pages = getconfig ("jquery_disabled_on");
     if ($disabled_on_pages){
         $disabled_on_pages = trim ($disabled_on_pages);
         $disabled_on_pages = explode (";", $disabled_on_pages);
         }else{
         $disabled_on_pages = array ();
         }
    
     if (! in_array (get_requested_pagename (), $disabled_on_pages)){
         ?>

<script type="text/javascript" src="admin/scripts/jquery.min.js"></script>
<?php
         add_hook ("after_jquery_include");
        
         }
    }
function get_access($page = null){
     if (! $page)
         $page = get_requested_pagename ();
     $sql = "SELECT `access` FROM " . tbname ("content") . " WHERE systemname='" . db_escape ($page) . "'  AND language='" . db_escape ($_SESSION ["language"]) . "'";
     $query = db_query ($sql);
     if (db_num_rows ($query) > 0){
         $result = db_fetch_object ($query);
         $access = explode (",", $result -> access);
         return $access;
         }
     return null;
    }
function get_redirection($page = null){
     if (! $page)
         $page = get_requested_pagename ();
     $sql = "SELECT `redirection` FROM " . tbname ("content") . " WHERE systemname='" . db_escape ($page) . "'  AND language='" . db_escape ($_SESSION ["language"]) . "'";
     $query = db_query ($sql);
     if (db_num_rows ($query) > 0){
         $result = db_fetch_object ($query);
         if (! empty ($result -> redirection) and ! is_null ($result -> redirection)){
             return $result -> redirection;
             }
         return null;
         }
     return null;
    }
function get_theme($page = null){
     if (! $page)
         $page = get_requested_pagename ();
     $theme = getconfig ("theme");
     $mobile_theme = getconfig ("mobile_theme");
     if ($mobile_theme and ! empty ($mobile_theme) and is_mobile ())
         $theme = $mobile_theme;
    
     if (is_200 ()){
         $sql = "SELECT `theme` FROM " . tbname ("content") . " WHERE systemname='" . db_escape ($page) . "'  AND language='" . db_escape ($_SESSION ["language"]) . "'";
         $query = db_query ($sql);
         if ($query and db_num_rows ($query) > 0){
             $data = db_fetch_object ($query);
             if (isset ($data -> theme) and ! empty ($data -> theme) and ! is_null ($data -> theme)){
                 $theme = $data -> theme;
                 }
             }
         }
     $theme = apply_filter ($theme, "theme");
     return $theme;
    }
function signature(){
     $signature = get_signature ();
     if (! empty ($signature)){
         echo '<div class="signature">';
         echo htmlspecialchars ($signature);
         echo '</div>';
         }
    }
function get_signature($page = null){
     if (! is_200 ())
         return "";
    
     if (! $page)
         $page = get_requested_pagename ();
    
     if (containsModule ($page))
         return "";
    
     $sql = "SELECT `signature` FROM " . tbname ("content") . " WHERE systemname='" . db_escape ($page) . "'  AND language='" . db_escape ($_SESSION ["language"]) . "'";
     $query = db_query ($sql);
     if (db_num_rows ($query) > 0){
         $data = db_fetch_object ($query);
         return $data -> signature;
         }
    
     return "";
    }
function delete_custom_data($var = null, $page = null){
     if (! $page)
         $page = get_requested_pagename ();
     $data = get_custom_data ($page);
     if (is_null ($data))
         $data = array ();
     // Wenn $var gesetzt ist, nur $var aus custom_data löschen
    if ($var){
         if (isset ($data [$var])){
             unset ($data [$var]);
             }
         } // Wenn $var nicht gesetzt ist, alle Werte von custom_data löschen
    else{
        
         $data = array ();
         }
    
     $json = json_encode ($data);
    
     return db_query ("UPDATE " . tbname ("content") . " SET custom_data = '" . db_escape ($json) . "' WHERE systemname='" . db_escape ($page) . "'");
    }
function set_custom_data($var, $value, $page = null){
     if (! $page)
         $page = get_requested_pagename ();
    
     $data = get_custom_data ($page);
     if (is_null ($data))
         $data = array ();
    
     $data [$var] = $value;
     $json = json_encode ($data);
    
     return db_query ("UPDATE " . tbname ("content") . " SET custom_data = '" . db_escape ($json) . "' WHERE systemname='" . db_escape ($page) . "'");
    }
function language_selection(){
     $query = db_query ("SELECT * FROM " . tbname ("languages") . " ORDER by name");
     echo "<ul class='language_selection'>";
     while ($row = db_fetch_object ($query)){
         $domain = getDomainByLanguage ($row -> language_code);
         if ($domain)
             echo "<li>" . "<a href='http://" . $domain . "'>" . $row -> name . "</a></li>";
         else
             echo "<li>" . "<a href='./?language=" . $row -> language_code . "'>" . $row -> name . "</a></li>";
         }
     echo "</ul>";
    }
function get_category(){
     $current_page = get_page ();
     return categories :: getCategoryById ($current_page ["category"]);
    }
function category(){
     echo get_category ();
    }
function get_body_classes(){
     $str = "";
     if (is_frontpage ()){
         $str .= "home ";
         }
    
     if (is_404 ()){
         $str .= "error404 ";
         }
    
     if (is_403 ()){
         $str .= "error403 ";
         }
    
     if (is_404 () or is_403 ()){
         $str .= "errorPage ";
         }else{
         $str .= "page ";
         }
         
     if(is_mobile()){
       $str .= "mobile ";
     } else {
       $str .= "desktop ";
     }
    
     if (containsModule (get_requested_pagename ())){
         $str .= "containsModule ";
         }
     $str = trim($str);
     return $str;
    }

function body_classes(){
  echo get_body_classes();
}

// Gibt "Diese Seite läuft mit UliCMS" aus
function poweredByUliCMS(){
     translation ("POWERED_BY_ULICMS");
    }

// Einen zufälligen Banner aus der Datenbank ausgeben
function random_banner(){
     $query = db_query ("SELECT * FROM " . tbname ("banner") . " WHERE language='all' OR language='" . db_escape ($_SESSION ["language"]) . "'ORDER BY RAND() LIMIT 1");
     if (db_num_rows ($query) > 0){
         while ($row = db_fetch_object ($query)){
             $type = "gif";
             if (isset ($row -> type)){
                 if (! empty ($row -> type)){
                     $type = $row -> type;
                     }
                 }
             if ($type == "gif"){
                 $title = $row -> name;
                 $link_url = $row -> link_url;
                 $image_url = $row -> image_url;
                 echo "<a href='$link_url' target='_blank'><img src='$image_url' title='$title' alt='$title' border=0></a>";
                 }else if ($type == "html"){
                 echo $row -> html;
                 }
             }
         }
    }
function logo(){
     if (! getconfig ("logo_image")){
         setconfig ("logo_image", "");
         }
     if (! getconfig ("logo_disabled")){
         setconfig ("logo_disabled", "no");
         }
    
     $logo_path = "content/images/" . getconfig ("logo_image");
    
     if (getconfig ("logo_disabled") == "no" and file_exists ($logo_path)){
         echo '<img class="website_logo" src="' . $logo_path . '" alt="' . htmlspecialchars (getconfig ("homepage_title"), ENT_QUOTES, "UTF-8") . '"/>';
         }
    }
function year(){
     echo date ("Y");
    }
function homepage_owner(){
     echo getconfig ("homepage_owner");
    }
function get_homepage_title(){
     $homepage_title = getconfig ("homepage_title_" . $_SESSION ["language"]);
     if (! $homepage_title){
         $homepage_title = getconfig ("homepage_title");
         }
     return htmlspecialchars ($homepage_title, ENT_QUOTES, "UTF-8");
    }
        
    
function homepage_title(){
     echo get_homepage_title ();
    }
$status = check_status ();
function meta_keywords($ipage = null){
     $status = check_status ();
     $ipage = db_escape ($_GET ["seite"]);
     $query = db_query ("SELECT meta_keywords FROM " . tbname ("content") . " WHERE systemname='$ipage' AND language='" . db_escape ($_SESSION ["language"]) . "'");
    
     if (db_num_rows ($query) > 0){
         while ($row = db_fetch_object ($query)){
             if (! empty ($row -> meta_keywords)){
                 return $row -> meta_keywords;
                 }
             }
         }
     $meta_keywords = getconfig ("meta_keywords_" . $_SESSION ["language"]);
     if (! $meta_keywords){
         $meta_keywords = getconfig ("meta_keywords");
         }
    
     return $meta_keywords;
    }
function meta_description($ipage = null){
     $status = check_status ();
     $ipage = db_escape ($_GET ["seite"]);
     $query = db_query ("SELECT meta_description FROM " . tbname ("content") . " WHERE systemname='$ipage' AND language='" . db_escape ($_SESSION ["language"]) . "'", $connection);
     if ($ipage == ""){
         $query = db_query ("SELECT meta_description FROM " . tbname ("content") . " ORDER BY id LIMIT 1", $connection);
         }
     if (db_num_rows ($query) > 0){
         while ($row = db_fetch_object ($query)){
             if (! empty ($row -> meta_description)){
                 return $row -> meta_description;
                 }
             }
         }
     $meta_description = getconfig ("meta_description_" . $_SESSION ["language"]);
     if (! $meta_description){
         $meta_description = getconfig ("meta_description");
         }
    
     return $meta_description;
    }
function get_title($ipage = null, $headline = false){
     $status = check_status ();
     if ($status == "404 Not Found"){
         return TRANSLATION_PAGE_NOT_FOUND;
         }else if ($status == "403 Forbidden"){
         return TRANSLATION_FORBIDDEN;
         }
    
     $ipage = db_escape ($_GET ["seite"]);
     $query = db_query ("SELECT alternate_title, title FROM " . tbname ("content") . " WHERE systemname='$ipage' AND language='" . db_escape ($_SESSION ["language"]) . "'", $connection);
     if ($ipage == ""){
         $query = db_query ("SELECT * FROM " . tbname ("content") . " ORDER BY id LIMIT 1");
         }
     if (db_num_rows ($query) > 0){
         while ($row = db_fetch_object ($query)){
             if ($headline and isset ($row -> alternate_title) and ! empty ($row -> alternate_title)){
                 $title = $row -> alternate_title;
                 }else{
                 $title = $row -> title;
                 }
            
             $title = apply_filter ($title, "title");
             return $title;
             }
         }
    }
function title($ipage = null){
     echo stringHelper :: real_htmlspecialchars (get_title ($ipage));
    }
function get_headline($ipage = null){
     return get_title ($ipage, true);
    }
function headline($ipage = null){
     echo stringHelper :: real_htmlspecialchars (get_headline ($ipage));
    }
function import($ipage){
     $ipage = db_escape ($ipage);
     if ($ipage == ""){
         $query = db_query ("SELECT content FROM " . tbname ("content") . " WHERE language='" . db_escape ($_SESSION ["language"]) . "' ORDER BY id LIMIT 1");
         }else{
         $query = db_query ("SELECT content FROM " . tbname ("content") . " WHERE systemname='$ipage' AND language='" . db_escape ($_SESSION ["language"]) . "'");
         }
    
     if (db_num_rows ($query) == 0){
         return false;
         }else{
         while ($row = db_fetch_object ($query)){
             $row -> content = replaceShortcodesWithModules ($row -> content);
             $row -> content = apply_filter ($row -> content, "content");
             $row -> content = correctHTMLValidationErrors ($row -> content);
             echo $row -> content;
             return true;
             }
         }
    }

// Todo: nicht W3-konformen HTML-Code korrigieren
function correctHTMLValidationErrors($txt){
     if (getconfig ("disable_html_validation")){
         return $txt;
         }
    
     // Ersetze & durch &amp;
    $txt = preg_replace ('/[&](?![A-Za-z]+[;])/', "&amp;", $txt);
    
     // replaced deprecated HTML-Tags
    $txt = str_ireplace ("<center>", "<div style=\"text-align:center\">", $txt);
     $txt = str_ireplace ("</center>", "</div>", $txt);
     $txt = str_ireplace ("<strike>", "<del>", $txt);
     $txt = str_ireplace ("</strike>", "</del>", $txt);
     $txt = str_ireplace ("<s>", "<del>", $txt);
     $txt = str_ireplace ("</s>", "</del>", $txt);
     $txt = str_ireplace ("<tt>", "<code>", $txt);
     $txt = str_ireplace ("</tt>", "</code>", $txt);
     $txt = str_ireplace ("<dir>", "<ul>", $txt);
     $txt = str_ireplace ("</dir>", "</ul>", $txt);
     $txt = str_ireplace ("<acronym>", "<abbr>", $txt);
     $txt = str_ireplace ("</acronym>", "</abbr>", $txt);
    
     return $txt;
    }
function apply_filter($text, $type){
     $modules = getAllModules ();
     for($i = 0; $i < count ($modules); $i ++){
         $module_content_filter_file = getModulePath ($modules [$i]) . $modules [$i] . "_" . $type . "_filter.php";
         if (file_exists ($module_content_filter_file)){
             include_once $module_content_filter_file;
             if (function_exists ($modules [$i] . "_" . $type . "_filter")){
                 $text = call_user_func ($modules [$i] . "_" . $type . "_filter", $text);
                 }
             }
         }
     return $text;
    }
function get_motto(){
     // Existiert ein Motto für diese Sprache? z.B. motto_en
    $motto = getconfig ("motto_" . $_SESSION ["language"]);
    
     // Ansonsten Standard Motto
    if (! $motto){
         $motto = getconfig ("motto");
         }
     return htmlspecialchars ($motto, ENT_QUOTES, "UTF-8");
    }
function motto(){
     echo get_motto ();
    }
function get_frontpage(){
     setLanguageByDomain ();
     if (isset ($_SESSION ["language"])){
         $frontpage = getconfig ("frontpage_" . $_SESSION ["language"]);
         if ($frontpage){
             return $frontpage;
             }
         }
     return getconfig ("frontpage");
    }
function get_requested_pagename(){
     $value = db_escape ($_GET ["seite"]);
     if ($value == ""){
         $value = get_frontpage ();
         }
     return $value;
    }
function is_frontpage(){
     return get_requested_pagename () === get_frontpage ();
    }
function is_200(){
     return check_status () == "200 OK";
    }
function is_404(){
     return check_status () == "404 Not Found";
    }
function is_403(){
     return check_status () == "403 Forbidden";
    }
function buildtree($src_arr, $parent_id = 0, $tree = array()){
     foreach ($src_arr as $idx => $row){
         if ($row ['parent'] == $parent_id){
             foreach ($row as $k => $v)
             $tree [$row ['id']] [$k] = $v;
             unset ($src_arr [$idx]);
             $tree [$row ['id']] ['children'] = buildtree ($src_arr, $row ['id']);
             }
         }
     ksort ($tree);
     return $tree;
    }
function parent_item_contains_current_page($id){
     $retval = false;
     $id = intval ($id);
     $language = $_SESSION ["language"];
     $sql = "SELECT id, systemname, parent FROM " . tbname ("content") . " WHERE language = '$language' AND active = 1 AND `deleted_at` IS NULL";
     $r = db_query ($sql);
    
     $data = array ();
     while ($row = db_fetch_assoc ($r)){
         $data [] = $row;
         }
    
     $tree = buildtree ($data, $id);
     foreach ($tree as $key){
         if ($key ["systemname"] == get_requested_pagename ())
             $retval = true;
         }
     return $retval;
    }
function get_menu($name = "top", $parent = null, $recursive = true){
     $html = "";
     $name = db_escape ($name);
     $language = $_SESSION ["language"];
     $sql = "SELECT id, systemname, access, redirection, title, alternate_title, menu_image FROM " . tbname ("content") . " WHERE menu='$name' AND language = '$language' AND active = 1 AND `deleted_at` IS NULL AND parent ";
    
     if (is_null ($parent)){<commit_msg>feature_minify<commit_after><?php
function get_all_combined_html(){
   $html = "";
   $html .= get_combined_stylesheet_html();
   $html .= "\r\n";
   $html .= combined_script_html();
   $html .= "\r\n";
   return $html;
}

function all_combined_html(){
   echo all_comined_html();
}

function get_type(){
     if (! $page)
         $page = get_requested_pagename ();
     $result = "";
     $sql = "SELECT `type` FROM " . tbname ("content") . " WHERE systemname='" . db_escape ($page) . "'  AND language='" . db_escape ($_SESSION ["language"]) . "'";
     $query = db_query ($sql);
     if (db_num_rows ($query) > 0){
         $result = db_fetch_object ($query);
         $result = $result -> type;
         }
     if (empty ($result))
         $result = "page";
     return $result;
    }
function get_parent(){
     if (! $page)
         $page = get_requested_pagename ();
     $result = "";
     $sql = "SELECT `parent` FROM " . tbname ("content") . " WHERE systemname='" . db_escape ($page) . "'  AND language='" . db_escape ($_SESSION ["language"]) . "'";
     $query = db_query ($sql);
     if (db_num_rows ($query) > 0){
         $result = db_fetch_object ($query);
         $result = $result -> parent;
         }
     if (empty ($result))
         $result = null;
     return $result;
    }
function get_custom_data($page = null){
     if (! $page)
         $page = get_requested_pagename ();
    
     $sql = "SELECT `custom_data` FROM " . tbname ("content") . " WHERE systemname='" . db_escape ($page) . "'  AND language='" . db_escape ($_SESSION ["language"]) . "'";
     $query = db_query ($sql);
     if (db_num_rows ($query) > 0){
         $result = db_fetch_object ($query);
         return json_decode ($result -> custom_data, true);
         }
     return null;
    }
function include_jquery(){
     $disabled_on_pages = getconfig ("jquery_disabled_on");
     if ($disabled_on_pages){
         $disabled_on_pages = trim ($disabled_on_pages);
         $disabled_on_pages = explode (";", $disabled_on_pages);
         }else{
         $disabled_on_pages = array ();
         }
    
     if (! in_array (get_requested_pagename (), $disabled_on_pages)){
         ?>

<script type="text/javascript" src="admin/scripts/jquery.min.js"></script>
<?php
         add_hook ("after_jquery_include");
        
         }
    }
function get_access($page = null){
     if (! $page)
         $page = get_requested_pagename ();
     $sql = "SELECT `access` FROM " . tbname ("content") . " WHERE systemname='" . db_escape ($page) . "'  AND language='" . db_escape ($_SESSION ["language"]) . "'";
     $query = db_query ($sql);
     if (db_num_rows ($query) > 0){
         $result = db_fetch_object ($query);
         $access = explode (",", $result -> access);
         return $access;
         }
     return null;
    }
function get_redirection($page = null){
     if (! $page)
         $page = get_requested_pagename ();
     $sql = "SELECT `redirection` FROM " . tbname ("content") . " WHERE systemname='" . db_escape ($page) . "'  AND language='" . db_escape ($_SESSION ["language"]) . "'";
     $query = db_query ($sql);
     if (db_num_rows ($query) > 0){
         $result = db_fetch_object ($query);
         if (! empty ($result -> redirection) and ! is_null ($result -> redirection)){
             return $result -> redirection;
             }
         return null;
         }
     return null;
    }
function get_theme($page = null){
     if (! $page)
         $page = get_requested_pagename ();
     $theme = getconfig ("theme");
     $mobile_theme = getconfig ("mobile_theme");
     if ($mobile_theme and ! empty ($mobile_theme) and is_mobile ())
         $theme = $mobile_theme;
    
     if (is_200 ()){
         $sql = "SELECT `theme` FROM " . tbname ("content") . " WHERE systemname='" . db_escape ($page) . "'  AND language='" . db_escape ($_SESSION ["language"]) . "'";
         $query = db_query ($sql);
         if ($query and db_num_rows ($query) > 0){
             $data = db_fetch_object ($query);
             if (isset ($data -> theme) and ! empty ($data -> theme) and ! is_null ($data -> theme)){
                 $theme = $data -> theme;
                 }
             }
         }
     $theme = apply_filter ($theme, "theme");
     return $theme;
    }
function signature(){
     $signature = get_signature ();
     if (! empty ($signature)){
         echo '<div class="signature">';
         echo htmlspecialchars ($signature);
         echo '</div>';
         }
    }
function get_signature($page = null){
     if (! is_200 ())
         return "";
    
     if (! $page)
         $page = get_requested_pagename ();
    
     if (containsModule ($page))
         return "";
    
     $sql = "SELECT `signature` FROM " . tbname ("content") . " WHERE systemname='" . db_escape ($page) . "'  AND language='" . db_escape ($_SESSION ["language"]) . "'";
     $query = db_query ($sql);
     if (db_num_rows ($query) > 0){
         $data = db_fetch_object ($query);
         return $data -> signature;
         }
    
     return "";
    }
function delete_custom_data($var = null, $page = null){
     if (! $page)
         $page = get_requested_pagename ();
     $data = get_custom_data ($page);
     if (is_null ($data))
         $data = array ();
     // Wenn $var gesetzt ist, nur $var aus custom_data löschen
    if ($var){
         if (isset ($data [$var])){
             unset ($data [$var]);
             }
         } // Wenn $var nicht gesetzt ist, alle Werte von custom_data löschen
    else{
        
         $data = array ();
         }
    
     $json = json_encode ($data);
    
     return db_query ("UPDATE " . tbname ("content") . " SET custom_data = '" . db_escape ($json) . "' WHERE systemname='" . db_escape ($page) . "'");
    }
function set_custom_data($var, $value, $page = null){
     if (! $page)
         $page = get_requested_pagename ();
    
     $data = get_custom_data ($page);
     if (is_null ($data))
         $data = array ();
    
     $data [$var] = $value;
     $json = json_encode ($data);
    
     return db_query ("UPDATE " . tbname ("content") . " SET custom_data = '" . db_escape ($json) . "' WHERE systemname='" . db_escape ($page) . "'");
    }
function language_selection(){
     $query = db_query ("SELECT * FROM " . tbname ("languages") . " ORDER by name");
     echo "<ul class='language_selection'>";
     while ($row = db_fetch_object ($query)){
         $domain = getDomainByLanguage ($row -> language_code);
         if ($domain)
             echo "<li>" . "<a href='http://" . $domain . "'>" . $row -> name . "</a></li>";
         else
             echo "<li>" . "<a href='./?language=" . $row -> language_code . "'>" . $row -> name . "</a></li>";
         }
     echo "</ul>";
    }
function get_category(){
     $current_page = get_page ();
     return categories :: getCategoryById ($current_page ["category"]);
    }
function category(){
     echo get_category ();
    }
function get_body_classes(){
     $str = "";
     if (is_frontpage ()){
         $str .= "home ";
         }
    
     if (is_404 ()){
         $str .= "error404 ";
         }
    
     if (is_403 ()){
         $str .= "error403 ";
         }
    
     if (is_404 () or is_403 ()){
         $str .= "errorPage ";
         }else{
         $str .= "page ";
         }
         
     if(is_mobile()){
       $str .= "mobile ";
     } else {
       $str .= "desktop ";
     }
    
     if (containsModule (get_requested_pagename ())){
         $str .= "containsModule ";
         }
     $str = trim($str);
     return $str;
    }

function body_classes(){
  echo get_body_classes();
}

// Gibt "Diese Seite läuft mit UliCMS" aus
function poweredByUliCMS(){
     translation ("POWERED_BY_ULICMS");
    }

// Einen zufälligen Banner aus der Datenbank ausgeben
function random_banner(){
     $query = db_query ("SELECT * FROM " . tbname ("banner") . " WHERE language='all' OR language='" . db_escape ($_SESSION ["language"]) . "'ORDER BY RAND() LIMIT 1");
     if (db_num_rows ($query) > 0){
         while ($row = db_fetch_object ($query)){
             $type = "gif";
             if (isset ($row -> type)){
                 if (! empty ($row -> type)){
                     $type = $row -> type;
                     }
                 }
             if ($type == "gif"){
                 $title = $row -> name;
                 $link_url = $row -> link_url;
                 $image_url = $row -> image_url;
                 echo "<a href='$link_url' target='_blank'><img src='$image_url' title='$title' alt='$title' border=0></a>";
                 }else if ($type == "html"){
                 echo $row -> html;
                 }
             }
         }
    }
function logo(){
     if (! getconfig ("logo_image")){
         setconfig ("logo_image", "");
         }
     if (! getconfig ("logo_disabled")){
         setconfig ("logo_disabled", "no");
         }
    
     $logo_path = "content/images/" . getconfig ("logo_image");
    
     if (getconfig ("logo_disabled") == "no" and file_exists ($logo_path)){
         echo '<img class="website_logo" src="' . $logo_path . '" alt="' . htmlspecialchars (getconfig ("homepage_title"), ENT_QUOTES, "UTF-8") . '"/>';
         }
    }
function year(){
     echo date ("Y");
    }
function homepage_owner(){
     echo getconfig ("homepage_owner");
    }
function get_homepage_title(){
     $homepage_title = getconfig ("homepage_title_" . $_SESSION ["language"]);
     if (! $homepage_title){
         $homepage_title = getconfig ("homepage_title");
         }
     return htmlspecialchars ($homepage_title, ENT_QUOTES, "UTF-8");
    }
        
    
function homepage_title(){
     echo get_homepage_title ();
    }
$status = check_status ();
function meta_keywords($ipage = null){
     $status = check_status ();
     $ipage = db_escape ($_GET ["seite"]);
     $query = db_query ("SELECT meta_keywords FROM " . tbname ("content") . " WHERE systemname='$ipage' AND language='" . db_escape ($_SESSION ["language"]) . "'");
    
     if (db_num_rows ($query) > 0){
         while ($row = db_fetch_object ($query)){
             if (! empty ($row -> meta_keywords)){
                 return $row -> meta_keywords;
                 }
             }
         }
     $meta_keywords = getconfig ("meta_keywords_" . $_SESSION ["language"]);
     if (! $meta_keywords){
         $meta_keywords = getconfig ("meta_keywords");
         }
    
     return $meta_keywords;
    }
function meta_description($ipage = null){
     $status = check_status ();
     $ipage = db_escape ($_GET ["seite"]);
     $query = db_query ("SELECT meta_description FROM " . tbname ("content") . " WHERE systemname='$ipage' AND language='" . db_escape ($_SESSION ["language"]) . "'", $connection);
     if ($ipage == ""){
         $query = db_query ("SELECT meta_description FROM " . tbname ("content") . " ORDER BY id LIMIT 1", $connection);
         }
     if (db_num_rows ($query) > 0){
         while ($row = db_fetch_object ($query)){
             if (! empty ($row -> meta_description)){
                 return $row -> meta_description;
                 }
             }
         }
     $meta_description = getconfig ("meta_description_" . $_SESSION ["language"]);
     if (! $meta_description){
         $meta_description = getconfig ("meta_description");
         }
    
     return $meta_description;
    }
function get_title($ipage = null, $headline = false){
     $status = check_status ();
     if ($status == "404 Not Found"){
         return TRANSLATION_PAGE_NOT_FOUND;
         }else if ($status == "403 Forbidden"){
         return TRANSLATION_FORBIDDEN;
         }
    
     $ipage = db_escape ($_GET ["seite"]);
     $query = db_query ("SELECT alternate_title, title FROM " . tbname ("content") . " WHERE systemname='$ipage' AND language='" . db_escape ($_SESSION ["language"]) . "'", $connection);
     if ($ipage == ""){
         $query = db_query ("SELECT * FROM " . tbname ("content") . " ORDER BY id LIMIT 1");
         }
     if (db_num_rows ($query) > 0){
         while ($row = db_fetch_object ($query)){
             if ($headline and isset ($row -> alternate_title) and ! empty ($row -> alternate_title)){
                 $title = $row -> alternate_title;
                 }else{
                 $title = $row -> title;
                 }
            
             $title = apply_filter ($title, "title");
             return $title;
             }
         }
    }
function title($ipage = null){
     echo stringHelper :: real_htmlspecialchars (get_title ($ipage));
    }
function get_headline($ipage = null){
     return get_title ($ipage, true);
    }
function headline($ipage = null){
     echo stringHelper :: real_htmlspecialchars (get_headline ($ipage));
    }
function import($ipage){
     $ipage = db_escape ($ipage);
     if ($ipage == ""){
         $query = db_query ("SELECT content FROM " . tbname ("content") . " WHERE language='" . db_escape ($_SESSION ["language"]) . "' ORDER BY id LIMIT 1");
         }else{
         $query = db_query ("SELECT content FROM " . tbname ("content") . " WHERE systemname='$ipage' AND language='" . db_escape ($_SESSION ["language"]) . "'");
         }
    
     if (db_num_rows ($query) == 0){
         return false;
         }else{
         while ($row = db_fetch_object ($query)){
             $row -> content = replaceShortcodesWithModules ($row -> content);
             $row -> content = apply_filter ($row -> content, "content");
             $row -> content = correctHTMLValidationErrors ($row -> content);
             echo $row -> content;
             return true;
             }
         }
    }

// Todo: nicht W3-konformen HTML-Code korrigieren
function correctHTMLValidationErrors($txt){
     if (getconfig ("disable_html_validation")){
         return $txt;
         }
    
     // Ersetze & durch &amp;
    $txt = preg_replace ('/[&](?![A-Za-z]+[;])/', "&amp;", $txt);
    
     // replaced deprecated HTML-Tags
    $txt = str_ireplace ("<center>", "<div style=\"text-align:center\">", $txt);
     $txt = str_ireplace ("</center>", "</div>", $txt);
     $txt = str_ireplace ("<strike>", "<del>", $txt);
     $txt = str_ireplace ("</strike>", "</del>", $txt);
     $txt = str_ireplace ("<s>", "<del>", $txt);
     $txt = str_ireplace ("</s>", "</del>", $txt);
     $txt = str_ireplace ("<tt>", "<code>", $txt);
     $txt = str_ireplace ("</tt>", "</code>", $txt);
     $txt = str_ireplace ("<dir>", "<ul>", $txt);
     $txt = str_ireplace ("</dir>", "</ul>", $txt);
     $txt = str_ireplace ("<acronym>", "<abbr>", $txt);
     $txt = str_ireplace ("</acronym>", "</abbr>", $txt);
    
     return $txt;
    }
function apply_filter($text, $type){
     $modules = getAllModules ();
     for($i = 0; $i < count ($modules); $i ++){
         $module_content_filter_file = getModulePath ($modules [$i]) . $modules [$i] . "_" . $type . "_filter.php";
         if (file_exists ($module_content_filter_file)){
             include_once $module_content_filter_file;
             if (function_exists ($modules [$i] . "_" . $type . "_filter")){
                 $text = call_user_func ($modules [$i] . "_" . $type . "_filter", $text);
                 }
             }
         }
     return $text;
    }
function get_motto(){
     // Existiert ein Motto für diese Sprache? z.B. motto_en
    $motto = getconfig ("motto_" . $_SESSION ["language"]);
    
     // Ansonsten Standard Motto
    if (! $motto){
         $motto = getconfig ("motto");
         }
     return htmlspecialchars ($motto, ENT_QUOTES, "UTF-8");
    }
function motto(){
     echo get_motto ();
    }
function get_frontpage(){
     setLanguageByDomain ();
     if (isset ($_SESSION ["language"])){
         $frontpage = getconfig ("frontpage_" . $_SESSION ["language"]);
         if ($frontpage){
             return $frontpage;
             }
         }
     return getconfig ("frontpage");
    }
function get_requested_pagename(){
     $value = db_escape ($_GET ["seite"]);
     if ($value == ""){
         $value = get_frontpage ();
         }
     return $value;
    }
function is_frontpage(){
     return get_requested_pagename () === get_frontpage ();
    }
function is_200(){
     return check_status () == "200 OK";
    }
function is_404(){
     return check_status () == "404 Not Found";
    }
function is_403(){
     return check_status () == "403 Forbidden";
    }
function buildtree($src_arr, $parent_id = 0, $tree = array()){
     foreach ($src_arr as $idx => $row){
         if ($row ['parent'] == $parent_id){
             foreach ($row as $k => $v)
             $tree [$row ['id']] [$k] = $v;
             unset ($src_arr [$idx]);
             $tree [$row ['id']] ['children'] = buildtree ($src_arr, $row ['id']);
             }
         }
     ksort ($tree);
     return $tree;
    }
function parent_item_contains_current_page($id){
     $retval = false;
     $id = intval ($id);
     $language = $_SESSION ["language"];
     $sql = "SELECT id, systemname, parent FROM " . tbname ("content") . " WHERE language = '$language' AND active = 1 AND `deleted_at` IS NULL";
     $r = db_query ($sql);
    
     $data = array ();
     while ($row = db_fetch_assoc ($r)){
         $data [] = $row;
         }
    
     $tree = buildtree ($data, $id);
     foreach ($tree as $key){
         if ($key ["systemname"] == get_requested_pagename ())
             $retval = true;
         }
     return $retval;
    }
function get_menu($name = "top", $parent = null, $recursive = true){
     $html = "";
     $name = db_escape ($name);
     $language = $_SESSION ["language"];
     $sql = "SELECT id, systemname, access, redirection, title, alternate_title, menu_image, target FROM " . tbname ("content") . " WHERE menu='$name' AND language = '$language' AND active = 1 AND `deleted_at` IS NULL AND parent ";
    
     if (is_null ($parent)){
{'fraction_non_alphanumeric': 0.17132054334126873, 'fraction_numerical': 0.004089063156420669, 'mean_word_length': 2.1960257787325457, 'pattern_counts': {'":': 0, '<': 93, '<?xml version=': 0, '>': 191, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1511740', 'n_tokens_mistral': 10990, 'n_tokens_neox': 10867, 'n_words': 2766}