[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 <?php 2 3 4 /** 5 6 * Permet configurer un onduleur esclave 7 * @Version $Id: ups.commun.php 2947 2008-05-04 17:27:18Z plouf $ 8 9 * @Projet LCS / SambaEdu 10 11 * @auteurs Philippe Chadefaux 12 13 * @Licence Distribue selon les termes de la licence GPL 14 15 * @note Rassemble les fonctions pour ups 16 */ 17 18 /** 19 20 * @Repertoire: ups 21 * file: ups.commun.php 22 23 */ 24 25 26 27 /** 28 * Parser 29 * @Parametres 30 * @Return 31 */ 32 33 function debutElement0($parser, $name, $attrs) { 34 global $filiation,$lselect,$pmarque; 35 array_push($filiation,$name); 36 if ($name=="MARQUE" and $pmarque=='') { 37 if ($attrs['NOM']!='') { 38 $marque=$attrs['NOM']; 39 // echo "[<a href=\"$lien?pmarque=$marque\">$marque</A>]<br>\r\n"; 40 array_push($lselect,$marque); 41 } 42 } 43 } 44 45 /** 46 * Parser 47 * @Parametres 48 * @Return 49 */ 50 51 function characterData0($parser, $data) { 52 } 53 54 55 /** 56 * Parser 57 * @Parametres 58 * @Return 59 */ 60 61 function finElement($parser, $name) { 62 global $filiation; 63 array_pop($filiation); 64 } 65 66 /** 67 * Parser 68 * @Parametres 69 * @Return 70 */ 71 72 Function debutElement1($parser, $name, $attrs) { 73 global $marqueOk,$version,$versionOk,$filiation,$lselect,$pmarque,$pversion; 74 array_push($filiation,$name); 75 if ($name=="MARQUE") { 76 if ($attrs['NOM']==$pmarque){$marqueOk=true;}else{$marqueOk=false;}; 77 } 78 if ($name=="VERSION" and $marqueOk) { 79 if ($attrs['VER']!='') 80 {$version=$attrs['VER']; 81 // echo "[$pmarque] <a href=\"$lien?pmarque=$pmarque&pversion=$version\">$version</A>"; 82 83 $versionOk=true; 84 $version=$attrs['VER']; 85 if ($pmarque!='' and $pversion==''){ array_push($lselect,$version);} 86 } 87 else 88 { $versionOk=false; } 89 } 90 } 91 92 /** 93 * parser 94 * @Parametres 95 * @Return 96 */ 97 98 99 function characterData1($parser, $data) { 100 global $marqueOk,$filiation; 101 end($filiation); 102 $element=current($filiation); 103 // if ($element=="DRIVER" and $marqueOk) 104 // {print " (driver : $data)<br>\r\n"; 105 // } 106 } 107 108 109 /** 110 * parser 111 * @Parametres $parser $name $attrs 112 * @Return 113 */ 114 115 function debutElement2($parser, $name, $attrs) { 116 global $pversion,$versionOk,$pmarque,$marqueOk,$filiation; 117 array_push($filiation,$name); 118 if ($name=="MARQUE") { 119 if ($attrs['NOM']==$pmarque){$marqueOk=true;}else{$marqueOk=false;}; 120 } 121 if ($name=="VERSION") { 122 if ($attrs['VER']==$pversion and $marqueOk) 123 { 124 $versionOk=true; 125 // echo "[$pmarque] $pversion<br>\r\n"; 126 } 127 else 128 { $versionOk=false; } 129 } 130 } 131 132 /** 133 * Parse a partir de parser les data 134 * @Parametres $parser $data 135 * @Return 136 */ 137 138 function characterData2($parser, $data) { 139 global $versionOk,$filiation,$lselect,$pmarque,$pversion,$pdriver,$pport,$ptype; 140 end($filiation); 141 $element=current($filiation); 142 if ($element=="DRIVER" and $versionOk){$pdriver=$data;} 143 if ($element=="TYPE" and $versionOk) {$ptype=$data;} 144 if ($element=="CABLE" and $versionOk){ 145 // echo "<a href=\"$lien?pmarque=$pmarque&pversion=$pversion&pdriver=$pdriver&pcable=$data\">$data</A><br>\r\n"; 146 array_push($lselect,$data); 147 } 148 } 149 150 /** 151 * Genere un etat sous forme de tableau de l'onduleur 152 * @Parametres $ups_location nom de l'onduleur 153 * @Return Un tableau HTML 154 */ 155 156 function affichage_ups($ups_location) { // Genere un etat sous forme de tableau de l'onduleur 157 158 // $ups_location = "myups@127.0.0.1"; 159 $text .= "<br><br><CENTER>"; 160 if(file_exists("/etc/nut/ipmaster")) { 161 $ip=exec("cat /etc/nut/ipmaster"); 162 $text .= gettext("Connected on ups of $ip"); 163 $text .= "<br><br>"; 164 } 165 166 if(file_exists("/etc/nut/ipslave")) { 167 $ip=exec("cat /etc/nut/ipslave"); 168 $text .= gettext("UPS master for $ip"); 169 $text .= "<br><br>"; 170 } 171 $text .= "<TABLE border=\"1\" width=\"60%\" bgcolor=\"#50A0A0\">"; 172 $text .= "<TR style='height: 30'><TD align=center><b>Model</b></TD><TD align=center><b>Status</b></TD><TD align=center><b>Battery</b></TD><TD align=center><b>Input</b></TD><TD align=center><b>Output</b></TD><TD align=center><b>Load</b></TD></TR>"; 173 $text .= "<TR style='height:30'>"; 174 175 176 $ups_test = exec("upsc $ups_location"); 177 if ($ups_test=="") { 178 $text .= "<TD bgcolor=\"red\" colspan=\"6\" align=\"center\">"; 179 $text .= "NO UPS DETECTED"; 180 $text .= "</TD>"; 181 } else { 182 $text .= "<TD>"; 183 $text .= exec ("upsc $ups_location ups.mfr"); 184 $text .= " - "; 185 $text .= exec ("upsc $ups_location ups.model"); 186 187 $text .= "</TD>"; 188 $ups_status = exec("upsc $ups_location ups.status"); 189 190 if (preg_match("/OL/i","$ups_status")) { 191 $text .= "<TD bgcolor=\"#00FF00\" align=center>"; 192 $text .= "ONLINE"; 193 } elseif (preg_match("/OB/i","$ups_status")) { 194 $text .= "<TD bgcolor=\"red\" align=center>"; 195 $text .= "ON BATTERY"; 196 } else { 197 $text .= "<TD bgcolor=\"red\" align=center>"; 198 } 199 200 $text .= "</TD>"; 201 $ups_battery = exec("upsc $ups_location battery.charge"); 202 if ($ups_battery > 30) { 203 $text .= "<TD bgcolor=\"#00FF00\" align=center>"; 204 } else { 205 $text .= "<TD bgcolor=\"red\" align=center>"; 206 } 207 $text .= "$ups_battery"; 208 $text .= " %</TD><TD bgcolor=\"#00FF00\" align=center>"; 209 $text .= exec("upsc $ups_location input.voltage"); 210 211 $text .= " VAC</TD><TD bgcolor=\"#00FF00\" align=center>"; 212 $text .= exec("upsc $ups_location output.voltage"); 213 214 $text .= " VAC</TD><TD bgcolor=\"#00FF00\" align=center>"; 215 $text .= exec("upsc $ups_location ups.load"); 216 $text .= " %</TD></TR>"; 217 } 218 $text .= "</TABLE>"; 219 return $text; 220 } 221
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Tue Mar 17 22:47:18 2015 | Cross-referenced by PHPXref 0.7.1 |