Location: PHPKode > projects > Bloggie Lite > admin/admin.php
<?

// 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.

//error_reporting('E_ALL');

$bloggie_root_path = "../";
define('IN_BLOGGIE', true);

include_once($bloggie_root_path.'init.php');

$style  =  &$pref_data['default_style'] ;
$template = new Template('../templates/'.$style.'/');
include_once($bloggie_root_path.'includes/functions-pluggable.php');

$timezone = $pref_data['gmt'];
$bloggie_path = $pref_data['bloggie_path'];
include_once($bloggie_root_path.'language/'.$pref_data['language']);

define('USER_COOKIE', 'USER_'.md5($pref_data['cookie_name']));
define('PASS_COOKIE', 'PASS_'.md5($pref_data['cookie_name']));

if (!authenticate()) {
redirect($bloggie_path."/login.php");
}

if (isset($_GET['mode'])) $mode=htmlspecialchars($_GET['mode']);  else { unset($mode); }
if (isset($_GET['select'])) { $select=$_GET['select']; } else { $select=""; }

$site_url =  $pref_data['bloggie_path'];
define("PATH_COOKIE", preg_replace("|http://[^/]+|is","", $site_url."/" ));
$cookie_domain=parse_url($site_url);
if(!strpos("-".$cookie_domain['host'], ".")) {
   $cookie_host= false;
}
else {
   define('DOMAIN_COOKIE', ".".$cookie_domain['host']);
}
if ( !defined('DOMAIN_COOKIE') ) define('DOMAIN_COOKIE', $cookie_host);

if ( isset($mode) && $mode=="logoff" ) {
clear_cookie();
nocache();
redirect($bloggie_root_path."index.php");
exit;
}


//echo $template->

//session_start();     


$mth_text[0]  = $lang['January'];
$mth_text[1]  = $lang['February'];
$mth_text[2]  = $lang['March'];
$mth_text[3]  = $lang['April'];
$mth_text[4]  = $lang['May'];
$mth_text[5]  = $lang['June'];
$mth_text[6]  = $lang['July'];
$mth_text[7]  = $lang['August'];
$mth_text[8]  = $lang['September'];
$mth_text[9]  = $lang['October'];
$mth_text[10] = $lang['November'];
$mth_text[11] = $lang['December'];



$template->set_filenames(array(
      'adminheader'   => 'admin/admin_header.tpl',
      'code'          => 'admin/code.tpl',
      'commentcode'   => 'admin/commentcode.tpl',
      'blog_body'     => 'admin/blog_body.tpl',
      'formsubmit'    => 'admin/formsubmit.tpl',
      'admincontent'  => 'admin/admincontent.tpl',
      'list'          => 'admin/list_body.tpl',
      'comment-list'  => 'admin/comment-list.tpl',
      'footer'        => 'admin/adminfooter.tpl',
      'userlist'      => 'admin/user_list_body.tpl',

));

$template->assign_vars(array(
     'CHAR_SET'          => $pref_data['encoding'],
     'CONTENT_DIRECTION' => $content_direction,
     'STYLE'             => $style,
     'TIME'              => 'Time [GMT '.$timezone.'] : '.gmtdate('d M , H:i:s', time(), $timezone ),
     'FONT_FAMILY'       => $pref_data['font_family']  ,
     'VERSION'           => $pref_data['version'],
     'ADMIN_TITLE'       => $lang['Admin_area'],
     'BLOG_NAME'         => $pref_data['blog_name'],
     'L_ID'              => $lang['Id'] ,
     'L_APPROVED'        => $lang['Approved'] ,
     'L_APPROVE'         => $lang['Approve'],
     'CONFIRMATION'      => $lang['Del_Msg_Alert']
));

