473,405 Members | 2,349 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,405 software developers and data experts.

Reading string from remote page

Hi! I want to write a script that will read a .php file on a remote
server and print to the current page a portion of the text contained in
the remote file. I am just wondering what the best method is for
reading from a file in this case - the file is only a few bytes long.
I've seen a tutorial or two that only tangentially addresses my
problem, and even then each one has varied greatly as to which object
they utilize.

Any ideas to get me started?

Many Thanks,

-Joel

Sep 23 '05 #1
4 2265
Jo************@gmail.com wrote:
Hi! I want to write a script that will read a .php file on a
remote server and print to the current page a portion of the
text contained in the remote file.
If "remote server" means a server that is not in the same domain as (or
a sub-domain of) the domain serving the page to the browser then normal
browser security will prevent any client-side mechanism from accessing
the content.
I am just wondering what the best method is for
reading from a file in this case - the file is only a
few bytes long.
Your own server could make the request to the "remote server" and pass
the result of request on, side-stepping the security restrictions.
I've seen a tutorial or two that only tangentially addresses
my problem, and even then each one has varied greatly as to
which object they utilize.

Any ideas to get me started?


Everything depends on what your are attempting to achieve, which is not
the simple matter of reading the output form a PHP script but includes
the context in which you want to do so and an explanation of why you
want to do so.

Richard.
Sep 25 '05 #2
Richard,

Thanks for your reply! I have the goal of serving dynamic content on
pages from a sever (A) that can serve little more than javascript. I
have a separate perl/php capable server (B) that I have written a few
server side scripts for, but I haven't found a way to display the
generated content on B through a page served by A. (The purpose is to
augment the capabilities of a blog account on server A.)

On A, I don't have the ability to make a request to B, parse the
result, and pass the rest on, since A is not server side capable. I
was hoping the process could be as simple as displaying pictures from a
separate server with the tag:
<IMG [...] src="http://www.remotedomain.com/pic.jpg">.

Following that model, I have already tried dynamically genereating a
".js" file and including it with the tag:
<SCRIPT [...] src="http://www.myBserver.com/generated.js">
Unfortunately, my blog account has a server side parser which
eliminates the src attribute of the SCRIPT tag if the src doesn't
belong to one of 12 approved domains (for security reasons.)

If I could use javascript to open a *text* file on a remote server,
read in a string, and print it, I wouldn't be including remote .js
files - I would just be displaying text from a remote site.

If that won't work, is there any way I could do a direct text include,
similar to the way I can use an IMG tag to display remote graphics?

Thanks again!

-Joel

Sep 25 '05 #3
Jo************@gmail.com wrote:
Hi! I want to write a script that will read a .php file on a remote
server and print to the current page a portion of the text contained in
the remote file.


The only thing you have to do is circumvent the cross-domain security
restriction in javascript.

Javascript security restrictions require that the scripting
and the data being acted upon be delivered from the same domain
(www.yourserver.com)

So what you need is a serverside cgi, servlet or similar
socket capable tool to proxy the request. The serverside widget
would take the result of the request and print it out as javascript
or such, and since the cgi , servlet or whatever was located on your
domain , javascript is happy.

--
--.
--=<> Dr. Clue (A.K.A. Ian A. Storms) <>=-- C++,HTML, CSS,Javascript
--=<> Internet Programming since 1994 <>=-- DHTML NSAPI TCP/IP
--=<> http://resume.drclue.net <>=-- AJAX, SOAP, XML, HTTP
--=<> http://www.drclue.net <>=-- SERVLETS,TCP/IP, SQL
--.
Sep 25 '05 #4
Thanks guys, you've been a help! Havea great day!

-Joel

Dr Clue wrote:
Jo************@gmail.com wrote:
Hi! I want to write a script that will read a .php file on a remote
server and print to the current page a portion of the text contained in
the remote file.


The only thing you have to do is circumvent the cross-domain security
restriction in javascript.

Javascript security restrictions require that the scripting
and the data being acted upon be delivered from the same domain
(www.yourserver.com)

So what you need is a serverside cgi, servlet or similar
socket capable tool to proxy the request. The serverside widget
would take the result of the request and print it out as javascript
or such, and since the cgi , servlet or whatever was located on your
domain , javascript is happy.

--
--.
--=<> Dr. Clue (A.K.A. Ian A. Storms) <>=-- C++,HTML, CSS,Javascript
--=<> Internet Programming since 1994 <>=-- DHTML NSAPI TCP/IP
--=<> http://resume.drclue.net <>=-- AJAX, SOAP, XML, HTTP
--=<> http://www.drclue.net <>=-- SERVLETS,TCP/IP, SQL
--.


Sep 26 '05 #5

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

Similar topics

1
by: Red Golpe | last post by:
I've managed to read from a local database using only javascript and the DAO ActiveX object, but I can't make it work with a remote database. When I change the connection string from "C:\..." to...
1
by: Roberto Castro | last post by:
I have some problems with the way I am showing the BLOB fields in the Image web controls. It does work on my localhost though sometimes I need to hit Refresh for the images to load properly....
5
by: WebBuilder451 | last post by:
is there ant place where i can learn the basics of reading an rss feed and enumerating through the values? just want to start at the bottom, no frills. thanks -- thanks (as always) some day...
9
by: Macca | last post by:
Hi, I have a synchronous socket server which my app uses to read data from clients. To test this I have a simulated client that sends 100 byte packets. I have set up the socket server so...
1
by: hecsan07 | last post by:
Hey I am trying to read the Windows Event Logc. In fact, I am able to read the Event Log. My problem is that I am reading and filtering a large log and it takes a very very very very long time...
6
by: Lloyd Dupont | last post by:
I have some XML file like that: === <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">...
29
by: Jerim79 | last post by:
I did try to find the answer to this before posting, so this isn't a knee jerk reaction. What I am trying to accomplish is to have a script that opens a cookie, reads a value, and then use a...
5
by: ycquak | last post by:
Hi, Currently I need to read contents from a dynamic page, which goes something like: http://servername/filename.jsp?arg1=a&arg2=b The content is not static, neither is there a file for me to...
3
by: blunt | last post by:
right the program is nearly complete just a couple of little tweaks and i should have it. The purpose of this program is to write config files for colubrius wireless access points but it's falling...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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.