fork download
  1. <?php
  2.  
  3. class PostInstall {
  4.  
  5. static function install($sources)
  6. {
  7. $files = self::getAllFiles($sources);
  8. self::copy($files);
  9.  
  10. }
  11.  
  12. static function getAllFiles($sources)
  13. {
  14. $result = [];
  15. foreach ($sources as $source) {
  16. if (is_dir($source)) {
  17. foreach (new DirectoryIterator($source) as $fileInfo) {
  18. if($fileInfo->isDot()) continue;
  19. $result[] = $fileInfo->getPathname();
  20. }
  21. } else {
  22. $result[] = $source;
  23. }
  24. }
  25. return $result;
  26. }
  27.  
  28. static function copy($files)
  29. {
  30. foreach ($files as $file)
  31. {
  32. $extension = pathinfo($file, PATHINFO_EXTENSION);
  33. if (strcmp($extension, "js") === 0) {
  34. $path = __DIR__ . "/public/media/js";
  35. } elseif (strcmp($extension, "css") === 0 ) {
  36. $path = __DIR__ . "/public/media/css";
  37. } else {
  38. $path = __DIR__ . "/public/media/fonts";
  39. }
  40. if (!is_dir($path)) {
  41. mkdir($path, 0700, true);
  42. }
  43. copy($file, $path . "/" . basename($file));
  44. }
  45. }
  46. }
  47.  
  48. $sources = [
  49. __DIR__ . "/vendor/videojs/video.js/dist/video.min.js",
  50. __DIR__ . "/vendor/videojs/video.js/dist/video-js.min.css",
  51. __DIR__ . "/vendor/videojs/video.js/dist/font/",
  52. __DIR__ . "/vendor/twbs/bootstrap/dist/css/bootstrap.min.css",
  53. __DIR__ . "/vendor/twbs/bootstrap/dist/js/bootstrap.min.js",
  54. __DIR__ . "/vendor/twbs/bootstrap/dist/fonts/"
  55. ];
  56.  
  57. PostInstall::install($sources);
Success #stdin #stdout #stderr 0.02s 52504KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
PHP Warning:  mkdir(): Permission denied in /home/GtLWB0/prog.php on line 41
PHP Warning:  copy(/home/GtLWB0/vendor/videojs/video.js/dist/video.min.js): failed to open stream: No such file or directory in /home/GtLWB0/prog.php on line 43
PHP Warning:  mkdir(): Permission denied in /home/GtLWB0/prog.php on line 41
PHP Warning:  copy(/home/GtLWB0/vendor/videojs/video.js/dist/video-js.min.css): failed to open stream: No such file or directory in /home/GtLWB0/prog.php on line 43
PHP Warning:  mkdir(): Permission denied in /home/GtLWB0/prog.php on line 41
PHP Warning:  copy(/home/GtLWB0/vendor/videojs/video.js/dist/font/): failed to open stream: No such file or directory in /home/GtLWB0/prog.php on line 43
PHP Warning:  mkdir(): Permission denied in /home/GtLWB0/prog.php on line 41
PHP Warning:  copy(/home/GtLWB0/vendor/twbs/bootstrap/dist/css/bootstrap.min.css): failed to open stream: No such file or directory in /home/GtLWB0/prog.php on line 43
PHP Warning:  mkdir(): Permission denied in /home/GtLWB0/prog.php on line 41
PHP Warning:  copy(/home/GtLWB0/vendor/twbs/bootstrap/dist/js/bootstrap.min.js): failed to open stream: No such file or directory in /home/GtLWB0/prog.php on line 43
PHP Warning:  mkdir(): Permission denied in /home/GtLWB0/prog.php on line 41
PHP Warning:  copy(/home/GtLWB0/vendor/twbs/bootstrap/dist/fonts/): failed to open stream: No such file or directory in /home/GtLWB0/prog.php on line 43