<?php

/**
 * @package eggblog
 * @author eggblog.net, tenfourzero@users.sourceforge.net
 * @version $Id: v4.0RC3 2008/01/21 11:25:04 tenfourzero Exp $
 * @copyright Copyright (c) 2005, http://www.eggblog.net
 * @license http://www.gnu.org/licenses/gpl.html GNU Lesser General Public License
 */


/**
 * require lib files
 */
require_once "_lib/global.php";

eb_pre();
if(empty($_SESSION['user_id'])) header("Location: index.php");
elseif(!eb_checkadmin($_SESSION['user_id'])) header("Location: index.php");
else {
	if(!empty($_GET['id'])) {
		$_GET['id']=htmlentities($_GET['id'],ENT_QUOTES);
		if($_GET['id']=="config") $output=eb_admin_config();
		elseif($_GET['id']=="newarticle") $output=eb_admin_newarticle();
		elseif($_GET['id']=="newphoto") $output=eb_admin_newphoto();
		elseif($_GET['id']=="newalbum") $output=eb_admin_newalbum();
		elseif($_GET['id']=="update") $output=eb_admin_update();
		elseif($_GET['id']=="members") $output=eb_admin_members(10);
		eb_head('');
		echo $output;
		eb_foot();
	}
	elseif(isset($_GET['deletearticle'])) {
		settype($_GET['deletearticle'],"integer");
		@mysql_query("UPDATE eb_articles SET article_flag=0 WHERE article_id=".$_GET['deletearticle']);
		header("Location: index.php");
	}
	elseif(isset($_GET['deletecomment'])) {
		settype($_GET['deletecomment'],"integer");
		settype($_GET['article'],"integer");
		$sql="DELETE FROM eb_comments WHERE comment_id=".$_GET['deletecomment'];
		@mysql_query($sql);
		header("Location: news.php?id=".$_GET['article']);
	}
	elseif(isset($_GET['deletetopic'])) {
		settype($_GET['deletetopic'],"integer");
		$sql="DELETE FROM eb_topics WHERE topic_id=".$_GET['deletetopic'];
		@mysql_query($sql);
		$sql="DELETE FROM eb_posts WHERE topic_id=".$_GET['deletetopic'];
		@mysql_query($sql);
		header("Location: forum.php");
	}
	elseif(isset($_GET['deletepost'])) {
		settype($_GET['deletepost'],"integer");
		settype($_GET['topic'],"integer");
		$sql="DELETE FROM eb_posts WHERE post_id=".$_GET['deletepost'];
		@mysql_query($sql);
		header("Location: forum.php?topic=".$_GET['topic']);
	}
	elseif(!empty($_GET['deletemember'])) {
		settype($_GET['deletemember'],"integer");
		eb_admin_deletemember($_GET['deletemember']);
	}
	elseif(!empty($_GET['deletephoto']) && !empty($_GET['album'])) {
		settype($_GET['deletephoto'],"integer");
		settype($_GET['album'],"integer");
		eb_admin_deletephoto($_GET['deletephoto'],$_GET['album']);
	}
	elseif(!empty($_GET['deletealbum'])) {
		settype($_GET['deletealbum'],"integer");
		eb_admin_deletealbum($_GET['deletealbum']);
	}
	elseif(!empty($_GET['editarticle'])) {
		settype($_GET['editarticle'],"integer");
		eb_admin_editarticle($_GET['editarticle']);
	}
	elseif(!empty($_GET['editcomment'])) {
		settype($_GET['editcomment'],"integer");
		settype($_GET['article'],"integer");
		eb_admin_editcomment($_GET['editcomment'],$_GET['article']);
	}
	elseif(!empty($_GET['edittopic'])) {
		settype($_GET['edittopic'],"integer");
		eb_admin_edittopic($_GET['edittopic']);
	}
	elseif(!empty($_GET['editpost'])) {
		settype($_GET['editpost'],"integer");
		settype($_GET['topic'],"integer");
		eb_admin_editpost($_GET['editpost'],$_GET['topic']);
	}
	elseif(!empty($_GET['editmember'])) {
		settype($_GET['editmember'],"integer");
		eb_admin_editmember($_GET['editmember']);
	}
	elseif(!empty($_GET['editphoto']) && !empty($_GET['album'])) {
		settype($_GET['editphoto'],"integer");
		settype($_GET['album'],"integer");
		eb_admin_editphoto($_GET['editphoto'],$_GET['album']);
	}
	elseif(!empty($_GET['editalbum'])) {
		settype($_GET['editalbum'],"integer");
		eb_admin_editalbum($_GET['editalbum']);
	}
	elseif(!empty($_GET['activatemember'])) {
		settype($_GET['activatemember'],"integer");
		eb_admin_activatemember($_GET['activatemember']);
	}
	else {
		eb_head('');
		eb_admin();
		eb_foot();
	}
}
?>