[Openfirst-cvscommit] photogallery/admin editphoto.php,NONE,1.1
Brought to you by:
xtimg
From: <dav...@us...> - 2003-08-22 10:57:15
|
Update of /cvsroot/openfirst/photogallery/admin In directory sc8-pr-cvs1:/tmp/cvs-serv19351 Added Files: editphoto.php Log Message: initial upload --- NEW FILE: editphoto.php --- <?php /* * openFIRST.photogallery - edit.php * * Copyright (C) 2003, * openFIRST Project * Original Author: David Di Biase <dav...@ea...> * * 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); include("galleryglobals.php"); if(! ISSET($user->user)){ showlogin(); die(include($footer)); } // Get information relating to this particular image $query = mysql_query("SELECT * FROM ofirst_photogallery_galleries WHERE ID = '".$_GET['ID']."'"); $gallery = mysql_fetch_object($query); $imgquery = mysql_query("SELECT * FROM ofirst_photogallery_image WHERE Gallery = '".$_GET['ID']."' AND Image = '".$_GET['PHOTO']."'") or die(mysql_error()); $image = mysql_fetch_object($imgquery); // Check if a text file relating to this image is present then prepare to fill it into the descriptions box $textfile = substr($_GET['PHOTO'],0,-4).".txt"; if(file_exists("../gallery/$gallery->GalleryName/".$textfile)){ $file = fopen("../gallery/$gallery->GalleryName/".$textfile,'r'); $description = ""; while(! feof($file)){ $line = fgets($file,1024); $description .= $line."<br>"; } fclose($file); } // Check if user initiated delete and run delete process if(ISSET($_POST['update'])){ // Check to see if the user wants to update with the textfile or the posted description if(! ISSET($_POST['txtupdate'])){ $description = $_POST['description']; } if(mysql_num_rows($imgquery) == 0){ mysql_query("INSERT INTO ofirst_photogallery_image SET ImageName = '".$_POST['imagename']."', Description = '".$description."', Dates = '".$_POST['date']."'") or die(mysql_error()); }else{ mysql_query("UPDATE ofirst_photogallery_image SET ImageName = '".$_POST['imagename']."', Description = '".$description."', Dates = '".$_POST['date']."' WHERE Gallery = '".$_GET['ID']."' AND Image = '".$_GET['PHOTO']."'") or die(mysql_error()); } if(ISSET($_POST['deletefile'])){ $textfile = substr($_GET['PHOTO'],0,-4).".txt"; unlink("../gallery/$gallery->GalleryName/".$textfile); echo "<br><br>Image information updated. Relating text file has been deleted in the process!"; }else{ echo "<br><br>Image information updated."; } echo " [ <a href='editphoto.php?ID=".$_GET['ID']."&PHOTO=".$_GET['PHOTO']."'>Manage</a> ]<br><br>"; die(include($footer)); } if(ISSET($_POST['deleteall'])){ mysql_query("DELETE FROM ofirst_photogallery_image WHERE Gallery = '".$_GET['ID']."' AND Image = '".$_GET['PHOTO']."'"); echo "<br><br>The description of this image has been removed! [ <a href='editphoto.php?ID=".$_GET['ID']."&PHOTO=".$_GET['PHOTO']."'>Manage</a> ]<br><br>"; die(include($footer)); } ?> <h2>Edit Gallery</h2> <p><em><?php echo $gallery->GalleryName; ?> Options - </em><a href="edit.php?ID=<?php echo $_GET['ID']; ?>">Edit</a> | <a href="upload.php?ID=<?php echo $_GET['ID']; ?>">Upload Photos</a> | <a href="cleargallery.php?ID=<?php echo $_GET['ID']; ?>">Clear Gallery</a> | <a href="edit.php?DELETE=<?php echo $_GET['ID']; ?>">Delete Gallery</a> (Must be empty to perform operation)</p> <p align="center"><img src="../gallery/<?php echo $gallery->GalleryName; ?>/<?php echo $_GET['PHOTO']; ?>" width="300" height="225"><br> <br> [ <a href="makethumb.php?ID=<?php echo $_GET['ID']; ?>&PHOTO=<?php echo $_GET['PHOTO']; ?>">Make Thumbnail</a> ]</p> <form action='editphoto.php?ID=<?php echo $_GET['ID']; ?>&PHOTO=<?php echo $_GET['PHOTO']; ?>' method='POST'> <table width="456" align="center"> <tr> <th width="101" valign="top"> <div align="center"> </div></th> <th width="275"><strong>Photo Information</strong></th> </tr> <tr> <td valign="top"><div align="right"><strong>File Name:</strong></div></td> <td valign="top"><?php echo $_GET['PHOTO']; ?></td> </tr> <tr> <td valign="top"><div align="right"><strong>Photo Name:</strong></div></td> <td valign="top"><input name="imagename" type="text" id="imagename" value="<?php if(ISSET($image->ImageName)){ echo $image->ImageName; } ?>" size="30"></td> </tr> <tr> <td valign="top"><div align="right"><strong>Date:</strong></div></td> <td valign="top"><input name="date" type="text" id="date" value="<?php if(ISSET($image->Dates)){ echo $image->Dates; }else{ echo date("F j, Y, g:i a",time()); } ?>" size="30"></td> </tr> <tr> <td valign="top"> <div align="right"><strong>Description:</strong></div></td> <td valign="top"> <textarea name="description" cols="40" rows="10" id="description"><?php echo $image->Description; ?></textarea> </td> </tr> <?php if(ISSET($description)){ ?> <tr> <td valign="top"> </td> <td valign="top"><table width="85%" bordercolor="#000000"> <tr> <th><div align="center">Text File Found</div></th> </tr> <tr> <td><?php echo $description; ?></td> </tr> </table></td> </tr> <tr> <td valign="top"><div align="right"> <input name="txtupdate" type="checkbox" id="deletefile5" value="checkbox"> </div></td> <td valign="top">Use description from .txt file in updating the image description. The .txt contets are in the above table.</td> </tr> <tr> <td valign="top"><div align="right"> <input name="deletefile" type="checkbox" id="deletefile4" value="checkbox"> </div></td> <td valign="top">Delete .txt file after adding this description to the image.</td> </tr> <?php } ?> <tr> <td valign="top"> </td> <td valign="top"> <input name='update' type='submit' id='update' value='Update Image Info'> <input name='deleteall' type='submit' id='update3' value='Delete Description'> </td> </tr> </table> </form><br><br> <?php include($footer); ?> |