if ($file != "." and $file != ".." and $file_arr[1] == "news") { $arch_arr[] = $file_arr[0]; } } closedir($handle); if (is_array($arch_arr)) { $arch_arr = array_reverse($arch_arr); foreach ($arch_arr as $arch_file) { $news_lines = file(SERVDIR . "/cdata/archives/{$arch_file}.news.arch"); $count = count($news_lines); $last = $count - 1; $first_news_arr = explode("|", $news_lines[$last]); $last_news_arr = explode("|", $news_lines[0]); $first_timestamp = $first_news_arr[0]; $last_timestamp = $last_news_arr[0]; $arch_url = RWU('archread', $PHP_SELF . build_uri('subaction,archive', array('list-archive', $arch_file))); echo "<a href=\"{$arch_url}&{$user_query}\">" . date("d M Y", $first_timestamp) . " - " . date("d M Y", $last_timestamp) . ", (<b>{$count}</b>)</a><br />"; } } } else { if ($CN_HALT != true and $static != true and ($subaction == "showcomments" or $subaction == "showfull" or $subaction == "addcomment") and (!isset($category) or $category == "" or $requested_cats[$ucat] == true)) { if ($subaction == "addcomment") { $allow_add_comment = true; $allow_comments = true; } if ($subaction == "showcomments") { $allow_comments = true; } if (($subaction == "showcomments" or $allow_comments == true) and $config_show_full_with_comments == "yes") { $allow_full_story = true; }
if (count($found)) { $itemid = 0; // Show results foreach ($found as $i => $resline) { $itemid++; if ($start_from > $itemid) { continue; } $id = $resline['id']; $title = htmlspecialchars($resline['title']); $title = $config_useutf8 ? UTF8ToEntities($title) : $title; $ucat = $resline['cat']; $archive = 0; if (preg_match('~(\\d+)\\.news\\.arch$~i', $resline['src'], $arc)) { $archive = $arc[1]; } $URL = $PHP_SELF . build_uri('subaction,id,archive,ucat', array('showfull')); $url = RWU('readmore', $URL); echo "<div class='cutenews_search_item'>{$itemid} <b><a href='{$url}'>{$title}</a></b> (" . date("d F, Y", $id) . ")</div>"; } echo "<p class='cutenews_founded'><b>" . lang('Founded news articles') . " [" . count($found) . "]</b> "; echo str_replace(array('%1', '%2'), array(date("d F Y", $date_from), date("d F Y", $date_to)), lang("from <b>%1</b> to <b>%2</b></p>", 'search')); } else { echo "<div class='cutenews_not_match'>" . lang('There are no news matching your search criteria') . "</div>"; } echo '<div class="cutenews_search_results"><i>' . lang('Search performed for') . ' ' . round(microtime(true) - $mc_start, 4) . ' s.</i></div>'; } elseif ($misc == "search" and ($subaction == "showfull" or $subaction == "showcomments" or $_POST["subaction"] == "addcomment" or $subaction == "addcomment")) { require_once SERVDIR . "/show_news.php"; unset($action, $subaction); } unset($search_form_hide, $dosearch);
$pages = ''; if ($number) { $pages_count = ceil($count_all / $number); $pages_start_from = 0; for ($j = 1; $j <= $pages_count; $j++) { if ($pages_start_from != $start_from) { $URL = $PHP_SELF . build_uri('start_from,ucat,archive,subaction,id:comm_start_from', array($pages_start_from, $ucat, $url_archive, $subaction, $id)); $pages .= '<a href="' . RWU('newspage', $URL) . '">' . $j . '</a> '; } else { $pages .= '<strong>' . $j . '</strong> '; } $pages_start_from += $number; } } else { $no_next = true; $no_prev = true; } $prev_next_msg = str_replace("{pages}", $pages, $prev_next_msg); //---------------------------------- // Next link (typo here ... typo there... typos everywhere !) //---------------------------------- if ($number < $count_all and $i < $count_all) { $URL = $PHP_SELF . build_uri('start_from,ucat,archive,subaction,id:comm_start_from', array($i, $ucat, $url_archive, $subaction, $id)); $prev_next_msg = preg_replace("'\\[next-link\\](.*?)\\[/next-link\\]'si", '<a href="' . RWU('newspage', $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 (!$no_prev or !$no_next) { echo $prev_next_msg; }
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;
} $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'])) {
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; }