PageRenderTime 40ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-content/plugins/backupbuddy/_docgen.php

https://bitbucket.org/betaimages/chakalos
PHP | 77 lines | 53 code | 19 blank | 5 comment | 6 complexity | 589d1f247d4fdee99f3a741009281110 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. <html>
  2. <head>
  3. <style type="text/css">
  4. .comment_block {
  5. border: 1px solid #CCCCCC;
  6. -webkit-border-radius: 3px;
  7. -moz-border-radius: 3px;
  8. border-radius: 3px;
  9. padding: 5px;
  10. background: #EEEEEE;
  11. }
  12. </style>
  13. </head>
  14. <?php
  15. $path = dirname( __FILE__ ) . '/*.php';
  16. //$path = dirname( __FILE__ ) . '/_pluginbuddy.php';
  17. // Does not support flag GLOB_BRACE
  18. function glob_recursive($pattern, $flags = 0) {
  19. $files = glob($pattern, $flags);
  20. foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR|GLOB_NOSORT) as $dir) {
  21. $files = array_merge($files, glob_recursive($dir.'/'.basename($pattern), $flags));
  22. }
  23. return $files;
  24. }
  25. echo 'Looking for PHP files with pattern: ' . $path .'<br>';
  26. $files = glob_recursive( $path );
  27. echo 'Found ' . count( $files ) . ' files matching pattern. All files listed relative to path of this file.';
  28. //echo '<pre>' . print_r( $files, true ) . '</pre>';
  29. foreach( $files as $file ) {
  30. echo '<hr>';
  31. echo '<h1>File: ' . str_replace( dirname( __FILE__ ), '', $file ) . '</h1>';
  32. //if ( strstr(
  33. $contents = file( $file );
  34. $in_comment_block = false; // True when inside a comment block /* ... */ (can be multiple lines).
  35. $in_class = ''; // Blank when not in a class; class name when in a class.
  36. $comment_block_contents = '';
  37. foreach( $contents as $content ) {
  38. if ( false !== strpos( $content, '/*' ) ) {
  39. $in_comment_block = true;
  40. $comment_block_contents = '';
  41. } // end checking for start of comment block.
  42. // Parse things NOT in comment blocks:
  43. if ( false === $in_comment_block ) {
  44. if ( ( false !== strpos( $content, 'class ' ) ) && ( false !== strpos( $content, ' {' ) ) ) { // todo: needs more specificity to avoid false positives.
  45. $in_class = substr( $content, strpos( $content, 'class ' ) + 6, -2 );
  46. echo '<h2>Class: ' . $in_class . '</h2>';
  47. }
  48. }
  49. if ( true === $in_comment_block ) {
  50. $comment_block_contents .= $content;
  51. } // end if in comment block.
  52. if ( false !== strpos( $content, '*/' ) ) {
  53. echo '<pre class="comment_block">' . print_r( $comment_block_contents, true ) . '</pre>';
  54. $in_comment_block = false;
  55. } // end checking for end of comment block.
  56. }
  57. }
  58. ?>