Page 1 of 2 12 LastLast
Results 1 to 10 of 13
  1. #1
    Join Date
    Aug 2007
    Posts
    9
    Plugin Contributions
    0

    Default Randomizing the header_bg image

    hi

    I'm having issues setting the header_bg image to randomize.

    I've tried both the css method and the src= method, with three different php random scripts, and non of them works.

    Alt text shows, so I know I have the file paths correct. There's no instruction with any of the scripts regarding permissions (I have the php files in the templates/CUSTOM/images folder and the css files in the templates/CUSTOM/css file) so I wonder if this is the issue?

    I wonder if anyone has any suggestions?

    Thanks
    Christian

  2. #2
    Join Date
    Apr 2006
    Posts
    265
    Plugin Contributions
    0

    Default Re: Randomizing the header_bg image

    If the alt text is showing, most likely the file paths are NOT correct.

    Do you have a link?

    BrandTim

  3. #3
    Join Date
    Aug 2007
    Posts
    9
    Plugin Contributions
    0

    Default Re: Randomizing the header_bg image

    Quote Originally Posted by brandtim View Post
    If the alt text is showing, most likely the file paths are NOT correct.

    Do you have a link?

    BrandTim
    indeed:

    http://www.fairytalemail.co.uk/index.php

  4. #4
    Join Date
    Aug 2007
    Posts
    9
    Plugin Contributions
    0

    Default Re: Randomizing the header_bg image

    I should add the image path is

    http://www.fairytalemail.co.uk/inclu.../header_bg.jpg

    and this sits in the space labelled "Featured Products"

  5. #5
    Join Date
    Apr 2006
    Posts
    265
    Plugin Contributions
    0

    Default Re: Randomizing the header_bg image

    Taking a brief look at your code, the img src is this:
    http://www.fairytalemail.co.uk/inclu...der/rotate.php

    but you want it to be this:
    http://www.fairytalemail.co.uk/inclu.../header_bg.jpg

    Not sure exactly why you're trying to use a php file as the src for an image (although it can be done). It would be much better if you called the php file which then either returned or echoed the src URL.

    Regardless, your file path is definitely not what you want it to be.

    BrandTim

  6. #6
    Join Date
    Aug 2007
    Posts
    9
    Plugin Contributions
    0

    Default Re: Randomizing the header_bg image

    I'm not sure where you're getting the

    http://www.fairytalemail.co.uk/inclu...der/rotate.php

    from, as I can't find that anywhere.

    Not sure why I was rambling about the alt text, however, what I meant to say was that attempting to open

    http://www.fairytalemail.co.uk/inclu...ader/image.php

    gives me a 403 error - I expect that this is right, and the filepath is right. It's the same file in the src: includes/templates/santa/images/header/image.php - and the same location as http://www.fairytalemail.co.uk/inclu.../header_bg.jpg which of course opens.

    That's why I suspected a permissions issue in the firstplace, as there seems to be no fauilt with the filepaths

  7. #7
    Join Date
    Aug 2007
    Posts
    9
    Plugin Contributions
    0

    Default Re: Randomizing the header_bg image

    I should also add that I've now tried this method:

    <?php
    $random_imgs = array('header_bg.jpg', 'header_bg2.jpg');
    $random_img = $random_imgs[rand(0, 1)];
    ?>
    <img src="includes/templates/santa/images/<?php echo $random_img; ?>" width="369" height="176" alt="Welcome to FairytaleMail's Christmas Pages!" /></div>

    </div>
    if I change the <?php echo $random_img; ?> and replace it with header_bg.jpg, I see the image; the filepath works.

    It seems that whenever I attempt to use any kind of script to randomise the images, zencart stops me. I've determined that it is a permissions issue, but I don't have much experience with these, and don't know where to start

  8. #8
    Join Date
    Aug 2007
    Posts
    9
    Plugin Contributions
    0

    Default Re: Randomizing the header_bg image

    In fact I seem to have solved it - I've changed the permissions on define_main_page.php (where the script in the last post was housed) to 755, and this seems to have scratched it

    Cheers for the suggestion regarding how I was handling the php, brandtim!

  9. #9
    Join Date
    Apr 2006
    Posts
    265
    Plugin Contributions
    0

    Default Re: Randomizing the header_bg image

    Do not leave your html_includes files at 755! See here.

    ZenCart does not have the power to stop you from using a randomizer on your images. No CMS does. That was not what was going on.

    I was getting the link:
    http://www.fairytalemail.co.uk/inclu...der/rotate.php
    from HTML source code of your site. That was literally where the src of the image was pointed.

    The 403 error when trying to access this file:
    http://www.fairytalemail.co.uk/inclu...ader/image.php
    via HTTP is correct. No remote user should be able to execute PHP scripts from within the includes directory. If that worked it would pose a serious security risk.

    This is not a permissions issue - this is an execution issue. You were trying to have the src of your image point to a PHP file which would then respond with an image (NOT an image URL). While this is possible in certain scenarios, this is a bad idea when working with CMSs.

    I suspect (but am not 100% certain) that the problem you were having with the randomizer PHP code in define_main_page.php is that it never got to the server. If your permissions were set to 444 or perhaps 644, depending on how you were trying to put the file on the server, the server was rejecting the file and it was remaining unchanged. Changing the permissions to 755 allowed you to over-write the file with your changes and that is what allowed it to work.

    Be sure to change the permissions back to 644! In fact, I'd highly and strongly recommend going through all of the security recommendations on the page linked to above ASAP.

    BrandTim

  10. #10
    Join Date
    Aug 2007
    Posts
    9
    Plugin Contributions
    0

    Default Re: Randomizing the header_bg image

    Cheers sport - I do have one problem though - locking down the images folder effectively rewrites my layout, is there any way around this?

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. moving the navigation bar to just below the header_bg image?
    By silver500 in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 24 Nov 2011, 12:26 AM
  2. Another Randomizing Items Question
    By DK_Scully in forum Templates, Stylesheets, Page Layout
    Replies: 9
    Last Post: 24 Jan 2011, 08:53 PM
  3. How to add another Image each side of header_bg
    By butchx5 in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 15 Jan 2009, 03:29 PM
  4. Product Sort Order keeps randomizing
    By muzikladie in forum Setting Up Categories, Products, Attributes
    Replies: 1
    Last Post: 6 Aug 2007, 04:03 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg