CdataStrategy.php
4 years ago
CdataStrategyAlways.php
4 years ago
CdataStrategyFactory.php
4 years ago
CdataStrategyIllegalCharacters.php
4 years ago
CdataStrategyIllegalCharactersHtmlEntities.php
4 years ago
CdataStrategyNever.php
4 years ago
XMLWriter.php
4 years ago
chunk.php
4 years ago
config.php
4 years ago
download.php
4 years ago
handler.php
4 years ago
helper.php
4 years ago
input.php
4 years ago
installer.php
4 years ago
session.php
4 years ago
wpallimport.php
4 years ago
zip.php
4 years ago
download.php
58 lines
| 1 | <?php |
| 2 | |
| 3 | class PMXE_Download |
| 4 | { |
| 5 | |
| 6 | static public function zip($file_name) |
| 7 | { |
| 8 | $uploads = wp_upload_dir(); |
| 9 | $bundle_url = $uploads['baseurl'] . str_replace($uploads['basedir'], '', $file_name); |
| 10 | $bundle_url = str_replace( "\\", "/", $bundle_url ); |
| 11 | wp_redirect($bundle_url); |
| 12 | die; |
| 13 | } |
| 14 | |
| 15 | static public function xls($file_name) |
| 16 | { |
| 17 | self::sendFile("Content-Type: application/vnd.ms-excel; charset=UTF-8", $file_name); |
| 18 | } |
| 19 | |
| 20 | static public function xlsx($file_name) |
| 21 | { |
| 22 | self::sendFile("Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; charset=UTF-8", $file_name); |
| 23 | } |
| 24 | |
| 25 | static public function csv($file_name) |
| 26 | { |
| 27 | self::sendFile("Content-Type: text/plain; charset=UTF-8", $file_name); |
| 28 | } |
| 29 | |
| 30 | static public function txt($file_name) |
| 31 | { |
| 32 | self::sendFile("Content-Type: text/plain; charset=UTF-8", $file_name); |
| 33 | } |
| 34 | |
| 35 | static public function xml($file_name) |
| 36 | { |
| 37 | self::sendFile("Content-Type: application/xhtml+xml; charset=UTF-8", $file_name); |
| 38 | } |
| 39 | |
| 40 | static public function sendFile($header, $file_name) |
| 41 | { |
| 42 | // If we ar testing don't sent it as attachment |
| 43 | if (php_sapi_name() != 'cli-server') { |
| 44 | header($header); |
| 45 | header("Content-Disposition: attachment; filename=\"" . basename($file_name) . "\""); |
| 46 | header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0"); |
| 47 | header("Cache-Control: post-check=0, pre-check=0", false); |
| 48 | header("Pragma: no-cache"); |
| 49 | } |
| 50 | while (ob_get_level()) { |
| 51 | ob_end_clean(); |
| 52 | } |
| 53 | |
| 54 | readfile($file_name); |
| 55 | die; |
| 56 | } |
| 57 | |
| 58 | } |