diff options
author | David Sommerseth <dazo@users.sourceforge.net> | 2009-03-29 23:32:02 +0200 |
---|---|---|
committer | David Sommerseth <dazo@users.sourceforge.net> | 2009-03-29 23:32:02 +0200 |
commit | f7e49e685734be5d2a1110833325bd7ced253b52 (patch) | |
tree | 2b96201c58574324155ea0d7a43342f4b23e92a6 /xslt | |
parent | b659361d6f45515d5895b584a10ed2292c5098c4 (diff) | |
download | eurephia-f7e49e685734be5d2a1110833325bd7ced253b52.tar.gz eurephia-f7e49e685734be5d2a1110833325bd7ced253b52.tar.xz eurephia-f7e49e685734be5d2a1110833325bd7ced253b52.zip |
Rewrote lastlog and users command to use XSLT for viewing lastlog
Diffstat (limited to 'xslt')
-rw-r--r-- | xslt/eurephiadm/lastlog.xsl | 189 |
1 files changed, 189 insertions, 0 deletions
diff --git a/xslt/eurephiadm/lastlog.xsl b/xslt/eurephiadm/lastlog.xsl new file mode 100644 index 0000000..a1da821 --- /dev/null +++ b/xslt/eurephiadm/lastlog.xsl @@ -0,0 +1,189 @@ +<?xml version="1.0"?> +<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> + <xsl:output method="text" encoding="UTF-8"/> + <xsl:strip-space elements="*"/> + + <xsl:template match="/eurephia"> + <xsl:choose> + <xsl:when test="$view = 'list'"> + <xsl:apply-templates select="lastlog|user/lastlog" mode="list"/> + </xsl:when> + <xsl:when test="$view = 'details' or $view = 'details2'"> + <xsl:apply-templates select="lastlog|user/lastlog" mode="details"/> + </xsl:when> + <xsl:otherwise> + <xsl:message terminate="yes">Invalid view: <xsl:value-of select="$view"/></xsl:message> + </xsl:otherwise> + </xsl:choose> + </xsl:template> + + <xsl:template match="lastlog" mode="list"> + <xsl:text> Status Login Logout Session closed </xsl:text> + <xsl:text>------------------------------------------------------------------------------- </xsl:text> + <xsl:apply-templates select="session" mode="list"/> + <xsl:text>------------------------------------------------------------------------------- </xsl:text> + </xsl:template> + + <xsl:template match="lastlog/session" mode="list"> + <xsl:text> </xsl:text> + <xsl:call-template name="left-align"> + <xsl:with-param name="value" select="@session_status"/> + <xsl:with-param name="width" select="10"/> + </xsl:call-template><xsl:text> </xsl:text> + <xsl:call-template name="left-align"> + <xsl:with-param name="value" select="login"/> + <xsl:with-param name="width" select="19"/> + </xsl:call-template><xsl:text> </xsl:text> + + <xsl:variable name="logout"> + <xsl:choose> + <xsl:when test="logout != ''"><xsl:value-of select="logout"/></xsl:when> + <xsl:otherwise>-</xsl:otherwise> + </xsl:choose> + </xsl:variable> + <xsl:call-template name="right-align"> + <xsl:with-param name="value" select="$logout"/> + <xsl:with-param name="width" select="19"/> + </xsl:call-template><xsl:text> </xsl:text> + + <xsl:variable name="sessionclose"> + <xsl:choose> + <xsl:when test="session_closed != ''"><xsl:value-of select="session_closed"/></xsl:when> + <xsl:otherwise>-</xsl:otherwise> + </xsl:choose> + </xsl:variable> + <xsl:call-template name="right-align"> + <xsl:with-param name="value" select="$sessionclose"/> + <xsl:with-param name="width" select="19"/> + </xsl:call-template> + <xsl:text> </xsl:text> + </xsl:template> + + + <xsl:template match="lastlog" mode="details"> + <xsl:text> Status Login Logout Session closed </xsl:text> + <xsl:text> Protocol Remote:port VPN MAC VPN IP </xsl:text> + <xsl:choose> + <xsl:when test="$view = 'details2'"> + <xsl:text> Common name / Username Organisation </xsl:text> + </xsl:when> + <xsl:otherwise> + <xsl:text> Common name Organisation </xsl:text> + </xsl:otherwise> + </xsl:choose> + <xsl:if test="$firewall = '1'"> + <xsl:text> Firewall access profile FW Destination </xsl:text> + </xsl:if> + <xsl:text>------------------------------------------------------------------------------- </xsl:text> + <xsl:apply-templates select="session" mode="details"/> + <xsl:text>------------------------------------------------------------------------------- </xsl:text> + </xsl:template> + + <xsl:template match="lastlog/session" mode="details"> + <xsl:text> </xsl:text> + <xsl:call-template name="left-align"> + <xsl:with-param name="value" select="@session_status"/> + <xsl:with-param name="width" select="10"/> + </xsl:call-template><xsl:text> </xsl:text> + <xsl:call-template name="left-align"> + <xsl:with-param name="value" select="login"/> + <xsl:with-param name="width" select="19"/> + </xsl:call-template><xsl:text> </xsl:text> + + <xsl:variable name="logout"> + <xsl:choose> + <xsl:when test="logout != ''"><xsl:value-of select="logout"/></xsl:when> + <xsl:otherwise>-</xsl:otherwise> + </xsl:choose> + </xsl:variable> + <xsl:call-template name="right-align"> + <xsl:with-param name="value" select="$logout"/> + <xsl:with-param name="width" select="19"/> + </xsl:call-template><xsl:text> </xsl:text> + + <xsl:variable name="sessionclose"> + <xsl:choose> + <xsl:when test="session_closed != ''"><xsl:value-of select="session_closed"/></xsl:when> + <xsl:otherwise>-</xsl:otherwise> + </xsl:choose> + </xsl:variable> + <xsl:call-template name="right-align"> + <xsl:with-param name="value" select="$sessionclose"/> + <xsl:with-param name="width" select="19"/> + </xsl:call-template> + <xsl:text> </xsl:text> + + <xsl:call-template name="left-align"> + <xsl:with-param name="value" select="connection/protocol"/> + <xsl:with-param name="width" select="11"/> + </xsl:call-template> + <xsl:text> </xsl:text> + <xsl:call-template name="left-align"> + <xsl:with-param name="value" select="concat(connection/remote_host,':',connection/remote_port)"/> + <xsl:with-param name="width" select="22"/> + </xsl:call-template> + <xsl:text> </xsl:text> + <xsl:call-template name="right-align"> + <xsl:with-param name="value" select="connection/vpn_macaddr"/> + <xsl:with-param name="width" select="19"/> + </xsl:call-template> + <xsl:text> </xsl:text> + <xsl:call-template name="right-align"> + <xsl:with-param name="value" select="connection/vpn_ipaddr"/> + <xsl:with-param name="width" select="19"/> + </xsl:call-template> + <xsl:text> </xsl:text> + + <xsl:choose> + <xsl:when test="$view = 'details2'"> + <xsl:call-template name="left-align"> + <xsl:with-param name="value" select="concat(certificate/common_name,' / ',username)"/> + <xsl:with-param name="width" select="37"/> + </xsl:call-template> + </xsl:when> + <xsl:otherwise> + <xsl:call-template name="left-align"> + <xsl:with-param name="value" select="certificate/common_name"/> + <xsl:with-param name="width" select="37"/> + </xsl:call-template> + </xsl:otherwise> + </xsl:choose> + <xsl:text> </xsl:text> + <xsl:call-template name="right-align"> + <xsl:with-param name="value" select="certificate/organisation"/> + <xsl:with-param name="width" select="37"/> + </xsl:call-template> + + <xsl:if test="$firewall = '1'"> + <xsl:text> </xsl:text> + <xsl:call-template name="left-align"> + <xsl:with-param name="value" select="certificate/access_profile"/> + <xsl:with-param name="width" select="37"/> + </xsl:call-template> + <xsl:text> </xsl:text> + <xsl:call-template name="right-align"> + <xsl:with-param name="value" select="certificate/access_profile/@fwdestination"/> + <xsl:with-param name="width" select="37"/> + </xsl:call-template> + </xsl:if> + + <xsl:text> </xsl:text> + <xsl:if test="last() > position()"> + <xsl:text> </xsl:text> + </xsl:if> + </xsl:template> + + + <xsl:template name="left-align"> + <xsl:param name="value"/> + <xsl:param name="width"/> + <xsl:value-of select="substring(concat($value, ' '), 1, $width)"/> + </xsl:template> + + <xsl:template name="right-align"> + <xsl:param name="value"/> + <xsl:param name="width"/> + <xsl:value-of select="concat(substring(' ', 1, $width - string-length($value)), $value)"/> + </xsl:template> + +</xsl:stylesheet> |