Skip to content

Commit

Permalink
Prepend URIPrefix to web interface links
Browse files Browse the repository at this point in the history
Prefix links in templates with URIPrefix and add the input field to the
Listener editor.

The URIPrefix is provided as a top-level template variable. All URIs
have been changed to have the prefix prepended.
  • Loading branch information
uu1101 committed Feb 16, 2014
1 parent d796fc8 commit 4376b37
Show file tree
Hide file tree
Showing 21 changed files with 57 additions and 40 deletions.
4 changes: 2 additions & 2 deletions modules/data/cert/tmpl/index.tmpl
@@ -1,12 +1,12 @@
<? INC Header.tmpl ?>

<? IF Cert ?>
<p>You already have a certificate set, use the form below to overwrite the current certificate. Alternatively click <a href="<? VAR ModPath ?>delete">here</a> to <a href="<? VAR ModPath ?>delete">delete</a> your certificate.</p>
<p>You already have a certificate set, use the form below to overwrite the current certificate. Alternatively click <a href="<? VAR URIPrefix TOP ?><? VAR ModPath ?>delete">here</a> to <a href="<? VAR URIPrefix TOP ?><? VAR ModPath ?>delete">delete</a> your certificate.</p>
<? ELSE ?>
<p>You do not have a cert.</p>
<? ENDIF ?>

<form method="post" action="<? VAR ModPath ?>update">
<form method="post" action="<? VAR URIPrefix TOP ?><? VAR ModPath ?>update">
<? INC _csrf_check.tmpl ?>
<div class="section">
<h3>Certificate</h3>
Expand Down
2 changes: 1 addition & 1 deletion modules/data/certauth/tmpl/index.tmpl
@@ -1,6 +1,6 @@
<? INC Header.tmpl ?>

<form method="post" action="<? VAR ModPath ?>add">
<form method="post" action="<? VAR URIPrefix TOP ?><? VAR ModPath ?>add">
<? INC _csrf_check.tmpl ?>
<div class="section">
<h3>Add A Note</h3>
Expand Down
4 changes: 2 additions & 2 deletions modules/data/lastseen/tmpl/index.tmpl
Expand Up @@ -17,8 +17,8 @@
<td><? VAR LastSeen DEFAULT="- unknown -" ?></td>
<td><? VAR Info ?></td>
<? IF WebAdminLoaded TOP ?><td><span class="nowrap">
[<a href="/mods/global/webadmin/edituser?user=<?VAR Username ESC=URL?>">Edit</a>]
<? IF !IsSelf ?>[<a href="/mods/global/webadmin/deluser?user=<?VAR Username ESC=URL?>">Delete</a>]<? ENDIF ?>
[<a href="<? VAR URIPrefix TOP ?>/mods/global/webadmin/edituser?user=<?VAR Username ESC=URL?>">Edit</a>]
<? IF !IsSelf ?>[<a href="<? VAR URIPrefix TOP ?>/mods/global/webadmin/deluser?user=<?VAR Username ESC=URL?>">Delete</a>]<? ENDIF ?>
</span></td><? ENDIF ?>
</tr>
<? ENDLOOP ?>
Expand Down
4 changes: 2 additions & 2 deletions modules/data/notes/tmpl/index.tmpl
@@ -1,6 +1,6 @@
<? INC Header.tmpl ?>

<form method="post" action="<? VAR ModPath ?>addnote">
<form method="post" action="<? VAR URIPrefix TOP ?><? VAR ModPath ?>addnote">
<? INC _csrf_check.tmpl ?>
<div class="section">
<h3>Add A Note</h3>
Expand Down Expand Up @@ -37,7 +37,7 @@
<tbody>
<? LOOP NotesLoop ?>
<tr class="<? IF __EVEN__ ?>evenrow<? ELSE ?>oddrow<? ENDIF ?>">
<td><a href="<? VAR ModPath TOP ?>delnote?key=<? VAR Key ESC=URL,HTML ?>"><img src="<? VAR ModFilesPath TOP ?>trash.gif" alt="[del]" /></a></td>
<td><a href="<? VAR URIPrefix TOP ?><? VAR ModPath TOP ?>delnote?key=<? VAR Key ESC=URL,HTML ?>"><img src="<? VAR URIPrefix TOP ?><? VAR ModFilesPath TOP ?>trash.gif" alt="[del]" /></a></td>
<td><? VAR Key ?></td>
<td><? VAR Note ?></td>
</tr>
Expand Down
2 changes: 1 addition & 1 deletion modules/data/perform/tmpl/index.tmpl
@@ -1,6 +1,6 @@
<? INC Header.tmpl ?>

