[Openfirst-cvscommit] forum/admin index.php,NONE,1.1
Brought to you by:
xtimg
From: <i-...@us...> - 2003-10-13 22:12:08
|
Update of /cvsroot/openfirst/forum/admin In directory sc8-pr-cvs1:/tmp/cvs-serv22484/admin Added Files: index.php Log Message: Admin module for Forum --- NEW FILE: index.php --- <?php /* * openFIRST.forum - admin/index.php * * Copyright (C) 2003, * openFIRST Project * Original Author: Greg Inozemtsev <gr...@si...> * * 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. * 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 * */ include_once("../../config/globals.php"); include_once($header); echo("<h1>Forum Admin</h1>"); if (isset($user->membertype)&&$user->membertype=="administrator"){ if(!isset($_POST["act"])) { $query = ofirst_dbquery("SELECT * FROM ofirst_forum ORDER BY ID"); echo("<table width=300><tr><th colspan=2><label for=cat>Forum</label></th></tr>"); echo('<tr><td align=center colspan=2><form id=ForumAdmin name=ForumAdmin method="POST" action="index.php"><select style="width:250px" name=cat id=cat size=4>'); if(ofirst_dbnum_rows($query)==0){ echo('<option selected value="0">(none)</option></select>'); } else{ while($cat = ofirst_dbfetch_object($query)){ echo('<option value="'.$cat->ID.'">'.ucfirst($cat->name).'</option>'); } ?> </select></td></tr> <tr><td align=right colspan=2> <input type=button onclick="{ document.ForumAdmin.act.value='hide'; document.ForumAdmin.submit(); } " value="Hide/Show"> <input type=button onclick="{ document.ForumAdmin.act.value='close'; document.ForumAdmin.submit(); } " value="Close/Open"> <input type=button onclick="if(confirm('Deleting a forum deletes all messages in it. Proceed?')){ document.ForumAdmin.act.value='delete'; document.ForumAdmin.submit(); } " value=Delete></td></tr> <?php } ?> <input type=hidden name=act value="new"> <tr><th colspan=2>New Subforum</th></tr> <tr><td><div><label for=newcat>Title</label></div></td> <td><input name=newcat id=newcat></tr> <tr><td><div><label for=newdesc>Description</label></div></td> <td><input name=newdesc id=newdesc></tr> <tr><td colspan=2 align=center><input type=submit value="Create"></td></tr> </td></tr></table></form> <?php } else { // Action switch($_POST["act"]){ case "hide": { if(isset($_POST["cat"])&&$_POST["cat"]!=0){ $q=ofirst_dbquery("SELECT name,hidden FROM ofirst_forum WHERE ID='".$_POST["cat"]."'"); $subforum=ofirst_dbfetch_object($q); if($subforum->hidden){ ofirst_dbquery("UPDATE ofirst_forum SET hidden='0' WHERE ID='".$_POST["cat"]."'"); echo("<div>Subforum ".$subforum->name." is now visible to all visitors</div>"); } else{ ofirst_dbquery("UPDATE ofirst_forum SET hidden='1' WHERE ID='".$_POST["cat"]."'"); echo("<div>Subforum ".$subforum->name." is only shown to administrators</div>"); } } else{ echo("<div>No action has been performed</div>"); } break; } case "close": { if(isset($_POST["cat"])&&$_POST["cat"]!=0){ $q=ofirst_dbquery("SELECT name,closed FROM ofirst_forum WHERE ID='".$_POST["cat"]."'"); $subforum=ofirst_dbfetch_object($q); if($subforum->closed){ ofirst_dbquery("UPDATE ofirst_forum SET closed='0' WHERE ID='".$_POST["cat"]."'"); echo("<div>Subforum ".$subforum->name." is now unlocked</div>"); } else{ ofirst_dbquery("UPDATE ofirst_forum SET closed='1' WHERE ID='".$_POST["cat"]."'"); echo("<div>Subforum ".$subforum->name." is now locked</div>"); } } else{ echo("<div>No action has been performed</div>"); } break; } case "delete": { if(isset($_POST["cat"])&&$_POST["cat"]!=0){ $q=ofirst_dbquery("SELECT name FROM ofirst_forum WHERE ID='".$_POST["cat"]."'"); $subforum=ofirst_dbfetch_object($q); ofirst_dbquery("DELETE FROM ofirst_forumposts WHERE forum='".$subforum->name."'"); ofirst_dbquery("DELETE FROM ofirst_forum WHERE ID='".$_POST["cat"]."'"); echo("<div>Subforum ".$subforum->name." deleted</div>"); } else{ echo("<div>No action has been performed</div>"); } break; } default: { if($_POST["newcat"]!=""){ $subforum=0; $q=ofirst_dbquery("SELECT name FROM ofirst_forum WHERE subforum='0'"); if(isset($_POST["cat"])){ $subforum=$_POST["cat"]; } if(ofirst_dbnum_rows($q)==0||$subforum!=0){ ofirst_dbquery("INSERT INTO ofirst_forum (name, message, subforum) VALUES ('" . $_POST["newcat"] . "', '" . $_POST["newdesc"] . "', '" .$subforum. "');"); echo("<div>Subforum ".$_POST["newcat"]." created</div>"); } else { echo("<div>Root category already exists. You must create a subforum.</div>"); } } else{ echo("<div>No action has been performed</div>"); } break; } } } } else{ echo("<div>You must log in as an administrative user to use this feature</div>"); } include_once($footer); ?> |