require_once("./.inc/globals.inc.php"); //////////////////////////////////////////////////////////////// // Check if "id" is set; if not, they shouldn't be here. //////////////////////////////////////////////////////////////// if (!isset($_SERVER["PATH_INFO"]) || $_SERVER["PATH_INFO"] == "/") { header ("Location: " . $webvars["SERVER_ROOT"]); //wc_track_now(); // Let's log it. exit; } //////////////////////////////////////////////////////////////// $mysql = mysql_pconnect("", $webvars["DB_USER"], $webvars["DB_PWD"]); mysql_select_db($webvars["DB_MAIN"]); list($junk, $request) = split("/", $_SERVER["PATH_INFO"], 2); function get_blog_name($id) { $sql_txt = "select name from blog_entries where entry_id=$id"; $result = mysql_query($sql_txt); if ($result && mysql_num_rows($result)) { $entry = mysql_fetch_row($result); return stripslashes($entry[0]); } } if (is_numeric($request)) { $webvars["PAGE_TITLE"] = get_blog_name($request); print_header(); print_blog_entry_with_comments($request); } else if(strpos($request, "/") == false) { $sql_txt = "select entry_id from blog_entries where mnemonic='$request'"; $result = mysql_query($sql_txt); if ($result && mysql_num_rows($result)) { $entry = mysql_fetch_row($result); $id = $entry[0]; $webvars["PAGE_TITLE"] = get_blog_name($id); print_header(); print_blog_entry_with_comments($id); } else { header ("Location: " . $webvars["SERVER_ROOT"]); //wc_track_now(); // Let's log it. exit; } } else { $datereq_array = preg_split('/(\/)/', $request); $year = array_shift($datereq_array); $month = array_shift($datereq_array); $day = array_shift($datereq_array); if (is_numeric($year) && is_numeric($month)) { $long_month = date("F", strtotime("$year-$month-01")); $webvars["PAGE_TITLE"] = "Archives for $long_month $year"; print_header(); echo ''; // Indexing the articles is good, but not these monthly summaries if (is_numeric($day)) { $sql_txt = "select date_format(ts_created, '%Y/%m/%d'), name, date_format(ts_created, '%a, %e %b %Y') from blog_entries where date_format(ts_created, '%Y%m%d') > '$year$month$day' order by ts_created limit 1"; $result = mysql_query($sql_txt); if ($result && mysql_num_rows($result)) { $entry = mysql_fetch_row($result); $yymmdd = $entry[0]; $name = $entry[1]; $long_date = $entry[2]; $next_link = "See next newer entry: $name ($long_date)"; } else $next_link = ""; $sql_txt = "select date_format(ts_created, '%Y/%m/%d'), name, date_format(ts_created, '%a, %e %b %Y') from blog_entries where date_format(ts_created, '%Y%m%d') < '$year$month$day' order by ts_created desc limit 1"; $result = mysql_query($sql_txt); if ($result && mysql_num_rows($result)) { $entry = mysql_fetch_row($result); $yymmdd = $entry[0]; $name = $entry[1]; $long_date = $entry[2]; $prev_link = "See next older entry: $name ($long_date)"; } else $prev_link = ""; $sql_txt = "select entry_id from blog_entries where date_format(ts_created, '%Y%m%d') = '$year$month$day' order by ts_created desc"; } else { // // This is for the monthly display // $timestamp_for_displayed_month = strtotime("$year-$month-01"); $sql_txt = "select date_format(ts_created, '%Y/%m'), date_format(ts_created, '%M %Y') from blog_entries where date_format(ts_created, '%Y%m') > '$year$month' order by ts_created limit 1"; $result = mysql_query($sql_txt); if ($result && mysql_num_rows($result)) { $entry = mysql_fetch_row($result); $yymm = $entry[0]; $long_date = $entry[1]; $next_link = "See next newer month: $long_date"; } else $next_link = ""; $sql_txt = "select date_format(ts_created, '%Y/%m'), date_format(ts_created, '%M %Y') from blog_entries where date_format(ts_created, '%Y%m') < '$year$month' order by ts_created desc limit 1"; $result = mysql_query($sql_txt); if ($result && mysql_num_rows($result)) { $entry = mysql_fetch_row($result); $yymm = $entry[0]; $long_date = $entry[1]; $prev_link = "See next older month: $long_date"; } else $prev_link = ""; //$next_yymm = date("Y/m", $timestamp_for_displayed_month + 60*60*24*40); // 40 days from the first of this month should always be next month //$next_long_yymm = date("F Y", $timestamp_for_displayed_month + 60*60*24*40); // 40 days from the first of this month should always be next month //$next_link = "See next newer month: $next_long_yymm"; //$prev_yymm = date("Y/m", $timestamp_for_displayed_month - 60*60*24*20); // 20 days from the first of this month should always be next month //$prev_long_yymm = date("F Y", $timestamp_for_displayed_month - 60*60*24*20); // 20 days from the first of this month should always be next month //$prev_link = "See next older month: $prev_long_yymm"; $sql_txt = "select entry_id from blog_entries where date_format(ts_created, '%Y%m') = '$year$month' order by ts_created desc"; } $result = mysql_query($sql_txt); if($result) { if (mysql_num_rows($result)) { $num_rows = mysql_num_rows($result); for ($i = 0; $i < $num_rows; $i++) { $entry = mysql_fetch_row($result); $id = $entry[0]; print_blog_entry_with_comments($id); } } echo "