[Openfirst-cvscommit] downloads/admin editinfo.php,NONE,1.1 index.php,NONE,1.1 killfile.php,NONE,1.1
Brought to you by:
xtimg
From: <i-...@us...> - 2003-10-07 01:33:28
|
Update of /cvsroot/openfirst/downloads/admin In directory sc8-pr-cvs1:/tmp/cvs-serv27295/admin Added Files: editinfo.php index.php killfile.php upload.php Log Message: Download manager. Initial upload. Needs mssql setup script. --- 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: index.php --- <?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 * 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>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); ?> --- 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); ?> |