C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\phpMyServer\download.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php

//----------------------------------//
//    Copyright by Matthias Speer   //
//----------------------------------//

include('./config.inc.php');

include(
'./auth.php');

$action=isset($_GET['action'])?$_GET['action']:'';
$option=(isset($_GET['option']))?$_GET['option']:'';
$path=isset($_GET['path'])?DecodeGET($_GET['path']):'';
$file=isset($_GET['file'])?DecodeGET($_GET['file']):'';
$fullpath=GetPath($path$file);

$html1 ='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">';
$html1.='<HTML><HEAD><TITLE>Download</TITLE>';
$html1.='<META http-equiv="Content-Type" content="text/html; charset='.GetLocText('charset'false).'">';
$html1.='<LINK href="style/global.css" rel="stylesheet" type="text/css">';
$html1.='<SCRIPT language="JavaScript" src="./script/frames.js" type="text/JavaScript"></SCRIPT></HEAD><BODY>';
$html2 ='</BODY></HTML>';

if ((
$fullpath!==false)&&($path!='')&&($file!=''))
{
    switch (
$PMS['os'].'|'.$PMS['modus'])
    {
        case 
'linux|PHPsys':
        case 
'linux|Python':
        case 
'linux|PerlCGI':
        case 
'linux|Perl_htaccess':    
        case 
'linux|SSI':            $mod=new PMSMod();
                                    if (
$mod->Copy2Temp("cp $fullpath"))
                                    {                                
                                        
header("Content-type: application/octet-stream");
                                        
header("Content-disposition: attachment; filename=".$file);
                                        
header("Content-Length: ".filesize($mod->TempFilename()));
                                        
header("Pragma: no-cache");
                                        
header("Expires: 0");
                                        
$mod->TempFile2Stdout();
                                    } else
                                    {
                                        echo 
$html1;
                                        
DisplayError(GetLocText('err_fnf'), $fullpath);
                                        echo 
$html2;
                                    }
                                    
$mod->Destructor();    
                                    break;
    
        case 
'linux|PHP':                 
        case 
'win|PHP':                header("Content-type: application/octet-stream");
                                    
header("Content-disposition: attachment; filename=".$file);
                                    
header("Content-Length: ".filesize($fullpath));
                                    
header("Pragma: no-cache");
                                    
header("Expires: 0");
                                    
readfile($fullpath);
                                    break;
    
        default:                    echo 
$html1;
                                    
DisplayMessage(GetLocText('msg_func_na'));
                                    echo 
$html2;
            
    }
} else
{
    echo 
$html1;
    
DisplayError(GetLocText('err_fnf'), $file);
    echo 
$html2;
}

?>