Nessuna descrizione

controller.php 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. session_start();
  3. $cmd = isset($_GET["cmd"]) ? $_GET["cmd"] : null;
  4. include "../dompdf_config.inc.php";
  5. include "functions.inc.php";
  6. switch ($cmd) {
  7. case "clear-font-cache":
  8. $files = glob(DOMPDF_FONT_CACHE."*.{UFM,AFM,ufm,afm}.php", GLOB_BRACE);
  9. foreach($files as $file) {
  10. unlink($file);
  11. }
  12. break;
  13. case "install-font":
  14. if (!auth_ok()) break;
  15. $family = $_POST["family"];
  16. $data = $_FILES["file"];
  17. foreach($data["error"] as $name => $error) {
  18. if ($error) {
  19. switch($error) {
  20. case UPLOAD_ERR_INI_SIZE:
  21. case UPLOAD_ERR_FORM_SIZE:
  22. echo "The uploaded file exceeds the upload_max_filesize directive in php.ini."; break;
  23. case UPLOAD_ERR_PARTIAL:
  24. echo "The uploaded file was only partially uploaded."; break;
  25. case UPLOAD_ERR_NO_FILE:
  26. break;
  27. case UPLOAD_ERR_NO_TMP_DIR:
  28. echo "Missing a temporary folder."; break;
  29. default:
  30. echo "Unknown error";
  31. }
  32. continue;
  33. }
  34. $weight = "normal";
  35. $style = "normal";
  36. switch($name) {
  37. case "bold":
  38. $weight = "bold"; break;
  39. case "italic":
  40. $style = "italic"; break;
  41. case "bold_italic":
  42. $weight = "bold";
  43. $style = "italic";
  44. break;
  45. }
  46. $style_arr = array(
  47. "family" => $family,
  48. "weight" => $weight,
  49. "style" => $style,
  50. );
  51. Font_Metrics::init();
  52. if (!Font_Metrics::register_font($style_arr, $data["tmp_name"][$name])) {
  53. echo htmlentities($data["name"][$name])." is not a valid font file";
  54. }
  55. else {
  56. $font_view = htmlentities("$family $weight $style");
  57. echo "The <strong>$font_view</strong> font was successfully installed !<br />";
  58. }
  59. }
  60. break;
  61. }