/includes/xml/mbinfo.php

https://github.com/inode64/PhpSpeed · PHP · 211 lines · 157 code · 34 blank · 20 comment · 17 complexity · 755495951b99cc6ca6c09d1ed98696ad MD5 · raw file

  1. <?php
  2. /***************************************************************************
  3. * Copyright (C) 2006 by phpSysInfo - A PHP System Information Script *
  4. * http://phpsysinfo.sourceforge.net/ *
  5. * *
  6. * This program is free software; you can redistribute it and/or modify *
  7. * it under the terms of the GNU General Public License as published by *
  8. * the Free Software Foundation; either version 2 of the License, or *
  9. * (at your option) any later version. *
  10. * *
  11. * This program is distributed in the hope that it will be useful, *
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  14. * GNU General Public License for more details. *
  15. * *
  16. * You should have received a copy of the GNU General Public License *
  17. * along with this program; if not, write to the *
  18. * Free Software Foundation, Inc., *
  19. * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
  20. ***************************************************************************/
  21. // $Id: mbinfo.php,v 1.16 2006/06/16 09:02:30 bigmichi1 Exp $
  22. function xml_mbinfo() {
  23. global $text;
  24. global $mbinfo;
  25. $_text = "";
  26. $arrBuff = $mbinfo->temperature();
  27. $_text = " <MBinfo>\n";
  28. if( sizeof($arrBuff ) > 0 ) {
  29. $_text .= " <Temperature>\n";
  30. foreach( $arrBuff as $arrValue ) {
  31. $_text .= " <Item>\n";
  32. $_text .= " <Label>" . htmlspecialchars( $arrValue['label'], ENT_QUOTES ) . "</Label>\n";
  33. $_text .= " <Value>" . htmlspecialchars( $arrValue['value'], ENT_QUOTES ) . "</Value>\n";
  34. $_text .= " <Limit>" . htmlspecialchars( $arrValue['limit'], ENT_QUOTES ) . "</Limit>\n";
  35. $_text .= " </Item>\n";
  36. }
  37. $_text .= " </Temperature>\n";
  38. }
  39. $arrBuff = $mbinfo->fans();
  40. if( sizeof( $arrBuff ) > 0 ) {
  41. $_text .= " <Fans>\n";
  42. foreach( $arrBuff as $arrValue ) {
  43. $_text .= " <Item>\n";
  44. $_text .= " <Label>" . htmlspecialchars( $arrValue['label'], ENT_QUOTES ) . "</Label>\n";
  45. $_text .= " <Value>" . htmlspecialchars( $arrValue['value'], ENT_QUOTES ) . "</Value>\n";
  46. $_text .= " <Min>" . htmlspecialchars( $arrValue['min'], ENT_QUOTES ) . "</Min>\n";
  47. $_text .= " <Div>" . htmlspecialchars( $arrValue['div'], ENT_QUOTES ) . "</Div>\n";
  48. $_text .= " </Item>\n";
  49. }
  50. $_text .= " </Fans>\n";
  51. }
  52. $arrBuff = $mbinfo->voltage();
  53. if( sizeof( $arrBuff ) > 0 ) {
  54. $_text .= " <Voltage>\n";
  55. foreach( $arrBuff as $arrValue ) {
  56. $_text .= " <Item>\n";
  57. $_text .= " <Label>" . htmlspecialchars( $arrValue['label'], ENT_QUOTES ) . "</Label>\n";
  58. $_text .= " <Value>" . htmlspecialchars( $arrValue['value'], ENT_QUOTES ) . "</Value>\n";
  59. $_text .= " <Min>" . htmlspecialchars( $arrValue['min'], ENT_QUOTES ) . "</Min>\n";
  60. $_text .= " <Max>" . htmlspecialchars( $arrValue['max'], ENT_QUOTES ) . "</Max>\n";
  61. $_text .= " </Item>\n";
  62. }
  63. $_text .= " </Voltage>\n";
  64. }
  65. $_text .= " </MBinfo>\n";
  66. return $_text;
  67. }
  68. function html_mbtemp() {
  69. global $text;
  70. global $XPath;
  71. $textdir = direction();
  72. $scale_factor = 2;
  73. $_text = " <tr>\n"
  74. . " <td><font size=\"-1\"><b>" . $text['s_label'] . "</b></font></td>\n"
  75. . " <td><font size=\"-1\"><b>" . $text['s_value'] . "</b></font></td>\n"
  76. . " <td align=\"" . $textdir['right'] . "\" valign=\"top\"><font size=\"-1\"><b>" . $text['s_limit'] . "</b></font></td>\n"
  77. . " </tr>\n";
  78. for( $i = 1, $max = sizeof( $XPath->getDataParts( "/phpsysinfo/MBinfo/Temperature" ) ); $i < $max; $i++ ) {
  79. $_text .= " <tr>\n"
  80. . " <td align=\"" . $textdir['left'] . "\" valign=\"top\"><font size=\"-1\">" . $XPath->getData( "/phpsysinfo/MBinfo/Temperature/Item[" . $i . "]/Label" ) . "</font></td>\n"
  81. . " <td align=\"" . $textdir['left'] . "\" valign=\"top\"><font size=\"-1\">";
  82. if( $XPath->getData( "/phpsysinfo/MBinfo/Temperature/Item[" . $i . "]/Value" ) == 0) {
  83. $_text .= "Unknown - Not connected?";
  84. } else {
  85. $_text .= create_bargraph( $XPath->getData( "/phpsysinfo/MBinfo/Temperature/Item[" . $i . "]/Value" ), $XPath->getData( "/phpsysinfo/MBinfo/Temperature/Item[" . $i . "]/Limit" ), $scale_factor );
  86. }
  87. $_text .= temperature( $XPath->getData( "/phpsysinfo/MBinfo/Temperature/Item[" . $i . "]/Value" ) ) . "</font></td>\n"
  88. . " <td align=\"" . $textdir['right'] . "\" valign=\"top\"><font size=\"-1\">" . $XPath->getData( "/phpsysinfo/MBinfo/Temperature/Item[" . $i . "]/Limit" ) . "</font></td>\n"
  89. . " </tr>\n";
  90. }
  91. return $_text;
  92. }
  93. function html_mbfans() {
  94. global $text;
  95. global $XPath;
  96. $textdir = direction();
  97. $booShowfans = false;
  98. $_text ="<table class=\"stat\">\n";
  99. $_text .= " <tr>\n"
  100. . " <td><font size=\"-1\"><b>" . $text['s_label'] . "</b></font></td>\n"
  101. . " <td align=\"" . $textdir['right'] . "\"><font size=\"-1\"><b>" . $text['s_value'] . "</b></font></td>\n"
  102. . " <td align=\"" . $textdir['right'] . "\"><font size=\"-1\"><b>" . $text['s_min'] . "</b></font></td>\n"
  103. . " <td align=\"" . $textdir['right'] . "\"><font size=\"-1\"><b>" . $text['s_div'] . "</b></font></td>\n"
  104. . " </tr>\n";
  105. for( $i = 1, $max = sizeof( $XPath->getDataParts( "/phpsysinfo/MBinfo/Fans" ) ); $i < $max; $i++ ) {
  106. $_text .= " <tr>\n"
  107. . " <td align=\"" . $textdir['left'] . "\" valign=\"top\"><font size=\"-1\">" . $XPath->getData( "/phpsysinfo/MBinfo/Fans/Item[" . $i . "]/Label" ) . "</font></td>\n"
  108. . " <td align=\"" . $textdir['right'] . "\" valign=\"top\"><font size=\"-1\">" . round( $XPath->getData( "/phpsysinfo/MBinfo/Fans/Item[" . $i . "]/Value" ) ) . " " . $text['rpm_mark'] . "</font></td>\n"
  109. . " <td align=\"" . $textdir['right'] . "\" valign=\"top\"><font size=\"-1\">" . $XPath->getData( "/phpsysinfo/MBinfo/Fans/Item[" . $i . "]/Min" ) . " " . $text['rpm_mark'] . "</font></td>\n"
  110. . " <td align=\"" . $textdir['right'] . "\" valign=\"top\"><font size=\"-1\">" . $XPath->getData( "/phpsysinfo/MBinfo/Fans/Item[" . $i . "]/Div" ) . "</font></td>\n"
  111. . " </tr>\n";
  112. if( round( $XPath->getData( "/phpsysinfo/MBinfo/Fans/Item[" . $i . "]/Value" ) ) > 0 ) {
  113. $booShowfans = true;
  114. }
  115. }
  116. $_text .= "</table>\n";
  117. if( ! $booShowfans ) {
  118. $_text = "";
  119. }
  120. return $_text;
  121. }
  122. function html_mbvoltage() {
  123. global $text;
  124. global $XPath;
  125. $textdir = direction();
  126. $_text = "<table class=\"stat\">\n";
  127. $_text .= " <tr>\n"
  128. . " <td><font size=\"-1\"><b>" . $text['s_label'] . "</b></font></td>\n"
  129. . " <td align=\"" . $textdir['right'] . "\"><font size=\"-1\"><b>" . $text['s_value'] . "</b></font></td>\n"
  130. . " <td align=\"" . $textdir['right'] . "\"><font size=\"-1\"><b>" . $text['s_min'] . "</b></font></td>\n"
  131. . " <td align=\"" . $textdir['right'] . "\"><font size=\"-1\"><b>" . $text['s_max'] . "</b></font></td>\n"
  132. . " </tr>\n";
  133. for( $i = 1, $max = sizeof( $XPath->getDataParts( "/phpsysinfo/MBinfo/Voltage" ) ); $i < $max; $i++ ) {
  134. $_text .= " <tr>\n"
  135. . " <td align=\"" . $textdir['left'] . "\" valign=\"top\"><font size=\"-1\">" . $XPath->getData( "/phpsysinfo/MBinfo/Voltage/Item[" . $i . "]/Label" ) . "</font></td>\n"
  136. . " <td align=\"" . $textdir['right'] . "\" valign=\"top\"><font size=\"-1\">" . $XPath->getData( "/phpsysinfo/MBinfo/Voltage/Item[" . $i . "]/Value" ) . " " . $text['voltage_mark'] . "</font></td>\n"
  137. . " <td align=\"" . $textdir['right'] . "\" valign=\"top\"><font size=\"-1\">" . $XPath->getData( "/phpsysinfo/MBinfo/Voltage/Item[" . $i . "]/Min" ) . " " . $text['voltage_mark'] . "</font></td>\n"
  138. . " <td align=\"" . $textdir['right'] . "\" valign=\"top\"><font size=\"-1\">" . $XPath->getData( "/phpsysinfo/MBinfo/Voltage/Item[" . $i . "]/Max" ) . " " . $text['voltage_mark'] . "</font></td>\n"
  139. . " </tr>\n";
  140. }
  141. $_text .= "</table>\n";
  142. return $_text;
  143. }
  144. function wml_mbtemp() {
  145. global $XPath;
  146. $_text = "";
  147. for( $i = 1, $max = sizeof( $XPath->getDataParts( "/phpsysinfo/MBinfo/Temperature" ) ); $i < $max; $i++ ) {
  148. $_text .= "<p>\n" . $XPath->getData( "/phpsysinfo/MBinfo/Temperature/Item[" . $i . "]/Label" ) . ": ";
  149. if( $XPath->getData( "/phpsysinfo/MBinfo/Temperature/Item[" . $i . "]/Value" ) == 0 ) {
  150. $_text .= "Unknown - Not connected?</p>";
  151. } else {
  152. $_text .= "&nbsp;" . str_replace( "&ordm;", "", temperature( $XPath->getData( "/phpsysinfo/MBinfo/Temperature/Item[" . $i . "]/Value" ) ) ) . "</p>\n";
  153. }
  154. }
  155. return $_text;
  156. }
  157. function wml_mbfans() {
  158. global $text;
  159. global $XPath;
  160. $_text = "<card id=\"fans\" title=\"" . $text['fans'] . "\">\n";
  161. for( $i = 1, $max = sizeof( $XPath->getDataParts( "/phpsysinfo/MBinfo/Fans" ) ); $i < $max; $i++ ) {
  162. $_text .= "<p>\n" . $XPath->getData( "/phpsysinfo/MBinfo/Fans/Item[" . $i . "]/Label" ) . ": " . round( $XPath->getData( "/phpsysinfo/MBinfo/Temperature/Item[" . $i . "]/Value" ) ) . "&nbsp;" . $text['rpm_mark'] . "</p>\n";
  163. }
  164. $_text .= "</card>\n";
  165. return $_text;
  166. }
  167. function wml_mbvoltage() {
  168. global $text;
  169. global $XPath;
  170. $_text = "<card id=\"volt\" title=\"" . $text['voltage'] . "\">\n";
  171. for( $i = 1, $max = sizeof( $XPath->getDataParts( "/phpsysinfo/MBinfo/Voltage" ) ); $i < $max; $i++ ) {
  172. $_text .= "<p><br/>\n" . $XPath->getData( "/phpsysinfo/MBinfo/Voltage/Item[" . $i . "]/Label" ) . ": " . $XPath->getData( "/phpsysinfo/MBinfo/Voltage/Item[" . $i . "]/Value" ) . "&nbsp;" . $text['voltage_mark'] . "<br/>\n";
  173. }
  174. $_text .= "</card>\n";
  175. return $_text;
  176. }
  177. ?>