File:  [mozdev] / cdn / www / sources.html
Revision 1.113: download - view: text, annotated - select for diffs - revision graph
Sun Feb 23 12:46:26 2003 UTC (16 years, 8 months ago) by cdn
Branches: MAIN
CVS tags: HEAD
function/if/for tangle

    1: <?php 
    2: 
    3: // $Id: sources.html,v 1.113 2003/02/23 12:46:26 cdn Exp $
    4: 
    5:   require("include/CVS_PATHS");
    6: 
    7:   define(MAX_READ_SIZE, 500000);
    8:   define(MAX_READ, 100000);
    9: 
   10:   $today              = date("y/m/d"); // echo $today . '<p />';
   11:   $day = (int)date('d');
   12:   --$day;
   13:   $yesterday          = date("y/m/" . sprintf('%2u', $day));
   14:   $commit_log         = "cvs@$project.mozdev.org";
   15: 
   16:   if(!$local_conf_commits) {
   17:     print '<span id="CVS-local-conf-commits">' . $local_conf_commits_msg . "</span>\n";
   18:   }
   19: 
   20:  // $today              = "03/02/14";
   21:  // $today = $yesterday; // echo $today . '<p />';
   22:  // $today              = "03/02/21"; // 03/02/01
   23:  // $today = "[0-9]{2}/[0-9]{2}/[0-9]{2}";
   24: 
   25:   //BEGIN BLOCK
   26:  
   27:    if(file_exists(COMMIT_PATH.$commit_log) && $local_conf_commits) {
   28: 
   29:     $size = filesize(COMMIT_PATH.$commit_log);
   30: 
   31:    // echo $size;
   32:     
   33:     $contents = array();
   34:     if ($size > MAX_READ_SIZE) {
   35:       // print "<!-- Log File is greater than 500K -->\n";
   36: 
   37:       $fp = fopen (COMMIT_PATH.$commit_log, "r");
   38:       fseek($fp, $size - MAX_READ);
   39:       if ($contents) {
   40:         print "$contents\n";
   41:         exit;
   42:       }
   43:       $tok = strtok(fread($fp, MAX_READ),"\n");
   44:       while ($tok) {
   45:         array_push($contents, $tok);
   46:         $tok = strtok("\n");
   47:       }
   48:       fclose($fp);
   49:     }
   50:     
   51:     if (!$contents) {
   52:       $contents = file(COMMIT_PATH.$commit_log);
   53:     }
   54: 
   55:    // echo $contents[0];
   56: 
   57:     // preprocess Tag: stuff would be here if it didn't mess
   58:     // things up completely
   59: 
   60:     $len=count($contents);
   61: 
   62:    // echo $len;  
   63:     
   64:     $_project = $project;
   65:     
   66:     if ( !isset($doNotCapitalise) ) {
   67:       $_project = PROJECT;
   68:     }
   69:    
   70:     print '<h4 id="CVS-h4">' . "Today's CVS Commits for " . $_project . " Project</h4>\n";
   71:     print '<table border="0" cellpadding="0" cellspacing="2" id="CVS-table">' . "\n";
   72: 
   73:     function cvs_parse ($contents, $today, $i, $len)
   74:     {
   75:         if(ereg("  Date: $today", $contents[$i])) {
   76: 
   77:           $yy = substr(YEAR, 0, 2);
   78: 
   79:           $_timestamp = str_replace('Date: ', '', ltrim($contents[$i]));
   80:           $_timestamp = str_replace("\n", '', $_timestamp);
   81: 
   82:           $_ts_link = $yy . ereg_replace('[\ \/]', '_', $_timestamp);
   83: 
   84:           $_timestamp = '<a name="' . $_ts_link . '">'; 
   85: 
   86:           $result = '<tr class="CVS-tr-header" valign="top"><td class="CVS-td-900">' . "\n";
   87: 
   88: //who
   89:           $result .= "<strong>" . $_timestamp . htmlspecialchars($contents[$i-1]) . "</a></strong>\n" . // who
   90:           "</td></tr>\n" .
   91:           '<tr class="CVS-tr-date">' .
   92:           '<td class="CVS-td-f90">' . "\n";
   93: 
   94:           $_time = htmlspecialchars($contents[$i]);
   95: 
   96: // when
   97:           $result .= '<a class="CVS-td-f90" href="' . '#' . $_ts_link . '">' . $_time . '</a>'; // when
   98: 
   99:           $result .= "\n</td></tr>\n" .
  100:           '<tr class="CVS-tr-checkins"><td class="CVS-td-checkins">' . "\n";
  101: 
  102:           $webcvs = 'http://www.mozdev.org/source/browse/' . $project;
  103: 
  104:           for($l=$i+1;$l<$len;$l++) {
  105:             if(ereg("  Revision  Changes    Path", $contents[$l]))
  106:               break;
  107: 
  108:             if(ereg("  User:", $contents[$l]))
  109:               break;
  110: 
  111:             $checkins = eregi_replace("((https|http|mailto|ftp):\/\/[^[:space:]<>]{1,})", 
  112:             "<a href=\"\\1\">\\1</a>", htmlspecialchars($contents[$l]));
  113: 
  114:             // '  Added:       www/img  background.png' 
  115:             // '  Modified:    www      cdn.css' 
  116:             // '  Removed:     www/protected sources.html'
  117:             // '               www/compact index.html' ?
  118: 
  119:             if ( ereg("((Added|Modified|Removed):)", $checkins) || ereg("^[[:space:]]{9}", $checkins) ||
  120:                  strstr($checkins, "New directory")
  121:                ) {
  122: 
  123:               if ( !strstr($checkins, "New directory") ) {
  124:                 $identifier = trim(substr($checkins, 0, 15)); // may change to &nbsp; group
  125: 
  126:                 $checkins = substr($checkins, 15);
  127:               }
  128:               else {
  129: //              if ( strstr($checkins[$Y-2], '-') && strstr($checkins[$Y-1], 'New') && strstr($checkins[$Y], 'directory') ) {
  130:                // $checkins .= '**';
  131: 
  132:                 $checkins = str_replace('- New directory', '-_New_directory', $checkins);
  133: 		$webcvs = 'http://www.mozdev.org/source/browse';
  134:               }
  135: 
  136:               $_16 = strpos($checkins, ' ');
  137: 
  138:               $_path = substr( $checkins, 0, $_16);
  139: 
  140:               $checkins = ereg_replace('[[:space:]]{1,}', ' ', trim( substr ( $checkins, $_16 ) ) );
  141: 
  142:               $checkinsA = explode(' ', $checkins);
  143: 
  144:               unset($checkins);
  145: 
  146:               for($z=0; $z < count($checkinsA); ++$z) {
  147:                 $checkinsA[$z] = trim($checkinsA[$z]);
  148:               }
  149: 
  150:               if ( !empty($identifier) ) {
  151:                 $checkins = $identifier;
  152:               }
  153: 
  154:               if ( !empty($_path)) { //$checkins .= '!empty($_path)';
  155:                 $webcvs = 'http://www.mozdev.org/source/browse/' . $project; // reset important !
  156:                 $webcvs .= '/' . $_path;
  157:                 $_path_ = $_path;
  158:                 $checkins .= ' <a href="' . $webcvs;
  159:                 $checkins .= '">' . $_path . '</a>';
  160:               }
  161: 
  162:               $Y = count($checkinsA);
  163: 
  164:               for($y=0; $y < $Y; ++$y) {
  165: 
  166:                 if ( ereg('Tag:', $checkinsA[$y]) || ereg('Tag:', $checkinsA[$y-1]) || $_tag ||
  167:                      strstr($checkinsA[$y], '-_New_directory')
  168:                    ) {
  169:                   $TAG = true;
  170:                 }
  171:                 else {
  172:                   $TAG = false;
  173:                 }
  174: 
  175:                 if(!$TAG) {
  176:                   $checkins .= ' <a href="' . $webcvs . '/';
  177: 
  178:                   if( $identifier == 'Removed:' || $idRemoved ) {
  179:                     $checkins .= 'Attic/';
  180:                   }
  181: 
  182:                   $checkins .= $checkinsA[$y] . '">';
  183:                 }
  184:                 else {
  185:                   $checkins .= ' ';
  186:                 }
  187: 
  188:                 $checkinsA[$y] = str_replace('-_New_directory', '- New directory', $checkinsA[$y]);
  189: 
  190:                 $checkins .= $checkinsA[$y];
  191: 
  192:                 if ( ereg("Tag\:$", trim($checkinsA[$y])) && empty($checkinsA[$y+1])) {
  193:                   $_tag = true; 
  194:                 }
  195:                 else {
  196:                   $_tag = false;
  197:                 }
  198: 
  199:                 if(!$TAG) {
  200:                   $checkins .= '</a>';
  201:                 }
  202: 
  203:               }
  204: 
  205:               if ( $identifier == 'Removed:' ) {
  206:                 $idRemoved = true;
  207:               }
  208:               else {
  209:                 $idRemoved = false;
  210:               }
  211: 
  212:             }
  213: 
  214: // what
  215:             $result .= '<div class="CVS-div-checkins">' . $checkins . "</div>\n"; // what
  216:           }
  217: 
  218:           $result .= "</td></tr>\n";
  219:         }
  220: 
  221:       return $result;
  222: 
  223:     }
  224:     
  225:     if($len) {
  226:       for($i=0;$i<$len;$i++) {
  227:         if(ereg("Modified:    www", $contents[$i]) && !$local_conf_commits)
  228:           break;
  229: 
  230:         $result[$i] = cvs_parse($contents, $today, $i, $len);
  231:       }
  232:     }
  233: 
  234:   if(!$result) {  
  235:     print '<tr><td id="CVS-no-commits">There are no new commits today</td></tr>' . "\n";
  236:   } else {
  237:     $reversed=array_reverse($result);
  238:     for($i=0;$i<count($result);$i++)
  239:       PRINT $reversed[$i];
  240:   }
  241: 
  242:     print "</table>\n\n";
  243: 
  244:   } //END BLOCK
  245: ?>

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>