Link to home
Start Free TrialLog in
Avatar of Mescronomicon
MescronomiconFlag for Canada

asked on

Load random javascript link in a PHP-Nuke block

I admin a gaming clan and I configured a server monitor to display on my web page as seen here:

http://www.phoenixalliance.biz

Since we have 5 game servers I would like to randomly load one of the server monitors in the php-nuke block on the home page and have links to all of them below.

This is the code to display the server monitor:

<script language="JavaScript" type="text/JavaScript" src="http://share1.serverspy.net/bin/smonV2loader.mpl?mid=229823"></script>

I'm at a loss as to how to do this.
Avatar of hielo
hielo
Flag of Wallis and Futuna image

1. Do you have the <script ...></script> on the body of the page or on the head?
2. If I understand correctly, http://share1.serverspy.net/bin/smonV2loader.mpl?mid=229823 is a URL to just one of the servers right?
Avatar of Mescronomicon

ASKER

It's in the body.

Simply clicking the link http://share1.serverspy.net/bin/smonV2loader.mpl?mid=229823 does not open the server monitor but prompts for a download for the v2loader.
what are the other 5 urls?
To clarify, I am trying to understand how you would differentiate amongst the monitors. Are they in different subdomains or is the mid value (on the link specified) different for each of the monitors?
The url you provided simply has some javascript that writes html element onto the document. Thus, instead of:
<script language="JavaScript" type="text/JavaScript" src="http://share1.serverspy.net/bin/smonV2loader.mpl?mid=229823"></script>

use:
<script type="text/javascript"><!--
var monitorURL=new Array("http://img.serverspy.net/images/monitor2/smon4.swf?mid=229823", "http://img.serverspy.net/images/monitor2/smon4.swf?mid=229824", "http://img.serverspy.net/images/monitor2/smon4.swf?mid=229825");
var max=(monitorURL.length-1);
var min=0;
var uri=monitorURL[ Math.floor(Math.random()*( max - min + 1) + min) ];

    document.write('<table border="0" cellspacing="0" cellpadding="0" align="center">');
    document.write('<tr><td>');
    document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="600" height="600" align="bottom">');
    document.write('  <param name="allowScriptAccess" value="sameDomain" >');
    document.write('  <param name="movie" value="'+uri+'" >');
    document.write('  <param name="quality" value="medium" >');
    document.write('  <param name="wmode" value="transparent" >');
    document.write('  <param name="bgcolor" value="#151b1f" >');
    document.write('  <embed src="'+uri+'" wmode="transparent" quality="medium" bgcolor="#151b1f" width="600" height="600" name="flashmovie" align="bottom" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" > ');
    document.write('</object>');
    document.write('</td></tr>');
    document.write('<tr><td><a href="http://www.serverspy.net" target="_blank"><img src="http://img.serverspy.net/images/flash/monitor/monbar.png" width="600" height="14" border="0" alt=""></a></td></tr>');
    document.write('</table>');
             //-->
</script>

You will simply need to supply the URL in the monitorURL array. NOTE: I got all these document.write statements from 'http://share1.serverspy.net/bin/smonV2loader.mpl?mid=229823' and if you look closely, the only thing that should change (other than the dimesions of table) is the src attribute to the embed element and the value to the movie parameter.
ASKER CERTIFIED SOLUTION
Avatar of Zvonko
Zvonko
Flag of North Macedonia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Of course remove the alert() in production.

Zvonko, that worked well for the random display.

How would I create links to open up the others monitors in the same place as the random one?

Is that possible?
Can you give me some more server numbers for test please?
Do you mind closing this question and opening a new one for the links part?