[ Index ] |
PHP Cross Reference of phpwcms V1.5.0 _r431 (28.01.12) |
[Summary view] [Print] [Text view]
1 <?php 2 /************************************************************************************* 3 Copyright notice 4 5 (c) 2002-2012 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 //enhance you custom frontend funtions here 25 26 // ------------------------------------------------------------- 27 28 29 // added by jens for content type 89: poll 30 function showPollImage($image, $zoom = 0) { 31 32 $image_border = ' border="'.intval($GLOBALS["template_default"]["article"]["imagelist_border"]).'"'; 33 if(empty($GLOBALS["template_default"]["article"]["imagelist_imgclass"])) { 34 $image_imgclass = ''; 35 } else { 36 $image_imgclass = ' class="'.$GLOBALS["template_default"]["article"]["imagelist_imgclass"].'"'; 37 } 38 39 $thumb_image = get_cached_image( 40 array( 41 "target_ext" => $image[3], 42 "image_name" => $image[2].'.'.$image[3], 43 "max_width" => $image[4], 44 "max_height" => $image[5], 45 "thumb_name" => md5($image[2].$image[4].$image[5].$GLOBALS['phpwcms']["sharpen_level"]) 46 ) 47 ); 48 49 if($zoom) { 50 $zoominfo = get_cached_image( 51 array( 52 "target_ext" => $image[3], 53 "image_name" => $image[2] . '.' . $image[3], 54 "max_width" => $GLOBALS['phpwcms']["img_prev_width"], 55 "max_height" => $GLOBALS['phpwcms']["img_prev_height"], 56 "thumb_name" => md5($image[2].$GLOBALS['phpwcms']["img_prev_width"].$GLOBALS['phpwcms']["img_prev_height"].$GLOBALS['phpwcms']["sharpen_level"]) 57 ) 58 ); 59 } 60 61 $list_img_temp = '<img src="'.PHPWCMS_IMAGES.$thumb_image[0].'" '.$thumb_image[3].$image_border.$image_imgclass.' />'; 62 63 if($zoom && !empty($zoominfo)) { 64 // if click enlarge the image 65 $open_popup_link = 'image_zoom.php?'.getClickZoomImageParameter($zoominfo[0].'?'.$zoominfo[3]); 66 $open_link = $open_popup_link; 67 $return_false = 'return false;'; 68 69 $html .= "<a href=\"".$open_link."\" onclick=\"checkClickZoom();clickZoom('".$open_popup_link."','previewpic','width="; 70 $html .= $zoominfo[1].",height=".$zoominfo[2]."');".$return_false.'">'; 71 $html .= $list_img_temp."</a>"; 72 } else { 73 // if not click enlarge 74 $html .= $list_img_temp; 75 } 76 return $html; 77 } 78 79 // taken from http://www.php.net/manual/en/function.utf8-decode.php 80 // vpribish at shopping dot com, 10-Sep-2004 08:55 81 function utf2html($str) { 82 $ret = ''; 83 $max = strlen($str); 84 $last = 0; // keeps the index of the last regular character 85 for ($i=0; $i < $max; $i++) { 86 $c = $str{$i}; 87 $c1 = ord($c); 88 if ($c1>>5 == 6) { // 110x xxxx, 110 prefix for 2 bytes unicode 89 $ret .= substr($str, $last, $i-$last); // append all the regular characters we've passed 90 $c1 &= 31; // remove the 3 bit two bytes prefix 91 $c2 = ord($str{++$i}); // the next byte 92 $c2 &= 63; // remove the 2 bit trailing byte prefix 93 $c2 |= (($c1 & 3) << 6); // last 2 bits of c1 become first 2 of c2 94 $c1 >>= 2; // c1 shifts 2 to the right 95 $ret .= "&#" . ($c1 * 100 + $c2) . ";"; // this is the fastest string concatenation 96 $last = $i+1; 97 } 98 } 99 return $ret . substr($str, $last, $i); // append the last batch of regular characters 100 } 101 102 // http://www.evilwalrus.com/viewcode.php?codeEx=627 103 function is_date($PASSED,$TXT_DATE_FORMAT='m/d/Y') { 104 $lib_import_datearr=array(); 105 $lib_import_datearr['h'] = 2; // 01-12 - time - hours 12 106 $lib_import_datearr['H'] = 2; // 00-23 - time - hours 24 107 $lib_import_datearr['g'] = 0; // 1-12 - time - hours 12 108 $lib_import_datearr['G'] = 0; // 0-23 - time - hours 24 109 $lib_import_datearr['i'] = 2; // 00-59 - time - minutes 110 $lib_import_datearr['k'] = 0; // 0-59 - time - minutes ** k - non standard code. 111 $lib_import_datearr['s'] = 2; // 00-59 - time - seconds 112 $lib_import_datearr['x'] = 0; // 0-59 - time - seconds ** x - non standard code. 113 $lib_import_datearr['a'] = 2; // am/pm - time 114 $lib_import_datearr['A'] = 2; // AM/PM - time 115 $lib_import_datearr['j'] = 0; // 1-31 - date - day 116 $lib_import_datearr['d'] = 2; // 01-31 - date - day 117 $lib_import_datearr['n'] = 0; // 1-12 - date - month 118 $lib_import_datearr['m'] = 2; // 01-12 - date - month 119 $lib_import_datearr['y'] = 2; // 04 - date - year 120 $lib_import_datearr['Y'] = 4; // 2004 - date - year 121 $PASSED = trim($PASSED); // No spaces at beginning or end of date value. 122 $TXT_DATE_FORMAT = trim($TXT_DATE_FORMAT); // No spaces at beginning or end of formatter string 123 $store_arr = array(); // Storage array 124 $lastchar = ""; // Badly named. This really stores the data chunk we are working with 125 $dte_frmt_lstchr = ""; // Current date formatting character 126 $dte_frmt_idx = 0; // Index of where we are in date formatting rule string 127 $bln_formatter = FALSE; // Boolean. Is the formatting character a value or a place holder (ie 'm' vs '/' or ':') 128 $bln_twelve_hour_cycle = FALSE; // Boolean. Whether or not stored hours are 1-12 or 0-23. TRUE = 1-12 129 for ($i=0;$i < strlen($PASSED); $i++) { 130 $dte_frmt_lstchr=substr($TXT_DATE_FORMAT, $dte_frmt_idx,1); // Get first date formatting character 131 $dte_frmt_idx ++; // Move index for format string ahead one. 132 if ((is_int($dte_frmt_lstchr) || is_string($dte_frmt_lstchr)) && array_key_exists($dte_frmt_lstchr, $lib_import_datearr)) { // See if this formatting character is a date value or a spacer value of some sort 133 $bln_formatter = FALSE; // This value needs to be parsed for the date value 134 } 135 else { 136 $bln_formatter = TRUE; // This is a placeholder character 137 } 138 // *** Get the value 139 if ($bln_formatter) { // Just get the character and test for equivalence 140 $lastchar = substr($PASSED,$i,1); 141 if ($lastchar!=$dte_frmt_lstchr) { // The current character does not match the expected formatting character. Crash and Burn! 142 $store_arr = FALSE; // Set the return value to false 143 $i = strlen($PASSED)+1; // Break the loop 144 } 145 } // END get character value 146 else { // Get the date value 147 switch ($lib_import_datearr[$dte_frmt_lstchr]) { // How many characters to get? Remember, type 0 means you must find the end. (As in month, 1 or 2 characters?). 148 case 0: // Zero is for those with either 1 or 2 places. Rule: if 2nd character is also a number, it belongs to the item. 149 $lastchar = substr($PASSED,$i,1); 150 if ($i+1 < strlen($PASSED)) { // are there more characters? 151 if (is_numeric(substr($PASSED,$i+1,1))) { $lastchar=$lastchar.substr($PASSED,$i+1,1); $i++; } // tack on next character. Move in string pointer forward 1 152 } 153 switch ($dte_frmt_lstchr) { 154 case "j": 155 if (!is_numeric($lastchar)) { $store_arr = FALSE; $i = strlen($PASSED)+1; } // The the value. Must be a number. Break out 156 else { $store_arr['mday']=$lastchar; } // assign the value to the array 157 break; 158 case "n": 159 if (!is_numeric($lastchar)) { $store_arr = FALSE; $i = strlen($PASSED)+1; } // The the value. Must be a number. Break out 160 else { $store_arr['mon']=$lastchar; } // assign the value to the array 161 break; 162 case "k": 163 if (!is_numeric($lastchar)) { $store_arr = FALSE; $i = strlen($PASSED)+1; } // The the value. Must be a number. Break out 164 else { $store_arr['minutes']=$lastchar; } // assign the value to the array 165 break; 166 case "x": 167 if (!is_numeric($lastchar)) { $store_arr = FALSE; $i = strlen($PASSED)+1; } // The the value. Must be a number. Break out 168 else { $store_arr['seconds']=$lastchar; } // assign the value to the array 169 break; 170 case "g": 171 if (!is_numeric($lastchar)) { $store_arr = FALSE; $i = strlen($PASSED)+1; } // The the value. Must be a number. Break out 172 else { $store_arr['hours']=$lastchar; $bln_twelve_hour_cycle= TRUE; } // assign the value to the array 173 break; 174 case "G": 175 if (!is_numeric($lastchar)) { $store_arr = FALSE; $i = strlen($PASSED)+1; } // The the value. Must be a number. Break out 176 else { $store_arr['hours']=$lastchar; $bln_twelve_hour_cycle= FALSE; } // assign the value to the array 177 break; 178 } 179 break; 180 case 2: 181 $lastchar = substr($PASSED,$i,2); 182 if (strlen($lastchar)!=2) { // Crap. We ran off the end of the string. Error out 183 $store_arr = FALSE; // Set the return value to false 184 $i = strlen($PASSED)+1; // Break the loop 185 } 186 else { // Right length. Test Type 187 $i++; // Move in string pointer forward 1 188 switch ($dte_frmt_lstchr) { 189 case "A": 190 if (strtoupper($lastchar)!="AM" && strtoupper($lastchar)!="PM") { $store_arr = FALSE; $i = strlen($PASSED)+1; } // Invalid AM/PM. Crash and burn 191 else { $store_arr['ampm']=strtoupper($lastchar); } // assign the value to the array 192 break; 193 case "a": 194 if (strtoupper($lastchar)!="AM" && strtoupper($lastchar)!="PM") { $store_arr = FALSE; $i = strlen($PASSED)+1; } // Invalid AM/PM. Crash and burn 195 else { $store_arr['ampm']=strtoupper($lastchar); } // assign the value to the array 196 break; 197 case "H": 198 if (!is_numeric($lastchar)) { $store_arr = FALSE; $i = strlen($PASSED)+1; } // The the value. Must be a number. Break out 199 else { $store_arr['hours']=$lastchar; $bln_twelve_hour_cycle= FALSE; } // assign the value to the array 200 break; 201 case "h": 202 if (!is_numeric($lastchar)) { $store_arr = FALSE; $i = strlen($PASSED)+1; } // The the value. Must be a number. Break out 203 else { $store_arr['hours']=$lastchar; $bln_twelve_hour_cycle= TRUE; } // assign the value to the array 204 break; 205 case "i": 206 if (!is_numeric($lastchar)) { $store_arr = FALSE; $i = strlen($PASSED)+1; } // The the value. Must be a number. Break out 207 else { $store_arr['minutes']=$lastchar; } // assign the value to the array 208 break; 209 case "s": 210 if (!is_numeric($lastchar)) { $store_arr = FALSE; $i = strlen($PASSED)+1; } // The the value. Must be a number. Break out 211 else { $store_arr['seconds']=$lastchar; } // assign the value to the array 212 break; 213 case "d": 214 if (!is_numeric($lastchar)) { $store_arr = FALSE; $i = strlen($PASSED)+1; } // The the value. Must be a number. Break out 215 else { $store_arr['mday']=$lastchar; } // assign the value to the array 216 break; 217 case "m": 218 if (!is_numeric($lastchar)) { $store_arr = FALSE; $i = strlen($PASSED)+1; } // The the value. Must be a number. Break out 219 else { $store_arr['mon']=$lastchar; } // assign the value to the array 220 break; 221 case "y": 222 if (!is_numeric($lastchar)) { $store_arr = FALSE; $i = strlen($PASSED)+1; } // The the value. Must be a number. Break out 223 else { 224 if ($lastchar<70) { $lastchar="20".$lastchar; } 225 else { $lastchar="19".$lastchar; } 226 $store_arr['year']=$lastchar; 227 } // assign the value to the array 228 break; 229 } 230 } 231 break; 232 case 4: 233 $lastchar = substr($PASSED,$i,4); 234 if (strlen($lastchar)!=4) { // Crap. We ran off the end of the string. Error out 235 $store_arr = FALSE; // Set the return value to false 236 $i = strlen($PASSED)+1; // Break the loop 237 } 238 else { // Right length. Test Type 239 $i=$i+3; // Move in string pointer forward 3 240 switch ($dte_frmt_lstchr) { 241 case "Y": 242 if (!is_numeric($lastchar)) { $store_arr = FALSE; $i = strlen($PASSED)+1; } // The the value. Must be a number. Break out 243 else { $store_arr['year']=$lastchar; } // assign the value to the array 244 break; 245 } 246 } 247 break; 248 } // END switch 249 } // END else get the date value 250 } 251 if (isset($store_arr['hours'])) { // are hours are set? 252 if ($bln_twelve_hour_cycle) { // If the recieved data was 12-hour cycle, we may need to test for PM and do some math! 253 if (isset($store_arr['ampm'])) { 254 if ($store_arr['ampm']=="PM") { // Is it PM? If so test to see if hour is set 255 $store_arr['hours']=$store_arr['hours']+12; // The 12 hour date was in PM. Example 11 pm really is 11+12 or 23! 256 } 257 else { // This is AM. Only 1 test needs to be done: 12 am! 258 if ($store_arr['hours']==12) { $store_arr['hours']=0; } // 12am in 24 cycle is really 0 (0-23!) 259 } 260 } 261 } 262 } 263 if (isset($store_arr['ampm'])) { 264 unset($store_arr['ampm']); 265 } 266 return $store_arr; 267 } 268 269 // http://de3.php.net/manual/en/function.is-numeric.php 270 // kiss dot pal at expert-net dot hu 271 // 05-Jan-2005 09:13 272 function is_float_ex($pNum) { 273 $num_chars = "0123456789.,+-"; 274 if(strlen(trim($pNum)) == 0) { // empty $pNum -> null 275 return false; 276 } else { 277 $i = 0; 278 $f = 1; // modify 279 $v = strlen($num_chars) - $f; 280 while(($i < strlen($pNum)) && ($v >= 0)) { 281 $v=strlen($num_chars)-$f; 282 while(($v >= 0) && ($num_chars[$v] <> $pNum[$i])) { 283 $v--; 284 } 285 if($f==1) { // Only first item + vagy - 286 $f=3; 287 } 288 if(($pNum[$i] == '.') || ($pNum[$i] == ',')) { 289 $f=5; 290 } 291 $i++; 292 } 293 return ($v < 0) ? false : true; 294 } 295 } 296 297 298 /* 299 * {SHOW_CONTENT} 300 * thanks to Jens Zetterström who has initiated this in 2005 301 * Shows the content of the article content part with the specified id. 302 * use it {SHOW_CONTENT:MODE,id[,id[,...]]} 303 * where MODE is what should returned 304 * and id is the corresponding ID 305 * MODE options: 306 * CP - list of Content Parts | id = id of the content part, one or more possible, comma seperated. 307 * CPA - ascending list of Content Parts but based on selected article | id = id of article, comma seperated 308 * CPAD - same as CPA, but descending 309 * AS - list of Article Summaries | id = id of articles, comma separated 310 * CAS - list of Article Summaries | id = id of structure level, comma separated 311 */ 312 function showSelectedContent($param='') { 313 314 global $template_default; 315 global $db; 316 global $content; 317 global $block; 318 global $phpwcms; 319 global $aktion; 320 321 $topcount = 999999; 322 $template = ''; 323 324 if($cp = explode(',', $param)) { 325 $mode = strtoupper(trim($cp[0])); 326 if(substr($mode, 0, 2) == 'AS') { 327 $mode = explode('|', $cp[0]); 328 if(isset($mode[1])) { 329 $mode[1] = trim($mode[1]); 330 if(is_numeric($mode[1])) { 331 $topcount = intval($mode[1]); 332 } elseif(empty($mode[2]) && strlen($mode[1]) > 4 && ($mode[1] == 'default' || is_file(PHPWCMS_TEMPLATE.'inc_cntpart/articlesummary/list/'.$mode[1]))) { 333 $template = $mode[1]; 334 } 335 } 336 if(isset($mode[2])) { 337 $mode[2] = trim($mode[2]); 338 if(is_numeric($mode[2])) { 339 $topcount = intval($mode[2]); 340 } elseif(strlen($mode[2]) > 4 && ($mode[2] == 'default' || is_file(PHPWCMS_TEMPLATE.'inc_cntpart/articlesummary/list/'.$mode[2]))) { 341 $template = $mode[2]; 342 } 343 } 344 $mode = strtoupper(trim($mode[0])); 345 if(isset($cp[1])) { // now check if 346 $cp[1] = trim($cp[1]); 347 if(!is_numeric($cp[1])) { 348 switch($cp[1]) { 349 case 'new': $cp = array('new' => 1); break; 350 case 'random': $cp = array('random' => 1); break; 351 case 'related': if(isset($cp[2])) { 352 unset($cp[0], $cp[1]); 353 $related = array(); 354 foreach($cp as $value) { 355 $related[] = "article_keyword LIKE '%".aporeplace(strtoupper(trim($value)))."%'"; 356 } 357 $cp = array('related' => 1); break; 358 } 359 360 default: $cp = array('new' => 1); 361 } 362 } 363 } 364 } 365 unset($cp[0]); 366 foreach($cp as $key => $value) { 367 $value = intval($value); 368 if(!$value) { 369 unset($cp[$key]); 370 } else { 371 $cp[$key] = $value; 372 } 373 } 374 if(!is_array($cp) || !count($cp)) { 375 return ''; 376 } 377 } else { 378 // oh no ID given, end function 379 return ''; 380 } 381 382 $CNT_TMP = ''; 383 384 if(substr($mode, 0, 2) == 'AS') { 385 386 if(substr($mode, -1) == 'P') { 387 $mode = substr($mode, 0, -1); 388 $priorize = 'article_priorize DESC, '; 389 } else { 390 $priorize = ''; 391 } 392 393 switch($mode) { 394 395 case 'ASL': $sort = $priorize.'article_begin ASC'; break; // sorted by livedate ascending 396 case 'ASLD': $sort = $priorize.'article_begin DESC'; break; // sorted by livedate descending 397 case 'ASK': $sort = $priorize.'article_end ASC'; break; // sorted by killdate ascending 398 case 'ASKD': $sort = $priorize.'article_end DESC'; break; // sorted by killdate descending 399 case 'ASC': $sort = $priorize.'article_tstamp ASC'; break; // sorted by change date ascending 400 case 'ASCD': $sort = $priorize.'article_tspamp DESC'; break; // sorted by change date descending 401 case 'ASR': $sort = 'RAND()'; break; // random sort 402 default: $sort = ''; 403 404 } 405 406 $CNT_TMP = list_articles_summary( get_article_data( $cp, $topcount, $sort ) , $topcount, $template); 407 408 409 } elseif($mode == 'CP' || $mode == 'CPA' || $mode == 'CPAD') { 410 411 $sort = ($mode=='CPAD') ? ' DESC' : ''; //means ASCENDING 412 413 foreach($cp as $value) { 414 415 if($mode == 'CP') { 416 // content part listing 417 $sql = "SELECT * FROM " . DB_PREPEND . "phpwcms_articlecontent "; 418 $sql .= "INNER JOIN " . DB_PREPEND . "phpwcms_article ON "; 419 $sql .= DB_PREPEND . "phpwcms_article.article_id = " . DB_PREPEND . "phpwcms_articlecontent.acontent_aid "; 420 $sql .= "WHERE acontent_id = " . $value . " AND acontent_visible = 1 "; 421 422 if( !FEUSER_LOGIN_STATUS ) { 423 $sql .= 'AND acontent_granted=0 '; 424 } 425 426 $sql .= "AND acontent_trash = 0 AND " . DB_PREPEND . "phpwcms_article.article_deleted=0 AND "; 427 $sql .= DB_PREPEND."phpwcms_article.article_begin < NOW() AND " . DB_PREPEND . "phpwcms_article.article_end > NOW() "; 428 $sql .= "LIMIT 1"; 429 430 } else { 431 // content parts based on article ID 432 $sql = "SELECT * FROM ".DB_PREPEND."phpwcms_articlecontent "; 433 $sql .= "WHERE acontent_aid=". $value." AND acontent_visible=1 AND acontent_trash=0 "; 434 435 if( !FEUSER_LOGIN_STATUS ) { 436 $sql .= 'AND acontent_granted=0 '; 437 } 438 439 $sql .= "ORDER BY acontent_sorting".$sort.", acontent_id"; 440 441 } 442 443 if($cresult = mysql_query($sql, $db)) { 444 while($crow = mysql_fetch_assoc($cresult)) { 445 446 if($crow["acontent_type"] == 30 && !isset($phpwcms['modules'][$crow["acontent_module"]])) { 447 continue; 448 } 449 450 if($crow["acontent_type"] == 24) { 451 // first retrieve alias ID information and settings 452 $crow = getContentPartAlias($crow); 453 } 454 455 $space = getContentPartSpacer($crow["acontent_before"], $crow["acontent_after"]); 456 457 // Space before 458 $CNT_TMP .= $space['before']; 459 460 // set frontend edit link 461 $CNT_TMP .= getFrontendEditLink('CP', $crow['acontent_aid'], $crow['acontent_id']); 462 463 // include content part code section 464 if($crow["acontent_type"] != 30) { 465 466 include(PHPWCMS_ROOT.'/include/inc_front/content/cnt' . $crow["acontent_type"] . '.article.inc.php'); 467 468 } elseif($crow["acontent_type"] == 30 && file_exists($phpwcms['modules'][$crow["acontent_module"]]['path'].'inc/cnt.article.php')) { 469 470 $CNT_TMP .= getFrontendEditLink('module', $phpwcms['modules'][$crow["acontent_module"]]['name']); 471 472 // now try to include module content part code 473 include($phpwcms['modules'][$crow["acontent_module"]]['path'].'inc/cnt.article.php'); 474 475 } 476 477 //check if top link should be shown 478 $CNT_TMP .= getContentPartTopLink($crow["acontent_top"]); 479 480 //Maybe content part ID should b used inside templates or for something different 481 $CNT_TMP = str_replace( array('[%CPID%]', '{CPID}'), $crow["acontent_id"], $CNT_TMP ); 482 483 // trigger content part functions 484 $CNT_TMP = trigger_cp($CNT_TMP, $crow); 485 486 // Space after 487 $CNT_TMP .= $space['after']; 488 489 } 490 mysql_free_result($cresult); 491 } 492 } 493 } 494 495 if(empty($phpwcms["allow_cntPHP_rt"])) { 496 $CNT_TMP = remove_unsecure_rptags($CNT_TMP); 497 } 498 return $CNT_TMP; 499 } 500 501 function getContentPartSpacer($space_before=0, $space_after=0) { 502 503 if(!$space_before && !$space_after) { 504 return array('before' => '', 'after' => ''); 505 506 } elseif($space_before && $space_after) { 507 return array('before' => '<div style="margin:' .$space_before. 'px 0 ' .$space_after. 'px 0; padding:0;">', 'after' => '</div>'); 508 509 } elseif($space_before && !$space_after) { 510 return array('before' => '<div style="margin:' .$space_before. 'px 0 0 0;padding:0;clear:both;"></div>', 'after' => ''); 511 512 } else { 513 return array('before' => '', 'after' => '<div style="margin:0 0' .$space_after. 'px 0;padding:0;clear:both;"></div>'); 514 515 } 516 } 517 518 function getContentPartTopLink($param=0) { 519 global $template_default; 520 $toplink = ''; 521 if($param) { 522 if($template_default["article"]["top_sign_before"].$template_default["article"]["top_sign_after"]) { 523 $toplink .= $template_default["article"]["top_sign_before"]; 524 $toplink .= '<a href="#top">'.$template_default["article"]["top_sign"].'</a>'; 525 $toplink .= $template_default["article"]["top_sign_after"]; 526 } else{ 527 $toplink .= '<br /><a href="#top">' . $template_default["article"]["top_sign"] . '</a>'; 528 } 529 } 530 return $toplink; 531 } 532 533 function getContentPartAlias($crow) { 534 global $db; 535 $alias = unserialize($crow["acontent_form"]); 536 if(!empty($alias['alias_ID'])) { 537 $alias['alias_ID'] = intval($alias['alias_ID']); 538 $sql_alias = "SELECT * FROM ".DB_PREPEND."phpwcms_articlecontent WHERE acontent_id="; 539 $sql_alias .= $alias['alias_ID'] . " AND acontent_trash=0 "; 540 if( !FEUSER_LOGIN_STATUS ) { 541 $sql_alias .= 'AND acontent_granted=0 '; 542 } 543 $sql_alias .= "LIMIT 1"; 544 if($alias_result = mysql_query($sql_alias, $db)) { 545 if($alias_row = mysql_fetch_assoc($alias_result)) { 546 if(empty($alias['alias_block'])) { 547 $alias_row['acontent_block'] = $crow['acontent_block']; 548 } 549 if(empty($alias['alias_spaces'])) { 550 $alias_row['acontent_before'] = $crow['acontent_before']; 551 $alias_row['acontent_after'] = $crow['acontent_after']; 552 } 553 if(empty($alias['alias_title'])) { 554 $alias_row['acontent_title'] = $crow['acontent_title']; 555 $alias_row['acontent_subtitle'] = $crow['acontent_subtitle']; 556 } 557 if(empty($alias['alias_toplink'])) { 558 $alias_row['acontent_top'] = $crow['acontent_top']; 559 } 560 $crow = $alias_row; 561 } 562 mysql_free_result($alias_result); 563 } 564 } 565 return $crow; 566 } 567 568 569 function get_article_data($article_id, $limit=0, $sort='', $where='') { 570 571 if(is_string($article_id)) { 572 $article_id = explode(',', $article_id); 573 } 574 if(is_array($article_id) && count($article_id)) { 575 foreach($article_id as $value) { 576 $value = intval($value); 577 if(!$value) { 578 unset($article_id); 579 } 580 } 581 } 582 if(!is_array($article_id) || !count($article_id)) { 583 return array(); 584 } 585 $article_id = array_unique($article_id); 586 587 $sql = 'SELECT *, UNIX_TIMESTAMP(article_tstamp) AS article_date, '; 588 $sql .= "UNIX_TIMESTAMP(article_begin) AS article_livedate, "; 589 $sql .= "UNIX_TIMESTAMP(article_end) AS article_killdate "; 590 $sql .= 'FROM '.DB_PREPEND.'phpwcms_article '; 591 $sql .= 'WHERE '; 592 593 // VISIBLE_MODE: 0 = frontend (all) mode, 1 = article user mode, 2 = admin user mode 594 switch(VISIBLE_MODE) { 595 case 0: $sql .= 'article_public=1 AND article_aktiv=1 AND '; 596 break; 597 case 1: $sql .= 'article_uid='.$_SESSION["wcs_user_id"].' AND '; 598 break; 599 //case 2: admin mode no additional neccessary 600 } 601 $sql .= 'article_deleted=0 AND article_begin < NOW() AND article_end > NOW() AND '; 602 603 if($where === '') { 604 $sql .= 'article_id IN (' . implode( ',', $article_id ) . ') '; 605 } else { 606 $sql .= ' ' . $where . ' '; 607 } 608 $sql .= 'GROUP BY article_id '; 609 if($sort) { 610 $sql .= 'ORDER BY '.$sort; 611 } 612 if($limit) { 613 $sql .= ' LIMIT '.$limit; 614 } 615 616 $data = array(); 617 $result = _dbQuery($sql); 618 619 if(!is_array($result)) { 620 return array(); 621 } 622 623 if($sort == '') { 624 foreach($article_id as $row) { 625 $data[$row] = ''; 626 } 627 } 628 629 foreach($result as $row) { 630 631 $data[$row["article_id"]] = array( 632 "article_id" => $row["article_id"], 633 "article_cid" => $row["article_cid"], 634 "article_title" => $row["article_title"], 635 "article_subtitle" => $row["article_subtitle"], 636 "article_keyword" => $row["article_keyword"], 637 "article_summary" => $row["article_summary"], 638 "article_redirect" => $row["article_redirect"], 639 "article_date" => $row["article_date"], 640 "article_username" => $row["article_username"], 641 "article_sort" => $row["article_sort"], 642 "article_notitle" => $row["article_notitle"], 643 "article_created" => $row["article_created"], 644 "article_image" => @unserialize($row["article_image"]), 645 "article_timeout" => $row["article_cache"], 646 "article_nosearch" => $row["article_nosearch"], 647 "article_nositemap" => $row["article_nositemap"], 648 "article_aliasid" => $row["article_aliasid"], 649 "article_headerdata"=> $row["article_headerdata"], 650 "article_morelink" => $row["article_morelink"], 651 "article_begin" => $row["article_begin"], 652 "article_end" => $row["article_end"], 653 "article_alias" => $row["article_alias"], 654 'article_livedate' => $row["article_livedate"], 655 'article_killdate' => $row["article_killdate"] 656 ); 657 // now check for article alias ID 658 if($row["article_aliasid"]) { 659 $aid = $row["article_id"]; 660 $alias_sql = "SELECT *, UNIX_TIMESTAMP(article_tstamp) AS article_date, "; 661 $alias_sql .= "UNIX_TIMESTAMP(article_begin) AS article_livedate, "; 662 $alias_sql .= "UNIX_TIMESTAMP(article_end) AS article_killdate "; 663 $alias_sql .= "FROM ".DB_PREPEND."phpwcms_article "; 664 $alias_sql .= "WHERE article_deleted=0 AND article_id=".intval($row["article_aliasid"]); 665 if(!$row["article_headerdata"]) { 666 switch(VISIBLE_MODE) { 667 case 0: $alias_sql .= " AND article_public=1 AND article_aktiv=1"; 668 break; 669 case 1: $alias_sql .= " AND article_uid=".$_SESSION["wcs_user_id"]; 670 break; 671 } 672 $alias_sql .= " AND article_begin < NOW() AND article_end > NOW()"; 673 } 674 $alias_sql .= " AND article_deleted=0 LIMIT 1"; 675 $alias_result = _dbQuery($alias_sql); 676 foreach($alias_result as $alias_row) { 677 $data[$aid]["article_id"] = $alias_row["article_id"]; 678 // use alias article header data 679 if(!$row["article_headerdata"]) { 680 $data[$aid]["article_title"] = $alias_row["article_title"]; 681 $data[$aid]["article_subtitle"] = $alias_row["article_subtitle"]; 682 $data[$aid]["article_keyword"] = $alias_row["article_keyword"]; 683 $data[$aid]["article_summary"] = $alias_row["article_summary"]; 684 $data[$aid]["article_redirect"] = $alias_row["article_redirect"]; 685 $data[$aid]["article_date"] = $alias_row["article_date"]; 686 $data[$aid]["article_image"] = @unserialize($alias_row["article_image"]); 687 $data[$aid]["article_begin"] = $alias_row["article_begin"]; 688 $data[$aid]["article_end"] = $alias_row["article_end"]; 689 $data[$aid]['article_livedate'] = $alias_row["article_livedate"]; 690 $data[$aid]['article_killdate'] = $alias_row["article_killdate"]; 691 } 692 } 693 } 694 } 695 696 if($sort == '') { 697 return array_diff($data, array('')); 698 } 699 700 return $data; 701 } 702 703 function convert2html($matches) { 704 if(isset($matches[1])) { 705 return html_entities($matches[1]); 706 } 707 } 708 709 function convert2htmlspecialchars($matches) { 710 if(isset($matches[1])) { 711 return html_specialchars($matches[1]); 712 } 713 } 714 715 function parse_images($matches) { 716 717 if(isset($matches[1])) { 718 719 // Image file ID 720 $img_id = intval($matches[1]); 721 722 // check for Alt-Text 723 $alt = explode(' ', trim($matches[2]), 2); 724 $value = explode('x', trim(strtolower($alt[0]))); 725 726 $alt = isset($alt[1]) ? html_specialchars(trim($alt[1])) : ''; 727 728 if(substr($value[0], 0, 1) == '.') { 729 $ext = trim($value[0]); 730 } else { 731 $ext = '.jpg'; 732 } 733 734 $width = isset($value[ 1 ]) ? intval($value[ 1 ]) : 0; 735 $height = isset($value[ 2 ]) ? intval($value[ 2 ]) : 0; 736 $crop = isset($value[ 3 ]) && intval($value[ 3 ]) === 1 ? 1 : 0; 737 $quality = isset($value[ 4 ]) ? intval($value[ 4 ]) : 0; 738 739 $image = '<img src="'.PHPWCMS_URL.'img/cmsimage.php/'.$width.'x'.$height.'x'.$crop; 740 if($quality <= 100 && $quality >= 10) { 741 $image .= 'x'.$quality; 742 } 743 $image .= '/'.$img_id.$ext.'" alt="'.$alt.'" border="0"'; 744 if(isset($matches[3])) { 745 746 $title = html_specialchars( preg_replace('/\s+/', ' ', clean_slweg( xss_clean( $matches[3] ) ) ) ); 747 if($title !== '') { 748 $image .= ' title="'.$title.'"'; 749 } 750 } 751 $image .= ' />'; 752 753 return $image; 754 755 } 756 757 return '<img src="'.PHPWCMS_URL.'img/leer.gif" alt="" border="0" />'; 758 759 } 760 761 function parse_downloads($match) { 762 763 if(isset($match[1])) { 764 765 $value = array(); 766 767 $value['cnt_object']['cnt_files']['id'] = convertStringToArray($match[1]); 768 769 if(isset($value['cnt_object']['cnt_files']['id']) && is_array($value['cnt_object']['cnt_files']['id']) && count($value['cnt_object']['cnt_files']['id'])) { 770 771 global $phpwcms; 772 773 $IS_NEWS_CP = true; 774 775 $news = array(); 776 $news['files_result'] = ''; 777 778 $crow = array(); 779 780 $value['cnt_object']['cnt_files']['caption'] = isset($match[2]) ? @html_entity_decode(trim($match[2]), ENT_QUOTES, PHPWCMS_CHARSET) : ''; 781 $value['files_direct_download'] = 0; 782 $value['files_template'] = ''; 783 784 // include content part files renderer 785 include (PHPWCMS_ROOT.'/include/inc_front/content/cnt7.article.inc.php'); 786 787 return $news['files_result']; 788 789 } 790 791 } 792 793 return ''; 794 795 } 796 797 /** 798 * process content part trigger functions 799 **/ 800 function trigger_cp($CP, & $CPDATA) { 801 foreach($GLOBALS['content']['CpTrigger'] as $trigger_function) { 802 if(function_exists($trigger_function)) { 803 $CP = $trigger_function($CP, $CPDATA); 804 } 805 } 806 return $CP; 807 } 808 809 /** 810 * register content part trigger function 811 * @param string $function name of the trigger function 812 * @param string $method method how trigger function should be registered 813 * LAST - register as last, multiple possible 814 * FIRST - register as first, multiple possible 815 * RFIRST - if not registered as first 816 * RLAST - if not registered as last 817 * 818 * Good place to place custom trigger function is 819 * /template/inc_script/frontend_init 820 * 821 * function replace_cp_word($text, & $data) { 822 * return str_replace('12345', '*12345 replaced by CPID:'.$data['acontent_id'].'*', $text); 823 * } 824 * register_cp_trigger('replace_cp_word'); 825 * 826 **/ 827 function register_cp_trigger($function='', $method='LAST') { 828 if(is_string($function)) { 829 switch($method) { 830 case 'FIRST': 831 array_unshift($GLOBALS['content']['CpTrigger'], $function); 832 break; 833 834 case 'RFIRST': 835 if(!in_array($function, $GLOBALS['content']['CpTrigger'])) { 836 array_unshift($GLOBALS['content']['CpTrigger'], $function); 837 } 838 break; 839 840 case 'RLAST': 841 if(!in_array($function, $GLOBALS['content']['CpTrigger'])) { 842 array_push($GLOBALS['content']['CpTrigger'], $function); 843 } 844 break; 845 846 case 'LAST': 847 default: 848 array_push($GLOBALS['content']['CpTrigger'], $function); 849 } 850 } 851 } 852 853 854 /** 855 * Check referrer string for search engine related information 856 * and log those fetched data in database 857 * Basic idea: http://www.tellinya.com/read/2007/07/11/34.html 858 * 859 * @return array 860 * @param string referrer string 861 * 862 **/ 863 function seReferrer($ref = false) { 864 865 if(!empty($ref) && is_string($ref)) { 866 $SeReferer = trim($ref); 867 } elseif(isset($_SERVER['HTTP_REFERER'])) { 868 $SeReferer = trim($_SERVER['HTTP_REFERER']); 869 } else { 870 return false; 871 } 872 $SePos = 0; 873 $SeDomain = ''; 874 875 //Check against Google, Yahoo, MSN, Ask and others 876 if( $SeReferer && preg_match('/[&\?](q|p|w|s|qry|searchfor|as_q|as_epq|query|qt|keyword|keywords|encquery)=([^&]+)/i', $SeReferer, $pcs) ){ 877 if( preg_match("/https?:\/\/([^\/]+)\//i", $SeReferer, $SeDomain) ) { 878 $SeDomain = trim(strtolower($SeDomain[1])); 879 $SeQuery = $pcs[2]; 880 if(preg_match("/[&\?](start|b|first|stq)=([0-9]*)/i",$SeReferer,$pcs)) { 881 $SePos = (int)trim($pcs[2]); 882 } 883 } 884 } 885 if(!isset($SeQuery)){ 886 //Check against DogPile 887 if( preg_match('/\/search\/web\/([^\/]+)\//i', $SeReferer, $pcs) ) { 888 if( preg_match("/https?:\/\/([^\/]+)\//i", $SeReferer, $SeDomain) ){ 889 $SeDomain = trim(strtolower($SeDomain[1])); 890 $SeQuery = $pcs[1]; 891 } 892 } 893 894 // We Do Not have a query 895 if(!isset($SeQuery)){ 896 return false; 897 } 898 } 899 900 $OldQ = $SeQuery; 901 $SeQuery = urldecode($SeQuery); 902 903 // The Multiple URLDecode Trick to fix DogPile %XXXX Encodes 904 while($SeQuery != $OldQ){ 905 $OldQ = $SeQuery; 906 $SeQuery = urldecode($SeQuery); 907 } 908 909 // check given query and decode utf-8 910 if(PHPWCMS_CHARSET != 'utf-8' && phpwcms_seems_utf8($SeQuery)) { 911 $SeQuery = makeCharsetConversion($SeQuery, 'utf-8', PHPWCMS_CHARSET, false); 912 } 913 914 return array( "domain" => $SeDomain, 915 "query" => $SeQuery, 916 "pos" => $SePos, 917 "referrer" => $SeReferer ); 918 } 919 920 921 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Jan 29 16:31:14 2012 | Cross-referenced by PHPXref 0.7.1 |