summaryrefslogtreecommitdiff
path: root/pages
diff options
context:
space:
mode:
Diffstat (limited to 'pages')
-rw-r--r--pages/Makefile2
-rw-r--r--pages/edit_searchtimer.ecpp4
-rw-r--r--pages/edit_timer.ecpp4
-rw-r--r--pages/edit_user.ecpp176
-rw-r--r--pages/login.ecpp5
-rw-r--r--pages/menu.ecpp1
-rw-r--r--pages/play_recording.ecpp3
-rw-r--r--pages/remote.ecpp4
-rw-r--r--pages/searchtimers.ecpp6
-rw-r--r--pages/setup.ecpp10
-rw-r--r--pages/switch_channel.ecpp4
-rw-r--r--pages/timers.ecpp3
-rw-r--r--pages/users.ecpp80
-rw-r--r--pages/vlc.ecpp14
14 files changed, 302 insertions, 14 deletions
diff --git a/pages/Makefile b/pages/Makefile
index f7512f5..c49c673 100644
--- a/pages/Makefile
+++ b/pages/Makefile
@@ -17,7 +17,7 @@ OBJS = menu.o recordings.o schedule.o screenshot.o timers.o \
searchepg.o login.o ibox.o xmlresponse.o play_recording.o \
pause_recording.o stop_recording.o ffw_recording.o \
rwd_recording.o setup.o content.o epginfo.o timerconflicts.o \
- recstream.o
+ recstream.o users.o edit_user.o
### Default rules:
diff --git a/pages/edit_searchtimer.ecpp b/pages/edit_searchtimer.ecpp
index fbd2cce..69103a1 100644
--- a/pages/edit_searchtimer.ecpp
+++ b/pages/edit_searchtimer.ecpp
@@ -10,6 +10,7 @@
#include "epgsearch.h"
#include "setup.h"
#include "i18n.h"
+#include "users.h"
using namespace std;
using namespace vdrlive;
@@ -99,6 +100,9 @@ if (!logged_in && LiveSetup().UseAuth()) return reply.redirect("login.html");
}>
<%cpp>
+ if (!cUser::CurrentUserHasRightTo(UR_EDITSTIMERS))
+ throw HtmlError( tr("Sorry, no permission. Please contact your administrator!") );
+
#define SELECTIF(x) reply.out() << ( (x) ? "selected=\"selected\"" : "" );
#define CHECKIF(x) reply.out() << ( (x) ? "checked=\"checked\"" : "" );
diff --git a/pages/edit_timer.ecpp b/pages/edit_timer.ecpp
index 47a6766..299f35a 100644
--- a/pages/edit_timer.ecpp
+++ b/pages/edit_timer.ecpp
@@ -13,6 +13,7 @@
#include "i18n.h"
#include "livefeatures.h"
#include "epgsearch.h"
+#include "users.h"
using namespace std;
using namespace vdrlive;
@@ -57,6 +58,9 @@ cTimer* timer;
<%cpp>
if (!logged_in && LiveSetup().UseAuth()) return reply.redirect("login.html");
+ if (!cUser::CurrentUserHasRightTo(UR_EDITTIMERS))
+ throw HtmlError( tr("Sorry, no permission. Please contact your administrator!") );
+
bool ajaxReq = !async.empty() && (lexical_cast<int>(async) != 0);
tChannelID channelid = tChannelID();
diff --git a/pages/edit_user.ecpp b/pages/edit_user.ecpp
new file mode 100644
index 0000000..2ae510a
--- /dev/null
+++ b/pages/edit_user.ecpp
@@ -0,0 +1,176 @@
+<%pre>
+#include "exception.h"
+#include "tools.h"
+#include "users.h"
+#include "livefeatures.h"
+#include "setup.h"
+
+using namespace std;
+using namespace vdrlive;
+
+</%pre>
+<%args>
+ // input parameters
+ string userid;
+ // form parameters
+ string username;
+ string password;
+ bool ur_editsetup = false;
+ bool ur_addtimers = false;
+ bool ur_deltimers = false;
+ bool ur_delrecs = false;
+ bool ur_useremote = false;
+ bool ur_startreplay = false;
+ bool ur_switchchnl = false;
+ bool ur_addstimers = false;
+ bool ur_delstimers = false;
+</%args>
+<%session scope="global">
+bool logged_in(false);
+</%session>
+<%request scope="page">
+cUser* editUser;
+</%request>
+<%include>page_init.eh</%include>
+<%cpp>
+ if (!logged_in && LiveSetup().UseAuth()) return reply.redirect("login.html");
+
+#define CHECKIF(x) reply.out() << ( (x) ? "checked=\"checked\"" : "" );
+
+ editUser = NULL;
+
+ if (request.getMethod() == "POST") {
+ if (!userid.empty()) {
+ editUser = Users.GetByUserId( userid );
+ if ( editUser == 0 )
+ throw HtmlError( tr("Couldn't find user. Maybe you mistyped your request?") );
+ editUser->SetName(username);
+ if (password != std::string(editUser->GetPasswordLength(), '*'))
+ editUser->SetPassword(password);
+ }
+ else
+ {
+ if (Users.GetByUserName( username ))
+ throw HtmlError( tr("This user name is already in use!") );
+ editUser = new cUser(Users.GetNewId(), username, password);
+ Users.Add(editUser);
+ }
+ editUser->SetUserrights(0);
+ if (ur_editsetup) editUser->SetRight(UR_EDITSETUP);
+ if (ur_addtimers) editUser->SetRight(UR_EDITTIMERS);
+ if (ur_deltimers) editUser->SetRight(UR_DELTIMERS);
+ if (ur_delrecs) editUser->SetRight(UR_DELRECS);
+ if (ur_useremote) editUser->SetRight(UR_USEREMOTE);
+ if (ur_startreplay) editUser->SetRight(UR_STARTREPLAY);
+ if (ur_switchchnl) editUser->SetRight(UR_SWITCHCHNL);
+ if (ur_addstimers) editUser->SetRight(UR_EDITSTIMERS);
+ if (ur_delstimers) editUser->SetRight(UR_DELSTIMERS);
+
+ Users.Save();
+
+ return reply.redirect("users.html");
+ }
+
+ pageTitle = !userid.empty() ? tr("Edit user") : tr("New user");
+
+ if ( !userid.empty() ) {
+ cUser* User = Users.GetByUserId( userid );
+ if ( User == 0 )
+ throw HtmlError( tr("Couldn't find user. Maybe you mistyped your request?") );
+
+ username = User->Name();
+ password = std::string(User->GetPasswordLength(), '*');
+ ur_editsetup = User->HasRightTo(UR_EDITSETUP);
+ ur_addtimers = User->HasRightTo(UR_EDITTIMERS);
+ ur_deltimers = User->HasRightTo(UR_DELTIMERS);
+ ur_delrecs = User->HasRightTo(UR_DELRECS);
+ ur_useremote = User->HasRightTo(UR_USEREMOTE);
+ ur_startreplay = User->HasRightTo(UR_STARTREPLAY);
+ ur_switchchnl = User->HasRightTo(UR_SWITCHCHNL);
+ ur_addstimers = User->HasRightTo(UR_EDITSTIMERS);
+ ur_delstimers = User->HasRightTo(UR_DELSTIMERS);
+ editUser = User;
+ }
+ else
+ {
+ ur_editsetup = true;
+ ur_addtimers = true;
+ ur_deltimers = true;
+ ur_delrecs = true;
+ ur_useremote = true;
+ ur_startreplay = true;
+ ur_switchchnl = true;
+ ur_addstimers = true;
+ ur_delstimers = true;
+ }
+</%cpp>
+<& pageelems.doc_type &>
+<html>
+ <head>
+ <title>VDR Live - <$ pageTitle $></title>
+ <& pageelems.stylesheets &>
+ <& pageelems.ajax_js &>
+ </head>
+ <body>
+ <& pageelems.logo &>
+ <& menu active=("users") &>
+ <div class="inhalt">
+ <form method="post" name="edit_user" action="edit_user.ecpp">
+ <input type="hidden" name="userid" value="<$ userid $>"/>
+ <table class="formular" cellpadding="0" cellspacing="0">
+ <tr class="head">
+ <td class="toprow leftcol rightcol" colspan="2"><div class="boxheader"><div><div class="caption"><$ pageTitle $></div></div></div></td>
+ </tr>
+
+ <tr>
+ <td class="label leftcol"><div class="withmargin"><$ tr("Name" ) $>:</div></td>
+ <td class="rightcol"><input type="text" name="username" value="<$ username $>" size="80" /></td>
+ </tr>
+ <tr>
+ <td class="label leftcol"><div class="withmargin"><$ tr("Password" ) $>:</div></td>
+ <td class="rightcol"><input type="password" name="password" value="<$ password $>" size="80" /></td>
+ </tr>
+ <!-- user rights -->
+ <tr>
+ <td class="label leftcol"><div class="withmargin"><$ tr("User rights") $>:</div></td>
+ <td class="rightcol">
+ <input type="checkbox" name="ur_editsetup" value="1" <{ CHECKIF(ur_editsetup) }> />
+ <label for="ur_editsetup"><$ tr("Edit setup") $></label><br>
+ <input type="checkbox" name="ur_addtimers" value="1" <{ CHECKIF(ur_addtimers) }> />
+ <label for="ur_addtimers"><$ tr("Add or edit timers") $></label><br>
+ <input type="checkbox" name="ur_deltimers" value="1" <{ CHECKIF(ur_deltimers) }> />
+ <label for="ur_deltimers"><$ tr("Delete timers") $></label><br>
+ <input type="checkbox" name="ur_delrecs" value="1" <{ CHECKIF(ur_delrecs) }> />
+ <label for="ur_delrecs"><$ tr("Delete recordings") $></label><br>
+ <input type="checkbox" name="ur_useremote" value="1" <{ CHECKIF(ur_useremote) }> />
+ <label for="ur_useremote"><$ tr("Use remote menu") $></label><br>
+ <input type="checkbox" name="ur_startreplay" value="1" <{ CHECKIF(ur_startreplay) }> />
+ <label for="ur_startreplay"><$ tr("Start replay") $></label><br>
+ <input type="checkbox" name="ur_switchchnl" value="1" <{ CHECKIF(ur_switchchnl) }> />
+ <label for="ur_switchchnl"><$ tr("Switch channel") $></label><br>
+<%cpp>
+ if (LiveFeatures< features::epgsearch >().Recent()) {
+</%cpp>
+ <input type="checkbox" name="ur_addstimers" value="1" <{ CHECKIF(ur_addstimers) }> />
+ <label for="ur_addstimers"><$ tr("Add or edit search timers") $></label><br>
+ <input type="checkbox" name="ur_delstimers" value="1" <{ CHECKIF(ur_delstimers) }> />
+ <label for="ur_delstimers"><$ tr("Delete search timers") $></label><br>
+<%cpp>
+ }
+</%cpp>
+ </td>
+ </tr>
+ <tr>
+ <td class="buttonpanel leftcol rightcol bottomrow" colspan="2">
+ <div class="withmargin">
+ <button class="green" type="submit" name="save"><$ tr("Save") $></button>
+ <button type="button" class="red" onclick="history.back()"><$ tr("Cancel") $></button>
+ </div>
+ </td>
+ </tr>
+ </table>
+ </form>
+ </div>
+ </body>
+</html>
+<%include>page_exit.eh</%include>
diff --git a/pages/login.ecpp b/pages/login.ecpp
index 754ec82..a49f1fa 100644
--- a/pages/login.ecpp
+++ b/pages/login.ecpp
@@ -1,6 +1,7 @@
<%pre>
#include "tools.h"
#include "setup.h"
+#include "users.h"
using namespace std;
using namespace vdrlive;
@@ -19,13 +20,15 @@ bool logged_in(false);
std::string message;
if (action == "login") {
- if ((login == LiveSetup().GetAdminLogin()) && (MD5Hash(password) == LiveSetup().GetMD5HashAdminPassword())) {
+ if (Users.ValidLogin(login, password)) {
logged_in = true;
+ cUsers::logged_in_user = login;
} else {
message = tr("Wrong username or password");
}
} else if (action == "logout") {
logged_in = false;
+ cUsers::logged_in_user = "";
}
LiveSetup().CheckLocalNet(request.getPeerIp());
diff --git a/pages/menu.ecpp b/pages/menu.ecpp
index a998169..1159014 100644
--- a/pages/menu.ecpp
+++ b/pages/menu.ecpp
@@ -96,6 +96,7 @@ if (!component.empty()) {
</%cpp>
<& menu.component current=("recordings") &>
<& menu.component current=("remote") &>
+ <& menu.component current=("users") &>
</div>
</div>
</div>
diff --git a/pages/play_recording.ecpp b/pages/play_recording.ecpp
index 5a26b41..1f018de 100644
--- a/pages/play_recording.ecpp
+++ b/pages/play_recording.ecpp
@@ -5,6 +5,7 @@
#include "setup.h"
#include "tasks.h"
#include "tools.h"
+#include "users.h"
using namespace std;
using namespace vdrlive;
@@ -18,6 +19,8 @@ using namespace vdrlive;
</%session>
<%cpp>
if (!logged_in && LiveSetup().UseAuth()) return reply.redirect("login.html");
+ if (!cUser::CurrentUserHasRightTo(UR_STARTREPLAY))
+ throw HtmlError( tr("Sorry, no permission. Please contact your administrator!") );
reply.setContentType( "application/xml" );
PlayRecordingTask task( param );
diff --git a/pages/remote.ecpp b/pages/remote.ecpp
index dd45cd0..dc0bf13 100644
--- a/pages/remote.ecpp
+++ b/pages/remote.ecpp
@@ -6,6 +6,7 @@
#include "grab.h"
#include "setup.h"
#include "tools.h"
+#include "users.h"
using namespace std;
using namespace vdrlive;
@@ -25,6 +26,9 @@ bool logged_in(false);
if (!logged_in && LiveSetup().UseAuth()) return reply.redirect("login.html");
}>
<%cpp>
+ if (!cUser::CurrentUserHasRightTo(UR_USEREMOTE))
+ throw HtmlError( tr("Sorry, no permission. Please contact your administrator!") );
+
pageTitle = tr("Remote Control");
ReadLock channelsLock( Channels );
diff --git a/pages/searchtimers.ecpp b/pages/searchtimers.ecpp
index fc2eaf8..dc8bc53 100644
--- a/pages/searchtimers.ecpp
+++ b/pages/searchtimers.ecpp
@@ -4,6 +4,7 @@
#include "epgsearch.h"
#include "tools.h"
#include "setup.h"
+#include "users.h"
using namespace vdrlive;
using namespace std;
@@ -27,8 +28,11 @@ if (!logged_in && LiveSetup().UseAuth()) return reply.redirect("login.html");
if ( !searchtimerid.empty() ) {
if (action == "toggle")
timers.ToggleActive(searchtimerid);
- if (action == "delete")
+ if (action == "delete") {
+ if (!cUser::CurrentUserHasRightTo(UR_DELSTIMERS))
+ throw HtmlError( tr("Sorry, no permission. Please contact your administrator!") );
timers.Delete(searchtimerid);
+ }
}
if (action == "update")
timers.TriggerUpdate();
diff --git a/pages/setup.ecpp b/pages/setup.ecpp
index cc1db8c..845e4b7 100644
--- a/pages/setup.ecpp
+++ b/pages/setup.ecpp
@@ -3,6 +3,7 @@
#include <vdr/tools.h>
#include "setup.h"
#include "tools.h"
+#include "users.h"
#include "i18n.h"
using namespace vdrlive;
@@ -33,7 +34,9 @@ using namespace std;
</%session>
<%include>page_init.eh</%include>
<%cpp>
-if (!logged_in && LiveSetup().UseAuth()) return reply.redirect("login.html");
+if (!logged_in && LiveSetup().UseAuth() ) return reply.redirect("login.html");
+if (!cUser::CurrentUserHasRightTo(UR_EDITSETUP))
+ throw HtmlError( tr("Sorry, no permission. Please contact your administrator!") );
#define SELECTIF(x) reply.out() << ( (x) ? "selected=\"selected\"" : "" );
#define CHECKIF(x) reply.out() << ( (x) ? "checked=\"checked\"" : "" );
@@ -152,6 +155,10 @@ if (!logged_in && LiveSetup().UseAuth()) return reply.redirect("login.html");
<td><input type="password" name="pass" value="<$ pass $>" id="pass" onchange="setauthchanged(this)" /></td>
</tr>
<tr>
+ <td class="label"><div class="withmargin"><a href="users.html"><$ tr("User management") $></a></div></td>
+ <td/>
+ </tr>
+ <tr>
<td class="label"><div class="withmargin"><$ tr("Local net (no login required)") $>:</div></td>
<td><input type="text" name="localnetmask" value="<$ localnetmask $>" id="localnetmask" /></td>
</tr>
@@ -282,4 +289,3 @@ if (!logged_in && LiveSetup().UseAuth()) return reply.redirect("login.html");
<%include>page_exit.eh</%include>
-
diff --git a/pages/switch_channel.ecpp b/pages/switch_channel.ecpp
index 9b8b48b..2cffefc 100644
--- a/pages/switch_channel.ecpp
+++ b/pages/switch_channel.ecpp
@@ -3,6 +3,7 @@
#include "exception.h"
#include "tasks.h"
#include "tools.h"
+#include "users.h"
using namespace std;
using namespace vdrlive;
@@ -16,6 +17,9 @@ using namespace vdrlive;
bool ajaxReq = !async.empty() && (lexical_cast<int>(async) != 0);
string referrer;
+ if (!cUser::CurrentUserHasRightTo(UR_SWITCHCHNL))
+ throw HtmlError( tr("Sorry, no permission. Please contact your administrator!") );
+
if (ajaxReq) {
reply.setContentType( "application/xml" );
}
diff --git a/pages/timers.ecpp b/pages/timers.ecpp
index 93d2e91..2a9ee4c 100644
--- a/pages/timers.ecpp
+++ b/pages/timers.ecpp
@@ -8,6 +8,7 @@
#include "epg_events.h"
#include "timerconflict.h"
#include "livefeatures.h"
+#include "users.h"
using namespace std;
using namespace vdrlive;
@@ -44,6 +45,8 @@ static const size_t maximumDescriptionLength = 300;
if ( timer == 0 )
throw HtmlError( tr("Couldn't find timer. Maybe you mistyped your request?") );
if (action == "delete") {
+ if (!cUser::CurrentUserHasRightTo(UR_DELTIMERS))
+ throw HtmlError( tr("Sorry, no permission. Please contact your administrator!") );
LiveTimerManager().DelTimer(timer);
timerNotifier.SetTimerModification();
}
diff --git a/pages/users.ecpp b/pages/users.ecpp
new file mode 100644
index 0000000..f884e91
--- /dev/null
+++ b/pages/users.ecpp
@@ -0,0 +1,80 @@
+<%pre>
+#include <vdr/channels.h>
+#include <vdr/i18n.h>
+#include "users.h"
+#include "setup.h"
+
+using namespace vdrlive;
+using namespace std;
+
+</%pre>
+<%args>
+ // input parameters
+ string userid;
+ string action;
+</%args>
+<%session scope="global">
+bool logged_in(false);
+</%session>
+<%include>page_init.eh</%include>
+<%cpp>
+if (!logged_in && LiveSetup().UseAuth()) return reply.redirect("login.html");
+</%cpp>
+<%cpp>
+ pageTitle = tr("Users");
+ if ( !userid.empty() ) {
+ if (action == "delete")
+ {
+ Users.Del(Users.GetByUserId( userid ));
+ Users.Save();
+ }
+ }
+</%cpp>
+<& pageelems.doc_type &>
+<html>
+ <head>
+ <title>VDR-Live - <$ pageTitle $></title>
+ <& pageelems.stylesheets &>
+ <& pageelems.ajax_js &>
+ </head>
+ <body>
+ <& pageelems.logo &>
+ <& menu active=("users") component=("users.user_actions")>
+ <div class="inhalt">
+ <table class="listing" cellspacing="0" cellpadding="0">
+ <tr class="head">
+ <td colspan="3">
+ <div class="boxheader"><div><div><$ pageTitle $></div></div></div>
+ </td>
+ </tr>
+ <tr class="description">
+ <td class="action leftcol"><div class="leftcol"><$ tr("Name") $></div></td>
+ <td class="rightcol" colspan="8"/>
+ </tr>
+<%cpp>
+ cUser* user = Users.First();
+ while (user)
+ {
+ bool bottom = (Users.Next(user) == NULL);
+ if (user)
+ {
+</%cpp>
+ <tr class="description">
+ <td class="action leftcol <? bottom ? "bottomrow" ?>"><div class="withmargin"><$ user->Name() $></div></td>
+ <td class="<? bottom ? "bottomrow" ?>"><a href="edit_user.html?userid=<$ user->Id() $>"><img src="<$ LiveSetup().GetThemedLink("img", "edit.png") $>" alt="" <& tooltip.hint text=(tr("Edit user")) &>></img></a></td>
+ <td class="action rightcol <? bottom ? "bottomrow" ?>"><a href="users.html?userid=<$ user->Id() $>&action=delete"><img src="<$ LiveSetup().GetThemedLink("img", "del.png") $>" alt="" <& tooltip.hint text=(tr("Delete user")) &>></img></a></td>
+ </tr>
+<%cpp>
+ }
+ user = Users.Next(user);
+ }
+</%cpp>
+ </table>
+ </div>
+ </body>
+</html>
+<%include>page_exit.eh</%include>
+
+<%def user_actions>
+<a href="edit_user.html"><$ tr("New user") $></a>
+</%def>
diff --git a/pages/vlc.ecpp b/pages/vlc.ecpp
index 050f716..065969c 100644
--- a/pages/vlc.ecpp
+++ b/pages/vlc.ecpp
@@ -4,6 +4,7 @@
#include <vdr/keys.h>
#include "setup.h"
#include "tools.h"
+#include "users.h"
using namespace std;
using namespace vdrlive;
@@ -23,6 +24,8 @@ using namespace vdrlive;
<%include>page_init.eh</%include>
<%cpp>
if (!logged_in && LiveSetup().UseAuth()) return reply.redirect("login.html");
+ if (!cUser::CurrentUserHasRightTo(UR_STARTREPLAY))
+ throw HtmlError( tr("Sorry, no permission. Please contact your administrator!") );
bool asyncReq = !async.empty() && (lexical_cast<int>(async) != 0);
@@ -96,9 +99,7 @@ using namespace vdrlive;
<%cpp>
#if TNTVERSION >= 1606
string server = request.getHost();
- if (Channel != 0) {
- server = server.substr(0, server.rfind(':'));
- }
+ server = server.substr(0, server.rfind(':'));
#else
string server = request.getServerIp();
#endif
@@ -108,12 +109,7 @@ using namespace vdrlive;
videourl = string("http://") + server + ":" + lexical_cast<string,int>(streamdevPort) + "/" + LiveSetup().GetStreamdevType() + "/" + *Channel->GetChannelID().ToString();
}
else {
-#if TNTVERSION >= 1606
-# define SERVER_AND_PORT server
-#else
-# define SERVER_AND_PORT server + ":" + lexical_cast<string,int>(LiveSetup().GetServerPort());
-#endif
- videourl = string("http://") + SERVER_AND_PORT + "/recstream.html?recid=" + recid;
+ videourl = string("http://") + server + ":" + lexical_cast<string,int>(LiveSetup().GetServerPort()) + "/recstream.html?recid=" + recid;
}
</%cpp>
<embed type="application/x-vlc-plugin" pluginspage="http://www.videolan.org/" version="VideoLAN.VLCPlugin.2" id="video1" name="video1" autoplay="yes" loop="no" width="720" height="576" target="<$ videourl $>" />