0 ? " AND YEAR(created_at) = $year" : "" ) . ( $month > 0 ? " AND MONTH(created_at) = $month" : "" ) . " ORDER BY created_at DESC LIMIT $offset,$num;" ); $prev_link = $page - 1; $next_link = 0; if ( count( $posts ) == $num ) { array_pop( $posts ); $next_link = $page + 1; } } function load_single_post($id = 0) { if ( $id == 0 ) { $id = mysql_insert_id(); } load_posts( "SELECT *, CONVERT_TZ(created_at, '+00:00', '" . get_profile_timezone() . "') AS created_at FROM users, log WHERE log.id = $id AND users.id = log.user_id LIMIT 1;" ); } function load_posts( $query ) { global $posts, $curPost, $post; $result = mysql_query( $query ); $posts = array(); $curPost = 0; while ( $row = mysql_fetch_assoc($result) ) { $posts[] = $row; } if ( have_posts() ) { $post = $posts[ 0 ]; } } function rewind_posts() { global $posts, $curPost; $curPos = 0; } function have_posts() { global $posts, $curPost; return count( $posts ) > 0 && $curPost < count( $posts ); } function the_post() { global $post, $posts, $curPost; $post = $posts[ $curPost++ ]; } function the_author() { global $post; echo $post['name']; } function the_author_name() { global $post; echo $post['fullname']; } function has_author_icon() { global $post; return !!$post['icon'] && $post['icon'] != 'http://'; } function the_author_icon() { global $post; echo $post['icon']; } function the_author_location() { global $post; echo $post['location']; } function the_permalink() { global $conf, $post; $slug = get_slug(); // TODO: Dynamic URL echo $conf['site.url'] . "/" . get_time( "Y/m" ) . "/" . ( empty( $slug ) ? "" : "$slug/" ) . $post['id'] . "/"; } function the_author_link() { global $conf, $post; // TODO: Dynamic URL echo $conf['site.url'] . "/" . $post['name'] . "/"; } function the_title() { echo get_title(); } function get_title() { $parts = explode( " ", get_text_content() ); return ereg_replace( "[.,?!;:]$", "", join(" ", array_slice( $parts, 0, 4 )) ) . ( count( $parts ) > 4 ? "..." : "" ); } function get_slug() { $parts = explode( " ", trim( ereg_replace( "[^a-zA-Z0-9 ]", "", get_text_content() ) ) ); return strtolower( join("-", array_slice( $parts, 0, 4 )) ); } function the_ID() { global $post; echo $post['id']; } function the_time( $format="F jS, Y" ) { echo get_time( $format ); } function get_time( $format="F jS, Y" ) { global $post; return date( $format, strtotime( $post['created_at'] ) ); } function the_content() { echo get_content(); } function get_content() { global $conf, $post; $text = $post['text']; $text = ereg_replace("\\\\", "", $text); $text = ereg_replace("([^[]|^)(https?://(www\\.)?([^/ ]+)[^ ]*)", "\\1\\4", $text); $text = ereg_replace("\\[([^ ]+) ([^]]+)\\]", "\\2", $text); $text = ereg_replace("^@(([a-zA-Z_-]+)[^ ]*)", "\\1", $text); return $text; } function get_text_content() { global $post; return ereg_replace( "\\[[^ ]+ ([^]]+)\\]", "\\1", ereg_replace("\\\\", "", $post['text'])); } function link_posts( $before = '', $num = 'next', $next = "« Older", $prev = "Newer »" ) { global $prev_link, $next_link; // TODO: Dynamic URL if ( $prev_link > 0 || $next_link > 0 ) { echo $before; if ( $next_link > 0 ) { echo ""; } if ( $prev_link > 0 ) { echo " 1 ? "/page/$prev_link/" : "/" ) . "' class='prev'>$prev"; } echo $after; } } ?>