Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID

In this Discussion

Dynamic galleries path

edited August 2009 in How do I?
Hello Victor!
Big thanks for your work. I'm very like it, but I have а problem. Unfortunately right now I can't give the link because I developing locally in Denwer, but I'll try to describe my problem thoroughly.
For my product I need to change path for galleries dynamically. So your code was modified:
1. All occurences of '/galleries/' in *.js changed to variable current_gallery_path.
2. All occurences of '/galleries/' in *.php changed to $settings['current_gallery_path'] (maybe it's not beautyful decision, but I have not found another way)
Of course changed only path strings, not function and variable names - chechked thoroughly.

3. current_gallery_path connected with $settings['current_gallery_path'] :
var current_gallery_path = <?php echo printValue($settings['current_gallery_path'])?>; 

in ajax.init.js

Now I have strange situation:
$settings['current_gallery_path'] = 'mygallerypath' ;
(actually in settings.php, but I tried in anoter places) works well and shows the galleries by needed path, but
$var_from_outside = 'mygallerypath';
$settings['current_gallery_path'] = $var_from_outside;
shows me the contents of parent(to mygallerypath) directory and "no images" message.
mygallerypath is on the same level as "stock" galleries directory, all slashes in code is on their places (checked very many times). The scope of $var_from_outside is global, php-debugger shows correct values for $var_from_outside and $settings['current_gallery_path'] till whole script executed.
After 3 days of debugging I have no idea what happens. So could you please tell me what goes wrong?

Thanks for your answer and sorry for poor English - it's not my native language.

Comments

  • edited August 2009
    i'd have to co through the full code to understand what is happening, and since it is not a bug, i cannot do that right now as i don't have the time.

    try converting the value of
    $var_from_outside
    to a string before passing it to the function, like
    strval($var_from_outside)
    more help: http://us.php.net/manual/en/function.strval.php
  • Thank you Victor, your solution helped partially.
    Now
    $var_from_outside = 'mygallerypath';
    $settings['current_gallery_path'] = strval($var_from_outside);

    works only if placed in settings.php exactly like here.
    But if $var_from_outside comes really from outside we've got the situation from my first post.
    Still thinkng how to work it out.
  • Even
    $var_from_outside=$_SESSION['current_gallery_path']; //registered earlier
    $settings['current_gallery_path'] = strval($var_from_outside);
    does not work :-(
  • it seems you're passing the variable through the GET method.

    i have to tell you that it will surely create a security breach issue, as someone passing malicious code might be able to get control of files in your server by passing a string like
    ../../../../etc/passwd
    or pointing at other sensitive folders and files in your server.

    it is not a good idea to pass paths dynamically for that reason. that said, i am sorry i cannot help you more.
  • I know about security issues, so I prefer sessions. The $var_from_outside passed through the POST method from face page to gallery script and there is
    session_start();
    $_SESSION['current_gallery_path']=$_POST['var_from_outside'];

    in the first lines of minishowcase's index.php.
    Today i'll put it on the server to give you the link.
  • great. send me the link and i'll see how i can help you!
  • And for security reasons the variable may contain noth the real path, but some code, that will be converted to path in the script.
Sign In or Register to comment.