[Openfirst-cvscommit] photogallery/admin upload.php,NONE,1.1 preview.php,NONE,1.1 makethumb.php,NONE
Brought to you by:
xtimg
From: <dav...@us...> - 2003-06-08 02:41:04
|
Update of /cvsroot/openfirst/photogallery/admin In directory sc8-pr-cvs1:/tmp/cvs-serv21108/admin Added Files: upload.php preview.php makethumb.php index.php email.php cleargallery.php Log Message: initial upload --- NEW FILE: upload.php --- <?php /* * openFIRST.photogallery - upload.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 * */ // Import globals and estbalish database connection include("../config/globals.php"); include($header); include("galleryglobals.php"); mysql_select_db($sqldatabase,$sqlconnection); // Check if user is an admin then allow processes if (isset($user->user)){ $query = mysql_query("SELECT * FROM ofirst_galleries WHERE ID = '".$_GET['ID']."'"); $gallery = mysql_fetch_object($query); // Check if user initiates upload process and run upload process if(ISSET($_POST['upload'])){ ini_set("max_execution_time",$gallery_execution_time); $dirlocate = $gallerydir.$gallery->GalleryName; $imgtypes = explode(",",$imgtypes); for ($num=1;$num<=$_POST['NUM_UPLOADS'];$num++){ $continue = false; // NOTE: The change to uppercase in the if statement helps remove errors // I noticed this when I found that some software applications save images // extensions as upper case, so just making sure it doesn't give people problems. foreach($imgtypes As $type){ $extension = substr($_FILES['upload'.$num]['name'],-3); if(strtoupper($extension) == strtoupper($type)){ $continue = true; continue; } } if(! $continue){ echo "<center><br>".$_FILES['upload'.$num]['name']." - ".$_FILES['upload'.$num]['size']." - ".$_FILES['upload'.$num]['type']." - <font color='Red'>Illegal file type!</font></center>"; continue; } if (! $_FILES['upload'.$num]['name'] == ""){ copy($_FILES['upload'.$num]['tmp_name'], $dirlocate."/".$_FILES['upload'.$num]['name']) or $error = true; echo "<center><br>".$_FILES['upload'.$num]['name']." - ".$_FILES['upload'.$num]['size']." - ".$_FILES['upload'.$num]['type']." - "; if(empty($error)){ echo "<font color='Green'>Successful</font><br></center>\n"; }else{ echo "<font color='Red'>Not Successful</font><br></center>\n"; } } } } // Prepare fields for uploading next time if(ISSET($_POST['setuploads'])){ $uploads = $_POST['uploads']; }else{ $uploads = 5; } ?> <h2>Upload to Gallery</h2> <p><a href="manage.php">Manager</a> <a href="newgallery.php">Add New Gallery</a><?php membersmenu($user->membertype); ?></p> <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> </p> <p align="center">Current Files Allowd: <?php echo $imgtypes; ?></p> <p align="center"> <form action='upload.php?ID=<?php echo $_GET['ID']; ?>' enctype="multipart/form-data" method='POST'> <input name="uploads" type="text" id="uploads" size="2" maxlength="2"> <input name="setuploads" type="submit" id="setuploads" value="Add Spaces"> <input type="hidden" name="MAX_FILE_SIZE" size="5200000"> <input type="hidden" name="NUM_UPLOADS" value="<?php echo $uploads; ?>"><br> <?php // Output upload fields depending on the user request or not for($n = 1; $n <= $uploads ; $n++ ){ echo $n.". <input type='file' name='upload".$n."' size='29'><br>\n"; } ?> <br> <input name="upload" type="submit" value="Upload To Gallery"> </form> <?php }else{ showlogin(); } include($footer); ?> --- NEW FILE: preview.php --- <?php /* * openFIRST.photogallery - preview.php * * Copyright (C) 2003, * openFIRST Project * Original Author: 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 * */ function makethumb($imagesrc,$imagename,$imgtypes){ $img = $imagesrc."/".$imagename; $imgt = explode(",", $imgtypes); // Gather information about GD's current state and version $a = 'function gd_info() { $array = Array("GD Version" => ""); ob_start(); eval("phpinfo();"); $info = ob_get_contents(); ob_end_clean(); foreach(explode("\n", $info) as $line) { if(strpos($line, "GD Version")!==false) $array["GD Version"] = trim(str_replace("GD Version", "", strip_tags($line))); return $array; }'; // Run through the different file types and create images for ($x = 0; $x < count($imgt); $x++) { $imgt[$x] = strtolower($imgt[$x]); if($imgt[$x] == strtolower(substr($img, strrpos($img, ".") + 1, strlen($img) - strrpos($img, ".")))) { // Run options if file is png if($imgt[$x] == "png") { if(function_exists("imagepng") == true) { $src_img = imagecreatefrompng("$img"); $new_h = 100; $new_w = 100; if(strpos($a["GD Version"], "2.0") > 0) { $dst_img = imagecreatetruecolor($new_w,$new_h); imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $new_w, $new_h, imagesx($src_img), imagesy($src_img)); }else { $dst_img = imagecreate($new_w,$new_h); imagecopyresized($dst_img, $src_img, 0, 0, 0, 0, $new_w, $new_h, imagesx($src_img), imagesy($src_img)); } imagepng($dst_img,$imagesrc."/thumbs/".$imagename); imagedestroy($dst_img); imagedestroy($src_img); } } // Run options if file is for extension jpg or jpeg if($imgt[$x] == "jpg" || $imgt[$x] == "jpeg") { if(function_exists("imagejpeg") == true) { $src_img = imagecreatefromjpeg("$img"); $new_h = 100; $new_w = 100; if(strpos($a["GD Version"], "2.0") > 0) { $dst_img = imagecreatetruecolor($new_w,$new_h); imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $new_w, $new_h, imagesx($src_img), imagesy($src_img)); } else { $dst_img = imagecreate($new_w,$new_h); imagecopyresized($dst_img, $src_img, 0, 0, 0, 0, $new_w, $new_h, imagesx($src_img), imagesy($src_img)); } imagejpeg($dst_img,$imagesrc."/thumbs/".$imagename); imagedestroy($dst_img); imagedestroy($src_img); } } // Run options if file is gif (NOTE THAT GD2 DOES NOT SUPPORT THIS FUNCTION) if($imgt[$x] == "gif") { if(function_exists("imagegif") == true) { $src_img = imagecreatefromgif("$img"); $new_h = 100; $new_w = 100; if(strpos($a["GD Version"], "2.0") > 0) { $dst_img = imagecreatetruecolor($new_w,$new_h); imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $new_w, $new_h, imagesx($src_img), imagesy($src_img)); } else { $dst_img = imagecreate($new_w,$new_h); imagecopyresized($dst_img, $src_img, 0, 0, 0, 0, $new_w, $new_h, imagesx($src_img), imagesy($src_img)); } imagegif($dst_img,$imagesrc."/thumbs/".$imagename); imagedestroy($dst_img); imagedestroy($src_img); } } // Run options if file is bmp if($imgt[$x] == "bmp") { if(function_exists("imagebitmap") == true) { $src_img = imagecreatefrombitmap("$img"); $new_h = 100; $new_w = 100; if(strpos($a["GD Version"], "2.0") > 0) { $dst_img = imagecreatetruecolor($new_w,$new_h); imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $new_w, $new_h, imagesx($src_img), imagesy($src_img)); } else { $dst_img = imagecreate($new_w,$new_h); imagecopyresized($dst_img, $src_img, 0, 0, 0, 0, $new_w, $new_h, imagesx($src_img), imagesy($src_img)); } imagebmp($dst_img,$imagesrc."/thumbs/".$imagename); imagedestroy($dst_img); imagedestroy($src_img); } } } } } ?> --- NEW FILE: makethumb.php --- <?php /* * openFIRST.photogallery - makethumb.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 * */ // Import globals and estbalish database connection include("../config/globals.php"); include($header); include("galleryglobals.php"); include("preview.php"); mysql_select_db($sqldatabase,$sqlconnection); // Check if user is an admin then allow processes if (isset($user->user)){ $query = mysql_query("SELECT * FROM ofirst_galleries WHERE ID = '".$_GET['ID']."'") or die(mysql_error()); $gallery = mysql_fetch_object($query); $dirlocate = $gallerydir.$gallery->GalleryName; // Make thumbnail for particular photo if(ISSET($_GET['PHOTO'])){ makethumb($dirlocate,$_GET['PHOTO'],$imgtypes); die("<br><br><center>Thumbnail created! [ <a href='edit.php?ID=".$_GET['ID']."'>Edit</a> ]"); } // Make thumbnail for entire gallery if(ISSET($_GET['OPTION'])){ $dir = opendir($dirlocate); while(! (($file = readdir($dir)) === false)){ if (is_file($dirlocate."/".$file)){ makethumb($dirlocate,$file,$imgtypes); } } die("<br><br><center>Thumbnails created for gallery! [ <a href='edit.php?ID=".$_GET['ID']."'>Edit</a> ]"); } }else{ showlogin(); } include($footer); ?> --- NEW FILE: index.php --- <?php /* * openFIRST.photogallery - admin/index.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 * */ // Import globals and estbalish database connection include("../config/globals.php"); include($header); include("galleryglobals.php"); mysql_select_db($sqldatabase,$sqlconnection); // Check if user is an admin then allow processes if (isset($user->user)){ ?> <h2>Gallery Manager</h2> <p><a href="manage.php">Manager</a> <a href="newgallery.php">Add New Gallery</a><?php membersmenu($user->membertype); ?></p> <p align="center"> <table width="633" border="0" align="center" cellpadding="6" cellspacing="0"> <tr bgcolor="#999999"> <td valign="top"> <div align="center"> </div></td> <td><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Gallery Name</strong></font></td> <td><strong><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Description</font></strong></td> <td> <div align="left"><strong><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Option</font></strong></div></td> </tr> <?php // Retrieve galleries from database and list them accordingly $query = mysql_query("SELECT * FROM ofirst_galleries"); while($gallery = mysql_fetch_object($query)){ ?> <tr> <td width="58" valign="top"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><a href="gallery.php?ID=<?php echo $gallery->ID; ?>"><img src="gallery.PNG" width="58" height="51" border="0"></a></font></td> <td width="145" valign="top"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><?php echo $gallery->GalleryName; ?></font></td> <td width="307" valign="top"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><?php echo $gallery->Description; ?></font></td> <td width="75" valign="top">[ <a href="edit.php?ID=<?php echo $gallery->ID; ?>">Edit</a> ]<br> [ <a href="edit.php?DELETE=<?php echo $gallery->ID; ?>">Delete</a> ]</td> </tr> <?php } if (mysql_num_rows($query) == 0){ echo "<tr><td>--</td><td><br>There are no galleries uploaded<br><br></td>"; } ?> </table> <br> </p> <p align="center"> </p> <?php }else{ showlogin(); } include($footer); ?> --- NEW FILE: email.php --- <?php /* * openFIRST.photogallery - email.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 * */ // Import globals and estbalish database connection include("../config/globals.php"); include($header); include("galleryglobals.php"); mysql_select_db($sqldatabase,$sqlconnection); if(ISSET($_POST['send'])){ ini_set("MAX_EXECUTION_TIME",$gallery_execution_time); ini_set("SMTP",$SMTP); $from = $_POST['name']; $email = $_POST['email']; $recipient = $_POST['recipient']; $recipientemail = $_POST['recipientemail']; $comment = $_POST['comment']; $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; $headers .= "From: ".$title." Photo Gallery <".$mailfrom.">\r\n"; $headers .= "Reply-To: ".$mailfrom."\r\n"; $headers .= "X-Priority: 1\r\n"; $headers .= "X-MSMail-Priority: High\r\n"; $message = "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'> <html><head><meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'> </head><body><div align='center'> <table width='550' border='0' cellspacing='0' cellpadding='0'> <tr> <td height='23'><p>Hello ".$recipient.",</p> <p>This is a message from the <b>".$title."</b> photo gallery mailing system. <b>".$from." (".$email.")</b> has requested that you peview this image. Here are his comments:</p> <table width='400' border='1' align='center' cellpadding='6' cellspacing='0' bordercolor='#333333'> <tr> <td height='23'><p>".$comment."<br> </p> </td> </tr> </table> <p align='center'><img src='".$home."/photogallery/".$_POST['photo']."' width='300' height='200'></p> <p align='left'>Thank you for your time,</p> <p align='left'>The <b>".$title."</b> photo gallery.<br> </p></td> </tr> </table> </div></body></html>"; mail($recipientemail,$title." Gallery Photo Sender",$message,$headers) or die("<br><br><br><center>E-Mail was <b>not</b> successfully sent!</center>"); die("<br><br><br><center>Photo was successfully sent recipient, thank you! [ <a href='index.php'>Galleries</a> ]</center>"); } ?> <h2>Send To A Friend</h2> <p>[ <a href="index.php">View Galleries</a> ] <p align="center"><br> <img src="<?php echo $_GET['PHOTO']; ?>" width="200" height="150"><br> <br> You have requested to send this photo to a friend. Please enter the required<br> information below. <form method="POST" action="email.php"> <input type="hidden" name="photo" value="<?php echo $_GET['PHOTO']; ?>"> <table width="521" border="0" align="center" cellpadding="6" cellspacing="0"> <tr bgcolor="#999999"> <td valign="top"> <div align="center"> </div></td> <td><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>Gallery Name</b></font></td> </tr> <tr> <td width="140" valign="top"> <div align="right">Your Name: </div> <div align="right"></div></td> <td width="266" valign="top"><div align="left"> <input name="name" type="text" id="name"> </div></td> </tr> <tr> <td valign="top"><div align="right">Your E-Mail:</div></td> <td valign="top"><div align="left"> <input name="email" type="text" id="email" size="40"> </div></td> </tr> <tr> <td valign="top"><div align="right">Recipients Name:</div></td> <td valign="top"><div align="left"> <input name="recipient" type="text" id="recipient"> </div></td> </tr> <tr> <td valign="top"><div align="right">Recipients E-Mail:</div></td> <td valign="top"><div align="left"> <input name="recipientemail" type="text" id="recipientemail" size="40"> </div></td> </tr> <tr> <td valign="top"><div align="right">Comments:</div></td> <td valign="top"><div align="left"> <textarea name="comment" cols="35" rows="9" id="comment"></textarea> </div></td> </tr> <tr> <td valign="top"> </td> <td valign="top"><input name="send" type="submit" id="send" value="Send E-Mail"></td> </tr> </table> </form> <p> <?php include($footer); ?> --- NEW FILE: cleargallery.php --- <?php /* * openFIRST.photogallery - cleargallery.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 * */ // Import globals and estbalish database connection include("../config/globals.php"); include($header); include("galleryglobals.php"); mysql_select_db($sqldatabase,$sqlconnection); $query = mysql_query("SELECT * FROM ofirst_galleries WHERE ID = '".$_GET['ID']."'"); $gallery = mysql_fetch_object($query); // Check if user initiates the confirm of clearing the gallery if (ISSET($_GET['CONFIRM'])){ $dirlocate = $gallerydir.$gallery->GalleryName; $dir = opendir($dirlocate); while(! (($file = readdir($dir)) === false)){ if (is_file($dirlocate."/".$file)){ unlink($dirlocate."/".$file); if (file_exists($dirlocate."/thumbs/".$file)){ unlink($dirlocate."/thumbs/".$file); } } die("<br><br><center>The <b>".$gallery->GalleryName."</b> gallery has been reset. [ <a href='manage.php'>Manage</a> ]"); } } ?> <h2>Edit Gallery</h2><p><a href="manage.php">Manager</a> <a href="newgallery.php">Add New Gallery</a><?php membersmenu($user->membertype); ?></p> <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></p> <br><br><p align="center">You are trying to clear the entire <b><?php echo $gallery->GalleryName; ?></b> gallery! <a href="cleargallery.php?ID=<?php echo $_GET['ID']; ?>&CONFIRM=True">Confirm</a></p> <?php include($footer); ?> |