Novahq.net Forum

Novahq.net Forum (https://novahq.net/forum/index.php)
-   phphq.Net Forums (https://novahq.net/forum/forumdisplay.php?f=277)
-   -   phAlbum outputs a lot of random stuff (https://novahq.net/forum/showthread.php?t=39937)

jaf1230 10-25-2007 09:26 PM

phAlbum outputs a lot of random stuff
 
I dropped phAlbum.php and the three .gifs on my web server. I did not touch anything in phAlbum.php, and when I view it in my web browser on my server, I get everything after <scott@phphq.net>. I have PHP configured correctly, and phpinfo runs correctly. If I try to create an album, it fails, saying that the requested url, /album/< was not found. Logging in gives the same result.

Edit: I wanted to attach the output, but even though the rules say "You may post attachments" there is no button to do so.

http://www.phphq.net :- Copyright (c) 2005 All Rights Reserved :- :- This script 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 script 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. :-http://www.gnu.org/licenses/gpl.txt :- //================================================== ============================== * Description //================================================== ============================== :- phAlbum has got to be the easiest drag and drop photo album around. It sports an easy customizable look, and very powerfull features. :- With this one little file, you can make a whole photo album, very easily. Have it creat thumbs for you on the fly. (Requires GD Library) :- Features include, unlimited directory + sub-directory support, ignored files, only show certain types, auto image resizeing if desired, and :- simplicity. Plus it requires no database! All you need is this one little file. All that you need to do to create your album, :- is make folders and put images in them. The script does the rest. How much simplier can it get? Well, it now comes with a simple :- admin panel! You can make folders and upload images without your ftp client! Now, it can't get any easier. You can also do it the :- old fashin way with the ftp client if you like and turn the admin panel off! Anyways, hope this script comes in handy! //================================================== ============================== * Setup //================================================== ============================== :- To setup this script, simply drop this file anywhere in your website. Then edit the vars in phAlbum.php. //================================================== ============================== * Frequently Asked Questions //================================================== ============================== :- Q1: The script wont make thumbnails! (Yes it will, but with your help). :- A1: Make sure the folder in which the files are in is chmod 777. Use your ftp client or site admin panel to do this. :- A2: Make sure the file you want the script to make a thumb of is either jpg, gih or png. This script will not make thumbs of any other file types. :- Q2: I keep getting creating thumb errors. :- A1: Maybe the folder is chmod 777. Please do this using your ftp client or site admin panel. :- A2: This script can only make thumbs of jpg or gif images. Any other image types this script will fail to make images of. :- Q3: I cannot upload files to the folders I created in the admin panel. :- A1: Your server may have some security against the chmod() function. You will have to chmod each folder 777 with your ftp client or site admin panel. Sorry :(. :- A2: The file type of the uploaded file must be in the $show_files array in the settings of this script. Otherwise it will be denied. */ // ** ! REMEMBER TO CHMOD YOUR FOLDERS ! ** //Never know.. unset($phmessage); unset($thumb_error); unset($display_admin); /* //================================================== ============================== * ! ATTENTION ! //================================================== ============================== :- Please read the above FAQ before giving up or emailing me. It may sort out your problems! */ $album_title="My Picture Album"; //The name of this album $home_link="Album Home"; //The home link $admin_username="admin"; $admin_password="password"; $display_admin="1"; // Display the admin login form? If you select no, you will not be able to login! You will have to upload etc manually. 1=yes,0=no. $open_folder="./phopen.gif"; //The open folder image $close_folder="./phclose.gif"; //The closed folder image $big_folder="./phfolder.gif"; //The big folder image $script_url=$_SERVER['PHP_SELF']; //Change this if you want to use this as an include file. $files_path="./album/"; // Where does the album start? Anything under the directory the script will read. With Trailing slash $full_server="./album/"; //Enter the full server path to where the albums start. //With Trailing Slash $show_files=array("jpg","gif","png"); //The array, only show these types of files. $ignore_word="-hide"; //Hide files with this string in the name. Example, mypicture-hide.jpg will not be shown. $table_cells="3"; //How many images/folders in each row do you want? // Looks best with 3 $thumb_width="175"; //Width of the thumb $thumb_height="150"; // Height of the thumb $auto_thumb="1"; //Automatically create thumb's of gif and jpg images? 1=yes, 0=no. REQUIRES GD LIBRARY $jpg_quality="50"; // JPG thumb quality, does not work for png or gif. 0=low, 100=highest. $supress_error="0"; //Suppress errors if thumb creation fails. 1=hide errors, 0=show errors. $text_color="#868284"; // The text color. $text_size="10"; // The text size. $text_face="Verdana, Arial, sans-serif"; //The text face. Arial, Verdana etc. $link_color="#868284"; // The link color. $link_hover="#FFFFFF"; // Link link hover color, you know, when you put your mouse over a link! $error_color="#FF0000"; //Color for error messages $bgcolor="#293134"; // Page background color. $drop_shadow="1"; //Use the cool css drop shadow around the images? 1=yes, 0=no. $shadow_strength="1"; //How much do you want the shadow to show? Increase this value for more. $shadow_direction="135"; //1 to 360. Changes where the light is coming from. $shadow_color="grey"; //The shadow color. $image_border="2"; //Do you want a border around the images? 1-10, number of pixels. $border_color="#000000"; // What color do you want the image border to be? /* //================================================== ============================== * Attention //================================================== ============================== : Don't edit below this line unless you know some php. Editing some variables or other stuff could cause undeseriable results!! : This is no joke, I spent lots of time trying to work through everything, this is why I have so many comments in the file. */ //We need this to be here so we can cookie before we echo. If($display_admin) { If($_POST['login']) { If(($_POST['password']==$admin_password) AND ($_POST['username']==$admin_username)) { setcookie("phAdmin",$admin_username.$admin_passwor d); sleep(1); header("Location: ".$script_url."?".$_SERVER['QUERY_STRING']); exit; } } } //Header html.. for css etc. ?> Error: Folder ".$_POST['albumname']." could not be created. Maybe the folder exists?"; } Else { $phmessage="Folder ".$_POST['albumname']." has been created!"; } } Else { $phmessage="No Album name entered!"; } //Upload Images! } Elseif($_POST['upload']) { If($_FILES['image']['name']) { If(!upload()) { $phmessage="Error: Image ".$_FILES['image']['name']." could not be upload. Probably a Chmod Error or file exists."; } Else { $phmessage="Image ".$_FILES['image']['name']." has been uploaded!"; } } Else { $phmessage="No File Selected"; } } Elseif($_POST['remove']) { If($_POST['file']) { If(!remove()) { $phmessage="Could not delete file, probably a premission error.."; } Else { $phmessage="The file has been removed."; } } Else { $phmessage="No filename was sent to be deleted..."; } } } } //Makes the tables look nice and pretty. If($table_cells=="1") { $cell_width="100%"; } Elseif($table_cells=="2") { $cell_width="50%"; } Elseif($table_cells=="3") { $cell_width="33%"; } Elseif($table_cells=="4") { $cell_width="25%"; } Elseif($table_cells=="5") { $cell_width="20%"; } Elseif($table_cells=="6") { $cell_width="16%"; } Else { $cell_width="10%"; } //This is just a random ignore word if none is set above, pretty impossible to be in the filename anyways. If(!$ignore_word) { $ignore_word=microtime(); } //A bit tricky, but all in all it works, returns the filename without the extension! function file_name($key) { $key=strrev(substr(strstr(strrev($key), "."), 1)); return($key); } //Lets get the file extension. function file_ext($key) { $key=strtolower(substr(strrchr($key, "."), 1)); $key=str_replace("jpeg", "jpg", $key); return($key); } //My ever popular (Yeah right) function for image creation. function file_thumb($file,$album,$file_name) { global $thumb_width,$thumb_height,$jpg_quality; //Get the file extension! $file_ext=file_ext($file); //The GD Libary only supports jpg and gif really, well it can only make a gif a jpg. There are other ways like image magik, but not many have it so I didn't include that. So dent anything that isn't a gif or jpg :(. $Allow=array("jpg","gif","png"); If(in_array($file_ext,$Allow)) { //Lets do some converting! $imgdata=getimagesize($full_server.$album.$file); $imgresized=imagecreatetruecolor($thumb_width, $thumb_height); If($file_ext=="gif") { $imgsoruce=imagecreatefromgif($full_server.$album. $file); } Elseif($file_ext=="jpg") { $imgsoruce=imagecreatefromjpeg($full_server.$album .$file); } Elseif($file_ext=="png") { $imgsoruce=imagecreatefrompng($full_server.$album. $file); } Else { return false; } imagecopyresized($imgresized, $imgsoruce, 0, 0, 0, 0, $thumb_width, $thumb_height, $imgdata[0], $imgdata[1]); $new_file=$full_server.$album.$file_name."_thumb." .$file_ext; //PHP 4.4.X added safemode check which made me add this here.. $fh=fopen($new_file,'w'); fclose($fh); If($file_ext=="gif") { If(!imagegif($imgresized, $new_file)) { return false; } } Elseif($file_ext=="jpg") { If(!imagejpeg($imgresized, $new_file,$jpg_quality)) { return false; } } Elseif($file_ext=="png") { If(!imagepng($imgresized, $new_file)) { return false; } } imagedestroy($imgsoruce); imagedestroy($imgresized); return True; } return false; } //The tiny but powerfull ;) admin panel. function phadmin() { global $phmessage,$script_url,$album; If($phmessage) { Echo("
".$phmessage."

"); } ?>
Make New Album


Upload Image


\"Album ".$home_link." "; } Else { $nav="\"Album ".$home_link." "; } //How many paths do we got in $album? $count=@count($folder); //Lets make the naviation! Don't look if you have a weak stomache! for($i=0;$i<$count;$i++) { If($folder[$i]) { $path.=$folder[$i]."/"; //Give all the folders except the last folder a link and a closed picture. If(($count-2) > $i) { $nav .=" > \"".ucwords($folder[$i])."\" ".ucwords($folder[$i])." "; } Else { $nav .=" > \"".ucwords($folder[$i])."\" ".ucwords($folder[$i])." "; } } } Echo($nav); //Lets get some images!! $dir=@opendir($full_server.$album); //Loop through them all ;). while($file=@readdir($dir)) { //Don't display the stupid directory tree files. If($file!= "." AND $file!= "..") { //If it's a directory, show the folder image with a link to the new album If(is_dir($full_server.$album.$file)) { //If the file has the ignore word in it, do not show the file. If(!eregi($ignore_word,$file)) { $display_name=str_replace($find,$replace,$file); //Make the html $folders .= "\"".ucwords($display_name)."\"
".ucwords($display_name)."\n"; $j++; If(is_int($j / $table_cells)) { //This makes the table all nice and neat, actually, it splits the table with a new every $table_cells images/folders. $folders.= "\n\n"; $folder_close="1"; } Else { $folders.=""; } } // Else, the file is not a directory, so it must be an image. } Else { $file_ext=".".file_ext($file); $file_name=file_name($file); $display_name=str_replace($find,$replace,$file_nam e); //Hide the thumb files from displaying as regular files and disallow any file types that are not allowed. If((!eregi("_thumb",$file)) && (in_array(file_ext($file),$show_files))) { //If the file has the ignore word in it, do not show the file. If(!eregi($ignore_word,$file)) { //If a thumb file dosen't exists, then try and make one. If($auto_thumb) { If(!file_exists($full_server.$album.$file_name."_t humb".$file_ext)) { If(!file_thumb($file,$full_server.$album,$file_nam e)) { $thumb_error .="Thumb for ".$files_path.$album.$file." could not be created.
"; } } } //Now, if there is a thumb file, display the thumb, else display the full images but smaller :(. If(file_exists($full_server.$album.$file_name."_th umb".$file_ext) OR file_exists($full_server.$album.$file_name."_thumb ".$file_ext)) { $thumb="_thumb".$file_ext; } Else { $thumb=$file_ext; } //Make the html $remove=""; If($display_admin) { If($phAdmin==true) { $remove="\n
\n"; $remove.="\n"; $remove.="\n"; $remove.="\n"; $remove.="
\n"; } } If($drop_shadow) { //Cool drop shadow effect. $images .= "
\"".ucwords($display_name)."\"
".ucwords($display_name)."
".$remove."\n"; } Else { //Image border $images .= "\"".ucwords($display_name)."\"
".ucwords($display_name)."
".$remove."\n"; } $k++; If(is_int($k / $table_cells)) { //This makes the table all nice and neat, actually, it splits the table with a new every $table_cells images/folders. $images .= "\n\n"; $image_close="1"; } Else { $images .=""; } } } } } } @closedir($dir); //Close the directory so the bugs don't get in and display some folders and images! Whew! What a workout! ?>

\n"); Echo("\n"); Echo($folders); If(!$folder_close) { Echo("\n"); } Echo("\n"); Echo("\n"); } Echo("
\n"); If($images) { Echo("\n"); Echo("\n"); Echo($images); If(!$image_close) { Echo("\n"); } Echo("
\n"); If($thumb_error && !$supress_error) { Echo("
The following thumb errors have occured:

".$thumb_error."
Maybe this is from the folder ".$files_path.$album." not being chmod 777.
"); } } Else { Echo("\n"); Echo("\n"); Echo(""); Echo("\n"); Echo("
No images to display in this album. Please pick another album.
\n"); } Echo("
\n"); Echo("
\n"); If($display_admin) { Echo("
\n"); If($phAdmin==true) { phadmin(); } Else { ?>
Admin Login Here:
Username:
Password:
©phAlbum

Scott 10-25-2007 10:55 PM

I have no idea what do you in your case. But it looks as though php isnt reading phAlbum.php as a php file. Did you modify it in any way?

jaf1230 10-25-2007 11:08 PM

I dropped it in exactly. I unzipped it straight into my htdocs folder too, to see if path was causing a problem.
Then, I decided to clean up your code. Aside from the various syntax errors, you have spelling errors all over the place. You should use things like isset. Also, you resize all images to 175*150, regardless of the proper aspect ratio. I have no idea how your code worked for anyone else.

Oh, I'm running PHP 5.2.4 and Apache 2.0.46 on Windows XP, if that makes any difference. Maybe your code worked in PHP 4 or something.

jaf1230 10-26-2007 01:04 AM

I've been working on your code for about three hours. I removed the "admin" functionality (and therefore the upload), because it wasn't something that I wanted/needed, and it didn't work off the bat for me. Pictures now display 4:3 or 3:4, but I'm going to fix it to work for any aspect ratio in the morning. I squashed all of the undefined bugs that I ran into.
When you append to a variable in a loop using .=, you need to declare the variable first.

Code:

$my_string = "";
while($some_flag){
$my_string .= "bob ";
}

This prevents those nasty undefined variable errors that were all over the place.

katana*GFR* 10-26-2007 05:18 AM

Jaf, are you sure you got it from the phphq.net? Since i have been using it multiple times and still am and i dont have any problem with it at all..

www.feesttentsassem.nl check "foto's" its there and working.. Right out of the box..

jaf1230 10-26-2007 10:26 AM

Katana, I definitely got the version straight off of phphq.net, unzipped it, didn't modify it at all, and put it on my server. You're running version 1.0 of phPhotoAlbum. The name seems to have changed to phAlbum, and the version on the website is 1.1. A new release shouldn't break so horribly, but it may have. Also, are you running PHP 4 or 5? The copyright on the script is 2005, and php 5.0.0 was released in July 2004.

Lakie 10-26-2007 11:01 AM

Are you sure that /album/ exists in the same directory as phAlbum.php?

There are plenty of people using it, and I just got a fresh copy working locally. The only way that I could vaguely replicate your error is if album didnt exist...

jaf1230 10-26-2007 11:14 AM

/album exists.
If it were a problem with my directory structure, the initial comments wouldn't show up. My guess is that PHP 5 interprets the <email> as a tag, and tries to do stuff after that. Also, considering the way the code was written, /album not existing wouldn't be the biggest problem. I have no idea why it works for you and not for me.
How about when you reply that it works for you, you tell me what you're running? I'm running (again) PHP 5, Apache 2.0, and Windows XP.
Also, I made some improvements to the script that allow creation of thumbnails in the correct aspect ratio, regardless of what it is.

[edit]
Here, check it out on my server.
http://jaf1230.no-ip.org:1231/phalbum/phalbum.php
./album exists and has a gif in it. (not my best work)
If you look at phalbum.php.txt, that's the exact text that's in phalbum.php. If that's not what's off the site, then I don't know how I got it. I downloaded a zip from phphq.net, unzipped it, and put album/, phalbum.php, the readme, and the three images in /phalbum.

[edit2]
My version of the script resides in http://jaf1230.no-ip.org:1231/phalbum/newphalbum.php
[/edit]

Scott 10-26-2007 03:18 PM

ref: http://jaf1230.no-ip.org:1231/phalbum/phalbum.php

That only happens when php is not phrasing the file as php, but rather html. I don't know how your server is setup so I can't really help you with that, it could be that your host does not allow php short open tags. Try changing the beginning <? tag to <?php and see if that works.

jaf1230 10-26-2007 03:23 PM

Short tags were turned off, so I turned them on. It still has a bunch of undefined variable errors. But hey, it seems to be working if you don't mind a page of errors.

Notice: Undefined index: login in E:\Program Files\Apache Group\Apache\htdocs\phalbum\phAlbum.php on line 123

Notice: Undefined index: makedir in E:\Program Files\Apache Group\Apache\htdocs\phalbum\phAlbum.php on line 205

Notice: Undefined index: upload in E:\Program Files\Apache Group\Apache\htdocs\phalbum\phAlbum.php on line 218

Notice: Undefined index: remove in E:\Program Files\Apache Group\Apache\htdocs\phalbum\phAlbum.php on line 228

Notice: Undefined index: album in E:\Program Files\Apache Group\Apache\htdocs\phalbum\phAlbum.php on line 466
Album Home Album Home
Notice: Undefined variable: images in E:\Program Files\Apache Group\Apache\htdocs\phalbum\phAlbum.php on line 598

Notice: Undefined variable: k in E:\Program Files\Apache Group\Apache\htdocs\phalbum\phAlbum.php on line 606

Notice: Undefined variable: navigation in E:\Program Files\Apache Group\Apache\htdocs\phalbum\phAlbum.php on line 625


Notice: Undefined variable: folders in E:\Program Files\Apache Group\Apache\htdocs\phalbum\phAlbum.php on line 632


Notice: Undefined variable: image_close in E:\Program Files\Apache Group\Apache\htdocs\phalbum\phAlbum.php on line 647

tazz0710 10-26-2007 06:22 PM

i just installed it and had no errors like that at all. only error i had was because i didnt have enough memory allocated for it.

But it is all working great.

Lakie 10-26-2007 08:49 PM

chuck this line below the opening <?

error_reporting(0);

by default most peoples have php error reporting set so that those wouldn't appear. PHP is odd in that itll often throw out a Notice even though it something that could happen quite legitimately in the processing of the script. Its a good idea to do it anyway in a live environment for security reasons...

jaf1230 10-29-2007 01:33 PM

*sigh* Yeah, it's a good idea to turn off error reporting, but it's a better idea to make sure that you don't get the errors in the first place. It's a simple line of code:
if(!isset($varToInit)) $varToInit = "";
If you put this in before all the loops that .= on a string, it'll make your code, oh, 500 bytes longer, and will be correct, proper code. It takes less than a minute, and makes your code a lot better. Like comments, which are fortunately abundant here.
When I get a chance, I'll merge my copy with the official copy and upload the changes. My version not only doesn't throw those errors, but it also allows images to be any aspect ratio (including insane things like 15000:1). I may also implement a logout button (an important security function).

damian 11-01-2007 05:34 PM

Id really like to get ahold of a copy of those modifications. Im running several copies of the album and love it because its really simple, but I too dont care for the fixed thumbnail sizes.
Heck id even pay someone if they could put a pageing system into it as well.
DeepSouth Fishing

jaf1230 11-01-2007 09:42 PM

Paging system? Do you mean having multiple pages of pictures, or what?

damian 11-02-2007 07:14 AM

yea, sorry for the short post, was on my way out door to work. Ive started getting quite a few contributions by visitors for our fishing site and wanted a way to break it down into like 20 or 30 thumbs to a page, but also have quick links for previous, home, and next page across the top, and then repeated again across the bottom.
Im really kinda hooked on this album primarily because of the simplicity of just dropping the images and it auto makes the thumbs. This way I can use seperate uploaders to add the photos to wichever album I need to use, and it makes it really easy to copy any album and create another similar album with very minor changes.
Thanks

damian 11-09-2007 12:22 PM

exactly. Id like to have certian number of images to show up, and then have page 2,3,4...etc.

jaf1230 11-09-2007 12:36 PM

This album's simplicity is what sold me on it. I downloaded about a dozen other albums that wanted me to put my stuff in their folders, rather than being drop-in. I haven't had the time to work on this recently, since this coming week is finals week for me. I might work on it over Thanksgiving break.


All times are GMT -5. The time now is 03:36 AM.

Powered by vBulletin®