[ Index ] |
PHP Cross Reference of phpwcms V1.4.3 _r380 (23.11.09) |
[Summary view] [Print] [Text view]
1 <?php 2 /************************************************************************************* 3 Copyright notice 4 5 (c) 2002-2009 Oliver Georgi (oliver@phpwcms.de) // All rights reserved. 6 7 This script is part of PHPWCMS. The PHPWCMS web content management system is 8 free software; you can redistribute it and/or modify it under the terms of 9 the GNU General Public License as published by the Free Software Foundation; 10 either version 2 of the License, or (at your option) any later version. 11 12 The GNU General Public License can be found at http://www.gnu.org/copyleft/gpl.html 13 A copy is found in the textfile GPL.txt and important notices to the license 14 from the author is found in LICENSE.txt distributed with these scripts. 15 16 This script is distributed in the hope that it will be useful, but WITHOUT ANY 17 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 18 PARTICULAR PURPOSE. See the GNU General Public License for more details. 19 20 This copyright notice MUST APPEAR in all copies of the script! 21 *************************************************************************************/ 22 23 // ---------------------------------------------------------------- 24 // obligate check for phpwcms constants 25 if (!defined('PHPWCMS_ROOT')) { 26 die("You Cannot Access This Script Directly, Have a Nice Day."); 27 } 28 // ---------------------------------------------------------------- 29 30 31 //predefine values 32 33 $content['cat'] = ''; 34 $content['metakey'] = ''; 35 $content['struct'] = get_struct_data(); //reads the complete structure as array 36 $content['article_date'] = time(); 37 $content['redirect'] = array('code' => ''); 38 $content['all_keywords'] = ''; 39 $content['globalRT'] = array(); 40 $content['aId_CpPage'] = 0; // set default content part pagination page (0 and 1) are the same 41 $content['CpTrigger'] = array(); // array to hold content part trigger functions 42 $content['404error'] = false; 43 $pagelayout = array(); 44 $no_content_for_this_page = 0; 45 $alias = ''; 46 $PERMIT_ACCESS = true; // by default set all content without permissions 47 $CUSTOM = array(); // var that holds result of content part "php var" 48 49 //method to get the right action values 50 //if there is only the ?alias try to find the right category 51 if(isset($_GET["id"])) { 52 53 $aktion = explode(',', $_GET["id"], 6); 54 $aktion[0] = intval($aktion[0]); //$aktion[0] will be always available 55 $aktion[1] = isset($aktion[1]) ? intval($aktion[1]) : 0; 56 $aktion[2] = isset($aktion[2]) ? intval($aktion[2]) : 0; 57 $aktion[3] = isset($aktion[3]) ? intval($aktion[3]) : 1; 58 $aktion[4] = isset($aktion[4]) ? intval($aktion[4]) : 0; 59 $aktion[5] = isset($aktion[5]) ? intval($aktion[5]) : 0; 60 61 // check if article category is given and available 62 if(!isset($content['struct'][ $aktion[0] ])) { 63 $aktion[0] = 0; 64 // OK in case not we should check if given article ID is correct 65 if($aktion[1]) { 66 $sql = 'SELECT article_id, article_cid FROM '.DB_PREPEND.'phpwcms_article WHERE '; 67 $sql .= 'article_deleted=0 AND article_aktiv=1 AND article_id='.$aktion[1].' LIMIT 1'; 68 $aktion[1] = 0; //reset 69 if($result = mysql_query($sql, $db)) { 70 if($row = mysql_fetch_row($result)) { 71 $aktion[0] = $row[1]; 72 $aktion[1] = $row[0]; 73 } 74 mysql_free_result($result); 75 } 76 } 77 $GLOBALS['_getVar']['id'] = implode(',', $aktion); 78 headerRedirect(PHPWCMS_URL.'index.php'.returnGlobalGET_QueryString(), 404); 79 } 80 81 } elseif(isset($_GET['aid'])) { 82 // try to find correct structure 83 $aktion = array(0,0,0,0,1,0); 84 85 $_GET['aid'] = explode('-', $_GET['aid'], 2); // now check for cp pagination 86 $content['aId_CpPage'] = isset($_GET['aid'][1]) ? intval($_GET['aid'][1]) : 0; // set cp paginate page 87 $_GET['aid'] = intval($_GET['aid'][0]); 88 if($_GET['aid']) { 89 $sql = 'SELECT article_cid FROM '.DB_PREPEND.'phpwcms_article WHERE '; 90 $sql .= 'article_deleted=0 '; 91 if(VISIBLE_MODE !== 2) { 92 $sql .= 'AND article_aktiv=1 AND article_public=1 '; 93 } elseif(VISIBLE_MODE === 1) { 94 $sql .= 'AND article_uid='.intval($_SESSION["wcs_user_id"]).' '; 95 } 96 $sql .= 'AND article_id='.$_GET['aid'].' LIMIT 1'; 97 if($result = mysql_query($sql, $db)) { 98 if($row = mysql_fetch_row($result)) { 99 $aktion[0] = $row[0]; 100 $aktion[1] = $_GET['aid']; 101 } else { 102 $content['404error'] = true; 103 } 104 mysql_free_result($result); 105 } else { 106 $content['404error'] = true; 107 } 108 } 109 if(!$aktion[1]) { 110 $content['aId_CpPage'] = 0; // no article = no pagination 111 } 112 113 } else { 114 // check the alias 115 $aktion = array(0,0,0,1,0,0); 116 117 if(count($GLOBALS['_getVar'])) { 118 reset($GLOBALS['_getVar']); 119 $alias = trim(key($GLOBALS['_getVar'])); 120 if($alias && $GLOBALS['_getVar'][$alias] === '') { // alias must be empty "" 121 122 $where_alias = aporeplace($alias); 123 124 // we have to check against MySQL < 4.0 -> UNION unknown 125 // so use a workaround 126 127 if(PHPWCMS_DB_VERSION < 40000) { 128 129 $sql = "SELECT acat_id, (0) AS article_id, 1 AS aktion3, 0 AS aktion4 FROM " . DB_PREPEND . "phpwcms_articlecat "; 130 $sql .= "WHERE acat_trash=0 AND acat_aktiv=1 AND acat_alias='" . $where_alias . "' LIMIT 1"; 131 132 $row = _dbQuery($sql); 133 134 if(!isset($row[0]['acat_id'])) { 135 136 $sql = "SELECT article_cid AS acat_id, article_id, 0 AS aktion3, 1 AS aktion4 FROM " . DB_PREPEND . "phpwcms_article "; 137 $sql .= "WHERE article_deleted=0 AND article_aktiv=1 AND article_alias='" . $where_alias . "' LIMIT 1"; 138 139 $row = _dbQuery($sql); 140 141 } 142 143 } else { 144 145 $sql = "(SELECT acat_id, (0) AS article_id, 1 AS aktion3, 0 AS aktion4 FROM " . DB_PREPEND . "phpwcms_articlecat "; 146 $sql .= "WHERE acat_trash=0 AND acat_aktiv=1 AND acat_alias='" . $where_alias . "')"; 147 $sql .= " UNION "; 148 $sql .= "(SELECT article_cid AS acat_id, article_id, 0 AS aktion3, 1 AS aktion4 FROM " . DB_PREPEND . "phpwcms_article "; 149 $sql .= "WHERE article_deleted=0 AND article_aktiv=1 AND article_alias='" . $where_alias . "') "; 150 $sql .= "LIMIT 1"; 151 152 $row = _dbQuery($sql); 153 154 } 155 156 if(isset($row[0]['acat_id'])) { 157 158 $aktion[0] = $row[0]['acat_id']; 159 $aktion[1] = $row[0]['article_id']; 160 $aktion[3] = $row[0]['aktion3']; 161 $aktion[4] = $row[0]['aktion4']; 162 163 define('PHPWCMS_ALIAS', $alias); 164 165 } elseif($alias == $indexpage['acat_alias']) { 166 167 define('PHPWCMS_ALIAS', $alias); 168 169 } else { 170 171 $content['404error'] = true; 172 173 } 174 175 } 176 } 177 178 } 179 if(isset($_GET['print'])) { 180 181 $aktion[2] = 1; 182 define('PRINT_PDF', intval($_GET['print']) == 2 ? true : false); 183 unset($_getVar['print'], $_GET['print']); 184 185 } 186 187 // define special OUTPUT format/action 188 $phpwcms['output_action'] = false; 189 if(!empty($_GET['phpwcms_output_action']) || !empty($_POST['phpwcms_output_action'])) { 190 191 // split by function - value: F-function1|function2|function3--S-SECT1|SECT2|SECT3 192 $phpwcms['output_action'] = explode('--', clean_slweg( empty($_GET['phpwcms_output_action']) ? $_POST['phpwcms_output_action'] : $_GET['phpwcms_output_action'] )); 193 unset( 194 $_GET['phpwcms_output_action'], 195 $_POST['phpwcms_output_action'], 196 $_getVar['phpwcms_output_action'] 197 ); 198 199 if(is_array($phpwcms['output_action'])) { 200 201 $phpwcms['output_function'] = array(); 202 $phpwcms['output_section'] = array(); 203 204 foreach($phpwcms['output_action'] as $value) { 205 206 $value = trim($value); 207 if($value{0} == 'F') { 208 $value = explode('|', substr($value, 2)); 209 $output_key = 'output_function'; 210 } elseif($value{0} == 'S') { 211 $value = explode('|', substr($value, 2)); 212 $output_key = 'output_section'; 213 } else { 214 continue; 215 } 216 217 if(is_array($value)) { 218 219 foreach($value as $_value) { 220 221 $_value = trim($_value); 222 223 if($_value != '') { 224 $phpwcms[$output_key][$_value] = $_value; 225 } 226 } 227 } 228 } 229 230 $phpwcms['output_action'] = count($phpwcms['output_function']) || count($phpwcms['output_section']) ? true : false; 231 232 } else { 233 $phpwcms['output_action'] = false; 234 } 235 } 236 237 238 //define the current article category ID 239 $content["cat_id"] = $aktion[0]; 240 $content['body_id'] = $content["cat_id"]; 241 242 // check if current level is a redirect level 243 if(!empty($content['struct'][ $content["cat_id"] ]['acat_redirect'])) { 244 $redirect = get_redirect_link( $content['struct'][ $content["cat_id"] ]['acat_redirect'] ); 245 headerRedirect($redirect['link'], 301); 246 } 247 248 //try to find current tree depth 249 $LEVEL_ID = array(); 250 $LEVEL_KEY = array(); 251 $LEVEL_STRUCT = array(); 252 $level_ID_array = get_breadcrumb($content["cat_id"], $content['struct']); 253 $level_count = 0; 254 foreach($level_ID_array as $key => $value) { 255 $LEVEL_ID[$level_count] = $key; 256 $LEVEL_KEY[$key] = $level_count; 257 $LEVEL_STRUCT[$level_count] = $content['struct'][$key]['acat_name']; 258 if($PERMIT_ACCESS && $content['struct'][$key]['acat_regonly']) { 259 $PERMIT_ACCESS = false; // only users have been logged in get access 260 } 261 $level_count++; 262 } 263 264 define('PERMIT_ACCESS', $PERMIT_ACCESS); 265 // frontend login check 266 _checkFrontendUserAutoLogin(); 267 268 // ------------------------------------------------------------- 269 270 // read the template information for page based on structure 271 if($content["struct"][ $content["cat_id"] ]["acat_template"]) { 272 //if there is a template defined for this structure level 273 //then choose the template information based on this ID 274 $sql = "SELECT template_var FROM ".DB_PREPEND."phpwcms_template WHERE template_trash=0 AND "; 275 $sql .= "template_id=".$content["struct"][ $content["cat_id"] ]["acat_template"]." LIMIT 1;"; 276 if($result = mysql_query($sql, $db)) { 277 if($row = mysql_fetch_row($result)) { 278 $block = unserialize($row[0]); 279 } 280 mysql_free_result($result); 281 } 282 } 283 if(!isset($block)) { 284 // if template ID is not defined or the were a problem with level's template ID then 285 // choose the default template or if no default template defined choose the next one 286 $sql = "SELECT template_var FROM ".DB_PREPEND."phpwcms_template "; 287 $sql .= "WHERE template_trash=0 ORDER BY template_default DESC LIMIT 1;"; 288 if($result = mysql_query($sql, $db)) { 289 if($row = mysql_fetch_row($result)) { 290 $block = unserialize($row[0]); 291 } 292 mysql_free_result($result); 293 } 294 } 295 // set array for possible custom html head additions 296 $block['custom_htmlhead'] = array('frontend.js' => ' <script src="'.TEMPLATE_PATH.'inc_js/frontend.js" type="text/javascript"></script>'); 297 // compatibility for older releases where only 298 // 1 css file could be stored per template 299 if(is_string($block['css'])) { 300 $block['css'] = array($block['css']); 301 } 302 // check if template_defaults should be overwritten 303 if(!empty($block['overwrite'])) { 304 $block['overwrite'] = str_replace('/', '', $block['overwrite']); 305 @include(PHPWCMS_TEMPLATE.'inc_settings/template_default/'.$block['overwrite']); 306 } 307 if(!empty($content['struct'][ $content['cat_id'] ]['acat_overwrite'])) { 308 $block['overwrite'] = str_replace('/', '', $content['struct'][ $content['cat_id'] ]['acat_overwrite']); 309 @include(PHPWCMS_TEMPLATE.'inc_settings/template_default/'.$block['overwrite']); 310 } 311 312 // ------------------------------------------------------------- 313 314 // retrieve pagelayout info 315 // check how the content should be rendered based on pagelayout render value 316 $block["layout"] = intval($block["layout"]); 317 $sql = "SELECT pagelayout_var FROM ".DB_PREPEND."phpwcms_pagelayout WHERE pagelayout_trash=0 "; 318 $sql .= $block["layout"] ? "AND pagelayout_id=".$block["layout"] : "ORDER BY pagelayout_default DESC"; 319 $sql .= " LIMIT 1"; 320 $result = _dbQuery($sql); 321 if(isset($result[0]['pagelayout_var'])) { 322 $pagelayout = @unserialize($result[0]['pagelayout_var']); 323 // if print action 324 if($aktion[2] === 1) { 325 $pagelayout = array('layout_title' => $pagelayout['layout_title'], 'layout_customblocks' => $pagelayout['layout_customblocks']); 326 } 327 } 328 if(empty($pagelayout)) { 329 // if no pagelayout could be found 330 die('There is no pagelayout available. Please <a href="'. 331 PHPWCMS_URL.get_login_file().'">login</a> to the admin section and <a href="'. 332 PHPWCMS_URL.'phpwcms.php?do=admin&p=8">create one here</a>!'); 333 } 334 // Pagetitle 335 $content["pagetitle"] = empty($pagelayout["layout_title"]) ? '' : $pagelayout["layout_title"]; 336 337 //generate the colspan attribute 338 $colspan = get_colspan($pagelayout); 339 340 // ------------------------------------------------------------- 341 342 // now initialize content blocks like CONTENT, HEADER, LEFT, RIGHT, FOOTER 343 $content['main'] = ''; // {CONTENT} 344 $content['CB']['LEFT'] = ''; // {LEFT} 345 $content['CB']['RIGHT'] = ''; // {RIGHT} 346 $content['CB']['HEADER'] = ''; // {HEADER} 347 $content['CB']['FOOTER'] = ''; // {FOOTER} 348 // and try to add and initialize custom blocks 349 if(!empty($pagelayout['layout_customblocks'])) { 350 $custom_blocks = explode(', ', $pagelayout['layout_customblocks']); 351 foreach($custom_blocks as $value) { 352 if($value != '') $content['CB'][$value] = ''; 353 } 354 unset($custom_blocks); 355 } 356 357 // ------------------------------------------------------------- 358 359 // try to include custom functions or what ever you want to do at this point of the script 360 // default dir: "phpwcms_template/inc_script/frontend_init"; only *.php files are allowed there 361 if($phpwcms["allow_ext_init"]) { 362 if(count($custom_includes = get_tmpl_files(PHPWCMS_TEMPLATE.'inc_script/frontend_init', 'php'))) { 363 foreach($custom_includes as $value) { 364 include_once(PHPWCMS_TEMPLATE.'inc_script/frontend_init/'.$value); 365 } 366 } 367 } 368 // include custom frontend init scripts based on module definitions 369 if(count($phpwcms['modules_fe_init'])) { 370 foreach($phpwcms['modules_fe_init'] as $value) { 371 include_once($value); 372 } 373 } 374 375 // redirect to login form if user is not logged in and has no permission to access level 376 if(!PERMIT_ACCESS && !_getFeUserLoginStatus()) { 377 378 if(!empty($block['feloginurl'])) { 379 $template_default['login_form_url'] = str_replace('{SITE}', PHPWCMS_URL, $block['feloginurl']); 380 } elseif(empty($template_default['login_form_url'])) { 381 $template_default['login_form_url'] = PHPWCMS_URL; 382 } 383 384 // store current URL 385 $_SESSION['LOGIN_REDIRECT'] = decode_entities(FE_CURRENT_URL); 386 387 // redirect to login form 388 headerRedirect($template_default['login_form_url'], 401); 389 } 390 391 // ------------------------------------------------------------- 392 393 //reads all articles for active cat into array 394 $content["articles"] = get_actcat_articles_data($content["cat_id"]); 395 396 // ------------------------------------------------------------- 397 398 // generating a list of articles inside the current article category 399 if(!$aktion[4]) { 400 $content["article_list_count"] = count($content["articles"]); 401 402 if(!$content['404error'] && ($content["article_list_count"] || $content['struct'][ $content['cat_id'] ]['acat_topcount'] == -1)) { 403 404 if($content["article_list_count"] == 1 || $content['struct'][ $content['cat_id'] ]['acat_topcount'] == -1) { 405 // if($temp_counter == 1) { 406 // if only 1 article for this category available 407 // then show this article directly 408 // sets article ID to this only 1 article 409 foreach($content["articles"] as $key => $value) { 410 $aktion[1] = intval($key); 411 break; 412 } 413 $aktion[4] = 1; // this needs to be set to 1 for showing the article 414 415 } else { 416 // there is more than 1 article inside this category 417 // -> list all - the 1st will be shown with summary and such stuff 418 $content["main"] .= list_articles_summary(); 419 420 } 421 422 } else { 423 424 $no_content_for_this_page = 1; 425 426 } 427 } 428 429 // ------------------------------------------------------------- 430 431 // check if current category should be cached 432 if($content['struct'][$content['cat_id']]['acat_timeout'] != '') { 433 $phpwcms['cache_timeout'] = $content['struct'][$content['cat_id']]['acat_timeout']; 434 } 435 // set search status for current category 436 $cache_searchable = $content['struct'][$content['cat_id']]['acat_nosearch']; 437 438 // ------------------------------------------------------------- 439 440 $content['list_mode'] = true; 441 442 if($aktion[1]) { 443 444 // render page based on article 445 include_once (PHPWCMS_ROOT."/include/inc_front/content.article.inc.php"); 446 $content['list_mode'] = false; 447 448 } elseif(!empty($content['struct'][$content['cat_id']]['acat_pagetitle'])) { 449 450 // a custom pagetitle for structure level exists 451 $content["pagetitle"] = $content['struct'][$content['cat_id']]['acat_pagetitle']; 452 453 } else { 454 455 $content["pagetitle"] = setPageTitle($content["pagetitle"], $content['struct'][$content['cat_id']]['acat_name'], ''); 456 457 } 458 459 // ------------------------------------------------------------- 460 461 //check for no content error 462 $content["main"] = trim($content["main"]); 463 if($content['404error'] || $no_content_for_this_page || $content["main"] == '') { 464 header('HTTP/1.0 404 Not Found'); 465 $content["main"] .= $block["errortext"]; 466 } 467 468 // ------------------------------------------------------------- 469 470 //check if one of needed block texts and values are empty and if then fill with content 471 if(!$block["maintext"]) { 472 $block["maintext"] = $content["main"]; 473 } 474 475 // ------------------------------------------------------------- 476 477 //normal page operation 478 if($aktion[2] == 0) { 479 480 switch($pagelayout["layout_render"]) { 481 482 case 0: //create the page layout table (header, left, content, right, footer) 483 $content["all"] = "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\""; //start main table 484 $content["all"] .= td_attributes($pagelayout, "all", 0); 485 $content["all"] .= align_base_layout($pagelayout["layout_align"])." summary=\"\">".LF; // align table 486 487 //header 488 $content["all"] .= colspan_table_row($pagelayout, "header", $colspan, $block["headertext"]); //header row 489 if($pagelayout["layout_topspace_height"]) { //header space 490 $content["all"] .= colspan_table_row($pagelayout, "topspace", $colspan, spacer(1, $pagelayout["layout_topspace_height"])); 491 } 492 493 //returns the main blocks: left column, content column, right column 494 $content["all"] .= get_table_block($pagelayout, $block["maintext"], $block["lefttext"], $block["righttext"]); 495 496 //footer 497 if($pagelayout["layout_bottomspace_height"]) { //bottom space 498 $content["all"] .= colspan_table_row($pagelayout, "bottomspace", $colspan, spacer(1, $pagelayout["layout_bottomspace_height"])); 499 } 500 $content["all"] .= colspan_table_row($pagelayout, "footer", $colspan, $block["footertext"]); //footer row 501 $content["all"] .= '</table>'.LF; //end main table 502 503 break; 504 505 506 case 1: //create the page layout based on DIV (layer) 507 508 //contentContainer DIV start 509 $content["all"] = ''; 510 $pagelayout['additional_wrap_div'] = false; 511 switch($pagelayout["layout_align"]) { 512 case 1: $content["all"] .= '<div align="center" style="margin:0;padding:0;">'; 513 $pagelayout['additional_wrap_div'] = true; 514 break; 515 case 2: $content["all"] .= '<div align="right" style="margin:0;padding:0;">'; 516 $pagelayout['additional_wrap_div'] = true; 517 break; 518 } 519 $content["all"] .= '<div id="container">'.LF; 520 521 //header DIV 522 if($block["headertext"] || $pagelayout['layout_header_height']) { 523 $content["all"] .= ' <div id="headerBlock">'.$block["headertext"]."</div>\n"; 524 } 525 //left DIV if 3column or 2column (with left block) 526 if($pagelayout["layout_type"] == 0 || $pagelayout["layout_type"] == 1) { 527 $content["all"] .= ' <div id="leftBlock">'.$block["lefttext"]."</div>\n"; 528 } 529 //right DIV if 3column or 2column (with right block) 530 if($pagelayout["layout_type"] == 0 || $pagelayout["layout_type"] == 2) { 531 $content["all"] .= ' <div id="rightBlock">'.$block["righttext"]."</div>\n"; 532 } 533 //main block 534 $content["all"] .= '<div id="mainBlock">'.$block["maintext"]."</div>\n"; 535 //footer DIV 536 if($block["footertext"] || $pagelayout['layout_footer_height']) { 537 $content["all"] .= ' <div id="footerBlock">'.$block["footertext"]."</div>\n"; 538 } 539 //contentContainer DIV end 540 if($pagelayout['additional_wrap_div']) { 541 $content["all"] .= "</div>"; 542 } 543 $content["all"] .= "</div>\n"; 544 545 break; 546 547 548 case 2: //create the page layout based only on the content of main block 549 $content["all"] = $block["maintext"]; 550 551 break; 552 553 } 554 555 } elseif ($aktion[2] == 1) { 556 557 //if print layout should be shown 558 $_print_tmpl = PRINT_PDF ? 'pdf' : 'print'; 559 $content['all'] = is_file(PHPWCMS_TEMPLATE.'inc_default/'.$_print_tmpl.'.tmpl') ? @file_get_contents(PHPWCMS_TEMPLATE.'inc_default/'.$_print_tmpl.'.tmpl') : '{CONTENT}<hr />{CURRENT_URL}'; 560 if(PRINT_PDF) { 561 $_print_settings = get_tmpl_section('PDF_SETTINGS', $content['all']); 562 $content['all'] = replace_tmpl_section('PDF_SETTINGS', $content['all']); 563 $_print_settings = parse_ini_str($_print_settings, false); 564 } 565 566 if($content['all']) { 567 $content["all"] = str_replace('{CURRENT_URL}', PHPWCMS_URL.'index.php'.returnGlobalGET_QueryString('htmlentities'), $content["all"]); 568 $content["all"] = str_replace('{CONTENT}', $block["maintext"], $content["all"]); 569 } else { 570 $content['all'] = $block["maintext"]; 571 } 572 573 } 574 575 // ------------------------------------------------------------- 576 577 // Render possible PHP Values in category or article keyword field 578 $content["struct"][$aktion[0]]["acat_info"] = render_PHPcode($content["struct"][$aktion[0]]["acat_info"]); 579 if(!empty($content["articles"][$aktion[1]]["article_keyword"]) && strpos($content["articles"][$aktion[1]]["article_keyword"], 'PHP') !== FALSE) { 580 $content["articles"][$aktion[1]]["article_keyword"] = render_PHPcode($content["articles"][$aktion[1]]["article_keyword"]); 581 } 582 583 // ------------------------------------------------------------- 584 585 // put in the complete rendered content 586 $content["all"] = str_replace('{CONTENT}', $content["main"], $content["all"]); 587 // put in custom rendered content 588 foreach($content['CB'] as $key => $value) { 589 //first check content of custom block in current template 590 if(isset($block['customblock_'.$key]) && $block['customblock_'.$key] !== '' && $value !== '') { 591 $value = str_replace('{'.$key.'}', $value, $block['customblock_'.$key]); 592 } 593 $content["all"] = str_replace('{'.$key.'}', $value, $content["all"]); 594 } 595 596 // check layout for list mode sections or detail view 597 if(strpos($content['all'], '_LIST_MODE')) { 598 $content['all'] = replace_tmpl_section( ($content['list_mode'] ? 'ELSE_LIST_MODE' : 'IF_LIST_MODE') , $content['all']); 599 $content['all'] = str_replace(array('<!--ELSE_LIST_MODE_START//-->', '<!--ELSE_LIST_MODE_END//-->', '<!--IF_LIST_MODE_START//-->', '<!--IF_LIST_MODE_END//-->'), '', $content['all']); 600 } 601 602 // search for specific article ID and or category ID and replace it 603 $content['all'] = str_replace('{CURRENT_ARTICLEID}', $aktion[1], $content['all']); 604 $content['all'] = str_replace('{CURRENT_CATEGORYID}', $aktion[0], $content['all']); 605 606 // search for level related replacement tags and replace it, sample: {LEVEL2_ID} 607 $content['all'] = preg_replace_callback('/\{LEVEL(\d+)_ID\}/', 'replace_level_id', $content['all']); 608 609 // {SHOW_CONTENT:MODE,id[,id[,...]]} 610 if( ! ( strpos($content["all"],'{SHOW_CONTENT:')===false ) ) { 611 $content["all"] = preg_replace('/\{SHOW_CONTENT:(.*?)\}/e', 'showSelectedContent("$1");', $content["all"]); 612 } 613 614 // ------------------------------------------------------------- 615 616 // include external PHP script (also normal HTML snippets) or return PHP var value 617 if(strpos($content["all"],'PHP') !== false) { 618 $content["all"] = render_PHPcode($content["all"]); 619 } 620 621 // ------------------------------------------------------------- 622 623 //breadcrumb replacement 624 if(strpos($content["all"],'{BREADCRUMB') !== false) { 625 $content["all"] = str_replace('{BREADCRUMB}', '{BREADCRUMB:0}', $content["all"]); 626 $replace = 'breadcrumb($content["cat_id"], $content["struct"], $1, $template_default["breadcrumb_spacer"]);'; 627 $content["all"] = preg_replace('/\{BREADCRUMB:(\d+)\}/e', $replace, $content["all"]); 628 } 629 630 // ------------------------------------------------------------- 631 632 // Simple row based navigation 633 if(strpos($content["all"],'{NAV_ROW') !== false) { 634 $content["all"] = str_replace('{NAV_ROW}', nav_level_row(0), $content["all"]); 635 $content["all"] = preg_replace('/\{NAV_ROW:(\w+|\d+):(0|1)\}/e',"nav_level_row('$1',$2);",$content["all"]); 636 } 637 638 // ------------------------------------------------------------- 639 640 // Simple Navigation table 641 if(strpos($content["all"],'{NAV_TABLE_SIMPLE}') !== false) { 642 $replace = nav_table_simple_struct($content["struct"], $content["cat_id"]); 643 $content["all"] = str_replace('{NAV_TABLE_SIMPLE}', $replace, $content["all"]); 644 } 645 646 // ------------------------------------------------------------- 647 648 // Left table based rollover navigation 649 if(strpos($content["all"],'{NAV_TABLE_COLUMN') !== false) { 650 $content["all"] = str_replace('{NAV_TABLE_COLUMN}', '{NAV_TABLE_COLUMN:0}', $content["all"]); 651 $replace = 'nav_table_struct($content["struct"], $content["cat_id"], "$1", $template_default["nav_table_struct"]);'; 652 $content["all"] = preg_replace('/\{NAV_TABLE_COLUMN:(\d+)\}/e', $replace, $content["all"]); 653 } 654 655 // ------------------------------------------------------------- 656 657 // some list based navigations 658 if(strpos($content["all"],'{NAV_LIST') !== false) { 659 660 //reads all active category IDs beginning with the current cat ID - without HOME 661 $content["cat_path"] = get_active_categories($content["struct"], $content["cat_id"]); 662 663 // some general list replacements first 664 $content["all"] = str_replace('{NAV_LIST}', '{NAV_LIST:0}', $content["all"]); 665 $content["all"] = str_replace('{NAV_LIST_TOP}', css_level_list($content["struct"], $content["cat_path"], 0, '', 1), $content["all"]); 666 $content["all"] = str_replace('{NAV_LIST_CURRENT}', css_level_list($content["struct"],$content["cat_path"],$content["cat_id"]), $content["all"]); 667 668 // build complete menu structure starting at a specific ID 669 // {NAV_LIST_UL:Parameter} Parameter: "menu_type, start_id, class_path, class_active, ul_id_name" 670 $content["all"] = preg_replace('/\{NAV_LIST_UL:(.*?)\}/e', 'buildCascadingMenu("$1");', $content["all"]); 671 672 // list based navigation starting at given level 673 $replace = 'nav_list_struct($content["struct"],$content["cat_id"],"$1", "$2");'; 674 $content["all"] = preg_replace('/\{NAV_LIST:(\d+):{0,1}(.*){0,1}\}/e', $replace, $content["all"]); 675 676 // List based navigation with Top Level - default settings 677 // creates a list styled top nav menu, + optional Home | {NAV_LIST_TOP:home_name:class_name} | default class name = list_top 678 $content["all"] = preg_replace('/\{NAV_LIST_TOP:(.*?):(.*?)\}/e', 'css_level_list($content["struct"], $content["cat_path"], 0, "$1", 1, "$2")', $content["all"]); 679 680 // List based navigation with Top Level - default settings 681 // creates a list styled nav menu of current level {NAV_LIST_CURRENT:1:back_name:class_name} | default class name = list_top 682 $content["all"] = preg_replace('/\{NAV_LIST_CURRENT:(\d+):(.*?):(.*?)\}/e', 'css_level_list($content["struct"],$content["cat_path"],$content["cat_id"],"$2","$1","$3")', $content["all"]); 683 } 684 685 // ------------------------------------------------------------- 686 687 // date replacement 688 if(strpos($content["all"],'{DATE_') !== false) { 689 $content["all"] = str_replace('{DATE_LONG}', international_date_format($template_default["date"]["language"], $template_default["date"]["long"]), $content["all"]); 690 $content["all"] = str_replace('{DATE_MEDIUM}', international_date_format($template_default["date"]["language"], $template_default["date"]["medium"]), $content["all"]); 691 $content["all"] = str_replace('{DATE_SHORT}', international_date_format($template_default["date"]["language"], $template_default["date"]["short"]), $content["all"]); 692 $content["all"] = str_replace('{DATE_ARTICLE}', international_date_format($template_default["date"]["language"], $template_default["date"]["article"], $content["article_date"]), $content["all"]); 693 } 694 695 // ------------------------------------------------------------- 696 697 // time replacement 698 if(strpos($content["all"],'{TIME_') !== false) { 699 $content["all"] = str_replace('{TIME_LONG}', date($template_default["time"]["long"]) , $content["all"] ); 700 $content["all"] = str_replace('{TIME_SHORT}', date($template_default["time"]["short"]), $content["all"] ); 701 $content["all"] = str_replace('{TIME_ARTICLE}', date($template_default["time"]["short"] , $content["article_date"]), $content["all"] ); 702 } 703 704 // ------------------------------------------------------------- 705 706 // replace custom search form input field and action with right target 707 if(strpos($content["all"],'###search_input_action') !== false) { 708 $content["all"] = str_replace('###search_input_field###', 'search_input_field', $content["all"]); 709 $content["all"] = str_replace('###search_input_value###', (empty($content["search_word"]) ? '' : $content["search_word"]), $content["all"]); 710 // create serahc form action 711 if(strpos($content["all"],'###search_input_action:') !== false) { 712 $content["all"] = preg_replace('/###search_input_action:(\d+)###/e','get_search_action("$1", $db);', $content["all"]); 713 } 714 } 715 716 // ------------------------------------------------------------- 717 718 // related articles based on keywords, inspired by Magnar Stav Johanssen 719 if(strpos($content["all"],'{RELATED:') !== false) { 720 if (!$no_content_for_this_page && !empty($content["articles"][$aktion[1]]["article_keyword"])) { 721 $related_keywords = $content["articles"][$aktion[1]]["article_keyword"]; 722 } else { 723 $related_keywords = ''; 724 } 725 $content["all"] = preg_replace('/\{RELATED:(\d+)\}/e','get_related_articles($related_keywords,$aktion[1],$template_default["related"],"$1",$db);',$content["all"]); 726 $content["all"] = preg_replace('/\{RELATED:(\d+):(.*?)\}/e','get_related_articles("$2",$aktion[1],$template_default["related"],"$1",$db);',$content["all"]); 727 } 728 729 // ------------------------------------------------------------- 730 731 // all new article list sorted by date 732 if(strpos($content["all"],'{NEW:') !== false) { 733 $content["all"] = preg_replace('/\{NEW:(\d+):{0,1}(\d+){0,1}\}/e','get_new_articles($template_default["news"],"$1","$2",$db);',$content["all"]); 734 } 735 736 // ------------------------------------------------------------- 737 738 // some more general parsing 739 $content["all"] = str_replace('{SITE}', PHPWCMS_URL, $content["all"]); 740 $content["all"] = str_replace('{RSSIMG}', $template_default["rss"]["image"], $content["all"]); 741 742 $content["all"] = html_parser($content["all"]); 743 744 $content["all"] = preg_replace_callback('/\[img=(\d+)(.*?){0,1}\](.*?)\[\/img\]/i', 'parse_images', $content["all"]); 745 $content["all"] = preg_replace_callback('/\[img=(\d+)(.*?){0,1}\]/i', 'parse_images', $content["all"]); 746 $content["all"] = preg_replace_callback('/\[download=(.*?)\/\]/i', 'parse_downloads', $content["all"]); 747 $content["all"] = preg_replace_callback('/\[download=(.*?)\](.*?)\[\/download\]/is', 'parse_downloads', $content["all"]); 748 749 // ------------------------------------------------------------- 750 751 // create link to articles for found keywords 752 $content["all"] = preg_replace('/\{KEYWORD:(.*?)\}/e', 'get_keyword_link("$1", $db);', $content["all"]); 753 //} 754 755 // ------------------------------------------------------------- 756 757 // include external HTML page but only part between <body></body> 758 $content["all"] = preg_replace_callback('/\{URL:(.*?)\}/i', 'include_url', $content["all"]); 759 760 // ------------------------------------------------------------- 761 762 // special browse the content links: UP, NEXT, PREVIOUS 763 // echo get_index_link_up('UP')." | ".get_index_link_prev('PREV',1).' | '.get_index_link_next('NEXT',1); 764 if(strpos($content["all"],'{BROWSE:') !== false) { 765 $content["all"] = preg_replace('/\{BROWSE:UP:(.*?)\}/e','get_index_link_up("$1");',$content["all"]); 766 $content["all"] = preg_replace('/\{BROWSE:NEXT:(.*?):(0|1)\}/e','get_index_link_next("$1",$2);',$content["all"]); 767 $content["all"] = preg_replace('/\{BROWSE:PREV:(.*?):(0|1)\}/e','get_index_link_prev("$1",$2);',$content["all"]); 768 } 769 770 // ------------------------------------------------------------- 771 772 // replace all "hardcoded" global replacement tags 773 774 if(count($content['globalRT'])) { 775 foreach($content['globalRT'] as $key => $value) { 776 if($key != '') { 777 $content["all"] = str_replace($key, $value, $content["all"]); 778 } 779 } 780 } 781 782 // ------------------------------------------------------------- 783 784 // add possible redirection code (article summary) to $block["htmlhead"]; 785 $block["htmlhead"] = render_PHPcode($block["htmlhead"]); 786 $block["htmlhead"] = $content["redirect"]["code"].$block["htmlhead"]."\n"; 787 788 // ------------------------------------------------------------- 789 790 791 if(!defined('PHPWCMS_ALIAS')) { 792 define('PHPWCMS_ALIAS', empty($content['struct'][ $content["cat_id"] ]['acat_alias']) ? '' : $content['struct'][ $content["cat_id"] ]['acat_alias'] ); 793 } 794 795 // try to include custom functions and replacement tags or what you want to do at this point of the script 796 // default dir: "phpwcms_template/inc_script/frontend_render"; only *.php files are allowed there 797 if($phpwcms["allow_ext_render"]) { 798 if(count($custom_includes = get_tmpl_files(PHPWCMS_TEMPLATE.'inc_script/frontend_render', 'php'))) { 799 foreach($custom_includes as $value) { 800 include_once(PHPWCMS_TEMPLATE.'inc_script/frontend_render/'.$value); 801 } 802 } 803 } 804 if(count($phpwcms['modules_fe_render'])) { 805 foreach($phpwcms['modules_fe_render'] as $value) { 806 include_once($value); 807 } 808 } 809 810 // insert description meta tag if not definied 811 if(empty($block['custom_htmlhead']['meta.description']) && !empty($content["struct"][$aktion[0]]["acat_info"]) && !stristr($block["htmlhead"], '"description"')) { 812 set_meta('description', $content["struct"][$aktion[0]]["acat_info"]); 813 } 814 // insert keywords meta tag if not definied 815 if(empty($block['custom_htmlhead']['meta.keywords']) && !empty($content['all_keywords']) && !stristr($block["htmlhead"], '"keywords"')) { 816 $content['all_keywords'] = convertStringToArray($content['all_keywords']); 817 if(count($content['all_keywords'])) { 818 set_meta('keywords', implode(', ', $content['all_keywords'])); 819 } 820 } 821 822 // replace Print URL 823 if(strpos($content["all"], '[PRINT') !== false) { 824 $GLOBALS['_getVar']['print'] = 1; 825 $content["all"] = str_replace('[PRINT]', '<a href="index.php'.returnGlobalGET_QueryString('htmlentities').'" target="_blank" rel="nofollow">', $content["all"]); 826 $content["all"] = str_replace('[/PRINT]', '</a>', $content["all"]); 827 $GLOBALS['_getVar']['print'] = 2; 828 $content["all"] = str_replace('[PRINT_PDF]', '<a href="index.php'.returnGlobalGET_QueryString('htmlentities').'" target="_blank" rel="nofollow">', $content["all"]); 829 $content["all"] = str_replace('[/PRINT_PDF]', '</a>', $content["all"]); 830 unset($GLOBALS['_getVar']['print']); 831 } 832 833 834 // Jérôme's Graphical Text MOD Coypright (C) 2004 835 if($phpwcms["gt_mod"]) { //enabled/disable GT MOD 836 require_once ('include/inc_module/mod_graphical_text/inc_front/gt.func.inc.php'); 837 } 838 839 // new $block['custom_htmlhead'] var (array) for usage in own rendering stuff. 840 // you will be able to use $GLOBALS['block']['custom_htmlhead']['myheadname'] 841 // always check if you want to use same head code only once 842 if(count($block['custom_htmlhead'])) { 843 $block["htmlhead"] .= implode(LF, $block['custom_htmlhead']).LF; 844 } 845 846 // some article related "global" replacement tags 847 if(isset($content['article_livedate'])) { 848 849 $content['all'] = render_cnt_template($content['all'], 'AUTHOR', html_specialchars($content['article_username'])); 850 $content['all'] = render_cnt_date($content['all'], $content["article_date"], $content['article_livedate'], $content['article_killdate']); 851 $content['all'] = render_cnt_template($content['all'], 'CATEGORY', $content['cat']); 852 853 } else { 854 855 $content['all'] = render_cnt_template($content['all'], 'AUTHOR', ''); 856 $content['all'] = render_cnt_date($content['all'], now(), now(), now()); 857 $content['all'] = render_cnt_template($content['all'], 'CATEGORY', html_specialchars($content['struct'][ $content['cat_id'] ]['acat_name'])); 858 859 } 860 861 // ------------------------------------------------------------- 862 863 //check for additional template based onLoad JavaScript Code 864 if($block["jsonload"]) { 865 if(empty($pagelayout["layout_jsonload"])) { 866 $pagelayout["layout_jsonload"] = ''; 867 } else { 868 $pagelayout["layout_jsonload"] .= ';'; 869 } 870 $pagelayout["layout_jsonload"] = str_replace(';;', ';', $pagelayout["layout_jsonload"] . $block["jsonload"] . ';'); 871 } 872 873 if(!empty($_GET['highlight'])) { 874 $highlight_words = clean_slweg(rawurldecode($_GET['highlight'])); 875 $highlight_words = explode(' ', $highlight_words); 876 $content['all'] = preg_replace_callback("/<!--SEARCH_HIGHLIGHT_START\/\/-->(.*?)<!--SEARCH_HIGHLIGHT_END\/\/-->/si", "pregReplaceHighlightWrapper", $content['all']); 877 } 878 $content['all'] = str_replace(array('<!--SEARCH_HIGHLIGHT_START//-->', '<!--SEARCH_HIGHLIGHT_END//-->'), '', $content['all']); 879 880 // render content part pagination 881 if(!empty($_CpPaginate)) { 882 883 $content['all'] = str_replace(array('<!--CP_PAGINATE_START//-->', '<!--CP_PAGINATE_END//-->'), '', $content['all']); 884 885 unset($_getVar['aid'], $_getVar['id']); 886 $content['CpPaginateNaviGET'] = returnGlobalGET_QueryString('htmlentities', array(), defined('PHPWCMS_ALIAS') ? array(PHPWCMS_ALIAS) : array()); 887 if(!empty($content['CpPaginateNaviGET']) && $content['CpPaginateNaviGET']{0} == '?') { 888 $content['CpPaginateNaviGET'] = '&'.substr($content['CpPaginateNaviGET'], 1); 889 } 890 891 // first build [1][2][3] paginate pages 892 if(strpos($content['all'], '{CP_PAGINATE}')) { 893 $content['CpPaginateNavi'] = array(); 894 foreach($content['CpPages'] as $key => $value) { 895 896 $content['CpPaginateNavi'][ $key ] = ' <a href="index.php?aid='.$aktion[1]; 897 if($key) { 898 $content['CpPaginateNavi'][ $key ] .= '-'.$key; 899 } 900 $content['CpPaginateNavi'][ $key ] .= $content['CpPaginateNaviGET'].'" class="'; // class="cpPaginate cpPaginatePage'.$value; 901 $content['CpPaginateNavi'][ $key ] .= ($key == $content['aId_CpPage']) ? 'cpPaginateActive' : 'cpPaginate'; 902 $content['CpPaginateNavi'][ $key ] .= '">'.$value.'</a>'; 903 904 } 905 $content['all'] = render_cnt_template($content['all'], 'CP_PAGINATE', implode(LF, $content['CpPaginateNavi'])); 906 } 907 908 // is there PREV 909 if(in_array($content['CpPages'][ $content['aId_CpPage'] ] - 1, $content['CpPages'])) { 910 911 $key = array_search($content['CpPages'][ $content['aId_CpPage'] ] - 1, $content['CpPages']); 912 $value = 'index.php?aid='.$aktion[1]; 913 if($key) { $value .= '-'.$key; } 914 $content['all'] = render_cnt_template($content['all'], 'CP_PAGINATE_PREV', $value); 915 916 } else { 917 $content['all'] = render_cnt_template($content['all'], 'CP_PAGINATE_PREV'); 918 } 919 920 // is there NEXT 921 if(in_array($content['CpPages'][ $content['aId_CpPage'] ] + 1, $content['CpPages'])) { 922 923 $key = array_search($content['CpPages'][ $content['aId_CpPage'] ] + 1, $content['CpPages']); 924 $value = 'index.php?aid='.$aktion[1]; 925 if($key) { $value .= '-'.$key; } 926 $content['all'] = render_cnt_template($content['all'], 'CP_PAGINATE_NEXT', $value); 927 928 } else { 929 $content['all'] = render_cnt_template($content['all'], 'CP_PAGINATE_NEXT'); 930 } 931 932 // search for content part pagination title menu 933 if(strpos($content['all'], '[CP_PAGINATE_MENU')) { 934 935 /** 936 * search for custom cp menu parameters 937 * 938 * [0] => item_prefix 939 * [1] => item_suffix 940 * [2] => active_class 941 * [3] => hide_active 942 * [4] => menu_prefix 943 * [5] => menu_suffix 944 */ 945 if( preg_match('/\[CP_PAGINATE_MENU:(.*?)\]/', $content['all'], $match) ) { 946 947 $content['all'] = str_replace($match[0], '[CP_PAGINATE_MENU]', $content['all']); 948 $content['CpTitleParams'] = explode('|', $match[1]); 949 if(!isset($content['CpTitleParams'][1])) { 950 $content['CpTitleParams'][1] = ''; 951 } 952 $content['CpTitleParams'][2] = empty($content['CpTitleParams'][2]) ? '' : trim($content['CpTitleParams'][2]); 953 $content['CpTitleParams'][3] = empty($content['CpTitleParams'][3]) ? 0 : 1 ; 954 $content['CpTitleParams'][4] = ''; 955 $content['CpTitleParams'][5] = ''; 956 957 } else { 958 959 $content['CpTitleParams'][0] = '<li>'; 960 $content['CpTitleParams'][1] = '</li>'; 961 $content['CpTitleParams'][2] = 'active'; 962 $content['CpTitleParams'][3] = 0; 963 $content['CpTitleParams'][4] = '<ul class="cpmenu">'; 964 $content['CpTitleParams'][5] = '</ul>'; 965 966 } 967 968 $content['CpTitleMenu'] = array(); 969 970 // cp menu items 971 foreach($content['CpPageTitles'] as $key => $value) { 972 973 $content['CpItem'] = '<a href="index.php?aid='.$aktion[1]; 974 975 if($key) { 976 $content['CpItem'] .= '-'.$key; 977 } 978 979 $content['CpItem'] .= $content['CpPaginateNaviGET'].'"'; 980 981 if($key == $content['aId_CpPage']) { 982 983 if(!empty($content['CpTitleParams'][3])) { 984 continue; 985 } 986 987 if(!empty($content['CpTitleParams'][2])) { 988 $content['CpItem'] .= ' class="'.$content['CpTitleParams'][2].'"'; 989 } 990 991 } 992 993 $content['CpItem'] .= '>'.html_specialchars($value).'</a>'; 994 $content['CpTitleMenu'][] = $content['CpTitleParams'][0] . $content['CpItem'] . $content['CpTitleParams'][1]; 995 } 996 997 // cp menu prefix/suffix 998 if(count($content['CpTitleMenu'])) { 999 $content['CpTitleMenu'][] = $content['CpTitleParams'][5]; 1000 array_unshift($content['CpTitleMenu'], $content['CpTitleParams'][4]); 1001 } 1002 1003 $content['all'] = render_cnt_template($content['all'], 'CP_PAGINATE_MENU', implode(LF, $content['CpTitleMenu'])); 1004 } 1005 1006 1007 } elseif(strpos($content['all'], 'CP_PAGINATE')) { 1008 1009 // remove CP_paginate block 1010 $content['all'] = replace_tmpl_section('CP_PAGINATE', $content['all']); 1011 1012 } 1013 1014 // check if print mode - then try to replace "no-print" sections from source 1015 if(strpos($content['all'], '--NO_PRINT')) { 1016 if($aktion[2] == 1) { 1017 1018 $content['all'] = replace_tmpl_section('NO_PRINT', $content['all']); 1019 $block['css'] = array('print_layout.css'); 1020 1021 } else { 1022 1023 $content['all'] = str_replace(array('<!--NO_PRINT_START//-->', '<!--NO_PRINT_END//-->'), '', $content['all']); 1024 1025 } 1026 } 1027 1028 // now clean up special sections in case user is logged in OR not 1029 if(strpos($content['all'], '--LOGGED_')) { 1030 1031 if( _getFeUserLoginStatus() ) { 1032 // if user IS logged in 1033 $content['all'] = str_replace(array('<!--LOGGED_IN_START//-->', '<!--LOGGED_IN_END//-->'), '', $content['all']); 1034 $content['all'] = replace_tmpl_section('LOGGED_OUT', $content['all']); 1035 } else { 1036 // user is NOT logged 1037 $content['all'] = str_replace(array('<!--LOGGED_OUT_START//-->', '<!--LOGGED_OUT_END//-->'), '', $content['all']); 1038 $content['all'] = replace_tmpl_section('LOGGED_IN', $content['all']); 1039 } 1040 1041 } 1042 1043 $content['all'] = preg_replace_callback('/\[HTML\](.*?)\[\/HTML\]/s', 'convert2html', $content['all'] ); 1044 $content['all'] = preg_replace_callback('/\[HTML_SPECIAL\](.*?)\[\/HTML_SPECIAL\]/s', 'convert2htmlspecialchars' , $content['all'] ); 1045 1046 // cleanup document to enhance XHTML Strict compatibility 1047 if($phpwcms['mode_XHTML'] == 2) { 1048 1049 $content['all'] = preg_replace(array('/ border="[0-9]+?"/', '/ target=".+?"/'), '', $content['all'] ); 1050 1051 } 1052 1053 // remove all useless replacement tags 1054 $content["pagetitle"] = sanitize_replacement_tags($content["pagetitle"]); 1055 1056 // now we should search all ?aid=123 and/or ?id=123 and replace'em by the real alias if available 1057 $match = array(); 1058 preg_match_all('/index.php\?(aid|id)=([\d\,]+)(["|&])/', $content['all'], $match); 1059 1060 if( isset($match[1]) && isset($match[2]) ) { 1061 1062 $all_id = array(); 1063 $sql_id = ''; 1064 1065 $all_aid = array(); 1066 $sql_aid = ''; 1067 1068 $old_style = false; 1069 1070 foreach($match[2] as $key => $value) { 1071 1072 if($match[1][$key] == 'id') { 1073 1074 if(strpos($match[2][$key], ',')) { 1075 1076 $old_style = true; 1077 1078 $this_id = 0; 1079 $this_aid = 0; 1080 1081 list($this_id, $this_aid) = explode(',', $match[2][$key]); 1082 1083 if( $this_aid = intval($this_aid) ) { 1084 1085 $all_aid[ $this_aid ] = $this_aid; 1086 1087 } elseif( $this_id = intval($this_id) ) { 1088 1089 $all_id[ $this_id ] = $this_id; 1090 1091 } 1092 1093 } else { 1094 1095 $all_id[ $match[2][$key] ] = $match[2][$key]; 1096 1097 } 1098 1099 } else { 1100 1101 $all_aid[ $match[2][$key] ] = $match[2][$key]; 1102 1103 } 1104 } 1105 1106 if(count($all_id)) { 1107 $sql_id = "SELECT 'id' AS alias_type, acat_id AS id, 0 AS aid, acat_alias AS alias FROM ".DB_PREPEND.'phpwcms_articlecat '; 1108 $sql_id .= 'WHERE acat_id IN (' . implode(',', $all_id) . ") AND acat_alias != ''"; 1109 } 1110 1111 if(count($all_aid)) { 1112 $sql_aid = "SELECT 'aid' AS alias_type, article_cid AS id, article_id AS aid, article_alias AS alias FROM ".DB_PREPEND.'phpwcms_article '; 1113 $sql_aid .= 'WHERE article_id IN (' . implode(',', $all_aid) . ") AND article_alias != ''"; 1114 } 1115 1116 if($sql_id && $sql_aid) { 1117 1118 $sql = '(' . $sql_id . ') UNION (' . $sql_aid . ')'; 1119 1120 } else { 1121 1122 $sql = $sql_id . $sql_aid ; 1123 1124 } 1125 1126 $match = _dbQuery($sql); 1127 1128 if(isset($match[0])) { 1129 1130 foreach($match as $value) { 1131 1132 $value['alias'] = html_specialchars($value['alias']); 1133 1134 if($value['alias_type'] == 'id') { 1135 1136 $content['all'] = str_replace('index.php?id=' . $value['id'] . '"', 'index.php?' . $value['alias'] . '"', $content['all']); 1137 $content['all'] = str_replace('index.php?id=' . $value['id'] . '&', 'index.php?' . $value['alias'] . '&', $content['all']); 1138 1139 } else { 1140 1141 $content['all'] = str_replace('index.php?aid=' . $value['aid'] . '"', 'index.php?' . $value['alias'] . '"', $content['all']); 1142 $content['all'] = str_replace('index.php?aid=' . $value['aid'] . '&', 'index.php?' . $value['alias'] . '&', $content['all']); 1143 1144 } 1145 1146 // search also for id=0,0,... 1147 if( $old_style == true ) { 1148 1149 $value['id'] = $value['id'] . ',' . $value['aid'] . ',0,1,0,0'; 1150 1151 $content['all'] = str_replace('index.php?id=' . $value['id'] . '"', 'index.php?' . $value['alias'] . '"', $content['all']); 1152 $content['all'] = str_replace('index.php?id=' . $value['id'] . '&', 'index.php?' . $value['alias'] . '&', $content['all']); 1153 1154 } 1155 1156 } 1157 1158 } 1159 1160 } 1161 1162 if(!empty($phpwcms['i18n_parse'])) { 1163 $content['all'] = i18n_substitute_text($content['all']); 1164 $content["pagetitle"] = i18n_substitute_text($content['pagetitle']); 1165 } 1166 1167 1168 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Dec 30 05:55:15 2009 | Cross-referenced by PHPXref 0.7 |