SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Wizard
    Join Date
    Apr 2002
    Posts
    2,292
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    trigger a search indexer (sphider) in background from php code?

    hello,

    i've installed sphider http://www.sphider.eu/ a free search spider indexer thing on a site. i want to trigger the indexing from a piece of php code which gets run when a particular web page is accessed but i want it to happen invisibly, in the background -- just be triggered by access to this particular web page but all the indexing that's going on remain unknown to the person who accessed the webpage. so i'm looking for some php code to trigger the indexing.

    that's the first problem. the second is it seems the indexing part is within a password protected place, so that may make the whole thing impossible.

    from sphider's forum (which i'm not getting much response from at the moment) there's this thread http://www.sphider.eu/forum/read.php?2,136 which talks about triggering the indexing of sphider from a cron job. for example one person posted this:

    cd /hsphere/local/home/campuspa/campuspages.net/sphider/admin/; /usr/local/bin/php spider.php -all

    which worked for them apparently. not sure where the password aspect comes into that. maybe with a cron job you don't need the password for some reason.

    any ideas how to trigger this from php automatically/invisibly much appreciated.

    thanks.

    ps the indexing takes a while so the indexing needs to happen in a seperate process/automated web page access.

  2. #2
    SitePoint Wizard
    Join Date
    Apr 2002
    Posts
    2,292
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    ah nearly found an answer:
    Code:
    $root = $_SERVER['DOCUMENT_ROOT'];
    
    exec("cd $root/sphider/admin/; php spider.php -all");
    it doesn't take place in the background, in another process though, so the page that's on pauses a good while while the indexing goes on. how to get that to happen in the background? (the password issue wasn't an issue thankfully)

  3. #3
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I would run such a script in a cron job (not the sphider.php directly). And this script would have a queue of pages to index in database, to which the pages are added from the script that your users visit. In such a way, the pages are queued immediately with no processing pauses, and are processed in background by the aforementioned script that runs in a cron job periodically.
    Saul

  4. #4
    SitePoint Wizard
    Join Date
    Apr 2002
    Posts
    2,292
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    but i've got a webpage which only admin people access when a page modification has been done so it'd be better to do it from that. just need to get the exec() backgrounded, that's all that's missing. thanks.

  5. #5
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    OK do it from that, it's the idea of queueing that I wanted to tell. It does not matter where you add the page to the queue, as long as you know what page to add from there.
    Saul

  6. #6
    SitePoint Wizard
    Join Date
    Apr 2002
    Posts
    2,292
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    right, i see, got ya.

    i've found the answer:

    exec("cd $root/sphider/admin/; php spider.php -all > /dev/null &");

    the > /dev/null & part backgrounds it super. that was less painful than i expected, esecially the password bit; i really saw badness/problems there but as i said, not an issue at all for some reason

    thanks.

  7. #7
    SitePoint Guru
    Join Date
    Oct 2006
    Location
    Queensland, Australia
    Posts
    852
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by johnyboy View Post
    right, i see, got ya.
    esecially the password bit; i really saw badness/problems there but as i said, not an issue at all for some reason
    The password on it would have been apache's authentication feature. A username and password would have only been required if accessing the file via http, which in this case you're not.

  8. #8
    SitePoint Wizard
    Join Date
    Apr 2002
    Posts
    2,292
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    i see, thanks for that.

  9. #9
    SitePoint Wizard
    Join Date
    Apr 2002
    Posts
    2,292
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    cripes, i posted here by accident, and the delete button isn't working


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
  •