Ah, but the danger is from "../" or absolute paths, both of which let unsanitized input potentially refer to directories outside (or above, if you prefer) your script's directory. Regarding your loop failure, other than that conditional that I think shouldn't be quite like that, I'm not sure what to tell you. On a slightly-related note, I see that you're using the set-and-test construct:


Code:

if($portfolio = $_GET['portfolio']) {$dir = $mdir . '/' . $portfolio . '/'; } else { $dir = $mdir . '/'; }


That will of course run the else {} code if $_GET['portfolio'] is empty, otherwise it will create the path from the non-empty $_GET['portfolio'] variable; is that what you want?
It is indeed what I wanted. Is there a better way to go about it?

How would you set up the loop so it didn't fail? Perhaps a hacky if($portfolio) {} else { instructions }?
comicIDIOT wrote:
It is indeed what I wanted. Is there a better way to go about it?

How would you set up the loop so it didn't fail? Perhaps a hacky if($portfolio) {} else { instructions }?
Do you care if the $portfolio is some invalid string? Or you just want to run { instructions} if $portfolio has no text in it? If the latter:


Code:
if (!isset($portfolio) || $portfolio == "") {
    instructions
}
I can't troubleshoot that enough to get a valid reason why it won't work.


Code:
# List all sub-directories as Portfolios if applicable portfolio thumbnail can be found
if (!isset($portfolio) || $portfolio == "") {    echo 'Hello there 1<br>';

   foreach($gallery_dirs as $f) {   echo 'Hello there 2<br>';
      if(file_exists($tpath . $f . '.jpg')) {
         echo '<img src="' . $tpath . $f . '.jpg" name="' . $f .'">';
      }
   }

} #endif, Portfolio List
I'm not getting either "Hello theres" and I know it's the correct page because I've changed some other things and gotten some non-fatal errors (and worked in preg_replace with some errors). :/



Update: I've changed the above code to the following, to still no avail. I get a "Hello there 0" but no "Hello there 1 or 2." It's not suppose to display images yet. Which, should actually have links around them. I guess I'll add that in as well. Then come back to this whole issue.


