[ 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: slave_ups.php 8564 2015-03-15 13:49:49Z 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 16 * @sudo /usr/share/se3/scripts/ups.sh 17 */ 18 19 /** 20 21 * @Repertoire: ups 22 * file: slave_ups.php 23 24 */ 25 26 27 28 // loading libs and init 29 include ("entete.inc.php"); 30 include ("ldap.inc.php"); 31 include ("ihm.inc.php"); 32 33 require_once "ups.commun.php"; 34 35 36 37 // list ($idpers, $login)= isauth(); 38 // if ($idpers == "0") header("Location:$urlauth"); 39 40 41 bindtextdomain ('se3-ups', "/var/www/se3/locale"); 42 textdomain ('se3-ups'); 43 44 //aide 45 $_SESSION["pageaide"]="Gestion_de_l\'onduleur#Onduleur_pour_plusieurs_serveurs"; 46 47 //Si on a le droit de se connecter 48 if ($is_admin = is_admin("Lcs_is_admin",$login)=="Y") { 49 50 echo "<H1>".gettext("Gestion des onduleurs")."</H1>"; 51 52 // ###################### Variables ##############################// 53 54 $lien = "ups.php"; 55 $xmlfile = "/var/www/se3/ups/ups.xml"; 56 $conffile = "/etc/nut/ups.conf"; 57 $lang_ups_titre = "Configuration de l'onduleur: Esclave "; 58 59 60 //###############################################################################################// 61 62 $ipmaster=isset($_POST['ipmaster']) ? $_POST['ipmaster'] : ""; 63 64 if ($ipmaster!="") { // Si on a recu une IP on la verifie 65 $ok=1; 66 if (!is_string($ipmaster)) {$ok = 0;} 67 68 $ip_long = ip2long($ipmaster); 69 $ip_revers = long2ip($ip_long); 70 if($ipmaster != $ip_revers) {$ok=0;} 71 } 72 73 if($ok=="1") { // If IP is Ok 74 $fp=fopen("/etc/nut/upsmon.conf","w+"); 75 $upsmon_var = "MONITOR myups@$ipmaster 1 monslave wawa slave\nMINSUPPLIES 1\nSHUTDOWNCMD \"/sbin/shutdown -h +1\"\nPOLLFREQ 5\nPOLLFREQALERT 5\nHOSTSYNC 15\nDEADTIME 15\nPOWERDONFLAG /etc/killpower\nRBWARNTIME 43200\nNOCOMMWARNTIME 300\nFINALDELAY 5\nNOTIFYCMD /usr/share/se3/sbin/mail_alertes_ups.sh\nNOTIFYFLAG ONBATT SYSLOG+EXEC\n"; 76 fputs($fp,$upsmon_var); 77 fclose($fp); 78 79 80 $fp=fopen("/etc/nut/ipmaster","w+"); 81 fputs($fp,$ipmaster); 82 fclose($fp); 83 84 $fp=fopen("/etc/nut/hosts.conf","w+"); 85 $hosts_var = "MONITOR myups@".$ipmaster." \"UPS slave\""; 86 fputs($fp,$hosts_var); 87 fclose($fp); 88 89 echo gettext("Veuillez patienter ...!"); 90 echo "<br>"; 91 echo "<a href=ups.php?action=Configurer>Configurer</a>"; 92 exec ("/usr/bin/sudo /usr/share/se3/scripts/ups.sh"); 93 echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=ups.php\">"; 94 exit; 95 } else { // Si pas encore d'IP 96 $text = "<br>"; 97 $text .= "<form action=\"slave_ups.php\" name=\"change\" method=\"post\" />"; 98 $text .= gettext("Indiquer l'adresse IP du serveur \"maitre\" qui est connecté à l'onduleur via le càble série."); 99 if($ok=="0") {$text .= "<br><br><font color='red'>"; 100 $text .= gettext("Erreur : Adresse IP non correcte."); 101 $text .= "</font>";} 102 $text .= "<br><table>\n"; 103 $text .= "<tr>"; 104 $text .= "<td>"; 105 $text .= "<input type=\"text\" name=\"ipmaster\" value=\"$ipmaster\" />"; 106 $text .= "</td><td>"; 107 $text .= "<input type=\"submit\" name=\"action\" value="; 108 $text .= gettext("Valider"); 109 $text .= ">"; 110 $text .= "</td></tr></table><br>\n"; 111 } 112 113 114 $titre =gettext("UPS"); 115 echo "<div style='no-border; height: 75%'>\n"; 116 print "$text\n"; 117 echo "</div>\n"; 118 119 } else 120 echo "$html<div class=alert_msg>".gettext("Cette fonctionnalit\xe9, n\xe 121 9cessite les droits d'administrateur du serveur Se3 !")."</div>"; 122 require ("pdp.inc.php"); 123 124 125 ?>
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 |