jargon

PHP BSave Loader: broken CVShort function

Nov 25th, 2021 (edited)
421
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. Fatal error: Uncaught TypeError: Unsupported operand types: array & int in C:\xampp8\htdocs\Mind_Realm_Web_Builder\php\bsave support.php:53 Stack trace: #0 C:\xampp8\htdocs\Mind_Realm_Web_Builder\php\super bsave.php(38): load_bsave('C:/xampp8/htdoc...') #1 C:\xampp8\htdocs\Mind_Realm_Web_Builder\mk11SUPER.php(6): super_bsave() #2 {main} thrown in C:\xampp8\htdocs\Mind_Realm_Web_Builder\php\bsave support.php on line 53
  2.  
  3. ===
  4.  
  5. <?php
  6.  
  7. function cvshort( $subject = '' )
  8. {
  9. return unpack("S", $subject);
  10. }
  11.  
  12. function load_bsave( $filename = '' )
  13. {
  14. $z = intval(0);
  15. $w = intval(0);
  16. $h = intval(0);
  17. $x = intval(0);
  18. $y = intval(0);
  19. $b = intval(0);
  20. $cb = intval(0);
  21.  
  22.  
  23. //dim as integer filemode = freefile
  24. $header = '';
  25. $buffer = '';
  26.  
  27. $ret = '';
  28.  
  29. if( !is_file( $filename ) )
  30. {
  31. $image = imagecreate( 24, 24);
  32. for( $offset = 0; $offset <= 5; $offset++ )
  33. {
  34. switch( $offset & 1 )
  35. {
  36. case 0:
  37. imageline( $image, 5-$offset, 0, 23-$offset, 23,12 ); // ,,&HAAAA
  38. case 1:
  39. imageline( $image, 23-$offset, 0, 5-$offset, 23,12 ); // ,,&HAAAA
  40. }
  41. }
  42. return $image;
  43. }
  44.  
  45. $buffer = file_get_contents( $filename );
  46.  
  47. $header = substr( $buffer, 0, 11 );
  48. $buffer = substr( $buffer, strlen( $header ) + 1 );
  49.  
  50. $magic = substr( $header, 0, 1 );
  51.  
  52. if( ord( $magic ) !== 0xFD )
  53. {
  54. return false;
  55. }
  56.  
  57. $z = cvshort( substr( $header, 5 , 2 ) ) & 32767;
  58. $w = cvshort( substr( $header, 7 , 2 ) ) & 32767;
  59. $h = cvshort( substr( $header, 9 , 2 ) ) & 32767;
  60.  
  61. if( ( $w === 25 ) && ( $h === 25 ) )
  62. {
  63. $image = imagecreate( 24, 24 );
  64. }
  65. else
  66. {
  67. $image = imagecreate( $w, $h );
  68. }
  69.  
  70. for( $y = 0; $y < $h; $y++ )
  71. {
  72. for( $b = 0; $b < 4; $b++ )
  73. {
  74. for( $x = 0; $x < $w; $x++ )
  75. {
  76. if( ($x & 7) === 0 )
  77. {
  78. $cb = ord( substr( $buffer, 0, 1 ) );
  79. $buffer = substr( $buffer, 1 );
  80. }
  81.  
  82. imagesetpixel( $image, $x, $y, imagecolorat( $image, $x, $y ) ^ ( ( 1 << $b ) & intdiv( -$cb, 0x80 ) ) );
  83.  
  84. $cb += $cb & 0xFF;
  85.  
  86. }
  87. }
  88. }
  89.  
  90. return $image;
  91. }
  92.  
  93. ?>
Add Comment
Please, Sign In to add comment