From: <abe...@us...> - 2013-01-21 08:25:16
|
Revision: 5918 http://astlinux.svn.sourceforge.net/astlinux/?rev=5918&view=rev Author: abelbeck Date: 2013-01-21 08:25:09 +0000 (Mon, 21 Jan 2013) Log Message: ----------- web interface, add XMPP_GROUPS and prosody Status tab support Modified Paths: -------------- branches/1.0/package/webinterface/altweb/admin/edit.php branches/1.0/package/webinterface/altweb/admin/prefs.php branches/1.0/package/webinterface/altweb/admin/xmpp.php branches/1.0/package/webinterface/altweb/common/status.inc Modified: branches/1.0/package/webinterface/altweb/admin/edit.php =================================================================== --- branches/1.0/package/webinterface/altweb/admin/edit.php 2013-01-21 08:08:32 UTC (rev 5917) +++ branches/1.0/package/webinterface/altweb/admin/edit.php 2013-01-21 08:25:09 UTC (rev 5918) @@ -1,6 +1,6 @@ <?php -// Copyright (C) 2008-2011 Lonnie Abelbeck +// Copyright (C) 2008-2013 Lonnie Abelbeck // This is free software, licensed under the GNU General Public License // version 3 as published by the Free Software Foundation; you can // redistribute it and/or modify it under the terms of the GNU @@ -251,6 +251,7 @@ $dir === '/mnt/kd/rc.conf.d' || $dir === '/mnt/kd/crontabs' || $dir === '/mnt/kd/apcupsd' || + $dir === '/mnt/kd/prosody' || $dir === '/mnt/kd/docs' || $dir === '/mnt/kd/arno-iptables-firewall' || $dir === '/mnt/kd/arno-iptables-firewall/plugins' || @@ -460,6 +461,14 @@ $sel = ($file === $openfile) ? ' selected="selected"' : ''; putHtml('<option value="'.$file.'"'.$sel.'>'.basename($file).' - Net Interface Rules</option>'); } + if (is_writable($file = '/mnt/kd/prosody/prosody.conf')) { + $sel = ($file === $openfile) ? ' selected="selected"' : ''; + putHtml('<option value="'.$file.'"'.$sel.'>prosody/'.basename($file).' - XMPP Configuration</option>'); + } + if (is_writable($file = '/mnt/kd/prosody/sharedgroups.conf')) { + $sel = ($file === $openfile) ? ' selected="selected"' : ''; + putHtml('<option value="'.$file.'"'.$sel.'>prosody/'.basename($file).' - XMPP Shared Groups</option>'); + } putHtml('</optgroup>'); if (is_dir('/mnt/kd/docs')) { putHtml('<optgroup label="———— Documentation ————">'); Modified: branches/1.0/package/webinterface/altweb/admin/prefs.php =================================================================== --- branches/1.0/package/webinterface/altweb/admin/prefs.php 2013-01-21 08:08:32 UTC (rev 5917) +++ branches/1.0/package/webinterface/altweb/admin/prefs.php 2013-01-21 08:25:09 UTC (rev 5918) @@ -1,6 +1,6 @@ <?php -// Copyright (C) 2008-2012 Lonnie Abelbeck +// Copyright (C) 2008-2013 Lonnie Abelbeck // This is free software, licensed under the GNU General Public License // version 3 as published by the Free Software Foundation; you can // redistribute it and/or modify it under the terms of the GNU @@ -15,6 +15,7 @@ // 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 +// 01-20-2013, Added Show XMPP Server Status // $myself = $_SERVER['PHP_SELF']; @@ -111,6 +112,10 @@ $value = 'status_custom_asterisk_cmdstr = "'.$value.'"'; fwrite($fp, $value."\n"); } + if (! isset($_POST['xmpp_server'])) { + $value = 'status_show_xmpp_server = no'; + fwrite($fp, $value."\n"); + } if (isset($_POST['adaptive_ban'])) { $value = 'status_show_adaptive_ban = yes'; fwrite($fp, $value."\n"); @@ -573,6 +578,10 @@ 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_xmpp_server') !== 'no') ? ' checked="checked"' : ''; + putHtml('<input type="checkbox" value="xmpp_server" name="xmpp_server"'.$sel.' /></td><td colspan="5">Show XMPP Server Status</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>'); Modified: branches/1.0/package/webinterface/altweb/admin/xmpp.php =================================================================== --- branches/1.0/package/webinterface/altweb/admin/xmpp.php 2013-01-21 08:08:32 UTC (rev 5917) +++ branches/1.0/package/webinterface/altweb/admin/xmpp.php 2013-01-21 08:25:09 UTC (rev 5918) @@ -114,6 +114,9 @@ $value = 'XMPP_S2S_PORT="'.trim($_POST['xmpp_s2s_port']).'"'; fwrite($fp, "### Server to Server TCP Port\n".$value."\n"); + $value = 'XMPP_GROUPS="'.$_POST['xmpp_groups'].'"'; + fwrite($fp, "### Shared Groups\n".$value."\n"); + $value = 'XMPP_C2S_IDLE_TIMEOUT="'.$_POST['idle_timeout'].'"'; fwrite($fp, "### Dead Client Timeout\n".$value."\n"); @@ -207,6 +210,25 @@ return($status == 0 ? TRUE : FALSE); } +// Function: reloadModule +// +function reloadModule($mod) { + + if ($mod === '') { + return(FALSE); + } + if (! is_file('/mnt/kd/prosody/prosody.cfg.lua')) { + return(2); + } + if (! is_file('/var/run/prosody/prosody.pid')) { + return(3); + } + + shell('prosodycmd \'module:reload("'.$mod.'")\' >/dev/null 2>/dev/null', $status); + + return($status == 0 ? TRUE : FALSE); +} + if (is_file($XMPPCONFFILE)) { $vars = parseRCconf($XMPPCONFFILE); } else { @@ -261,10 +283,21 @@ } elseif ($result == 11 && $ok === TRUE) { $result = 14; } + } elseif (isset($_POST['submit_reload_groups'])) { + $result = 99; + if (reloadModule('groups') === TRUE) { + $result = 16; + } } elseif (isset($_POST['submit_sip_tls'])) { $result = saveXMPPsettings($XMPPCONFDIR, $XMPPCONFFILE); header('Location: /admin/siptlscert.php'); exit; + } elseif (isset($_POST['submit_edit_groups'])) { + $result = saveXMPPsettings($XMPPCONFDIR, $XMPPCONFFILE); + if (is_writable($file = '/mnt/kd/prosody/sharedgroups.conf')) { + header('Location: /admin/edit.php?file='.$file); + exit; + } } header('Location: '.$myself.'?result='.$result); exit; @@ -293,6 +326,8 @@ putHtml('<p style="color: green;">User(s) successfully deleted.</p>'); } elseif ($result == 15) { putHtml('<p style="color: green;">User successfully added or changed.</p>'); + } elseif ($result == 16) { + putHtml('<p style="color: green;">Shared Groups Reloaded.</p>'); } elseif ($result == 99) { putHtml('<p style="color: red;">Action Failed.</p>'); } elseif ($result == 999) { @@ -399,6 +434,23 @@ putHtml('</td></tr>'); putHtml('<tr class="dtrow1"><td style="text-align: right;">'); + putHtml('Shared Groups:'); + putHtml('</td><td style="text-align: left;">'); + $xmpp_groups = getVARdef($vars, 'XMPP_GROUPS'); + putHtml('<select name="xmpp_groups">'); + putHtml('<option value="no">disabled</option>'); + $sel = ($xmpp_groups === 'yes') ? ' selected="selected"' : ''; + putHtml('<option value="yes"'.$sel.'>enabled</option>'); + putHtml('</select>'); + if (is_file('/mnt/kd/prosody/sharedgroups.conf')) { + putHtml('–'); + putHtml('<input type="submit" value="Edit Groups" name="submit_edit_groups" class="button" />'); + putHtml('–'); + putHtml('<input type="submit" value="Reload" name="submit_reload_groups" class="button" />'); + } + putHtml('</td></tr>'); + + putHtml('<tr class="dtrow1"><td style="text-align: right;">'); putHtml('Server-to-Client<br />Keep Alive Ping:'); putHtml('</td><td style="text-align: left;">'); $idle_timeout = getVARdef($vars, 'XMPP_C2S_IDLE_TIMEOUT'); Modified: branches/1.0/package/webinterface/altweb/common/status.inc =================================================================== --- branches/1.0/package/webinterface/altweb/common/status.inc 2013-01-21 08:08:32 UTC (rev 5917) +++ branches/1.0/package/webinterface/altweb/common/status.inc 2013-01-21 08:25:09 UTC (rev 5918) @@ -1,6 +1,6 @@ <?php -// Copyright (C) 2008-2012 Lonnie Abelbeck +// Copyright (C) 2008-2013 Lonnie Abelbeck // This is free software, licensed under the GNU General Public License // version 3 as published by the Free Software Foundation; you can // redistribute it and/or modify it under the terms of the GNU @@ -29,6 +29,7 @@ // 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 +// 01-20-2013, Added XMPP Server Status // // System location of OpenVPN Client logfile $OVPNCLOGFILE = '/var/log/openvpnclient-status.log'; @@ -1035,6 +1036,29 @@ } } +if (is_file('/var/run/prosody/prosody.pid')) { + if (getPREFdef($global_prefs, 'status_show_xmpp_server') !== 'no') { + putHtml("<h2>XMPP Server Status:</h2>"); + putHtml("<pre>"); + $tmpfile = tempnam("/tmp", "PHP_"); + $cmd = "/usr/bin/prosodycmd 'server:version()' 'server:uptime()' 'c2s:show()'"; + if (trim(shell_exec('. /etc/rc.conf; echo "$XMPP_ENABLE_S2S"')) === 'yes') { + $cmd .= " 's2s:show()'"; + } + shell($cmd.' >'.$tmpfile, $status); + + $ph = @fopen($tmpfile, "r"); + while (! feof($ph)) { + if ($line = rtrim(fgets($ph, 1024))) { + 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>"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |