PageRenderTime 55ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/trunk/jfx-private/modules/core/actions/dev-stats.php

http://jfxcms.googlecode.com/
PHP | 106 lines | 49 code | 37 blank | 20 comment | 27 complexity | 769eff33b78f44ca5d246b98a129763a MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1
  1. <?php
  2. ############### COPYLEFT GPLv3 LICENSE ###############
  3. ##
  4. ## JFX Version 0.2.9
  5. ## Website Management Software
  6. ## www.jfxcms.com
  7. ##
  8. ## Copyright 2009 GPLv3 - http://www.opensource.org/licenses/gpl-3.0.html
  9. ##
  10. ## Anthony Gallon
  11. ## oi_antz@hotmail.com
  12. ##
  13. ## Permission is hereby granted to any person having a copy of this software
  14. ## to freely use and modify as required so long as the copyright notices
  15. ## and branding remain intact.
  16. ##
  17. ## Full license details available at http://www.jfxcms.com/license
  18. ##
  19. ############### COPYLEFT GPLv3 LICENSE ###############
  20. $THEME->addBreadcrumb($this->adminUrl.'/dev-stats/', $this->lang('ap_title_dev-stats'));
  21. $dir = $CONFIG->publicDir;
  22. $numFiles = countFiles($dir, 'php');
  23. echo $numFiles.' files in the website <br />';
  24. $numLines = countLines($dir, 'php');
  25. echo $numLines.' lines in the website<br />';
  26. function countLines($dir, $ext=''){
  27. $num = 0;
  28. $dh = opendir($dir);
  29. while($file = readdir($dh)){
  30. if($file == '.' || $file == '..') continue;
  31. if($ext != '' && !is_dir($dir.'/'.$file)){
  32. $pathInfo = pathinfo($dir.'/'.$file);
  33. if(array_key_exists('extension', $pathInfo) && $pathInfo['extension']==$ext){
  34. // bingo!
  35. $fc = file_get_contents($dir.'/'.$file);
  36. $lines = explode("\n", $fc);
  37. $num += count($lines);
  38. }
  39. }else if($ext == '' && is_file($dir.'/'.$file)){
  40. $fc = file_get_contents($dir.'/'.$file);
  41. $lines = explode("\n", $fc);
  42. $num += count($lines);
  43. };
  44. if(is_dir($dir.'/'.$file)){
  45. $num += countLines($dir.'/'.$file, $ext);
  46. }
  47. };
  48. return $num;
  49. }
  50. function countFiles($dir, $ext=''){
  51. $num = 0;
  52. $dh = opendir($dir);
  53. while($file = readdir($dh)){
  54. if($file == '.' || $file == '..') continue;
  55. if($ext != '' && !is_dir($dir.'/'.$file)){
  56. $pathInfo = pathinfo($dir.'/'.$file);
  57. if(array_key_exists('extension', $pathInfo) && $pathInfo['extension']==$ext){
  58. // bingo!
  59. $num ++;
  60. }
  61. }else if($ext == '' && file_exists($dir.'/'.$file) && !is_dir($dir.'/'.$file)){
  62. $num++;
  63. };
  64. if(is_dir($dir.'/'.$file)){
  65. $num += countFiles($dir.'/'.$file, $ext);
  66. }
  67. };
  68. return $num;
  69. }