= 0 && $index < sizeof($pages)) $posts = $pages[$index]; else $posts = array(); if (!empty($posts)) { $titlenolink = (strpos($NMTITLENOLINK, 'main') !== false); $showexcerpt = ($NMSHOWEXCERPT == 'Y'); foreach ($posts as $post) nm_show_post($post->slug, $showexcerpt, $NMREADMORE, $titlenolink); if (sizeof($pages) > 1) nm_show_navigation($index, sizeof($pages)); } else { echo '
' . i18n_r('news_manager/NO_POSTS') . '
'; } } /******************************************************* * @function nm_show_archive * @param $id - unique archive id * @action show posts by archive */ function nm_show_archive($archive) { global $NMREADMORE, $NMTITLENOLINK, $NMARCHIVESBY; $archives = nm_get_archives($NMARCHIVESBY); if (array_key_exists($archive, $archives)) { $posts = $archives[$archive]; $titlenolink = (strpos($NMTITLENOLINK, 'archive') !== false); foreach ($posts as $slug) nm_show_post($slug, true, $NMREADMORE, $titlenolink); } } /******************************************************* * @function nm_show_tag * @param $id - unique tag id * @action show posts by tag */ function nm_show_tag($tag) { global $NMREADMORE, $NMTITLENOLINK; $tags = nm_get_tags(); if (array_key_exists($tag, $tags)) { $titlenolink = (strpos($NMTITLENOLINK, 'tag') !== false); $posts = $tags[$tag]; foreach ($posts as $slug) nm_show_post($slug, true, $NMREADMORE, $titlenolink); } } /******************************************************* * @function get_search_results() * @action search posts by keyword(s) */ function nm_show_search_results() { global $NMREADMORE, $NMTITLENOLINK; $keywords = @explode(' ', $_POST['keywords']); $posts = nm_get_posts(); foreach ($keywords as $keyword) { $match = array(); foreach ($posts as $post) { $data = getXML(NMPOSTPATH.$post->slug.'.xml'); $content = $data->title . $data->content; if (stripos($content, $keyword) !== false) $match[] = $post; } $posts = $match; } if (!empty($posts)) { $titlenolink = (strpos($NMTITLENOLINK, 'search') !== false); echo '' . i18n_r('news_manager/FOUND') . '
'; foreach ($posts as $post) nm_show_post($post->slug, true, $NMREADMORE, $titlenolink); } else { echo '' . i18n_r('news_manager/NOT_FOUND') . '
'; } } /******************************************************* * @function nm_show_post * @param $slug post slug * @param $excerpt - if TRUE, print only a short summary * @param $readmore - if TRUE, insert link to post after the excerpt ('a' for always) * @param $titlenolink - if TRUE, display post title without link * @action show the requested post on front-end news page */ function nm_show_post($slug, $excerpt=false, $readmore=false, $titlenolink=false) { $file = NMPOSTPATH.$slug.'.xml'; if (dirname(realpath($file)) == realpath(NMPOSTPATH)) // no path traversal $post = @getXML($file); if (!empty($post) && $post->private != 'Y') { $url = nm_get_url('post') . $slug; $title = stripslashes($post->title); $date = nm_get_date(i18n_r('news_manager/DATE_FORMAT'), strtotime($post->date)); $content = strip_decode($post->content); if ($excerpt) { $content = $readmore ? nm_create_excerpt($content, $url, ($readmore === 'a')) : nm_create_excerpt($content); $image = nm_get_image_url(stripslashes($post->image)); if ($image) { $imghtml = ''; global $NMIMAGES; if ($NMIMAGES) { if (isset($NMIMAGES['alt']) && $NMIMAGES['alt']) $imghtml .= ' alt="'.htmlspecialchars($title, ENT_COMPAT).'"'; if (isset($NMIMAGES['title']) && $NMIMAGES['title']) $imghtml .= ' title="'.htmlspecialchars($title, ENT_COMPAT).'"'; $imghtml = ''; if (isset($NMIMAGES['link']) && $NMIMAGES['link']) $imghtml = ''.$imghtml.''; } $imghtml = ''.$imghtml.'
'.PHP_EOL; } else { $imghtml = ''; } } else { $imghtml = ''; } # print post data ?>