function blog_page_site_viewpost() { //Global language variables. global $lang; //Load blog post. if (isset($_GET['post']) && blog_get_post($_GET['post'])) { $post = blog_get_post($_GET['post']); ?> <div id="blog_post"> <span id="blog_post_info"> <?php echo $post['date'] . ' ' . $lang['blog']['at'] . ' ' . $post['time'] . ' ' . $lang['blog']['in'] . ' ' . $post['category']; ?> </span> <div id="blog_post_content"> <?php run_hook('theme_content', array(&$post['content'])); echo $post['content']; ?> </div> </div> <?php //Check if reactions are enabled if (module_get_setting('blog', 'allow_reactions') == 'true') { ?> <div id="blog_reactions"> <p> <?php $number = blog_get_reactions($post['seoname']); if ($number) { $number = count($number); if ($number == 1) { echo $number . ' ' . $lang['blog']['reaction']; } else { echo $number . ' ' . $lang['blog']['reactions']; } } else { echo $lang['blog']['no_reactions']; } ?> </p> <?php $reactions = blog_get_reactions($_GET['post']); if ($reactions) { foreach ($reactions as $reaction) { ?> <div class="blog_reaction" id="reaction<?php echo $reaction['id']; ?> "> <p class="blog_reaction_name"> <?php if (isset($reaction['website'])) { echo '<a href="' . $reaction['website'] . '">' . $reaction['name'] . '</a>:'; } else { echo $reaction['name'] . ':'; } ?> </p> <span class="blog_reaction_info"> <a href="#reaction<?php echo $reaction['id']; ?> "><?php echo $reaction['date'] . ' ' . $lang['blog']['at'] . ' ' . $reaction['time']; ?> </a> </span> <p class="blog_reaction_message"><?php echo $reaction['message']; ?> </p> </div> <?php } } //If form is posted... if (isset($_POST['submit'])) { //Check if everything has been filled in. if (empty($_POST['blog_reaction_name']) || filter_input(INPUT_POST, 'blog_reaction_email', FILTER_VALIDATE_EMAIL) == false || $_POST['blog_reaction_website'] != 'http://' && !empty($_POST['blog_reaction_website']) && filter_input(INPUT_POST, 'blog_reaction_website', FILTER_VALIDATE_URL, FILTER_FLAG_HOST_REQUIRED) == false || empty($_POST['blog_reaction_message'])) { echo '<p class="error">' . $lang['contactform']['fields'] . '</p>'; } else { blog_save_reaction($_GET['post'], $_POST['blog_reaction_name'], $_POST['blog_reaction_email'], $_POST['blog_reaction_website'], $_POST['blog_reaction_message']); //Redirect user. redirect(SITE_URI . '/' . PAGE_URL_PREFIX . CURRENT_PAGE_SEONAME . BLOG_URL_PREFIX . $_GET['post'], 0); } } ?> <form id="blog_post_form" method="post" action=""> <div> <label for="blog_reaction_name"><?php echo $lang['general']['name']; ?> </label> <br /> <input name="blog_reaction_name" id="blog_reaction_name" type="text" /> <br /> <label for="blog_reaction_email"><?php echo $lang['general']['email']; ?> </label> <br /> <input name="blog_reaction_email" id="blog_reaction_email" type="text" /> <br /> <label for="blog_reaction_website"><?php echo $lang['general']['website']; ?> </label> <br /> <input name="blog_reaction_website" id="blog_reaction_website" type="text" value="http://" /> <br /> <label for="blog_reaction_message"><?php echo $lang['general']['message']; ?> </label> <br /> <textarea name="blog_reaction_message" id="blog_reaction_message" rows="7" cols="45"></textarea> <br /> <input type="submit" name="submit" value="<?php echo $lang['general']['send']; ?> " /> </div> </form> </div> <?php //End of commenting check. } } else { echo $lang['general']['not_found']; } ?> <p> <a href="javascript: history.go(-1)" title="<?php echo $lang['general']['back']; ?> "><<< <?php echo $lang['general']['back']; ?> </a> </p> <?php }
/** * Load posts in an array. Will return FALSE if no posts exist. */ function blog_get_posts() { $files = read_dir_contents(BLOG_POSTS_DIR, 'files'); if ($files) { natcasesort($files); $files = array_reverse($files); foreach ($files as $post) { $posts[] = blog_get_post(blog_get_post_seoname($post)); } unset($post); return $posts; } else { return false; } }
function blog_page_admin_editpost() { global $lang, $var1, $cont1, $cont2, $cont3; //If form is posted... if (isset($_POST['save']) || isset($_POST['save_exit'])) { if (seo_url($cont1)) { //Save blogpost. $seoname = blog_save_post($cont1, $cont2, $cont3, $var1); //Redirect user. if (isset($_POST['save'])) { redirect('?module=blog&page=editpost&var1=' . $seoname, 0); exit; } else { redirect('?module=blog', 0); exit; } } else { $error = show_error($lang['page']['no_title'], 1, true); } } $post = blog_get_post($var1); ?> <?php if (isset($error)) { echo $error; } ?> <div class="rightmenu"> <p><?php echo $lang['page']['items']; ?> </p> <?php show_link_insert_box(); show_image_insert_box('images'); ?> </div> <form method="post" action=""> <p> <label class="kop2" for="cont1"><?php echo $lang['general']['title']; ?> </label> <input name="cont1" id="cont1" type="text" value="<?php echo $post['title']; ?> " /> </p> <p> <label class="kop2" for="cont2"><?php echo $lang['blog']['category']; ?> </label> <select name="cont2" id="cont2"> <option value=""><?php echo $lang['blog']['choose_cat']; ?> </option> <?php //If there are categories. if (blog_get_categories()) { $categories = blog_get_categories(); foreach ($categories as $category) { if ($post['category_seoname'] == $category['seoname']) { echo '<option value="' . $category['seoname'] . '" selected="selected">' . $category['title'] . '</option>'; } else { echo '<option value="' . $category['seoname'] . '">' . $category['title'] . '</option>'; } } unset($key); } ?> </select> </p> <p> <label class="kop2" for="cont3"><?php echo $lang['general']['contents']; ?> </label> <textarea class="<?php if (defined('WYSIWYG_TEXTAREA_CLASS')) { echo WYSIWYG_TEXTAREA_CLASS; } ?> " name="cont3" id="cont3" cols="70" rows="20"><?php echo htmlspecialchars($post['content']); ?> </textarea> </p> <?php show_common_submits('?module=blog', true); ?> </form> <?php }