Jump to content

mike2

Members
  • Posts

    73
  • Joined

  • Last visited

Posts posted by mike2

  1. I would like to modify my php script where my PDF search results would not only display the company name, the country, but also display a limit number link by pages so that not all of the results are shown. 
     
    I also want the first word searched to go to the first occurrence of the word on the PDF document.
     
    What would be the best way to do this? 
     
    Here is my code: 

    <html>
      <head></head>
      <body>
      <?php if (!isset($_POST['q'])) { ?>
     
     
    <img src="/wvb-logo-slogen.png" border="0" />
        <h2>Search</h2>
        <form method="post" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>">
          <input type="text" name="q" size="30" />
        </form>
     
      <?php } else { ?>
     
    <img src="/wvb-logo-slogen.png" border="0" />
        <h2>Search Results</h2>
     
      <?php
        try {
          // create object
         // $swish = new Swish('/usr/local/apache/htdocs/swish/index.swish-e');
            $swish = new Swish('/var/www/html/pdf2/index.swish-e');
     
     
          // get and run query from command-line
          $queryStr = htmlentities($_POST['q']);
          $result = $swish->query($queryStr);
      ?>
     
       Found <?php echo $result->hits; ?> match(es) for '<?php echo $queryStr; ?>'.
     
      <?php
          // iterate over result set
          // print details for each match
          while($r = $result->nextResult()) {
      ?>
     
      <p>
        <?php echo $r->swishreccount; ?>
        <strong>
          <a href="<?php echo '/pdf2', ltrim($r->swishdocpath, '.') ;  ?>">
             <?php echo $r->swishdocpath; ?>
          </a>
        </strong> (score: <?php echo $r->swishrank; ?>) <br/>
    <?php echo $r->swishdocpath; ?>
    
     </p>
     
      <?php
          }
        } catch (Exception $e) {
          die('ERROR: ' . $e->getMessage());
        }
      }
      ?>
     
      </body>
    </html>

     
    Any assistance would be greatly appreciated.

  2. Mike,

    This isn't a php problem really. It's a sysadmin/configuration issue. You don't seem to have a clear idea of how all the pieces fit together. You really need to find someone who is an expert sysadmin, with experience installing and configuring LAMP with PECL modules installed, and retain them for a few hours to figure out your issue. Probably it's something that can be fixed quickly by someone knowledgable in that area.

    I do know how the pieces fit together. I just need assistance. I just need to keep doing my research.

  3. I'm also working at this moment and have a full time job. So, the question is, if you are not able to fix that yourself after 44 replies, why don't you just hire some programmer to do this job for you?  

    I don't even know where to begin looking.

  4. I'm also working at this moment and have a full time job. So, the question is, if you are not able to fix that yourself after 44 replies, why don't you just hire some programmer to do this job for you?  

    I don't know anyone who would be able to help me. I e-mailed somebody to see if they knew somebody via skype and I still haven't heard back from them. Are there websites with actual professionals that would be able to assist me?

     

    Furthermore my alma mater, of all places, doesn't teach any classes that specialize in php coding.

  5. @Mike, the main point to consider here is a file/directory permissions on linux. I was able to configure and run the script less than 20min executing it by apache and lxc users to 3 logical partitions on my CentOS 6.5 system and all results were successfully. Hire someone with knowledge on Unix machines and everything should be ok and stop making a mess. 

    I am not making mess I am trying to get this done for my job. My employer assigned me this project. Did you not read my post. I have no idea what to do to be honest with you and I need help. I am just trying to grab and search files from a different directory.

  6. I installed in my centos machine just for testing purpose this API. So, I was able to index all searchable html files locating in directories out of apache home directory. Here it's my attempt,

     

    swish-e.conf

    IndexDir /home/lxc/public_html /var/www/html/tests
    IndexOnly .html .htm
    FuzzyIndexingMode Stemming_en1
    
    [lxc@localhost pdo]$ /usr/local/bin/swish-e -c swish-e.conf
    Indexing Data Source: "File-System"
    Indexing "/home/lxc/public_html"
    Indexing "/var/www/html/tests"
    Removing very common words...
    no words removed.
    Writing main index...
    Sorting words ...
    Sorting 1 words alphabetically
    Writing header ...
    Writing index entries ...
      Writing word text: Complete
      Writing word hash: Complete
      Writing word data: Complete
    1 unique word indexed.
    4 properties sorted.                                              
    4 files indexed.  5 total bytes.  1 total words.
    Elapsed time: 00:00:00 CPU time: 00:00:00
    Indexing done!
    

    My apache home dir in this system (if it matters at all) is /www/htdocs. I ran the command from the linux shell following the guide you've been posted before - http://devzone.zend.com/1591/indexing-web-content-with-php-and-swish-e/

    I don't know if you are still online right now but I think I may know what the issue is.

     

    The server contains a 1.5 TB drive which is partitioned by lvm. The partitions created on this server are all on the same physical drive but different logical volumes. For example the /home directory resides under the /vg_zeus-lv_home device name. The apache is installed at the device named /vg_zeus-lv_root.

     

    The issue is related to apache and /home/wvbadmin directories residing on seperate logical volumes.

     

    Would the following scenario work to give me the results I need for my pdfsearch2.php script to give the same results as pdfsearch.php script under the /var/www/html directory?

     

    Now keep in mind that I copied everything over from /var/www/html directory to /mnt/www/html directory. This is what is inside /mnt/www/html directory:

     

    total 48

    -rw-r--r--. 1 root root  6678 May  8 14:33 favicon.ico

    -rw-r--r--. 1 root root   113 May  8 14:33 hello.php

    -rw-r--r--. 1 root root    19 May  8 14:33 info.php

    drwxr-xr-x. 2 root root  4096 May  8 14:35 pdf2

    -rw-r--r--. 1 root root  1228 May  8 14:44 pdfsearch2.php

    -rw-r--r--. 1 root root  1204 May  8 14:33 pdfsearch3.php

    -rw-r--r--. 1 root root  1216 May 12 11:35 pdfsearch.php

    -rw-r--r--. 1 root root  1838 May  8 14:33 search.php

    -rw-r--r--. 1 root root 10077 May  8 15:24 wvb-logo-slogen.png

     

    Here is the following scenario:

     

    Scenario 1: Configure apache so that the htdocs root is located under the /home directory. We might create a user "www" to be the owner of htdocs. This would then place both htdocs and pdf directories under the same logical volume.

     

    How would I go about doing the above scenrio? Where in the apache config file is htdocs?

     

    Would that work?

  7.  

    The file path is most likly wrong

     

    Is the html directory your document root? If so the image path should be like

    <img src="/wvb-logo-slogen.png" border="0" />

    To answer your question no it is not root. I think I just found it hold on. But I want to make /mnt/www/html the root for apache. Is it possible to change the configuration file because I have to do that next.

  8.  

    The file path is most likly wrong

     

    Is the html directory your document root? If so the image path should be like

    <img src="/wvb-logo-slogen.png" border="0" />

    What do you mean is the html directory of my document root? Are you asking is it assigned under the root user? yes it is. Or are we talking about logical volumes here?

     

     

    -rw-r--r--. 1 root root 10077 May  8 15:24 wvb-logo-slogen.png

     

    How would I go about changing it to root? I tried putting that code like this and I am still not getting it to appear:

     

    <html>

      <head></head>

      <body>

      <?php if (!isset($_POST['q'])) { ?>

     

     <img src="/wvb-logo-slogen.png" border="0" />

        <h2>Search</h2>

        <form method="post" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>">

          <input type="text" name="q" size="30" />

        </form>

     

     

     

  9. How would I get a logo to appear within my search page? I have this png file it is called the following:

     

    wvb-logo-slogen.png

     

    the png file is located under the /mnt/www/html directory.

     

    Here is the code that I am trying to use to get this logo to be displayed on my web page:

     

      <?php if (!isset($_POST['q'])) { ?>

     <!-- begin logo -->
      <div id="logo"> <a href="home"><img src="/mnt/www/html/wvb-logo-slogen.png" border="0" /></a> </div>
      <!-- end logo -->



        <h2>Search</h2>
        <form method="post" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>">
          <input type="text" name="q" size="30" />
        </form>

      <?php } else { ?>

        <h2>Search Results</h2>

      <?php
        try {
          // create object
         // $swish = new Swish('/usr/local/apache/htdocs/swish/index.swish-e');
            $swish = new Swish('/var/www/html/pdf2/index.swish-e');


          // get and run query from command-line
          $queryStr = htmlentities($_POST['q']);
          $result = $swish->query($queryStr);
      ?>

        Found <?php echo $result->hits; ?> match(es) for '<?php echo $queryStr; ?>'
    .
      <?php
          // iterate over result set
          // print details for each match
          while($r = $result->nextResult()) {
      ?>

      <p>
        <?php echo $r->swishreccount; ?>
        <strong>
          <a href="<?php echo '/pdf2', ltrim($r->swishdocpath, '.') ;  ?>">
             <?php echo $r->swishdocpath; ?>
          </a>
        </strong> (score: <?php echo $r->swishrank; ?>) <br/>
    <?php echo $r->swishdocpath; ?>

      </p>

      <?php
          }
        } catch (Exception $e) {
          die('ERROR: ' . $e->getMessage());
        }
      }
      ?>

      </body>
    </html>
     

     

    My questions are the following: Why isn't my logo displaying? Is it the right format? Are there special html or php items that I need to put in order for my logo to be displayed right above the word "Search"?

     

    Any assistance would truly be appreciated because I have no experience using php.

  10. I installed in my centos machine just for testing purpose this API. So, I was able to index all searchable html files locating in directories out of apache home directory. Here it's my attempt,

     

    swish-e.conf

    IndexDir /home/lxc/public_html /var/www/html/tests
    IndexOnly .html .htm
    FuzzyIndexingMode Stemming_en1
    
    [lxc@localhost pdo]$ /usr/local/bin/swish-e -c swish-e.conf
    Indexing Data Source: "File-System"
    Indexing "/home/lxc/public_html"
    Indexing "/var/www/html/tests"
    Removing very common words...
    no words removed.
    Writing main index...
    Sorting words ...
    Sorting 1 words alphabetically
    Writing header ...
    Writing index entries ...
      Writing word text: Complete
      Writing word hash: Complete
      Writing word data: Complete
    1 unique word indexed.
    4 properties sorted.                                              
    4 files indexed.  5 total bytes.  1 total words.
    Elapsed time: 00:00:00 CPU time: 00:00:00
    Indexing done!
    

    My apache home dir in this system (if it matters at all) is /www/htdocs. I ran the command from the linux shell following the guide you've been posted before - http://devzone.zend.com/1591/indexing-web-content-with-php-and-swish-e/

    Forgive the lateness of my reply. But things have changed I will let you know what has happened.

  11.  

    Same error? Can I see the output of -

    ls -la /home/wvbadmin/pdf3/index.swish-e
    

    Here is output:

     

    [root@zeus conf]# ls -la /home/wvbadmin/pdf3/index.swish-e

    -rw-r--r--. 1 root root 4816366 May  5 23:32 /home/wvbadmin/pdf3/index.swish-e

     

  12. Do you understand how symlinks work?

     

    It doesn't matter what the symlink permissions are, if the underlying directory permissions won't allow access. Also if apache doesn't allow access to the files or directory, you're going to get these permissions errors.

     

    It's an apache config problem.

     

    Also fwiw, with mod_apache... yes you have to restart apache anytime you change an apache configuration item or a php configuration item.

     

    Then, do

     su -c 'chmod 755 /home/wvbadmin/pdf3/index.swish-e'
    

    and everything should work as expected.

    I did just that and I am still getting permission error.

    One more thing that I want to mention is that I have never even used php code before. This is my first time and I just to be able to get this phase of my project done before I move on the next phase.

     

    If I were to change the location of the DocumentRoot from /var/www/html to /home/wvbadmin would that be of assistance or does the Apache config file need to be pointed at /var/www/html?

  13. Why did you call "/home/wvbadmin/pdf3/index.swish-e" when we're talking about "/home/wvbadmin/pdf2/index.swish-e". If you want to call "/home/wvbadmin/pdf3/index.swish-e" then you are providing us wrong script in your first reply! Can you post the script of pdfsearch2.php.

    Here is also what is inside my /var/www/html directory if it's any help.

     

    [root@zeus html]# ls -l

    total 60

    -rw-r--r--. 1 root root  6678 Apr 30 13:25 favicon.ico

    -rw-r--r--. 1 root root 17256 May  5 16:02 h1

    -rw-r--r--. 1 root root   113 Apr 29 16:45 hello.php

    -rw-r--r--. 1 root root    19 Apr 24 23:53 info.php

    drwxr-xr-x. 2 root root 12288 May  5 21:51 pdf2

    lrwxrwxrwx. 1 root root    20 May  5 15:46 pdf3 -> /home/wvbadmin/pdf3/

    -rw-r--r--. 1 root root  1214 May  6 11:18 pdfsearch2.php

    -rw-r--r--. 1 root root  1216 May  6 09:56 pdfsearch.php

    -rw-r--r--. 1 root root  1838 Apr 30 13:10 search.php

     

  14. Do you understand how symlinks work?

     

    It doesn't matter what the symlink permissions are, if the underlying directory permissions won't allow access. Also if apache doesn't allow access to the files or directory, you're going to get these permissions errors.

     

    It's an apache config problem.

     

    Also fwiw, with mod_apache... yes you have to restart apache anytime you change an apache configuration item or a php configuration item.

    To answer your question about soft links and how they work. Don't they link up to a another directory? I also restarted Apache and I am still getting permission denied. I understand that is either an apache config problem or something with my code. It shouldn't be my code. My code should be doing what it is supposed to be doing.

  15. Why did you call "/home/wvbadmin/pdf3/index.swish-e" when we're talking about "/home/wvbadmin/pdf2/index.swish-e". If you want to call "/home/wvbadmin/pdf3/index.swish-e" then you are providing us wrong script in your first reply! Can you post the script of pdfsearch2.php.

    My apoligies here is the updated pdfsearch2.php script:

     

    <html>

      <head></head>

      <body>

      <?php if (!isset($_POST['q'])) { ?>

     

        <h2>Search</h2>

        <form method="post" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>">

          <input type="text" name="q" size="30" />

        </form>

     

      <?php } else { ?>

     

        <h2>Search Results</h2>

     

      <?php

        try {

          // create object

         // $swish = new Swish('/usr/local/apache/htdocs/swish/index.swish-e');

            $swish = new Swish('/home/wvbadmin/pdf3/index.swish-e');

     

     

          // get and run query from command-line

          $queryStr = htmlentities($_POST['q']);

          $result = $swish->query($queryStr);

      ?>

     

        Found <?php echo $result->hits; ?> match(es) for '<?php echo $queryStr; ?>'

    .

      <?php

          // iterate over result set

          // print details for each match

          while($r = $result->nextResult()) {

      ?>

     

      <p>

        <?php echo $r->swishreccount; ?>

        <strong>

          <a href="<?php echo '/pdf3', ltrim($r->swishdocpath, '.'); ?>">

             <?php echo $r->swishdocpath; ?>

          </a>

        </strong> (score: <?php echo $r->swishrank; ?>) <br/>

    <?php echo $r->swishdocpath; ?>

     

      </p>

     

      <?php

          }

        } catch (Exception $e) {

          die('ERROR: ' . $e->getMessage());

        }

      }

      ?>

     

      </body>

    </html>

     

  16. I will give those a try and let you know what the outcome is.

    I did them both and I am still getting:

     

    Search Results

    ERROR: Could not open the index file '/home/wvbadmin/pdf3/index.swish-e': Permission denied

     

    when I go to http://64.244.240.221:8080/pdfsearch2.php

     

    and enter in the word bank in the search engine and nothing shows up. Just the above message. 

     

    I even tried going into the apache config file and changed UserDir to /pdf3 and it is still not working. I am starting to lose my patience. I just want to search from the /home/wvbadmin/pdf3 directory.

     

    I should be able to run this.

  17. This your script - $swish = new Swish('/home/wvbadmin/pdf2/index.swish-e');

     

    Re-read my 2 and 18 replies!

    I redid what you told me to do in your 2nd reply. I am still getting the same error.

     

    Permissions denied. Should I restart apache?

     

    I did the following:

     

    su -c 'chmod 755 /home/wvbadmin/ -R'

     

    Should I now do what you told me to do reply number 18?

  18. Do you have

     

    Options +FollowSymLinks
    
    Enabled in your apache config or htaccess in some appropriate place? Symlinks won't work in apache with that at very least. If you're running mod_php, php has to play by the rules of apache.

     

    Here is what I have in my Apache configuration file.

     

    # The Options directive is both complicated and important.  Please see

    # http://httpd.apache.org/docs/2.2/mod/core.html#options

    # for more information.

    #

        Options Indexes FollowSymLinks

     

    Should the above be changed to Options +FollowSymLinks? Is that what you are asking/do?

     

    Also

     

    Here is what I have in the Apache configuration file as far as htaccess

     

    #

    # AccessFileName: The name of the file to look for in each directory

    # for additional configuration directives.  See also the AllowOverride

    # directive.

    #

    AccessFileName .htaccess

     

     

    Plus

     

        #

        # UserDir is disabled by default since it can confirm the presence

        # of a username on the system (depending on home directory

        # permissions).

        #

        UserDir disabled

     

    Should the above be changed to UserDir pdf3? Since that is where we are searching from?

     

    What do you mean by mod_php?

     

    This is the version I am running.

     

    [root@zeus conf]# rpm -q php

    php-5.3.3-27.el6_5.x86_64

     

  19. Okay, Let me try to answer that question as best I can:

     

    Under the /home/wvbadmin/pdf2 directory and

     

    /home/wvbadmin/pdf3 directory I have the index.swish-e file but under /home/wvbadmin/pdf3 directory index.swish-e is lit up as green indicating it is an executable. I don't know why.

     

     

    Under the /var/www/html directory I have this:

     

    -rw-r--r--. 1 root root  6678 Apr 30 13:25 favicon.ico

    -rw-r--r--. 1 root root 17256 May  5 16:02 h1

    -rw-r--r--. 1 root root   113 Apr 29 16:45 hello.php

    -rw-r--r--. 1 root root    19 Apr 24 23:53 info.php

    drwxr-xr-x. 2 root root 12288 May  5 21:51 pdf2

    lrwxrwxrwx. 1 root root    20 May  5 15:46 pdf3 -> /home/wvbadmin/pdf3/

    -rw-r--r--. 1 root root  1214 May  6 11:18 pdfsearch2.php

    -rw-r--r--. 1 root root  1216 May  6 09:56 pdfsearch.php

    -rw-r--r--. 1 root root  1838 Apr 30 13:10 search.php

     

    Under the /var/www/html/pdf2 directory and

     

    /var/www/html/pdf3 directory I have the index.swish-e file but under /var/www/html/pdf3 directory index.swish-e is lit up as green indicating it is an executable. Again I don't know why.

     

    Also take into account that pdf3 is being soft linked to the /home/wvbadmin/pdf3 directory which is where I want to get and search my files from if you remember my original question.

    Are there any changes I can make to the Apache configuration file that would be get this problem resolved? I would like to resolve this issue as soon as possible.

  20. Okay, Let me try to answer that question as best I can:

     

    Under the /home/wvbadmin/pdf2 directory and

     

    /home/wvbadmin/pdf3 directory I have the index.swish-e file but under /home/wvbadmin/pdf3 directory index.swish-e is lit up as green indicating it is an executable. I don't know why.

     

     

    Under the /var/www/html directory I have this:

     

    -rw-r--r--. 1 root root  6678 Apr 30 13:25 favicon.ico

    -rw-r--r--. 1 root root 17256 May  5 16:02 h1

    -rw-r--r--. 1 root root   113 Apr 29 16:45 hello.php

    -rw-r--r--. 1 root root    19 Apr 24 23:53 info.php

    drwxr-xr-x. 2 root root 12288 May  5 21:51 pdf2

    lrwxrwxrwx. 1 root root    20 May  5 15:46 pdf3 -> /home/wvbadmin/pdf3/

    -rw-r--r--. 1 root root  1214 May  6 11:18 pdfsearch2.php

    -rw-r--r--. 1 root root  1216 May  6 09:56 pdfsearch.php

    -rw-r--r--. 1 root root  1838 Apr 30 13:10 search.php

     

    Under the /var/www/html/pdf2 directory and

     

    /var/www/html/pdf3 directory I have the index.swish-e file but under /var/www/html/pdf3 directory index.swish-e is lit up as green indicating it is an executable. Again I don't know why.

     

    Also take into account that pdf3 is being soft linked to the /home/wvbadmin/pdf3 directory which is where I want to get and search my files from if you remember my original question.

    As you can see pdfsearch2.php is what I am trying to run but is giving me a permission error.

     

    phpsearch.php works correctly and does its function but what I am trying to do is get pdfsearch2.php to work the same way as pdfsearch.php but search files that are in the /home/wvbadmin/pdf3 directory.

  21. Well actually. Let me tell you why. I was going to do pdf2 but I wanted to test if a soft link would work that is why.

     

    index.swish-e is located under /var/www/html/pdf3 and /var/www/html/pdf2.

     

    Mike, please, step by step. Can you explain this -

     

    How many files with the same name you have in your file structure? 

    Okay, Let me try to answer that question as best I can:

     

    Under the /home/wvbadmin/pdf2 directory and

     

    /home/wvbadmin/pdf3 directory I have the index.swish-e file but under /home/wvbadmin/pdf3 directory index.swish-e is lit up as green indicating it is an executable. I don't know why.

     

     

    Under the /var/www/html directory I have this:

     

    -rw-r--r--. 1 root root  6678 Apr 30 13:25 favicon.ico

    -rw-r--r--. 1 root root 17256 May  5 16:02 h1

    -rw-r--r--. 1 root root   113 Apr 29 16:45 hello.php

    -rw-r--r--. 1 root root    19 Apr 24 23:53 info.php

    drwxr-xr-x. 2 root root 12288 May  5 21:51 pdf2

    lrwxrwxrwx. 1 root root    20 May  5 15:46 pdf3 -> /home/wvbadmin/pdf3/

    -rw-r--r--. 1 root root  1214 May  6 11:18 pdfsearch2.php

    -rw-r--r--. 1 root root  1216 May  6 09:56 pdfsearch.php

    -rw-r--r--. 1 root root  1838 Apr 30 13:10 search.php

     

    Under the /var/www/html/pdf2 directory and

     

    /var/www/html/pdf3 directory I have the index.swish-e file but under /var/www/html/pdf3 directory index.swish-e is lit up as green indicating it is an executable. Again I don't know why.

     

    Also take into account that pdf3 is being soft linked to the /home/wvbadmin/pdf3 directory which is where I want to get and search my files from if you remember my original question.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.