function convert() { $fileName = $_GET["filename"]; $extension = strtolower(pathinfo($fileName, PATHINFO_EXTENSION)); $internalExtension = trim(getInternalExtension($fileName), '.'); if (in_array("." + $extension, $GLOBALS['DOC_SERV_CONVERT']) && $internalExtension != "") { $fileUri = $_GET["fileUri"]; if ($fileUri == "") { $fileUri = FileUri($fileName); } $key = GenerateRevisionId($fileUri); $newFileUri; $result; $percent; try { $percent = GetConvertedUri($fileUri, $extension, $internalExtension, $key, TRUE, $newFileUri); } catch (Exception $e) { $result["error"] = "error: " . $e->getMessage(); return $result; } if ($percent != 100) { $result["step"] = $percent; $result["filename"] = $fileName; $result["fileUri"] = $fileUri; return $result; } $baseNameWithoutExt = substr($fileName, 0, strlen($fileName) - strlen($extension) - 1); $newFileName = GetCorrectName($baseNameWithoutExt . "." . $internalExtension); if (($data = file_get_contents(str_replace(" ", "%20", $newFileUri))) === FALSE) { $result["error"] = 'Bad Request'; return $result; } else { file_put_contents(getStoragePath($newFileName), $data, LOCK_EX); } unlink(getStoragePath($fileName)); $fileName = $newFileName; } $result["filename"] = $fileName; return $result; }
$filename; $fileuri; $externalUrl = $_GET["fileUrl"]; if (!empty($externalUrl)) { $filename = DoUpload($externalUrl); } else { $filename = $_GET["fileID"]; } $type = $_GET["type"]; if (!empty($type)) { $filename = tryGetDefaultByType($type); $new_url = "doceditor.php?fileID=" . $filename; header('Location: ' . $new_url, true); exit; } $fileuri = FileUri($filename); function tryGetDefaultByType($type) { $ext; switch ($type) { case "document": $ext = ".docx"; break; case "spreadsheet": $ext = ".xlsx"; break; case "presentation": $ext = ".pptx"; break; default: return;