// All rights reserved. This script is part of PHPWCMS. The PHPWCMS web content management system is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The GNU General Public License can be found at http://www.gnu.org/copyleft/gpl.html A copy is found in the textfile GPL.txt and important notices to the license from the author is found in LICENSE.txt distributed with these scripts. This script is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. This copyright notice MUST APPEAR in all copies of the script! *************************************************************************************/ // ---------------------------------------------------------------- // obligate check for phpwcms constants if (!defined('PHPWCMS_ROOT')) { die("You Cannot Access This Script Directly, Have a Nice Day."); } // ---------------------------------------------------------------- //specific functions for the frontend function spacer($width=1, $height=1) { //creates a placeholder image (transparent gif) return ''; } function headline(& $head, & $subhead, & $layout) { $c = ''; if($head) { $c .= $layout["content_head_before"]; $c .= html_specialchars($head); $c .= $layout["content_head_after"]; } if($subhead) { $c .= $layout["content_subhead_before"]; $c .= html_specialchars($subhead); $c .= $layout["content_subhead_after"]; } return $c; } //defines multimedia plugin specific values for width or height function plugin_size($mediatype, $player, $width, $height) { switch($mediatype) { case 0: //Video switch($player) { case 0: //Quicktime $width = ($width) ? $width : ""; $height = ($height) ? $height+16 : ""; break; case 1: //RealPlayer $width = ($width) ? $width : ""; $width = ($height) ? $height+36 : ""; break; case 2: //MediaPlayer $width = ($width) ? $width : ""; $width = ($height) ? $height : ""; break; case 3: //Flash $width = ($width) ? $width : ""; $width = ($height) ? $height : ""; break; } break; case 1: //Audio break; case 2: //Flash break; } } function must_filled($c) { //spaceholder for form fields that have to be filled //with some content or has to be marked or like that return intval($c) ? '' : ''; } function add_attribute($baseval, $attribute, $val, $space=" ") { //to add all relevant attributes that contains //values to a string maybe a html tag $attribute = isEmpty(strval($val)) ? '' : $attribute.'="'.$val.'"'; $attribute = ($baseval && !isEmpty($val)) ? $space.$attribute : $attribute; return $attribute; } function add_style_attribute($attribute='', $val='') { //to add all relevant attributes that contains //values to a string maybe a html tag $attribute = isEmpty(strval($val)) ? '' : $attribute.': '.$val.';'; return $attribute; } function html_attribute($attribute='', $val='') { //to return only 1 well formatted attributes and values return isEmpty(strval($val)) ? '' : $attribute.'="'.$val.'"'; } function html_height_attribute($val=0) { //to return only 1 well formatted attributes and values return (intval($val)) ? ' style="height:'.$val.'px;" ' : ''; } function get_body_attributes(& $values) { //return a standard list of standard html body attributes //based on the pagelayout definitions $body_class = ''; $link_class = ''; if(is_array($values)) { if(empty($values["layout_noborder"])) { $body_class .= add_style_attribute(' margin', '0').LF; $body_class .= add_style_attribute(' padding-top', empty($values["layout_border_top"]) ? '0' : intval($values["layout_border_top"]) .'px').LF; $body_class .= add_style_attribute(' padding-bottom', empty($values["layout_border_bottom"]) ? '0' : intval($values["layout_border_bottom"]).'px').LF; $body_class .= add_style_attribute(' padding-left', empty($values["layout_border_left"]) ? '0' : intval($values["layout_border_left"]) .'px').LF; $body_class .= add_style_attribute(' padding-right', empty($values["layout_border_right"]) ? '0' : intval($values["layout_border_right"]) .'px').LF; $body_class .= LF; } if(!empty($values["layout_bgcolor"])) { $body_class .= add_style_attribute(' background-color', $values["layout_bgcolor"]); $body_class .= LF; } if(!empty($values["layout_bgimage"])) { $body_class .= add_style_attribute(' background-image', 'url('.$values["layout_bgimage"].')'); $body_class .= LF; } if(!empty($values["layout_textcolor"])) { $body_class .= add_style_attribute(' color', $values["layout_textcolor"]); $body_class .= LF; } if(!empty($body_class)) { $body_class = ' body {'.LF.$body_class.' }'.LF; } if(!empty($values["layout_linkcolor"])) { $link_class .= ' a, a:link, a:active, a:visited, a:hover { color: '.$values["layout_linkcolor"].'; }'; $link_class .= LF; } if(!empty($values["layout_vcolor"])) { $link_class .= ' a:visited { color: '.$values["layout_vcolor"].'; }'; $link_class .= LF; } if(!empty($values["layout_acolor"])) { $link_class .= ' a:active { color: '.$values["layout_acolor"].'; }'; $link_class .= LF; } if(!empty($body_class) || !empty($link_class)) { $body_class = ' '.LF; } return $body_class; } return ''; } function align_base_layout($value) { //to get the alignment of the base layout table switch($value) { case 1: $align = "center"; break; case 2: $align = "right"; break; default: $align = 0; } return ($align) ? ' align="'.$align.'"' : ''; } function get_colspan($value) { //returns colspan value back to table row if(!isset($value["layout_type"])) $value["layout_type"] = 0; switch($value["layout_type"]) { case 0: $col=3; break; case 1: $col=2; break; case 2: $col=2; break; case 3: $col=0; break; default: $col=3; } if(!empty($value["layout_leftspace_width"])) $col++; if(!empty($value["layout_rightspace_width"])) $col++; return ($col) ? (' colspan="'.$col.'"') : ''; } function colspan_table_row($val, $block, $colspan="", $rowcontent=" ") { //creates a new table row for header or footer or such rows return ($rowcontent) ? "\n".$rowcontent."\n\n" : ''; } function get_table_block($val, $content="", $leftblock="", $rightblock="") { //creates the string with all relevant main block data //$val = $pagelayout array values $mainblock = "\n"; //start row //if 3column or 2column (with left block) if($val["layout_type"]==0 || $val["layout_type"]==1) { $mainblock .= "".$leftblock."\n"; } //if there is a spacer column between left and main block if($val["layout_leftspace_width"]) { $mainblock .= ""; $mainblock .= spacer($val["layout_leftspace_width"]); $mainblock .= "\n"; } $mainblock .= "".$content."\n"; //if there is a spacer column between main block and right column if($val["layout_rightspace_width"]) { $mainblock .= ""; $mainblock .= spacer($val["layout_rightspace_width"]); $mainblock .= "\n"; } //if 3column or 2column (with right block) if($val["layout_type"]==0 || $val["layout_type"]==2) { $mainblock .= "".$rightblock."\n"; } $mainblock .= "\n"; //end row return $mainblock; } function td_attributes($val, $block, $top=1) { //creates a string with all relevant cell attributes like nackground color/image, class $td_attrib = ($top) ? ' valign="top"' : ""; if(!empty($val["layout_".$block."_height"])) { $td_attrib .= html_height_attribute($val["layout_".$block."_height"]); } if(!empty($val["layout_".$block."_width"])) { $td_attrib .= html_attribute(" width", $val["layout_".$block."_width"]); } if(!empty($val["layout_".$block."_bgcolor"])) { $td_attrib .= html_attribute(" bgcolor", $val["layout_".$block."_bgcolor"]); } if(!empty($val["layout_".$block."_bgimage"])) { $td_attrib .= html_attribute(" style", 'background-image:url('.$val["layout_".$block."_bgimage"].')'); } if(!empty($val["layout_".$block."_class"])) { $td_attrib .= html_attribute(" class", $val["layout_".$block."_class"]); } return $td_attrib; } function table_attributes($val, $var_part, $top=1, $tr=false) { //creates a string with all relevant cell attributes like background color/image, class //P.S. it is nearly the same as td_attributes - but it was boring to rewrite code ;-) $td_attrib = ''; if($top) { $td_attrib = ' valign="top"'; } if(!$tr) { $td_attrib .= html_attribute(" border", (!empty($val[$var_part."_border"])) ? $val[$var_part."_border"] : '0'); $td_attrib .= html_attribute(" cellspacing", (!empty($val[$var_part."_cspace"])) ? $val[$var_part."_cspace"] : '0'); $td_attrib .= html_attribute(" cellpadding", (!empty($val[$var_part."_cpad"])) ? $val[$var_part."_cpad"] : '0'); } if(!empty($val[$var_part."_height"])) { $td_attrib .= html_height_attribute($val[$var_part."_height"]); } if(!empty($val[$var_part."_width"])) { $td_attrib .= html_attribute(" width", $val[$var_part."_width"]); } if(!empty($val[$var_part."_bgcolor"])) { $td_attrib .= html_attribute(" bgcolor", $val[$var_part."_bgcolor"]); } if(!empty($val[$var_part."_bgimage"])) { $td_attrib .= html_attribute(" background", $val[$var_part."_bgimage"]); } if(!empty($val[$var_part."_class"])) { $td_attrib .= html_attribute(" class", $val[$var_part."_class"]); } return $td_attrib; } function get_breadcrumb ($start_id, &$struct_array, $key="acat_name") { //returns the breadcrumb path starting with given start_id $data = array(); while ($start_id && isset($struct_array[$start_id])) { $data[$start_id] = $struct_array[$start_id][$key]; $start_id = $struct_array[$start_id]["acat_struct"]; } if(!empty($struct_array[$start_id][$key])) { $data[$start_id] = $struct_array[$start_id][$key]; } return array_reverse($data, 1); } function breadcrumb ($start_id, &$struct_array, $end_id, $spacer=' > ') { //builds the breadcrumb menu based on given values //$link_to = the page on which the breadcrum part links //$root_name = name of the breadcrumb part if empty/false/0 $start_id //$spacer = how should breadcrumb parts be divided $start_id = intval($start_id); $end_id = intval($end_id); $act_id = $start_id; //store actual ID for later comparing $breadcrumb = ''; global $template_default; while ($start_id) { //get the breadcrumb path starting with given start_id if($end_id && $start_id == $end_id) break; $data[$start_id] = $struct_array[$start_id]["acat_name"]; $start_id = $struct_array[$start_id]["acat_struct"]; } $data[$start_id] = $struct_array[$start_id]["acat_name"]; $crumbs_part = array_reverse($data, 1); if(is_array($crumbs_part) && count($crumbs_part)) { foreach($crumbs_part as $key => $value) { $alias = ''; if($struct_array[$key]["acat_hidden"] != 1) { // check if the structure should be unvisible when active if($breadcrumb) { $breadcrumb .= $spacer; } if ($act_id != $key) { if(!$struct_array[$key]["acat_redirect"]) { $breadcrumb .= ''; } else { $redirect = get_redirect_link($struct_array[$key]["acat_redirect"], ' ', ''); $breadcrumb .= ''; } $breadcrumb .= html_specialchars($crumbs_part[$key]).''; } else { if(!$struct_array[$key]["acat_redirect"]) { $breadcrumb .= ''; } else { $redirect = get_redirect_link($struct_array[$key]["acat_redirect"], ' ', ''); $breadcrumb .= ''; } if(!empty($template_default['breadcrumb_active_prefix'])) { $breadcrumb .= $template_default['breadcrumb_active_prefix']; } $breadcrumb .= html_specialchars($crumbs_part[$key]); if(!empty($template_default['breadcrumb_active_suffix'])) { $breadcrumb .= $template_default['breadcrumb_active_suffix']; } $breadcrumb .= ''; } } } } return $breadcrumb; } function get_redirect_link($link='#', $pre='', $after=' ') { // returns the link var and target var if available $link = explode(' ', $link); $l['link'] = empty($link[0]) ? '#' : $link[0]; $l['target'] = empty($link[1]) ? '' : $pre.'target="'.$link[1].'"'.$after; return $l; } function get_struct_data($root_name='', $root_info='') { //returns the complete active and public struct data as array //so it is reusable by many menu functions -> lower db access // first check pre-rendered structure for current user mode $sysvalue_key = 'structure_array_vmode_'.get_user_vmode(); $data = _getConfig($sysvalue_key); if(is_array($data)) { return $data; } global $db; global $indexpage; $data = array(); $data[0] = array( "acat_id" => 0, "acat_name" => $indexpage['acat_name'], "acat_info" => $indexpage['acat_info'], "acat_struct" => 0, "acat_sort" => 0, "acat_hidden" => intval($indexpage['acat_hidden']), "acat_regonly" => intval($indexpage['acat_regonly']), "acat_ssl" => intval($indexpage['acat_ssl']), "acat_template" => intval($indexpage['acat_template']), "acat_alias" => $indexpage['acat_alias'], "acat_topcount" => intval($indexpage['acat_topcount']), "acat_maxlist" => intval($indexpage['acat_maxlist']), "acat_redirect" => $indexpage['acat_redirect'], "acat_order" => intval($indexpage['acat_order']), "acat_timeout" => $indexpage['acat_timeout'], "acat_nosearch" => $indexpage['acat_nosearch'], "acat_nositemap"=> $indexpage['acat_nositemap'], "acat_permit" => !empty($indexpage['acat_permit']) && is_array($indexpage['acat_permit']) ? $indexpage['acat_permit'] : array(), "acat_pagetitle"=> empty($indexpage['acat_pagetitle']) ? '' : $indexpage['acat_pagetitle'], "acat_paginate" => empty($indexpage['acat_paginate']) ? 0 : 1, "acat_overwrite"=> empty($indexpage['acat_overwrite']) ? '' : $indexpage['acat_overwrite'], "acat_archive" => empty($indexpage['acat_archive']) ? 0 : 1, "acat_class" => empty($indexpage['acat_class']) ? '' : $indexpage['acat_class'], "acat_keywords" => empty($indexpage['acat_keywords']) ? '' : $indexpage['acat_keywords'] ); $sql = "SELECT * FROM ".DB_PREPEND."phpwcms_articlecat WHERE "; // VISIBLE_MODE: 0 = frontend (all) mode, 1 = article user mode, 2 = admin user mode if(VISIBLE_MODE != 2) { // for 0 AND 1 $sql .= "acat_aktiv=1 AND acat_public=1 AND "; } $sql .= "acat_trash=0 ORDER BY acat_struct, acat_sort"; if($result = mysql_query($sql, $db)) { while($row = mysql_fetch_assoc($result)) { $data[$row["acat_id"]] = array( "acat_id" => $row["acat_id"], "acat_name" => $row["acat_name"], "acat_info" => $row["acat_info"], "acat_struct" => $row["acat_struct"], "acat_sort" => $row["acat_sort"], "acat_hidden" => $row["acat_hidden"], "acat_regonly" => $row["acat_regonly"], "acat_ssl" => $row["acat_ssl"], "acat_template" => $row["acat_template"], "acat_alias" => $row["acat_alias"], "acat_topcount" => $row["acat_topcount"], "acat_maxlist" => $row["acat_maxlist"], "acat_redirect" => $row["acat_redirect"], "acat_order" => $row["acat_order"], "acat_timeout" => $row["acat_cache"], "acat_nosearch" => $row["acat_nosearch"], "acat_nositemap"=> $row["acat_nositemap"], "acat_permit" => empty($row["acat_permit"]) ? array() : explode(',', $row["acat_permit"]), "acat_pagetitle"=> $row["acat_pagetitle"], "acat_paginate" => $row["acat_paginate"], "acat_overwrite"=> $row["acat_overwrite"], "acat_archive" => $row["acat_archive"], "acat_class" => $row["acat_class"], "acat_keywords" => $row["acat_keywords"] ); } mysql_free_result($result); } // set max_allowed_package to bigger value _dbSetVar('max_allowed_packet', 16*1024*1024, '<'); // store pre-rendered serialized array in database _setConfig($sysvalue_key, $data, 'frontend_render', 1); return $data; } function get_actcat_articles_data($act_cat_id) { //returns the complete active and public article data as array (basic infos only) //so it is reusable by many functions -> lower db access global $content; global $db; $data = array(); if(isset($content['struct'][ $act_cat_id ])) { $ao = get_order_sort($content['struct'][ $act_cat_id ]['acat_order']); } else { return $data; } $as = $content['struct'][ $act_cat_id ]; $as['acat_maxlist'] = intval($as['acat_maxlist']); $sql = "SELECT *, UNIX_TIMESTAMP(article_tstamp) AS article_date, "; $sql .= "UNIX_TIMESTAMP(article_begin) AS article_livedate, "; $sql .= "UNIX_TIMESTAMP(article_end) AS article_killdate "; $sql .= "FROM ".DB_PREPEND."phpwcms_article "; $sql .= "WHERE article_cid=".$act_cat_id; // VISIBLE_MODE: 0 = frontend (all) mode, 1 = article user mode, 2 = admin user mode switch(VISIBLE_MODE) { case 0: $sql .= " AND article_public=1 AND article_aktiv=1"; break; case 1: $sql .= " AND article_uid=".$_SESSION["wcs_user_id"]; break; //case 2: admin mode no additional neccessary } $sql .= ' AND article_deleted=0 AND article_begin < NOW() '; if($content['struct'][ $act_cat_id ]['acat_archive'] == 0) { $sql .= 'AND article_end > NOW() '; } else { $sql .= 'AND IF( article_archive_status=1 , 1 , article_end > NOW() ) '; } $sql .= "ORDER BY ".$ao[2]; if(empty($as['acat_paginate']) && $as['acat_maxlist'] && $as['acat_topcount'] >= $as['acat_maxlist']) { $sql .= ' LIMIT '.$as['acat_maxlist']; } if($result = mysql_query($sql, $db)) { while($row = mysql_fetch_assoc($result)) { $data[$row["article_id"]] = array( "article_id" => $row["article_id"], "article_cid" => $row["article_cid"], "article_title" => $row["article_title"], "article_subtitle" => $row["article_subtitle"], "article_menutitle" => $row["article_menutitle"], "article_keyword" => $row["article_keyword"], "article_summary" => $row["article_summary"], "article_redirect" => $row["article_redirect"], "article_date" => $row["article_date"], "article_username" => $row["article_username"], "article_sort" => $row["article_sort"], "article_notitle" => $row["article_notitle"], "article_created" => $row["article_created"], "article_image" => @unserialize($row["article_image"]), "article_timeout" => $row["article_cache"], "article_nosearch" => $row["article_nosearch"], "article_nositemap" => $row["article_nositemap"], "article_aliasid" => $row["article_aliasid"], "article_headerdata"=> $row["article_headerdata"], "article_morelink" => $row["article_morelink"], "article_begin" => $row["article_begin"], "article_end" => $row["article_end"], "article_alias" => $row["article_alias"], 'article_livedate' => $row["article_livedate"], 'article_killdate' => $row["article_killdate"] ); // now check for article alias ID if($row["article_aliasid"]) { $aid = $row["article_id"]; $alias_sql = "SELECT *, UNIX_TIMESTAMP(article_tstamp) AS article_date, "; $alias_sql .= "UNIX_TIMESTAMP(article_begin) AS article_livedate, "; $alias_sql .= "UNIX_TIMESTAMP(article_end) AS article_killdate "; $alias_sql .= "FROM ".DB_PREPEND."phpwcms_article "; $alias_sql .= "WHERE article_deleted=0 AND article_id=".intval($row["article_aliasid"]); if(!$row["article_headerdata"]) { switch(VISIBLE_MODE) { case 0: $alias_sql .= " AND article_public=1 AND article_aktiv=1"; break; case 1: $alias_sql .= " AND article_uid=".$_SESSION["wcs_user_id"]; break; } $alias_sql .= " AND article_begin < NOW() AND article_end > NOW()"; } $alias_sql .= " AND article_deleted=0 LIMIT 1"; if($alias_result = mysql_query($alias_sql, $db)) { if($alias_row = mysql_fetch_assoc($alias_result)) { $data[$aid]["article_id"] = $alias_row["article_id"]; $data[$aid]["article_alias"] = $alias_row["article_alias"]; // use alias article header data if(!$row["article_headerdata"]) { $data[$aid]["article_title"] = $alias_row["article_title"]; $data[$aid]["article_subtitle"] = $alias_row["article_subtitle"]; $data[$aid]["article_keyword"] = $alias_row["article_keyword"]; $data[$aid]["article_summary"] = $alias_row["article_summary"]; $data[$aid]["article_redirect"] = $alias_row["article_redirect"]; $data[$aid]["article_date"] = $alias_row["article_date"]; $data[$aid]["article_image"] = @unserialize($alias_row["article_image"]); $data[$aid]["article_begin"] = $alias_row["article_begin"]; $data[$aid]["article_end"] = $alias_row["article_end"]; $data[$aid]['article_livedate'] = $alias_row["article_livedate"]; $data[$aid]['article_killdate'] = $alias_row["article_killdate"]; $data[$aid]['article_menutitle'] = $alias_row["article_menutitle"]; } } mysql_free_result($alias_result); } } } mysql_free_result($result); } return $data; } function setArticleSummaryImageData($img) { // used to set correct list image values based on given data //first check if lis_image data is set - will not for all old articles if(!isset($img['list_usesummary'])) { $img['list_usesummary'] = 1; } if($img['list_usesummary'] && !empty($img['hash'])) { $img['list_name'] = $img['name']; $img['list_hash'] = $img['hash']; $img['list_ext'] = $img['ext']; $img['list_id'] = $img['id']; $img['list_caption'] = $img['caption']; $img['list_zoom'] = empty($img['list_zoom']) ? $img['zoom'] : $img['list_zoom']; $img['list_width'] = empty($img['list_width']) ? $img['width'] : $img['list_width']; $img['list_height'] = empty($img['list_height']) ? $img['height'] : $img['list_height']; } return $img; } //menu creating function nav_table_simple_struct(&$struct, $act_cat_id, $link_to="index.php") { //returns a simple table based navigation menu of possible //structure levels based on current structure level $nav_table = "\n\n"; $nav_table .= "\n"; $nav_table .= '\n"; foreach($struct as $key => $value) { if($key != $act_cat_id && _getStructureLevelDisplayStatus($key, $act_cat_id) ) { $nav_table .= "\n"; $nav_table .= "\n"; $nav_table .= '\n"; } } $nav_table .= '
\"\"'; $nav_table .= html_specialchars($struct[$act_cat_id]["acat_name"]); $nav_table .= "
\"\"'; if(!$struct[$key]["acat_redirect"]) { $nav_table .= ''; } $nav_table .= html_specialchars($struct[$key]["acat_name"])."
'; return $nav_table; } function nav_level_row($show_id, $show_home=1) { //returns a simple row based navigation if(strtoupper($show_id) == 'CURRENT') { $act_cat_id = $GLOBALS['content']["cat_id"]; } else { $act_cat_id = intval($show_id); } $nav = ''; if($show_home && $GLOBALS['content']['struct'][$act_cat_id]['acat_hidden'] != 1) { if($GLOBALS['content']["cat_id"] == $act_cat_id) { $before = $GLOBALS['template_default']["nav_row"]["link_before_active"]; $after = $GLOBALS['template_default']["nav_row"]["link_after_active"]; $direct_before = $GLOBALS['template_default']["nav_row"]["link_direct_before_active"]; $direct_after = $GLOBALS['template_default']["nav_row"]["link_direct_after_active"]; } else { $before = $GLOBALS['template_default']["nav_row"]["link_before"]; $after = $GLOBALS['template_default']["nav_row"]["link_after"]; $direct_before = $GLOBALS['template_default']["nav_row"]["link_direct_before"]; $direct_after = $GLOBALS['template_default']["nav_row"]["link_direct_after"]; } $nav .= $before; $nav .= ''.$direct_before; $nav .= html_specialchars($GLOBALS['content']['struct'][$act_cat_id]['acat_name']); $nav .= $direct_after.''.$after; } // check against breadcrumb - active site tree if($GLOBALS['content']['struct'][$GLOBALS['content']["cat_id"]]['acat_struct'] != 0) { $breadcrumb = get_breadcrumb($GLOBALS['content']["cat_id"], $GLOBALS['content']['struct']); } foreach($GLOBALS['content']['struct'] as $key => $value) { if($key != $act_cat_id && _getStructureLevelDisplayStatus($key, $act_cat_id) ) { $class = empty($GLOBALS['content']['struct'][$key]["acat_class"]) ? '' : ' class="'.$GLOBALS['content']['struct'][$key]["acat_class"].'"'; if($nav) { $nav .= $GLOBALS['template_default']["nav_row"]["between"]; } if($GLOBALS['content']["cat_id"] == $key || isset($breadcrumb[$key])) { $before = $GLOBALS['template_default']["nav_row"]["link_before_active"]; $after = $GLOBALS['template_default']["nav_row"]["link_after_active"]; $direct_before = $GLOBALS['template_default']["nav_row"]["link_direct_before_active"]; $direct_after = $GLOBALS['template_default']["nav_row"]["link_direct_after_active"]; } else { $before = $GLOBALS['template_default']["nav_row"]["link_before"]; $after = $GLOBALS['template_default']["nav_row"]["link_after"]; $direct_before = $GLOBALS['template_default']["nav_row"]["link_direct_before"]; $direct_after = $GLOBALS['template_default']["nav_row"]["link_direct_after"]; } $nav .= $before; if(!$GLOBALS['content']['struct'][$key]["acat_redirect"]) { $nav .= ''; } else { $redirect = get_redirect_link($GLOBALS['content']['struct'][$key]["acat_redirect"], ' ', ''); $nav .= ''; } $nav .= $direct_before; $nav .= html_specialchars($GLOBALS['content']['struct'][$key]['acat_name']);; $nav .= $direct_after.''.$after; } } if($nav) { $nav = $GLOBALS['template_default']["nav_row"]["before"].$nav; $nav .= $GLOBALS['template_default']["nav_row"]["after"]; } return $nav; } function nav_table_struct (&$struct, $act_cat_id, $level, $nav_table_struct, $link_to="index.php") { // start with home directory for the listing = top nav structure // 1. Build the recursive tree for given actual article category ID // return the tree starting with given start_id (like breadcrumb) // if the $start_id = 0 then this stops because 0 = top level $level = intval($level); $start_id = $act_cat_id; $data = array(); $c = 0; $total_levels = 0; $level_depth = 0; //$start_level = $level; while ($start_id) { $data[$start_id] = 1; $start_id = $struct[$start_id]["acat_struct"]; $total_levels++; } if(is_array($data) && count($data)) { $temp_tree = array_reverse($data, 1); } else { $temp_tree = false; } foreach($struct as $key => $value) { if($struct[$key]["acat_struct"] == $act_cat_id && $key && (!$struct[$key]["acat_hidden"] || isset($GLOBALS['LEVEL_KEY'][$key]))) { $c++; } } $c = (!$c) ? 1 : 0; //build image src path and real image tag $nav_table_struct["linkimage_over_js"] = get_real_imgsrc($nav_table_struct["linkimage_over"]); $nav_table_struct["linkimage_norm"] = add_linkid($nav_table_struct["linkimage_norm"], '#'); $nav_table_struct["linkimage_over"] = add_linkid($nav_table_struct["linkimage_over"], '#'); $nav_table_struct["linkimage_active"] = add_linkid($nav_table_struct["linkimage_active"], '#'); $lc = count($temp_tree); $ld = false; for($l = 0; $l <= $lc; $l++) { if(isset($GLOBALS['LEVEL_ID'][$l])) { $curStructID = $GLOBALS['LEVEL_ID'][$l]; // now all deeper levels can be deleted if($ld) { unset($temp_tree[$curStructID]); } if(!isset($nav_table_struct['array_struct'][$l])) { $nav_table_struct['array_struct'][$l]["linkimage_over_js"] = $nav_table_struct["linkimage_over_js"]; $nav_table_struct['array_struct'][$l]["linkimage_norm"] = $nav_table_struct["linkimage_norm"]; $nav_table_struct['array_struct'][$l]["linkimage_over"] = $nav_table_struct["linkimage_over"]; $nav_table_struct['array_struct'][$l]["linkimage_active"] = $nav_table_struct["linkimage_active"]; $nav_table_struct['array_struct'][$l]["link_before"] = $nav_table_struct["link_before"]; $nav_table_struct['array_struct'][$l]["link_after"] = $nav_table_struct["link_after"]; $nav_table_struct['array_struct'][$l]["link_active_before"] = $nav_table_struct["link_active_before"]; $nav_table_struct['array_struct'][$l]["link_active_after"] = $nav_table_struct["link_active_after"]; $nav_table_struct['array_struct'][$l]["row_norm_bgcolor"] = $nav_table_struct["row_norm_bgcolor"]; $nav_table_struct['array_struct'][$l]["row_norm_class"] = $nav_table_struct["row_norm_class"]; $nav_table_struct['array_struct'][$l]["row_over_bgcolor"] = $nav_table_struct["row_over_bgcolor"]; $nav_table_struct['array_struct'][$l]["row_active_bgcolor"] = $nav_table_struct["row_active_bgcolor"]; $nav_table_struct['array_struct'][$l]["row_active_class"] = $nav_table_struct["row_active_class"]; $nav_table_struct['array_struct'][$l]["space_celltop"] = $nav_table_struct["space_celltop"]; $nav_table_struct['array_struct'][$l]["space_cellbottom"] = $nav_table_struct["space_cellbottom"]; $nav_table_struct['array_struct'][$l]["cell_height"] = $nav_table_struct["cell_height"]; $nav_table_struct['array_struct'][$l]["cell_class"] = $nav_table_struct["cell_class"]; $nav_table_struct['array_struct'][$l]["cell_active_height"] = $nav_table_struct["cell_active_height"]; $nav_table_struct['array_struct'][$l]["cell_active_class"] = $nav_table_struct["cell_active_class"]; } else { $nav_table_struct['array_struct'][$l]["linkimage_over_js"] = get_real_imgsrc($nav_table_struct['array_struct'][$l]["linkimage_over"]); $nav_table_struct['array_struct'][$l]["linkimage_norm"] = add_linkid($nav_table_struct['array_struct'][$l]["linkimage_norm"], '#'); $nav_table_struct['array_struct'][$l]["linkimage_over"] = add_linkid($nav_table_struct['array_struct'][$l]["linkimage_over"], '#'); $nav_table_struct['array_struct'][$l]["linkimage_active"] = add_linkid($nav_table_struct['array_struct'][$l]["linkimage_active"], '#'); } if($struct[$curStructID]['acat_hidden'] == 1) { unset($temp_tree[$curStructID]); $ld = true; } } } $temp_menu = build_levels ($struct, $level, $temp_tree, $act_cat_id, $nav_table_struct, $level_depth, $c, $link_to); //starts at root level if($temp_menu) { initFrontendJS(); return "\n".$temp_menu.""; } return ''; } function get_real_imgsrc($img='') { // strips real src attribute from image tag if($img) { $img = preg_replace('/.*src=["|\'](.*?)["|\'].*/i', "$1", $img); } return $img; } function add_linkid($img='', $linkid='') { //used to add the link ID for js over functions $img = preg_replace('/( \/>|>)$/', $linkid."$1", $img); return $img; } function build_levels ($struct, $level, $temp_tree, $act_cat_id, $nav_table_struct, $count, $div, $link_to) { // this returns the level structure based on given arrays // it is special for browsing from root levels $nav_table_struct["linkimage_over_js"] = $nav_table_struct['array_struct'][$count]["linkimage_over_js"]; $nav_table_struct["linkimage_norm"] = $nav_table_struct['array_struct'][$count]["linkimage_norm"]; $nav_table_struct["linkimage_over"] = $nav_table_struct['array_struct'][$count]["linkimage_over"]; $nav_table_struct["linkimage_active"] = $nav_table_struct['array_struct'][$count]["linkimage_active"]; $nav_table_struct["row_norm_bgcolor"] = $nav_table_struct['array_struct'][$count]["row_norm_bgcolor"]; $nav_table_struct["row_norm_class"] = $nav_table_struct['array_struct'][$count]["row_norm_class"]; $nav_table_struct["row_over_bgcolor"] = $nav_table_struct['array_struct'][$count]["row_over_bgcolor"]; $nav_table_struct["row_active_bgcolor"] = $nav_table_struct['array_struct'][$count]["row_active_bgcolor"]; $nav_table_struct["row_active_class"] = $nav_table_struct['array_struct'][$count]["row_active_class"]; $nav_table_struct["space_celltop"] = $nav_table_struct['array_struct'][$count]["space_celltop"]; $nav_table_struct["space_cellbottom"] = $nav_table_struct['array_struct'][$count]["space_cellbottom"]; $nav_table_struct["cell_height"] = $nav_table_struct['array_struct'][$count]["cell_height"]; $nav_table_struct["cell_class"] = $nav_table_struct['array_struct'][$count]["cell_class"]; $nav_table_struct["cell_active_height"] = $nav_table_struct['array_struct'][$count]["cell_active_height"]; $nav_table_struct["cell_active_class"] = $nav_table_struct['array_struct'][$count]["cell_active_class"]; $nav_table_struct["link_before"] = $nav_table_struct['array_struct'][$count]["link_before"]; $nav_table_struct["link_after"] = $nav_table_struct['array_struct'][$count]["link_after"]; $nav_table_struct["link_active_before"] = $nav_table_struct['array_struct'][$count]["link_active_before"]; $nav_table_struct["link_active_after"] = $nav_table_struct['array_struct'][$count]["link_active_after"]; $temp_menu = ''; $js = ''; $depth = count($temp_tree)-$div; $current_level = $count; $count++; $depth2 = $depth-$count+2; $right_cell = ''; $left_cell = ''; $cell_top = ''; $cell_bottom = ''; $space_right = ''; $space_cell = ''; $space_row = ''; $cell_height = $nav_table_struct["cell_height"] ? $nav_table_struct["cell_height"] : 1; if($nav_table_struct["space_right"]) { $right_cell = ""; $right_cell .= spacer($nav_table_struct["space_right"], $cell_height)."\n"; $space_right = "".spacer(1, 1).""; } if($nav_table_struct["space_left"]) { $colspan = ($count > 1) ? " colspan=\"".$count."\"" : ""; $left_cell = ""; $left_cell .= spacer($nav_table_struct["space_left"], $cell_height)."\n"; $space_cell = "".spacer(1, 1)."".spacer(1, 1).""; } else { if($count > 1) { $colspan = ($count > 2) ? " colspan=\"".($count-1)."\"" : ""; $left_cell = "".spacer(1, 1)."\n"; $space_cell = "".spacer(1, 1)."".spacer(1, 1).""; } } if($nav_table_struct["space_celltop"]) $cell_top = spacer(1, $nav_table_struct["space_celltop"])."
"; if($nav_table_struct["space_cellbottom"]) $cell_bottom = "
".spacer(1, $nav_table_struct["space_cellbottom"]); $colspan = ($depth2 > 1) ? ' colspan="'.($depth2).'"' : ''; foreach($struct as $key => $value) { if( _getStructureLevelDisplayStatus($key, $level) ) { $link_image_id = "linkid".randpassword(6); $link_name_id = ' name="'.$link_image_id.'" id="'.$link_image_id.'"'; if(!$struct[$key]["acat_redirect"]) { $link = 'index.php?'; if($struct[$key]["acat_alias"]) { $link .= html_specialchars($struct[$key]["acat_alias"]); } else { $link .= 'id='.$key; //',0,0,1,0,0'; } $redirect['target'] = ''; } else { $redirect = get_redirect_link($struct[$key]["acat_redirect"], ' ', ''); $link = $redirect['link']; } $js = ' style="cursor:pointer;cursor:hand;"'; //display:block; $js_act = $js; if($nav_table_struct["js_over_effects"]) { if($redirect['target'] != ' target="_blank"') { $js .= " onclick=\"location.href='".js_singlequote($link)."';return false;\""; } else { $js .= " onclick=\"window.open('".js_singlequote($link)."', 'phpwcmnewwin');return false;\""; } $js_act = $js; $js .= ' onmouseover="'; if($nav_table_struct["linkimage_over_js"]) { $js .= "MM_swapImage('".$link_image_id."','','".$nav_table_struct["linkimage_over_js"]."',1);"; } if($nav_table_struct["row_over_bgcolor"]) $js .= "this.bgColor='".$nav_table_struct["row_over_bgcolor"]."';"; $js .= '" onmouseout="'; if($nav_table_struct["linkimage_over_js"]) $js .= "MM_swapImgRestore();"; if($nav_table_struct["row_norm_bgcolor"]) $js .= "this.bgColor='".$nav_table_struct["row_norm_bgcolor"]."';"; $js .= '"'; } else { $js = ''; } // add structure level based classes if(!empty($struct[$key]["acat_class"])) { $nav_table_struct_temp = $nav_table_struct; $nav_table_struct["row_norm_class"] = trim($nav_table_struct["row_norm_class"].' '.$struct[$key]["acat_class"]); $nav_table_struct["row_active_class"] = trim($nav_table_struct["row_active_class"].' '.$struct[$key]["acat_class"]); $nav_table_struct["row_space_class"] = 'row_space '.$struct[$key]["acat_class"]; } else { $nav_table_struct_temp = NULL; } //spacer row if($nav_table_struct["row_space"]) { $space_row = "\n".$space_cell; $space_row .= "".spacer(1, $nav_table_struct["row_space"]).""; $space_row .= $space_right."\n\n"; $temp_menu .= $space_row; } if(!empty($temp_tree[$key])) { //if($act_cat_id == $key) { //check if inside active tree structure if($act_cat_id == $key || (!empty($nav_table_struct["all_nodes_active"]) && isset($GLOBALS['LEVEL_KEY'][$key]))) { $temp_menu .= "\n".$left_cell; $temp_menu .= "".str_replace('#', $link_name_id, $nav_table_struct["linkimage_active"])."\n"; $temp_menu .= "".$cell_top; $temp_menu .= ''; $temp_menu .= $nav_table_struct["link_active_before"]; $temp_menu .= html_specialchars($struct[$key]["acat_name"]); $temp_menu .= $nav_table_struct["link_active_after"].''; } else { $temp_menu .= "\n".$left_cell; $temp_menu .= "".str_replace('#', $link_name_id, $nav_table_struct["linkimage_norm"])."\n"; $temp_menu .= "".$cell_top; $temp_menu .= ''; $temp_menu .= $nav_table_struct["link_before"]; $temp_menu .= html_specialchars($struct[$key]["acat_name"]); $temp_menu .= $nav_table_struct["link_after"].''; } $temp_menu .= $cell_bottom."\n".$right_cell."\n"; $temp_menu .= build_levels ($struct, $key, $temp_tree, $act_cat_id, $nav_table_struct, $count, $div, $link_to); } else { $temp_menu .= "\n".$left_cell; $temp_menu .= "".str_replace('#', $link_name_id, $nav_table_struct["linkimage_norm"])."\n"; $temp_menu .= "".$cell_top; $temp_menu .= ''; $temp_menu .= $nav_table_struct["link_before"]; $temp_menu .= html_specialchars($struct[$key]["acat_name"]); $temp_menu .= $nav_table_struct["link_after"].''; $temp_menu .= $cell_bottom."\n".$right_cell."\n"; } // reset table structure attributes if($nav_table_struct_temp !== NULL) { $nav_table_struct = $nav_table_struct_temp; } } } if($nav_table_struct["row_space"] && $count == 1) { $temp_menu .= $space_row; } return $temp_menu; } function list_articles_summary($alt=NULL, $topcount=99999, $template='') { // returns an article listing only with headline and summary text // and with an listing of all other available articles of this category global $content; global $template_default; global $_getVar; // alternative way to send article listings if(is_array($alt)) { // first save default value of $content["articles"] $_old_articles = $content["articles"]; $content["articles"] = $alt; $temp_topcount = intval($topcount); if($temp_topcount == 0) { $temp_topcount = $content['struct'][ $content['cat_id'] ]['acat_topcount']; } $template = trim($template); } else { $temp_topcount = $content['struct'][ $content['cat_id'] ]['acat_topcount']; } $max_articles = count($content["articles"]); if(empty($template_default['article_paginate_show'])) { $paginate_show = array('bottom'=>1); } else { $paginate_show = array(); foreach((explode(' ', $template_default['article_paginate_show'])) as $value) { if($value == 'top') { $paginate_show['top'] = 1; } elseif($value == 'bottom') { $paginate_show['bottom'] = 1; } elseif(strpos($value, 'rt') !== false) { $paginate_show['rt'] = str_replace('rt', '', $value); } } if(!count($paginate_show)) { $paginate_show = array('bottom'=>1); } } if($content['struct'][ $content['cat_id'] ]['acat_paginate'] && $content['struct'][ $content['cat_id'] ]['acat_maxlist'] && $max_articles > $content['struct'][ $content['cat_id'] ]['acat_maxlist']) { $paginate = true; $paginate_navi = empty($template_default['article_paginate_navi']) ? '
{PREV:«} {NEXT:»}
' : $template_default['article_paginate_navi']; $max_pages = ceil($max_articles / $content['struct'][ $content['cat_id'] ]['acat_maxlist']); // always do full top article listing because of paginating $temp_topcount = $max_articles+1; if(isset($_getVar['listpage'])) { $page_current = intval($_getVar['listpage']); if($page_current < 1) { $page_current = 1; } elseif($page_current > $max_pages) { $page_current = $max_pages; } } else { $page_current = 1; } $page_next = $page_current; $page_prev = $page_current; if($page_current < $max_pages) { $page_next = $page_current + 1; } if($page_current > 1) { $page_prev = $page_current - 1; } // setting pagination navi $page_article_max = $content['struct'][ $content['cat_id'] ]['acat_maxlist'] * $page_current; $page_article_at = $content['struct'][ $content['cat_id'] ]['acat_maxlist'] * ($page_current - 1); $page_article_at = $page_article_at + 1; if($page_article_max > $max_articles) $page_article_max = $max_articles; $paginate_navi = str_replace('#####', $max_articles, $paginate_navi); $paginate_navi = str_replace('####', $page_article_max, $paginate_navi); $paginate_navi = str_replace('###', $page_article_at, $paginate_navi); $paginate_navi = str_replace('##', $max_pages, $paginate_navi); $paginate_navi = str_replace('#', $page_current, $paginate_navi); $GLOBALS['paginate_temp'] = array('next' => '', 'prev' => '', 'navi' => ''); $paginate_navi = preg_replace_callback('/\{NEXT:(.*?)\}/', create_function('$matches', '$GLOBALS["paginate_temp"]["next"]=$matches[1]; return "{NEXT}";'), $paginate_navi); $paginate_navi = preg_replace_callback('/\{PREV:(.*?)\}/', create_function('$matches', '$GLOBALS["paginate_temp"]["prev"]=$matches[1]; return "{PREV}";'), $paginate_navi); $paginate_navi = preg_replace_callback('/\{NAVI:(.*?)\}/', create_function('$matches', '$GLOBALS["paginate_temp"]["navi"]=$matches[1]; return "{NAVI}";'), $paginate_navi); // next page link if($GLOBALS['paginate_temp']['next'] && $page_current < $max_pages) { $_getVar['listpage'] = $page_next; $page_next_link = '' . $GLOBALS['paginate_temp']['next'] . ''; } else { $page_next_link = $GLOBALS['paginate_temp']['next']; } // previous page link if($GLOBALS['paginate_temp']['prev'] && $page_current > 1) { $_getVar['listpage'] = $page_prev; $page_prev_link = '' . $GLOBALS['paginate_temp']['prev'] . ''; } else { $page_prev_link = $GLOBALS['paginate_temp']['prev']; } // set listpage value to current page $paginate_navi = str_replace('{NEXT}', $page_next_link, $paginate_navi); $paginate_navi = str_replace('{PREV}', $page_prev_link, $paginate_navi); // temporary unset GET listpage setting unset($_getVar['listpage']); if($GLOBALS['paginate_temp']['navi']) { $navi = explode(',', $GLOBALS['paginate_temp']['navi'], 2); $navi[0] = trim($navi[0]); $navi[1] = empty($navi[1]) ? array(0 => ' ') : explode('|', $navi[1]); $navi['spacer'] = empty($navi[1][0]) ? ' ' : $navi[1][0]; //spacer $navi['prefix'] = empty($navi[1][1]) ? '' : $navi[1][1]; //prefix $navi['suffix'] = empty($navi[1][2]) ? '' : $navi[1][2]; //suffix $navi['navi'] = $navi['prefix']; if($navi[0] == '123') { for($i = 1; $i <= $max_pages; $i++) { if($i > 1) $navi['navi'] .= $navi['spacer']; $navi['navi'] .= ($i == $page_current) ? $i : ''.$i.''; } } elseif($navi[0] == '1-3') { for($i = 0; $i < $max_pages; $i++) { $i_start = $i * $content['struct'][ $content['cat_id'] ]['acat_maxlist'] + 1; $i_end = $i_start - 1 + $content['struct'][ $content['cat_id'] ]['acat_maxlist']; if($i_end > $max_articles) $i_end = $max_articles; if($i > 0) $navi['navi'] .= $navi['spacer']; $i_entry = $i_start.'–'.$i_end; $i_page = $i+1; $navi['navi'] .= ($i_page == $page_current) ? $i_entry : ''.$i_entry.''; } } $navi['navi'] .= $navi['suffix']; // replace navi $paginate_navi = str_replace('{NAVI}', $navi['navi'], $paginate_navi); } // reset GET listpage setting $_getVar['listpage'] = $page_current; unset($GLOBALS['paginate_temp']); } else { $paginate = false; $paginate_navi = ''; } $tmpllist = array(); //temporary array for storing templates to minimize load $temp_counter = 0; $space_counter = 0; $listing = $template_default["space_top"]; //start with space at top if(isset($paginate_show['top'])) { $listing .= str_replace('{POS}', 'top', $paginate_navi); } foreach($content["articles"] as $article) { if($paginate && $content['struct'][ $content['cat_id'] ]['acat_maxlist']) { // get page number based on current article counter $page_article = ceil( ($temp_counter + 1) / $content['struct'][ $content['cat_id'] ]['acat_maxlist']); if($page_article > $page_current) { //stop listing break; } elseif($page_article != $page_current) { //no listing - goto next article $temp_counter++; continue; } } $link_data = get_article_morelink($article); $article_link = $link_data[0]; //add available keywords to page wide keyword field $content['all_keywords'] .= $article["article_keyword"].','; if($temp_counter < $temp_topcount) { // as long as the counter is lower than the default "top_count" value // show the complete article summary listing $article["article_image"] = setArticleSummaryImageData($article["article_image"]); if($template) { $article["article_image"]['tmpllist'] = $template; } // build image/image link $article["article_image"]["poplink"] = ''; $thumb_image = false; $thumb_img = ''; $img_thumb_name = ''; $img_thumb_rel = ''; $img_thumb_abs = ''; $img_thumb_width = 0; $img_thumb_height = 0; $img_thumb_ext = 'jpg'; $img_zoom_name = ''; $img_zoom_rel = ''; $img_zoom_abs = ''; $img_zoom_width = 0; $img_zoom_height = 0; if(empty($article["article_image"]["list_caption"])) { $article["article_image"]["list_caption"] = ''; } $caption = getImageCaption($article["article_image"]["list_caption"]); $article["article_image"]["list_caption"] = $caption[0]; // caption text $article["article_image"]["copyright"] = $caption[4]; // copyright information $article["article_image"]["list_alt"] = $caption[1]; // alt text $article["article_image"]["list_title"] = $caption[3]; // title text if(!empty($article["article_image"]["list_hash"])) { $thumb_image = get_cached_image( array( "target_ext" => $article["article_image"]['list_ext'], "image_name" => $article["article_image"]['list_hash'] . '.' . $article["article_image"]['list_ext'], "max_width" => $article["article_image"]['list_width'], "max_height" => $article["article_image"]['list_height'], "thumb_name" => md5($article["article_image"]['list_hash'].$article["article_image"]['list_width'].$article["article_image"]['list_height'].$GLOBALS['phpwcms']["sharpen_level"]) )); if($thumb_image != false) { $img_thumb_name = $thumb_image[0]; $img_thumb_rel = PHPWCMS_IMAGES.$thumb_image[0]; $img_thumb_abs = PHPWCMS_URL.PHPWCMS_IMAGES.$thumb_image[0]; $img_thumb_width = $thumb_image[1]; $img_thumb_height = $thumb_image[2]; $img_thumb_ext = $article["article_image"]['list_ext']; $caption[3] = empty($caption[3]) ? '' : ' title="'.html_specialchars($caption[3]).'"'; $caption[1] = html_specialchars($caption[1]); $thumb_img = ''.$caption[1].''; if($article["article_image"]["list_zoom"]) { $zoominfo = get_cached_image( array( "target_ext" => $article["article_image"]['list_ext'], "image_name" => $article["article_image"]['list_hash'] . '.' . $article["article_image"]['list_ext'], "max_width" => $GLOBALS['phpwcms']["img_prev_width"], "max_height" => $GLOBALS['phpwcms']["img_prev_height"], "thumb_name" => md5($article["article_image"]['list_hash'].$GLOBALS['phpwcms']["img_prev_width"].$GLOBALS['phpwcms']["img_prev_height"].$GLOBALS['phpwcms']["sharpen_level"]) ) ); if($zoominfo != false) { $img_zoom_name = $zoominfo[0]; $img_zoom_rel = PHPWCMS_IMAGES.$zoominfo[0]; $img_zoom_abs = PHPWCMS_URL.PHPWCMS_IMAGES.$zoominfo[0]; $img_zoom_width = $zoominfo[1]; $img_zoom_height = $zoominfo[2]; $article["article_image"]["poplink"] = 'image_zoom.php?'.getClickZoomImageParameter($zoominfo[0].'?'.$zoominfo[3]); if(!empty($caption[2][0])) { $open_link = $caption[2][0]; $return_false = ''; } else { $open_link = $article["article_image"]["poplink"]; $return_false = 'return false;'; } if(empty($article["article_image"]["list_lightbox"]) && !empty($caption[2][0])) { initFrontendJS(); $article["article_image"]["poplink"] = ''; } else { // lightbox initSlimbox(); $article["article_image"]["poplink"] = ''; } } unset($caption); } } else { $article["article_image"]["list_id"] = 0; $article["article_image"]["list_hash"] = ''; } // set default template if(empty($article["article_image"]['tmpllist']) || $article["article_image"]['tmpllist'] == 'default') { $article["article_image"]['tmpllist'] = 'default'; if(empty($tmpllist['default'])) { $tmpllist['default'] = file_get_contents(PHPWCMS_TEMPLATE.'inc_default/article_summary_list.tmpl'); } } // try to read the template files // 1. try to check if template was read if(!isset($tmpllist[ $article["article_image"]['tmpllist'] ])) { $tmpllist[ $article["article_image"]['tmpllist'] ] = @file_get_contents(PHPWCMS_TEMPLATE.'inc_cntpart/articlesummary/list/'.$article["article_image"]['tmpllist']); } if($tmpllist[ $article["article_image"]['tmpllist'] ]) { // set frontend edit link $tmpl = getFrontendEditLink('summary', $article['article_id']); //rendering $tmpl .= $tmpllist[ $article["article_image"]['tmpllist'] ]; $tmpl = render_cnt_template($tmpl, 'TITLE', empty($article['article_notitle']) ? html_specialchars($article["article_title"]) : '' ); $tmpl = render_cnt_template($tmpl, 'SUB', html_specialchars($article["article_subtitle"])); // replace thumbnail and zoom image information $tmpl = str_replace( array( '{THUMB_NAME}', '{THUMB_REL}', '{THUMB_ABS}', '{THUMB_WIDTH}', '{THUMB_HEIGHT}', '{IMAGE_NAME}', '{IMAGE_REL}', '{IMAGE_ABS}', '{IMAGE_WIDTH}', '{IMAGE_HEIGHT}', '{IMAGE_ID}', '{IMAGE_HASH}', '{IMAGE_EXT}' ), array( $img_thumb_name, $img_thumb_rel, $img_thumb_abs, $img_thumb_width, $img_thumb_height, $img_zoom_name, $img_zoom_rel, $img_zoom_abs, $img_zoom_width, $img_zoom_height, $article["article_image"]["list_id"], $article["article_image"]["list_hash"], $img_thumb_ext ), $tmpl ); if( preg_match('/\{SUMMARY:(\d+)\}/', $tmpl, $matches) ) { if(empty($article['article_image']['list_maxwords'])) { $article['article_image']['list_maxwords'] = intval($matches[1]); } $tmpl = preg_replace('/\{SUMMARY:\d+\}/', '{SUMMARY}', $tmpl); } if(strpos($article["article_summary"], '-//-')) { $article["article_summary"] = explode('-//-', $article["article_summary"]); $article['article_image']['list_maxwords_temp'] = count(preg_split("/[\s,]+/", $article["article_summary"][0], -1, PREG_SPLIT_NO_EMPTY)); if(empty($article['article_image']['list_maxwords']) || $article['article_image']['list_maxwords_temp'] < $article['article_image']['list_maxwords']) { $article['article_image']['list_maxwords'] = $article['article_image']['list_maxwords_temp']; $article["article_summary"] = trim($article["article_summary"][0]); } else { $article["article_summary"] = implode(' ', $article["article_summary"]); } } $tmpl = render_cnt_template($tmpl, 'SUMMARY', empty($article['article_image']['list_maxwords']) ? $article["article_summary"] : getCleanSubString($article["article_summary"], $article['article_image']['list_maxwords'], $template_default['ellipse_sign'], 'word', true)); $tmpl = render_cnt_template($tmpl, 'IMAGE', $thumb_img); $tmpl = render_cnt_template($tmpl, 'ZOOMIMAGE', $article["article_image"]["poplink"]); $tmpl = render_cnt_template($tmpl, 'CAPTION', nl2br(html_specialchars($article["article_image"]["list_caption"]))); $tmpl = render_cnt_template($tmpl, 'ALT', html_specialchars($article["article_image"]["list_alt"])); $tmpl = render_cnt_template($tmpl, 'IMAGE_TITLE', html_specialchars($article["article_image"]["list_title"])); $tmpl = render_cnt_template($tmpl, 'COPYRIGHT', html_specialchars($article["article_image"]["copyright"])); $tmpl = render_cnt_template($tmpl, 'ARTICLELINK', $article["article_morelink"] ? $article_link : ''); $tmpl = render_cnt_template($tmpl, 'EDITOR', html_specialchars($article["article_username"])); $tmpl = render_cnt_template($tmpl, 'ARTICLEID', $article["article_id"]); $tmpl = render_cnt_template($tmpl, 'MORE', $article["article_morelink"] ? $template_default["top_readmore_link"] : ''); $tmpl = render_cnt_template($tmpl, 'TARGET', ($article["article_morelink"] && $link_data[1]) ? ' target="'.$link_data[1].'"' : ''); $tmpl = render_cnt_template($tmpl, 'BEFORE', ''); $tmpl = render_cnt_template($tmpl, 'AFTER', ''); $tmpl = render_cnt_date($tmpl, $article["article_date"], $article["article_livedate"], $article["article_killdate"] ); if($space_counter) { $tmpl = render_cnt_template($tmpl, 'SPACE', ''); } else { $tmpl = render_cnt_template($tmpl, 'SPACE', ''); } $listing .= $tmpl; $article["article_image"]['tmpllist'] = 1; } else { $article["article_image"]['tmpllist'] = 0; } } else { // if "top_count" value is equal or larger // show only the article headline listing if($temp_counter && $temp_counter == $temp_topcount) { $listing .= $template_default["space_aftertop_text"]; } elseif ($temp_counter) { $listing .= $template_default["space_between_list"]; } $listing .= $template_default["list_headline_before"]; // set frontend edit link $listing .= getFrontendEditLink('article', $article['article_id']); $listing .= getFrontendEditLink('summary', $article['article_id']); $listing .= ''; $listing .= $template_default["list_startimage"]; $listing .= html_specialchars($article["article_title"]); $listing .= ''.$template_default["list_headline_after"]; } $temp_counter++; $space_counter++; } if(isset($paginate_show['bottom'])) { $listing .= str_replace('{POS}', 'bottom', $paginate_navi); } if(!empty($paginate_show['rt'])) { $content['globalRT'][ $paginate_show['rt'] ] = $paginate_navi; } // restore original articles if(isset($_old_articles)) { $content["articles"] = $_old_articles; } $listing .= $template_default["space_bottom"]; //ends with space at bottom return $listing; } function get_html_part($value, $class="", $link="", $span_or_div=1) { // returns a content part for html output like // html if($value) { $html_tag = ($span_or_div) ? 'span' : 'div'; $html_part = ($link) ? ''.html_specialchars($value).'' : html_specialchars($value); if($class) { $html_part = '<'.$html_tag.' class="'.$class.'">'.$html_part; } else { $html_part = '<'.$html_tag.'>'.$html_part; } return $html_part.''; } else { return ''; } } function span_class($value, $class) { return !empty($class) ? ''.$value.'' : $value; } function div_class($value, $class, $tag='div') { return !empty($class) ? '<'.$tag.' class="'.$class.'">'.$value.'' : $value; } function get_class_attrib($class) { return !empty($class) ? ' class="'.$class.'"' : ''; } function html_parser($string) { // parse the $string and replace all possible // values with $replace if(trim($string) == '') { return $string; } $string = render_bbcode_basics($string, ''); // page TOP link $search[0] = '/\[TOP\](.*?)\[\/TOP\]/is'; $replace[0] = '$1'; // internal Link to article ID $search[1] = '/\[ID (\d+)\](.*?)\[\/ID\]/s'; $replace[1] = '$2'; // external Link (string) $search[2] = '/\[EXT (.*?)\](.*?)\[\/EXT\]/s'; $replace[2] = '$2'; // internal Link (string) $search[3] = '/\[INT (.*?)\](.*?)\[\/INT\]/s'; $replace[3] = '$2'; // random GIF Image $search[4] = '/\{RANDOM_GIF:(.*?)\}/'; $replace[4] = ''; // random JPEG Image $search[5] = '/\{RANDOM_JPEG:(.*?)\}/'; $replace[5] = ''; // random PNG Image $search[6] = '/\{RANDOM_PNG:(.*?)\}/'; $replace[6] = ''; // insert non db image standard $search[7] = '/\{IMAGE:(.*?)\}/'; $replace[7] = ''; // insert non db image left $search[8] = '/\{IMAGE_LEFT:(.*?)\}/'; $replace[8] = ''; // insert non db image right $search[9] = '/\{IMAGE_RIGHT:(.*?)\}/'; $replace[9] = ''; // insert non db image center $search[10] = '/\{IMAGE_CENTER:(.*?)\}/'; $replace[10] = '
'; // insert non db image right $search[11] = '/\{SPACER:(\d+)x(\d+)\}/'; $replace[11] = ''; // RSS feed link $search[13] = '/\[RSS (.*?)\](.*?)\[\/RSS\]/s'; $replace[13] = '$2'; // back Link (string) $search[14] = '/\[BACK\](.*?)\[\/BACK\]/i'; $replace[14] = '$1'; // random Image Tag $search[15] = '/\{RANDOM:(.*?)\}/e'; $replace[15] = 'get_random_image_tag("$1");'; // span or div style $search[16] = '/\[(span|div)_style:(.*?)\](.*?)\[\/style\]/s'; $replace[16] = '<$1 style="$2">$3'; // span or div class $search[17] = '/\[(span|div)_class:(.*?)\](.*?)\[\/class\]/s'; $replace[17] = '<$1 class="$2">$3'; // anchor link $search[22] = '/\{A:(.*?)\}/is'; $replace[22] = ''; // this parses an E-Mail Link without subject (by Florian, 21-11-2003) $search[23] = '/\[E{0,1}MAIL (.*?)\](.*?)\[\/E{0,1}MAIL\]/is'; $replace[23] = '$2'; // this tags out a Mailaddress with an predifined subject (by Florian, 21-11-2003) $search[24] = '/\[MAILSUB (.*?) (.*?)\](.*?)\[\/MAILSUB\]/is'; $replace[24] = '$3'; $search[26] = '/\
/i'; $replace[26] = '
'; // create "make bookmark" javascript code $search[27] = '/\[BOOKMARK\s{0,}(.*)\](.*?)\[\/BOOKMARK\]/is'; $replace[27] = '$2'; // ABBreviation $search[28] = '/\[abbr (.*?)\](.*?)\[\/abbr\]/is'; $replace[28] = '$2'; $search[29] = '/\[dfn (.*?)\](.*?)\[\/dfn\]/is'; $replace[29] = '$2'; $search[34] = '/\[blockquote (.*?)\](.*?)\[\/blockquote\]/is'; $replace[34] = '
$2
'; $search[35] = '/\[acronym (.*?)\](.*?)\[\/acronym\]/is'; $replace[35] = '$2'; $search[36] = '/\[ID (.*?)\](.*?)\[\/ID\]/s'; $replace[36] = '$2'; $search[49] = '/\[E{0,1}MAIL\](.*?)\[\/E{0,1}MAIL\]/is'; $replace[49] = '$1'; $string = preg_replace($search, $replace, $string); $string = str_replace( array( '\'', '&quot;', '-//-' ), array( ''', '"', ' ' ), $string ); return $string; } function include_ext_php($inc_file, $t=0) { // includes an external PHP script file and returns // the result as string from buffered include content //check if this is a local file if(!$t && is_file($inc_file)) { $this_path = str_replace("\\", '/', dirname(realpath($inc_file))); $this_path = preg_replace('/\/$/', '', $this_path); $root_path = str_replace("\\", '/', realpath(PHPWCMS_ROOT)); $root_path = preg_replace('/\/$/', '', $root_path); if(strpos($this_path, $root_path) === 0) $t = 1; } elseif(!$t && !empty($GLOBALS['phpwcms']['allow_remote_URL'])) { //if remote URL is allowed in conf.inc.php $t = 1; } if(!$t) { return ''; } ob_start(); @include($inc_file); return ob_get_clean();; } function international_date_format($language="EN", $format="Y/m/d", $date_now=0) { // formats the given date // for the specific language // use the normal date format options if(!$format) { $format = "Y/m/d"; } if(!intval($date_now)) { $date_now = time(); } if($language == "EN" || !$language) { return date($format, $date_now); } else { $lang_include = PHPWCMS_ROOT.'/include/inc_lang/date/'.substr(strtolower($language), 0, 2).'.date.lang.php'; if(is_file($lang_include)) { include($lang_include); $date_format_function = array ( "a" => 1, "A" => 1, "B" => 1, "d" => 1, "g" => 1, "G" => 1, "h" => 1, "H" => 1, "i" => 1, "I" => 1, "j" => 1, "m" => 1, "n" => 1, "s" => 1, "t" => 1, "T" => 1, "U" => 1, "w" => 1, "Y" => 1, "y" => 1, "z" => 1, "Z" => 1, "D" => 0, "F" => 0, "l" => 0, "M" => 0, "S" => 0 ); $str_length = strlen($format); $date = ""; for($i = 0; $i < $str_length; $i++) $date_format[$i] = substr($format, $i, 1); foreach($date_format as $key => $value) { if(isset($date_format_function[$value])) { if($date_format_function[$value]) { $date .= date($value, $date_now); } else{ switch($value) { case "D": $date .= $weekday_short[ intval(date("w", $date_now)) ]; break; //short weekday name case "l": $date .= $weekday_long[ intval(date("w", $date_now)) ]; break; //long weekday name case "F": $date .= $month_long[ intval(date("n", $date_now)) ]; break; //long month name case "M": $date .= $month_short[ intval(date("n", $date_now)) ]; break; //long month name case "S": $date .= ""; break; } } } else { $date .= $value; } } } else { $date = date($format, $date_now); } } return $date; } function get_random_image_tag($path) { // returns an random image from the give path // it looks for image of following type: gif, jpg, jpeg, png // {RANDOM:path} willl return // {RANDOM:SRC:path} willl return absolute URI PHPWCMS_URL/path/rand_image $imgArray = array(); $path = trim($path); if(strtoupper(substr($path, 0, 4)) == 'SRC:') { $tag = false; $path = trim(substr($path, 4)); } else { $tag = true; } $path = trim($path, '/'); $imgpath = PHPWCMS_ROOT . '/' . $path . '/'; $imageinfo = false; if(is_dir($imgpath)) { $handle = opendir( $imgpath ); while($file = readdir( $handle )) { if( $file{0} != '.' && preg_match('/(\.jpg|\.jpeg|\.gif|\.png)$/i', $file)) { $imgArray[] = $file; } } closedir( $handle ); } if(count($imgArray) && ($imageinfo = is_random_image($imgArray, $imgpath))) { if($tag) { return ''.html_specialchars($imageinfo[ $value) { if( _getStructureLevelDisplayStatus($key, $struct_id) ) { $level_entry[$key] = $value; } } } return $level_entry; } function get_active_categories($struct, $act_struct_id) { // returns an array with all active categories/structure levels $which_cat_array = array(); $which_category = $act_struct_id; while($which_category) { $which_cat_array[$which_category] = 1; $which_category = $GLOBALS['content']["struct"][$which_category]["acat_struct"]; } return $which_cat_array; } function css_level_list(&$struct, $struct_path, $level, $parent_level_name='', $parent_level=1, $class='') { // returns list
of the current structure level // if $parent_level=1 the first list entry will be the parent level // $parent_level=0 - only the list of all levels in this structure // if $parent_leve_name != "" then it uses the given string // predefined class for this menu is "list_level" if(!trim($class)) { $class = 'list_level'; } $parent_level_name = trim($parent_level_name); $level = intval($level); $parent_level = intval($parent_level); $activated = 0; $css_list = ''; //returns the complete level of NON hidden categories $level_struct = return_struct_level($struct, $level); $breadcrumb = get_breadcrumb(key($struct_path), $struct); foreach($level_struct as $key => $value) { if(!$level_struct[$key]["acat_redirect"]) { $link = 'index.php?'; if($level_struct[$key]["acat_alias"]) { $link .= html_specialchars($level_struct[$key]["acat_alias"]); } else { $link .= 'id='.$key; } $redirect['target'] = ''; } else { $redirect = get_redirect_link($level_struct[$key]["acat_redirect"], ' ', ''); $link = $redirect['link']; } $css_list .= ' '; $css_list .= html_specialchars($level_struct[$key]["acat_name"]); $css_list .= ''.LF; } if($parent_level) { if(!$struct[$level]["acat_redirect"]) { $link = 'index.php?'; if($struct[$level]["acat_alias"]) { $link .= html_specialchars($struct[$level]["acat_alias"]); } else { $link .= 'id='.$level; } $redirect['target'] = ''; } else { $redirect = get_redirect_link($struct[$level]["acat_redirect"], ' ', ''); $link = $redirect['link']; } $css_list_home = '
  • '; $css_list_home .= ''; $css_list_home .= html_specialchars((!$parent_level_name) ? $struct[$level]["acat_name"] : $parent_level_name); $css_list_home .= '
  • '.LF; $css_list = $css_list_home . $css_list; } if($css_list) { $css_list = LF.'
      '.LF . $css_list .'
    '.LF; } return $css_list; } // REWRITE - PATCHED FOR 04/04 // jan212 function url_search($query) { if ( substr($query,0,4) == '?id=') { $noid = substr($query, 4); $file = str_replace(',', '.', $noid).PHPWCMS_REWRITE_EXT; } else { $noid = substr($query,1); $file = str_replace(',', '.', $noid).PHPWCMS_REWRITE_EXT; $file = str_replace('aid=', 'aid'.rawurlencode('='), $file); } $link = ' href="'.str_replace('aid=', 'aid'.rawurlencode('='), $file).'"'; return($link); } function js_url_search($query) { if ( substr($query,0,4) == '?id=') { $noid = substr($query, 4); $file = str_replace(',', '.', $noid).PHPWCMS_REWRITE_EXT; } else { $noid = substr($query,1); $file = str_replace(',', '.', $noid).PHPWCMS_REWRITE_EXT; $file = str_replace('aid=', 'aid'.rawurlencode('='), $file); } $link = "onclick=\"location.href='".$file."'"; return($link); } function get_related_articles($keywords, $current_article_id, $template_default, $max_cnt_links=0, $dbcon) { // find keyword for current article used for RELATED replacementtag // prepared and inspired by Magnar Stav Johanssen $keyword_links = ''; $max_cnt_links = intval($max_cnt_links); // replace unwanted chars and convert to wanted $keywords = str_replace( array("ALLKEYWORDS",";", "'", ' ', ',,'), array($GLOBALS['content']['all_keywords'].',', ",", '', ',', ','), strtoupper($keywords) ); // choose comma separated keywords $keywordarray = convertStringToArray($keywords); // check for empty keywords or keywords smaller than 3 chars if(is_array($keywordarray) && count($keywordarray)) { foreach($keywordarray as $key => $value) { if(substr($keywordarray[$key], 0, 1) == '-') { $doNotUse = substr($keywordarray[$key], 1); foreach($keywordarray as $key2 => $value2) { if($doNotUse == $value2) { unset($keywordarray[$key2]); unset($keywordarray[$key]); } } } if(isset($keywordarray[$key]) && (strlen($keywordarray[$key]) < 3 || empty($keywordarray[$key]))) { unset($keywordarray[$key]); } } } if(is_array($keywordarray) && count($keywordarray)) { $where = ""; foreach($keywordarray as $value) { //build where keyword = blabla $where .= ($where) ? " OR " : ""; //replace every "'" to "''" for security reasons with aporeplace() $where .= "article_keyword LIKE '%".aporeplace($value)."%'"; } $limit = ($max_cnt_links) ? " LIMIT ".$max_cnt_links : ""; $sql = "SELECT article_id, article_title, article_cid, article_subtitle, article_summary, article_alias, article_redirect, article_morelink "; $sql .= "FROM ".DB_PREPEND."phpwcms_article WHERE article_deleted=0 AND "; $sql .= "article_id<>".intval($current_article_id)." AND "; // VISIBLE_MODE: 0 = frontend (all) mode, 1 = article user mode, 2 = admin user mode switch(VISIBLE_MODE) { case 0: $sql .= "article_public=1 AND article_aktiv=1 AND "; break; case 1: $sql .= "article_uid=".$_SESSION["wcs_user_id"]." AND "; break; //case 2: admin mode no additional neccessary } $sql .= "article_begin < NOW() AND article_end > NOW() AND (".$where.") "; if(empty($template_default['sort_by'])) $template_default['sort_by'] = ''; switch($template_default['sort_by']) { case 'title_asc': $sql .= "ORDER BY article_title"; break; case 'title_desc': $sql .= "ORDER BY article_title DESC"; break; case 'ldate_asc': $sql .= "ORDER BY article_begin"; break; case 'ldate_desc': $sql .= "ORDER BY article_begin DESC"; break; case 'kdate_asc': $sql .= "ORDER BY article_end"; break; case 'kdate_desc': $sql .= "ORDER BY article_end DESC"; break; case 'cdate_asc': $sql .= "ORDER BY article_created"; break; case 'cdate_desc': $sql .= "ORDER BY article_created DESC"; break; default: $sql .= "ORDER BY article_tstamp DESC"; } $sql .= $limit; // related things $target = $template_default["link_target"] ? ' target="'.$template_default["link_target"].'"' : ''; $result = _dbQuery($sql); if(isset($result[0])) { foreach($result as $row) { if(empty($row['article_redirect'])) { if(empty($row['article_morelink'])) { continue; } $article_link = 'index.php?'.setGetArticleAid($row).'"'.$target; } else { $redirect = get_redirect_link($row['article_redirect'], ' ', ''); $article_link = $redirect['link'].'"'.$redirect['target']; } if($template_default["link_length"] && strlen($row['article_title']) > $template_default["link_length"]) { $article_title = substr($row['article_title'], 0, $template_default["link_length"]).$template_default["cut_title_add"]; } else { $article_title = $row['article_title']; } $keyword_links .= $template_default["link_before"]; $keyword_links .= $template_default["link_symbol"]; $keyword_links .= ' $template_default["link_length"]) { $article_title = substr($row['article_title'], 0, $template_default["link_length"]).$template_default["cut_title_add"]; } else { $article_title = $row['article_title']; } $article_title = html_specialchars($article_title); if(trim($template_default["date_format"])) { $article_title = $template_default["date_before"] . html_specialchars(international_date_format( $template_default["date_language"], $template_default["date_format"], $row['article_date'])) . $template_default["date_after"] . $article_title; } $new_links .= $template_default["link_before"]; $new_links .= $template_default["link_symbol"]; $new_links .= ' NOW() LIMIT 1"; $data = _dbQuery($sql); if(isset($data[0])) { return ''.$link_text.''; } } return ''.$link_text.''; } function get_keyword_link($keywords="", $db) { // returns a link or linklist for special article keywords // used for replacement tag {KEYWORD:Charlie} $keywords = explode(",", $keywords); $where = ""; $keyword_list = ""; $link = ""; if(count($keywords)) { foreach($keywords as $value) { $value = trim($value); if($value) { if($where) { $where .= " AND "; $keyword_list .= ", "; } $where .= "article_keyword LIKE '%*".aporeplace($value)."*%'"; $keyword_list .= html_specialchars($value); } } } else { $keyword_list = $keywords; } if($where) { $x = 0; $sql = "SELECT article_id, article_cid, article_title, article_alias FROM ".DB_PREPEND."phpwcms_article WHERE "; // VISIBLE_MODE: 0 = frontend (all) mode, 1 = article user mode, 2 = admin user mode switch(VISIBLE_MODE) { case 0: $sql .= "article_public=1 AND article_aktiv=1 AND "; break; case 1: $sql .= "article_uid=".$_SESSION["wcs_user_id"]." AND "; break; //case 2: admin mode no additional neccessary } $sql .= "article_deleted=0 AND article_begin < NOW() "; $sql .= "AND article_end > NOW() AND (".$where.")"; if($result = mysql_query($sql, $db)) { $article_list = array(); while($row = mysql_fetch_row($result)) { $article_list[$x][0] = $row[0]; //article ID $article_list[$x][1] = $row[1]; //article catID $article_list[$x][2] = html_specialchars($row[2]); //article title $article_list[$x]['article_alias'] = $row[3]; $article_list[$x]['article_id'] = $row[0]; $x++; } mysql_free_result($result); } if($x) { // if keyword(s) found if($x == 1) { // if only 1 article found $link .= ''.$keyword_list.''; } else { // if more than one article found foreach($article_list as $key => $value) { if($link) $link .= '|'; $link .= ''.($key+1).''; } $link = $keyword_list.' ['.$link.']'; } } } if(!$link) $link = $keyword_list; $link = $GLOBALS['template_default']["article"]["keyword_before"] . $link; $link .= $GLOBALS['template_default']["article"]["keyword_after"]; return $link; } function clean_replacement_tags($text = '', $allowed_tags='') { // strip out special replacement tags $text = render_PHPcode($text); $text = str_replace('', ' ', $text); $text = strip_tags($text, $allowed_tags); $text = str_replace('|', ' ', $text); $search = array( '/\{.*?\}/si', '/\[ID.*?\/ID\]/si', '/(\s+)/i', '/\[img=(\d+)(.*?){0,1}\](.*?)\[\/img\]/i', '/\[img=(\d+)(.*?){0,1}\]/i', '/\[download=(.*?)\/\]/i', '/\[download=(.*?)\](.*?)\[\/download\]/is' ); $replace = array( '', '', ' ', '$3', '', '', '$2' ); $text = preg_replace($search, $replace, $text); return trim($text); } function get_search_action($id, $dbcon) { // return the search form action $id = intval($id); $cid = 0; if($id) { $sql = "SELECT article_cid, article_alias FROM ".DB_PREPEND."phpwcms_article WHERE "; $sql .= "article_public=1 AND article_aktiv=1 AND article_deleted=0 AND article_begin < NOW() "; $sql .= "AND article_end > NOW() AND article_id=".$id." LIMIT 1"; if($result = mysql_query($sql, $dbcon)) { if($row = mysql_fetch_row($result)) { $cid = $row[0]; $data = array('article_id'=>$id, 'article_alias'=>$row[1]); } mysql_free_result($result); } } return ($cid) ? 'index.php?'.setGetArticleAid($data) : ''; } function get_index_link_up($linktext) { // return the link to parent category of current category $cat_id = $GLOBALS['content']['cat_id']; $linktext = trim($linktext); $link = ''; if(!$linktext) $linktext = 'UP'; if($cat_id && !$GLOBALS['content']['struct'][$cat_id]['acat_hidden']) { $upid = $GLOBALS['content']['struct'][$cat_id]['acat_struct']; $link = ''; } return ($link) ? $link.$linktext.'' : $linktext; } function get_index_link_next($linktext, $cat_down=0) { global $content; // return the link to next article in current ctageory $a_id = isset($content['article_id']) ? $content['article_id'] : $GLOBALS['aktion'][1]; $linktext = trim($linktext); if(!$linktext) $linktext = 'NEXT'; $link = ''; if(count($content['articles']) > 1) { $c = 0; //temp counter foreach($content['articles'] as $key => $value) { if($c || !$a_id) { $link = ''; break; } if($key == $a_id) $c++; } } if($cat_down && !$link) { // go cat down or to next cat above if($content['cat_id']) { foreach($content['struct'] as $key => $value) { if($content['struct'][$key]['acat_struct'] == $content['cat_id']) { $link = ''; break; } } } else { $c = 0; foreach($content['struct'] as $key => $value) { if($c) { $link = ''; break; } $c++; } } if(!$link && $content['cat_id']) { $c=0; $temp_key = array(); foreach($content['struct'] as $key => $value) { if($content['struct'][$key]['acat_struct'] == $content['struct'][ $content['cat_id'] ]['acat_struct']) { $temp_key[] = $key; } } $count_temp = count($temp_key); if($count_temp) { $c=0; foreach($temp_key as $value) { if($value == $content['cat_id'] && $c+1 < $count_temp) { //$link = ''; $key = $temp_key[$c+1]; $link = ''; break; } $c++; } if($c == $count_temp && !$link) { // back reverese to higher next structure level $current_id = $content['cat_id']; while($c=1) { $parent_id = $content['struct'][ $current_id ]['acat_struct']; $parent_struct_id = $content['struct'][ $parent_id ]['acat_struct']; $c=0; foreach($content['struct'] as $key => $value) { if($content['struct'][$key]['acat_struct'] == $parent_struct_id) { if($c) { $link = ''; break; } if($key == $parent_id) $c=1; } } if(!$parent_struct_id) { if(!$parent_id) $link = ''; break; } else { $current_id = $parent_id; } } } } } } return ($link) ? $link.$linktext.'' : $linktext; } function get_index_link_prev($linktext, $cat_up=0) { // return the link to next article in current ctageory $a_id = isset($GLOBALS['content']['article_id']) ? $GLOBALS['content']['article_id'] : $GLOBALS['aktion'][1]; $linktext = trim($linktext); if(!$linktext) $linktext = 'PREV'; $link = ''; $c = 0; //temp counter if(count($GLOBALS['content']['articles']) > 1 && $a_id) { foreach($GLOBALS['content']['articles'] as $key => $value) { if($key == $a_id && $c) { $link = ''; break; } $c++; $prev_cat_id = $GLOBALS['content']['articles'][$key]['article_cid']; $prev_art_id = $key; } } if($cat_up && $a_id && $c && !$link) { $link = ''; } if($cat_up && !$link) { // go cat down or to next cat above $temp_key = array(); foreach($GLOBALS['content']['struct'] as $key => $value) { if($GLOBALS['content']['struct'][$key]['acat_struct'] == $GLOBALS['content']['struct'][ $GLOBALS['content']['cat_id'] ]['acat_struct']) { $temp_key[] = $key; } } if(count($temp_key) && $GLOBALS['content']['cat_id']) { $c = 0; foreach($temp_key as $value) { if($value == $GLOBALS['content']['cat_id']) { $prev_cat_id = (!$c) ? $GLOBALS['content']['struct'][$value]['acat_struct'] : $temp_key[$c-1]; $link = ''; break; } $c++; } } } return ($link) ? $link.$linktext.'' : $linktext; } function include_int_php($string) { // return the PHP var value $s = html_despecialchars($string[1]); if((strpos($s,'$GLOBALS') || strpos($s,'$_'))===false) { $s = preg_replace('/^\$(.*?)\[(.*?)/si', '$GLOBALS["$1"][$2', $s); if(substr($s,strlen($s)-1) != ']') { $s = str_replace('$', '', $s); $s = '$GLOBALS["'.$s.'"]'; } } $s = str_replace('$phpwcms', '$notavailable', $s); $s = str_replace('["phpwcms"]', '["notavailable"]', $s); $s = str_replace("['phpwcms']", '["notavailable"]', $s); ob_start(); eval('echo '.$s.';'); return ob_get_clean(); } function include_int_phpcode($string) { // return the PHP code $s = html_despecialchars($string[1]); $s = str_replace('
    ', "\n", $s); $s = str_replace('
    ', "\n", $s); ob_start(); eval($s.";"); return ob_get_clean(); } function build_sitemap($start=0, $counter=0) { // create sitemap $s = ''; $c = ''; $counter++; if($GLOBALS['sitemap']['classcount']) { if($GLOBALS['sitemap']['catclass']) $c = ' class="'.$GLOBALS['sitemap']['catclass'].$counter.'"'; } else { if($GLOBALS['sitemap']['catclass']) $c = ' class="'.$GLOBALS['sitemap']['catclass'].'"'; } foreach($GLOBALS['content']['struct'] as $key => $value) { //if ($key && $GLOBALS['content']['struct'][$key]['acat_nositemap'] && $start == $GLOBALS['content']['struct'][$key]['acat_struct']) if( $GLOBALS['content']['struct'][$key]['acat_nositemap'] && _getStructureLevelDisplayStatus($key, $start) ) { $s .= ''; //$c. if(!$GLOBALS['content']['struct'][$key]["acat_redirect"]) { $s .= '\n".$s.''; return $s; } function build_sitemap_articlelist($cat, $counter=0) { // create list of articles for given category $ao = get_order_sort($GLOBALS['content']['struct'][ $cat ]['acat_order']); $sql = "SELECT article_id, article_title FROM ".DB_PREPEND."phpwcms_article "; $sql .= "WHERE article_cid=".intval($cat)." AND article_nositemap=1 AND "; // VISIBLE_MODE: 0 = frontend (all) mode, 1 = article user mode, 2 = admin user mode switch(VISIBLE_MODE) { case 0: $sql .= "article_public=1 AND article_aktiv=1 AND "; break; case 1: $sql .= "article_uid=".$_SESSION["wcs_user_id"]." AND "; break; //case 2: admin mode no additional neccessary } $sql .= "article_deleted=0 AND article_beginNOW() "; $sql .= "ORDER BY ".$ao[2]; $s = ''; $c = ''; if($GLOBALS['sitemap']['classcount']) { if($GLOBALS['sitemap']['articleclass']) $c = ' class="'.$GLOBALS['sitemap']['articleclass'].$counter.'"'; } else { if($GLOBALS['sitemap']['articleclass']) $c = ' class="'.$GLOBALS['sitemap']['articleclass'].'"'; } if($result = mysql_query($sql, $GLOBALS['db'])) { while($row = mysql_fetch_row($result)) { $s .= ''; //.$c $s .= ''; $s .= html_specialchars($row[1]); $s .= "\n"; } mysql_free_result($result); } if($s) $s = "\n\n".$s.''; return $s; } function render_cnt_template($text='', $tag='', $value='') { // render content part by replacing placeholder tags by value $value = strval($value); if($value) { $text = preg_replace('/\['.$tag.'\](.*?)\[\/'.$tag.'\]/is', '$1', $text); $text = preg_replace('/\['.$tag.'_ELSE\](.*?)\[\/'.$tag.'_ELSE\]/is', '', $text); } else { $text = preg_replace('/\['.$tag.'_ELSE\](.*?)\[\/'.$tag.'_ELSE\]/is', '$1', $text); $text = preg_replace('/\['.$tag.'\](.*?)\[\/'.$tag.'\]/is', '', $text); } return str_replace('{'.$tag.'}', $value, $text); } function replace_cnt_template($text='', $tag='', $value='') { // replace tag by value return preg_replace('/\['.$tag.'\].*?\[\/'.$tag.'\]/is', strval($value), $text); } function parse_cnt_urlencode($value) { // replace tag by value return preg_replace_callback('/\[URLENCODE\](.*?)\[\/URLENCODE\]/s', 'render_urlencode', $value); } function render_urlencode($match) { if(is_array($match) && isset($match[1])) { $match = $match[1]; } return rawurlencode(decode_entities($match)); } function render_cnt_date($text='', $date, $livedate=NULL, $killdate=NULL) { // render date by replacing placeholder tags by value $date = is_numeric($date) ? intval($date) : now(); $text = preg_replace('/\{DATE:(.*?) lang=(..)\}/e', 'international_date_format("$2","$1","'.$date.'")', $text); $text = preg_replace('/\{DATE:(.*?)\}/e', 'date("$1",'.$date.')', $text); if(intval($livedate)) { $text = preg_replace('/\{LIVEDATE:(.*?) lang=(..)\}/e', 'international_date_format("$2","$1","'.$livedate.'")', $text); $text = preg_replace('/\{LIVEDATE:(.*?)\}/e', 'date("$1",'.$livedate.')', $text); } if(intval($killdate)) { $text = preg_replace('/\{KILLDATE:(.*?) lang=(..)\}/e', 'international_date_format("$2","$1","'.$killdate.'")', $text); $text = preg_replace('/\{KILLDATE:(.*?)\}/e', 'date("$1",'.$killdate.')', $text); } return preg_replace('/\{NOW:(.*?) lang=(..)\}/e', 'international_date_format("$2","$1","'.now().'")', $text); } function render_date($text='', $date, $rt='DATE') { // render date by replacing placeholder tags by value $rt = preg_quote($rt); $text = preg_replace('/\{'.$rt.':(.*?) lang=(..)\}/e', 'international_date_format("$2","$1","'.$date.'")', $text); return preg_replace('/\{'.$rt.':(.*?)\}/e', 'date("$1",'.$date.')', $text); } function returnTagContent($string='', $tag='', $findall=false, $tagOpen='[', $tagClose=']') { // used to exclude a special string sequence from string // enclosed by [tag][/tag] or also $data = array(); $data['original'] = $string; $tag_open = preg_quote($tagOpen.$tag.$tagClose, '/'); $tag_close = preg_quote($tagOpen.'/'.$tag.$tagClose, '/'); $data['new'] = trim(preg_replace('/'.$tag_open.'(.*?)'.$tag_close.'/is', '', $string)); if($findall) { preg_match_all('/'.$tag_open.'(.*?)'.$tag_close.'/is', $string, $matches); } else { preg_match('/'.$tag_open.'(.*?)'.$tag_close.'/is', $string, $matches); } $data['tag'] = isset($matches[1]) ? $matches[1] : ''; return $data; } function include_url($url) { // include given URL but only take content between global $include_urlparts; if( is_string($url) ) { $url = array( 1 => $url ); } elseif( ! isset($url[1]) ) { return ''; } $k = ''; $url = trim($url[1]); $url = explode(' ', $url); $cache = isset($url[1]) ? intval(str_replace('CACHE=', '', strtoupper($url[1]))) : 0; $url = $url[0]; $cache_status = 'MISSING'; if($url && $cache) { $cache_filename = md5($url).'-url'; // set cache file name $cache_file = PHPWCMS_CONTENT.'tmp/'.$cache_filename; // set caching file $cache_status = check_cache($cache_file, $cache); // ceck existence if($cache_status == 'VALID') { // read cache $k = read_textfile($cache_file); $k = trim($k); if(empty($k)) { $cache_status == 'EXPIRED'; // check if cache content is available } } } if($cache_status != 'VALID' && $url) { // cache file is missing or outdated $include_urlparts = parse_url($url); if(!empty($include_urlparts['path'])) { $include_urlparts['path'] = dirname($include_urlparts['path']); $include_urlparts['path'] = str_replace('\\', '/', $include_urlparts['path']); } $k = @file_get_contents($url); if($k) { // now check against charset if(preg_match('/charset=(.*?)"/i', $k, $match)) { $charset = $match[1]; $charset = str_replace(array('"', "'", '/'), '', $charset); $charset = strtolower(trim($charset)); } elseif(preg_match('/http-equiv="{0,1}Content-Type"{0,1}\s{1,}(content="{0,1}.*?"{0,1}.{0,3}>)/i', $k, $match)) { $charset = ''; if(!empty($match[1])) { $charset = strtolower($match[1]); $charset = trim(str_replace(array('"', "'", '/', 'content=', ' ', '>'), '', $charset)); } } else { $charset = false; } if(preg_match('/]*?'.'>(.*)<\/body>/is', $k, $match)) { $k = $match[1]; } $k = str_replace(array('', '<%', '%>'), array('<?', '?>', '<%', '%>'), $k); $k = preg_replace_callback('/(href|src|action)=[\'|"]{0,1}(.*?)[\'|"]{0,1}( .*?){0,1}>/i', 'make_absoluteURL', $k); $k = htmlfilter_sanitize( trim($k) , array(false, 'link', 'meta'), array(), array('img', 'br', 'hr', 'input'), true); if($charset != false) { $k = makeCharsetConversion($k, $charset, PHPWCMS_CHARSET, 1); } // now write or update cache file in case there is timeout or content if($cache && $k) { @write_textfile($cache_file, $k); } } $include_urlparts = ''; } return $k; } function make_absoluteURL($matches) { // replaces all relative URLs in href=/src= to absolute paths based on called URI $parts = $GLOBALS['include_urlparts']; $path = $matches[2]; $k = ''; if(preg_match('/^(http|mailto|ftp|https|skype|itms)/i', $path)) { $k = $path; } else { if(empty($parts['path'])) $parts['path'] = ''; $k = $parts['host'].$parts['path'].'/'.$path; $k = str_replace('///', '/', $k); $k = str_replace('//', '/', $k); $k = $parts['scheme'].'://'.$k; } if(empty($matches[3])) $matches[3] = ''; return $matches[1].'="'.$k.'"'.$matches[3].'>'; } function render_PHPcode($string='') { // combined PHP replace renderer // includes external PHP script and returns the content $string = preg_replace('/\{PHP:(.*?)\}/e', 'include_ext_php("$1");', $string); // do complete PHP code $string = preg_replace_callback("/\[PHP\](.*?)\[\/PHP\]/s", 'include_int_phpcode', $string); // includes external PHP script and returns the content $string = preg_replace_callback("/\{PHPVAR:(.*?)\}/s", 'include_int_php', $string); return $string; } function nav_list_struct (&$struct, $act_cat_id, $level, $class='') { // start with home directory for the listing = top nav structure // 1. Build the recursive tree for given actual article category ID // return the tree starting with given start_id (like breadcrumb) // if the $start_id = 0 then this stops because 0 = top level $level = intval($level); $data = array(); $start_id = $act_cat_id; $class = trim($class); $depth = 0; while ($start_id) { $data[$start_id] = 1; $start_id = $struct[$start_id]["acat_struct"]; } $temp_tree = sizeof($data) ? array_reverse($data, 1) : false; $temp_menu = build_list ($struct, $level, $temp_tree, $act_cat_id, $class, $depth); $temp_menu = str_replace("\n\n", LF, $temp_menu); return $temp_menu ? $temp_menu : ''; } function build_list ($struct, $level, $temp_tree, $act_cat_id, $class='', $depth=0) { // this returns the level structure based on given arrays // it is special for browsing from root levels if($class != '') { $curClass = ' class="'.$class.$depth.'"'; $curClassNext = ' class="'.$class.($depth+1).'"'; $curClassActive = ' class="'.$class.'Active'.$depth.'"'; } else { $curClass = ''; $curClassNext = ''; $curClassActive = ' class="listActive"'; } $depth++; $temp_menu = "\n\n"; foreach($struct as $key => $value) { if( _getStructureLevelDisplayStatus($key, $level) ) { if(!$struct[$key]["acat_redirect"]) { $link = 'index.php?'; if($struct[$key]["acat_alias"]) { $link .= html_specialchars($struct[$key]["acat_alias"]); } else { $link .= 'id='.$key; //',0,0,1,0,0'; } $redirect['target'] = ''; } else { $redirect = get_redirect_link($struct[$key]["acat_redirect"], ' ', ''); $link = $redirect['link']; } if(!empty($temp_tree[$key])) { if($act_cat_id == $key) { $temp_menu .= "\n"; } else { $temp_menu .= "\n
  • "; } $temp_menu .= ''.html_specialchars($struct[$key]["acat_name"]).''; $temp_menu .= build_list ($struct, $key, $temp_tree, $act_cat_id, $class, $depth); $temp_menu .= '
  • '; } else { $temp_menu .= "\n
  • ".''; $temp_menu .= html_specialchars($struct[$key]["acat_name"])."
  • \n"; } } } $temp_menu = trim($temp_menu); return $temp_menu != "" ? $temp_menu."\n" : ''; } function combined_POST_cleaning($val) { $val = clean_slweg($val); $val = remove_unsecure_rptags($val); return $val; } function get_fe_userinfo($forum_userID) { // get frontend userinformation $forum_userID = intval($forum_userID); $got_the_info = false; if($forum_userID != 0 && (!isset($GLOBALS['FE_USER']) || !isset($GLOBALS['FE_USER'][$forum_userID]))) { //connect to user db and get information $sql = "SELECT * FROM ".DB_PREPEND."phpwcms_user WHERE usr_id=".$forum_userID." LIMIT 1"; if($result = mysql_query($sql, $GLOBALS['db'])) { if($row = mysql_fetch_assoc($result)) { $GLOBALS['FE_USER'][$forum_userID] = array( 'FE_ID' => $forum_userID, 'login' => $row['usr_login'], 'pass' => $row['usr_pass'], 'email' => $row['usr_email'], 'admin' => $row['usr_admin'], 'fe' => $row['usr_fe'], 'aktiv' => $row['usr_aktiv'], 'name' => $row['usr_name'], 'lang' => empty($row['usr_lang']) ? $GLOBALS['phpwcms']['default_lang'] : $row['usr_lang'], 'wysiwyg' => $row['usr_wysiwyg'] ); $got_the_info = true; } mysql_free_result($result); } } else { $got_the_info = true; } if(($forum_userID === 0 && !isset($GLOBALS['FE_USER'][$forum_userID])) || !$got_the_info) { $forum_userID = 0; $GLOBALS['FE_USER'][$forum_userID] = array( 'FE_ID' => $forum_userID, 'login' => 'guest', 'pass' => '', 'email' => 'noreply@localhost', 'admin' => 0, 'fe' => 0, 'aktiv' => 1, 'name' => 'Guest', 'lang' => $GLOBALS['phpwcms']['default_lang'], 'wysiwyg' => $GLOBALS['phpwcms']['wysiwyg_editor'] ); } } function highlightSearchResult($string='', $search, $wrap='|') { // string will be highlighted by $search - can be string or array if(!empty($string) && !empty($search)) { // make $wrap[0] prefix and $wrap[1] suffix $wrap = explode('|', $wrap); if(empty($wrap[1])) $wrap[1] = ''; $highlight_match = ''; // make all search values array fields if(is_array($search)) { // make unique $search = array_unique($search); } else { $search = array(strval($search)); } foreach($search as $key => $value) { if($highlight_match != '') $highlight_match .= '|'; $highlight_match .= preg_quote($value, '/'); } $highlight_match = str_replace("\\?", '.?', $highlight_match); $highlight_match = str_replace("\\*", '.*', $highlight_match); $highlight_match = trim($highlight_match); if(false == preg_match('/<.+>/', $string)) { $string = preg_replace('/('.$highlight_match.')/i', $wrap[0].'$1'.$wrap[1], $string); } else { $string = preg_replace('/(?<=>)([^<]+)?('.$highlight_match.')/i', '$1'.$wrap[0].'$2'.$wrap[1], $string); } } return $string; } function pregReplaceHighlightWrapper($matches) { // just a wrapper for frontend sectional highlighting global $highlight_words; return highlightSearchResult($matches[1], $highlight_words, '|'); } function buildCascadingMenu($parameter='', $counter=0, $param='string') { // @string $parameter = "menu_type, start_id, max_level_depth, class_path, class_active_li|class_active_a, // ul_id_name, wrap_ul_div(0 = off, 1 =
    , 2 =
    , 3 =