<form method="post" action="<? VAR ModPath ?>">
<form method="post" action="<? VAR URIPrefix TOP ?><? VAR ModPath ?>">
<? INC _csrf_check.tmpl ?>
<div class="section">
<h3>Perform</h3>
Expand Down
2 changes: 1 addition & 1 deletion modules/data/send_raw/tmpl/index.tmpl
@@ -1,7 +1,7 @@
<? ADDROW JSLoop HREF=/modfiles/user/send_raw/select.js ?>
<? INC Header.tmpl ?>

<form method="post" action="<? VAR ModPath ?>">
<form method="post" action="<? VAR URIPrefix TOP ?><? VAR ModPath ?>">
<? INC _csrf_check.tmpl ?>

<div class="section">
Expand Down
2 changes: 1 addition & 1 deletion modules/data/stickychan/tmpl/index.tmpl
@@ -1,6 +1,6 @@
<? INC Header.tmpl ?>

<form action="" method="post">
<form method="post" action="<? VAR URIPrefix TOP ?><? VAR ModPath TOP ?>">
<? INC _csrf_check.tmpl ?>
<table class="data">
<thead>
Expand Down
2 changes: 1 addition & 1 deletion modules/data/webadmin/tmpl/add_edit_chan.tmpl
@@ -1,6 +1,6 @@
<? INC Header.tmpl ?>

<form action="<? IF Edit ?>editchan<? ELSE ?>addchan<? ENDIF ?>" method="post">
<form action="<? VAR URIPrefix TOP ?><? VAR ModPath TOP ?><? IF Edit ?>editchan<? ELSE ?>addchan<? ENDIF ?>" method="post">
<? INC _csrf_check.tmpl ?>
<div class="section">
<input type="hidden" name="submitted" value="1" />
Expand Down
6 changes: 3 additions & 3 deletions modules/data/webadmin/tmpl/add_edit_network.tmpl
Expand Up @@ -5,7 +5,7 @@
<p>To connect to this network from your IRC client, you can set the server password field as follows: <code><? VAR Username ?>/<? IF Edit ?><? VAR Name ?><? ELSE ?>&lt;network&gt;<? ENDIF ?>:&lt;password&gt;</code> or username field as <code><? VAR Username ?>/<? IF Edit ?><? VAR Name ?><? ELSE ?>&lt;network&gt;<? ENDIF ?></code></p>
</div>

