<?php
// ====================================================================
// Copyright (c) 2002 by the ANDURAS AG, Passau, Germany.
// ====================================================================
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
// ====================================================================
// $Id: surfprot_gui.inc,v 1.6 2002/08/16 08:55:06 anders Exp $
// ====================================================================
//==========================================================================
// BASIC OUTPUT FUNCTIONS
//==========================================================================
//--------------------------------------------------------------------------
// Create meta refresh line
//--------------------------------------------------------------------------
function create_meta_refresh($url, $seconds = 2)
{
return '<meta http-equiv="refresh" content="'.$seconds.';'.urlencode($url).'">';
}
//--------------------------------------------------------------------------
// Output Javascript environment
//--------------------------------------------------------------------------
function output_in_javascript_env($script)
{
echo "\n<script language=\"JavaScript\">\n";
echo "<!--\n";
echo $script;
echo "\n//-->\n";
echo "</script>\n";
}
//--------------------------------------------------------------------------
// Output Javascript functions code
//--------------------------------------------------------------------------
function output_javascript_functions()
{
global $window_width, $window_height;
output_in_javascript_env(
"var OpenOnUnloadDisabled = 0;\n".
"function OpenNewStopWindow() {\n".
"if (OpenOnUnloadDisabled == 0) {\n".
"OpenOnUnloadDisabled = 1;\n".
"open('".create_script_url("stop")."','".time()."','width=".$window_width.",height=".$window_height.",scrollbars=no,resize=no');".
"}\n".
"}\n"
);
}
//--------------------------------------------------------------------------
// Output HTML header
//--------------------------------------------------------------------------
function output_html_header($title = "", $javascript = FALSE, $additional = "")
{
echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n";
echo "<html>\n";
echo "<head>\n";
echo $additional;
if ($javascript) output_javascript_functions();
echo "\n<title>";
if ($title != "")
echo $title;
else
echo "ANDURAS® SurfProtect Download";
echo "</title>\n";
echo "</head>\n";
}
//--------------------------------------------------------------------------
// Output HTML footer
//--------------------------------------------------------------------------
function output_html_footer()
{
echo "\n</html>\n";
}
//--------------------------------------------------------------------------
// Pop up another window with download...
//--------------------------------------------------------------------------
function popup()
{
global $window_width, $window_height, $http_referer, $url;
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Pragma: no-cache"); // HTTP/1.0
// Meta-Refresh is fallback for non-javascript browers
echo "<noscript>";
output_html_header("", FALSE,
create_meta_refresh(create_script_url("")."&nojavascript=TRUE"), 2);
echo "</noscript>";
echo '<body>';
echo "\n\n";
echo "<!----------------------------------------------------------------\n";
echo " This is not the file you wanted!\n";
echo " Please click directly onto the link and DO NOT use\n";
echo " 'Save Link As' or 'Save target as' ...\n";
echo "------------------------------------------------------------------>\n";
echo "\n";
// Open new PopUp window with download and virus scan
$winid = "win_".md5($url);
output_in_javascript_env(
"if (window.name == '".$winid."_opener') {\n".
" document.write('".gui_already_downloading()."');\n".
"} else {\n".
" if (window.$winid && !$winid.closed) {\n".
" $winid.focus();\n".
" } else {\n".
" $winid = window.open('".create_script_url("download")."','".$winid."','width=".$window_width.",height=".$window_height.",scrollbars=no,resize=yes,hotkeys=no,status=no');\n".
" if ($winid.opener == null) { $winid.opener = self; }\n".
" window.name = '".$winid."_opener';\n".
" history.back();\n".
"}}\n"
);
echo "</body>";
output_html_footer();
}
?>