Changeset 3952 for trunk/tools/database/www/cvs.php3
- Timestamp:
- Aug 5, 2000, 11:24:00 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/database/www/cvs.php3
r3950 r3952 1 1 <?php 2 2 3 require " ../Odin32DBhelpers.php3";3 require "Odin32DBhelpers.php3"; 4 4 5 5 /* … … 34 34 global $sCVSROOT; 35 35 36 $timer = Odin32DBTimerStart("");37 36 38 37 $this->fOk = 0; … … 94 93 } 95 94 95 /* 96 * Parse the file. 97 */ 98 $this->fOk = $this->ParseFile2($hFile, 0);// $fNoDeltas); 99 100 fclose($hFile); 101 102 /* 103 * Return. 104 */ 105 106 return 1; 107 } 108 109 110 /** 111 * Parses the file. 112 * (internal) 113 */ 114 function ParseFile($hFile, $fNoDeltas) 115 { 96 116 97 117 /* … … 274 294 $this->sError = "Invalid file format."; 275 295 fclose($hFile); 276 return 1;296 return 0; 277 297 } 278 298 $this->aasKeys[$sKey] = $asValue; … … 299 319 } 300 320 301 fclose($hFile);302 303 /*304 * Return successfully.305 */306 $this->fOk = 1;307 308 Odin32DBTimerStop($timer);309 321 return 1; 310 322 } 323 324 325 /** 326 * Parses the file. 327 * (internal) 328 */ 329 function ParseFile2($hFile, $fNoDeltas) 330 { 331 332 /* 333 * Parse file. 334 */ 335 $sKey = ""; 336 $sRev = ""; 337 338 $sLine = ""; 339 $fStop = 0; 340 while (!$fStop) 341 { 342 /* 343 * Left trim. 344 * If empty line, get next and iterate. 345 */ 346 $sLine = ltrim($sLine); 347 if ($sLine == "") 348 { 349 if (feof($hFile)) 350 break; 351 $sLine = fgets($hFile, 0x1000); 352 continue; 353 } 354 355 /* 356 * Are we looking for a new key word? 357 */ 358 if ($sKey == "") 359 { 360 $cch = strlen($sLine); 361 for ($i = 0; $i < $cch; $i++) 362 { 363 $c = $sLine[$i]; 364 if (!( ($c >= 'a' && $c <= 'z') 365 || ($c >= 'A' && $c <= 'Z') 366 || ($c >= '0' && $c <= '9') 367 || $c == '.' || $c == '_' 368 ) 369 ) 370 break; 371 } 372 if ($sLine[0] >= "0" && $sLine[0] <= "9") // Revision number: delta or revision info 373 $sRev = substr($sLine, 0, $i); 374 else 375 $sKey = substr($sLine, 0, $i); 376 $sLine = ltrim(substr($sLine, $i)); 377 continue; 378 } 379 380 381 /* 382 * Extract value 383 */ 384 $fSemicolon = !($sKey == "desc" || $sKey == "log" || $sKey == "desc"); 385 $asValue = array(); 386 $fEnd = 0; 387 if ($sLine[0] == "@") //check if the value is enclosed in '@'s 388 { 389 $sLine = substr($sLine, 1); 390 for (;;) 391 { 392 /* get new line? */ 393 if ($sLine == "") 394 { 395 if (feof($hFile)) 396 break; 397 $sLine = fgets($hFile, 0x1000); 398 continue; 399 } 400 401 /* 402 * Look for end char ( @) and copy. 403 * If end of value then $sLine <- rest of line. 404 */ 405 if ($sLine[0] != '@' || $sLine[1] == '@') 406 { 407 $iAt = 0; 408 while ($iAt = strpos($sLine, "@", $iAt+1)) 409 if ($fEnd = ($sLine[++$iAt] != '@')) 410 { 411 $asValue[] = str_replace("@@", "@", substr($sLine, 0, $iAt - 1)); 412 /* if semicolon end, skip to it. ASSUMES: same line! */ 413 if ($fSemicolon && ($i = strpos($sLine, ";", $iAt)) > 0) 414 $iAt = $i + 1; 415 $sLine = substr($sLine, $iAt); 416 break; 417 } 418 if ($iAt > 0) 419 break; 420 } 421 else 422 { 423 /* if semicolon end, skip to it. ASSUMES: same line! */ 424 if ($fSemicolon && ($iAt = strpos($sLine, ";", 1)) > 0) 425 $sLine = substr($sLine, $iAt+1); 426 else 427 $sLine = substr($sLine, 1); 428 break; 429 } 430 431 $asValue[] = str_replace("@@", "@", $sLine); 432 $sLine = fgets($hFile, 0x1000); 433 } 434 } 435 else 436 { 437 for (;;) 438 { 439 /* get new line? */ 440 if ($sLine == "") 441 { 442 if (feof($hFile)) 443 break; 444 $sLine = fgets($hFile, 0x1000); 445 continue; 446 } 447 448 /* 449 * Look for end char (either ; or @) and copy. 450 * If end of value then $sLine <- rest of line. 451 */ 452 if (($i = strpos($sLine, ';')) <= 0 && $sLine[0] != ';') 453 { //terminator not found. 454 $asValue[] = $sLine; 455 $sLine = fgets($hFile, 0x1000); 456 } 457 else 458 { //terminator found 459 $asValue[] = substr($sLine, 0, $i); 460 $sLine = substr($sLine, $i+1); 461 break; // end 462 } 463 } 464 } 465 466 467 /* 468 * Process the key. 469 */ 470 switch ($sKey) 471 { 472 /* 473 * This is normally the keyword separating 474 * revision info from log+text info. 475 */ 476 case "desc": 477 $sRev = ""; 478 break; 479 480 /* 481 * Stop after the first log entry. 482 */ 483 case "log": 484 $fStop = $fNoDeltas; 485 break; 486 487 /* 488 * Don'r read deltas for archives with the expand tag set 489 */ 490 case "expand": 491 $fNoDeltas = 1;//= $asValue[0] != ""; 492 break; 493 } 494 495 /* 496 * Save key and value in the appopriate place. 497 */ 498 if ($sRev == "") 499 { /* Base keys */ 500 if (sizeof($this->aaKeys) <= 0 //sanity check! head must come first and have a value! 501 && ($sKey != "head" || sizeof($asValue) <= 0 || $asValue[0] == "")) 502 { 503 $this->sError = "Invalid file format."; 504 fclose($hFile); 505 return 1; 506 } 507 $this->aasKeys[$sKey] = $asValue; 508 } 509 else if ($sKey != "text") 510 { /* Revision information keys */ 511 if (!isset($this->aaasRevs[$sRev])) 512 $this->aaasRevs[$sRev] = array($sKey => $asValue); 513 else 514 $this->aaasRevs[$sRev][$sKey] = $asValue; 515 } 516 else 517 { /* Delta (ie. 'text') key */ 518 $this->aasDeltas[$sRev] = $asValue; 519 } 520 521 /* 522 * Completed reading of this key, so next one. 523 */ 524 $sKey = ""; 525 } 526 527 return 1; 528 } 529 311 530 312 531 … … 400 619 case 'hpp': 401 620 C_ColorInit($aVariables); 621 $iColorEncoder = 1; 402 622 break; 623 default: 624 $iColorEncoder = 0; 403 625 } 404 626 … … 410 632 echo "<table><tr><td bgcolor=#020286><pre><font size=-0 face=\"System VIO, System Monospaced\" color=#02FEFE>\n"; 411 633 412 $fComment = 0; 413 $iLine = 0; 414 $cLines = sizeof($this->aasDeltas[$sRevision]); 415 //echo "<!-- debug $this->sExt -->\n"; 416 while ($iLine < $cLines) 417 { 418 $sLine = htmlspecialchars($this->aasDeltas[$sRevision][$iLine++]); 419 634 for ($cLines = sizeof($this->aasDeltas[$sRevision]), $iLine = 0; 635 ($iLine < $cLines); 636 $iLine++) 637 { 420 638 /* 421 639 * Preprocessing... Color coding 422 640 */ 423 switch ($ this->sExt)641 switch ($iColorEncoder) 424 642 { 425 case 'c': 426 case 'cpp': 427 case 'cxx': 428 case 'h': 429 case 'hpp': 430 $sLine = C_ColorEncode($sLine, $aVariables); 431 //echo "<a name=$iLine>"; 432 //C_ColorEncode2($sLine, $aVariables); 433 //echo "</a>"; 643 case 1: 644 echo "<a name=$iLine>"; 645 echo C_ColorEncode(htmlspecialchars($this->aasDeltas[$sRevision][$iLine]), $aVariables); 646 //C_ColorEncode2(htmlspecialchars($this->aasDeltas[$sRevision][$iLine]), $aVariables); 647 echo "</a>"; 434 648 break; 435 649 436 650 default: 437 echo "<a name=$iLine>$sLine</a>"; 438 439 } 440 441 /* 442 * Finished processing of the line. So, write it. 443 */ 444 echo "<a name=$iLine>$sLine</a>"; 651 echo "<a name=$iLine>",htmlspecialchars($this->aasDeltas[$sRevision][$iLine]),"</a>"; 652 } 445 653 } 446 654 … … 505 713 $sCurDate = date("Y.m.d.H.i.s"); 506 714 if ($sDate > $sCurDate) 507 {508 715 return "0 seconds"; //fixme? 509 }510 716 511 717 /* seconds */ … … 595 801 { 596 802 global $sCVSROOT; 803 $timer = Odin32DBTimerStart("List Directory"); 597 804 598 805 /* … … 655 862 * Get CVS data. 656 863 */ 864 $cvstimer = Odin32DBTimerStart("Get CVS Data"); 657 865 $asRev = array(); 658 866 $asAge = array(); … … 667 875 $asAge[$sFile] = $obj->getAge($sRev); 668 876 $asAuthor[$sFile] = $obj->getAuthor($sRev); 669 $asLog[$sFile] = $obj->getLog($sRev); 877 $asTmpLog = $obj->getLog($sRev); 878 for ($sLog = "", $j = sizeof($asTmpLog) - 1; $j >= 0; $j--) 879 { 880 if ($sLog == "") 881 { 882 if (trim($asTmpLog[$j]) != "") 883 $sLog = $asTmpLog[$j]; 884 continue; 885 } 886 $sLog = $asTmpLog[$j]."<br>".$sLog; 887 } 888 $asLog[$sFile] = $sLog; 889 $sLog = ""; 670 890 } 671 891 else 672 $asLog[$sFile] = $obj->sError; 673 } 892 $asLog[$sFile] = $obj->sError; 893 } 894 Odin32DBTimerStop($cvstimer); 674 895 675 896 /* … … 688 909 asort($asSorted); 689 910 911 690 912 /* 691 913 * Present data … … 694 916 echo "<table border=0 width=100% cellspacing=1 cellpadding=2>\n", 695 917 " <hr NOSHADE>\n", 696 " <th bgcolor= #".$aColumnColors[4+0-$iSortColumn]."><b><a href=cvs.phtml?sDir=$sDir&iSortColumn=0>Filename</a></b></th>\n",697 " <th bgcolor= #".$aColumnColors[4+1-$iSortColumn]."><b><a href=cvs.phtml?sDir=$sDir&iSortColumn=1>Rev</a></b></th>\n",698 " <th bgcolor= #".$aColumnColors[4+2-$iSortColumn]."><b><a href=cvs.phtml?sDir=$sDir&iSortColumn=2>Age</a></b></th>\n",699 " <th bgcolor= #".$aColumnColors[4+3-$iSortColumn]."><b><a href=cvs.phtml?sDir=$sDir&iSortColumn=3>Author</a></b></th>\n",700 " <th bgcolor= #".$aColumnColors[4+4-$iSortColumn]."><b><a href=cvs.phtml?sDir=$sDir&iSortColumn=4>Last Log Entry</a></b></th>\n",918 " <th bgcolor=",$aColumnColors[4+0-$iSortColumn],"><font size=-1><b><a href=cvs.phtml?sDir=$sDir&iSortColumn=0>Filename</a></b></font></th>\n", 919 " <th bgcolor=",$aColumnColors[4+1-$iSortColumn],"><font size=-1><b><a href=cvs.phtml?sDir=$sDir&iSortColumn=1>Rev</a></b></font></th>\n", 920 " <th bgcolor=",$aColumnColors[4+2-$iSortColumn],"><font size=-1><b><a href=cvs.phtml?sDir=$sDir&iSortColumn=2>Age</a></b></font></th>\n", 921 " <th bgcolor=",$aColumnColors[4+3-$iSortColumn],"><font size=-1><b><a href=cvs.phtml?sDir=$sDir&iSortColumn=3>Author</a></b></font></th>\n", 922 " <th bgcolor=",$aColumnColors[4+4-$iSortColumn],"><font size=-1><b><a href=cvs.phtml?sDir=$sDir&iSortColumn=4>Last Log Entry</a></b></font></th>\n", 701 923 " </hr>\n"; 702 924 $i = 0; … … 709 931 $sParentDir = ""; 710 932 $sBgColor = ($i++ % 2) ? "" : " bgcolor=#ccccee"; 711 echo " 712 " 713 "<font size=-1><a href=\"cvs.phtml?sDir=$sParentDir\">Parent Directory</a></font></td>\n",714 " 715 " 716 " 717 " 718 " 933 echo "<tr>\n", 934 " <td", $sBgColor , ">", 935 "<font size=-1><a href=\"cvs.phtml?sDir=",$sParentDir,"\"><img src=\"cvsicons/parent.gif\" border=0> Parent Directory</a></font></td>\n", 936 " <td$sBgColor> </td>\n", 937 " <td$sBgColor> </td>\n", 938 " <td$sBgColor> </td>\n", 939 " <td$sBgColor> </td>\n", 940 "</tr>\n"; 719 941 } 720 942 while (list($sKey, $sVal) = each($asSubDirs)) 721 943 { 722 944 $sBgColor = ($i++ % 2) ? "" : " bgcolor=#ccccee"; 723 echo " 724 " <td$sBgColor><font size=-1><a href=\"cvs.phtml?sDir=$sDir/$sVal\">$sVal</a></font></td>\n",725 " 726 " 727 " 728 " 729 " 945 echo "<tr>\n", 946 " <td$sBgColor><font size=-1><a href=\"cvs.phtml?sDir=$sDir/$sVal\"><img src=\"cvsicons/dir.gif\" border=0> $sVal</a></font></td>\n", 947 " <td$sBgColor> </td>\n", 948 " <td$sBgColor> </td>\n", 949 " <td$sBgColor> </td>\n", 950 " <td$sBgColor> </td>\n", 951 "</tr>\n"; 730 952 } 731 953 … … 737 959 $sAge = isset($asAge[$sKey]) ? $asAge[$sKey] : "<i> error </i>"; 738 960 $sAuthor= isset($asAuthor[$sKey])?$asAuthor[$sKey] : "<i> error </i>"; 739 for ($sLog = "", $j = sizeof($asLog[$sKey]) - 1; $j >= 0; $j--) 740 { 741 if ($sLog == "") 742 { 743 if (trim($asLog[$sKey][$j]) != "") 744 $sLog = $asLog[$sKey][$j]; 745 continue; 746 } 747 $sLog = $asLog[$sKey][$j]."<br>".$sLog; 748 } 749 echo " <tr>\n", 750 " <td$sBgColor><font size=-1><a href=\"cvs.phtml?sFile=$sDir/$sKey\">$sKey</a></font></td>\n", 751 " <td$sBgColor><font size=-1><a href=\"cvs.phtml?sFile=$sDir/$sKey?sRev=$sRev\">$sRev</a></font></td>\n", 752 " <td$sBgColor><font size=-1>$sAge</font></td>\n", 753 " <td$sBgColor><font size=-1>$sAuthor</font></td>\n", 754 " <td$sBgColor><font size=-1>$sLog</font></td>\n", 755 " </tr>\n"; 961 $sLog = isset($asLog[$sKey]) ?$asLog[$sKey] : "<i> error </i>"; 962 echo "<tr>\n", 963 " <td$sBgColor><font size=-1><a href=\"cvs.phtml?sFile=$sDir/$sKey\"><img src=\"cvsicons/file.gif\" border=0>",substr($sKey, 0, -2),"</a></font></td>\n", 964 " <td$sBgColor><font size=-2><a href=\"cvs.phtml?sFile=$sDir/$sKey?sRev=$sRev\">$sRev</a></font></td>\n", 965 " <td$sBgColor><font size=-2>$sAge</font></td>\n", 966 " <td$sBgColor><font size=-2>$sAuthor</font></td>\n", 967 " <td$sBgColor><font size=-2>$sLog</font></td>\n", 968 "</tr>\n"; 756 969 } 757 970 758 971 echo "</table>\n"; 972 Odin32DBTimerStop($timer); 759 973 760 974
Note:
See TracChangeset
for help on using the changeset viewer.