if(authenticate()) {
  $userdata = authenticate();
  $sql    = "SELECT id, user, level FROM ".USER_TBL." WHERE user='".$userdata['username']."'" ;

if( !($result = $db->sql_query($sql)) )
   {
    $sql_error = $db->sql_error();
    error($lang['Error'], $sql_error['message']);
   }
  $row = $db->sql_fetchrow($result) ;
  $userlevel =   $row['level'];
  $userid    =   $row['id'];
$template->assign_block_vars('logoff', array(
           'L_LOGOFF'       => "<a class=\"std\" href=\"".$_SERVER['PHP_SELF']."?mode=logoff\">".$lang['Logoff']."</a>",
             ));
}

//echo $userlevel;  //Debug code
if ($userlevel==1) {
$template->assign_vars(array(
     'MENU'             => 'Home',
     'L_USER_LIST'      => $lang['User_listing'],
     'L_CATEGORY'       => $lang['Category'],
     'L_LEVEL'          => $lang['Level'],
     'L_POSTED_BY'      => $lang['Posted By'],
     'L_TIME'           => $lang['Time'],
     'L_DATE'           => $lang['Date'],
     'L_LIST'           => $lang['Listing'],
     'L_NAME'           => $lang['Name'],
     'L_MESSAGE'        => $lang['Message'],
     'L_SUBJECT'        => $lang['Subject'],
     'L_CATEGORY'       => $lang['Category'],
     'L_DEL'            => $lang['Del'],
     'L_EDIT'           => $lang['Edit'],
     'L_COMMENTS'       => $lang['Comments'],
     'L_TRACKBACK_URLS' => $lang['Trackback_urls'],
     'L_DATE_POST'      => $lang['Publish_Date'],
     'L_EDIT_TIMESTAMP' => $lang['Edit_Timestamp'],
     'L_UID'            => $lang['User_id'],
     'USER_NAME'        => $userdata['username'],
     'L_ENABLE_PING'    => $lang['Enable_Ping'],
     'L_ENABLE_COMMENT' => $lang['Enable_Comment'],
     'L_OPTIONS'        => $lang['Options'],
     'L_FONT_COLOR'     => $lang['Font_Color'],
     'L_DEFAULT'        => $lang['Default'],
     'ADMINIMAGE'       => "images/adminpanel.jpg",
     'MENU_HOME'        => "<a href=\"../index.php\">Blog Home</a>",
     'MENU_ADD'         => "<a href=\"".$_SERVER['PHP_SELF']."?mode=add\">".$lang['New_post']."</a>",
     'MENU_EDIT'        => "<a href=\"".$_SERVER['PHP_SELF']."?mode=editlist\" title=\"".$lang['Post'].", ".$lang['Comment']."\">".$lang['Edit']."</a>",
     'MENU_MANAGE'         => "<a href=\"".$_SERVER['PHP_SELF']."?mode=manage\" title=\"".$lang['Category'].", ".$lang['User_Admin'].", ".$lang['Plugin'].", ".$lang['Permalink']."\">".$lang['Manage']."</a>",
//     'MENU_CAT'         => "<a href=\"".$_SERVER['PHP_SELF']."?mode=catadmin\">".$lang['Category']."</a>",
//     'MENU_USER'        => "<a href=\"".$_SERVER['PHP_SELF']."?mode=useradmin\">".$lang['User_Admin']."</a>",
     'MENU_OPTIONS'     => "<a href=\"".$_SERVER['PHP_SELF']."?mode=options\">".$lang['Options']."</a>",
));
//if  (!isset($mode)) $mode="";
execute("admin_menu");
} elseif ($userlevel==2) {
$template->assign_vars(array(
     'MENU'             => 'Home',
     'ADMIN_TITLE'      => "- ". $lang['Admin_area'],
     'L_USER_LIST'      => $lang['User_listing'],
     'L_CATEGORY'       => $lang['Category'],
     'L_LEVEL'          => $lang['Level'],
     'L_POSTED_BY'      => $lang['Posted By'],
     'L_TIME'           => $lang['Time'],
     'L_DATE'           => $lang['Date'],
     'L_LIST'           => $lang['Listing'],
     'L_NAME'           => $lang['Name'],
     'L_MESSAGE'        => $lang['Message'],
     'L_SUBJECT'        => $lang['Subject'],
     'L_CATEGORY'       => $lang['Category'],
      'L_DEL'           => $lang['Del'],
      'L_EDIT'          => $lang['Edit'],
     'USER_NAME'        => $username,
     'ADMINIMAGE'       => "images/adminpanel.jpg",
//     'MENU_HEADER1'     => "Blog Admin - User",
     'MENU_HOME'        => "<a href=\"index.php\">Blog Home</a>",
     'MENU_ADD'         => "<a href=\"".$_SERVER['PHP_SELF']."?mode=add\">".$lang['New_post']."</a>",
     'MENU_EDIT'        => "<a href=\"".$_SERVER['PHP_SELF']."?mode=editlist\">".$lang['Edit']."</a>",
     'MENU_OPTIONS'       => "<a href=\"".$_SERVER['PHP_SELF']."?mode=options\">".$lang['Options']."</a>",
//     'MENU_HEADER2'     => $lang['User_Admin'],
//     'MENU_HEADER3'     => "File Management",
));

}

     //print_r($func_list);


