Location: PHPKode > projects > MyNews > mynews/admin.php
<?php
// ----------------------------------------------------------------------
// MyNews
// Copyright (C) 2004 by Frank Mancuso Aka crash4o4
// https://sourceforge.net/projects/mynews/
// http://frankmancuso.ca
// ----------------------------------------------------------------------
// LICENSE
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License (GPL)
// 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.
//
// To read the license please visit http://www.gnu.org/copyleft/gpl.html
// ----------------------------------------------------------------------
// Original Author of file: Frank Mancuso aka crash4o4
// Purpose of file:
// ----------------------------------------------------------------------


include("auth.php");
include("mynews.php");
include("skin.php");
include("bbcode.php");
page_header($username); // Display Header. From skin.php
?>


<tr>
<td height="400" valign="top">
<?php
// Call MyNews Class
$mynews = new MyNews;

// Define Action Variable
$Action = @$_GET["Action"];


// if the user is a admin
if ($group_id == "Admin")
{
?>
<div align="center"><a href="admin.php?Action=Create">Add News</a> | <a href="admin.php?Action=List_News">Edit News</a> | <a href="admin.php?Action=add_user">Add User</a> | <a href="admin.php?Action=view_users">Edit User</a></div>
<p>&nbsp;</p>
<?php
// What Action Should be Taken
switch ($Action) {
	
case "Create":
	$mynews->Create();
	break;

case "Submit":
	$News_Title = addslashes($_POST['News_Title']);
	$News_Body = addslashes($_POST['News_Body']);
	$News_Body_Extend = addslashes($_POST['News_Body_Extend']);
	$mynews->Submit($username,$News_Title,$News_Body,$News_Body_Extend);
	break;

case "List_News":
	$mynews->List_News();
	break;
	
case "Edit":
	$news_id = $_GET["news_id"];
	$mynews->Edit($news_id);
	break;

case "Update":
	$news_id 		= $_POST['news_id'];
	$News_Title       	= addslashes($_POST['News_Title']);
	$News_Body		= addslashes($_POST['News_Body']);
	$News_Body_Extend	= addslashes($_POST['News_Body_Extend']);
	$Active			= $_POST['Active'];
	$mynews->Update($news_id,$News_Title,$News_Body,$News_Body_Extend,$Active);
	break;

case "Delete":
	$news_id = $_GET['news_id'];
	$mynews->Delete($news_id);
	break;
	
case "add_user":
	$mynews->add_user();
	break;

case "create_user":
	$user 	= $_POST['user'];
	$pass 	= $_POST['pass'];
	$email 	= $_POST['email'];
	$group 	= $_POST['group'];
	$mynews->create_user($user,$pass,$email,$group);
	break;

case "view_users":
	$mynews->view_users();
	break;
	
case "edit_user":
	$user_id = $_GET['user_id'];
	$mynews->edit_user($user_id);
	break;

case "update_user":
	$user_id 	= $_POST['user_id'];
	$username 	= $_POST['username'];
	$email 		= $_POST['email'];
	$group_id	= $_POST['group'];
	$mynews->update_user($user_id,$username,$email,$group_id);
	break;

case "delete_user":
	$uid		= $_GET['uid'];
	$mynews->delete_user($uid);
	break;
	
case "update_pass":
	$user_id	= $_POST['user_id'];
	$pass1		= $_POST['pass1'];
	$pass2		= $_POST['pass2'];
	$mynews->update_pass($user_id,$pass1,$pass2);
	break;
	
case "myaccount":
	$mynews->myaccount();
	break;

default:
	default_page();
	
	} // end of switch

} // end of Admin power


// if user is a moderator
if ($group_id == "Mod")
{
?>
<div align="center"><a href="admin.php?Action=Create">Add News</a> | <a href="admin.php?Action=List_News">Edit News</a></div>
<p>&nbsp;</p>
<?php
// What Action Should be Taken
switch ($Action) {
	
case "Create":
	$mynews->Create();
	break;

case "Submit":
	$News_Title = addslashes($_POST['News_Title']);
	$News_Body = addslashes($_POST['News_Body']);
	$News_Body_Extend = addslashes($_POST['News_Body_Extend']);
	$mynews->Submit($username,$News_Title,$News_Body,$News_Body_Extend);
	break;

case "List_News":
	$mynews->List_News();
	break;
	
case "Edit":
	$news_id = $_GET["news_id"];
	$mynews->Edit($news_id);
	break;

case "Update":
	$news_id 		= addslashes($_POST['news_id']);
	$News_Title       	= addslashes($_POST['News_Title']);
	$News_Body		= addslashes($_POST['News_Body']);
	$News_Body_Extend	= addslashes($_POST['News_Body_Extend']);
	$Active			= $_POST['Active'];
	$mynews->Update($news_id,$News_Title,$News_Body,$News_Body_Extend,$Active);
	break;

case "Delete":
	$news_id = $_GET['news_id'];
	$mynews->Delete($news_id);
	break;

case "myaccount":
	$mynews->myaccount();
	break;
	
default:
	default_page();
	
	} // end of switch
	
} // end of moderator power


// If user is a writer
if ($group_id == "Writter")
{
?>
<div align="center"><a href="admin.php?Action=Create">Add News</a></div>
<p>&nbsp;</p>
<?php
// What Action Should be Taken
switch ($Action) {
	
case "Create":
	$mynews->Create();
	break;

case "Submit":
	$News_Title = addslashes($_POST['News_Title']);
	$News_Body = addslashes($_POST['News_Body']);
	$News_Body_Extend = addslashes($_POST['News_Body_Extend']);
	$mynews->Submit($username,$News_Title,$News_Body,$News_Body_Extend);
	break;
	
case "myaccount":
	$mynews->myaccount();
	break;
	
case "update_mypass":
	$pass1		= $_POST['pass1'];
	$pass2		= $_POST['pass2'];
	$mynews->update_mypass($username,$pass1,$pass2);
	break;
	
default:
	default_page();
	
	} // end of switch	

} // end of writer power

?>

</td>
</tr>



<?php
page_footer(); // Display Footer. From skin.php
?>









Return current item: MyNews