<form action="<? IF Edit ?>editnetwork<? ELSE ?>addnetwork<? ENDIF ?>" method="post">
<form action="<? VAR URIPrefix TOP ?><? VAR ModPath TOP ?><? IF Edit ?>editnetwork<? ELSE ?>addnetwork<? ENDIF ?>" method="post">
<? INC _csrf_check.tmpl ?>
<div class="section">
<input type="hidden" name="submitted" value="1" />
Expand Down Expand Up @@ -116,7 +116,7 @@
<table>
<thead>
<tr>
<td>[<a href="addchan?user=<? VAR Username ESC=URL ?>&amp;network=<? VAR Name ESC=URL ?>">Add</a>]</td>
<td>[<a href="<? VAR URIPrefix TOP ?><? VAR ModPath TOP ?>addchan?user=<? VAR Username ESC=URL ?>&amp;network=<? VAR Name ESC=URL ?>">Add</a>]</td>
<? IF ChannelLoop ?>
<td>Save</td>
<td>Name</td>
Expand All @@ -135,7 +135,7 @@
<tr class="<? IF __EVEN__ ?>evenrow<? ELSE ?>oddrow<? ENDIF ?>">
<td>
<input type="hidden" name="channel" value="<? VAR Name ?>" />
[<a href="editchan?user=<? VAR Username ESC=URL ?>&amp;network=<? VAR Network ESC=URL ?>&amp;name=<? VAR Name ESC=URL ?>">Edit</a>] [<a href="delchan?user=<? VAR Username ESC=URL ?>&amp;network=<? VAR Network ESC=URL ?>&amp;name=<? VAR Name ESC=URL ?>">Del</a>]
[<a href="<? VAR URIPrefix TOP ?><? VAR ModPath TOP ?>editchan?user=<? VAR Username ESC=URL ?>&amp;network=<? VAR Network ESC=URL ?>&amp;name=<? VAR Name ESC=URL ?>">Edit</a>] [<a href="<? VAR URIPrefix TOP ?><? VAR ModPath TOP ?>delchan?user=<? VAR Username ESC=URL ?>&amp;network=<? VAR Network ESC=URL ?>&amp;name=<? VAR Name ESC=URL ?>">Del</a>]
</td>
<td><input type="checkbox" name="save_<? VAR Name ?>"<? IF InConfig ?> checked="checked"<? ENDIF ?> /></td>
<td><? VAR Name ?></td>
Expand Down
6 changes: 3 additions & 3 deletions modules/data/webadmin/tmpl/add_edit_user.tmpl
@@ -1,6 +1,6 @@
<? INC Header.tmpl ?>

<form action="<? IF Edit ?>edituser<? ELSE ?>adduser<? ENDIF ?>" method="post">
<form action="<? VAR URIPrefix TOP ?><? VAR ModPath TOP ?><? IF Edit ?>edituser<? ELSE ?>adduser<? ENDIF ?>" method="post">
<? INC _csrf_check.tmpl ?>
<div class="section">
<input type="hidden" name="submitted" value="1" />
Expand Down Expand Up @@ -128,7 +128,7 @@
<table>
<thead>
<tr>
<td>[<a href="addnetwork?user=<? VAR Username ESC=URL ?>">Add</a>]</td>
<td>[<a href="<? VAR URIPrefix TOP ?><? VAR ModPath TOP ?>addnetwork?user=<? VAR Username ESC=URL ?>">Add</a>]</td>
<? IF NetworkLoop ?>
<td>Name</td>
<td>Clients</td>
Expand All @@ -145,7 +145,7 @@
<tr class="<? IF __EVEN__ ?>evenrow<? ELSE ?>oddrow<? ENDIF ?>">
<td>
<input type="hidden" name="network" value="<? VAR Name ?>" />
[<a href="editnetwork?user=<? VAR Username ESC=URL ?>&amp;network=<? VAR Name ESC=URL ?>">Edit</a>] [<a href="delnetwork?user=<? VAR Username ESC=URL ?>&amp;name=<? VAR Name ESC=URL ?>">Del</a>]
[<a href="<? VAR URIPrefix TOP ?><? VAR ModPath TOP ?>editnetwork?user=<? VAR Username ESC=URL ?>&amp;network=<? VAR Name ESC=URL ?>">Edit</a>] [<a href="<? VAR URIPrefix TOP ?><? VAR ModPath TOP ?>delnetwork?user=<? VAR Username ESC=URL ?>&amp;name=<? VAR Name ESC=URL ?>">Del</a>]
</td>
<td><? VAR Name ?></td>
<td><? VAR Clients ?></td>
Expand Down
4 changes: 2 additions & 2 deletions modules/data/webadmin/tmpl/del_network.tmpl
Expand Up @@ -6,13 +6,13 @@
<div class="sectionbody">
<div class="subsection">
Are you sure you want to delete "<? VAR Username ?>/<? VAR Network ?>"?
<form action="delnetwork" method="post">
<form action="<? VAR URIPrefix TOP ?><? VAR ModPath TOP ?>delnetwork" method="post">
<? INC _csrf_check.tmpl ?>
<input type="hidden" name="user" value="<? VAR Username ?>" />
<input type="hidden" name="name" value="<? VAR Network ?>" />
<div class="yesnobutton"><input type="submit" value="Yes" /></div>
</form>
<form action="listusers" method="get">
<form action="<? VAR URIPrefix TOP ?><? VAR ModPath TOP ?>listusers" method="get">
<div class="yesnobutton"><input type="submit" value="No" /></div>
</form>
</div>
Expand Down
4 changes: 2 additions & 2 deletions modules/data/webadmin/tmpl/del_user.tmpl
Expand Up @@ -6,13 +6,13 @@
<div class="sectionbody">
<div class="subsection">
Are you sure you want to delete "<? VAR Username ?>"?
<form action="deluser" method="post">
<form action="<? VAR URIPrefix TOP ?><? VAR ModPath TOP ?>deluser" method="post">
<? INC _csrf_check.tmpl ?>
<input type="hidden" name="submitted" value="1" />
<input type="hidden" name="user" value="<? VAR Username ?>" />
<div class="yesnobutton"><input type="submit" value="Yes" /></div>
</form>
<form action="listusers" method="get">
<form action="<? VAR URIPrefix TOP ?><? VAR ModPath TOP ?>listusers" method="get">
<div class="yesnobutton"><input type="submit" value="No" /></div>
</form>
</div>
Expand Down
8 changes: 4 additions & 4 deletions modules/data/webadmin/tmpl/listusers.tmpl
Expand Up @@ -2,7 +2,7 @@