Code:
# List all sub-directories as Portfolios if applicable portfolio thumbnail can be found
if ($portfolio) {echo 'Hello there 0<br>';} else {    echo 'Hello there 1<br>';

   foreach($gallery_dirs as $f) {   echo 'Hello there 2<br>';
      if(file_exists($tpath . $f . '.jpg')) {
         echo '<img src="' . $tpath . $f . '.jpg" name="' . $f .'">';
      }
   }

} #endif, Portfolio List
Can you add an echo "{{".$portfolio."}}"; right before the if(... statement so we can see more about what might be happening?
I did. No dice.

http://alexglanville.com/eyefi/

I added a closing bracket just for the heck if it, got an unexpected "}" on line 205. I have no idea why that won't show. Not even the brackets show. Which is odd.
comicIDIOT wrote:
I did. No dice.

http://alexglanville.com/eyefi/

I added a closing bracket just for the heck if it, got an unexpected "}" on line 205. I have no idea why that won't show. Not even the brackets show. Which is odd.
Oh, that's a bit of PHP silliness. Try using "[[" and "]]" instead of the curly braces.
Still no luck. I have this setup currently:


Code:
$test = "Hey there, this is a test variable!";
echo "[[".$test."]]";
echo "[[".$portfolio."]]";
comicIDIOT wrote:
Still no luck. I have this setup currently:


Code:
$test = "Hey there, this is a test variable!";
echo "[[".$test."]]";
echo "[[".$portfolio."]]";
And you get "[[]][[]]", I assume?
Nope, nothing shows. Shockingly, I just found out (and was editing my post) that both appear at the bottom of the page when $portfolio is set. I'm baffled. But looking for answers within the code.

http://alexglanville.com/eyefi/?portfolio=portrait
http://alexglanville.com/eyefi/

This is a larger chunk of the code:


Code:
# List all sub-directories as Portfolios if applicable portfolio thumbnail can be found
$test = "Hey there, this is a test variable!";
echo "[[".$test."]]";
echo "[[".$portfolio."]]";

if ($portfolio) {echo 'Hello there 0<br>';} else {    echo 'Hello there 1<br>';

   foreach($gallery_dirs as $f) {   echo 'Hello there 2<br>';
      if(file_exists($tpath . $f . '.jpg')) {
         echo '<img src="' . $tpath . $f . '.jpg" name="' . $f .'">';
      }
   }

} #endif, Portfolio List
Since you're loading the full-size images on the gallery page anyways, have you considered writing a client side viewer? As in, load all of your images on one page, and then focus on an image when the user clicks on one.

You could still make it possible to link to a particular image with anchors/GET - plus, you're making things slightly faster while making it all look slicker.

Also, hello. Long time no speak.
rthprog wrote:
Since you're loading the full-size images on the gallery page anyways, have you considered writing a client side viewer? As in, load all of your images on one page, and then focus on an image when the user clicks on one.

You could still make it possible to link to a particular image with anchors/GET - plus, you're making things slightly faster while making it all look slicker.

Also, hello. Long time no speak.


Initially, the full size images were 640x480, and they are on the demo pages. But since I plan to move this to my portfolio's, they'll almost be 800pixels on the longest side. I haven't considered a client side viewer. I know I'm misunderstanding what you are saying by client side viewer, but an iOS application has crossed my mind many times. But that's farther down the road when I start enabling online registration and booking for photography sessions.

So I'm understanding what you mean, do you have any examples of client-side viewers that are web based?

Hello as well! I've been following your projects and such on Facebook and must say I'm impressed by all of them; great job on the recent Facebook hackathon as well Smile
comicIDIOT wrote:
rthprog wrote:
Since you're loading the full-size images on the gallery page anyways, have you considered writing a client side viewer? As in, load all of your images on one page, and then focus on an image when the user clicks on one.

You could still make it possible to link to a particular image with anchors/GET - plus, you're making things slightly faster while making it all look slicker.

Also, hello. Long time no speak.


Initially, the full size images were 640x480, and they are on the demo pages. But since I plan to move this to my portfolio's, they'll almost be 800pixels on the longest side. I haven't considered a client side viewer. I know I'm misunderstanding what you are saying by client side viewer, but an iOS application has crossed my mind many times. But that's farther down the road when I start enabling online registration and booking for photography sessions.

My client side, I mean client side javascript, as opposed to server side php. Something as simple as a lightbox with left/right buttons + keydown events would do.

A quick google search brings up tons of such implementations, though it would be fun to implement your own. (For example, http://galleria.aino.se/themes/folio/ )

comicIDIOT wrote:

Hello as well! I've been following your projects and such on Facebook and must say I'm impressed by all of them; great job on the recent Facebook hackathon as well

Thanks!
Ah, of course. I failed to realize server & client side scripts. I do have JavaScript in my plans, but nor for the gallery just yet. I want to continue my education of PHP before starting JavaScript. I'm not sure what project to start learning JavaScript with, though.

Meanwhile, I've made no progress in understanding where this error is stemming from Sad
Would you mind pastebinning your full code, or PMing it to be if you don't feel comfortable publishing it? Since you said nothing appears with $portfolio is empty, it sounds like you're doing something wrong above that. Smile
Sure, here is the entire page. I still have to set an image for thumbnails. I'll go ahead and do that now, but "Hello there 2" should show up none-the-less.

Update: I managed to get "Hello there 1" by forcing $portfolio to be a predicted value every time. But, it doesn't work if ?portfolio= is not set, oddly. I adjusted the following starting on line 206:


Code:
# List all sub-directories as Portfolios if applicable portfolio thumbnail can be found
$test = "Hey there, this is a test variable!";
echo "[[".$test."]]";

$portfolio = 1;

echo "[[".$portfolio."]]";

if ($portfolio !=1) {echo 'Hello there 0<br>';} elseif ($portfolio == 1) {    echo 'Hello there 1<br>';

   foreach($gallery_dirs as $f) {   echo 'Hello there 2<br>';
      if(file_exists($tpath . $f . '.jpg')) {
         echo '<img src="' . $tpath . $f . '.jpg" name="' . $f .'">';
      }
   }

} #endif, Portfolio List
It's amazing how the simple things can elude us. With just two variable adjustments and some commented out code (all Hello Theres!) we get a nice looking landing page. I've included the print out of the array for display purposes. Now, I just need to go to the other pages, to match the header & footer php files I'm using and I'll be able to use this script on my site Smile Again, to all who contributed, I really appreciate it!

Now, I just need to deiced if I want to check and see if there's a matching thumbnail image to save on bandwidth, or save smaller file sizes with JPEGmini. Which would hinder my previous project to include EXIF data within the photos for viewing. I'm sure I could upload a second image and point the EXIF script that image and display it's EXIf, but that opens the door to EXIF misinformation. Whether intentional or accidental.

As for the errors that's been troubling myself (and us?) the last few posts it turns out, all of the above came after something that came to this.


Code:
if(!$portfolio) {die();}


I'm a !bonafide genius.
Hahahahahaha, I figured it was probably something like that. Well done. Smile
Thanks Smile

Update: I've managed to add links to the respective portfolios, added the background images, restyled the notices and what not. Still need to sanitize the input and I plan to work with functions a bit and see if I can get the size down at all.

All that remains is figuring out how to fetch the thumbnails from their respective directory. Currently, I'm fetching and resizing full-size 900px photos. I don't get that much traffic, but I'm assuming my bandwidth would suffer anyways.

http://alexglanville.com/portfolio.php?portfolio=Hello!
Was able to adjust the script so that it would use thumbnails. No file_exists is in place to catch if the thumbnail isn't there for the full size image yet, but I know I'll need to add that. Right now I'm focusing on getting the include files in place and rewriting some pages to accept changes in the future - i.e. a different style.

Currently, the last two navigation links will result in error messages on the portfolio page, just to show it off.

Other things that I plan to adjust is to push down the portfolios, maybe enough so when the error message appears it doesn't push anything down the page a bit (not that it terribly matters). When I get around to the finalizing the pages as a whole, I'll need to take a new head-shot as the current head shot is a bad portrait and almost two years old.

Check it out! New & Old refers to the portfolio script, I'm not changing domains Very Happy

New: http://www.comicidiot.com
Old: http://www.alexglanville.com
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 3 of 5
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement