header('Content-Type: audio/mpeg'); break; case 'woff': header('Content-Type: application/font-woff'); break; case 'ttf': header('Content-Type: application/x-font-ttf'); break; case 'eot': header('Content-Type: application/vnd.ms-fontobject'); break; case 'svg': header('Content-Type: image/svg+xml'); break; default: header('Content-Type: ' . getFileMIME($path)); } } // Read the text file(s) (CSS & JS) if ($type == 'stylesheets' || $type == 'javascripts') { // Storage vars $last_modified = $output_data = null; // If there's a cache file, read it if (hasCache($cache_lang) && !$is_developer) { $last_modified = filemtime(pathCache($cache_lang)); $cache_read = readCache($cache_lang); if ($deflate_support || !$has_compression) { $output_data = $cache_read; } else { $output_data = gzinflate($cache_read); }
} // Resize and compress if this is a JPEG file if (preg_match('/^(jpg|jpeg|png|gif)$/i', $ext)) { // Image thumbnail path $thumb = $content_dir . '/' . $name . '_thumb.' . $ext; $thumb_first_upload = !file_exists($thumb); // Resize only if first time file is uploaded if ($file_first_upload) { // Resize the image resizeImage($path, $ext, 1024, 1024); // Copy the image copy($path, $thumb); } // Create the thumbnail (only once) if (!$thumb_first_upload || resizeImage($thumb, $ext, 140, 105, 'square')) { $thumb_xml = '<thumb>' . htmlspecialchars($location . 'store/share/' . $user . '/' . $name . '_thumb.' . $ext) . '</thumb>'; } } // Return the path to the file exit('<jappix xmlns=\'jappix:file:post\'> <href>' . htmlspecialchars($location . 'store/share/' . $user . '/' . $name . '.' . $ext) . '</href> <title>' . htmlspecialchars($new_name) . '</title> <type>' . htmlspecialchars(getFileMIME($path)) . '</type> <length>' . htmlspecialchars(filesize($path)) . '</length> ' . $thumb_xml . ' </jappix>'); } // Bad request error! exit('<jappix xmlns=\'jappix:file:post\'> <error>bad-request</error> </jappix>');