} $pages .= '<a href="' . $URL . '">' . $j . '</a> '; } else { $pages .= ' <strong>' . $j . '</strong> '; } $pages_start_from += $comm_per_page; } $prev_next_msg = str_replace("{pages}", $pages, $prev_next_msg); } // Next link if ($comm_per_page < $total_comments and $comment_number < $total_comments) { // $URL = $PHP_SELF . build_uri('subaction,comm_start_from,archive,id,ucat', array('showcomments', $comment_number)); if ($archive) { $URL = RWU('archcommpage', $PHP_SELF . build_uri('subaction,comm_start_from,title,archive,id,ucat', array('showcomments', $comment_number, titleToUrl($news_arr[NEW_TITLE])))); } else { $URL = RWU('commpage', $PHP_SELF . build_uri('subaction,comm_start_from,title,id,ucat', array('showcomments', $comment_number, titleToUrl($news_arr[NEW_TITLE])))); } $prev_next_msg = preg_replace("'\\[next-link\\](.*?)\\[/next-link\\]'si", "<a href=\"{$URL}\">\\1</a>", $prev_next_msg); } else { $prev_next_msg = preg_replace("'\\[next-link\\](.*?)\\[/next-link\\]'si", "\\1", $prev_next_msg); $no_next = true; } if (empty($no_prev) or empty($no_next)) { echo $prev_next_msg; } $username = $usermail = false; $template_form = str_replace("{config_http_script_dir}", $config_http_script_dir, $template_form); //---------------------------------- // Check if the remember script exists //---------------------------------- if (!empty($_SESS['user'])) {
if (!$found) { fwrite($new_comments, "{$id}|>|{$time}|{$name}|{$mail}|{$ip}|{$comments}||\n"); } flock($new_comments, LOCK_UN); fclose($new_comments); //---------------------------------- // Sign this comment in the Flood Protection //---------------------------------- if ($config_flood_time != "0" and $config_flood_time != "") { $flood_file = fopen(SERVDIR . "/cdata/flood.db.php", "a"); flock($flood_file, LOCK_EX); fwrite($flood_file, time() . "|{$ip}|{$id}|\n"); flock($flood_file, LOCK_UN); fclose($flood_file); } // checkout hook('comment_added'); //---------------------------------- // Notify for New Comment ? //---------------------------------- if ($config_notify_comment == "yes" and $config_notify_status == "active") { $date = date($config_timestamp_active, time() + $config_date_adjust * 60); $url = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; $subject = lang("CuteNews - New Comment Added"); $message = lang("New Comment was added by %1 on %3 at %4\n\n%2 ", $name, $comments, $date, $url); send_mail($config_notify_email, $subject, $message); } $URL = RWU('readcomm', $PHP_SELF . build_uri('subaction,id,ucat,archive,start_from:comm_start_from,title', array('showcomments', $id, $ucat, $archive, $start_from, titleToUrl($news_arr[NEW_TITLE])), false)); echo '<script type="text/javascript">window.location="' . $URL . '";</script>'; // ------------ ALL OK ---------------- return TRUE;
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; }