Location: PHPKode > projects > OpenBlog mini > OpenBlog mini 1.0/index.php
<?php
	session_start();

	include 'config.php';
	
	// This grabs information about what needs to be viewed (Single Post or All Posts In Month)
	$get_post_id = $_GET['id'];
	$get_post_search = $_POST['search'];
	$get_post_skip = $_GET['skip'];
	
	// This makes the data coming in via _POST safe
	$get_post_id_replace_quote_single = str_replace("'", "`", $get_post_id);
	$get_post_id_replace_quote_double = str_replace('"', "``", $get_post_id_replace_quote_single);
	$get_post_id_replace_slashes = str_replace("\\", "/", $get_post_id_replace_quote_double);
	$get_post_id = $get_post_id_replace_slashes;
	
	$get_post_search_replace_quote_single = str_replace("'", "`", $get_post_search);
	$get_post_search_replace_quote_double = str_replace('"', "``", $get_post_search_replace_quote_single);
	$get_post_search_replace_slashes = str_replace("\\", "/", $get_post_search_replace_quote_double);
	$get_post_search = $get_post_search_replace_slashes;
	
	$get_post_skip_replace_quote_single = str_replace("'", "`", $get_post_skip);
	$get_post_skip_replace_quote_double = str_replace('"', "``", $get_post_skip_replace_quote_single);
	$get_post_skip_replace_slashes = str_replace("\\", "/", $get_post_skip_replace_quote_double);
	$get_post_skip = $get_post_skip_replace_slashes;
	
	// This section modifies the MySQL query based on whether ID or Date information is included in webpage request
	if ((!empty($get_post_id)) && (empty($get_post_search))) { 
		$query_post = " WHERE " . $mysql_post_id . " = '" . $get_post_id . "'"; 
		$query_limit_counter_stop = 1;
		$permalink = "&bull; <a href='index.php?id=" . $get_post_id . "' style='text-decoration:none'>Permalink</a><br><br>";
	}	
	if ((empty($get_post_id)) && (!empty($get_post_search))) { 
		$query_date = " WHERE " . $mysql_post_tags . " LIKE '%" . $get_post_search . "%'"; 
		$query_limit_counter_stop = 1000;
	}	
	if ((empty($get_post_id)) && (empty($get_post_search))) { 
		if (empty($get_post_skip)) { $query_limit_counter_stop = 10; }
	}
	if (!empty($get_post_skip)) { 
		$_SESSION['site_post_skip'] = 'YES';
		$query_limit = "LIMIT 10 OFFSET " . $get_post_skip; 
		$query_limit_counter_stop = 10;
	}
	else {
		$_SESSION['site_post_skip'] = 'NO';
	}
	
	$mysql_post_data = "SELECT * FROM " . $mysql_post_table . $query_post . $query_date . " ORDER BY " . $mysql_post_date . " DESC " . $query_limit; 

	$mysql_post_data_info = mysql_query($mysql_post_data) or die(mysql_error());
	$mysql_post_data_info_count = mysql_num_rows($mysql_post_data_info);
	
	if ($_SESSION['site_post_skip'] != 'YES') {
		$_SESSION['site_post_total'] = $mysql_post_data_info_count;
	}

	echo $html_header;
	
	// This grabs each post that matches the criteria above and goes through each, one at a time
	while($mysql_post_data_info_details = mysql_fetch_array($mysql_post_data_info)){
	
		if ($query_limit_counter < $query_limit_counter_stop) {
		
			if ($post_counter > 0) { echo "\n\n<br><hr><br>"; }
			
			$post_id = $mysql_post_data_info_details[$mysql_post_id];
			$post_title = $mysql_post_data_info_details[$mysql_post_title];
			$post_body = $mysql_post_data_info_details[$mysql_post_body];
			$post_date = $mysql_post_data_info_details[$mysql_post_date];
			$post_tags = $mysql_post_data_info_details[$mysql_post_tags];	

			$body_link_url = str_replace("##LINKURL##", "<a href='", $post_body);
			$body_link_name = str_replace("##LINKNAME##", "'>", $body_link_url);
			$body_link_end = str_replace("##ENDLINK##", "</a>", $body_link_name);	
			$body_image = str_replace("##IMAGE##", "<img src='", $body_link_end);	
			$post_image_end = str_replace("##ENDIMAGE##", "' border='0'>", $body_image);	
			$post_youtube = str_replace("##YOUTUBE##", "<iframe width='640' height='380' src='http://www.youtube.com/embed/", $post_image_end);	
			$post_body = str_replace("##ENDYOUTUBE##", "' frameborder='0' allowfullscreen></iframe>", $post_youtube);		
			
			echo "\n\n<font face='" . $site_font . "' size='5'>\n<b>\n<a href='index.php?id=" . $post_id . "' style='text-decoration:none'>" . $post_title . "</a>\n</b>\n</font>\n<br>\n\n<font face='" . $site_font . "' size='2'>\n<i>Posted: " . $post_date; 
			if (!empty($post_tags)) { echo " &ndash; Tags: " . $post_tags; }
			echo "</i>\n</font>\n<br><br>\n<font face='" . $site_font . "' size='2'>\n" . $post_body . "\n</font>\n<br><br>" . $permalink . "\n\n";
			
			// DISQUS Embed Code [Start]
			
			// DISQUS Embed Code [Stop]
			
			if ($_SESSION['logged_in'] == 'YES') {
			echo "\n\n<form method='post' action='view.php' style='display: inline; margin: 0;'>\n<input type='hidden' name='post_id' value='" . $post_id . "'>\n<input type='submit' value='Modify/Delete Post'>\n</form><br>\n";
			}
				
			$post_counter += 1;	
		}	
		
		$query_limit_counter += 1;	
		
		
	}
	// This section determines how to display Older/Newer links at the bottom of pages
	if (!empty($get_post_skip)) {
		$get_post_skip_next = $get_post_skip + 10;
		if ($get_post_skip_next > $_SESSION['site_post_total']) {
			echo "\n<br><br>\n<center><a href='index.php?skip=" . ($get_post_skip - 10) . "' style='text-decoration:none'>Newer Posts &rarr;</a></center>"; 
		}
		else {		
			if ($get_post_skip_next > 10) { 
				echo "\n<br><br>\n<center><a href='index.php?skip=" . $get_post_skip_next . "' style='text-decoration:none'>&larr; Older Posts</a> | <a href='index.php?skip=" . ($get_post_skip_next - 10) . "' style='text-decoration:none'>Newer Posts &rarr;</a></center>"; 
			}
		}
		
	}
	if ((empty($get_post_skip)) && ($_SESSION['site_post_total'] > 10)) { echo "\n<br><br>\n<center><a href='index.php?skip=10' style='text-decoration:none'>&larr; Older Posts</a></center>"; }
	
	echo $html_footer;

?>
Return current item: OpenBlog mini