Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. <?php
  2. class PhpCompatStream
  3. {
  4. private $handle = null;
  5.  
  6. function stream_open($path, $mode, $options, &$opened_path)
  7. {
  8. $this->handle = fopen(substr($path, 5), $mode, $options);
  9. return true;
  10. }
  11.  
  12. function stream_read($count)
  13. {
  14. return str_replace(
  15. array('<?=', '<? ', "<?\n", "<?\r", "<?\t"),
  16. array('<?php echo ', '<?php ', "<?php\n", "<?php\r", "<?php\t"),
  17. fread($this->handle, $count)
  18. );
  19. }
  20.  
  21. function stream_write($data)
  22. {
  23. return fwrite($this->handle, $data);
  24. }
  25.  
  26. function stream_tell()
  27. {
  28. return ftell($this->handle);
  29. }
  30.  
  31. function stream_eof()
  32. {
  33. return feof($this->handle);
  34. }
  35.  
  36. function stream_seek($offset, $whence)
  37. {
  38. return fseek($offset, $whence);
  39. }
  40. }
  41.  
  42. stream_wrapper_register('pc', 'PhpCompatStream');
  43.  
  44. include 'pc://./test.php';
  45. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement