Location: PHPKode > projects > PSlash > pslash-0.70/html/admin.php
<?

###############################################################################
# Copyright (C) 2000  Derek Leung
#
# 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.
#
# You may modify your copy or copies of this Program or any portion of it,
# but you must cause the modified files to carry prominent notices stating 
# that you changed the files and the date of any change.  And you are required 
# to keep a copy of this License along with this Program.
#
# You are not required to accept this License, since you have not signed it. 
# However, nothing else grants you permission to modify or distribute this 
# Program or its derivative works. These actions are prohibited by law if 
# you do not accept this License. Therefore, by modifying or distributing 
# this Program (or any work based on this Program), you indicate your 
# acceptance of this License to do so, and all its terms and conditions 
# for copying, distributing or modifying this Program or works based on it.
#
# 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.  
#
# 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.
#
# See the GNU General Public License for more details.
# http://www.opensource.org/licenses/gpl-license.html
###############################################################################

require("mainfile.php");
global $config;

// modules for other admin functions.  
// Add your modules here and make sure remember to add the case switch at the end of the page.
// And add the link in AdminMenu().
require("admin/block.php"); // admin function for blocks management
require("admin/news.php");	// admin function for news management
require("admin/manageAdmin.php"); // admin function for admin managemnet
require("admin/user.php"); // admin function for user management
require("admin/topic.php"); // admin function for topic management
require("admin/article.php"); // admin function for article management
require("admin/category.php"); // admin function for category management
require("admin/poll.php"); // admin function for poll management

// kick out everyone if he is not a admin or moderator
$userArray = getCookie($config[user_cookie_name]);
if ($userArray[status] != "Admin" && $userArray[status] != "Moderator") {
		errorPage("You don't have authorization to go into Admin area!",$config[def_theme]);
}

/*********************************************************/
/* general functions                                     */
/*********************************************************/

