PageRenderTime 29ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/nordugrid-arc-2.0.0/src/services/ldap-monitor/includes/headfoot.inc

#
PHP | 274 lines | 162 code | 47 blank | 65 comment | 22 complexity | c31426a5d702d02fd02015d72b066637 MD5 | raw file
Possible License(s): Apache-2.0
  1. <?php
  2. // Author: oxana.smirnova@hep.lu.se
  3. /**
  4. * A class to set up HTML pages
  5. */
  6. class LmDoc { // class LmDoc
  7. var $module;
  8. var $version;
  9. var $title = "";
  10. var $refresh = 120;
  11. var $bg = "#ffffff";
  12. var $lc = "#cc0000";
  13. var $language = "en";
  14. var $strings = array();
  15. var $errors = array();
  16. var $countries = array();
  17. var $mdsattr = array();
  18. var $isattr = array();
  19. var $loadmon = array();
  20. var $clusdes = array();
  21. var $jobstat = array();
  22. var $volist = array();
  23. var $vousers = array();
  24. var $userlist = array();
  25. var $userres = array();
  26. var $attlist = array();
  27. var $quelist = array();
  28. var $sestat = array();
  29. var $allusers = array();
  30. var $ldapdump = array();
  31. var $giislist = array();
  32. /**
  33. * @return LmDoc
  34. * @param wintyp string
  35. * @param extratitle string
  36. * @desc Creates a new HTML document of type wintyp, title appended with an optional extratitle
  37. */
  38. function LmDoc ( $wintyp="", $extratitle="" ) { // function LmDoc ()
  39. header("Content-type: text/html; charset=utf-8");
  40. ob_implicit_flush(0);
  41. ob_start();
  42. // ini_set("max_execution_time","120");
  43. // ini_set("memory_limit","15M");
  44. // set_time_limit(10);
  45. // Dumps the page start HTML code
  46. //echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">\n";
  47. //echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n";
  48. echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD W3 HTML//EN\">\n";
  49. echo "<html><head>\n";
  50. echo "<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">\n";
  51. echo "<meta name=\"robots\" content=\"noindex,nofollow\">\n";
  52. echo "<script type=\"text/javascript\" src=\"monitor.js\"></script>\n";
  53. echo "<script type=\"text/javascript\" src=\"mylo.js\"></script>\n";
  54. if ( $wintyp ) {
  55. $this->module = $wintyp;
  56. // Localize
  57. $yaccept = @$_SERVER["HTTP_ACCEPT_LANGUAGE"] ;
  58. if ( !$yaccept ) $yaccept = "en";
  59. if ( FORCE_LANG != "default" ) $yaccept = FORCE_LANG;
  60. $yazyk = "en";
  61. $yazyki = explode(",",$yaccept);
  62. foreach ( $yazyki as $option ) {
  63. if ( $yazyk != "en" ) continue;
  64. $option = trim($option);
  65. $option = substr($option,0,2);
  66. // some sniffing
  67. // touch("test/".$option);
  68. // echo "<!--$option-->\n";
  69. $locfile = $option.".inc";
  70. if ( !file_exists("lang/".$locfile) ) continue;
  71. $yazyk = $option;
  72. }
  73. $locfile = $yazyk.".inc";
  74. include $locfile;
  75. setlocale(LC_ALL, $yazyk);
  76. $this->language = $yazyk;
  77. $this->strings = $message;
  78. $this->errors = $message["errors"];
  79. $this->countries = $message["tlconvert"];
  80. $this->mdsattr = $message["mdsattr"];
  81. $this->isattr = $message["isattr"];
  82. // Assigns $this->clusdes = $message["clusdes"];
  83. $this->$wintyp = $message[$wintyp];
  84. $toptitle = $message[$wintyp][0];
  85. // Set page parameters
  86. require ('settings.inc');
  87. $inpnam = implode("_",array("def",$wintyp));
  88. // Page style definitions (see settings.inc)
  89. // Sets top window title
  90. $this->title = ( $toptitle ) ? $toptitle : "";
  91. // Refresh rate
  92. $this->refresh = (${$inpnam}["refresh"]) ? ${$inpnam}["refresh"] : 0;
  93. // Background and link colors
  94. $this->bg = (${$inpnam}["bgcolor"]) ? ${$inpnam}["bgcolor"] : "#ffffff";
  95. $this->lc = (${$inpnam}["lcolor"]) ? ${$inpnam}["lcolor"] : "#cc0000";
  96. // Dumps the header HTML code
  97. $titles = explode(":",$this->title); // sometimes titles are many
  98. echo "<title>".$titles[0]." ".$extratitle."</title>\n";
  99. if ( $this->refresh ) echo "<meta http-equiv=\"refresh\" content=".$this->refresh.">\n";
  100. echo "<style>\n";
  101. echo "<!--\n";
  102. echo "A {text-decoration:none; }\n";
  103. echo "A:link {color: ".$this->lc."; }\n";
  104. echo "A:visited {color: ".$this->lc."; }\n";
  105. echo "A:first-child {color: ".$this->lc."; }\n";
  106. echo "BODY {background-color: ".$this->bg."; font-size:small; height:auto;}\n";
  107. echo "P {padding: 0em; margin: 10px 0px 6px 0px; font-size:small; }\n";
  108. echo "TD {font-size:small;}\n";
  109. echo "DT {text-align: justify;}\n";
  110. echo "DD {text-align: justify;}\n";
  111. echo ".right {text-align: right; padding: 0em; margin: 0em;}\n";
  112. echo ".fix {font-family: monospace;}\n";
  113. echo "//-->\n";
  114. echo "</style>\n";
  115. // define giislist
  116. $this->giislist = $giislist;
  117. }
  118. // Finishes HTML header, starts document body
  119. echo "</head>\n";
  120. echo "<body>\n";
  121. echo "<center>\n";
  122. }
  123. /**
  124. * @return void
  125. * @param errors array
  126. * @param title string
  127. * @param subtitle string
  128. * @desc Makes an opening Monitor header
  129. */
  130. function tabletop ( $toptitle="", $subtitle="" ) { // function tabletop()
  131. $lang = FORCE_LANG;
  132. echo "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n";
  133. echo "<tr><td nowrap align=\"center\" colspan=\"2\"><b>".$toptitle."</b></td>\n";
  134. echo "<tr><td nowrap align=\"left\"><b><i>".$subtitle."</i></b></td>\n";
  135. echo "<td nowrap align=\"right\"><a href=\"javascript: window.location.reload()\">\n";
  136. echo " <img src=\"./mon-icons/icon-refresh.png\" vspace=\"4\" width=\"24\" height=\"24\" border=\"0\" align=\"absmiddle\" title=\"".$this->errors["301"]."\" alt=\"".$this->errors["301"]."\"></a>\n";
  137. echo " <a href=\"javascript:(self.print();)\" onClick=\"self.print();\">\n";
  138. echo " <img src=\"./mon-icons/icon-print.png\" vspace=\"4\" width=\"24\" height=\"24\" border=\"0\" align=\"absmiddle\" title=\"".$this->errors["302"]."\" alt=\"".$this->errors["302"]."\"></a>\n";
  139. echo " <a href=\"javascript:monitor('help.php?module=".$this->module."&lang=".$lang."',400,300,10);\" onClick=\"javascript:monitor('help.php?module=".$this->module."',400,300,10);\">\n";
  140. echo " <img src=\"./mon-icons/icon-help.png\" vspace=\"4\" width=\"24\" height=\"24\" border=\"0\" align=\"absmiddle\" title=\"".$this->errors["303"]."\" alt=\"".$this->errors["303"]."\"></a>\n";
  141. echo " <a href=\"javascript:(self.close();)\" onClick=\"self.close();\">\n";
  142. echo " <img src=\"./mon-icons/icon-close.png\" vspace=\"4\" width=\"24\" height=\"24\" border=\"0\" align=\"absmiddle\" title=\"".$this->errors["304"]."\" alt=\"".$this->errors["304"]."\"></a>\n";
  143. echo "</td></tr></table>\n";
  144. }
  145. /**
  146. * @return string
  147. * @desc returns version number from README
  148. */
  149. function getVersion ()
  150. {
  151. $v = "N/A";
  152. if ( file_exists("README") ) {
  153. $readme = fopen("README","r");
  154. $fline = fgets($readme);
  155. $v = substr(stristr($fline,"version "),8);
  156. fclose($readme);
  157. }
  158. $this->version = $v;
  159. return $v;
  160. }
  161. /**
  162. * @return void
  163. * @desc Closes an HTML document
  164. */
  165. function close ()
  166. {
  167. // Closes the HTML document
  168. echo "\n</center>\n";
  169. echo "</body></html>\n";
  170. ob_end_flush();
  171. ob_implicit_flush();
  172. }
  173. }
  174. /**
  175. * Below are some generic functions, non-class-specific
  176. *
  177. * function dbgmsg ( string ) : prints out a message and flushes output; useful for debugging
  178. * function popup ( string, int, int, int ) : opens up a new window, depending on the client
  179. */
  180. /**
  181. * @return void
  182. * @param dbgtxt string
  183. * @desc Outputs a debug message outside the table
  184. */
  185. function dbgmsg( $dbgtxt="Debug" )
  186. {
  187. echo "$dbgtxt\n";
  188. flush();
  189. }
  190. /**
  191. * @return void
  192. * @param contact string
  193. * @param x int
  194. * @param y int
  195. * @param n int
  196. * @desc Returns a new monitor window URL
  197. */
  198. $agent = @$_SERVER["HTTP_USER_AGENT"] ;
  199. if ( !defined("USERAGENT") ) define("USERAGENT",$agent);
  200. function popup( $contact, $x=400, $y=300, $n=1, $lang, $debug )
  201. {
  202. ( USERAGENT ) ? $agent = USERAGENT : $agent = "lynx";
  203. if ( preg_match("/opera/i",$agent)
  204. || preg_match("/lynx/i",$agent)
  205. || preg_match("/konqueror/i",$agent)
  206. ) return $contact;
  207. // $link = "javascript:monitor('".$contact."',$x,$y,$n)";
  208. if ( $lang != "default" && $lang != FALSE ) {
  209. if ( strpos($contact,"?") ) {
  210. $contact .= "&" ;
  211. } else {
  212. $contact .= "?" ;
  213. }
  214. $contact .= "lang=$lang";
  215. }
  216. if ( $debug ) {
  217. if ( strpos($contact,"?") ) {
  218. $contact .= "&" ;
  219. } else {
  220. $contact .= "?" ;
  221. }
  222. $contact .= "debug=$debug";
  223. }
  224. $link = $contact."\" target=\"win".$n."\" onClick=\"monitor('".$contact."',$x,$y,$n); return false";
  225. return $link;
  226. }
  227. ?>