Jump to content

[SOLVED] Photo Gallery problem


logicopinion

Recommended Posts

Hello, i have a simple photo gallery.. wich reads images from "folder" creats thumbs in other folder and outputs on the page..

 

everything worked perfectly:

 

i kept it on my JOBS Server..

but now i got finished with that site.. bought new web hosting and trying to upload everything there..

 

and lil problem appeared i can`t understand why.. because on my temporary server gallery worked well when it came to new server error appeared.

 

this is the link of a temporary server and no error appears:

 

http://www.1school.ge/hotelbatumi/index.php?page=gallery&lang_id=eng

 

and this is new web server where it shows some error:

 

http://hotelbatumi.ge/index.php?page=gallery&lang_id=eng

 

and this is php code of gallery:

 


<?php
$lang_id = &$_REQUEST['lang_id'];
if (isset($lang_id) && $lang_id == "geo") { $imgpath="images/gallery_ge_pgtitle.jpg"; } 
elseif (isset($lang_id) && $lang_id == "eng") { $imgpath="images/gallery_en_pgtitle.jpg"; }
elseif (isset($lang_id) && $lang_id == "rus") { $imgpath="images/gallery_ru_pgtitle.jpg"; }
print "<BR>";
print "<table align='center' border='0' cellpadding='0' cellspacing='0' width='530' height='50'>";
print "<TR><TD height='50'><img src='$imgpath'></TD></TR>";
print "</table>";
?>
<?php


function createThumbs( $pathToImages, $pathToThumbs, $thumbWidth )
{

  $dir = opendir( $pathToImages );


  while (false !== ($fname = readdir( $dir ))) {
  
    $info = pathinfo($pathToImages . $fname);
  
    if ( strtolower($info['extension']) == 'jpg' )
    {
   

    
      $img = imagecreatefromjpeg( "{$pathToImages}{$fname}" );
      $width = imagesx( $img );
      $height = imagesy( $img );

    
      $new_width = $thumbWidth;
      $new_height = floor( $height * ( $thumbWidth / $width ) );

    
      $tmp_img = imagecreatetruecolor( $new_width, $new_height );

    
      imagecopyresized( $tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height );

    
      imagejpeg( $tmp_img, "{$pathToThumbs}{$fname}" );
    }
  }

  closedir( $dir );
}
createThumbs("images/upload/","images/upload/thumbs/",140);



function createGallery( $pathToImages, $pathToThumbs )
{
  
  $output .= "<table bgcolor='#f0f0f0' border=\"0\" cellspacing=\"5\" align=\"center\" cellpadding=\"12\" width=\"500\">";
  $output .= "<tr>";
  

  $dir = opendir( $pathToThumbs );

  $counter = 0;
  $output.=" <SCRIPT LANGUAGE=\"JavaScript\">
        function openindex(imgname)

         {
        OpenWindow=window.open(\"\", \"newwin\", \"height=700, width=760,toolbar=no,scrollbars=\"+scroll+\", menubar=no, top=100, left=50\");
        OpenWindow.document.write(\"<HTML>\")
        OpenWindow.document.write(\"<HEAD>\")
        OpenWindow.document.write(\"<TITLE>Gallery</TITLE>\")
        OpenWindow.document.write(\"</HEAD>\")
        OpenWindow.document.write(\"<STYLE>\")
        OpenWindow.document.write(\".asdad {font-size:14px; font-family: Tahoma; color: #C30000; Font-weight:Bold; text-decoration:none;} p { font-family:Tahoma; font-weight:bold; font-size:10px; color:#000000;\")
        OpenWindow.document.write(\"</STYLE>\")
        OpenWindow.document.write(\"<BODY BGCOLOR='#FFFFFF' topmargin='0' leftmargin='0' rightmargin='0' bottommargin='0'>\")
        OpenWindow.document.write(\"<div align=right style='padding-top:15px; padding-right:15px;'><a class='asdad'  href='JavaScript:self.close();'>x</a></div>\")
        OpenWindow.document.write(\"<div align=right style='padding-right:15px;'><P>HOTEL BATUMI</p></div>\")
        OpenWindow.document.write(\"<table border='0' cellspacing='0' cellpadding='0' width='100%' align='center' width='750' height='700'>\")
        OpenWindow.document.write(\"<tr>\")
        OpenWindow.document.write(\"<td align='center' valign='top'>\")
        OpenWindow.document.write(\"<img src=\"+imgname+\">\")
        OpenWindow.document.write(\"</td>\")
        OpenWindow.document.write(\"</tr>\")
        OpenWindow.document.write(\"</table>\")
        OpenWindow.document.write(\"</BODY>\")
        OpenWindow.document.write(\"</HTML>\")
        OpenWindow.document.close()
        self.name=\"main\"              
         }
           </SCRIPT>";

  while (false !== ($fname = readdir($dir)))
  {
  
    if ($fname != '.' && $fname != '..')
    {
     $output .= "

  
                  <td onmouseover=\"this.style.backgroundColor='#DADADA';\" onmouseout=\"this.style.backgroundColor='#f0f0f0';\" valign=\"middle\" align=\"center\">
                  <a href=\"javascript:void(0)\" onclick=\"openindex('{$pathToImages}{$fname}')\" Return false;>";

                  $output .= "<img src=\"{$pathToThumbs}{$fname}\" border=\"0\" />";
                $output .= "</a></td>";
              $counter += 1;
          if ( $counter % 3 == 0 ) { $output .= "</tr><tr>"; }
    }
  }

  closedir( $dir );

  $output .= "</tr>";
  $output .= "</table>";
  print "$output";


}
createGallery("images/upload/","images/upload/thumbs/");

?>

 

Any Suggestations?

 

Thank you in Advacne !!!

 

Link to comment
https://forums.phpfreaks.com/topic/104552-solved-photo-gallery-problem/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.