PageRenderTime 53ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/security/index.php

http://github.com/php/web-php
PHP | 147 lines | 132 code | 12 blank | 3 comment | 20 complexity | f3d4ecf7c881346a78888c2caef6d509 MD5 | raw file
  1. <?php
  2. $_SERVER['BASE_PAGE'] = 'security/index.php';
  3. include_once __DIR__ . '/../include/prepend.inc';
  4. if(!isset($_COOKIE["MAGIC_COOKIE"])) {
  5. mirror_redirect("/manual/security");
  6. exit;
  7. }
  8. $SIDEBAR_DATA = <<< EOT
  9. <br>
  10. <div id="securitySidebar">
  11. <h3><a href="/security/">Security Center?</a></h3>
  12. <p>In an effort to make security related information more readily available, the PHP Security Response Team created a new Security Center on March 1st, 2007. The Security Center will serve as the central location where interested parties can find information about security threats, fixes and/or workarounds and any other related meterial.</p>
  13. <h3>Security related books</h3>
  14. <ul>
  15. <li><a href="http://www.amazon.com/exec/obidos/ASIN/0973862106/">Guide to PHP Security</a></li>
  16. <li><a href="http://www.amazon.com/exec/obidos/ASIN/059600656X/">Essential PHP Security</a></li>
  17. </ul>
  18. <h3>Other links</h3>
  19. <ul>
  20. <li><a href="https://www.php.net/manual/security">PHP manual on security</a></li>
  21. <li><a href="http://www.suhosin.org">Suhosin</a></li>
  22. <li><a href="http://phpsec.org/projects/guide/">PHP Security Consortium</a></li>
  23. </ul>
  24. </div>
  25. EOT;
  26. site_header("PHP Security center");
  27. echo "<h1>PHP Security Center</h1>\n";
  28. $dbfile = $_SERVER['DOCUMENT_ROOT'] . '/security/vulndb.txt';
  29. $fp = @fopen($dbfile, "rt");
  30. if(is_resource($fp)) {
  31. $RECORDS = array();
  32. $record_no = 1;
  33. while($s = fgets($fp)) {
  34. if($s == "\n") {
  35. if(!isset($RECORDS[$record_no]["id"])) {
  36. $RECORDS[$record_no]["id"] = $record_no;
  37. }
  38. $field = null;
  39. $record_no++;
  40. continue;
  41. }
  42. if(preg_match("/^([-\w]+):\s*(.*)/", $s, $m)) {
  43. // new record
  44. $field = strtolower($m[1]);
  45. $data = $m[2];
  46. } else {
  47. $data = $s;
  48. }
  49. if($field) {
  50. if(isset($RECORDS[$record_no][$field])) {
  51. $RECORDS[$record_no][$field] .= $data;
  52. } else {
  53. $RECORDS[$record_no][$field] = $data;
  54. }
  55. }
  56. }
  57. }
  58. //echo "<pre>";print_r($RECORDS);
  59. $id = isset($_GET["id"]) ? (int)$_GET["id"] : 0;
  60. if(!$id || !isset($RECORDS[$id])) {
  61. ?>
  62. <h3>PHP Vulnerability Disclosures</h3>
  63. <p>This page contains information about PHP-related security threats, patches and known workarounds.</p>
  64. <p>If you believe you have discovered a security problem in PHP please inform the<br>PHP Security Response Team in confidence by mailing <a href="mailto:security@php.net">security@php.net</a></p>
  65. <br>
  66. <p>The following colors are used to highlight the severity of a bug:</p>
  67. <ul class="colors">
  68. <li class="low">low risk is yellow</li>
  69. <li class="medium">medium risk is orange</li>
  70. <li class="critical">critical is red</li>
  71. </ul>
  72. <?php
  73. function cmp_records($a, $b) {
  74. $c = date("Ym", strtotime($a["published"]));
  75. $d = date("Ym", strtotime($b["published"]));
  76. if($c >= $d) {
  77. if($c > $d) {
  78. return -1;
  79. }
  80. return 0;
  81. }
  82. return 1;
  83. }
  84. usort($RECORDS, "cmp_records");
  85. $last_month = "";
  86. foreach($RECORDS as $record) {
  87. if(!isset($record["summary"])) {
  88. if(strlen($record["description"]) > 80) {
  89. $record["summary"] = substr($record["description"], 0, 70) . "...";
  90. } else {
  91. $record["summary"] = $record["description"];
  92. }
  93. }
  94. $current_month = date("Ym", strtotime($record["published"]));
  95. if($current_month != $last_month) {
  96. $last_month = $current_month;
  97. $current_month = $record["affects"];
  98. echo "<br><h1>", date("F Y", strtotime($record["published"])), "</h1>\n";
  99. }
  100. ?>
  101. <div class="record <?php echo strtolower($record["severity"]) ?>">
  102. <div class="id"><a href="/security/advisories/PHPSA-<?php echo $record["id"] ?>.php">PHPSA-<?php printf("%04d", $record["id"]) ?></a></div>
  103. <div class="date"><?php echo date("Y-m-d", strtotime($record["published"]))?></div>
  104. <div class="range <?php echo strtolower($record["range"]) ?>"><?php echo $record["range"] ?></div>
  105. <div class="affects"><?php echo $record["affects"] ?></div>
  106. <div class="summary"><?php echo $record["summary"] ?></div>
  107. </div>
  108. <?php
  109. } // foreach($records);
  110. } elseif(isset($RECORDS)) { // Print a single record
  111. $date = date("F jS Y", strtotime($RECORDS[$id]["published"]));
  112. $RECORDS[$id]["id"] = sprintf("PHPSA-%04d", $RECORDS[$id]["id"]);
  113. printf("<h3>%s (%s)</h3>\n", $RECORDS[$id]["id"], $date);
  114. echo "<div class=\"singlerecord\">\n";
  115. foreach($RECORDS[$id] as $field => $data) {
  116. if(!$data) {
  117. continue;
  118. }
  119. $title = ucfirst(strtr($field, "-", " "));
  120. // Turn urls into links (stolen from master/manage/user-notes.php)
  121. $data = preg_replace(
  122. '!((mailto:|(http|ftp|nntp|news):\/\/).*?)(\s|<|\)|"|\\|\'|$)!',
  123. '<a href="\1" target="_blank">\1</a>\4',
  124. $data
  125. );
  126. echo <<< EOT
  127. <div class="row $field">
  128. <div class="title">$title</div>
  129. <div class="data">$data</div>
  130. </div>\n
  131. EOT;
  132. }
  133. echo "</div>\n";
  134. }
  135. site_footer();