Jump to content

a.beam.reach

New Members
  • Posts

    9
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

a.beam.reach's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Incredible. Now I'll play around with the formatting. This forum is great. Friendly help in minutes! I hope my learning curve will be steep so I can help out others soon. Thanks, Trevor
  2. Thank you for your help. Is the first line where I point to the image folder? I don't get any errors but also don't get any results. $array=glob('http://www.mysite.com/images/*'); foreach($array as $v){ echo '<img src="'.$v.'">'; }
  3. I would like to write a script that displays all photos (jpg) from a folder. I want to be able to load photos into a folder without renaming them and have a script sort them and display them alphabetically. Can someone point me in the right direction? Thanks in advance for any help offered!
  4. Thank you LazyJones and xenophobia. . .. I did not get a chance to try your suggestion xenophobia. . . . as I had already tried the suggestion of LazyJones. It worked great! I did notice the suggestions were slightly different. Guess there is more than one way to skin a cat! Thanks to you both. Trevor
  5. I am wondering how to ignore lines of PHP code if the applicable variable is empty. For example in the code below. . . . if the variable $r is empty. . .. I would like the entire line: echo "http://www.mysite.com/images/$r/1" to be ignored. Can you tell that I am very novice!!!! I am learning though. <? // SET GALLERY OPTIONS HERE // ----------------------- // Set Gallery options by editing this text: $q =$_POST['q']; $r =$_POST['r']; echo "http://www.mysite.com/images/$q/1" echo "http://www.mysite.com/images/$r/1" ?>
  6. I use a flash photo gallery called Simple Viewer-Pro. http://www.airtightinteractive.com/simpleviewer/ I wanted to use this gallery because it allows me to dump photos into a folder on my server and simply run a php script that writes a xml file which the flash file uses to properly sort etc. I build many auction listings daily and wanted to cut down on some time. Glyde helped me with how to handle some variables in the PHP form. The gallery works great but I have been warned that many people either dont have flash or intentionally turn it off. I want to provide an 'alternate content' link on my listings with the pictures that are displayed in the flash file. But. .. . . I don't want to have to manually write this file. Finally My Question Can I use PHP to write a simple html file? Here is the PHP code that writes the xml file and builds thumbnails: <? // SET GALLERY OPTIONS HERE // ----------------------- // Set Gallery options by editing this text: $q =$_POST['q']; $r =$_POST['r']; $s =$_POST['s']; $t =$_POST['t']; $u =$_POST['u']; $v =$_POST['v']; $w =$_POST['w']; $x =$_POST['x']; $y =$_POST['y']; $z =$_POST['z']; $a =$_POST['a']; $options .= '<simpleviewerGallery maxImageWidth="' .$r. '" maxImageHeight="' .$s. '" textColor="0x' .$t. '" frameColor="0x' .$u. '" frameWidth="' .$v. '" stagePadding="' .$w. '" thumbnailColumns="' .$x. '" thumbnailRows="' .$y. '" navPosition="' .$z. '" title="" enableRightClickOpen="' .$a. '" backgroundImagePath="" imagePath="http://www.goods-byeauction.com/ebayimg/' .$q. '/images/" thumbPath="http://www.goods-byeauction.com/ebayimg/' .$q. '/images/">'; // Set showDownloadLinks to true if you want to show a 'Download Image' link as the caption to each image. $showDownloadLinks = false; // set useCopyResized to true if thumbnails are not being created. // This can be due to the imagecopyresampled function being disabled on some servers $useCopyResized = true; // Set sortImagesByDate to true to sort by date. Otherwise files are sorted by filename. $sortImagesByDate = false; // Set sortInReverseOrder to true to sort images in reverse order. $sortInReverseOrder = false; // END OF OPTIONS // ----------------------- print "Creating XML and thumbnails for SimpleViewer.<br>"; print "-------------------------------------------------<br><br>"; //Get GD imaging library info $tgdInfo = getGDversion(); if ($tgdInfo == 0){ print "Note: The GD imaging library was not found on this Server. Thumbnails will not be created. Please contact your web server administrator.<br><br>"; } if ($tgdInfo < 2){ print "Note: The GD imaging library is version ".$tgdInfo." on this server. Thumbnails will be reduced quality. Please contact your web server administrator to upgrade GD version to 2.0.1 or later.<br><br>"; } if ($sortImagesByDate){ print "Sorting images by date.<br>"; }else{ print "Sorting images by filename.<br>"; } if ($sortInReverseOrder){ print "Sorting images in reverse order.<br><br>"; }else{ print "Sorting images in forward order.<br><br>"; } //loop thru images $xml = '<?xml version="1.0" encoding="UTF-8" ?>'.$options; $folder = opendir("images"); while($file = readdir($folder)) { if ($file[0] != "." && $file[0] != ".." ) { if ($sortImagesByDate){ $files[$file] = filemtime("images/$file"); }else{ $files[$file] = $file; } } } // now sort by date modified if ($sortInReverseOrder){ arsort($files); }else{ asort($files); } foreach($files as $key => $value) { $xml .= ' <image>'; $xml .= '<filename>'.$key.'</filename>'; //add auto captions: 'Image X' if ($showDownloadLinks){ $xml .= '<caption><![CDATA[<A href="images/'.$key.'" target="_blank"><U>Open image in new window</U></A>]]></caption>'; } $xml .= '</image>'; print "- Created Image Entry for: $key<br>"; if (!file_exists("./thumbs/".$key)){ if (createThumb($key)){ print "- Created Thumbnail for: $key<br>"; } } } closedir($folder); $xml .= '</simpleviewerGallery>'; //next line can cause erroneous warnings //chmod( 'imageData.xml', 0777 ); $file = "gallery.xml"; if (!$file_handle = fopen($file,"w")) { print "<br>Cannot open XML document: $file<br>"; } elseif (!fwrite($file_handle, $xml)) { print "<br>Cannot write to XML document: $file<br>"; }else{ print "<br>Successfully created XML document: $file<br>"; } fclose($file_handle); // }}} // {{{ createThumb() /** * Create a squared thumbnail from an existing image. * * @param string $file Location and name where the file is stored . * @return boolean * @access public * @author Christian Machmeier */ function createThumb($fileName) { // Get information about the installed GD. $gdVersion = getGDversion(); if ($gdVersion == false) { return false; } $file = 'images/'.$fileName; $fileDest = 'thumbs/'.$fileName; // Get the image dimensions. $dimensions = @getimagesize($file); $width = $dimensions[0]; $height = $dimensions[1]; $outputX = 65; $outputY = 65; $quality = 85; // The image is of vertical shape. if ($width < $height) { $deltaX = 0; $deltaY = ($height - $width) / 2; $portionX = $width; $portionY = $width; // The image is of horizontal shape. } else if ($width > $height) { $deltaX = ($width - $height) / 2; $deltaY = 0; $portionX = $height; $portionY = $height; // The image is of squared shape. } else { $deltaX = 0; $deltaY = 0; $portionX = $width; $portionY = $height; } $imageSrc = @imagecreatefromjpeg($file); // The thumbnail creation with GD1.x functions does the job. if ($gdVersion < 2 || $useCopyResized) { // Create an empty thumbnail image. $imageDest = @imagecreate($outputX, $outputY); // Try to create the thumbnail from the source image. if (@imagecopyresized($imageDest, $imageSrc, 0, 0, $deltaX, $deltaY, $outputX, $outputY, $portionX, $portionY)) { // save the thumbnail image into a file. @imagejpeg($imageDest, $fileDest, $quality); // Delete both image resources. @imagedestroy($imageSrc); @imagedestroy($imageDest); return true; } } else { // The recommended approach is the usage of the GD2.x functions. // Create an empty thumbnail image. $imageDest = @imagecreatetruecolor($outputX, $outputY); // Try to create the thumbnail from the source image. if (@imagecopyresampled($imageDest, $imageSrc, 0, 0, $deltaX, $deltaY, $outputX, $outputY, $portionX, $portionY)) { // save the thumbnail image into a file. @imagejpeg($imageDest, $fileDest, $quality); // Delete both image resources. @imagedestroy($imageSrc); @imagedestroy($imageDest); return true; } } return false; } function getGDversion() { static $gd_version_number = null; if ($gd_version_number === null) { // Use output buffering to get results from phpinfo() // without disturbing the page we're in. Output // buffering is "stackable" so we don't even have to // worry about previous or encompassing buffering. ob_start(); phpinfo(; $module_info = ob_get_contents(); ob_end_clean(); if (preg_match("/\bgd\s+version\b[^\d\n\r]+?([\d\.]+)/i", $module_info,$matches)) { $gd_version_number = $matches[1]; } else { $gd_version_number = 0; } } return $gd_version_number; } ?>
  7. Thank you Glyde!!! Wow that was fast. . . . I think you answered my question almost BEFORE I asked it. I had it mostly correct at one time but neglected the period after the $q I have already applied it and tested it. . . . works great! Thank you
  8. I am very 'green' with PHP! I have a form on another html page and I want to add the user input ( $q =$_POST['q'] ) to the php code below in place of "VARIABLE HERE" I would be grateful for any help on how to do this. <? // SET GALLERY OPTIONS HERE // ----------------------- // Set Gallery options by editing this text: $q =$_POST['q']; $options .= '<simpleviewerGallery maxImageWidth="600" maxImageHeight="600" textColor="0xFFFFFF" frameColor="0x000000" frameWidth="2" stagePadding="40" thumbnailColumns="1" thumbnailRows="5" navPosition="left" title="" enableRightClickOpen="false" backgroundImagePath="" imagePath="http://www.mysite.com/VARIABLE HERE/images/">';
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.