browse.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. require_once('../include/prepend.php');
  3. commonHeader("Browse Notes"); ?>
  4. <P>
  5. These pages are only visible at <A href="http://gtk.php.net/manual/">gtk.php.net</A>
  6. because that's where the database that stores them is located. If (when) the
  7. PHP-GTK website is mirrored in several locations, we'll work out a way of
  8. having the docs available across all the mirror sites.
  9. </P><?php
  10. commonFooter();
  11. die();
  12. $last = '';
  13. $used = array();
  14. $let = isset($_GET['let']) ? $_GET['let'] : 'a';
  15. if (strlen($let) > 1 || !preg_match("'[a-z]'", $let)) {
  16. $let = 'a';
  17. }
  18. $y = isset($_GET['y']) ? $_GET['y'] : date('Y', time());
  19. if (strlen($y) != 4 || !preg_match("'[\d]{4}'", $y)) {
  20. $y = date('Y', time());
  21. }
  22. $db = sqlite_open($notesfile);
  23. $query = sqlite_query($db, "SELECT DISTINCT $order FROM notes");
  24. while ($row = sqlite_fetch_array($query, SQLITE_ASSOC)) {
  25. if ($order == 'date') {
  26. $year = date('Y', $row['date']);
  27. if (!in_array($year, $used)) {
  28. $used[] = $year;
  29. }
  30. } else {
  31. $first_letter = strtolower($row[$order][0]);
  32. if (!array_key_exists($first_letter, $used)) {
  33. $used[$first_letter] = true;
  34. }
  35. }
  36. }
  37. sqlite_close($db);
  38. $links = array();
  39. if ($order == 'date') {
  40. rsort($used);
  41. foreach ($used as $year) {
  42. $links[] = make_link("{$_SERVER['PHP_SELF']}?y=$year$queue", "<b>$year</b>");
  43. }
  44. } else {
  45. for ($i = ord('a'); $i <= ord('z'); $i++) {
  46. $letter = chr($i);
  47. if (isset($used[$letter])) {
  48. $links[] = make_link("{$_SERVER['PHP_SELF']}?let=$letter$queue", "<b>$letter</b>");
  49. } else {
  50. $links[] = $letter;
  51. }
  52. }
  53. }
  54. $jumpbar = "<table border='0' cellpadding='4' cellspacing='0' width='100%'>\n".
  55. "<tr bgcolor='#d0d0d0' valign='top'>\n".
  56. "<td align='right' colspan='2'><small>Jump to: ".
  57. implode(" <span style='color:#999999'>|</span> ", $links).
  58. "<br /></small></td>\n".
  59. "</tr>\n".
  60. "</table><br />\n\n";
  61. echo $jumpbar;
  62. echo '<table border="0" cellpadding="4" cellspacing="0" width="100%">';
  63. if (!isset($used[$let]) && $order != 'date') {
  64. echo '<tr><td colspan="2">No entries for <b>'.$let.'</b><br /></td></tr>';
  65. echo stretchPage(15);
  66. echo "&nbsp;</div>";
  67. } else {
  68. $db = sqlite_open($notesfile);
  69. if ($order == 'date') {
  70. $query = sqlite_query($db, "SELECT * FROM notes WHERE strftime('%Y', date, 'unixepoch') = '$y' ORDER BY date DESC");
  71. } else {
  72. $query = sqlite_query($db, "SELECT * FROM notes WHERE lower(substr($order, 1, 1)) = '$let' ORDER BY lower($order)");
  73. }
  74. while ($row = sqlite_fetch_array($query, SQLITE_ASSOC)) {
  75. if ($order == 'page') {
  76. if ($row['page'] != $last) {
  77. makeTitle($row['page']);
  78. $last = $row['page'];
  79. }
  80. } else {
  81. makeTitle($row['page']);
  82. }
  83. makeEntry($row, $admin);
  84. }
  85. sqlite_close($db);
  86. }
  87. echo '</table>';
  88. echo $jumpbar;