Current location: Hot Scripts Forums » Programming Languages » PHP » Gallery Scripting Help


Gallery Scripting Help

Reply
  #1 (permalink)  
Old 01-27-06, 04:58 AM
dennell dennell is offline
Newbie Coder
 
Join Date: Dec 2005
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Gallery Scripting Help

Hi there i was just wondering whether anyone knew why this code wont work when i try and open a certain Directory on my virtual homespace.

Code:
<?php 


	$handle=opendir("."); 
	$strSought = "gif"; 
	$imgCount = 0;  

	while ($file = readdir($handle)) 
	{ 
		if ($strSought == substr($file, -3)) 
		{ 
		    $imgCount = $imgCount + 1; 
		} 
	} 

	closedir($handle);

	if ($imgCount != 0)
	{
		$handle=opendir('.'); 

		$perRow = 5;

		$numRows = $imgCount/$perRow;

		$imgNum = 0;

		echo "<table width=\"100%\" border=\"0\">"; 

	 	//Note: readdir returns filenames in the order in which they are 
	 	//    stored by the filesystem. Future enhancement: sort by filename 
	 	//    (sequence they were shot) 
	 	
	 	while (false !== ($file = readdir($handle))) 
	 	{ 
			if ($strSought == substr($file, -3)) 
			{ 
			    $imgNum++;

			    $size = GetImageSize($file); 

			    $jpglink = substr($file, 0, 8);

			    echo "<td><a href=\"$jpglink.jpg\"><img src=\"$file\" height=\"$size[1]\" width=\"$size[0]\" border=\"1\" hspace=\"10\" vspace=\"20\"></a>";						

			    //modulus (%) $a % $b remainder of $a divided by $b 
			    if ($imgNum%$perRow)
			    {
				echo "</td>";
			    }
			    else							
			    {
				echo "</td></tr><tr>";
			    }
		 	 }
	  } 

	 closedir($handle); 
	 echo "</table>"; 
  }

?>
When i change the $handle=opendir("."); to $handle=opendir("/chosen/directory");
I keep getting an error

Does anyone have a solution please?
Reply With Quote
  #2 (permalink)  
Old 01-27-06, 09:39 AM
wheezy360's Avatar
wheezy360 wheezy360 is offline
Newbie Coder
 
Join Date: Nov 2003
Location: Toronto, ON
Posts: 64
Thanks: 0
Thanked 0 Times in 0 Posts
Could you post the error, please?
__________________
mike-robinson.ca
Reply With Quote
  #3 (permalink)  
Old 01-27-06, 10:01 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
Add a dot or remove the first slash from the directory. This should work.

PHP Code:

$handle=opendir("./chosen/directory"); 


// or

$handle=opendir("chosen/directory"); 
Reply With Quote
  #4 (permalink)  
Old 02-02-06, 10:31 AM
dennell dennell is offline
Newbie Coder
 
Join Date: Dec 2005
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks guys but!!

Hi guys thanks a lot for this it works really well indeed except i have one slight problem and that is when i create sepreate pages for the users eg. nico.php and sarah.php... no matter which of those two users I am logged in as I am still able to access both the user pages...

so for example, if i log in as nico i get redirected to nico.php page. but i am able still to access sarah.php... just by the simple fact that i am a logged in user

I hope this makes sense
can anyone help me with this??

thanks
Reply With Quote
  #5 (permalink)  
Old 02-04-06, 10:05 AM
End User's Avatar
End User End User is offline
Level II Curmudgeon
 
Join Date: Dec 2004
Posts: 3,027
Thanks: 14
Thanked 35 Times in 33 Posts
Quote:
Originally Posted by dennell
Hi guys thanks a lot for this it works really well indeed except i have one slight problem and that is when i create sepreate pages for the users eg. nico.php and sarah.php... no matter which of those two users I am logged in as I am still able to access both the user pages...

so for example, if i log in as nico i get redirected to nico.php page. but i am able still to access sarah.php... just by the simple fact that i am a logged in user
Sounds like you need to add some code to track who is logged in and restrcit them from accessing pages they aren't allowed to view.
__________________
I don't live on the edge, but sometimes I go there to visit.
-------------------------------------------------------------------------
Sanitize Your Data | Oracle Date & Substring Functions | Code Snippet Library | [url=http://www.codmb.com/Call Of Duty[/url]
Reply With Quote
  #6 (permalink)  
Old 02-04-06, 10:44 AM
ermau's Avatar
ermau ermau is offline
Wannabe Coder
 
Join Date: Aug 2003
Location: Florida, USA
Posts: 240
Thanks: 0
Thanked 0 Times in 0 Posts
Or dynamically generate your pages based on what user is logged in, the way it's supposed to be done
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP Gallery Feedback Kobra Website Reviews 3 01-02-06 03:21 PM
Looking for a different gallery solution Benqo Script Requests 2 12-13-05 10:21 AM
can someone help me develop a "favorites" or "wish list" script for my gallery? fpereira16 Script Requests 0 11-07-05 07:33 PM
Looking for a PHP Gallery script sm00nie Script Requests 0 06-26-05 08:55 PM
Ice Cream Man needs help! - Photo Gallery Creation Ice Cream Man Script Requests 0 04-07-05 07:22 PM


All times are GMT -5. The time now is 06:29 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.