[Openfirst-cvscommit] photogallery email.php,NONE,1.1 makethumb.php,NONE,1.1 edit.php,1.1,1.2 galler
Brought to you by:
xtimg
From: <dav...@us...> - 2003-06-05 19:18:40
|
Update of /cvsroot/openfirst/photogallery In directory sc8-pr-cvs1:/tmp/cvs-serv29426 Modified Files: edit.php gallery.php galleryglobals.php preview.php Added Files: email.php makethumb.php Log Message: Commit includes changes from task 79086. Thumbnails are completely fixed and working properly. preview.php required a lof of editing and should reqiure a bit more of a clean up. The e-mail option is now up and active. You can now set the SMTP server to send from in galleryglobals.php. --- 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: 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); $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> ]"); } include($footer); ?> Index: edit.php =================================================================== RCS file: /cvsroot/openfirst/photogallery/edit.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** edit.php 5 Jun 2003 01:56:56 -0000 1.1 --- edit.php 5 Jun 2003 18:36:16 -0000 1.2 *************** *** 116,118 **** ?> </table> ! <?php include($footer); ?> --- 116,119 ---- ?> </table> ! <center><br>[ <a href='makethumb.php?ID=<?php echo $_GET['ID']; ?>; ?>&OPTION=all'>Make Thumbnail's for Entire Gallery</a> ]<br><br></center> ! <?php include($footer); ?> \ No newline at end of file Index: gallery.php =================================================================== RCS file: /cvsroot/openfirst/photogallery/gallery.php,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** gallery.php 5 Jun 2003 01:56:56 -0000 1.4 --- gallery.php 5 Jun 2003 18:36:17 -0000 1.5 *************** *** 83,88 **** } echo "<td width='34%'><a target='_blank' href='viewphoto.php?ID=".$_GET['ID']."&PHOTO=".$file."'> ! <center><img height=100 width=152 src='preview.php?img=$dirlocate/$file'><br><a href=email.php> ! <img src=email.PNG alt='Email to a friend'></a><a target='_blank' href='viewphoto.php?ID=".$_GET['ID']."&PHOTO=".$file."'><img alt='Enlarge' src='enlarge.PNG'></a></center></a></td>"; $num++; } --- 83,97 ---- } echo "<td width='34%'><a target='_blank' href='viewphoto.php?ID=".$_GET['ID']."&PHOTO=".$file."'> ! <center>"; ! ! if(file_exists($dirlocate."/thumbs/".$file)){ ! echo "<img height=100 width=152 src='".$dirlocate."/thumbs/".$file."'>"; ! }else{ ! echo "<img height=100 width=152 src='".$dirlocate."/".$file."'>"; ! } ! ! echo "<br><a href='email.php?PHOTO=".$dirlocate."/".$file."'><img src=email.PNG alt='Email to a friend'></a><a target='_blank' ! href='viewphoto.php?ID=".$_GET['ID']."&PHOTO=".$file."'><img alt='Enlarge' src='enlarge.PNG'> ! </a></center></a></td>"; $num++; } Index: galleryglobals.php =================================================================== RCS file: /cvsroot/openfirst/photogallery/galleryglobals.php,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** galleryglobals.php 5 Jun 2003 14:20:55 -0000 1.4 --- galleryglobals.php 5 Jun 2003 18:36:18 -0000 1.5 *************** *** 38,40 **** --- 38,43 ---- $gallery_execution_time = "1200"; + // Declare SMTP to use when sending photo's by e-mail + $SMTP = "smtp.localhost.com"; + ?> Index: preview.php =================================================================== RCS file: /cvsroot/openfirst/photogallery/preview.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** preview.php 2 Jun 2003 23:51:57 -0000 1.3 --- preview.php 5 Jun 2003 18:36:19 -0000 1.4 *************** *** 26,126 **** * */ - $img = $_GET["img"]; ! include("galleryglobals.php"); ! $imgt = explode(",", $imgtypes); ! 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, ".")))) { ! if($imgt[$x] == "png") { ! if(function_exists(imagepng) == true) { ! header("Content-Type: image/png"); ! $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); ! imagedestroy($dst_img); ! imagedestroy($src_img); ! } else { ! header("Location: thumbnailerror.png"); ! } ! $displayed = "true"; ! } elseif($imgt[$x] == "jpg" || $imgt[$x] == "jpeg") { ! if(function_exists(imagejpeg) == true) { ! header("Content-Type: image/jpeg"); ! $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); ! imagedestroy($dst_img); ! imagedestroy($src_img); ! } else { ! header("Location: thumbnailerror.png"); ! } ! $displayed = "true"; ! } elseif($imgt[$x] == "gif") { ! if(function_exists(imagegif) == true) { ! header("Content-Type: image/gif"); ! $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); ! imagedestroy($dst_img); ! imagedestroy($src_img); ! } else { ! header("Location: thumbnailerror.png"); ! } ! $displayed = "true"; ! } elseif($imgt[$x] == "bmp") { ! if(function_exists(imagebitmap) == true) { ! header("Content-Type: image/bmp"); ! $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)); ! } ! imagebitmap($dst_img); ! imagedestroy($dst_img); ! imagedestroy($src_img); ! } else { ! header("Location: thumbnailerror.png"); ! } ! $displayed = "true"; ! } else { ! header("Location: thumbnailerror.png"); ! $displayed = "true"; ! } ! } ! } ! if($displayed != "true") { ! header("Location: thumbnailerror.png"); ! } ! ?> --- 26,137 ---- * */ ! 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); ! } ! } ! } ! } ! ! ! } ! ! ?> \ No newline at end of file |