<?IF !UserLoop?>
<div class="textsection">
There are no users defined. Click <a href="adduser">here</a> if you would like to add one.
There are no users defined. Click <a href="<? VAR URIPrefix TOP ?><? VAR ModPath TOP ?>adduser">here</a> if you would like to add one.
</div>
<?ELSE?>
<div class="toptable">
Expand All @@ -21,9 +21,9 @@
<tr class="<?IF __EVEN__?>evenrow<?ELSE?>oddrow<?ENDIF?>">
<td>
<span class="nowrap">
[<a href="edituser?user=<?VAR Username ESC=URL?>">Edit</a>]
[<a href="adduser?clone=<? VAR Username ESC=URL ?>" alt="Clone <? VAR Username ESC=URL ?>">Clone</a>]
<? IF !IsSelf ?>[<a href="deluser?user=<?VAR Username ESC=URL?>">Delete</a>]<? ENDIF ?>
[<a href="<? VAR URIPrefix TOP ?><? VAR ModPath TOP ?>edituser?user=<?VAR Username ESC=URL?>">Edit</a>]
[<a href="<? VAR URIPrefix TOP ?><? VAR ModPath TOP ?>adduser?clone=<? VAR Username ESC=URL ?>" alt="Clone <? VAR Username ESC=URL ?>">Clone</a>]
<? IF !IsSelf ?>[<a href="<? VAR URIPrefix TOP ?><? VAR ModPath TOP ?>deluser?user=<?VAR Username ESC=URL?>">Delete</a>]<? ENDIF ?>
</span>
</td>
<td><? VAR Username ?></td>
Expand Down
6 changes: 3 additions & 3 deletions modules/data/webadmin/tmpl/settings.tmpl
Expand Up @@ -42,7 +42,7 @@
<td><? VAR URIPrefix ?></td>
<td>
<? IF SuggestDeletion ?>
<form action="del_listener" method="post">
<form action="<? VAR URIPrefix TOP ?><? VAR ModPath TOP ?>del_listener" method="post">
<? INC _csrf_check.tmpl ?>
<input name="host" type="hidden" value="<? VAR BindHost ?>"/>
<input name="port" type="hidden" value="<? VAR Port ?>"/>
Expand All @@ -55,7 +55,7 @@
</tr>
<? ENDLOOP ?>
<tr>
<form action="add_listener" method="post">
<form action="<? VAR URIPrefix TOP ?><? VAR ModPath TOP ?>add_listener" method="post">
<? INC _csrf_check.tmpl ?>
<td><input name="port" type="number" min="1" max="65535" class="number"/></td>
<td><input name="host" type="text" value="*" class="sixth"/></td>
Expand All @@ -74,7 +74,7 @@
</div>
</div>

<form action="settings" method="post">
<form action="<? VAR URIPrefix TOP ?><? VAR ModPath TOP ?>settings" method="post">
<? INC _csrf_check.tmpl ?>
<input type="hidden" name="submitted" value="1" />