if (isset($mode)) {

     if ($mode =="add") {
        $template->assign_vars(array(
        'CURRENT_ADD'      => " class=\"current\"",
        ));
     }
     elseif ($mode =="editlist" || $mode =="edit" || $mode =="commentlist" || $mode =="editcom") {
        $template->assign_vars(array(
        'CURRENT_EDIT'      => " class=\"current\"",
        ));
        if ($mode =="editlist") {
        $template->assign_block_vars('editsubmenu', array(
        'SUBMENU_1'  => "<a href=\"".$_SERVER['PHP_SELF']."?mode=editlist\" class=\"current\">".$lang['Edit']."</a>",
        'SUBMENU_2'  => "<a href=\"".$_SERVER['PHP_SELF']."?mode=commentlist\">".$lang['Comments']."</a>",
        ));
        $template->assign_block_vars('switchjs', array( ));
        }
        elseif ($mode =="commentlist" || $mode =="editcom") {
        $template->assign_block_vars('editsubmenu', array(
        'SUBMENU_1'  => "<a href=\"".$_SERVER['PHP_SELF']."?mode=editlist\">".$lang['Edit']."</a>",
        'SUBMENU_2'  => "<a href=\"".$_SERVER['PHP_SELF']."?mode=commentlist\" class=\"current\">".$lang['Comments']."</a>",
        ));
        }
     }
     elseif ($mode =="manage" || $mode =="catadmin" || $mode =="useradmin" || $mode =="permalink" || $mode =="plugin") {
        $template->assign_vars(array(
        'CURRENT_MANAGE'      => " class=\"current\"",
        ));
        if ($mode =="catadmin" || $mode =="manage" ) {
        $template->assign_block_vars('managesubmenu', array(
        'SUBMENU_1'  => "<a href=\"".$_SERVER['PHP_SELF']."?mode=catadmin\" class=\"current\">".$lang['Category']."</a>  ",
        'SUBMENU_2'  => "<a href=\"".$_SERVER['PHP_SELF']."?mode=useradmin\">".$lang['User_Admin']."</a>",
        'SUBMENU_3'  => "<a href=\"".$_SERVER['PHP_SELF']."?mode=plugin\">".$lang['Plugin']."</a>",
        'SUBMENU_4'  => "<a href=\"".$_SERVER['PHP_SELF']."?mode=permalink\">".$lang['Permalink']."</a>",

        ));
        }
        elseif ($mode =="useradmin") {
        $template->assign_block_vars('managesubmenu', array(
        'SUBMENU_1'  => "<a href=\"".$_SERVER['PHP_SELF']."?mode=catadmin\">".$lang['Category']."</a>  ",
        'SUBMENU_2'  => "<a href=\"".$_SERVER['PHP_SELF']."?mode=useradmin\" class=\"current\">".$lang['User_Admin']."</a>",
        'SUBMENU_3'  => "<a href=\"".$_SERVER['PHP_SELF']."?mode=plugin\">".$lang['Plugin']."</a>",
        'SUBMENU_4'  => "<a href=\"".$_SERVER['PHP_SELF']."?mode=permalink\">".$lang['Permalink']."</a>",
        ));
        }
        elseif ($mode =="plugin") {
        $template->assign_block_vars('managesubmenu', array(
        'SUBMENU_1'  => "<a href=\"".$_SERVER['PHP_SELF']."?mode=catadmin\">".$lang['Category']."</a>  ",
        'SUBMENU_2'  => "<a href=\"".$_SERVER['PHP_SELF']."?mode=useradmin\">".$lang['User_Admin']."</a>",
        'SUBMENU_3'  => "<a href=\"".$_SERVER['PHP_SELF']."?mode=plugin\" class=\"current\">".$lang['Plugin']."</a>",
        'SUBMENU_4'  => "<a href=\"".$_SERVER['PHP_SELF']."?mode=permalink\">".$lang['Permalink']."</a>",
        ));
        }
        elseif ($mode =="permalink") {
        $template->assign_block_vars('managesubmenu', array(
        'SUBMENU_1'  => "<a href=\"".$_SERVER['PHP_SELF']."?mode=catadmin\">".$lang['Category']."</a>  ",
        'SUBMENU_2'  => "<a href=\"".$_SERVER['PHP_SELF']."?mode=useradmin\">".$lang['User_Admin']."</a>",
        'SUBMENU_3'  => "<a href=\"".$_SERVER['PHP_SELF']."?mode=plugin\">".$lang['Plugin']."</a>",
        'SUBMENU_4'  => "<a href=\"".$_SERVER['PHP_SELF']."?mode=permalink\" class=\"current\">".$lang['Permalink']."</a>",
        ));
        }
     }
     elseif ($mode =="options" || $mode =="setting" ) {
     $template->assign_vars(array(
     'CURRENT_OPTIONS'      => " class=\"current\"",
     ));
        if ($mode =="options" || $mode =="setting" ) {
        $template->assign_block_vars('optionssubmenu', array(
           'SUBMENU_1'  => "<a href=\"".$_SERVER['PHP_SELF']."?mode=setting\" class=\"current\">".$lang['Settings']."</a>",
            ));
        }
     }
}
$template->pparse('adminheader');
//include($mybloggie_root_path.'spacer6.php');
//$template->pparse('adminmenu');
//$template->pparse('sidevert');

