Page 1 of 1

[SOLVED] loading pop up window from PHP script

Posted: Sat Dec 27, 2003 1:22 am
by vientorio
Hello there, hopefully somone can help

we are mirroring a site from here in new zealand. this customers mirror uses a file called dl.php followed by the query and PHP grabs the file to be downloaded.

When the dl.php gets displayed to a web browser we need it to open a popup window that automatically closes after 3 or 4 seconds.

the web url for the link to pop up is [url]
http://www.url.com/assign.php?l=name&mode=behind

the PHP file is as follows

Code: Select all

<?php

print("<html>
<head>
<TITLE>Downloading...</TITLE>
<style type="text/css">
<!--
     A:link {text-decoration: none;}
     A:visited {text-decoration: none;}
     A:hover {text-decoration: none;}
a:hover{color:red}
-->
</style>

</head>

<body bgcolor="#004080" link="#000080" vlink="#000080" alink="#800000" topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0">

<div align="center">
  <center>
  <table border="0" width="100%" cellspacing="0" cellpadding="0">
    <tr>
      <td width="100%" height="73"><p align="center"><a href="http://www.gameburnworld.com"><img border="0" src="http://www.gameburnworld.com/game_header_1.jpg" width="165" height="55"><img border="0" src="http://www.gameburnworld.com/game_header_2.jpg" width="165" height="55"><img border="0" src="http://www.gameburnworld.com/game_header_3.jpg" width="197" height="55"></a></td>
    </tr>
    <tr>
      <td width="100%"><p align="center"><!--Insert Banner Here--!></td>
    </tr>
    <tr>
      <td width="100%"><font color="#004080">|</font></td>
    </tr>
  </table>
  </center>
</div>

<div align="center"><center><table border="1" width="100%" bgcolor="#C0C0C0" cellspacing="0" cellpadding="0" bordercolor="#808080">
  <tr>
    <td width="100%">
<hr align="center">");

$display_template = "<div align="center">
  <center>
  <table border="0" width="25%" cellspacing="0" cellpadding="0">
    <tr>
      <td width="100%"><p align="center"><font face="Tahoma" size="2" color="#000080"><b><a href='<URL>'target="_blank"</b></font><font face="Tahoma" size="2"><b><MIRROR></a></b></font></td>
    </tr>
    <tr>
      <td width="100%">
        <p align="center"><font face="Tahoma" size="2" color="#000000">(Opens In
        A New Window)</font></td>
    </tr>
  </table>
  </center>
</div>";

$servers = file ('servers.txt');
for ($i = 0; $i < count ($servers); $i++)

{
  $sarr = explode ('::', $servers[$i]);
  $sarr[2] = str_replace ('<FILENAME>', $_GET['file'], $sarr[2]);
  $dtmp = str_replace ('<URL>', $sarr[2], $display_template);
  $dtmp = str_replace ('<MIRROR>', $sarr[1], $dtmp);
  $dtmp = str_replace ('<LOCATION>', $sarr[0], $dtmp);
  $dtmp = str_replace ('<COUNTER>', $i + 1, $dtmp);
  echo $dtmp;
}

print("<p align="center"><font face="Tahoma" size="2"><font color="#FFFF00">Mirror
Provided By:</font> <b><a href="http://www.gtcs.net.nz" target="_blank">GTCS</a></b></font></p> <p align="center"><a href="http://www.gtcs.net.nz" target="_blank"><img border="0" src="http://bgw.gtcs.net.nz/logo1.gif" alt="GTCS New Zealand! Click Now!" width="200" height="100"></a></p>

<hr align="center">

<p align="center"><font face="Tahoma" size="2" color="#800000"><b>* While you
are downloading, please take the time to visit the download mirror sponsor,
their links and banners are on this page.</b></font></p>

<hr align="center">

</td>
  </tr>
</table></center>
</div>

<div align="center">
  <center>
  <table border="0" width="100%" cellspacing="0" cellpadding="0">
    <tr>
      <td width="100%"><font color="#004080">|</font></td>
    </tr>
  </table>
  </center>
</div>
<div align="center">
  <center>
  <table border="1" width="100%" bordercolor="#808080" cellspacing="0" cellpadding="0" bgcolor="#C0C0C0" height="22">
    <tr>
      <td width="100%">
        <p align="center"><font face="Arial" size="1">© 2004 <a href="http://www.gameburnworld.com"><u>GameBurnWorld</u></a>
        ® All Rights Reserved | <a href="http://www.gameburnworld.com/termsofuse.htm"><u>Terms
        Of Use</u></a> | <a href="http://www.gameburnworld.com/privacypolicy.htm"><u>Privacy
        Policy</u></a> | <a href="http://www.gameburnworld.com/contact.htm"><u>Contact
        Us</u></a> | <a href="http://www.gameburnworld.com/advertise.htm"><u>Advertise
        With Us</u></a> |</font></td>
    </tr>
  </table>
  </center>
</div>

</body>

</html>");

?>
we have tried adding javascript pop up but it doesnt work, throws an error, the page to be opened only needs to be 100 x 50 pixels as its not actually there to display anything, just part of our counting system.

ive tried inserting



<SCRIPT LANGUAGE="JavaScript" src="http://www.url.com/assign.php?l=name&mode=behind"> </script>

But it throws this

Parse error: parse error, unexpected T_STRING in C:\Inetpub\Mirrors\dl.php on line 14

many thanks in advance to whoever looks into this for me

Kindest regards

Geoff 8)

Posted: Sat Dec 27, 2003 3:10 am
by nigma
Hey, didn't really read the post over, but thought you might be interested in something called heredoc syntax since you appear to be outputting much html to the browser using a print statement. Heredoc works identically with both print and echo, man pages are available as follows:

http://us2.php.net/echo
http://us2.php.net/print

Posted: Sat Dec 27, 2003 3:32 am
by vientorio
thanks nigma, although theis script is done this was for a reason, all i need is a piece of script to open a popup window.

cheers

geoff 8)

