/Documentation/ReferenceManualScripts/related/redirect.php

https://github.com/aivanov-cern/cmssw · PHP · 171 lines · 83 code · 6 blank · 82 comment · 4 complexity · 9014d95e6cca60572041e9cc29f81ece MD5 · raw file

  1. <?php
  2. //$doxy_URL = "http://cms-service-sdtweb.web.cern.ch/cms-service-sdtweb/doxygen/";
  3. //$doxy_PATH = "/afs/cern.ch/cms/sdt/web/doxygen/";
  4. $doxy_URL = "http://cmssdt.cern.ch/SDT/doxygen/";
  5. $doxy_PATH = "/data/doxygen/";
  6. $output = "";
  7. $object = "";
  8. $object_name = "";
  9. $grep = "";
  10. $star = "";
  11. $ext = "\.html";
  12. $r = isset($_GET["r"])?$_GET["r"]:""; // release
  13. $c = isset($_GET["c"])?$_GET["c"]:""; // class
  14. $s = isset($_GET["s"])?$_GET["s"]:""; // struct
  15. $n = isset($_GET["n"])?$_GET["n"]:""; // namespace
  16. $o = isset($_GET["o"])?$_GET["o"]:""; // source
  17. $k = isset($_GET["k"])?$_GET["k"]:""; // keywords
  18. $K = isset($_GET["K"])?$_GET["K"]:""; // keywords strict // changed: 10-07-08
  19. if ($K != "" && $k != "") // changed: 10-07-08
  20. {
  21. print "K and k can't be specified at the same time !!!";
  22. exit;
  23. }
  24. if ($K != "") $k = $K; // changed: 10-07-08
  25. if ($k != "")
  26. {
  27. $k = trim($k,"{");
  28. $k = trim($k,"}");
  29. $k = trim($k);
  30. if ($k != "")
  31. {
  32. $k = str_replace("*",".*",$k);
  33. $keywords = explode(",", $k); // changed: 10-07-08
  34. for ($i=0; $i<count($keywords); $i++)
  35. {
  36. $grep = $grep." | egrep ".'"'.$keywords[$i].'"';
  37. }
  38. //$grep = " | grep ".str_replace(",", " | grep ", $k);
  39. //$grep = " | egrep ".str_replace(",", " | egrep ", '"'.$k.'"');
  40. }
  41. }
  42. if ($r == "" && ($c =="" || $s =="" || $n =="" || $o ==""))
  43. {
  44. //header("Location: http://cmsdoc.cern.ch/cms/cpt/Software/html/General/gendoxy-doc.php");
  45. header("http://cmssdt.cern.ch/SDT/cgi-bin/doxygen.php");
  46. }
  47. else
  48. {
  49. if ($c != "")
  50. {
  51. $object = "class";
  52. $object_name = $c;
  53. }
  54. else if ($s != "")
  55. {
  56. $object = "struct";
  57. $object_name = $s;
  58. }
  59. else if ($n != "")
  60. {
  61. $object = "namespace";
  62. $object_name = $n;
  63. }
  64. else if ($o != "")
  65. {
  66. $object = "";
  67. $object_name = $o;
  68. $ext = "_8(cc|h|py)[-,_]source\.html";
  69. }
  70. $object_name = str_replace("_", "__", $object_name);
  71. $object_name = str_replace("*", ".*", $object_name);
  72. if ($k != "" && substr_count($object_name,'*') == 0 )
  73. {
  74. $object_name = '.*'.$object_name.'.*';
  75. }
  76. }
  77. //$query1 = 'cd '.$doxy_PATH.'; ls CMSSW_'.$r.'/doc/html/'.$object.$star.$object_name.$ext.$grep;
  78. //$query2 = 'cd '.$doxy_PATH.'; ls CMSSW_'.$r.'/doc/html/*/*/'.$object.$star.$object_name.$ext.$grep;
  79. $query0 = 'cat '.$doxy_PATH.'CMSSW_'.$r.'/*.index | egrep "'.$object.$object_name.$ext.'"'.$grep;
  80. //print $query1;
  81. //print $query2;
  82. //print $query0; exit;
  83. //$output = shell_exec($query1);
  84. //$output = $output==""? shell_exec($query2):$output;
  85. $output = shell_exec($query0);
  86. if ($output == "")
  87. {
  88. $URL = $doxy_URL.$r."/doc/html/".$object.str_replace(".*", "*", $object_name).".html";
  89. $html_s = "<html><head><title>Doxygen Links</title></head><body>";
  90. $div_s = "<div style='width: 95%; margin: 0 auto; border: 1px solid black; text-style: Arial, Helvetica, sans-serif;'><div style='font-size: 18px; border-bottom: 1px solid black; text-align: center; font-weight: bold; padding: 10px; background-color: #b7cade;'>SORRY, NO MATCH FOUND!!!</div><div style='margin: 10px; font-size: 14px;'>";
  91. $body = $URL;
  92. $div_e = "<p style='color: red;'>Either there is no documenation for that release or the query syntax is faulty, please check it out:<br />$query0</p></div></div>";
  93. $html_e = "</body></html>";
  94. print $html_s.$div_s.$body.$div_e.$html_e;
  95. //echo "Doxygen documentation not available for ".$URL;
  96. }
  97. else
  98. {
  99. $output = ereg_replace("[[:space:]]+", ",", trim($output));
  100. $list = explode(",", $output);
  101. if (count($list) == 1)
  102. {
  103. $URL = $doxy_URL.$output;
  104. header("Location: ".$URL);
  105. }
  106. else
  107. {
  108. if ($K != "") // changed: 10-07-08
  109. {
  110. for ($i=0; $i<count($list); $i++)
  111. {
  112. $explodedpath = explode("/",$list[$i]);
  113. $pattern = $explodedpath[count($explodedpath)-1];
  114. $pattern = str_replace("struct", "", $pattern);
  115. $pattern = str_replace("namespace", "", $pattern);
  116. $pattern = str_replace("class", "", $pattern);
  117. $pattern = str_replace($c, "", $pattern);
  118. $pattern = str_replace($s, "", $pattern);
  119. $pattern = str_replace($n, "", $pattern);
  120. $pattern = str_replace(".html", "", $pattern);
  121. for ($j=0; $j<count($keywords); $j++)
  122. $pattern = str_replace($keywords[$j], "", $pattern);
  123. $pattern = str_replace("_", "", $pattern);
  124. $pattern = ereg_replace("[0-9]+", "", $pattern);
  125. if (strlen($pattern) == 0)
  126. {
  127. $URL = $doxy_URL.$list[$i];
  128. header("Location: ".$URL);
  129. }
  130. }
  131. }
  132. $anchor_s = "<a href='";
  133. $anchor_m = "'>";
  134. $anchor_e = "</a>";
  135. $html_s = "<html><head><title>Doxygen Links</title></head><body>";
  136. $div_s = "<div style='width: 95%; margin: 0 auto; border: 1px solid black; text-style: Arial, Helvetica, sans-serif;'><div style='font-size: 18px; border-bottom: 1px solid black; text-align: center; font-weight: bold; padding: 10px; background-color: #b7cade;'>MANY ENTRIES MATCH YOUR QUERY !!!</div><div style='margin: 10px; font-size: 14px;'>";
  137. $body = "";
  138. $div_e = "</div></div>";
  139. $html_e = "</body></html>";
  140. for ($i=0; $i<count($list); $i++)
  141. $body = $body.$anchor_s.$doxy_URL.$list[$i].$anchor_m.$list[$i].$anchor_e."<br /><br />";
  142. print $html_s.$div_s.$body.$div_e.$html_e;
  143. }
  144. }
  145. exit;
  146. ?>