473,509 Members | 2,671 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Testing Servers Response with PHP

7 New Member
Hi all. Not sure if this is the right place to ask this but I'm not sure which language would be best to find a good solution.

Let me give you a quick overview before getting to the problem. Currently we have 8 ad servers. We are trying to make a site which will connect to each server and return back an ad banner, so loading the page will connect with all 8 servers and return 1 ad banner from each server.

Initially, javascript was used to connect to the servers using the server IP and location of the banner. But I was told to try to change it into iframes which I did. I'm no expert, but I was told a method which did work. This method had me create 8 new notepad txt files and each txt file contained one line of javascript code pertaining to a certain server. So 8 servers, 8 javascript lines in 8 txt files. For the sake of clarity, we'll call them adserver1.html, adserver2.html all the way to adserver8.html.

Then we have a site called servertest.html. The purpose of servertest.html is to test how quickly each of the 8 servers respond and the appropriate delay should be reflected on the site. So if one server responds fast, the ad banner pops up immediately and if another ad server responds 2 seconds slower, the ad will op up after 2 seconds of delay. (That was just an example, in reality, the delay is however long it takes for the server to respond).

The 8 iframe code lines are in this site (servertest.html). So for example, we have the iframe code of:
Expand|Select|Wrap|Line Numbers
  1. <iframe src="adserver1.html" align="center" height = "140px" width = "200px" scrolling="auto"></iframe>
[Please use CODE tags when posting source code. Thanks! --pbmods]

The adserver1.html file has the following line (the X's is the server IP address):

Expand|Select|Wrap|Line Numbers
  1. <script language="javascript" type="text/javascript" src="http://XXX.XXX.XXX.XXX/bannercode/5251/04FF9A29A4ED390C0A260146E8E2080E.php">
  2. </script>
Now the problem we have is that it's messy. We want to try to find a way to compress the 8 adserver#.html txt files into either just one adserver.html file OR somehow have the iframes work in the servertest.html which doesn't require separate adserver#.html files.

OR, if it's easier, perhaps get rid of iframes completely and use some other method either using PHP or other languages.

Keep in mind the main goal of this is to test how quickly each server responds and displays their ad banner.

Is there a way, using PHP, to achieve this in a single document rather than having a total of 9 separate documents?
Jun 20 '07 #1
2 1462
ronnil
134 Recognized Expert New Member
there certainly is.

the simplest thing would be to put the server urls in a database and load them from there

BUT since it's ONLY 8 lines this might be overkill

what i would do:

make a txt file called banners.txt or something

put 1 url per line

check out http://www.php.net/manual/en/ref.filesystem.php (hint: file() is the function you're looking for)

now when you got the contents of the file loaded into an array, you simply iterate through it.

you can keep the javascript almost intact if you like (for instance if you want to trigger the loading of the banners manually), but you can also write the entire code dynamically based on the contents of the file.

now, if you decide to add a ninth banner, all you need to do is add a single line in your banner.txt

-------------------
you can also keep the urls in another php-file in an array, include that php file and again iterate through that array

the possibilitys are endless, and you're not even gonna have to use php, you can use almost any kind of server-side language --- so I'm just gonna stop now ;)
Jun 20 '07 #2
gwong123
7 New Member
I will have to try that soon. But will using an array and calling the data from that txt in the main document really work? Because before, the following javascript (the same line that is now in separate txt files) used to be located in the main document. It worked, but the page didn't load until each of the servers had responded/timed out. What we needed was for the servers to show their banners as soon as they were able to respond.

<script language="javascript" type="text/javascript" src="http://XXX.XXX.XXX.XXX/bannercode/5251/04FF9A29A4ED390C0A260146E8E2080E.php">
</script>

The above worked, but was slow and didn't achieve what we needed. When placed into a browser window, it returned:

