473,806 Members | 2,967 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2300
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.remotedomai n.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.c om/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
2225
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 "http://..." it doesn't work any more. Any suggestion? Red Golpe ______________________________________________ "What does not kill you... makes you stronger"
1
3304
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. However, when I try to access the same page from another machine or when I test the code on a remote server the images just wouldn't show. The page I am talking about has 3 Image web controls. In the CodeBehind I am loading these controls by using an...
5
1333
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 i''m gona pay this forum back for all the help i''m getting kes
9
3609
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 that its buffer is bigger than this. I did this expecting the data to be read in one pass.
1
16757
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 to complete. I am using the ordinary technique for reading/writing from and to the Event Log. I am wondering if there is a better way to speed things up. Below is an excerpt of the code I am using (notice that I am filtering by Category and...
6
1514
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"> <plist version="1.0"> <dict> <key>affiliateId</key> <string>AFL9124395098</string>
29
3015
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 switch/case to take action based on that value in the cookie. I want to set the cookie manually, so I don't need setcookie(). I see that in PHP it stores the cookie in memory. Is there a way to have PHP just read a cookie from the desktop machine?...
5
2672
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 read from. Thus, I would like to know how could I accomplish this task in php. I saw from forums, there is a similar implementation of the RSS reader which reads it in the following way:
3
5095
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 over in this section of code: while(line!=32){ fgets(c, 1, sourceFile); strncpy (compare,c,1); if (compare=='\n'){ line++; } }
0
9719
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10372
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10110
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7650
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6877
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5546
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5682
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4329
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.