Guest User

Untitled

a guest
May 25th, 2018
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. <?php
  2. $changes = array( );
  3. $touched = array( );
  4. $files = array( '1.txt', '2.txt', '3.txt' );
  5. $totalchanged = 0;
  6. $totaltouched = 0;
  7.  
  8. $author = '';
  9. foreach( $files as $file )
  10. {
  11. $c = file( $file );
  12. foreach( $c as $o )
  13. {
  14. $o = trim( $o );
  15. if( $o == '' ) { }
  16. elseif( strpos( $o, "\t" ) === false )
  17. {
  18. $author = $o;
  19. if( $author == 'Fenix1053' )
  20. $author = 'Fenix';
  21. elseif( $author == 'CCarlon' )
  22. $author = 'CC';
  23.  
  24. if( !isset( $changes[ $author ] ) )
  25. $changes[ $author ] = 0;
  26. if( !isset( $touched[ $author ] ) )
  27. $touched[ $author ] = 0;
  28. }
  29. else
  30. {
  31. $x = explode( "\t", $o );
  32. if( $x[0] != '-' )
  33. {
  34. $changes[ $author ] += $x[0] + $x[1];
  35. $totalchanged += $x[0] + $x[1];
  36. }
  37. else
  38. {
  39. $touched[ $author ] ++;
  40. $totaltouched++;
  41. }
  42. }
  43. }
  44. }
  45.  
  46. arsort( $changes );
  47. foreach( $changes as $author => $changed )
  48. {
  49. echo $author . ': ' . $changed . ' (' . round( $changed / $totalchanged * 100, 2 ) . '%) lines, ' . $touched[ $author ] . ' (' . round( $touched[ $author ] / $totaltouched * 100, 2 ) . '%) files' . "\n";
  50. }
  51. ?>
Add Comment
Please, Sign In to add comment