Expand|Select|Wrap|Line Numbers
  1. var js='http://XXX.XXX.XXX.XXX/bannercode/5251/04FF9A29A4ED390C0A260146E8E2080E.php';var _a=(typeof(js)=='undefined');var _c=(typeof(_c)=='undefined')?0:(_c+1);if(_a){var _b=0;var windowOnload=window.onload;window.onload=function(){if(windowOnload){windowOnload();}try{window.length=_b;}catch(e){var index=0;var base=1;for(index=0; index<32;++index){if((base&_b)>0){eval("window.a"+index+"=0;");}base*=2;}window.status=_b;}}}var transformer={_a:'',_b:'',_c:'',_d:'',_e:'',_f:'',a:function(a){if(!a){var b=this._d.background_color;if(''!=b){b='background-color:'+this._d.background_color;}document.write('<td style=\''+this._d.border_style+';'+b+'\'><div style=\'width:'+this._d.cellWidth+'px;height:'+this._d.cellHeight+'px\'>&nbsp;</div></td>');}else{document.write('<td style=\''+this._d.border_style+';'+'\'></td>');}},b:function(a){var b=a.bannertext.title.replace(/\\/g,'\\\\').replace(/\'/g,'\\\'');b=this.q(b);a.bannertext.title=this.q(a.bannertext.title);a.bannertext.description=this.q(a.bannertext.description);var c='content_'+_c+'_'+a.id+'_'+this._a.id;var d=this._a.click_target;var e=this._f+'/clk1/'+a.link;document.write('<td'+' style=\''+this._d.border_style+';vertical-align:top;cursor:pointer;background-color:'+this._d.background_color+'\' onmouseover=\"javascript:window.status=\''+b+'\';return true;\" onmouseout=\"javascript:window.status=\'\'\">');var f='<a target=\''+d+'\' href=\"'+e+'\" style=\"text-decoration:none\"><div id=\''+c+'\' style=\'width:'+this._d.cellWidth+'px;height:'+this._d.cellHeight+'px;overflow:hidden;vertical-align:top;cursor:pointer\'>';var g=this.r(' ','',a.bannertext.title);if(g.length>0){f+='<div style=\''+this._d.title_style+'\'>'+a.bannertext.title+'</div>';}f+='<div style=\''+this._d.description_style+'\'>'+a.bannertext.description+'</div>';f+='</div></a>';document.write(f);document.write('</td>');return c;},c:function(a){var b=this._f+'/clk1/'+a.link;var c=this._a.click_target;document.write('<td'+' style=\'vertical-align:top;cursor:pointer\' onmouseover=\"javascript:window.status=\'\';return true;\">');var d='<a target=\''+c+'\' href=\"'+b+'\" style=\"text-decoration:none\"><img'+' style=\'width:'+this._a.style1.width+'px;height:'+this._a.style1.height+'px;border:0px solid #FFFFFF;overflow:hidden;vertical-align:top;cursor:pointer\' src=\''+this._f+'/img1/'+a.img+'\'/></a>';document.write(d);document.write('</td>');},d:function(a){for(var _i in a){if(typeof(a[_i])!='function'){this.f(document.getElementById(a[_i]));}}},e:function(a,b){var c=document.getElementById(b).firstChild;var d=c.innerHTML;c.innerHTML='jJ';var 
  2.  
and a whole bunch more that I cut out

Then when I changed that to <iframe src=http://XXX.XXX.XXX.XXX/bannercode/5251/04FF9A29A4ED390C0A260146E8E2080E.php"> it only returned the server information instead of the banner ad itself. It was only when I separated out the javascript lines into 8 separate documents and used the <iframe> tags to embed the external documents (adserver1.html etc) into the main site did it work.

It seems because the .php file contained javascript it can't be used with iframes on the same site I think?
Expand|Select|Wrap|Line Numbers
  1. <iframe src="adserver1.html" align="center" height = "140px" width = "200px" scrolling="auto"></iframe>
So I used the above iframe line to embed the javascript and was able to achieve what we needed. If I made it into an array, wouldn't that be the same as putting the javascript back into the main document and losing the iframes? Because I would have a txt file with 8 lines of javascript code for each server, put all that into an array, then iterate through it in the main document thus bringing about the old effect again.

I don't mind losing the iframes, as long as the desired effect is maintained but I'm worried that the array will put the javascript back in and return me back to the way things were when what I really need is to reduce the number of extra server files from 8 to 1 or none at all.

I apologize if my concern is rather noobish, but I'm just trying to make sure that things will return the right results.
Jun 20 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
2817
by: Paul Winkler | last post by:
This is driving me up the wall... any help would be MUCH appreciated. I have a module that I've whittled down into a 65-line script in an attempt to isolate the cause of the problem. (Real...
0
1447
by: BS | last post by:
Hi All, This may be an old question, but there's little useful references online that I've been able to find. I want the following code to display bit by bit, not send all at once to the...
0
1590
by: gg.2.starfire | last post by:
WebCheck (http://www.raycosoft.com/rayco/products/webcheck) is a program for testing and analyzing static or dynamic web pages. WebCheck fetches web pages, applies detailed tests to each web page...
0
1511
by: Chuck | last post by:
Sorry for the advertisement but I think this is something that people could actually use. I am creating a new product called Simple Load Testing and I thought I would see if anyone would be...
0
1482
by: Brian Russell | last post by:
We have three servers (beyond my development box) in our organization. The first is a testing server that has IIS and SQL Server on it. The second is another testing server that also has IIS and...
2
4314
by: balakrishnan.dinesh | last post by:
Hi frends & collins, The code below is the one Im using now for xmlhttp request in IE as well as Netscape browser.I have put this code in a server,if i want to retrive the data from the same...
6
1625
by: Andy | last post by:
Hi guys, I'm currently working on a project that determines the geographical location of a request to our servers. I'm not sure exactly how it works as the geolocation functionality is coming...
4
1922
by: David | last post by:
Hi list. Do test-driven development or behaviour-driven development advocate how to do higher-level testing than unit testing? types of testing: unit integration system
0
7233
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
7135
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
7342
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7410
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
7505
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
5650
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,...
1
5060
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...
0
3201
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1570
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 ...

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.