PassMark Logo
Home » Forum

Announcement

Collapse
No announcement yet.

Warning: file(search_template.html): failed to open stream..

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

  • Warning: file(search_template.html): failed to open stream..

    I'm testing Zoom on a client's site with the hopes of getting it to work and purchasing a Zoom Professional license. I'm very impressed with Zoom, but unfortunately I'm running into a small problem that I can't seem to resolve on my own.

    I'm using Zoom Free, Version 4.2(Build 1007). The site is being hosted by Interland on a shared server(unfortunately) which is running PHP Version 4.3.10.

    I am getting the following error;

    "Warning: file(search_template.html): failed to open stream: No such file or directory in d:\Customers\user1177213\www\search.php on line 586"

    Line 586 of search.php is: $template = file ($TemplateFilename);

    Looking at the PHP, I don't see where the variable $TemplateFilename is defined, but the warning message seems to indicate that it's defined as search_template.html. I have verified that the search_template.html file has been uploaded to the server along with the rest of the Zoom-generated files. I placed them all in the www root directory, since that's the only place where PHP files will actually work on this server. I'm not sure what else to do, short of altering the PHP code, which is likely to do more harm than good.

    I have had some other issues with Interland's limited PHP configuration and support... can you please give me some insight into this problem so I can upgrade the software and get the search page up and running?

    Any help would be very appreciated.

    [ED UPDATE: For other readers who don't want to read all of this long topic, but have the same problem: The root cause of this problem was an incorrect working directory for PHP. As a result of this, all relative file references were failing. Interland, the web host, corrected the PHP configuration and fixed the problem.]

  • #2
    You are correct that $TemplateFilename is defined as search_template.html. This is done in the settings.php file.

    I assume you have checked the file permissions on the search_template.html file and it allows opening and reading?

    These type of file open operations appear to be supported at Interland, see,
    http://answers.interland.com/display...=19116&n=19&s=

    You could always write a very small PHP script to test the function on your server.

    <?php
    $handle = fopen("search_template.html", "r");
    ?>

    OR

    <?php
    $template = file (search_template.html);
    ?>

    ----
    David

    Comment


    • #3
      David,

      Thank you for your reply. I think the link you offered was prematurely truncated. I'll go and try to find the file permissions help page myself, but it would be helpful if you could repost that link for me.

      I tried your PHP test suggestions, creating files containing only what you suggested, and I got the following results:

      fopen_test.php looks like:
      Code:
      <?php
      $handle = fopen&#40;"search_template.html", "r"&#41;;
      ?>
      ... and yields the following in a browser:
      Warning: fopen(search_template.html): failed to open stream: No such file or directory in d:\Customers\user1177213\www\fopen_test.php on line 2

      file_test.php looks like:
      Code:
      <?php 
      $template = file &#40;search_template.html&#41;; 
      ?>
      ... and yields the following in a browser:
      Notice: Use of undefined constant search_template - assumed 'search_template' in d:\Customers\user1177213\www\file_test.php on line 1

      Notice: Use of undefined constant html - assumed 'html' in d:\Customers\user1177213\www\file_test.php on line 1

      Warning: file(search_templatehtml): failed to open stream: No such file or directory in d:\Customers\user1177213\www\file_test.php on line 1

      Honestly, I'm not a PHP expert, and these notices and warnings don't give me much insight into the problem.

      Comment


      • #4
        David,

        Is this the link you meant?:
        http://answers.interland.com/display...RL=&r=0.193722

        I have accessed the administrative control panel of this account, and there is no "Edit Permissions" option and no "Account Functions drop-down list". But then we're on a different plan than is specified for that documentation. I certainly don't expect any help from Wrensoft resolving issues with Interland, but do these errors indicate a problem that must be addressed on the server? If I could narrow that down, at least, it would help guide my desisions for using Zoom and Interland on future projects. I really like Zoom, but Interland doesn't seem to offer the flexibility and administrative functions necessary to run it, or much else, using PHP. What do you think?

        Comment


        • #5
          I tried using my FTP program to change the permissions of search_template.html, but I got this error: "Error -142: remote chmod failed". There is no function I can find on the account's administrative control panel that would allow me to do this either. Everything is locked down tight.

          Ah but wait... I checked again, and this is baffling. Originally the file had an octal of 000, or no permissions. After reconnecting via FTP, the permissions are showing as 777! I am thoroughly confused.

          Comment


          • #6
            For some crazy reason it seems that the Interland FAQ pages are doing session management, so none of the Interland FAQ links above see to work.

            If you go to this page,
            http://answers.interland.com/
            and search for "fopen" you will find the articles I mentioned about.

            In particular the articles say,

            "The fopen() function is used to open a file or URL in PHP. This function is required for many tasks that our customers perform, such as payment processing, accessing text and images from remote sites, or other tasks that require the HTTP, HTTPS, or FTP protocols."

            "In the PHP versions that are installed on Interland servers, we have enabled allow_url_fopen"

            "PHP scripts do not have to reside in a particular directory and will run anywhere on your account, as long as the file permissions are correct."

            I also made a mistake in the example script above. It should have been,
            <?php
            $template = file ("search_template.html");
            ?>

            You could also try

            <?php
            $template = file ("d:\Customers\user1177213\www\search_template.htm l");
            ?>

            and

            <?php
            $template = file (".\search_template.html");
            ?>


            If this doesn't work I would contact Interland and ask why this simple 1 line script doesn't work.

            You should also ask them how you change file permissions on your server. (the common methods are using FTP or a Shell login in Linux).

            -----
            David

            Comment


            • #7
              In reference to your post about using FTP to change file permissions.

              FTP was a Unix tool originally and the FTP commands often assume you are connecting to a Unix / Linux machine. This means that many 3rd party FTP programs don't handle Windows server file permissions very well (or at all). It is a bit of a lucky dip. There is a discussion of the Windows permission issue here,
              http://www.xav.com/scripts/installer/3008.html

              ----
              David

              Comment


              • #8
                Thanks again David - you're being very helpful here.

                I've tried your latest suggestions. When I use "d:\Customers\user1177213\www\search_template.html " in the file function, I just get a blank page with no errors. All other methods result in:
                Warning: file(.\search_template.html): failed to open stream: No such file or directory in d:\Customers\user1177213\www\file_test3.php on line 1

                This seems profoundly wrong to me, even though I don't have a thorough understanding of the situation. I don't understand why the server would be throwing errors containing a local system path. It doesn't seem very secure or helpful.

                Also, I'm not sure why you mentioned the fopen() function, as it does not appear in the line throwing the original warning in search.php. Was that just for test purposes?

                I'm going to call Interland tomorrow. What specifically should I ask them? If I can't get this problem resolved tomorrow, I'm going to have to resort to a 3rd party site search service, unfortunately. But I'd rather get this working and use Zoom.

                Comment


                • #9
                  A blank page means the script executed without error. (in other words the fopen command worked)

                  Using fopen is almost the same as the file command. They should both work or both fail. So yes, it was just for testing.

                  In theory the following 3 PHPs command should give the same result,
                  $template = file ("search_template.html");
                  $template = file ("d:\Customers\user1177213\www\search_template.htm l");
                  $template = file (".\search_template.html");

                  Becuase the 2nd command worked and the others didn't we can guess that the script is being run in directory A but is trying to open files in directory B. (and we don't know where B is on your server). In other words the current working directory (CWD) is set to a strange location.

                  Could you try this PHP script to get & change the CWD.

                  <?php
                  echo "Display current directory\n";
                  echo getcwd()."\n";
                  chdir('d:\Customers\user1177213\www\');
                  echo "After change directory\n";
                  echo getcwd()."\n";
                  $template = file ("search_template.html");
                  ?>

                  If you still get the failed to open stream message I would ask your hosting company why this small script above doesn't work.

                  ----
                  David

                  Comment


                  • #10
                    I tried your new test script and got more errors, so I tried changing
                    chdir('d:\Customers\user1177213\www\');
                    to
                    chdir('d:/Customers/user1177213/www/');
                    because the backslash was escaping the second single quote. After I made that change, here's what the script returns:

                    Display current directory C:\WINDOWS
                    Warning: chdir(): No such file or directory (errno 2) in d:\Customers\user1177213\www\cwd_test.php on line 8
                    After change directory C:\WINDOWS
                    Warning: file(search_template.html): failed to open stream: No such file or directory in d:\Customers\user1177213\www\cwd_test.php on line 11

                    Comment


                    • #11
                      I also tried using chdir('d:\Customers\user1177213\www'); without the last backslash after www, and I get the same error message.

                      Comment


                      • #12
                        I have been in contact with Interland. The only feedback I've received so far is that they're looking into the problem...

                        Comment


                        • #13
                          The code was missing double slashes in the file path, it should be more like this:

                          chdir("d:\\Customers\\user1177213\\www\\");

                          Although I think you're pretty close to solving the problem, if this still doesn't work, you can consider e-mailing us at zoom [at] wrensoft [dot] com, and giving us temporary FTP access to your server. We can then do some tests in a much quicker fashion and probably get the script up and running.
                          --Ray
                          Wrensoft Web Software
                          Sydney, Australia
                          Zoom Search Engine

                          Comment


                          • #14
                            Here is Interland's email response to the two phone conversations I had with them yesterday:
                            Since this is a 3rd party script and we know php is running you
                            will need to contact the script maker to troubleshoot the script.


                            Unfortunately, I'll now have to use a 3rd party site search service until Interland is willing and able to support PHP like they claim they do.

                            Comment


                            • #15
                              Yes, this is to be expected with big hosting companies. They are very unwilling to spend even 5min looking a a problem (partially becuase their support people often have no technical knowledge and can only give canned answers).

                              This is also why we were trying to get a 3 line script that demonstrated the problem. They could hardly call the 3 line script a 3rd party product.

                              We still think we can make changes to our script to work around whatever wacky situation Interland have set up. You need to e-mail us at zoom [at] wrensoft [dot] com, and giving us temporary FTP access to your server.

                              ----
                              David

                              Comment

                              Working...
                              X