zip.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. $container_guid = (int) get_input("container_guid", 0);
  3. $parent_guid = get_input("parent_guid");
  4. set_time_limit(0);
  5. $forward_url = REFERER;
  6. if (!empty($container_guid) && get_uploaded_file("zip_file")) {
  7. $extension_array = explode(".", $_FILES["zip_file"]["name"]);
  8. if (strtolower(end($extension_array)) == "zip") {
  9. $file = $_FILES["zip_file"];
  10. // disable notifications of new objects
  11. elgg_unregister_notification_event('object', 'file');
  12. if (file_tools_unzip($file, $container_guid, $parent_guid)) {
  13. system_message(elgg_echo("file:saved"));
  14. $container = get_entity($container_guid);
  15. if (elgg_instanceof($container, "group")) {
  16. $forward_url = "file/group/" . $container->getGUID() . "/all#" . $parent_guid;
  17. } else {
  18. $forward_url = "file/owner/" . $container->username . "#" . $parent_guid;
  19. }
  20. } else {
  21. register_error(elgg_echo("file:uploadfailed"));
  22. }
  23. // reenable notifications of new objects
  24. elgg_register_notification_event('object', 'file', array('create'));
  25. } else {
  26. register_error(elgg_echo("file:uploadfailed"));
  27. }
  28. } else {
  29. register_error(elgg_echo("file:cannotload"));
  30. }
  31. forward($forward_url);