473,406 Members | 2,377 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Html page as input to php procedure

Is there a way to let the html content of an external url be input to
a php procedure?

Example: I want to show the content of http://server.com/test.html,
but with every occurrence of the word 'chess' replaced by 'go'.

Kind regards,

Jan Nordgreen
Jun 27 '08 #1
5 1177
damezumari schreef:
Is there a way to let the html content of an external url be input to
a php procedure?

Example: I want to show the content of http://server.com/test.html,
but with every occurrence of the word 'chess' replaced by 'go'.

Kind regards,

Jan Nordgreen
Hi,

Yes, it is very easy too.

eg with:
http://nl3.php.net/manual/en/functio...t-contents.php

You just suply an url instead of a file.

Replacing the chess with go can be done with str_replace:
http://nl3.php.net/manual/en/function.str-replace.php

Regards,
Erwin Moller
Jun 27 '08 #2
however on many servers you wont be able to access files from other
urls, because this could be abused for a DoS attack
Jun 27 '08 #3
On Jun 4, 2:10 pm, damezumari <jannordgr...@gmail.comwrote:
Is there a way to let the html content of an external url be input to
a php procedure?

Example: I want to show the content ofhttp://server.com/test.html,
but with every occurrence of the word 'chess' replaced by 'go'.

Kind regards,

Jan Nordgreen
function doSomething ($url)
{
if ($handle = fopen ($url, 'r'))
{
// Do something with the page
fclose ($handle);
return ('Page accessed');
}
}

Or even :

function getPage ($url)
{
return (file_get_contents ($url))
}

Do bear in mind reading web pages over the internet can be a lot
slower than reading from the filesystem. If a server takes longer than
30 seconds to respond when you try to access it then your script will
time out (assuming the default timeout value is still configured,
which it usually is).
Jun 27 '08 #4
Martin wrote:
however on many servers you wont be able to access files from other
urls...
In which case, using fsockopen
(<URL:http://php.net/manual/en/function.fsockopen.php>) will be fine.
because this could be abused for a DoS attack
fopen wrappers won't make DoS attacks more or less likely, they can be
easily initiated from various types of requests. For the most part, it
depends on how many machines are making requests.

--
Curtis
Jun 27 '08 #5
On 4 Jun., 22:49, Curtis <zer0d...@verizon.netwrote:
Martin wrote:
however on many servers you wont be able to access files from other
urls...

In which case, using fsockopen
(<URL:http://php.net/manual/en/function.fsockopen.php>) will be fine.
because this could be abused for a DoS attack
fopen wrappers won't make DoS attacks more or less likely, they can be
easily initiated from various types of requests. For the most part, it
depends on how many machines are making requests.

--
Curtis
Of course, but I heard of some hosters having problems with DoS
attacks started from their servers with fopen. And with an
internetserver and its bandwith one first part of an DoS attack is a
lot easier than with your home internet connection, but of course
you're right, one server is not enough for such an attack
Jun 27 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Tom Ticknor | last post by:
I am creating a page dynamically in ASP by gathering data from a database. I wish to email the resulting page to my user group by using the CDOSYS HTMLbody. The problem is I don't know how to...
4
by: frogman042 | last post by:
My daughter is playing around trying to learn JavaScript and she wrote a small program that prints out a message in increasing and decreasing font size and color changes. She is using document...
6
by: Rod Snyder | last post by:
I'm trying to set up an asp.net (vb.net) that will allow a user to insert/update a bio/profile. I wanted to create a SQL Server 2000 table that includes their contact info and bio info. However,...
6
by: Paolo Pignatelli | last post by:
I have an aspx code behind page that goes something like this in the HTML view: <asp:HyperLink id=HyperLink1 runat="server" NavigateUrl='<%#"mailto:" &amp;...
15
by: Nathan | last post by:
I have an aspx page with a data grid, some textboxes, and an update button. This page also has one html input element with type=file (not inside the data grid and runat=server). The update...
6
by: Uday | last post by:
Hi everyone, I have a ASP page that triggers a db-side stored procedure. At the end of the procedure, it spits out a log file, that this ASP page reads and displays for the users. But the...
5
by: Simon Benson | last post by:
Probably a fairly simple problem but one that's been plaguing me for a couple of days... can anyone help? I have a classic ASP page with a number of text boxes which are updatable. For...
3
by: .Net Sports | last post by:
I need to call an stored procedure from an asp script, I don't need to do an Output parameter, only input parameters on 3 vars, but I get a "BOF EOF not true or record has been deleted" error when...
19
Atli
by: Atli | last post by:
Introduction At some point, all web developers will need to collect data from their users. In a dynamic web page, everything revolves around the users input, so knowing how to ask for and collect...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.