Problem with php script

software development

#1

I am having a problem with a php script I hope that somebody can help me. I have looked at it until me eyes are crossed and I can’t figure it out.

The error i am getting is
Parse error: syntax error, unexpected T_IF, expecting ‘=’ in /home/.reebok/animationa/animationarchive.net/gen_pages/thumb.php on line 14

Here is the script

<?php // The file $filename = $_GET["file"]; $max = $_GET["width"]; $border = $_GET["border"]; // Content type header('Content-type: image/jpeg'); // Get new dimensions list($width, $height, $im_type) if ($width < $max) { $max = $width; } if ($width > $height) { $percent = $max / $width; } else { $percent = $max / $height; } $new_width = $width * $percent; $new_height = $height * $percent; // Resample $image_p = imagecreatetruecolor($new_width, $new_height); if ($im_type == 1) { $image = imagecreatefromgif("/home/.griff/disneyin/di/{$filename}"); } elseif ($im_type == 2) { $image = imagecreatefromjpeg("/home/.griff/disneyin/di/{$filename}"); } elseif ($im_type == 3) { $image = imagecreatefrompng("/home/.griff/disneyin/di/{$filename}"); ImageAlphaBlending($image, true); ImageAlphaBlending($image_p, true); } elseif ($im_type == 6) { $image = imagecreatefromwbmp("/home/.griff/disneyin/di/{$filename}"); } imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height); // Border if ($border == 1) { $color_black = imagecolorallocate($image_p,0,0,0); imageline($image_p, 0, 0, 0, $new_height-1, $color_black); imageline($image_p, 0, 0, $new_width-1, 0, $color_black); imageline($image_p, $new_width-1, 0, $new_width-1, $new_height-1, $color_black); imageline($image_p, 0, $new_height-1, $new_width-1, $new_height-1, $color_black); } // Output imagejpeg($image_p, null, 100); ?>

If somebody can help i would be greatly appreciative.


#2