Posted: Sat Dec 27, 2003 3:57 am
by igoy
You can use this javascriptfunction for opening a browser window :

Code: Select all

<script language="javascript">
function MM_openBrWindow(theURL,winName,features, myWidth, myHeight, isCenter) { //v3.0
  if(window.screen)if(isCenter)if(isCenter=="true"){
    var myLeft = (screen.width-myWidth)/2;
    var myTop = (screen.height-myHeight)/2;
    features+=(features!='')?',':'';
    features+=',left='+myLeft+',top='+myTop;
  }
  window.open(theURL,winName,features+((features!='')?',':'')+'width='+myWidth+',height='+myHeight);
}
</script>
and then you can use like this

Posted: Sat Dec 27, 2003 4:29 am
by vientorio
<script language="javascript">
function MM_openBrWindow(theURL,winName,features, myWidth, myHeight, isCenter) { //v3.0
if(window.screen)if(isCenter)if(isCenter=="true"){
var myLeft = (screen.width-myWidth)/2;
var myTop = (screen.height-myHeight)/2;
features+=(features!='')?',':'';
features+=',left='+myLeft+',top='+myTop;
}
window.open(theURL,winName,features+((features!='')?',':'')+'width='+myWidth+',height='+myHeight);
}
</script>
thankyou but im having trouble now, the link http://www.url.com/assign.php?l=name&mode=behind actually already open a pre determined size window behind the window that calls it. so what i need is just the simplest piece of script to add to the dl.php to goto exactly the url here, not hit counters, anything like that. I am sorry i should have been more careful in describing what i need.

Thankyou for helping, i have taken note of the script qouted here because it is of use in another project

Kind regards
geoff 8)

Posted: Sat Dec 27, 2003 7:08 am
by vientorio
Perhaps i should be more clear in my question

I have a small problem with one of our customers PHP script. we mirror files for them and they use a dl.php file to get the file. When this dl.php file is displayed in a web browser we need it to open a pop up window

the top of the PHP file is as follows

Code: Select all

print("<html>
<head>
<TITLE>Downloading...</TITLE>
<style type="text/css">
<!--
     A:link &#123;text-decoration: none;&#125;
     A:visited &#123;text-decoration: none;&#125;
     A:hover &#123;text-decoration: none;&#125;
a:hover&#123;color:red&#125;
-->
</style>

</head>


we need to insert a link like this:

Code: Select all

<SCRIPT LANGUAGE="JavaScript" src="http://www.domain.com/assign.php?l=vientorio&mode=behind"> </script>


Many thanks in advance for any help

Regards,
Geoff :)