File:  [mozdev] / cdn / www / sources.html
Revision 1.114: download - view: text, annotated - select for diffs - revision graph
Sun Feb 23 12:47:45 2003 UTC (16 years, 6 months ago) by cdn
Branches: MAIN
CVS tags: HEAD
$project helps

    1: <?php 
    2: 
    3: // $Id: sources.html,v 1.114 2003/02/23 12:47:45 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:       global $project;
   76: 
   77:         if(ereg("  Date: $today", $contents[$i])) {
   78: 
   79:           $yy = substr(YEAR, 0, 2);
   80: 
   81:           $_timestamp = str_replace('Date: ', '', ltrim($contents[$i]));
   82:           $_timestamp = str_replace("\n", '', $_timestamp);
   83: 
   84:           $_ts_link = $yy . ereg_replace('[\ \/]', '_', $_timestamp);
   85: 
   86:           $_timestamp = '<a name="' . $_ts_link . '">'; 
   87: 
   88:           $result = '<tr class="CVS-tr-header" valign="top"><td class="CVS-td-900">' . "\n";
   89: 
   90: //who
   91:           $result .= "<strong>" . $_timestamp . htmlspecialchars($contents[$i-1]) . "</a></strong>\n" . // who
   92:           "</td></tr>\n" .
   93:           '<tr class="CVS-tr-date">' .
   94:           '<td class="CVS-td-f90">' . "\n";
   95: 
   96:           $_time = htmlspecialchars($contents[$i]);
   97: 
   98: // when
   99:           $result .= '<a class="CVS-td-f90" href="' . '#' . $_ts_link . '">' . $_time . '</a>'; // when
  100: 
  101:           $result .= "\n</td></tr>\n" .
  102:           '<tr class="CVS-tr-checkins"><td class="CVS-td-checkins">' . "\n";
  103: 
  104:           $webcvs = 'http://www.mozdev.org/source/browse/' . $project;
  105: 
  106:           for($l=$i+1;$l<$len;$l++) {
  107:             if(ereg("  Revision  Changes    Path", $contents[$l]))
  108:               break;
  109: 
  110:             if(ereg("  User:", $contents[$l]))
  111:               break;
  112: 
  113:             $checkins = eregi_replace("((https|http|mailto|ftp):\/\/[^[:space:]<>]{1,})", 
  114:             "<a href=\"\\1\">\\1</a>", htmlspecialchars($contents[$l]));
  115: 
  116:             // '  Added:       www/img  background.png' 
  117:             // '  Modified:    www      cdn.css' 
  118:             // '  Removed:     www/protected sources.html'
  119:             // '               www/compact index.html' ?
  120: 
  121:             if ( ereg("((Added|Modified|Removed):)", $checkins) || ereg("^[[:space:]]{9}", $checkins) ||
  122:                  strstr($checkins, "New directory")
  123:                ) {
  124: 
  125:               if ( !strstr($checkins, "New directory") ) {
  126:                 $identifier = trim(substr($checkins, 0, 15)); // may change to &nbsp; group
  127: 
  128:                 $checkins = substr($checkins, 15);
  129:               }
  130:               else {
  131: //              if ( strstr($checkins[$Y-2], '-') && strstr($checkins[$Y-1], 'New') && strstr($checkins[$Y], 'directory') ) {
  132:                // $checkins .= '**';
  133: 
  134:                 $checkins = str_replace('- New directory', '-_New_directory', $checkins);
  135: 		$webcvs = 'http://www.mozdev.org/source/browse';
  136:               }
  137: 
  138:               $_16 = strpos($checkins, ' ');
  139: 
  140:               $_path = substr( $checkins, 0, $_16);
  141: 
  142:               $checkins = ereg_replace('[[:space:]]{1,}', ' ', trim( substr ( $checkins, $_16 ) ) );
  143: 
  144:               $checkinsA = explode(' ', $checkins);
  145: 
  146:               unset($checkins);
  147: 
  148:               for($z=0; $z < count($checkinsA); ++$z) {
  149:                 $checkinsA[$z] = trim($checkinsA[$z]);
  150:               }
  151: 
  152:               if ( !empty($identifier) ) {
  153:                 $checkins = $identifier;
  154:               }
  155: 
  156:               if ( !empty($_path)) { //$checkins .= '!empty($_path)';
  157:                 $webcvs = 'http://www.mozdev.org/source/browse/' . $project; // reset important !
  158:                 $webcvs .= '/' . $_path;
  159:                 $_path_ = $_path;
  160:                 $checkins .= ' <a href="' . $webcvs;
  161:                 $checkins .= '">' . $_path . '</a>';
  162:               }
  163: 
  164:               $Y = count($checkinsA);
  165: 
  166:               for($y=0; $y < $Y; ++$y) {
  167: 
  168:                 if ( ereg('Tag:', $checkinsA[$y]) || ereg('Tag:', $checkinsA[$y-1]) || $_tag ||
  169:                      strstr($checkinsA[$y], '-_New_directory')
  170:                    ) {
  171:                   $TAG = true;
  172:                 }
  173:                 else {
  174:                   $TAG = false;
  175:                 }
  176: 
  177:                 if(!$TAG) {
  178:                   $checkins .= ' <a href="' . $webcvs . '/';
  179: 
  180:                   if( $identifier == 'Removed:' || $idRemoved ) {
  181:                     $checkins .= 'Attic/';
  182:                   }
  183: 
  184:                   $checkins .= $checkinsA[$y] . '">';
  185:                 }
  186:                 else {
  187:                   $checkins .= ' ';
  188:                 }
  189: 
  190:                 $checkinsA[$y] = str_replace('-_New_directory', '- New directory', $checkinsA[$y]);
  191: 
  192:                 $checkins .= $checkinsA[$y];
  193: 
  194:                 if ( ereg("Tag\:$", trim($checkinsA[$y])) && empty($checkinsA[$y+1])) {
  195:                   $_tag = true; 
  196:                 }
  197:                 else {
  198:                   $_tag = false;
  199:                 }
  200: 
  201:                 if(!$TAG) {
  202:                   $checkins .= '</a>';
  203:                 }
  204: 
  205:               }
  206: 
  207:               if ( $identifier == 'Removed:' ) {
  208:                 $idRemoved = true;
  209:               }
  210:               else {
  211:                 $idRemoved = false;
  212:               }
  213: 
  214:             }
  215: 
  216: // what
  217:             $result .= '<div class="CVS-div-checkins">' . $checkins . "</div>\n"; // what
  218:           }
  219: 
  220:           $result .= "</td></tr>\n";
  221:         }
  222: 
  223:       return $result;
  224: 
  225:     }
  226:     
  227:     if($len) {
  228:       for($i=0;$i<$len;$i++) {
  229:         if(ereg("Modified:    www", $contents[$i]) && !$local_conf_commits)
  230:           break;
  231: 
  232:         $result[$i] = cvs_parse($contents, $today, $i, $len);
  233:       }
  234:     }
  235: 
  236:   if(!$result) {  
  237:     print '<tr><td id="CVS-no-commits">There are no new commits today</td></tr>' . "\n";
  238:   } else {
  239:     $reversed=array_reverse($result);
  240:     for($i=0;$i<count($result);$i++)
  241:       PRINT $reversed[$i];
  242:   }
  243: 
  244:     print "</table>\n\n";
  245: 
  246:   } //END BLOCK
  247: ?>

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