Problem w/ Latest release of WAMPP

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Problem w/ Latest release of WAMPP

Postby MAGnUm » 02. July 2003 23:07

ok i am trying to use fopen() to open a file on a friends server and save it on mine. for some reason fopen will not open remote files, but works on local files if anyone has any ideas please let me know.
MAGnUm
 

Postby boppy » 03. July 2003 09:57

it works... Try this on your machine:

<?
$handle = fopen ("http://boppy.dyn.ee/MAGnUm.txt", "r");
echo fgets($handle,25);
?>

should be: "Hi MAGnUm - It works :)"

- It runs on a Win2k-Server i have access to and on some Linux-Machines... So it should also run on yours *g*

...so long
boppy
User avatar
boppy
AF Moderator
 
Posts: 501
Joined: 27. December 2002 02:15
Location: W-E-City

?

Postby MAGnUm » 06. July 2003 04:41

yes your script works, but try this one. and yeh it works i tried it on an older version of WAMPP 1.3.*

Code: Select all
<?php
###############################################################
# Script Title: 4CM_Grabber
#         File: 4CM_Grabber.php
#  Description: This script will Grab information from a given web site
#       Author: John B. Abela
#        Email: support@4cm.com
#          Web: http://www.4cm.com/
#      Version: 2.0.5
#
#  Copyright © 1996-2000 www.4cm.com.  All Rights Reserved.
#
#
#  www.4cm.com (4CM) offers no warranties on this script.
#  The downloader of the script is solely responsible for any
#  problems caused by the installation of the script or use
#  of the script, including possible legal action for the grabbing
#  of the data, as a result of this script!
#
#  ALL COPYRIGHT NOTICES REGARDING: www.4cm.com
#  MUST REMAIN INTACT IN THE SCRIPT AND IN THE HTML OF THE SCRIPT! 
#
#  For more info on this script, see:
#  http://www.4cm.com/
#
#  (Please be kind and sign our guestbook at:
#     http://www.4cm.com/guestbook/  and say your using
#       this script!!)
###############################################################

########################
## Mandatory Setting  ##
########################
$GrabURL = "http://www.defenselink.mil/index.html";  //-  Complete URL of the page your grabbing from!
$GrabStart = '<!-- DDI_NEWS -->';  //- HTML Code To Start Grab. Must Be A Unique Bit Of Code!
$GrabEnd = '<!-- /DDI_NEWS -->';  //- HTML Code To End Grab. Must Be A Unique Bit Of Code!

#############################
## Do Not Edit Below Here  ##
## Do Not Edit Below Here  ##
#############################
echo "<font face=Verdana size=1><B>DefenseLINK News</B><BR>";
$OpenFile = fopen("$GrabURL", "r"); //- DO NOT CHANGE
$RetrieveFile = fread($OpenFile, 200000);  //- Reduce This To Save Memory
$GrabData = eregi("$GrabStart(.*)$GrabEnd", $RetrieveFile, $DataPrint);
$DataPrint[1] = str_replace('<A HREF="/', '<A HREF="http://www.defenselink.mil/', $DataPrint[1]);
$DataPrint[1] = str_replace("<li>", "", $DataPrint[1]);
$DataPrint[1] = str_replace("</LI>", "<BR>", $DataPrint[1]);
fclose($OpenFile); //- DO NOT CHANGE
echo $DataPrint[1]; //- DO NOT CHANGE
echo "&nbsp;&nbsp;<font face=Verdana size=1>Script Provided By: <a href=\"http://www.4cm.com/\" target=\"_blank\">www.4cm.com</a></font>"; //- DO NOT REMOVE
####################
## End of Script  ##
####################

?>

:mrgreen:
MAGnUm
 

Postby Oswald » 06. July 2003 10:51

Dear Magnum!

It seems to be a problem with newer version of PHP. I tried your code with 4.0.6 and it worked. I tried it with 4.3.2 and it doesn't work. In both cases under Linux.

I modified your script to make it run also with newer versions of PHP:

Code: Select all
...
#############################
## Do Not Edit Below Here  ##
## Do Not Edit Below Here  ##
#############################
echo "<font face=Verdana size=1><B>DefenseLINK News</B><BR>";

#$OpenFile = fopen("$GrabURL", "rb"); //- DO NOT CHANGE
#$RetrieveFile = fread($OpenFile, 200000);  //- Reduce This To Save Memory
$RetrieveFile = file_get_contents("$GrabURL");  //- Reduce This To Save Memory

$GrabData = eregi("$GrabStart(.*)$GrabEnd", $RetrieveFile, $DataPrint);
$DataPrint[1] = str_replace('<A HREF="/', '<A HREF="http://www.defenselink.mil/', $DataPrint[1]);
$DataPrint[1] = str_replace("<li>", "", $DataPrint[1]);
$DataPrint[1] = str_replace("</LI>", "<BR>", $DataPrint[1]);

#fclose($OpenFile); //- DO NOT CHANGE

echo $DataPrint[1]; //- DO NOT CHANGE
echo "&nbsp;&nbsp;<font face=Verdana size=1>Script Provided By: <a href=\"http://www.4cm.com/\" target=\"_blank\">www.4cm.com</a></font>"; //- DO NOT REMOVE
####################
## End of Script  ##
####################
...


I removed the fopen() and fclose() line and replaced the fread() command by the file_get_contents() command.

Greetings,
Oswald
User avatar
Oswald
Apache Friends
 
Posts: 2718
Joined: 26. December 2002 19:51
Location: Berlin, Germany
Operating System: Linux

thanks

Postby MAGnUm » 06. July 2003 14:01

I was just wondering why php was doing it, doesnt make much sense. thanks.
MAGnUm
 

Postby Oswald » 06. July 2003 14:39

Hi Magnum!

On network streams fread() stops reading after receiving the first packet. It doesn't matter what size is given as second parameter to fread(). If you want to read more data you've to repeat the fread() call. This behaviour seems to only concern newer version of PHP.

Find a more exact (and with a better english) explanation here: http://www.php.net/manual/en/function.fread.php

Greetings,
Oswald
User avatar
Oswald
Apache Friends
 
Posts: 2718
Joined: 26. December 2002 19:51
Location: Berlin, Germany
Operating System: Linux

Postby WestPointer » 17. February 2006 00:53

I'm having this problem with a fresh install of xampp on WinXP Pro. I tried changing the fopen/fread to file_get_contents but get the message
Warning: file_get_contents(http://rss.cnn.com/rss/cnn_us.rss): failed to open stream: HTTP request failed! in \abouttoday.php on line 1262


Is fopen simply broke with xampp?
WestPointer
 
Posts: 1
Joined: 17. February 2006 00:13


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 126 guests