if (isset($mode)) {
execute('mode_to_php', $mode);
    switch ($mode) {
    case "add":
    $template->pparse('code');
    include 'add.php';
    break;
    case "set" :
    include 'set.php';
    break;
    case "del":
    include 'del.php';
    break;
    case "deluser":
    include 'deluser.php';
    break;
    case "edit":
    $template->pparse('code');
    include 'edit.php';
    break;
    case "edituser":
    include 'edituser.php';
    break;
    case "editlist":
    include 'edit_list.php';
    break;
    case "clist":
    include 'comment_list.php';
    break;
    case "commentlist":
    include_once ($bloggie_root_path.'includes/function-format.php');
    include 'comment-list.php';
    break;
    case "editcom":
    $template->pparse('commentcode');
    include 'editcom.php';
    break;
    case "catadmin":
    case "manage":
    include 'catadmin.php';
    break;
    case "useradmin":
    include 'useradmin.php';
    break;
    case "permalink":
    include 'linkadmin.php';
    break;
    case "setting":
    include 'settings.php';
    break;
    case "options":
    include 'settings.php';
    break;
    case "plugin":
    include 'plugin.php';
    break;

/**    case "edituserlist":
    include 'edituserlist.php';
    break;
    case "deluserlist":
    include 'deluserlist.php';
    break; **/

//    default:
//    $template->assign_vars(array(
//     'VERSION_INFO'      => versioncheck($pref_data['version']),
//    ));
//    $template->pparse('admincontent') ; break;

  }
}

if (!isset($mode)) {
    $template->assign_vars(array(
     'VERSION_INFO'      => versioncheck($pref_data['version']),
    ));
   $template->pparse('admincontent') ;
}

$template->pparse('footer');
//}

?>
Return current item: Bloggie Lite