PHP online compression and decompression of SWF file code (fixed version)

Source: Internet
Author: User
Tags fread php online
    1. //-----------------
    2. Filename
    3. $filename = "test.swf";
    4. Open File
    5. $rs = fopen ($filename, "R");
    6. Reading data from a file
    7. $str = Fread ($rs, FileSize ($filename));
    8. Set SWF header File
    9. $head = substr ($str, 0, 8);
    10. $head [0] = ' F ';
    11. Get SWF file contents
    12. $body = substr ($STR, 8);
    13. Compress the contents of a file using the highest compression level 9
    14. $body = Gzcompress ($body, 9);
    15. Merging file headers and contents
    16. $str = $head. $body;
    17. Close the Read file stream
    18. Fclose ($RS);
    19. Create a new file
    20. $ws = fopen ("create.swf", "w");
    21. Write a file
    22. Fwrite ($ws, $STR);
    23. Close file leave
    24. Fclose ($WS);
    25. //-------------------
    26. ?>
Copy Code

2. Unzip the SWF file online

  1. //-------------------
  2. Filename
  3. $filename = "1000109.swf";
  4. Open File
  5. $rs = fopen ($filename, "R");
  6. Reading data from a file
  7. $str = Fread ($rs, FileSize ($filename));
  8. Set SWF header File
  9. $head = substr ($str, 0, 8);
  10. $head = ' F '. $head;
  11. $head [0] = ' F ';
  12. /* $head [1] = (' W ');
  13. $head [2] = (' S ');
  14. $head [3] = version;
  15. $head [4] = ($str% 256);
  16. $head [5] = ($STR/256 256);
  17. $head [6] = ($str/256/256% 256);
  18. $head [7] = ($str/256/256/256% 256); */
  19. Get SWF file contents
  20. $body = substr ($STR, 8);
  21. Unzip the contents of a file
  22. $body = gzuncompress ($body);
  23. Merging file headers and contents
  24. $str = $head. $body;
  25. Close the Read file stream
  26. Fclose ($RS);
  27. Create a new file
  28. $ws = fopen ("create.swf", "w");
  29. Write a file
  30. Fwrite ($ws, $STR);
  31. Close file leave
  32. Fclose ($WS);
  33. //-------------------
  34. ?>
Copy Code
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.