147 | | // Unzip package to working directory |
148 | | $result = unzip_file($package, $working_dir); //TODO optimizations, Copy when Move/Rename would suffice? |
| 147 | $extension = pathinfo($package, PATHINFO_EXTENSION); |
| 148 | |
| 149 | // Make uploading a PHP file instead of a zip archive possible |
| 150 | if ( $extension == 'php' ) { |
| 151 | // Create a new folder |
| 152 | mkdir($working_dir); |
| 153 | |
| 154 | // Copy the PHP file into the new foler |
| 155 | $result = rename($package, $working_dir . '/' . basename($package)); |
| 156 | } else { |
| 157 | // Unzip package to working directory |
| 158 | $result = unzip_file($package, $working_dir); //TODO optimizations, Copy when Move/Rename would suffice? |
| 159 | |
| 160 | // Once extracted, delete the package if required. |
| 161 | if ( $delete_package ) |
| 162 | unlink($package); |
| 163 | } |