| @@ -2,8 +2,9 @@ | ||
| 2 | 2 | |
| 3 | 3 | namespace ImportWP\Common\Exporter\File; |
| 4 | 4 | |
| 5 | 5 | use ImportWP\Common\Model\ExporterModel; |
| 6 | +use ImportWP\Container; | |
| 6 | 7 | |
| 7 | 8 | class File |
| 8 | 9 | { |
| 9 | 10 | /** |
| @@ -65,17 +66,44 @@ | ||
| 65 | 66 | } |
| 66 | 67 | |
| 67 | 68 | public function get_file_path() |
| 68 | 69 | { |
| 69 | - $path = WP_CONTENT_DIR . DIRECTORY_SEPARATOR . 'uploads' . DIRECTORY_SEPARATOR . 'exportwp' . DIRECTORY_SEPARATOR; | |
| 70 | + /** | |
| 71 | + * @var \ImportWP\Common\Filesystem\Filesystem $filesystem | |
| 72 | + */ | |
| 73 | + $filesystem = Container::getInstance()->get('filesystem'); | |
| 74 | + | |
| 75 | + $path = wp_normalize_path($filesystem->get_temp_directory(false, 'exportwp')); | |
| 70 | 76 | if (!file_exists($path)) { |
| 71 | 77 | mkdir($path); |
| 72 | 78 | } |
| 73 | 79 | |
| 74 | - return $path . $this->get_file_name(); | |
| 80 | + if (!file_exists($path . '/.htaccess')) { | |
| 81 | + file_put_contents($path . '/.htaccess', "# Apache 2.4+ | |
| 82 | +<IfModule mod_authz_core.c> | |
| 83 | + Require all denied | |
| 84 | +</IfModule> | |
| 85 | + | |
| 86 | +# Apache 2.2 and older (or when mod_authz_core isn't available) | |
| 87 | +<IfModule !mod_authz_core.c> | |
| 88 | + Deny from all | |
| 89 | +</IfModule>"); | |
| 90 | + } | |
| 91 | + | |
| 92 | + if (!file_exists($path . '/index.html')) { | |
| 93 | + touch($path . '/index.html'); | |
| 94 | + } | |
| 95 | + | |
| 96 | + return $path . '/' . $this->get_file_name(); | |
| 75 | 97 | } |
| 76 | 98 | |
| 77 | 99 | public function get_file_url() |
| 78 | 100 | { |
| 79 | - return content_url('/uploads/exportwp/' . $this->get_file_name()); | |
| 101 | + /** | |
| 102 | + * @var \ImportWP\Common\Filesystem\Filesystem $filesystem | |
| 103 | + */ | |
| 104 | + $filesystem = Container::getInstance()->get('filesystem'); | |
| 105 | + $url = $filesystem->get_temp_directory(true, 'exportwp'); | |
| 106 | + | |
| 107 | + return $url . '/' . $this->get_file_name(); | |
| 80 | 108 | } |
| 81 | 109 | } |