FRONTPAGE

FRONTPAGE

<?php

$mikepage = 0;
$start_at = 0;
$items_per_page = 13;
if (array_key_exists('mpage', $_REQUEST)) {
$mikepage = $_REQUEST['mpage'];
$start_at = ($mikepage) * $items_per_page;
}

$q = "select SQL_CALC_FOUND_ROWS post_title, post_content, post_date, post_name from wp_posts where post_status = 'publish' and post_type = 'post' order by post_date desc limit $start_at, $items_per_page";
$r = mysql_query($q);

$count_q = "SELECT FOUND_ROWS()";
$count_r = mysql_query($count_q);
$total_posts = mysql_result($count_r, 0);

$total_pages = ceil($total_posts / $items_per_page);

echo "“;
if ($mikepage > $total_pages) {
$mikepage = $total_pages;
$start_at = ($mikepage – 1) * $items_per_page;
$q = “select SQL_CALC_FOUND_ROWS post_title, post_content, post_date, post_name from wp_posts where post_status = ‘publish’ and post_type = ‘post’ order by post_date desc limit $start_at, $items_per_page”;
$r = mysql_query($q);
}

if ($total_posts == 0) {
echo ”

For 91 Days in Istanbul is Coming Very Soon

“;
}
while ($l = mysql_fetch_array($r, MYSQL_ASSOC)) {
$post_title = $l[‘post_title’];
$post_content = $l[‘post_content’];
$post_datetime = $l[‘post_date’];
$post_name = $l[‘post_name’];
$post_timestr = strtotime($post_datetime);

$linkdate = date(“y/m/d”, $post_timestr);
$pubdate = date (“M d, Y”, $post_timestr);

// get the image
$img_src = “http://for91days.com/photos/Thumbs/”.$post_name.”.jpg”;

$excerpt_begin = ““;
$excerpt_end = ““;
$excerpt_beginpos = strpos($post_content, $excerpt_begin) + strlen($excerpt_begin);
$trimmed_content = substr($post_content, $excerpt_beginpos);
$excerpt_endpos = strpos($trimmed_content, $excerpt_end);
$trimmed_content = substr($trimmed_content, 0, $excerpt_endpos);
$trimmed_content = strip_tags($trimmed_content);
if (in_array(substr($trimmed_content, -1), array(‘.’, ‘!’))) {
$trimmed_content = substr($trimmed_content, 0, -1);
}
if (substr($trimmed_content, -3) != ‘…’) {
$trimmed_content .= “…”;
}
$trimmed_content .= ” Read More“;

$post_link = “http://istanbul.for91days.com/$linkdate/$post_name/”;

echo ”

$post_title
$trimmed_content

$pubdate

“;
}

echo “

“;
if ($mikepage > 0) {
$prevpage = $mikepage – 1;
echo “NEWER“;

if ($mikepage < $total_pages) { echo " | "; }
}
if ($mikepage < ($total_pages-1)) {
$nextpage = $mikepage + 1;
echo "OLDER“;
}
echo “

“;
?>