From: <abe...@us...> - 2012-09-28 20:05:33
|
Revision: 5696 http://astlinux.svn.sourceforge.net/astlinux/?rev=5696&view=rev Author: abelbeck Date: 2012-09-28 20:05:27 +0000 (Fri, 28 Sep 2012) Log Message: ----------- web interface, Status and Prefs tab, added several new options Modified Paths: -------------- branches/1.0/package/webinterface/altweb/admin/prefs.php branches/1.0/package/webinterface/altweb/common/status.inc Modified: branches/1.0/package/webinterface/altweb/admin/prefs.php =================================================================== --- branches/1.0/package/webinterface/altweb/admin/prefs.php 2012-09-27 03:44:39 UTC (rev 5695) +++ branches/1.0/package/webinterface/altweb/admin/prefs.php 2012-09-28 20:05:27 UTC (rev 5696) @@ -12,6 +12,9 @@ // 08-19-2008, Added CDR Log Format Menu // 08-24-2008, Added /mnt/kd/ prefs file support // 01-02-2012, Added Show Jabber Status/Command +// 09-28-2012, Added Show Adaptive Ban Plugin Status +// 09-28-2012, Added Show Latest System Logs/Hide Log Words +// 09-28-2012, Added Show Custom Asterisk Command // $myself = $_SERVER['PHP_SELF']; @@ -96,6 +99,22 @@ $value = 'status_jabber_show_status = yes'; fwrite($fp, $value."\n"); } + if (isset($_POST['custom_asterisk'])) { + $value = 'status_custom_asterisk_status = yes'; + fwrite($fp, $value."\n"); + } + if (($value = trim($_POST['asterisk_name'])) !== '') { + $value = 'status_custom_asterisk_name_cmdstr = "'.$value.'"'; + fwrite($fp, $value."\n"); + } + if (($value = trim($_POST['asterisk_cmd'])) !== '') { + $value = 'status_custom_asterisk_cmdstr = "'.$value.'"'; + fwrite($fp, $value."\n"); + } + if (isset($_POST['adaptive_ban'])) { + $value = 'status_show_adaptive_ban = yes'; + fwrite($fp, $value."\n"); + } if (isset($_POST['firewall_states'])) { $value = 'status_show_firewall_states = yes'; fwrite($fp, $value."\n"); @@ -116,6 +135,15 @@ $value = 'status_show_hardware_monitoring = yes'; fwrite($fp, $value."\n"); } + if (! isset($_POST['system_logs'])) { + $value = 'status_show_system_logs = no'; + fwrite($fp, $value."\n"); + } + if (($value = trim($_POST['exclude_logs'])) !== '') { + $value = 'status_exclude_logs_cmdstr = "'.$value.'"'; + fwrite($fp, $value."\n"); + } + if (isset($_POST['exclude_extensions'])) { $value = 'status_exclude_extensions = yes'; fwrite($fp, $value."\n"); @@ -532,8 +560,23 @@ $value = 'jabber show connections'; } putHtml('<input type="text" size="28" maxlength="64" value="'.$value.'" name="jabber_cmd" /></td></tr>'); - + putHtml('<tr class="dtrow1"><td style="text-align: right;">'); + $sel = (getPREFdef($global_prefs, 'status_custom_asterisk_status') === 'yes') ? ' checked="checked"' : ''; + putHtml('<input type="checkbox" value="custom_asterisk" name="custom_asterisk"'.$sel.' /></td><td colspan="5">Custom Asterisk Name:'); + if (($value = getPREFdef($global_prefs, 'status_custom_asterisk_name_cmdstr')) === '') { + $value = 'Asterisk Command Status'; + } + putHtml('<input type="text" size="28" maxlength="64" value="'.$value.'" name="asterisk_name" /></td></tr>'); + putHtml('<tr class="dtrow1"><td style="text-align: right;" colspan="3">Custom Asterisk Command:</td><td colspan="3">'); + $value = getPREFdef($global_prefs, 'status_custom_asterisk_cmdstr'); + putHtml('<input type="text" size="28" maxlength="64" value="'.$value.'" name="asterisk_cmd" /></td></tr>'); + + putHtml('<tr class="dtrow1"><td style="text-align: right;">'); + $sel = (getPREFdef($global_prefs, 'status_show_adaptive_ban') === 'yes') ? ' checked="checked"' : ''; + putHtml('<input type="checkbox" value="adaptive_ban" name="adaptive_ban"'.$sel.' /></td><td colspan="5">Show Adaptive Ban Plugin Status</td></tr>'); + + putHtml('<tr class="dtrow1"><td style="text-align: right;">'); $sel = (getPREFdef($global_prefs, 'status_show_firewall_states') === 'yes') ? ' checked="checked"' : ''; putHtml('<input type="checkbox" value="firewall_states" name="firewall_states"'.$sel.' /></td><td colspan="5">Show Firewall States</td></tr>'); putHtml('<tr class="dtrow1"><td style="text-align: right;" colspan="2">Hide SRC Ports:</td><td colspan="4">'); @@ -549,7 +592,15 @@ putHtml('<tr class="dtrow1"><td style="text-align: right;">'); $sel = (getPREFdef($global_prefs, 'status_show_hardware_monitoring') === 'yes') ? ' checked="checked"' : ''; putHtml('<input type="checkbox" value="hardware_monitoring" name="hardware_monitoring"'.$sel.' /></td><td colspan="5">Show Hardware Monitoring</td></tr>'); + putHtml('<tr class="dtrow1"><td style="text-align: right;">'); + $sel = (getPREFdef($global_prefs, 'status_show_system_logs') !== 'no') ? ' checked="checked"' : ''; + putHtml('<input type="checkbox" value="system_logs" name="system_logs"'.$sel.' /></td><td colspan="5">Show Latest System Logs</td></tr>'); + putHtml('<tr class="dtrow1"><td style="text-align: right;" colspan="2">Hide Log Words:</td><td colspan="4">'); + $value = getPREFdef($global_prefs, 'status_exclude_logs_cmdstr'); + putHtml('<input type="text" size="48" maxlength="128" value="'.$value.'" name="exclude_logs" /></td></tr>'); + + putHtml('<tr class="dtrow1"><td style="text-align: right;">'); $sel = (getPREFdef($global_prefs, 'status_exclude_extensions') === 'yes') ? ' checked="checked"' : ''; putHtml('<input type="checkbox" value="exclude_extensions" name="exclude_extensions"'.$sel.' /></td><td colspan="5">Exclude 4-digit Extensions in SIP/IAX2 Peer Status</td></tr>'); putHtml('<tr class="dtrow1"><td style="text-align: right;">'); @@ -558,7 +609,7 @@ putHtml('<tr class="dtrow1"><td style="text-align: right;">'); $sel = (getPREFdef($global_prefs, 'status_asterisk_manager') === 'no') ? ' checked="checked"' : ''; putHtml('<input type="checkbox" value="disable_ami" name="disable_ami"'.$sel.' /></td><td colspan="5">Disable Asterisk Manager Interface for Asterisk Commands</td></tr>'); - + putHtml('<tr class="dtrow0"><td colspan="6"> </td></tr>'); putHtml('<tr class="dtrow0"><td class="dialogText" style="text-align: left;" colspan="6">'); Modified: branches/1.0/package/webinterface/altweb/common/status.inc =================================================================== --- branches/1.0/package/webinterface/altweb/common/status.inc 2012-09-27 03:44:39 UTC (rev 5695) +++ branches/1.0/package/webinterface/altweb/common/status.inc 2012-09-28 20:05:27 UTC (rev 5696) @@ -26,6 +26,9 @@ // 08-10-2011, Added APC UPS Status // 01-02-2012, Added Jabber Status // 07-07-2012, Added UPnP Status +// 09-28-2012, Added Adaptive Ban Plugin Status +// 09-28-2012, Added Latest System Logs/Hide Log Words +// 09-28-2012, Added Custom Asterisk Command // // System location of OpenVPN Client logfile $OVPNCLOGFILE = '/var/log/openvpnclient-status.log'; @@ -1007,8 +1010,52 @@ @unlink($tmpfile); putHtml("</pre>"); } + + if ($status == 0 && getPREFdef($global_prefs, 'status_custom_asterisk_status') === 'yes') { + if (($cmd = getPREFdef($global_prefs, 'status_custom_asterisk_name_cmdstr')) === '') { + $cmd = 'Asterisk Command Status'; + } + putHtml("<h2>".htmlspecialchars($cmd).":</h2>"); + putHtml("<pre>"); + if (($cmd = getPREFdef($global_prefs, 'status_custom_asterisk_cmdstr')) !== '') { + $tmpfile = tempnam("/tmp", "PHP_"); + asteriskCMD($cmd, $tmpfile); + $ph = @fopen($tmpfile, "r"); + while (! feof($ph)) { + if ($line = trim(fgets($ph, 1024))) { + if (strncasecmp($line, 'verbosity ', 10)) { + putText($line); + } + } + } + fclose($ph); + @unlink($tmpfile); + } + putHtml("</pre>"); + } } +if (is_file('/var/lock/aif_adaptive_ban.lock')) { + if (getPREFdef($global_prefs, 'status_show_adaptive_ban') === 'yes') { + putHtml("<h2>Adaptive Ban Plugin Status:</h2>"); + putHtml("<pre>"); + $tmpfile = tempnam("/tmp", "PHP_"); + $ipv6 = trim(shell_exec('. /etc/rc.conf; if [ "$IPV6" = "yes" ]; then echo "1"; else echo "0"; fi')); + $cmd = '/usr/share/arno-iptables-firewall/plugins/adaptive-ban-helper status /usr/sbin/iptables /usr/sbin/ip6tables '.$ipv6; + shell($cmd.' >'.$tmpfile, $status); + + $ph = @fopen($tmpfile, "r"); + while (! feof($ph)) { + if ($line = trim(fgets($ph, 1024))) { + putText($line); + } + } + fclose($ph); + @unlink($tmpfile); + putHtml("</pre>"); + } +} + if (is_file($CONNTRACK)) { if (getPREFdef($global_prefs, 'status_show_firewall_states') === 'yes') { putHtml("<h2>Firewall States:</h2>"); @@ -1121,19 +1168,33 @@ } if ($daemon['syslogd'] > 0) { - putHtml("<h2>Latest System Logs:</h2>"); - putHtml("<pre>"); - $tmpfile = tempnam("/tmp", "PHP_"); - shell('tail -n 30 /var/log/messages >'.$tmpfile, $status); - $ph = @fopen($tmpfile, "r"); - while (! feof($ph)) { - if ($line = trim(fgets($ph, 1024))) { - putText($line); + if (getPREFdef($global_prefs, 'status_show_system_logs') !== 'no') { + putHtml("<h2>Latest System Logs:</h2>"); + putHtml("<pre>"); + $tmpfile = tempnam("/tmp", "PHP_"); + if (($str = getPREFdef($global_prefs, 'status_exclude_logs_cmdstr')) !== '') { + $exclude_words = explode(' ', $str); + $exclude_logs = ''; + foreach ($exclude_words as $exclude_word) { + if ($exclude_word !== '') { + $exclude_word = strtr($exclude_word, '$`[]\'\\', '......'); // map special chars to dot + $exclude_logs .= " -e '$exclude_word'"; + } + } + shell('grep -v -i '.$exclude_logs.' /var/log/messages | tail -n 30 >'.$tmpfile, $status); + } else { + shell('tail -n 30 /var/log/messages >'.$tmpfile, $status); } + $ph = @fopen($tmpfile, "r"); + while (! feof($ph)) { + if ($line = trim(fgets($ph, 1024))) { + putText($line); + } + } + fclose($ph); + @unlink($tmpfile); + putHtml("</pre>"); } - fclose($ph); - @unlink($tmpfile); - putHtml("</pre>"); } putHtml('<p style="color: orange;">Asterisk® is a registered trademark of Digium, Inc.</p>'); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |