Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 383
  • Last Modified:

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.
0
Mescronomicon
Asked:
Mescronomicon
  • 4
  • 4
  • 3
1 Solution
 
hieloCommented:
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?
0
 
MescronomiconAuthor Commented:
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.
0
 
hieloCommented:
what are the other 5 urls?
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
hieloCommented:
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?
0
 
hieloCommented:
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.
0
 
ZvonkoSystems architectCommented:
Change this:
<script language="JavaScript" type="text/JavaScript" src="http://share1.serverspy.net/bin/smonV2loader.mpl?mid=229823"></script>



To this:

<script>
var srv = [229823,229824];

var sNum = parseInt(Math.random()*srv.length);
alert(sNum);
document.write('<scr'+'ipt language="JavaScript" type="text/JavaScript" src="http://share1.serverspy.net/bin/smonV2loader.mpl?mid='+srv[sNum]+'"></scr'+'ipt>');
</script>


0
 
ZvonkoSystems architectCommented:
Of course remove the alert() in production.

0
 
MescronomiconAuthor Commented:
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?
0
 
ZvonkoSystems architectCommented:
Can you give me some more server numbers for test please?
0
 
ZvonkoSystems architectCommented:
Do you mind closing this question and opening a new one for the links part?
0
 
MescronomiconAuthor Commented:
0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 4
  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now