<?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_popup.inc,v 1.10 2002/08/16 08:55:06 anders Exp $
// ====================================================================
//--------------------------------------------------------------------------
// General PopUp window data
//--------------------------------------------------------------------------
$window_width = 350;
$window_height = 250;
$help_url = "http://$servername/$scriptbase/help.html";
//--------------------------------------------------------------------------
// All data for graphical scale
//--------------------------------------------------------------------------
$image_path = "http://$servername/$scriptbase";
$scale_image = $image_path."/scale.png";
$scale_width = 213;
$scale_height = 26;
$scale_pos_x = 25;
$scale_pos_y = 99;
$bar_image = $image_path."/bar.png";
$bar_width = 2;
$bar_height = 13;
$bar_pos_x = $scale_pos_x+6;
$bar_pos_y = $scale_pos_y+6;
$active_image = $image_path."/active.gif";
$active_width = 208;
$active_height = 26;
$active_pos_x = $scale_pos_x;
$active_pos_y = $scale_pos_y;
//==========================================================================
// PRIVATE FUNCTIONS
//==========================================================================
//--------------------------------------------------------------------------
// Output string with max length (adding "..." if necessary)
//--------------------------------------------------------------------------
function _output_string($string, $maxlen = 40)
{
if (strlen($string) > $maxlen)
echo substr($string, 0, $maxlen)."...";
else
echo $string;
}
//--------------------------------------------------------------------------
// Output graphical button
//--------------------------------------------------------------------------
function _output_button($name, $x = "", $y = "", $href = "", $target = "")
{
global $image_path;
if (($x != "") || ($y != ""))
echo '<div style="position:absolute; left:'.$x.'px; top:'.$y.'px">';
echo '<a href="'.$href.'" OnClick="OpenOnUnloadDisabled=1"';
if ($target != "") echo ' target="'.$target.'"';
echo '>';
echo '<img src="'.$image_path."/".$name.'.png" border="0" width="64" height="20" alt="'.$name.'">';
echo '</a>';
if (($x != "") || ($y != ""))
echo '</div>';
}
//--------------------------------------------------------------------------
// Show user/password formular
//--------------------------------------------------------------------------
function _output_userpass_form($type, $x, $y)
{
global $image_path, $script_url, $url, $remote_addr, $http_referer, $nojavascript;
global $temp_datafile_name, $temp_headerfile_name;
echo '<div style="position:absolute; left:'.$x.'px; top:'.$y.'px">';
echo '<form action="'.$script_url.'" method="post" onSubmit="OpenOnUnloadDisabled=1;">';
echo '<input type="hidden" name="action" value="download">';
echo '<input type="hidden" name="qurl" value="'.urlencode($url).'">';
echo '<input type="hidden" name="remote_addr" value="'.$remote_addr.'">';
echo '<input type="hidden" name="http_referer" value="'.$http_referer.'">';
echo '<input type="hidden" name="nojavascript" value="'.$nojavascript.'">';
echo '<table colspacing="0" colpadding="0">';
echo '<tr><td colspan="2">Kennung:</td></tr>';
echo '<tr><td colspan="2">';
echo '<font size="1">';
echo '<input style="border-style:solid; border-width:1px; border-color:#000000; background-color:#CCCCCC;" type="text" name="'.$type.'_user" value="" size="16" maxlength="32">';
echo '</font>';
echo '</td></tr>';
echo '<tr><td colspan="2">Passwort:</td></tr>';
echo '<tr><td colspan="2">';
echo '<font size="1">';
echo '<input style="border-style:solid; border-width:1px; border-color:#000000; background-color:#CCCCCC;" type="password" name="'.$type.'_password" value="" size="16" maxlength="32">';
echo '</font>';
echo '</td></tr>';
echo '<tr height="30"><td valign="bottom">';
echo '<input type="image" border="0" src="'.$image_path.'/ok.png">';
echo '</td><td valign="bottom">';
_output_button("cancel", "", "", "javascript:window.close();", "");
echo '</td></tr>';
echo '</table>';
echo '</form>';
echo '</div>';
}
//==========================================================================
// PUBLIC FUNCTIONS
//==========================================================================
//--------------------------------------------------------------------------
// Output GUI header
//--------------------------------------------------------------------------
function gui_header()
{
global $image_path;
$stylesheet = '<style type="text/css">
<!--
body,tr { font-family: Verdana, Arial, Helvetica, sans-serif; bgcolor:#FFFFFF; font-size: 10px;}
//-->
</style>
';
output_html_header("", TRUE, $stylesheet);
# $winid = "win_".md5($url);
# output_in_javascript_env("if (document.image) {opener.name='".$winid."_opened';}");
output_in_javascript_env("window.onunload=function(){OpenNewStopWindow();}");
echo '<body bgcolor="#FFFFFF"';
echo ' background="'.$image_path.'/background.png"';
echo '>';
echo '<div style="position:absolute; left:104px; top:42px">';
echo '<font color="#FFAA00">'.VERSION.'</font>';
echo '</div>';
flush();
}
//--------------------------------------------------------------------------
// Output, that download has begun
//--------------------------------------------------------------------------
function gui_download_msg()
{
global $filename, $url;
$up = parse_url($url);
echo '<div style="position:absolute; left:25px; top:58px">';
echo "<b>Laden:</b>";
echo '</div>';
echo '<div style="position:absolute; left:25px; top:72px">';
_output_string($filename,40);
echo '</div>';
echo '<div style="position:absolute; left:25px; top:84px">';
echo "<i>von</i> ";
_output_string($up[scheme]."://".$up[host],36);
echo '</div>';
flush();
}
//--------------------------------------------------------------------------
// Output download scales
//--------------------------------------------------------------------------
function _gui_empty_scale()
{
global $scale_image, $scale_width, $scale_height, $scale_pos_x, $scale_pos_y;
echo '<div style="position:absolute; left:'.$scale_pos_x.'px; top:'.$scale_pos_y.'px">';
echo '<img src="'.$scale_image.'" width="'.$scale_width.'" height="'.$scale_height.'" alt="">';
echo '</div>';
flush();
}
function _gui_active_scale()
{
global $active_image, $active_width, $active_height, $active_pos_x, $active_pos_y;
echo '<div style="position:absolute; left:'.$active_pos_x.'px; top:'.$active_pos_y.'px">';
echo '<img src="'.$active_image.'" width="'.$active_width.'" height="'.$active_height.'" alt="|">';
echo '</div>';
flush();
}
//--------------------------------------------------------------------------
// Output complete scale or piece of the bar (called from "read_data")
//--------------------------------------------------------------------------
function gui_scale_bar($ch)
{
global $popup_enabled, $header, $last_percent, $download_started;
global $bar_image, $bar_width, $bar_height, $bar_pos_x, $bar_pos_y;
global $server_errno, $help_url;
if ($popup_enabled && !server_error_occured())
{
$state = curl_getinfo($ch);
if (!$download_started)
{
if ($header["content-length"] == 0)
_gui_active_scale();
else
_gui_empty_scale();
_output_button("cancel", 25, 130, "javascript:window.location='".create_script_url("stop")."';");
_output_button("help", 100, 130, $help_url, "_blank");
$download_started = TRUE;
}
if ($header["content-length"] != 0)
{
$percent = floor($state[size_download]/$header["content-length"]*100);
for ($i=$last_percent; $i<$percent; $i++)
{
echo '<div style="position:absolute; left:'.($bar_pos_x+$i*$bar_width).'px; top:'.($bar_pos_y).'px">';
echo '<img src="'.$bar_image.'" width="'.$bar_width.'" height="'.$bar_height.'" alt="|">';
echo '</div>';
}
$last_percent = $percent;
}
flush();
}
}
//--------------------------------------------------------------------------
// Output HTTP authorization form
//--------------------------------------------------------------------------
function gui_auth_form()
{
echo '<div style="position:absolute; left:25px; top:100px">';
echo "Authentifizierung erforderlich:";
echo '</div>';
_output_userpass_form("auth",25,120);
flush();
}
//--------------------------------------------------------------------------
// Output FTP authorization form
//--------------------------------------------------------------------------
function gui_ftp_form()
{
echo '<div style="position:absolute; left:25px; top:100px">';
echo "FTP Kennung und Passwort erforderlich:";
echo '</div>';
_output_userpass_form("ftp",25,120);
flush();
}
//--------------------------------------------------------------------------
// Output Error message
//--------------------------------------------------------------------------
function gui_error_msg($error)
{
global $download_started;
if (!$download_started) $y = 100; else $y = 160;
echo '<div style="position:absolute; left:25px; top:'.$y.'px">';
echo '<font color="#FF0000">';
echo $error;
echo '</font>';
echo '</div>';
_output_button("close", 25, $y+20, "javascript:window.close();");
flush();
}
//--------------------------------------------------------------------------
// Output message, that virus scanning is in progress
//--------------------------------------------------------------------------
function gui_scanning_msg()
{
echo '<div style="position:absolute; left:25px; top:160px">';
echo "Überprüfen auf Viren...";
echo '</div>';
flush();
}
//--------------------------------------------------------------------------
// Output message, that virus has been found!
//--------------------------------------------------------------------------
function gui_virus_found_msg()
{
echo '<div style="position:absolute; left:25px; top:180px">';
echo '<font color="#FF0000">';
echo "Virus gefunden, Datei infiziert!";
echo '</font>';
echo '</div>';
echo '<div style="position:absolute; left:25px; top:195px">';
echo '<font color="#FF0000">';
echo "Download nicht möglich!";
echo '</font>';
echo '</div>';
_output_button("close", 25, 215, "javascript:window.close();");
flush();
}
//--------------------------------------------------------------------------
// Output message, that NO virus has been found :-)
//--------------------------------------------------------------------------
function gui_no_virus_found_msg()
{
echo '<div style="position:absolute; left:25px; top:180px">';
echo '<font color="#008000">';
echo "Kein Virus gefunden, Datei o.k.";
echo '</font>';
echo '</div>';
_output_button("saveas", 25, 200, create_script_url("deliver").'&saveas=TRUE');
flush();
}
//--------------------------------------------------------------------------
// Output message, that no virus scanning was performed
//--------------------------------------------------------------------------
function gui_scan_disabled_msg()
{
echo '<div style="position:absolute; left:25px; top:160px">';
echo '<font color="#FF0000">';
echo "Datei nicht auf Viren überprüft!";
echo '</font>';
echo '</div>';
_output_button("saveas", 25, 180, create_script_url("deliver").'&saveas=TRUE');
flush();
}
//--------------------------------------------------------------------------
// Output message, that scanning has failed
//--------------------------------------------------------------------------
function gui_scan_failure_msg()
{
echo '<div style="position:absolute; left:25px; top:180px">';
echo '<font color="#FF0000">';
echo "Fehler beim Scannen auf Viren!";
echo '</font>';
echo '</div>';
_output_button("close", 25, 215, "javascript:window.close();");
flush();
}
//--------------------------------------------------------------------------
// Output message, that virus was found and file has been disinfected
//--------------------------------------------------------------------------
function gui_virus_found_and_disinfected_msg()
{
echo '<div style="position:absolute; left:25px; top:180px">';
echo '<font color="#0000FF">';
echo "Virus gefunden und entfernt!";
echo '</font>';
echo '</div>';
_output_button("saveas", 25, 180, create_script_url("deliver").'&saveas=TRUE');
flush();
}
//--------------------------------------------------------------------------
// Output message, that connection has timed out (and show retry button)
//--------------------------------------------------------------------------
function gui_timeout_msg()
{
global $download_timeout, $retry, $download_started;
if (!$download_started) $y = 100; else $y = 160;
gui_error_msg("Download timed out! (max: ".$download_timeout." secs)");
_output_button("retry", 100, $y+20, "javascript:window.location='".create_script_url("download")."&retry=".($retry+1)."';");
flush();
}
//--------------------------------------------------------------------------
// download aborted message
//--------------------------------------------------------------------------
function gui_download_aborted_msg()
{
# echo '<body bgcolor="#FFFFF">';
# echo "Download aborted";
# echo "<p>";
# echo "Removed temporary files!";
# echo '</body>';
}
//--------------------------------------------------------------------------
// Output message, that download has already been started
// (This function MUST return a single string with a complete HTML page!)
//--------------------------------------------------------------------------
function gui_already_downloading()
{
global $servername, $scriptbase;
$titleimage_url = "http://$servername/$scriptbase/titleline.png";
$str = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">';
$str .= '<html>\n';
$str .= '<head>\n';
$str .= '<style type="text/css">\n<!--\n body,tr { font-family: Verdana, Arial, Helvetica, sans-serif; bgcolor:#FFFFFF; font-size: 10px;}\n //-->\n</style>\n';
$str .= '<title>ANDURAS® SurfProtect Download läuft bereits...</title>';
$str .= '</head>\n';
$str .= '<body>\n';
$str .= '<img src="'.$titleimage_url.'"><hr noshade size="2" />\n';
$str .= '<h2>Der Downloadvorgang läuft bereits...</h2>\n';
$str .= '<p>\n';
$str .= 'Diese Meldung erscheint immer dann, wenn Sie erneut versuchen eine Datei herunterzuladen, ';
$str .= 'die bereits heruntergeladen wird.<br>';
$str .= 'Falls sie dies irrtümlich versucht haben, so können Sie mit dem folgenden Link auf die ';
$str .= 'Seite zurückspringen, von der Sie den Download gestartet haben.';
$str .= '<p>\n';
$str .= '<a href=\"javascript:history.back();\">Zurück zur vorherigen Seite</a>\n';
$str .= '<p>\n';
$str .= 'Das erneute Starten eines Download kann jedoch auch durch eine Seite, welche den ';
$str .= 'Downloadvorgang automatisch startet, ausgelöst werden.<p>';
$str .= 'Falls dies der Fall war, so können Sie mit dem folgenden Link auf die Seite vor dem ';
$str .= 'automatischen Download zurückspringen.';
$str .= '<p>\n';
$str .= '<a href=\"javascript:history.go(-2);\">Zwei Seiten zurück gehen</a>\n';
$str .= '<p>\n';
$str .= '</body>\n';
$str .= '</html>';
return $str;
}
//--------------------------------------------------------------------------
// Output GUI footer
//--------------------------------------------------------------------------
function gui_footer()
{
echo "</body>";
output_html_footer();
}
?>