You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

local.php 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. # Use the interface
  3. require 'sieve_transfer.php';
  4. class LocalTransfer extends SieveTransfer
  5. {
  6. public function LoadScript($path)
  7. {
  8. $content = '';
  9. if ( file_exists($path) )
  10. $content = file_get_contents($path);
  11. return $content;
  12. }
  13. public function SaveScript($path,$script)
  14. {
  15. $success = false;
  16. $folder = pathinfo($path,PATHINFO_DIRNAME);
  17. $try = true;
  18. # Create the folder if not exists
  19. if ( !is_dir($folder) )
  20. $try = @mkdir($folder,true);
  21. if ( !$try )
  22. {
  23. $msg = sprintf('Cannot create folder "%s" to save the script.', $folder);
  24. throw new Exception($msg);
  25. }
  26. # Copy the script
  27. $bytes = @file_put_contents($path,$script);
  28. $success = ($bytes != false);
  29. if ( !$success )
  30. {
  31. $msg = sprintf('Cannot write file "%s" to save the script.', $path);
  32. throw new Exception($msg);
  33. }
  34. # Compile the script
  35. if ( $success )
  36. $success = (system("$this->params['sievecbin'] $path") == 0);
  37. return $success;
  38. }
  39. }