function adminMain($mesg="") {

// Main menu for Admin section
	global $config;

	// Access Right #1 -> Article Moderation
	$userArray = getCookie($config[user_cookie_name]);
	if (sizeof($userArray) <= 0) {
		$mesg = translate("You have to login first!");
		header("Location: user.php?mesg=$mesg");
		exit;
	}

	if ($userArray[status] != "Admin" && $userArray[status] != "Moderator") {
		errorPage("You don't have authorization to go into Admin area!",$config[def_theme]);
	}

	ps_header("");
	$rightArray = getAdminRights();
	echo "<h3>" . translate("Administration") ;
	if ($mesg) {
		echo "<font size=+1 color=red><em> ($mesg)</em></font>";
	}
	echo "</h3><hr>";

	// News Moderation/ Post new article
	if(in_array(1,$rightArray)) {
		echo "<b>" . translate("News waiting for Moderation") . "</b>";
		$result = mysql_query("SELECT qid, subject, topic, timestamp FROM ps_queue order by timestamp");
		
		if(mysql_num_rows($result) == 0) {
			// no news in queue
			echo "<table width=\"98%\"><tr><td>".translate("No news need to moderate")."</td></tr></table>";
		} else {
			// news in queue, display it
			echo "<form action=\"admin.php\" method=\"post\"><table border=1 width=\"100%\">";
			$topics = getTopicRights();
			
			while (list($qid, $subject, $topic, $timestamp) = mysql_fetch_row($result)) {
				if (in_array($topic,$topics)) {
					$datetime = formatTimeStamp($timestamp);
					echo"<tr>
						<td  width=11 align=middle><input type=radio name=\"qid\" value=\"$qid\"></td>
						<td ><a href=\"admin.php?op=queueNews&qid=$qid\">$subject</a></td>
						<td >$datetime &nbsp;</td>
						<td align=right>$topic</td></tr>
					";
					$dummy++;
				}
			}
			
			?>
			<tr>
				<td colspan=4>
					<SELECT name="op">
						<option value="queueNews"><? echo translate("Display News in queue"); ?></option>
						<option value="deleteQueueNews"><? echo translate("Delete News in queue"); ?></option>
					</select>
					<INPUT type="submit" value="<? echo translate("Go!"); ?>">&nbsp;
				</td>
			</tr>
		</table>
	</form>
	<?
			
		}
		mysql_free_result($result);
		echo "<hr><li><a href=\"submit.php\">".translate("Post news from admin")."</a><hr>";
	}


	// Access Right 2 -> Edit/Delete News
	if(in_array(2,$rightArray)) { ?>
		<b><? echo translate("Edit/Delete News"); ?></b>
		<form action="admin.php" method="post"><li>
			<A HREF="admin.php?op=selectNews"><? echo translate("Select News"); ?></A><br>
			<? echo translate("News ID:"); ?> <input type="text" NAME="sid" SIZE=3>
			<select name="op">
				<option value="editNews" SELECTED><? echo translate("Edit News"); ?></option>
				<option value="removeNews"><? echo translate("Remove News"); ?></option></select>
			<input type="submit" value="<? echo translate("Go!");?>">
			<?
			$result = mysql_query("SELECT MAX(s.sid) FROM ps_stories s");
			if ($result) {
				list($num) = mysql_fetch_row($result);
				mysql_free_result($result);
			} else {
				$num = 0;
			}
		
			printf("<font size=-1>(" . translate("Highest article ID currently is %s.") . ")</font>",$num); ?>
		</form>
		<hr>
	<? }

	// Access Right 3 -> Edit blocks
	
	echo "<b>".translate("Admin Tools")."</b><br><br>";
	if(in_array(3,$rightArray))
		echo "<li><a href=\"admin.php?op=blocks\">".translate("Manage Blocks")."</a>";

	// Access Right 4 => Add/Edit Admin/Moderator
	if(in_array(4,$rightArray))
		echo "<li><a href=\"admin.php?op=editAdmin\">".translate("Manage Admins Priviledges")."</a>";

	// Access Right 5 => Add/Edit/Delete Topics
	if(in_array(5,$rightArray))
		echo "<li><a href=\"admin.php?op=mod_topics\">".translate("Manage Topics")."</a>";
	
	// Access Right 6 => Add/Edit/Delete Users
	if(in_array(6,$rightArray)) {
		echo "<li><a href=\"admin.php?op=mod_users\">".translate("Manage Users")."</a> ";
		list($numUser) = mysql_fetch_row(mysql_query("select count(uid) from ps_users"));
		printf("<font size=-1>(" . translate("There are currently %s users.") . ")</font>",$numUser);
	}

	// Access Right 8 => Add/Edit/Delete Article
	if(in_array(8,$rightArray)) {
		echo "<li><a href=\"admin.php?op=mod_category\">".translate("Manage Category")."</a>";
		echo "<li><a href=\"admin.php?op=mod_article\">".translate("Manage Article")."</a>";
	}

	// Access Right 10 => upload screenshots
	if(in_array(10,$rightArray))
		echo "<li><a href=\"modules/webfile/\">".translate("Screenshots Management")."</a>";

	echo "<br><br><hr>";

	// Access Right 7 => Add/Edit/Delete Users
	if(in_array(7,$rightArray)) {
		echo "<b>".translate("Polls Management")."</b><br><br>";
		echo "<p>
			<li><a href=\"admin.php?op=createPoll\">".translate("Create new poll")."</a><br>
			<li><a href=\"admin.php?op=viewPoll\">".translate("View poll results")."</a><br>
			<li><a href=\"admin.php?op=removePoll\">".translate("Remove existing poll")."</a>";
	}


	// Access Right 9 => Site stats
	echo "<br><br><hr><li><a href=\"modules/visitors2/index.php\">".translate("Site statistics")."</a> ";
	if(in_array(9,$rightArray)) {
		echo "<li><a href=\"modules/visitors2/admin/admin.php\">".translate("Site statistics management")."</a> ";
	}

	unset($userArray,$mesg,$rightArray,$result,$qid,$subject,$topic,$timestamp,$topics,$topic,$num)	;
	echo "<br><hr><li><a href=\"user.php?op=logout\">".translate("Logout")."</a><br>";
	ps_footer("");
}


################################################################################################
#	Add your case switch here.  Please sort it by modules type								   #
################################################################################################

	switch($op) {
		
		###########################

		// Topic management
		case "addTopic":
			addTopic($add_topic);
			break;

		case "delTopic":
			deltopic($chng_tid);
			break;

		case "mod_topics":
			displayTopics($mesg);
			break;

		case "modifyTopic":
			modifyTopic($chng_tid);
			break;
		
		case "updateTopic":
			updateTopic($chng_tid, $chng_topic, $chng_icon_type, $chng_icon_size, $chng_icon_name, $chng_icon_url, $chng_alt, $chng_required, $moderate,$displayTopic);
			break;

		###########################

		// Admin management

		case "assignAdmin":
			assignAdmin($uid,$action,$status,$startNum,$uname,$mesg,$letter,$sortby,$orderby,$page);
			break;

		case "editAdmin":
			displayadmins($mesg);
			break;
		
		case "modifyadmin":
			modifyadmin($chng_uid);
			break;

		case "UpdateAdmin":
			updateAdmin($adminUid,$admin,$tid);	
			break;

		###########################

		// Blocks Management

		case "blocks":
			blocks($topic,$mesg);
			break;

		case "changeblock":
			changeblock($id, $title, $content, $type, $topic, $listOrder, $url, $refresh);
			break;

		case "deleteblock":
			deleteblock($id,$topic);
			break;

		case "makeblock":
			makeblock($title, $content, $type,$topic, $listOrder,$url,$refresh);
			break;
		
		###########################

		// News Management
		
		case "deleteQueueNews":
			deleteQueueNews($qid);
			break;

		case "queueNews":
			queueNews($qid,$uid,$author,$subject,$fulltext,$topic,$ip);
			break;

		case "editNews":
			editNews($sid, $author, $subject, $fulltext, $topic,$ip);
			break;

		case "postQueueNews":
			postQueueNews($qid, $uid, $author, $subject, $fulltext, $topic, $ip);
			break;

		case "removeNews":
			removeNews($sid, $ok);
			break;

		case "selectNews":
			selectNews($page);
			break;

		case "updateNews":
			updateNews($sid, $author, $subject, $fulltext, $topic,$ip);
			break;

		###########################

		// Poll Management

		case "viewPoll": 
			poll_viewPoll($pollID, $topic);
			break;

		case "createPoll":
			poll_createPoll($pollTitle, $topic,$optionText);
			break;

		case "removePoll":
			poll_removePoll($pollID);
			break;

		###########################

		// User Management

		case "delUser":
 			delUser($chng_user);
			break;

		case "updateUser":
			updateUser($chng_uid, $chng_uname, $userTitle, $chng_name, $chng_url, $chng_email, $chng_femail, $chng_pass, $chng_pass2, $ban);
			break;

		case "mod_users":
			displayUsers($mesg,$letter,$sortby,$orderby,$page);
			break;

		case "modifyUser":
			modifyUser($chng_user);
			break;

		###########################

		// Article Management
		case "mod_article":
			manageArticle($action,$topic,$aName,$cid,$content,$aid,$html,$link,$url,$listOrder,$mesg);
			break;

		###########################

		// Category Management

		case "mod_category":
			manageCategory($action,$cName,$topic,$cid,$listOrder,$mesg);
			break;

		###########################

		// General Function

		case "adminMain":
			adminMain();
			break;

		case "logout":
			header("Location: user.php?op=logout");
			break;

		default:
			adminMain($mesg);
			break;
	}


# Don't add empty spaces at the end of this file....
# If you don't want to see cookies errors.
?>
Return current item: PSlash