You’re missing a semicolon on this line:list($width, $height, $im_type)--------
si-blog | Keystone Websites
Save $97 on yearly plans with promo code [color=#CC0000]SCJESSEY97[/color]


#3

i have tried that and when i add a semicolon to the line so it looks like

list($width, $height, $im_type);

I get the error:

Parse error: syntax error, unexpected ‘;’, expecting ‘=’ in /home/.reebok/animationa/animationarchive.net/gen_pages/thumb.php on line 12


#4

Hmmm. Well it definitely should have the semicolon, but I cannot see another problem. Odd. Are you sure that you are getting all the variables passed in the $_GET array?


si-blog | Keystone Websites
Save $97 on yearly plans with promo code [color=#CC0000]SCJESSEY97[/color]


#5

Oh I’ve figured it out. It’s the same line that has the problem. You are not using list() correctly. It should have an assignment in it:list($width, $height, $im_type) = $info;--------
si-blog | Keystone Websites
Save $97 on yearly plans with promo code [color=#CC0000]SCJESSEY97[/color]


#6

thanks for the help, but it still didn’t work. So I changed scripts and the new one seems to be working. The only issue is that in the new script it has 2 columns. The one on the left makes thumbnails and show thoses thumbnaisl for EVERY image in the folder, even if there are hundreds of images. On the right hand column is the image, so you select the image on the left and it shows it to the right. For a better understanding of what I am talking about look here: http://animationarchive.net/Classic Characters/AIM Buddy Icons/? What I whould like figure out is on the page just show the thumbnail (in just 1 column), but also show only maybe only 30 thumbnails at a time. I have looked through the scip and don’t see anything simple to change to get it to do that. Any help would be greatly appreciated. Here is the script:

<? /* * uAlbum by Pavel Mica - Crempa (http://ualbum.crempa.net) * v1.43 * simple one script online gallery (PHP CSS XHTML JS included) * */ // SETTINGS AREA ------------------------------------------------------------------------------------------------------ // layout define("THUMBNAIL_DIRECTORY","thumbs"); // name of thumbnail directory define("GALLERY_TITLE",""); // uAlbum title (right top corner position) define("TITLE",""); // actual gallery title define("LOADING_TEXT","Loading..."); // loading text (showed during image loading) define("SUBDIRECTORY_THUMBNAIL_DESCRIPTION_FILE","images"); // number of images title define("SUBDIRECTORY_THUMBNAIL_DESCRIPTION_DATE","date"); // date of directory title define("SUBDIRECTORY_THUMBNAIL_DESCRIPTION_DATE_FORMAT","d.m.Y"); // date format (PHP) of directory date define("SLIDESHOW_START_TEXT",""); define("SLIDESHOW_STOP_TEXT",""); define("FULLSCREEN_START_TEXT","fullscreen mode"); define("FULLSCREEN_STOP_TEXT","normal mode"); define("NEXT_IMAGE_TEXT","nexT>"); define("PREVIOUS_IMAGE_TEXT","<Prev"); define("GO_BACK_TEXT","<<.."); define("LAST_IMAGE_TEXT","That's all"); define("ORIGINAL_SIZE_SCREEN_TEXT","Original size"); define("ORIGINAL_SIZE_ALERT_TEXT","Image has original size now"); //layout colors define("MAIN_COLOR","rgb(155,155,155)"); define("GALLERY_TITLE_COLOR","rgb(255,255,255)"); define("TITLE_COLOR","rgb(0,0,0)"); // other setting define("NUMBER_OF_COLUMNS",3); // number of columns in "root directory" mode (layout is prepared for 3 columns) define("SLIDESHOW_INTERVAL",5000); // slideshow interval (ms) define("THUMBNAIL_DIRECTORY_CHMOD",0777); // CHMOD used for thumbnail directory define("RESIZE_ORIGINAL_IMAGES",false); // sets original images (images placed in same folder like script) resizing // images are resized (overwrited) to size setted below // use this function if size of images uploaded to the server is too big // gallery names replacement // you can set galery name replacing, original directory name is showed changed // example... directory name: "[s]koln[i]_v[y]let" ...is showed like... gallery name: "školní výlet" ...with default setting $replacement_original = array("_","[e]","[s]","[c]","[r]","[z]","[y]","[a]","[i]","[e]","[u]","[1u]","[o]"); $replacement_new = array(" ","ě","š","č","ř","ž","ý","á","í","é","ú","ů","ó"); // file sorting define("SORT_BY_DATE",false); // enables date/time sorting (default sorting is by name) define("OLDER_FIRST",false); // older files are showed first (works with names too) // error messages define("DIRECTORY_PERMISSION_PROBLEM_TEXT", "uAlbum could not create thumbnail directory
Set permissons using CHMOD(777) or contact your server admin"); define("FILE_PERMISSION_PROBLEM_TEXT", "uAlbum could not write thumbnails
Set permissons using CHMOD(777) or contact your server admin"); define("GDLIB_PNG_PROBLEM_TEXT", "Warning: You have not installed GD library or PNG file type is not supported"); define("GDLIB_GIF_PROBLEM_TEXT", "Warning: You have not installed GD library or GIF file type is not supported"); define("GDLIB_JPEG_PROBLEM_TEXT", "Warning: You have not installed GD library or JPEG file type is not supported"); // image sizes (experimental, do not change) define("LANDSCAPE_X",600); define("LANDSCAPE_Y",450); define("VERTICAL_X",337); define("VERTICAL_Y",450); // SCRIPT AREA ------------------------------------------------------------------------------------------------------ // --- FUNCTIONS --- function resizeImage($source,$destination,$x_size,$y_size) { $thumbnail=imagecreatetruecolor($x_size,$y_size); //thumbnail creating $path_parts = pathinfo($source); // file recognize process $extension=$path_parts["extension"]; $extension = strtolower($extension); switch ($extension) { case "png": if (!function_exists("ImageCreateFromPNG") or !function_exists("ImagePNG")) die (GDLIB_PNG_PROBLEM_TEXT); $img=ImageCreateFromPNG($source); imageCopyResampled($thumbnail,$img,0,0,0,0,$x_size,$y_size,ImageSX($img),ImageSY($img)); if (!@ImagePNG($thumbnail,$destination)) die(FILE_PERMISSION_PROBLEM_TEXT); break; case "gif": if (!function_exists("ImageCreateFromGIF") or !function_exists("ImageGIF")) die (GDLIB_GIF_PROBLEM_TEXT); $img=ImageCreateFromGIF($source); imageCopyResampled($thumbnail,$img,0,0,0,0,$x_size,$y_size,ImageSX($img),ImageSY($img)); if (!@ImageGIF($thumbnail,$destination)) die(FILE_PERMISSION_PROBLEM_TEXT);; break; default: if (!function_exists("ImageCreateFromJPEG") or !function_exists("ImageJPEG")) die (GDLIB_JPEG_PROBLEM_TEXT); $img=ImageCreateFromJPEG($source); imageCopyResampled($thumbnail,$img,0,0,0,0,$x_size,$y_size,ImageSX($img),ImageSY($img)); if (!@ImageJPEG($thumbnail,$destination)) die(FILE_PERMISSION_PROBLEM_TEXT);; break; } } function dateSortDesc($a, $b) { return (@filemtime($b) - @filemtime($a)); } function dateSortAsc($a, $b) { return (@filemtime($a) - @filemtime($b)); } function readDirectory($dir) { $dir = OpenDir($dir); // open script (.) directory $directories = Array(); // initializing directories array $files = Array(); // initializing files array while ($file = ReadDir($dir)) // loading all files in the script directory { if (!Is_Dir($file)) // testing if file(founded object) is directory { $path_parts = pathinfo($file); // file recognize process $extension=$path_parts["extension"]; $extension = strtolower($extension); if ($extension=="jpg" or $extension=="jpeg" or $extension=="png" or $extension=="gif") { $files[] = $file; // add file into array } } elseif($file!="." and $file!=".." and $file!=THUMBNAIL_DIRECTORY) { // object is directory and we dont want show thumbnail, . or .. directories $directories[] = $file; // add directory into array } } CloseDir($dir); // closing directory $output['directories'] = $directories; $output['files'] = $files; return $output; } // --- SCRIPT --- $directory_info = readDirectory('.'); $directories = $directory_info['directories']; $files = $directory_info['files']; // creating thumbnail directory if (!@OpenDir(THUMBNAIL_DIRECTORY)) { if (!@mkdir(THUMBNAIL_DIRECTORY,THUMBNAIL_DIRECTORY_CHMOD)) die (DIRECTORY_PERMISSION_PROBLEM_TEXT); chmod(THUMBNAIL_DIRECTORY,THUMBNAIL_DIRECTORY_CHMOD); } // sorting if (SORT_BY_DATE==true) { if (OLDER_FIRST==true) { usort($files, "dateSortAsc"); usort($directories, "dateSortAsc"); } else { usort($files, "dateSortDesc"); usort($directories, "dateSortDesc"); } } else { natsort($files); sort($directories); } reset($files); reset($directories); // --- FILE OPERATIONS --- $file_list=""; // string varibale contains filenames $thumbnail_list=""; // string variable contains construction of thumbnails list (left panel) $file_list_size=""; // string variable contains image orientation $i=0; //file array iterateing and generating thumbnails (if doesnt exist) and JS arrays foreach ($files as $file) { if (!file_exists(THUMBNAIL_DIRECTORY."/".$file)) resizeImage($file,THUMBNAIL_DIRECTORY."/".$file,90,90); if ($i!=0 && $i%2==0) $thumbnail_list.=""; // generating IE space after every two thumbnails $thumbnail_list.="\"".$file."\"\n"; $resolution=GetImageSize($file); // image resolution detection if (($resolution[0]>$resolution[1]) and ($resolution[0]!=LANDSCAPE_X or $resolution[1]!=LANDSCAPE_Y) and RESIZE_ORIGINAL_IMAGES==true) { resizeImage($file,$file,LANDSCAPE_X,LANDSCAPE_Y); } elseif (($resolution[0]<=$resolution[1]) and ($resolution[0]!=VERTICAL_X or $resolution[1]!=VERTICAL_Y) and RESIZE_ORIGINAL_IMAGES==true) { resizeImage($file,$file,VERTICAL_X,VERTICAL_Y); } $file_list.="'".$file."',"; // generating array of filenames } //last dash removing $file_list=substr($file_list, 0, -1); $file_list_size=substr($file_list_size, 0, -1); // --- DIRECTORY OPERATIONS --- $directory_list = Array(); foreach ($directories as $directory) { $subdirectory_info = readDirectory($directory); $subdirectory_files_count = count($subdirectory_info['files']); //number of image files in subdirectory $subdirectory_name = str_replace($replacement_original, $replacement_new, $directory); $subdirectory_date = date(SUBDIRECTORY_THUMBNAIL_DESCRIPTION_DATE_FORMAT,@filemtime($directory)); if ($subdirectory_files_count!=0) // some image files was founded in subdirectory { // sorting files in subdirectory if (SORT_BY_DATE==true) { if (OLDER_FIRST==true) { usort($subdirectory_info['files'], "dateSortAsc"); } else { usort($subdirectory_info['files'], "dateSortDesc"); } } else { natsort($subdirectory_info['files']); } $path_parts = pathinfo($subdirectory_info['files'][0]); // file recognize process $extension=strtolower($path_parts["extension"]); // generating subdirectory thumbnail if (!file_exists(THUMBNAIL_DIRECTORY."/".$directory.".".$extension)) resizeImage($directory."/".$subdirectory_info['files'][0],THUMBNAIL_DIRECTORY."/".$directory.".".$extension,90,90); $directory_list[]= "
\"".$directory.".".$extension."\" ".$subdirectory_name." ".SUBDIRECTORY_THUMBNAIL_DESCRIPTION_FILE.": ".$subdirectory_files_count."
".SUBDIRECTORY_THUMBNAIL_DESCRIPTION_DATE.": ".$subdirectory_date."
"; } else { $directory_list[]=" ".$subdirectory_name." "; } } // actual directory name detecting and setting gallery name $script_name = pathinfo($_SERVER["PHP_SELF"]); $pcs = explode("/", $script_name['dirname']); $dir_title = str_replace($replacement_original, $replacement_new, $pcs[count($pcs)-1]); $title = TITLE=="" ? ($dir_title =="" ? "Root directory" : $dir_title) : TITLE; // image absolute path detection $script_name_img = pathinfo("http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']); $imgPath = $script_name_img['dirname']; echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";

?>


#7

I recommend contacting the author of the script if you want that sort of help.


si-blog | Keystone Websites
Save $97 on yearly plans with promo code [color=#CC0000]SCJESSEY97[/color]