#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Posts
    16
    Rep Power
    0
    Can anyone tell me why this would not work with PHP 3.0.16?

    First, assume all the variables are set properly. And putting

    printf ($modInclude);

    right before include ($modInclude);

    shows me that, yes, indeed the variable is correct.

    ****************
    function search($q, $r, $o, $s) {
    global $config;
    $modules = $config["searchModules"];
    $installBase = ereg_replace("(^.*)[/]$", "1", $config["installBase"]);

    settype($retVal, "array");

    reset($modules);
    while (list(, $module) = each($modules)) {
    $modInclude = $installBase . $config["fileSeparator"] . "libs" . $config["fileSeparator"] . "search" . $config["fileSeparator"] . $module . ".php";
    print($modInclude);
    if (!function_exists($module)) {
    if (is_readable($modInclude)) {
    include($modInclude);
    } else {
    printf("Error number 1: Unable to access search module '%s' (%s).<BR>n", $module, $modInclude);
    }
    }
    if (function_exists($module)) {
    $retVal = $module($retVal, $q, $r, $o, $s);
    if (is_string($retVal)) {
    printf("Error: Module '%s' had a fatal error. Details below:<BR>n<BR>n%s<BR>n", $module, $retVal);
    exit(1);
    }
    } else {
    printf("Error number 2: Search module '%s' (%s) is not usable.<BR>nThis module must contain the function '%s($retVal, $q, $r, $o, $s)'.<BR>n", $module, $modInclude, $module);
    }
    }
    print($modInclude);
    return $retVal;
    }
    ************
  2. #2
  3. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Brussels, Belgium
    Posts
    14,643
    Rep Power
    4492
    It'd help a little if you tell us what this code is trying to do, what the error is, and what line number.

    ------------------
    *************************************************************
    * The manual can probably answer 90% of your questions... *
    * *
    * PHP Manual. www.php.net/manual *
    * MySQL Manual: www.mysql.com/documentation/mysql/bychapter *
    *************************************************************
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Posts
    16
    Rep Power
    0
    So sorry. I've been staring at it so long I'd forgotten not everyone is as intimately involved with it as I am : )

    It's part of Digital Genesis Search (www.digitalgenesis.com); this part I quoted is all about looking to see what files are in a given directory and then including them in the page. There is a separate config.php file that is called by a require line at the top of the script (not shown); the $modInclude variable is then created in this part of the script by piecing together the information from the config.php file and running through the list of things in the $config[searchModules] variable (from config.php).

    My point is that it seems to create this $modInclude variable just fine (basically, a path), but it never executes the include($modInclude); line even though the the path name it creates is correct.

    I know this because I can
    printf ($modInclude);
    just before the include statement, then cut and paste that into an include line in another php file and it will work without error.

    The errors I get are the ones generated by the script in the lines
    printf("Error number 1: Unable to access search module '%s' (%s).<BR>n", $module, $modInclude);

    and
    printf("Error number 2: Search module '%s' (%s) is not usable.<BR>nThis module must contain the function '%s($retVal, $q, $r, $o, $s)'.<BR>n", $module, $modInclude, $module);


    For EACH of the items in $config[searchModules]

    No other errors are produced.

    Hope that's better?

    Thankyouthankyouthankyou for looking at this.


    [This message has been edited by mandy (edited October 06, 2000).]
  6. #4
  7. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Brussels, Belgium
    Posts
    14,643
    Rep Power
    4492
    if (is_readable($modInclude)) {

    This line could be causing trouble. Who is the include file owned by? If PHP runs as one user, and the file is owned by you, then this function will return false. It can still be included, though. If you're just checking to see if the file exists, try file_exists()

    Also, can you explain this line?

    $retVal = $module($retVal, $q, $r, $o, $s);

    it looks like your trying to call a function by using a variable. I don't think you can do that without using the eval() command...

    Don't know if I'm helping or not...but I'm trying..

    ---JH

    ------------------
    *************************************************************
    * The manual can probably answer 90% of your questions... *
    * *
    * PHP Manual. www.php.net/manual *
    * MySQL Manual: www.mysql.com/documentation/mysql/bychapter *
    *************************************************************
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Posts
    16
    Rep Power
    0
    uy. I can't answer these questions very well. I don't know enough about php and I didn't write it, I'm just trying to make it work. After some discussions with the guy who wrote it, he thought it was perhaps a php 3.0.16 bug or, perhaps more likely, something funky about the way the server I'm using is configured.

    I'll buy the permisssions theory. Those files are kept in a .htaccess protected directory, but I can write a little php file that includes a file from that directory without any problem, so do you think that is still it? The files are owned by the same owner of the whole web directory. How do I find out what PHP runs as?

    Also, if I want to change the line as you suggest, would it look like this?

    if (file_exists($modInclude)) {

    I can't explain the $retVal line at all, but other people don't seem to have the trouble I'm having making this work, so maybe we can assume it's okay.

    (There's a working version of this script at the digitalgenesis.com site.)

    Thanks again.
  10. #6
  11. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Brussels, Belgium
    Posts
    14,643
    Rep Power
    4492
    Maybe they can help you out more at the dgs website...i'm kind of at a loss.

    One of your problems is definetly the is_readable() function. It's failing, that's why you're getting Error 1. It's probably a permissions thing. PHP usually runs as 'nobody' or 'www'. The way you used file_exists() is correct, you could try it an d see if it gets rid of the first error.

    To see who php runs as, you can look in the phpinfo(). I think it shows something there...

    <HTML><BODY><? echo phpinfo(); ?></BODY></HTML>

    For your second error, nothing is being assigned to $retVal, so it's failing the is_string() test, and giving you the error. I'm at a big loss on the line assigning a value to $retVal, expecially if it's working on other sites.

    Sorry I can't be more help...

    ---JH

Similar Threads

  1. Frames hijacked after remote search
    By Telejoke in forum Antivirus Protection
    Replies: 2
    Last Post: September 26th, 2007, 09:32 AM
  2. Replies: 4
    Last Post: February 13th, 2005, 11:58 PM
  3. Is there any alternative to fulltext search?
    By irishairpics in forum MySQL Help
    Replies: 2
    Last Post: December 10th, 2003, 02:40 PM
  4. Site html search with php?
    By stojan in forum PHP Development
    Replies: 1
    Last Post: November 17th, 2003, 09:20 PM
  5. Replies: 37
    Last Post: October 2nd, 2003, 08:09 AM

IMN logo majestic logo threadwatch logo seochat tools logo