File size: 3,843 Bytes
07c3cdd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php
/**
 * users_ViewResume.php
 *
 * ProcessMaker Open Source Edition
 * Copyright (C) 2004 - 2008 Colosa Inc.23
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 *
 * For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
 * Coral Gables, FL, 33134, USA, or email info@colosa.com.
 */
if (($RBAC_Response = $RBAC->userCanAccess( "PM_LOGIN" )) != 1)
    return $RBAC_Response;


$uid = (isset( $_SESSION['CURRENT_USER'] ) ? $_SESSION['CURRENT_USER'] : $_SESSION['USER_LOGGED']);
require_once 'classes/model/Users.php';
$oUser = new Users();
$form = $oUser->load( $uid );
if (! isset( $form['USR_RESUME'] ) || $form['USR_RESUME'] === '')
    die( G::LoadTranslation( 'ID_WITHOUT_RESUME' ) );
$direction = PATH_IMAGES_ENVIRONMENT_FILES . $uid . "/" . $form['USR_RESUME'];
if (! file_exists( $direction )) {
    die( 'The file "' . $direction . '"doesn\'t exist in the server!' );
}
//	echo $direction ;
header( 'Pragma: ' );
header( 'Cache-Control: cache' );

G::sendHeaders( $direction );
readfile( $direction );
//DumpHeaders($direction);


/*
 * This function is verified to work with Netscape and the *very latest*
 * version of IE.  I don't know if it works with Opera, but it should now.
 */
function DumpHeaders ($filename)
{

    global $root_path;

    if (! $filename)
        return;

    $HTTP_USER_AGENT = $_SERVER['HTTP_USER_AGENT'];

    $isIE = 0;

    if (strstr( $HTTP_USER_AGENT, 'compatible; MSIE ' ) !== false && strstr( $HTTP_USER_AGENT, 'Opera' ) === false) {
        $isIE = 1;
    }

    if (strstr( $HTTP_USER_AGENT, 'compatible; MSIE 6' ) !== false && strstr( $HTTP_USER_AGENT, 'Opera' ) === false) {
        $isIE6 = 1;
    }

    // The ereg_replace function has been DEPRECATED as of PHP 5.3.0.
    // $aux = ereg_replace('[^-a-zA-Z0-9\.]', '_', $filename);
    $aux = preg_replace( '/[^-a-zA-Z0-9\.]/', '_', $filename );
    $aux = explode( '_', $aux );
    $downloadName = $aux[count( $aux ) - 1];
    //  $downloadName = $filename;


    //$downloadName = ereg_replace('[^-a-zA-Z0-9\.]', '_', $filename);


    if ($isIE && ! isset( $isIE6 )) {
        // http://support.microsoft.com/support/kb/articles/Q182/3/15.asp
        // Do not have quotes around filename, but that applied to
        // "attachment"... does it apply to inline too?


        // This combination seems to work mostly.  IE 5.5 SP 1 has
        // known issues (see the Microsoft Knowledge Base)
        header( "Content-Disposition: inline; filename=$downloadName" );

        // This works for most types, but doesn't work with Word files
        header( "Content-Type: application/download; name=\"$downloadName\"" );

        //header("Content-Type: $type0/$type1; name=\"$downloadName\"");
        //header("Content-Type: application/x-msdownload; name=\"$downloadName\"");
        //header("Content-Type: application/octet-stream; name=\"$downloadName\"");
    } else {
        header( "Content-Disposition: attachment; filename=\"$downloadName\"" );
        header( "Content-Type: application/octet-stream; name=\"$downloadName\"" );
    }

    //$filename = PATH_UPLOAD . "$filename";
    readfile( $filename );
}

//G::header2( "location: /files/" .$_SESSION['ENVIRONMENT']. "/" .$appid, $filename);