[260] | 1 | <?php |
---|
| 2 | |
---|
| 3 | class download |
---|
| 4 | { |
---|
| 5 | |
---|
| 6 | function Decode_String($string) |
---|
| 7 | { |
---|
| 8 | $base64 = $string; |
---|
| 9 | $base64_de = base64_decode($base64); |
---|
| 10 | $array_info = unserialize($base64_de); |
---|
| 11 | |
---|
| 12 | if($array_info['server'] == $_SERVER['SERVER_ADDR']){ |
---|
| 13 | $this->down_file($array_info['fileUp']); |
---|
| 14 | }else{ |
---|
| 15 | $url = "http://".$array_info['server'].$array_info['path'].$array_info['filePhp'].$base64; |
---|
| 16 | header("Location:" . $url); |
---|
| 17 | } |
---|
| 18 | } |
---|
| 19 | |
---|
| 20 | function down_file($file) |
---|
| 21 | { |
---|
| 22 | |
---|
| 23 | ini_set("session.save_path","/php_sessions"); |
---|
| 24 | $size = filesize(ini_get("session.save_path").'/'. $file); |
---|
| 25 | $NameFile = explode("_IM_SendFile_",$file); |
---|
| 26 | |
---|
| 27 | if (!empty($file)) |
---|
| 28 | { |
---|
| 29 | if (ereg('Opera(/| )([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT'])) |
---|
| 30 | $UserBrowser = "Opera"; |
---|
| 31 | elseif (ereg('MSIE ([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT'])) |
---|
| 32 | $UserBrowser = "IE"; |
---|
| 33 | else |
---|
| 34 | $UserBrowser = ''; |
---|
| 35 | |
---|
| 36 | $strFileType = strrev(substr(strrev($NameFile),0,4)); |
---|
| 37 | $ContentType = "application/octet-stream"; |
---|
| 38 | |
---|
| 39 | if ($strFileType == ".asf") |
---|
| 40 | $ContentType = "video/x-ms-asf"; |
---|
| 41 | if ($strFileType == ".avi") |
---|
| 42 | $ContentType = "video/avi"; |
---|
| 43 | if ($strFileType == ".doc") |
---|
| 44 | $ContentType = "application/msword"; |
---|
| 45 | if ($strFileType == ".zip") |
---|
| 46 | $ContentType = "application/zip"; |
---|
| 47 | if ($strFileType == ".xls") |
---|
| 48 | $ContentType = "application/vnd.ms-excel"; |
---|
| 49 | if ($strFileType == ".gif") |
---|
| 50 | $ContentType = "image/gif"; |
---|
| 51 | if ($strFileType == ".jpg" || $strFileType == "jpeg") |
---|
| 52 | $ContentType = "image/jpeg"; |
---|
| 53 | if ($strFileType == ".wav") |
---|
| 54 | $ContentType = "audio/wav"; |
---|
| 55 | if ($strFileType == ".mp3") |
---|
| 56 | $ContentType = "audio/mpeg3"; |
---|
| 57 | if ($strFileType == ".mpg" || $strFileType == "mpeg") |
---|
| 58 | $ContentType = "video/mpeg"; |
---|
| 59 | if ($strFileType == ".rtf") |
---|
| 60 | $ContentType = "application/rtf"; |
---|
| 61 | if ($strFileType == ".htm" || $strFileType == "html") |
---|
| 62 | $ContentType = "text/html"; |
---|
| 63 | if ($strFileType == ".xml") |
---|
| 64 | $ContentType = "text/xml"; |
---|
| 65 | if ($strFileType == ".xsl") |
---|
| 66 | $ContentType = "text/xsl"; |
---|
| 67 | if ($strFileType == ".css") |
---|
| 68 | $ContentType = "text/css"; |
---|
| 69 | if ($strFileType == ".php") |
---|
| 70 | $ContentType = "text/php"; |
---|
| 71 | if ($strFileType == ".asp") |
---|
| 72 | $ContentType = "text/asp"; |
---|
| 73 | if ($strFileType == ".pdf") |
---|
| 74 | $ContentType = "application/pdf"; |
---|
| 75 | if ($strFileType == ".txt") |
---|
| 76 | $ContentType = "text/plain"; |
---|
| 77 | if ($strFileType == ".log") |
---|
| 78 | $ContentType = "text/plain"; |
---|
| 79 | if ($strFileType == ".wmv") |
---|
| 80 | $ContentType = "video/x-ms-wmv"; |
---|
| 81 | if ($strFileType == ".sxc") |
---|
| 82 | $ContentType = "application/vnd.sun.xml.calc"; |
---|
| 83 | if ($strFileType == ".odt") |
---|
| 84 | $ContentType = "application/vnd.oasis.opendocument.text"; |
---|
| 85 | if ($strFileType == ".stc") |
---|
| 86 | $ContentType = "application/vnd.sun.xml.calc.template"; |
---|
| 87 | if ($strFileType == ".sxd") |
---|
| 88 | $ContentType = "application/vnd.sun.xml.draw"; |
---|
| 89 | if ($strFileType == ".std") |
---|
| 90 | $ContentType = "application/vnd.sun.xml.draw.template"; |
---|
| 91 | if ($strFileType == ".sxi") |
---|
| 92 | $ContentType = "application/vnd.sun.xml.impress"; |
---|
| 93 | if ($strFileType == ".sti") |
---|
| 94 | $ContentType = "application/vnd.sun.xml.impress.template"; |
---|
| 95 | if ($strFileType == ".sxm") |
---|
| 96 | $ContentType = "application/vnd.sun.xml.math"; |
---|
| 97 | if ($strFileType == ".sxw") |
---|
| 98 | $ContentType = "application/vnd.sun.xml.writer"; |
---|
| 99 | if ($strFileType == ".sxq") |
---|
| 100 | $ContentType = "application/vnd.sun.xml.writer.global"; |
---|
| 101 | if ($strFileType == ".stw") |
---|
| 102 | $ContentType = "application/vnd.sun.xml.writer.template"; |
---|
| 103 | if ($strFileType == ".ps") |
---|
| 104 | $ContentType = "application/postscript"; |
---|
| 105 | if ($strFileType == ".pps") |
---|
| 106 | $ContentType = "application/vnd.ms-powerpoint"; |
---|
| 107 | if ($strFileType == ".odt") |
---|
| 108 | $ContentType = "application/vnd.oasis.opendocument.text"; |
---|
| 109 | if ($strFileType == ".ott") |
---|
| 110 | $ContentType = "application/vnd.oasis.opendocument.text-template"; |
---|
| 111 | if ($strFileType == ".oth") |
---|
| 112 | $ContentType = "application/vnd.oasis.opendocument.text-web"; |
---|
| 113 | if ($strFileType == ".odm") |
---|
| 114 | $ContentType = "application/vnd.oasis.opendocument.text-master"; |
---|
| 115 | if ($strFileType == ".odg") |
---|
| 116 | $ContentType = "application/vnd.oasis.opendocument.graphics"; |
---|
| 117 | if ($strFileType == ".otg") |
---|
| 118 | $ContentType = "application/vnd.oasis.opendocument.graphics-template"; |
---|
| 119 | if ($strFileType == ".odp") |
---|
| 120 | $ContentType = "application/vnd.oasis.opendocument.presentation"; |
---|
| 121 | if ($strFileType == ".otp") |
---|
| 122 | $ContentType = "application/vnd.oasis.opendocument.presentation-template"; |
---|
| 123 | if ($strFileType == ".ods") |
---|
| 124 | $ContentType = "application/vnd.oasis.opendocument.spreadsheet"; |
---|
| 125 | if ($strFileType == ".ots") |
---|
| 126 | $ContentType = "application/vnd.oasis.opendocument.spreadsheet-template"; |
---|
| 127 | if ($strFileType == ".odc") |
---|
| 128 | $ContentType = "application/vnd.oasis.opendocument.chart"; |
---|
| 129 | if ($strFileType == ".odf") |
---|
| 130 | $ContentType = "application/vnd.oasis.opendocument.formula"; |
---|
| 131 | if ($strFileType == ".odi") |
---|
| 132 | $ContentType = "application/vnd.oasis.opendocument.image"; |
---|
| 133 | if ($strFileType == ".ndl") |
---|
| 134 | $ContentType = "application/vnd.lotus-notes"; |
---|
| 135 | |
---|
| 136 | $mime_type = ($UserBrowser == 'IE' || $UserBrowser == 'Opera') ? 'application/octetstream' : 'application/octet-stream'; |
---|
| 137 | |
---|
| 138 | header("Content-Type: $ContentType"); |
---|
| 139 | header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); |
---|
| 140 | header("Pragma: public"); |
---|
| 141 | header("Expires: 0"); |
---|
| 142 | header("Content-Disposition: attachment; filename=\"" . $NameFile[1] . "\""); |
---|
| 143 | header("Content-length: " . $size); |
---|
| 144 | readfile(ini_get("session.save_path") . "/" . $file); |
---|
| 145 | die(); |
---|
| 146 | } |
---|
| 147 | } |
---|
| 148 | } |
---|
| 149 | |
---|
| 150 | if(isset ($_REQUEST['file'])){ |
---|
| 151 | $obj_down = new download(); |
---|
| 152 | $obj_down->Decode_String($_REQUEST['file']); |
---|
| 153 | } |
---|
| 154 | |
---|
| 155 | ?> |
---|