Exemple #1
0
 }
 if (isset($_GET['s']) && !empty($_GET['s']) && $temp_var['status'] != $_GET['s']) {
     continue;
 }
 if (isset($_GET['t']) && !empty($_GET['t']) && !in_array($_GET['t'], $temp_var['tags_array'])) {
     continue;
 }
 if (isset($_GET['q']) && strlen($_GET['q']) > 2 && !preg_match('/[!?\'$&\\/()=%*:;,.@\\"#~|_+{}<>]/i', $_GET['q'])) {
     $post_content = file_get_contents(MN_ROOT . $dir['posts'] . 'post_' . $temp_var['post_id'] . '.php');
     if (stripos($post_content, $_GET['q']) === false) {
         continue;
     }
 }
 $var = get_post_data($temp_var['post_id']);
 $approve_button = $auth == 1 && $var['status'] == 4 ? ' &middot; <form action="./mn-posts.php" method="post" id="approve_' . $var['id'] . '"><span class="simurl" onclick="$(\'form:#approve_' . $var['id'] . '\').submit();">' . $lang['uni_approve'] . '</span><input type="hidden" name="id" value="' . $var['id'] . '" /><input type="hidden" name="action" value="approve" /></form>' : '';
 $comments_count = get_comments_count($var['id']);
 $comments_s = $var['comments'] == 1 && $conf['comments'] ? '' : ' off';
 $comments = $comments_count > 0 ? '<!-- ' . $comments_count . ' --><a href="./mn-comments.php?p=' . $var['id'] . '" class="comment-link' . $comments_s . '">' . $comments_count . '</a>' : '<!-- 0 --><span class="trivial' . $comments_s . '">0</span>';
 $author = !empty($users[$var['author']]) ? $users[$var['author']] : '<!-- anonym --><span class="trivial">' . $lang['posts_author_anonym'] . '</span>';
 $status = $var['timestamp'] > mn_time() && ($var['status'] == 1 || $var['status'] == 2) ? '<span class="status_6">' . $lang['posts_future_post'] . '</span>' : '<span class="status_' . $var['status'] . '">' . $lang['posts_status_name_' . $var['status']] . '</span>';
 $datetime = $var['timestamp'] == 9999999999 || empty($var['timestamp']) ? '<span class="trivial">-</span>' : date('d.m.Y', $var['timestamp']) . '<br /><span class="trivial">' . date('H:i', $var['timestamp']) . '</span>';
 $var['title'] = mb_strlen($var['title']) > 38 ? '<span title="' . $var['title'] . '">' . mb_substr($var['title'], 0, 36, 'utf-8') . '&hellip;</span>' : $var['title'];
 if ($var['cat'] == '-1') {
     $category_name = '<!-- uncategorized --><span class="trivial">' . $lang['cats_uncategorized'] . '</span>';
 } elseif (empty($categories[$var['cat']])) {
     $category_name = '<!-- unknown --><span class="trivial">' . $lang['cats_unknown_category'] . '</span>';
 } else {
     $category_name = $categories[$var['cat']];
 }
 if (isset($conf['web_url']) && !empty($conf['web_url']) && substr_count($conf['web_url'], 'http://') == 1) {
     $show_web = ' (<a href="' . generate_url($conf['web_url']) . 'mn_post=' . $var['id'] . '" title="' . $lang['posts_show_post_web'] . '">&raquo;</a>)';
function posts_tmpl($id, $template, $url)
{
    global $conf, $dir, $file, $lang, $mn_categories, $mn_tags, $mn_mode, $mn_users;
    if (file_exists(MN_ROOT . $dir['posts'] . 'post_' . $id . '.php') && file_exists(MN_ROOT . $dir['templates'] . $template . '.html')) {
        $p = get_post_data($id);
        $tmpl_file = file_get_contents(MN_ROOT . $dir['templates'] . $template . '.html');
        $comments_count = get_comments_count($id);
        $comments = $conf['comments'] ? '<a href="' . generate_post_url($url, $p) . '#mn-comments">' . $lang['web_comments'] . ' (' . $comments_count . ')</a>' : '';
        if (!empty($p['full_story'])) {
            $tmpl_result = preg_replace('/\\[VAR-LINK\\](.*?)\\[\\/VAR-LINK\\]/is', '<a href="' . generate_post_url($url, $p) . '">$1</a>', $tmpl_file);
            $link = '<a href="' . generate_post_url($url, $p) . '">' . $lang['web_post_link'] . '</a>';
        } else {
            $tmpl_result = preg_replace('/\\[VAR-LINK\\](.*?)\\[\\/VAR-LINK\\]/is', '', $tmpl_file);
            $link = '';
        }
        if (!empty($p['author']) && !empty($mn_users[$p['author']])) {
            $author = '<a href="' . $url . 'mn_user='******'author'] . '">' . $mn_users[$p['author']] . '</a>';
            $author_name = $mn_users[$p['author']];
        } else {
            $author = '<em class="mn-trivial">' . $lang['web_anonym'] . '</em>';
            $author_name = '<em class="mn-trivial">' . $lang['web_anonym'] . '</em>';
        }
        if (!empty($p['cat']) && !empty($mn_categories[$p['cat']]['name'])) {
            $category = '<a href="' . generate_category_url($url, $mn_categories[$p['cat']]) . '">' . $mn_categories[$p['cat']]['name'] . '</a>';
            $category_id = $p['cat'];
            $category_name = $mn_categories[$p['cat']]['name'];
            $category_friendly_url = $mn_categories[$p['cat']]['friendly_url'];
        } else {
            $category = '<em class="mn-trivial">' . $lang['web_uncategorized'] . '</em>';
            $category_id = '-1';
            $category_name = '<em class="mn-trivial">' . $lang['web_uncategorized'] . '</em>';
            $category_friendly_url = '';
        }
        if (isset($_GET['mn_q']) && $mn_mode != 'rss' && !preg_match('/[\'$&\\/()=%*\\"#~|+{}<>]/i', $_GET['mn_q']) && strlen($_GET['mn_q']) > 2) {
            $q_search = '/(>[^<]*)(' . $_GET['mn_q'] . ')/is';
            $q_replace = '\\1<span class="mn-highlight">\\2</span>';
            $p['title'] = preg_replace('/' . $_GET['mn_q'] . '/is', '<span class="mn-highlight">\\0</span>', $p['title']);
            $p['short_story'] = preg_replace($q_search, $q_replace, $p['short_story']);
            $p['full_story'] = preg_replace($q_search, $q_replace, $p['full_story']);
        }
        if (!empty($p['tags']) && !empty($mn_tags)) {
            $p['tags-array'] = explode(',', $p['tags']);
            $tags = '';
            $tag_names = '';
            foreach ($p['tags-array'] as $tag_id) {
                if (empty($mn_tags[$tag_id])) {
                    continue;
                } else {
                    $tags .= '<a href="' . generate_tag_url($url, $mn_tags[$tag_id]) . '">' . $mn_tags[$tag_id]['name'] . '</a>, ';
                    $tag_names .= $mn_tags[$tag_id]['name'] . ', ';
                }
            }
            $tags = substr($tags, 0, -2);
            $tag_names = substr($tag_names, 0, -2);
        } else {
            $tags = '';
            $tag_names = '';
        }
        $p_img = explode(';', $p['image']);
        if (!empty($p_img[0]) && !empty($p_img[1]) && !empty($p_img[2])) {
            $image_filename = $p_img[0];
            $image_url = $conf['admin_url'] . '/' . $dir['images'] . $image_filename;
            $image_width = $p_img[1];
            $image_height = $p_img[2];
            $image = '<img src="' . $image_url . '" width="' . $image_width . '" height="' . $image_height . '" alt="' . $p['title'] . '" class="mn-post-image" />';
        } else {
            $image = $image_url = $image_filename = $image_width = $image_height = '';
        }
        if ($mn_mode == 'rss') {
            $title = htmlspecialchars($p['title'], ENT_QUOTES);
            $link = generate_post_url($url, $p);
            $p['title'] = htmlspecialchars($p['title'], ENT_QUOTES);
            $short_story = htmlspecialchars($p['short_story'], ENT_QUOTES);
            $p['full_story'] = htmlspecialchars($p['full_story'], ENT_QUOTES);
        } elseif (substr($template, -2, 2) == '10') {
            $title = $p['title'];
            $short_story = $p['short_story'] . $p['full_story'];
        } else {
            $title = '<a href="' . generate_post_url($url, $p) . '">' . $p['title'] . '</a>';
            $short_story = $p['short_story'];
            if ($conf['admin_icons'] && isset($_COOKIE['mn_user_name']) && isset($_COOKIE['mn_logged'])) {
                $title .= ' <a href="' . $conf['admin_url'] . '/mn-posts.php?action=edit&amp;id=' . $id . '"><img src="' . $conf['admin_url'] . '/stuff/img/icons/edit-gray.png" alt="edit" /></a> <a href="' . $conf['admin_url'] . '/mn-posts.php?action=delete&amp;id=' . $id . '&amp;nofancy"><img src="' . $conf['admin_url'] . '/stuff/img/icons/cross-gray.png" alt="delete" /></a>';
            }
        }
        $tmpl_values_search = array('{AUTHOR}', '{AUTHOR_ID}', '{AUTHOR_NAME}', '{CATEGORY}', '{CATEGORY_FRIENDLY_URL}', '{CATEGORY_ID}', '{CATEGORY_NAME}', '{COMMENTS}', '{COMMENTS_COUNT}', '{FRIENDLY_URL}', '{IMAGE}', '{IMAGE_FILENAME}', '{IMAGE_URL}', '{IMAGE_WIDTH}', '{IMAGE_HEIGHT}', '{LINK}', '{POST_ID}', '{POST_URL}', '{TAGS}', '{TAG_NAMES}', '{TEXT}', '{TEXT_FULL}', '{TEXT_LONG}', '{TEXT_PEREX}', '{TITLE}', '{TITLE_PLAIN}', '{VIEWS}', '{VIEWS_COUNT}');
        $tmpl_values_replace = array($author, $p['author'], $author_name, $category, $category_friendly_url, $category_id, $category_name, $comments, $comments_count, $p['friendly_url'], $image, $image_filename, $image_url, $image_width, $image_height, $link, $id, generate_post_url($url, $p), $tags, $tag_names, $short_story, $p['short_story'] . $p['full_story'], $p['full_story'], $p['short_story'], $title, $p['title'], $lang['web_viewed'] . ': ' . $p['views'] . '&times;', $p['views']);
        $result = str_ireplace($tmpl_values_search, $tmpl_values_replace, $tmpl_result);
        $result = $mn_mode != 'rss' ? preg_replace('/\\[PERM-LINK\\](.*?)\\[\\/PERM-LINK\\]/is', '<a href="' . generate_post_url($url, $p) . '">$1</a>', $result) : preg_replace('/\\[PERM-LINK\\](.*?)\\[\\/PERM-LINK\\]/is', '$1', $result);
        $result = preg_replace('/\\[LINK\\](.*?)\\[\\/LINK\\]/is', '<a href="' . generate_post_url($url, $p) . '">$1</a>', $result);
        $result = preg_replace('#\\[mn_gallery=(.*?)\\]#ie', 'mn_gallery(\'$1\')', $result);
        $result = common_tmpl($p['timestamp'], $result);
        $result = xfields_tmpl('posts', $p['xfields'], $result);
        return $result;
    } else {
        return '<p>' . $lang['web_msg_no_post_or_tmpl'] . '</p>';
    }
}