PassMark Logo
Home » Forum

Announcement

Collapse
No announcement yet.

Password protecting my zoom search engine

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Password protecting my zoom search engine

    I'm trying to embed the CGI into my php file. I've read this http://www.wrensoft.com/zoom/support...i.html#ssi_cgi

    But am still having problems. I'm not positive where I'm supposed to insert the suggested code so I tried it like this below. I also I'm not certain of the correct path. To reach the search.cgi it is currently located at http://mydomain/alpha/search.cgi. Is this correct?

    <form <?php
    $QSTRING = $_SERVER['QUERY_STRING'];
    virtual("/alpha/search.cgi".'?'.$QSTRING);
    ?>
    <p align="center"><input name="zoom_query">
    <input type="submit"
    value="Search"></p>
    </form>

    Thanks in advance for your help.

  • #2
    Inserting that PHP in the middle of the unclosed <form> tag certainly doesn't make any sense.

    That virtual() call inserts the output of the CGI inside the location on that page. You shouldn't need the form HTML at all that you've put around the PHP code.

    The page should literally look more like this:

    Code:
    <html>
    <head>
    <title>my custom PHP search page</title>
    </head>
    <body>
        <h1>Page title here</h1>
        <p>Check out my search form and results below!</p>
        <?php
        $QSTRING = $_SERVER['QUERY_STRING']; 
        virtual("/cgi-bin/search.cgi".'?'.$QSTRING);
        ?>
        <p>Rest of the page here</p>
    </body>
    </html>
    If you want to create a custom search form, then you'll have this separate from the PHP code above (you can have it before or after it, but not in the middle of it!). This is a different thing and not necessary for embedding the CGI. Follow the instructions carefully though and remember to set your Link Back URL.

    It's also worth noting that the instructions are different for IIS and Apache. Make sure you know what server you're running on and which example you should be following.
    --Ray
    Wrensoft Web Software
    Sydney, Australia
    Zoom Search Engine

    Comment


    • #3
      Thanks for the quick response.

      Clearly I'm showing my lack of skill so thank you for pushing me in the right directions.

      So my site is on Apache and I quickly respidered my index and included 'test.php' in the Link Back URL.

      Finally I simply cut and pasted your example:

      Code:
      <html>
      <head>
      <title>my custom PHP search page</title>
      </head>
      <body>
          <h1>Page title here</h1>
          <p>Check out my search form and results below!</p>
          <?php
          $QSTRING = $_SERVER['QUERY_STRING']; 
          virtual("/cgi-bin/search.cgi".'?'.$QSTRING);
          ?>
          <p>Rest of the page here</p>
      </body>
      </html>
      in for my test.php page.

      Here is the output... (any more thoughts?) Thanks!

      Page title here

      Check out my search form and results below!

      Fatal error: Call to undefined function virtual() in /home/user/public_html/mysite.com/test1/test.php on line 11[/CODE]

      Comment


      • #4
        Try the documented IIS method which uses shellexec(). The virtual() function might not be available on your web host's configuration.

        It is important to get the correct filepath when using shellexec(). This path must correspond to the actual filesystem on your server, and not a URL path like in your example before. It'll be more like "/home/user/public_html/mysite.com/alpha/search.cgi" (I'm just guessing from the examples you gave me).

        You should also make sure that the CGI is working fine as it is (with permissions correctly set), when you directly access the "search.cgi" from your browser.
        --Ray
        Wrensoft Web Software
        Sydney, Australia
        Zoom Search Engine

        Comment


        • #5
          So updated my test.php (search page) to the code below but I now just get "page title here" etc and nothing else. Not even errors. Is there away to know if the shell exec directory path is right? I use gatorhost which is popular. Also in the configuration I put "test.php" in the Link Back URL. Is that correct? -Thanks!

          <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
          <html>
          <head>
          <title>my custom PHP search page</title>
          </head>
          <body>
          <h1>Page title here</h1>
          <p>Check out my search form and results below!</p>
          <?php
          $QSTRING = $_SERVER['QUERY_STRING'];
          $REMADDR = $_SERVER['REMOTE_ADDR'];
          putenv("REQUEST_METHOD=GET");
          putenv("QUERY_STRING=$QSTRING");
          putenv("REMOTE_ADDR=$REMADDR");
          // absolute path to search.cgi required below
          $output = shell_exec("/home/user/public_html/mysite.com/test1/search.cgi");
          $output = ereg_replace("Content-type: text/html", "", $output);
          echo $output;
          ?>
          <p>Rest of the page here</p>
          </body>
          </html>

          Comment


          • #6
            I don't know what your filesystem path is, I was just guessing from your above posts and examples. You might want to ask your web host. Did you make sure that the CGI itself can actually execute when you access it directly via HTTP? (i.e. enter in http://www.mysite.com/test1/search.cgi into your browser).
            --Ray
            Wrensoft Web Software
            Sydney, Australia
            Zoom Search Engine

            Comment


            • #7
              Slowly but surely I'm making my way through this. I've resolved my path issue and I think I'm almost there but I have a strange bit of text appearing and I'm not sure why.

              The words "; charset=windows-1252" - (Note I added the quotes) appear above my search results when I run the simple page you suggested. Everything else is great!

              <html>
              <head>

              <?php
              $QSTRING = $_SERVER['QUERY_STRING'];
              $REMADDR = $_SERVER['REMOTE_ADDR'];
              putenv("REQUEST_METHOD=GET");
              putenv("QUERY_STRING=$QSTRING");
              putenv("REMOTE_ADDR=$REMADDR");
              // absolute path to search.cgi required below
              $output = shell_exec("/home/username/public_html/mysite.com/beta/search.cgi");
              $output = ereg_replace("Content-type: text/html", "", $output);
              echo $output;
              ?>
              <p>Rest of the page here</p>
              </body>
              </html>
              Any thoughts?

              Thanks again for all your great help!

              Comment


              • #8
                Try replacing the "ereg_replace" line in the above code with this:

                Code:
                $output = ereg_replace("Content-type: text/html; charset=windows-1252", "", $output);
                Should do the trick.
                --Ray
                Wrensoft Web Software
                Sydney, Australia
                Zoom Search Engine

                Comment

                Working...
                X