diff options
author | Christian Wieninger <cwieninger (at) gmx (dot) de> | 2007-05-23 17:33:08 +0000 |
---|---|---|
committer | Christian Wieninger <cwieninger (at) gmx (dot) de> | 2007-05-23 17:33:08 +0000 |
commit | d0ec6ac5a5e8858d423923778fdd5667297f63c2 (patch) | |
tree | af131913b1cb7b657384ed1ab14d674e634c3b29 | |
parent | 2a543304c089a0e8f942fe23fe3db59017b84a20 (diff) | |
download | vdr-plugin-live-d0ec6ac5a5e8858d423923778fdd5667297f63c2.tar.gz vdr-plugin-live-d0ec6ac5a5e8858d423923778fdd5667297f63c2.tar.bz2 |
- show auth part only when enabled
- common method Setup::SaveSetup to store setup values from osd and web frontend
-rw-r--r-- | pages/setup.ecpp | 54 | ||||
-rw-r--r-- | setup.cpp | 26 | ||||
-rw-r--r-- | setup.h | 5 |
3 files changed, 55 insertions, 30 deletions
diff --git a/pages/setup.ecpp b/pages/setup.ecpp index e69ef66..012d798 100644 --- a/pages/setup.ecpp +++ b/pages/setup.ecpp @@ -10,7 +10,6 @@ using namespace std; bool useauth = 0; string login; string pass; - int passLength = 0; </%args> <%session scope="global"> bool logged_in(false); @@ -23,14 +22,18 @@ if (!logged_in && LiveSetup().UseAuth()) return reply.redirect("login.html"); if ( request.getMethod() == "POST") { LiveSetup().SetLastChannel(lastchannel); LiveSetup().SetUseAuth(useauth); - LiveSetup().SetAdminLogin(login); - LiveSetup().SetAdminPassword(pass); - return reply.redirect("setup.html"); + if (useauth) { + LiveSetup().SetAdminLogin(login); + if (pass != "") + LiveSetup().SetAdminPassword(pass); + } + LiveSetup().SaveSetup(); } pageTitle = tr("Setup"); lastchannel = LiveSetup().GetLastChannel(); login = LiveSetup().GetAdminLogin(); useauth = LiveSetup().UseAuth(); + </%cpp> <& pageelems.doc_type &> <html> @@ -39,8 +42,18 @@ if (!logged_in && LiveSetup().UseAuth()) return reply.redirect("login.html"); <link rel="stylesheet" type="text/css" href="/styles.css" /> <& tooltip.javascript var=("domTT_styleClass") value=("domTTepg") &> <& pageelems.ajax_js &> + <script type="text/javascript"><!-- + function initform() + { + changeduseauth(document.getElementById("useauth")); + } + function changeduseauth(selection) + { + document.getElementById("authsection").style.display = (selection.checked ? "block" : "none"); + } + //--></script> </head> - <body onload="<& pageelems.infobox_start_update &>"> + <body onload="<& pageelems.infobox_start_update &>; initform()"> <& pageelems.logo &> <& menu active=("setup") &> <div class="inhalt"> @@ -48,7 +61,7 @@ if (!logged_in && LiveSetup().UseAuth()) return reply.redirect("login.html"); <table class="edit" cellpadding="0" cellspacing="0"> <tr> <td class="head" colspan="4"><div class="boxheader"><div><div><$ tr("Setup") $></div></div></div></td> - </tr> <!-- Last channel --> + </tr> <tr> <td class="border" style="border-left: 1px solid black"></td> <td class="label"><$ tr("Last channel to display") $>:</td> @@ -58,22 +71,23 @@ if (!logged_in && LiveSetup().UseAuth()) return reply.redirect("login.html"); <tr> <td class="border" style="border-left: 1px solid black"></td> <td class="label"><$ tr("Use authentication") $>:</td> - <td><input type="checkbox" name="useauth" value="1" <{ reply.out() << ( useauth ? "checked=\"checked\"" : "" ); }>/></td> - <td class="border" style="border-right: 1px solid black"></td> - </tr> - <tr> - <td class="border" style="border-left: 1px solid black"></td> - <td class="label"><$ tr("Admin login") $>:</td> - <td><input type="text" name="login" value="<$ login $>" id="login" /></td> - <td class="border" style="border-right: 1px solid black"></td> - </tr> - <tr> - <td class="border" style="border-left: 1px solid black"></td> - <td class="label"><$ tr("Admin password") $>:</td> - <td><input type="text" name="pass" value="<$ pass $>" id="pass" /></td> + <td> + <input type="checkbox" name="useauth" id="useauth" value="1" <{ reply.out() << ( useauth ? "checked=\"checked\"" : "" ); }> onclick="changeduseauth(this)"/> + <div id="authsection" style="display: none"> + <table border="0" cellpadding="0" cellspacing="0" class="dependent"> + <tr> + <td><$ tr("Admin login") $>:</td> + <td><input type="text" name="login" value="<$ login $>" id="login" /></td> + </tr> + <tr> + <td><$ tr("Admin password") $>:</td> + <td><input type="password" name="pass" value="<$ pass $>" id="pass" /></td> + </tr> + </table> + </div> + </td> <td class="border" style="border-right: 1px solid black"></td> </tr> - <tr> <td class="border" style="border-left: 1px solid black"></td> <td class="buttonpanel" colspan="2"> @@ -28,6 +28,7 @@ Setup::Setup(): m_adminLogin("admin") { m_adminPasswordMD5 = "4:" + MD5Hash("live"); + liveplugin = cPluginManager::GetPlugin("live"); } bool Setup::ParseCommandLine( int argc, char* argv[] ) @@ -130,6 +131,19 @@ std::string Setup::SetAdminPassword(std::string password) return m_adminPasswordMD5; } +bool Setup::SaveSetup() +{ + if (!liveplugin) return false; + liveplugin->SetupStore("LastChannel", m_lastChannel); + liveplugin->SetupStore("UseAuth", m_useAuth); + if (m_useAuth) + { + liveplugin->SetupStore("AdminLogin", m_adminLogin.c_str()); + liveplugin->SetupStore("AdminPasswordMD5", m_adminPasswordMD5.c_str()); + } + return true; +} + Setup& LiveSetup() { static Setup instance; @@ -168,19 +182,11 @@ void cMenuSetupLive::Set(void) void cMenuSetupLive::Store(void) { vdrlive::LiveSetup().SetLastChannel(m_lastChannel); - SetupStore("LastChannel", m_lastChannel); - vdrlive::LiveSetup().SetUseAuth(m_useAuth); - SetupStore("UseAuth", m_useAuth); - vdrlive::LiveSetup().SetAdminLogin(m_adminLogin); - SetupStore("AdminLogin", m_adminLogin); - if (m_oldpasswordMD5 != m_newpasswordMD5) // only save the password if needed - { - std::string passwordMD5 = vdrlive::LiveSetup().SetAdminPassword(m_adminPassword); - SetupStore("AdminPasswordMD5", passwordMD5.c_str()); - } + vdrlive::LiveSetup().SetAdminPassword(m_adminPassword); + LiveSetup().SaveSetup(); } bool cMenuSetupLive::InEditMode(const char* ItemText, const char* ItemName, const char* ItemValue) @@ -39,6 +39,8 @@ public: void SetUseAuth(int auth) { m_useAuth = auth; } void SetScrenshotInterval(int interval) { m_screenshotInterval = interval; } + bool SaveSetup(); + bool ParseCommandLine( int argc, char* argv[] ); char const* CommandLineHelp() const; @@ -48,6 +50,9 @@ private: Setup(); Setup( Setup const& ); + // me + cPlugin* liveplugin; + mutable std::string m_helpString; // commandline options int m_serverPort; |