[Openfirst-cvscommit] news/admin editnews.php,NONE,1.1 killnews.php,NONE,1.1
Brought to you by:
xtimg
From: <i-...@us...> - 2003-10-01 22:52:52
|
Update of /cvsroot/openfirst/news/admin In directory sc8-pr-cvs1:/tmp/cvs-serv3453/news/admin Added Files: editnews.php killnews.php Log Message: Added new admin modules - edit and delete news. Modified scripts to include the DHTML editor (RSS compatible now) --- NEW FILE: editnews.php --- <?php /* * openFIRST.news - admin/editnews.php * * Copyright (C) 2003, * openFIRST Project * Original Author: Greg Inozemtsev <gr...@si...> * Based on admin/index.php by Tim Ginn <tim...@sy...> * * 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("../../config/globals.php"); include($header); echo("<h1>Edit News Item</h1>"); if(isset($user->membertype)){ if($user->membertype == "administrator") { $articleid=0; if(isset($_GET["id"])){ $articleid=$_GET["id"]; } if(! isset($_POST["news"])) { // Display a form for news. $query = ofirst_dbquery("SELECT * FROM ofirst_news ORDER BY ID DESC"); $title=""; $found=false; if (ofirst_dbnum_rows($query) != 0){ while($news = ofirst_dbfetch_object($query)){ if($news->ID==$articleid){ $found=true; break; } } } if($found){ ?> <form name="NewsForm" id="NewsForm" method="post" action="<?php echo($_SERVER["PHP_SELF"]); ?>"> <p><br /> <br /> </p> <table width="618" align="center"> <tr> <th> </th> <th>Edit News</th> </tr> <tr> <td><div align="right">Headline:</div></td> <td><input name="title" type="text" value="<?php {echo($news->title);} ?>" style="width: 250px;"></td> </tr> <tr> <td width="156"><div align="right">Image:</div></td> <td width="332"> <input type="text" name="image" value="<?php {echo($news->image);} ?>" style="width: 250px;"> </td> </tr> <tr> <td valign="top"> <div align="right">Descriptions</div></td> <td> <?php $dhtml=function_exists("make_wysiwyg"); if($dhtml){ make_wysiwyg("news", 500, 300, $news->news); } else{ echo('<textarea name="news" cols="60" rows="20">$news->news</textarea>'); } ?> </td> </tr> <tr> <td> </td> <td> <?php if($dhtml){ echo('<input name="news2" type="button" id="news" value="Save Changes" onclick="dhtmlEditorPrepareSubmit(); document.NewsForm.submit();" />'); } else { echo('<input name="news2" type="submit" id="news" value="Save Changes" />'); } ?> <input name="reset" type="reset" /> <input name="StoryID" id="StoryID" type="hidden" value="<?php echo($news->ID); ?>"/> </td> </tr> </table> <p> </p> </form> <?php } else { echo('<div>This news item does not exist.</div>'); } } else { // Add the news. $now = date("D M j G:i:s T Y"); $query=ofirst_dbquery("UPDATE ofirst_news SET date='".$now."', poster='".$user->user."', title='".$_POST["title"]."', news='".$_POST["news"]."', image='".$_POST["image"]."' WHERE ID='".$_POST["StoryID"]."';"); echo("The news item "" . $_POST["title"] . "" has been modified. [ <a href='../index.php'>Main</a> ]"); } } } else { echo("You must be logged on as an administrative user to edit news."); } include($footer); ?> --- NEW FILE: killnews.php --- <?php /* * openFIRST.news - admin/killnews.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("../../config/globals.php"); include($header); ?> <br> <table width="618" align="center"> <tr> <th>Delete News Item</th> </tr> <tr> <td align="center"> <?php $admin=false; if (isset($user->membertype)){ $admin=($user->membertype == "administrator"); } if($admin) { if(!isset($_POST["StoryID"])) { $query = ofirst_dbquery("SELECT * FROM ofirst_news ORDER BY ID DESC"); $title=""; $found=false; if (ofirst_dbnum_rows($query) != 0){ while($news = ofirst_dbfetch_object($query)){ if($news->ID==$_GET["id"]){ $found=true; $title=$news->title; break; } } } ?> <?php if($found){ echo('<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'); echo('<input name="StoryID" type="hidden" value="'.$_GET["id"].'">'); echo('<div>Delete news item "'.$title.'"?</div><br>'); echo('<input type="submit" value="Confirm"></form>'); } else { echo('<div>This news item does not exist.</div>'); } } else { // Delete the news by ID. ofirst_dbquery("DELETE FROM ofirst_news WHERE ID=".$_POST["StoryID"].";"); echo("The news item has been deleted. [ <a href='../index.php'>Main</a> ]"); } } else { echo("You must be logged on as an administrative user to delete news."); } echo("</td></tr></table>"); include($footer); ?> |