parse Changelog ("History") files and generate HTML pages
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
3.1KB

  1. <?
  2. #############################################################################
  3. # HistView Client (c) 2003-2009 by Itzchak Rehberg #
  4. # written by Itzchak Rehberg <devel AT izzysoft DOT de> #
  5. # http://www.izzysoft.de/ #
  6. # ------------------------------------------------------------------------- #
  7. # This program is free software; you can redistribute and/or modify it #
  8. # under the terms of the GNU General Public License (see doc/LICENSE) #
  9. # ------------------------------------------------------------------------- #
  10. # Calls HistView Api to display a history file #
  11. # Call it as "histview.php?prog=XxX". The Title will then change to "XxX" #
  12. # and the historyfile xxx.hist (note: lower case) will be displayed. #
  13. #############################################################################
  14. /* $Id$ */
  15. #==================================================================[ Setup ]===
  16. #-------------------------------[ Read request vars and do some protection ]---
  17. $prog = $_REQUEST["prog"];
  18. # $prog should only contain letters, digits and "_"
  19. if (empty($prog) || @preg_match("/[^\w]/u",$prog)) $prog = "HistView";
  20. # $file should be alphanumeric - no special chars or / or \
  21. $file = $_REQUEST["file"];
  22. if (empty($file) || @preg_match("/[^\w-_.]/u",$file)) unset ($file);
  23. # $dir should only be one of ours - here: "tar","deb","rpm"
  24. $dir = $_REQUEST["dir"];
  25. if (!empty($dir) && !in_array($dir,array("tar","deb","rpm"))) unset ($file,$dir);
  26. #------------------------------------------------------[ Setup directories ]---
  27. $dirs = array( "tar" => "/var/ftp/downloads",
  28. "deb" => "/var/repo/debian",
  29. "rpm" => "/var/repo/redhat/RPMS.dist" );
  30. $charset = "iso-8859-15";
  31. #========================================================[ Process Request ]===
  32. #----------------------------------------------[ Was a download requested? ]---
  33. if (!empty($_REQUEST["file"])) {
  34. include("class.download.inc");
  35. if (!empty($file) && !empty($dir)) {
  36. $dl = new download();
  37. if ($dl->sendfile($file,$dirs[$dir])) exit;
  38. }
  39. $e404 = "\n<DIV CLASS='ebox'>Sorry - but the requested file was not found here.</DIV>";
  40. } else {
  41. $e404 = "";
  42. }
  43. #-----------------------------------------------[ Display the history file ]---
  44. include("histview.inc");
  45. $file = $dirs["tar"]."/".strtolower($prog).".hist"; // ChangeLog to parse
  46. # Simple method, no download links to provide:
  47. #$hv = new histview($file);
  48. # Providing download links:
  49. $hv = new histview($file,strtolower($prog));
  50. # Setting up the directories
  51. $hv->set_basedir("tar", $dirs["tar"]);
  52. # Process the page
  53. $hv->process();
  54. $history = $hv->out();
  55. $title = "History for $prog";
  56. echo "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>\n";
  57. echo "<HTML><HEAD>\n"
  58. . " <META HTTP-EQUIV='Content-Type' CONTENT='text/html; charset=$charset'/>\n"
  59. . ' <LINK REL="stylesheet" TYPE="text/css" HREF="histview.css">'."\n"
  60. . " <TITLE>$title</TITLE>\n"
  61. . "</HEAD><BODY>\n<H2>$title</H2>\n";
  62. echo $e404;
  63. echo $history."\n</BODY></HTML>\n";
  64. ?>