<?
// Copyright (C) Bloggie Lite Written by : Sean
// http://www.mywebland.com , http://mybloggie.mywebland.com
// You are requested to retain this copyright notice in order to use
// this software.
//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either version 2
//of the License, or (at your option) any later version.
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software
//Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
if ( !defined('IN_BLOGGIE') ) {
die("You are not allowed to access this page directly !");
}
if ( !function_exists('time_format') ) {
function time_format($timestamp) {
$time = date('h:i a', $timestamp) ;
return $time;
}
}
if ( !function_exists('date_format') ) {
function date_format($timestamp) {
global $lang;
$dt = date("d", $timestamp) ;
$shortmth = date("M", $timestamp) ;
$yr = date("Y", $timestamp) ;
$date = $dt." ".$lang["$shortmth"]." ".$yr;
return $date;
}
}
if ( !function_exists('return_day') ) {
function return_day($timestamp) {
global $lang;
$dt = date("d", $timestamp) ;
$date = $dt;
return $date;
}
}
if ( !function_exists('return_mth') ) {
function return_mth($timestamp) {
global $lang;
$shortmth = date("M", $timestamp) ;
$date = $lang["$shortmth"];
return $date;
}
}
if ( !function_exists('return_year') ) {
function return_year($timestamp) {
global $lang;
$yr = date("Y", $timestamp) ;
$date = $yr;
return $date;
}
}
if ( !function_exists('smenu') ) {
function smenu() {
global $func_list, $pref_data,$current_timestamp, $db, $site_url, $lang, $template, $sef_method, $perma_link, $link_format, $cat_format, $archives_format;
$template->set_filenames(array(
'sidemenu' => 'sidemenu.tpl'));
$sql = "SELECT post_id, perm_subj, subject, timestamp FROM ".POST_TBL."
WHERE ".POST_TBL.".timestamp<='".$current_timestamp."'
ORDER BY timestamp DESC limit 0 , ".$pref_data['recent_limit'];
$result = $db->sql_query($sql) ;
$template->assign_block_vars('recent', array(
'RECENT_POSTS' => $lang['Recent'],
));
while ($row = $db->sql_fetchrow($result)) {
$time_YYYYMMDD = time_YYYYMMDD($row['timestamp']);
$perma_link->assign_vars(array(
'READ' => "read",
'YYYY' => $time_YYYYMMDD['YYYY'],
'MM' => $time_YYYYMMDD['MM'],
'DD' => $time_YYYYMMDD['DD'],
'TITLE' => $row['perm_subj'],
'POST_ID' => $row['post_id'],
));
$modified_link = $perma_link->parse($link_format);
$sef_url = $site_url."/".$modified_link;
$template->assign_block_vars('recent.loops', array(
'TITLE' => $row['subject'],
'LINK' => $sef_url
));
}
unset($result);
unset($row);
$sql= "SELECT DISTINCT ".POST_TBL.".cat_id AS c, ".CAT_TBL.".cat_id, ".CAT_TBL.".cat_perma, ".CAT_TBL.".cat_desc, COUNT( 'c' ) as z
FROM ".POST_TBL.", ".CAT_TBL."
WHERE ".POST_TBL.".cat_id = ".CAT_TBL.".cat_id AND ".POST_TBL.".timestamp<='".$current_timestamp."'
GROUP BY c
ORDER BY ".CAT_TBL.".cat_desc ASC"
;
$result = $db->sql_query($sql) ;
$template->assign_block_vars('categories', array(
'CATEGORIES' => $lang['Categories']
));
while ($row = $db->sql_fetchrow($result)) {
$perma_link->assign_vars(array(
'CAT' => "category",
'CAT_DESC' => $row['cat_perma'],
'CAT_ID' => $row['cat_id'],
));
$modified_link = $perma_link->parse($cat_format);
$sef_url = $site_url."/".$modified_link;
$template->assign_block_vars('categories.loops', array(
'TITLE' => $row['cat_desc'],
'LINK' => $sef_url,
));
}
unset($result);
unset($row);
$sql= "SELECT DATE_FORMAT( FROM_UNIXTIME( `timestamp` ) , '%m' ) AS m,
DATE_FORMAT( FROM_UNIXTIME( `timestamp` ) , '%Y' ) AS y, COUNT( 'm' ) as t, timestamp
FROM ".POST_TBL."
WHERE ".POST_TBL.".timestamp<='".$current_timestamp."'
GROUP BY m , y
ORDER BY y DESC , m DESC
LIMIT 0 , ".$pref_data['archive_limit'];
if ( !($result = $db->sql_query($sql)) ) {
$sql_error = $db->sql_error(); echo $sql_error['message'];
}
$result = $db->sql_query($sql) ;
$template->assign_block_vars('archives', array(
'ARCHIVES' => $lang['Archives'],
));
while ($row = $db->sql_fetchrow($result)) {
switch ($row['m']) {
case 1: $mthfulltext = $lang['January']; break;
case 2: $mthfulltext = $lang['February']; break;
case 3: $mthfulltext = $lang['March']; break;
case 4: $mthfulltext = $lang['April']; break;
case 5: $mthfulltext = $lang['May']; break;
case 6: $mthfulltext = $lang['June']; break;
case 7: $mthfulltext = $lang['July']; break;
case 8: $mthfulltext = $lang['August']; break;
case 9: $mthfulltext = $lang['September']; break;
case 10: $mthfulltext = $lang['October']; break;
case 11: $mthfulltext = $lang['November']; break;
case 12: $mthfulltext = $lang['December']; break;
}
$perma_link->assign_vars(array(
'ARC' => "archives",
'MTH' => $row['m'],
'YR' => $row['y'],
));
$modified_link = $perma_link->parse($archives_format);
$sef_url = $site_url."/".$modified_link;
$template->assign_block_vars('archives.loops', array(
'TITLE' => $mthfulltext." ".$row['y'],
'LINK' => $sef_url,
));
}
$template->pparse('sidemenu');
}
add_func_list("sidemenu", "smenu", 0, 5);
}
if ( !function_exists('nav_menu') ) {
function nav_menu() {
global $lang, $template, $site_url;
$nav_menu ="<a href=\"".$site_url."/index.php\">".$lang['Home']."</a> | <a href=\"".$site_url."/admin/admin.php\">".$lang['Admin']."</a>";
$template->assign_vars(array(
'NAV_MENU' => $nav_menu,
));
}
add_func_list("nav_bar", "nav_menu", 0, 1);
}
/**
if ( !function_exists('misc_menu1') ) {
function misc_menu1() {
global $func_list, $pref_data, $site_url, $lang, $template, $mode;
// echo $mode;
if ($mode =="plugin" || $mode =="plugin" ) {
$template->assign_block_vars('misc', array(
'CURRENT_MISC' => " class=\"current\"",
'MISC_MENU' => "<a href=\"".$_SERVER['PHP_SELF']."?mode=plugin\">Testing</a>",
));
} else {
$template->assign_block_vars('misc', array(
'MISC_MENU' => "<a href=\"".$_SERVER['PHP_SELF']."?mode=plugin\">Testing</a>",
)); }
}
// add_func_list("admin_menu", "misc_menu1", 1, 10);
function do_mode() {
global $func_list, $pref_data, $template, $mode;
switch ($mode) {
case "plugin":
include 'plugin.php';
break;
}
return true;
}
add_func_list("admin_menu", "misc_menu1", 0, 10);
add_func_list("mode_to_php", "do_mode", 0,10);
} ***/
?>