SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2003
    Location
    l'Europe
    Posts
    94
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    fopen () en fread()

    Hi,
    I'm trying to make a workaround for the following.
    We are consulting a large daily paper on the intranet in pdf format.

    Only a few items are relevant to us.
    The same site offers the possibility to search for some keywords (date, title, ...) and the result list
    gives all found items with
    - the first two or three sentences,
    - a button that opens the daily paper on the page where that item is printed (pdf format)
    - a button that opens a page with only the text of that item in HTML format

    Because only a few items are relevant, I've made a database (MySQL) where I put the following data in a form:
    - date paper
    - number item in that paper
    - title to which the item belongs (to be able to group the items)
    /// with these three fields, I can recreate the URL with a button to open the item in HTML-format, copy the text and paste it in a text area.///
    - the contents of the article

    I can create a daily report and email it to all subscribers of the departement.

    My question:
    I want to simplify the input of the fourth field: the contents.
    (Access to the database of the daily paper isn't an option.)
    I've tried it with 'fopen("URL", "r")' and 'fread()' and assign its value to $contents, but this function works for me only with IP-based hosts (e.g. 10.255.26.987)
    The site which publishes the paper is a site on the internet which we are allowed to view from our intranet.
    I've looked up theire IP-address, but that IP-address isn't allowed to be viewed (strangly).

    Can anyone points me to a possible workaround?
    Can I change a setting in PHP to be able to use name based hosts?

    Thank you very much!
    Ann Dupont

  2. #2
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    fopen() shouldn't require an IP address but here's another way of doing it
    PHP Code:
    $contents implode(''file('http://www.some-site.com/')); 
    implode(), file()

  3. #3
    SitePoint Enthusiast
    Join Date
    Feb 2003
    Location
    l'Europe
    Posts
    94
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by DJ P@CkMaN
    fopen() shouldn't require an IP address but here's another way of doing it
    PHP Code:
    $contents implode(''file('http://www.some-site.com/')); 
    implode(), file()
    Thank you for your reply, DJ P@CkMaN!

    I've tried your suggestion at home (not intranet) where I have a copy of the site from work on my localhost.

    It works for all sites beginning with
    - http://localhost/...
    - http://www.myprovider.com/

    But all other sites gives following error message:
    - Warning: php_hostconnect: connect failed in c:\program files\apache group\apache\htdocs\test.php on line 3
    - Warning
    : file(http://www.sitepoint.com/ ) - Bad file descriptor in c:\program files\apache group\apache\htdocs\test.php on line
    3
    - Warning
    : Bad arguments to implode() in c:\program files\apache group\apache\htdocs\test.php on line 3


    For my first post, I believe it is a simular situation; all sites with an IP-address I've tried were sites on the intranet. When I tried a name based host (http://www.somesite.com) it was a site we can access from the intranet, but it is a site where access has been granted to...

    Do I have to make adjustments to my settings of php (4.1.0) or apache (1.3.26)?

    Thank you for any suggestions!

    Ann
    Last edited by ann_dupont; Mar 18, 2003 at 12:35.

  4. #4
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    You should update to the latest version of PHP which is 4.3.1

  5. #5
    SitePoint Enthusiast
    Join Date
    Feb 2003
    Location
    l'Europe
    Posts
    94
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by DJ P@CkMaN
    You should update to the latest version of PHP which is 4.3.1
    Thank you for your time,

    I've upgraded my PHP version to 4.3.1, but I'm getting the same error message:
    Warning: file() [function.file]: php_hostconnect: connect failed in c:\program files\apache group\apache\htdocs\test.php on line 2

    Warning: file(http://www.sitepoint.com/) [function.file]: failed to create stream: Bad file descriptor in c:\program files\apache group\apache\htdocs\test.php on line 2

    Warning: implode() [function.implode]: Bad arguments. in c:\program files\apache group\apache\htdocs\test.php on line 2

    I've been searching Google and others for this subject and I came across:
    fopen() will only be able to open files if your server has direct access to the internet. If it needs to access other HTTP servers via a proxy server fopen() will not work

    I do all my development on a machine which is on a LAN and which access the internet via a peoxy server hence my problem!
    (from: http://forums.devshed.com/showthread.php?threadid=29877)

    I believe I'm in te same situation. The PHP manual isn't very clear about it...
    Ann


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
  •