SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    May 2010
    Posts
    35
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Can't scandir() due to security restriction. Now how will my function work?

    Hi

    I have created a paging system for my site that manifests as a 'Next' and 'Previous' button at the bottom of the page. It works by matching the digits in the current URL, and then printing the HTML of the NEXT and PREV buttons with the href pointing to the new URL which is the same as the current URL but with the number being one greater or one lesser. So if my URL is http://www.site.com/services/page/05/ then the hrefs in the buttons will be http://www.site.com/services/page/04/ and http://www.site.com/services/page/06/ respectively.

    The thing is, if there is no 'next' page (as if we were at the end) or if there is no 'prev' page as if we are at the beginning, then the buttons must not display. So I created a conditional statement for each print command so that if the next or previous page in the list does not exist, it does not print the HTML.

    The list is an array of names of .html files in a directory. I create this list by scanning the directory and doing a PREG match to establish which directory contains the pages and which files are eligible to be pages (because not all addresses in that directory are suitable to be pages like '.' and '..'). By using this method I can make this whole thing a function and put the buttons in different parts of the website, and then in each different case I can specify what directory contains the files, what the files all look like (the PREG pattern) and how the new URLs must be printed inside the NEXT and PREV button links.

    OK great, so when I moved this system from my MAMP development environment to my client's live host, it didn't work because of a security restriction. So what should I do as an alternative? Thanks

  2. #2
    SitePoint Wizard bronze trophy Immerse's Avatar
    Join Date
    Mar 2006
    Location
    Netherlands
    Posts
    1,661
    Mentioned
    7 Post(s)
    Tagged
    1 Thread(s)
    Perhaps you can use a DirectoryIterator? http://php.net/manual/en/class.directoryiterator.php

    Otherwise you might need to contact the host, ask them to allow scandir. I don't really see why it should be blocked, unless they've configured their server poorly.

  3. #3
    Floridiot joebert's Avatar
    Join Date
    Mar 2004
    Location
    Kenneth City, FL
    Posts
    823
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What is the security restriction?
    Do you have an exact error message handy?


Bookmarks

Posting Permissions

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