[Openfirst-cvscommit] news/admin editinfo.php,NONE,1.1 killfile.php,NONE,1.1 upload.php,NONE,1.1 ind
Brought to you by:
xtimg
From: <i-...@us...> - 2003-10-06 22:11:39
|
Update of /cvsroot/openfirst/news/admin In directory sc8-pr-cvs1:/tmp/cvs-serv30273/admin Modified Files: index.php Added Files: editinfo.php killfile.php upload.php Log Message: New scripts for admin --- NEW FILE: editinfo.php --- <?php /* * openFIRST.downloads - admin/editinfo.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); echo("<h1>Edit File Information</h1>"); if(isset($user->membertype)){ if($user->membertype == "administrator") { $fileid=0; if(isset($_GET["id"])){ $fileid=$_GET["id"]; } if(! isset($_POST["desc"])) { // Display a form for news. $query = ofirst_dbquery("SELECT * FROM ofirst_downloads ORDER BY ID DESC"); $title=""; $found=false; if (ofirst_dbnum_rows($query) != 0){ while($file = ofirst_dbfetch_object($query)){ if($file->ID==$fileid){ $found=true; break; } } } if($found){ ?> <form method="post" action="<?php echo($_SERVER["PHP_SELF"]); ?>"> <p><br /> <br /> </p> <table width="618" align="center"> <tr> <th> </th> <th>Edit File Info</th> </tr> <tr> <td><div align="right">Title:</div></td> <td><input name="title" type="text" value="<?php {echo($file->Title);} ?>" style="width: 250px;"></td> </tr> <tr> <td width="156"><div align="right">Category:</div></td> <td width="332"> <select name="category"><option value="">(none)</option> <?php $query = ofirst_dbquery("SELECT * FROM ofirst_downloadcat ORDER BY Category"); if(ofirst_dbnum_rows($query)!=0){ while($cat = ofirst_dbfetch_object($query)){ echo("<option"); if($cat->Category==$file->Category){ echo " selected"; } echo(">".$cat->Category.'</option>'); } } ?> </td> </tr> <tr> <td valign="top"> <div align="right">Description</div></td> <td> <textarea name="desc" cols="50" rows="8"><?php echo($file->Description); ?></textarea> </td> </tr> <tr> <td> </td> <td> <input name="ok" type="submit" id="ok" value="Save Changes" /> <input name="reset" type="reset" /> <input name="ID" id="ID" type="hidden" value="<?php echo($file->ID); ?>"/> </td> </tr> </table> <p> </p> </form> <?php } else { echo('<div>This file does not exist.</div>'); } } else { $query=ofirst_dbquery("UPDATE ofirst_downloads SET Title='".$_POST["title"]."', Description='".$_POST["desc"]."', Category='".$_POST["category"]."' WHERE ID='".$_POST["ID"]."';"); echo("The information for file "" . $_POST["title"] . "" has been modified. [ <a href='../index.php'>Main</a> ]"); } } } else { echo("You must be logged on as an administrative user to edit file details."); } include($footer); ?> --- NEW FILE: killfile.php --- <?php /* * openFIRST.downloads - admin/killfile.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 File</th> </tr> <tr> <td align="center"> <?php $admin=false; if (isset($user->membertype)){ $admin=($user->membertype == "administrator"); } if($admin) { if(!isset($_POST["ID"])) { $query = ofirst_dbquery("SELECT ID,Title FROM ofirst_downloads ORDER BY ID DESC"); $filename=""; $found=false; if (ofirst_dbnum_rows($query) != 0){ while($file = ofirst_dbfetch_object($query)){ if($file->ID==$_GET["id"]){ $found=true; $filename=$file->Title; break; } } } ?> <?php if($found){ echo('<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'); echo('<input name="ID" type="hidden" value="'.$_GET["id"].'">'); echo('<div>Delete '.$filename.'?</div><br>'); echo('<input type="submit" value="Confirm"></form>'); } else { echo('<div>This file does not exist.</div>'); } } else { // Delete by ID. $query = ofirst_dbquery("SELECT FileData FROM ofirst_downloads WHERE ID='".$_POST["ID"]."'"); $file = ofirst_dbfetch_object($query); if(ereg("location:*",$file->FileData)){ //erase from filesystem if(!unlink("../".substr($file->FileData,9))){ echo('<div style="color:red">Warning: could not erase the file from the filesystem. The file will be removed from File Manager.</div>'); } } ofirst_dbquery("DELETE FROM ofirst_downloads WHERE ID=".$_POST["ID"].";"); echo("<div>The file has been deleted.</div><div>[<a href='../index.php'>Return to File Manager</a>]</div>"); } } else { echo("You must be logged on as an administrative user to delete files."); } echo("</td></tr></table>"); include($footer); ?> --- NEW FILE: upload.php --- <?php /* * openFIRST.downloads- admin/upload.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 * */ // Import globals and estbalish database connection include("../../config/globals.php"); include($header); //directory to upload to $uploaddir=$fbasepath."/downloads/files/"; $serverdir="files/"; // Check if user is an admin then allow processes if(! isset($user->user) || $user->membertype != "administrator"){ showlogin(); die(include($footer)); } echo("<h1>File Upload</h1>"); // Check if user initiates upload process and run upload process if(isset($_POST['Title'])){ $extension=substr(strrchr($_FILES['newfile']['name'],"."),1); $now = date("Y-m-d"); if(!isset($_POST['db'])){ $uploadfile = $uploaddir.$_FILES['newfile']['name']; if (move_uploaded_file($_FILES['newfile']['tmp_name'], $uploadfile)) { echo('<div style="color:green">'.$_FILES['newfile']['name'].' was successfully uploaded to filesystem</div>'); ofirst_dbquery("INSERT INTO ofirst_downloads (Category, Title, Description, mime, ext, DateAdded, FileData) VALUES ('".$_POST["Category"]."', '".$_POST["Title"]."', '".$_POST["Description"]."', '".$_FILES['newfile']['type']."', '".$extension."', '$now', 'location:".$serverdir.$_FILES['newfile']['name']."');"); } else { echo('<div style="color:red">Could not upload '.$_FILES['newfile']['name'].'</div>'); } } else { if($bindata=file_get_contents($_FILES['newfile']['tmp_name'])){ $bindata=base64_encode($bindata); echo('<div style="color:green">'.$_FILES['newfile']['name'].' was successfully uploaded to database</div>'); ofirst_dbquery("INSERT INTO ofirst_downloads (Category, Title, Description, mime, ext, DateAdded, FileData) VALUES ('".$_POST["Category"]."', '".$_POST["Title"]."', '".$_POST["Description"]."', '".$_FILES['newfile']['type']."', '".$extension."', '$now', '".$bindata."');"); } else { echo('<div style="color:red">Could not upload '.$_FILES['newfile']['name'].'</div>'); } } } echo('<br><br><div><a href="../index.php">[Return to File Manager]</a></div>'); include($footer); ?> Index: index.php =================================================================== RCS file: /cvsroot/openfirst/news/admin/index.php,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** index.php 1 Oct 2003 22:52:09 -0000 1.10 --- index.php 6 Oct 2003 22:11:33 -0000 1.11 *************** *** 1,9 **** <?php /* ! * openFIRST.news - admin/index.php * * Copyright (C) 2003, * openFIRST Project ! * Original Author: Tim Ginn <tim...@sy...> * * This program is free software; you can redistribute it and/or modify --- 1,9 ---- <?php /* ! * openFIRST.downloads - 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 *************** *** 29,100 **** include($header); ! echo("<h1>Add News</h1>"); if(isset($user->membertype)){ if($user->membertype == "administrator") { ! if(! isset($_POST["news"])) { ! // Display a form for news. ?> ! <form name="NewsForm" id="NewsForm" method="post" action="index.php"> ! <p><br /> ! <br /> ! </p> ! <table width="618" align="center"> ! <tr> ! <th> </th> ! <th>Add News</th> ! </tr> ! <tr> ! <td><div align="right">Headline:</div></td> ! <td><input name="title" type="text" value="openFIRST News" 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 $basepath . "/images/openfirst.png"; ?>" ! 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, "Insert your news here."); ! } ! else{ ! echo('<textarea name="news" cols="60" rows="20">Insert your news here.</textarea>'); ! } ?> ! </td> ! </tr> ! <tr> ! <td> </td> ! <td> <?php ! if($dhtml){ ! echo('<input name="news2" type="button" id="news" value="Add News Item" onclick="dhtmlEditorPrepareSubmit(); document.NewsForm.submit();" />'); ! } ! else { ! echo('<input name="news2" type="submit" id="news" value="Add News Item" />'); } ! ?> ! <input name="reset" type="reset" value="Clear News Item" /> </td> ! </tr> ! </table> ! <p> </p> ! </form> ! <?php ! } else { ! // Add the news. ! $now = date("D M j G:i:s T Y"); ! ! $query = ofirst_dbquery("INSERT INTO ofirst_news (date, poster, title, news, image) VALUES ('$now', '$user->user', '" . $_POST["title"] . "', '" . $_POST["news"] . "', '" . $_POST["image"] . "');"); ! echo("The news item " . $_POST["title"] . " has been added. [ <a href='../index.php'>Main</a> ]"); } } ! } else { ! echo("You must be logged on as an administrative user to add news."); } include($footer); --- 29,153 ---- include($header); ! echo("<h1>Category Editor</h1>"); if(isset($user->membertype)){ if($user->membertype == "administrator") { ! if(!(isset($_POST["cat"])||isset($_POST["newcat"]))) { ! $query = ofirst_dbquery("SELECT * FROM ofirst_downloadcat ORDER BY Category"); ! if(ofirst_dbnum_rows($query)!=0){ ! echo("<table width=300><tr><th>Delete Category</th></tr>"); ! echo('<tr><td align=center><form method="post" action="index.php"><select style="width:250px" name=cat size=4>'); ! while($cat = ofirst_dbfetch_object($query)){ ! echo("<option>".$cat->Category.'</option>'); ! } ! echo("</select><br><input type=submit value=Delete></form></td></tr></table><br><br>"); ! } ?> ! <form method=post action=index.php><table width=300> ! <tr><th colspan=2>New Category</th></tr> ! <tr><td><div align=right>Title:</div></td> ! <td><input name=newcat></tr> ! <tr><td><div align=right>Icon:</div></td> ! <td><select name=newicon> ! <option value=members/icons/filesystems/folder.png>Standard Sub Directory</option> ! <option value=members/icons/filesystems/folder_green.png>Green Sub Directory</option> ! <option value=members/icons/filesystems/folder_red.png>Red Sub Directory</option> ! <option value=members/icons/filesystems/folder_orange.png>Orange Sub Directory</option> ! <option value=members/icons/filesystems/folder_yellow.png>Yellow Sub Directory</option> ! <option value=members/icons/filesystems/folder_grey.png>Grey Sub Directory</option> ! <option value=members/icons/filesystems/folder_violet.png>Violet Sub Directory</option> ! <option value=members/icons/filesystems/trashcan_full.png>Junk Sub Directory</option> ! <option value=members/icons/filesystems/favorites.png>Favorites Sub Directory</option> ! <option value=members/icons/filesystems/folder_cool.png>Smiley Sub Directory</option> ! <option value=members/icons/filesystems/folder_penguin.png>Penguin-ified Sub Directory</option> ! <option value=members/icons/filesystems/folder_cd.png>CD-ROM Sub Directory</option> ! <option value=members/icons/filesystems/folder_home.png>Home Sub Directory</option> ! <option value=members/icons/filesystems/folder_html.png>Web Sub Directory</option> ! <option value=members/icons/filesystems/folder_image.png>Image Sub Directory</option> ! <option value=members/icons/filesystems/folder_important.png>Important Sub Directory</option> ! <option value=members/icons/filesystems/folder_man.png>Documentation Sub Directory</option> ! <option value=members/icons/filesystems/folder_midi.png>Midi Sub Directory</option> ! <option value=members/icons/filesystems/folder_sound.png>Audio Sub Directory</option> ! <option value=members/icons/filesystems/folder_tar.png>Archive Sub Directory</option> ! <option value=members/icons/filesystems/folder_video.png>Video Sub Directory</option> ! <option value=members/icons/filesystems/network_local.png>Network Sub Directory</option> ! <option value=members/icons/filesystems/folder_txt.png>Text Documents Directory</option> ! <option value=members/icons/filesystems/folder_wordprocessing.png>Word Processing Directory</option> ! </select><br>(or) <input name=customicon></td></tr> ! <tr><td><div align=right>Description:</div></td> ! <td><input name=newdesc></tr> ! <tr><td colspan=2 align=center><input type=submit value=Create></td></tr> ! </td></tr></table></form> <?php ! } ! else { ! // Action ! $nodelete=false; ! if(isset($_POST["cat"])){ ! if(!isset($_POST["conflictaction"])){ ! $query=ofirst_dbquery("SELECT ID FROM ofirst_downloads WHERE Category='".$_POST["cat"]."';"); ! if(ofirst_dbnum_rows($query)!=0){ ! //there are still files ! $nodelete=true; ?> ! ! <table width=500><tr><th>Conflict</th></tr><tr><td align=left><form method=post action=index.php><input name=cat type=hidden value="<?php echo($_POST["cat"]); ?>"> ! <div>There are still files left in the category you are deleting. What would you like to do?</div><br> ! <input type=radio checked value=delete name=conflictaction>Delete Files</input><br> ! <input type=radio value=move name=conflictaction>Move Files to</input> <select name=movecat> ! <option value="">(none)</option> <?php ! $q = ofirst_dbquery("SELECT * FROM ofirst_downloadcat ORDER BY Category"); ! if(ofirst_dbnum_rows($q)!=0){ ! while($cat = ofirst_dbfetch_object($q)){ ! if($_POST["cat"]!=$cat->Category){ ! echo("<option>".$cat->Category.'</option>'); ! } ! } } ! ?></select><br> ! <input type=radio value=leave name=conflictaction>Leave as is (not recommended)<br>Note: If this option is selected, the files will not be accessible unless a category with the same name is created.</input><br><input type=submit value=OK> ! </form></td></tr></table> ! <?php ! } ! } ! else { ! switch($_POST["conflictaction"]){ ! case "delete": { ! ofirst_dbquery("DELETE FROM ofirst_downloads WHERE Category='".$_POST["cat"]."';"); ! break; ! } ! case "move": { ! ofirst_dbquery("UPDATE ofirst_downloads SET Category='".$_POST["movecat"]."' WHERE Category='".$_POST["cat"]."';"); ! break; ! } ! default: { ! break; ! } ! } ! } ! if(!$nodelete){ ! ofirst_dbquery("DELETE FROM ofirst_downloadcat WHERE Category='".$_POST["cat"]."';"); ! echo("Category " . $_POST["cat"] . " has been deleted. [ <a href='../index.php'>Main</a> ]"); ! } ! } ! else { ! if(isset($_POST["newcat"])){ ! if($_POST["customicon"]!=""){ ! $icon=$_POST["customicon"]; ! } ! else { ! $icon=$_POST["newicon"]; ! } ! ofirst_dbquery("INSERT INTO ofirst_downloadcat (Category, Description, Icon) VALUES ('" . $_POST["newcat"] . "', '" . $_POST["newdesc"] . "', '" .$icon. "');"); ! echo("Category " . $_POST["newcat"] . " has been created. [ <a href='../index.php'>Main</a> ]"); ! } ! } ! } } } ! else { ! echo("You must be logged on as an administrative user to edit categories."); } include($footer); |