Expand Down
2 changes: 2 additions & 0 deletions src/WebModules.cpp
Expand Up @@ -325,6 +325,7 @@ void CWebSock::SetVars() {
m_Template["Version"] = CZNC::GetVersion();
m_Template["SkinName"] = GetSkinName();
m_Template["_CSRF_Check"] = GetCSRFCheck();
m_Template["URIPrefix"] = GetURIPrefix();

if (GetSession()->IsAdmin()) {
m_Template["IsAdmin"] = "true";
Expand Down Expand Up @@ -473,6 +474,7 @@ CWebSock::EPageReqResult CWebSock::PrintStaticFile(const CString& sPath, CString

CWebSock::EPageReqResult CWebSock::PrintTemplate(const CString& sPageName, CString& sPageRet, CModule* pModule) {
SetVars();

m_Template["PageName"] = sPageName;

if (pModule) {
Expand Down
7 changes: 6 additions & 1 deletion webskins/_default_/pub/_default_.css
Expand Up @@ -247,6 +247,11 @@ input.third, textarea.third,
width: 150px;
}

input.sixth, textarea.sixth,
.sixth input, .sixth textarea {
width: 75px;
}

input.number {
width: 40px;
}
Expand Down Expand Up @@ -299,7 +304,7 @@ tr.evenrow td {

.subsection input, .subsection select, .subsection textarea {
margin: 5px 0 5px 0;
min-width: 100px;
min-width: 75px;
vertical-align: middle;
}

Expand Down
4 changes: 2 additions & 2 deletions webskins/_default_/tmpl/BaseHeader.tmpl
Expand Up @@ -6,11 +6,11 @@
<meta charset="UTF-8" />
<title>ZNC - <? VAR Title DEFAULT="Web Frontend" ?></title>
<? LOOP CSSLoop ?>
<?IF HREF?><link rel="stylesheet" type="text/css" href="<? VAR HREF ?>" /><?ENDIF?>
<?IF HREF?><link rel="stylesheet" type="text/css" href="<? VAR URIPrefix TOP ?><? VAR HREF ?>" /><?ENDIF?>
<?ENDLOOP?>

<? LOOP JSLoop ?>
<?IF HREF?><script type="text/javascript" src="<? VAR HREF ?>"></script><?ENDIF?>
<?IF HREF?><script type="text/javascript" src="<? VAR URIPrefix TOP ?><? VAR HREF ?>"></script><?ENDIF?>
<?ENDLOOP?>

<? INC ExtraHeader.tmpl ?>
Expand Down
4 changes: 2 additions & 2 deletions webskins/_default_/tmpl/LoginBar.tmpl
@@ -1,9 +1,9 @@
<? IF LoggedIn ?>
<span class="logoutbox"><a href="/logout">Logout</a></span>
<span class="logoutbox"><a href="<? VAR URIPrefix TOP ?>/logout">Logout</a></span>
<? ELSE IF !ModName && PageName == "login" ?>
<span class="logoutbox">&nbsp;</span>
<? ELSE ?>
<form action="/login" method="post">
<form action="<? VAR URIPrefix TOP ?>/login" method="post">
<div class="loginbox">
<input type="hidden" name="submitted" value="1" />
User:<input type="text" name="user" />
Expand Down
14 changes: 7 additions & 7 deletions webskins/_default_/tmpl/Menu.tmpl
@@ -1,14 +1,14 @@
<div id="menu">
<ul class="nav">
<li class="topitem<? IF !ModName && PageName == "index" ?> active<? ENDIF ?>"><a href="/">Home</a></li>
<li class="topitem<? IF !ModName && PageName == "index" ?> active<? ENDIF ?>"><a href="<? VAR URIPrefix TOP ?>/">Home</a></li>

<? IF GlobalModLoop ?>
<li class="topitem parent"><span class="title">Global Modules</span>
<ul>
<? LOOP GlobalModLoop SORTASC=ModName ?>
<li class="modtitle<? IF Active ?> active<? ENDIF ?>"><a href="<? VAR ModPath ?>"><? VAR Title ?></a></li>
<li class="modtitle<? IF Active ?> active<? ENDIF ?>"><a href="<? VAR URIPrefix TOP ?><? VAR ModPath ?>"><? VAR Title ?></a></li>
<? LOOP SubPageLoop ?>
<li class="subitem<? IF Active ?> active<? ENDIF ?>"><a href="<? VAR ModPath ?><? VAR PageName ?><? IF Params ?>?<? VAR Params ?><? ENDIF ?>"><? VAR Title ?></a></li>
<li class="subitem<? IF Active ?> active<? ENDIF ?>"><a href="<? VAR URIPrefix TOP ?><? VAR ModPath ?><? VAR PageName ?><? IF Params ?>?<? VAR Params ?><? ENDIF ?>"><? VAR Title ?></a></li>
<? ENDLOOP ?>
<? ENDLOOP ?>
</ul>
Expand All @@ -19,9 +19,9 @@
<li class="topitem parent"><span class="title">User Modules</span>
<ul>
<? LOOP UserModLoop SORTASC=ModName ?>
<li class="modtitle<? IF Active ?> active<? ENDIF ?>"><a href="<? VAR ModPath ?>"><? VAR Title ?></a></li>
<li class="modtitle<? IF Active ?> active<? ENDIF ?>"><a href="<? VAR URIPrefix TOP ?><? VAR ModPath ?>"><? VAR Title ?></a></li>
<? LOOP SubPageLoop ?>
<li class="subitem<? IF Active ?> active<? ENDIF ?>"><a href="<? VAR ModPath ?><? VAR PageName ?><? IF Params ?>?<? VAR Params ?><? ENDIF ?>"><? VAR Title ?></a></li>
<li class="subitem<? IF Active ?> active<? ENDIF ?>"><a href="<? VAR URIPrefix TOP ?><? VAR ModPath ?><? VAR PageName ?><? IF Params ?>?<? VAR Params ?><? ENDIF ?>"><? VAR Title ?></a></li>
<? ENDLOOP ?>
<? ENDLOOP ?>
</ul>
Expand All @@ -34,9 +34,9 @@
<li class="topitem parent"><span class="title">Network Modules (<? VAR NetworkName ?>)</span>
<ul>
<? LOOP ModLoop SORTASC=ModName ?>
<li class="modtitle<? IF Active ?> active<? ENDIF ?>"><a href="<? VAR ModPath ?>"><? VAR Title ?></a></li>
<li class="modtitle<? IF Active ?> active<? ENDIF ?>"><a href="<? VAR URIPrefix TOP ?><? VAR ModPath ?>"><? VAR Title ?></a></li>
<? LOOP SubPageLoop ?>
<li class="subitem<? IF Active ?> active<? ENDIF ?>"><a href="<? VAR ModPath ?><? VAR PageName ?><? IF Params ?>?<? VAR Params ?><? ENDIF ?>"><? VAR Title ?></a></li>
<li class="subitem<? IF Active ?> active<? ENDIF ?>"><a href="<? VAR URIPrefix TOP ?><? VAR ModPath ?><? VAR PageName ?><? IF Params ?>?<? VAR Params ?><? ENDIF ?>"><? VAR Title ?></a></li>
<? ENDLOOP ?>
<? ENDLOOP ?>
</ul>
Expand Down
5 changes: 5 additions & 0 deletions webskins/dark-clouds/pub/dark-clouds.css
Expand Up @@ -167,6 +167,11 @@ input.third, textarea.third,
width: 100px;
}

input.sixth, textarea.sixth,
.sixth input, .sixth textarea {
width: 50px;
}

.checkboxandlabel {
white-space: nowrap;
}
Expand Down
5 changes: 5 additions & 0 deletions webskins/ice/pub/ice.css
Expand Up @@ -141,6 +141,11 @@ input.third, textarea.third,
width: 125px;
}

input.sixth, textarea.sixth,
.sixth input, .sixth textarea {
width: 62px;
}

.subsection div.checkbox {
padding: 9px 0 0 3px;
}
Expand Down

0 comments on commit 4376b37

Please sign in to comment.