} else { $url_target = 'target="_blank"'; $mail_or_url = ""; if (substr($comment_arr[COM_MAIL], 0, 3) == "www") { $mail_or_url = "http://"; } } $output = str_replace("{author}", "<a {$url_target} href=\"{$mail_or_url}" . stripslashes($comment_arr[COM_MAIL]) . "\">" . stripslashes(UTF8ToEntities($comment_arr[1])) . "</a>", $template_comment); } else { $output = str_replace("{author}", UTF8ToEntities($comment_arr[COM_USER]), $template_comment); } $comment_arr[COM_TEXT] = preg_replace("/\\b((http(s?):\\/\\/)|(www\\.))([\\w\\.]+)([&-~\\%\\/\\w+\\.-?]+)\\b/i", "<a href=\"http\$3://\$4\$5\$6\" target=\"_blank\">\$2\$4\$5\$6</a>", $comment_arr[COM_TEXT]); $comment_arr[COM_TEXT] = preg_replace("/([\\w\\.]+)(@)([-\\w\\.]+)/i", "<a href=\"mailto:\$0\">\$0</a>", $comment_arr[COM_TEXT]); $output = str_replace("{mail}", $comment_arr[2], $output); $output = str_replace("{date}", date($config_timestamp_comment, $comment_arr[0]), $output); $output = embedateformat($news_arr[0], $output); $output = str_replace("{comment-id}", $comment_arr[0], $output); $output = str_replace("{comment}", "<a name=\"" . $comment_arr[0] . "\"></a>" . UTF8ToEntities($comment_arr[4]), $output); $output = str_replace("{comment-iteration}", $iteration, $output); $output = replace_comment("show", $output); echo $output; $showed_comments++; if ($comm_per_page != 0 and $comm_per_page == $showed_comments) { break; } } } } } //---------------------------------- // Prepare the Comment Pagination
function template_replacer_news($news_arr, $output) { // Predefined Globals global $config_timestamp_active, $config_http_script_dir, $config_comments_popup, $config_comments_popup_string, $config_full_popup, $config_full_popup_string, $rss_news_include_url, $my_names, $my_start_from, $cat, $action, $cat_icon, $archive, $name_to_nick, $template, $user_query, $member_db, $_SESS, $PHP_SELF; // Short Story not exists if (empty($news_arr[NEW_FULL]) and strpos($output, '{short-story}') === false) { $news_arr[NEW_FULL] = $news_arr[NEW_SHORT]; } $output = more_fields($news_arr[NEW_MF], $output); // Date Formatting [year, month, day, hour, minute, date=$config_timestamp_active] list($output, $news_arr) = hook('template_replacer_news_before', array($output, $news_arr)); $output = embedateformat($news_arr[NEW_ID], $output); // Replace news content $output = str_replace("{title}", hesc($news_arr[NEW_TITLE]), $output); $output = str_replace("{author}", $my_names[$news_arr[NEW_USER]] ? $my_names[$news_arr[NEW_USER]] : $news_arr[NEW_USER], $output); $output = str_replace("{author-name}", hesc($name_to_nick[$news_arr[NEW_USER]]), $output); $output = str_replace("{short-story}", hesc($news_arr[NEW_SHORT]), $output); $output = str_replace("{full-story}", hesc($news_arr[NEW_FULL]), $output); // Replace system information $output = str_replace("{avatar-url}", $news_arr[NEW_AVATAR], $output); $output = str_replace("{category}", hesc(catid2name($news_arr[NEW_CAT])), $output); $output = str_replace("{category-url}", linkedcat($news_arr[NEW_CAT]), $output); $output = str_replace("{page-views}", false, $output); $output = str_replace("{phpself}", $PHP_SELF, $output); $output = str_replace("{index-link}", '<a href="' . $PHP_SELF . '">' . lang('Go back') . '</a>', $output); $output = str_replace("{back-previous}", '<a href="javascript:history.go(-1)">Go back</a>', $output); $output = str_replace("{cute-http-path}", $config_http_script_dir, $output); $output = str_replace("{news-id}", $news_arr[NEW_ID], $output); $output = str_replace("{category-id}", $news_arr[NEW_CAT], $output); $output = str_replace("{comments-num}", countComments($news_arr[NEW_ID], $archive), $output); $output = str_replace("{archive-id}", $archive, $output); $output = str_replace("{category-icon}", caticon($news_arr[NEW_CAT], $cat_icon, $cat), $output); $mf_for_avatar = options_extract($news_arr[NEW_MF]); if (array_key_exists('_avatar_width', $mf_for_avatar)) { $width_for_avatar = 'width:' . $mf_for_avatar['_avatar_width'] . ';'; } if (array_key_exists('_avatar_height', $mf_for_avatar)) { $height_for_avatar = 'height:' . $mf_for_avatar['_avatar_height'] . ';'; } $output = str_replace("{avatar}", $news_arr[NEW_AVATAR] ? '<img alt="" src="' . $news_arr[NEW_AVATAR] . '" style="border: none;' . $width_for_avatar . $height_for_avatar . '" />' : '', $output); $output = preg_replace('/\\[loggedin\\](.*?)\\[\\/loggedin\\]/is', empty($_SESS['user']) ? '' : '\\1', $output); // social plugins $output = str_replace('{fb-comments}', show_social_code('fb', $news_arr), $output); $output = str_replace('{fb-like}', show_social_code('fb-like', $news_arr), $output); $output = str_replace('{twitter}', show_social_code('twitter', $news_arr), $output); // in RSS we need the date in specific format if ($template == 'rss') { $output = str_replace("{date}", date("r", $news_arr[0]), $output); $output = str_replace("{rss-news-include-url}", $rss_news_include_url ? $rss_news_include_url : $config_http_script_dir . '/router.php', $output); } else { $output = str_replace("{date}", date($config_timestamp_active, $news_arr[NEW_ID]), $output); } // Star Rating if (empty($archive)) { $output = str_replace("{star-rate}", rating_bar($news_arr[NEW_ID], $news_arr[NEW_RATE]), $output); } else { $output = str_replace("{star-rate}", false, $output); } // Mail Exist in mailist ---------------------------------------------------- [mail]...[/mail] if (!empty($my_mails[$news_arr[NEW_USER]])) { $output = str_replace(array("[mail]", '[/mail]'), array('<a href="mailto:' . $my_mails[$news_arr[NEW_USER]] . '">', ''), $output); } else { $output = str_replace(array("[mail]", '[/mail]'), '', $output); } // By click to comments - popup window -------------------------------------- [com-link]...[/com-link] if ($config_comments_popup == "yes") { $URL = build_uri('subaction,id,ucat,start_from,template,archive', array('showcomments', $news_arr[NEW_ID], $news_arr[NEW_CAT], $my_start_from)); $output = str_replace(array('[com-link]', '[/com-link]'), array('<a href="#" onclick="window.open(\'' . $config_http_script_dir . '/router.php' . $URL . '\', \'News\', \'' . $config_comments_popup_string . '\'); return false;">', '</a>'), $output); } else { if ($archive) { $URL = RWU('archreadcomm', $PHP_SELF . build_uri('subaction,id,ucat,title,template,archive', array('showcomments', $news_arr[NEW_ID], $news_arr[NEW_CAT], titleToUrl($news_arr[NEW_TITLE])))); } else { $URL = RWU('readcomm', $PHP_SELF . build_uri('subaction,id,ucat,title,template', array('showcomments', $news_arr[NEW_ID], $news_arr[NEW_CAT], titleToUrl($news_arr[NEW_TITLE])))); } $output = str_replace(array("[com-link]", '[/com-link]'), array("<a href=\"{$URL}\">", '</a>'), $output); } // Open link --------------------------------------------------------------- [link]...[/link] $URL = build_uri('subaction,id,start_from,ucat,archive,template', array('showfull', $news_arr[NEW_ID], $my_start_from, $news_arr[NEW_CAT])); $URL .= "&#disqus_thread"; $output = preg_replace('/\\[link target\\=([a-z0-9_]+?)\\](.*?)\\[\\/link\\]/is', '<a href="' . $PHP_SELF . $URL . '" target="\\1">\\2</a>', $output); $output = str_replace(array("[link]", "[/link]"), array('<a href="' . $PHP_SELF . $URL . '">', "</a>"), $output); // With Action = showheadlines -------------------------------------------- [full-link]...[/full-link] if ($news_arr[NEW_FULL] or $action == "showheadlines") { if ($config_full_popup == "yes") { $URL = build_uri('subaction,id,archive,template', array('showfull', $news_arr[NEW_ID], $archive, $template)); // Popup string $attrlink = "href='#' onclick=\"window.open('{$config_http_script_dir}/router.php{$URL}', '_News', '{$config_full_popup_string}'); return false;\""; $output = preg_replace('/\\[full\\-link target\\=([a-z0-9_]+?)\\](.*?)\\[\\/full\\-link\\]/is', "<a {$attrlink} target='\\1'>\\2</a>", $output); $output = str_replace('[full-link]', "<a {$attrlink}>", $output); } else { $template = $template == 'Default' ? '' : $template; if ($archive) { $URL = RWU('archreadmore', $PHP_SELF . build_uri('subaction,id,archive,ucat,title,template', array('showfull', $news_arr[0], $archive, $news_arr[NEW_CAT], titleToUrl($news_arr[NEW_TITLE]), $template)) . "&{$user_query}"); } else { $URL = RWU('readmore', $PHP_SELF . build_uri('subaction,id,ucat,title,template', array('showfull', $news_arr[0], $news_arr[NEW_CAT], titleToUrl($news_arr[NEW_TITLE]), $template)) . "&{$user_query}"); } // Target string $attrlink = "href='{$URL}'"; $output = preg_replace('/\\[full\\-link target\\=([a-z0-9_]+?)\\](.*?)\\[\\/full\\-link\\]/is', "<a {$attrlink} target='\\1'>\\2</a>", $output); $output = str_replace("[full-link]", "<a {$attrlink}>", $output); } $output = str_replace("[/full-link]", "</a>", $output); } else { $output = preg_replace('~\\[full-link.*?\\].*?\\[/full-link\\]~si', '<!-- no full story-->', $output); } // Admin can edit for news ------------------------------------------------ [edit]...[/edit] $DREdit = false; if (empty($_SESS['user']) == false) { $member_db = user_search($_SESS['user']); if (in_array($member_db[UDB_ACL], array(ACL_LEVEL_ADMIN, ACL_LEVEL_JOURNALIST))) { $url = '/index.php' . build_uri('mod,action,id,source', array('editnews', 'editnews', $news_arr[NEW_ID], $archive)); $output = preg_replace('/\\[edit\\]/i', '<a target="_blank" href="' . $config_http_script_dir . $url . '">', $output); $output = preg_replace('/\\[\\/edit\\]/i', '</a>', $output); $DREdit = true; } } // If not used, replace [edit]..[/edit] if ($DREdit == false) { $output = preg_replace('~\\[edit\\].*?\\[/edit\\]~si', '', $output); } list($output, $news_arr) = hook('template_replacer_news_middle', array($output, $news_arr)); $output = replace_news("show", $output); list($output) = hook('template_replacer_news_after', array($output, $news_arr)); return $output; }