[Eis-commits] SF.net SVN: eis: [208] trunk
Status: Pre-Alpha
Brought to you by:
baslijnse
|
From: <bas...@us...> - 2007-09-14 09:08:17
|
Revision: 208
http://eis.svn.sourceforge.net/eis/?rev=208&view=rev
Author: baslijnse
Date: 2007-09-14 02:08:02 -0700 (Fri, 14 Sep 2007)
Log Message:
-----------
Finished fully functional version of the authentication system. Also updated the Login element and added permissions and a login page to the server manager application.
Modified Paths:
--------------
trunk/lib/engine/application.lib.php
trunk/lib/engine/engine.lib.php
trunk/lib/engine/user.lib.php
trunk/mod/eis_engine/applications/servermanager.xml
trunk/mod/eis_engine/config/module.php
trunk/mod/eis_engine/locales/en_en/default/servermanager/css/main.css
trunk/mod/eis_engine/locales/en_en/default/servermanager/layout.html
trunk/mod/eis_engine/locales/en_en/strings.xml
trunk/mod/eis_engine/services/AuthService.php
trunk/mod/eis_user/config/elements.php
trunk/mod/eis_user/elements/Login.php
trunk/mod/eis_user/locales/en_en/strings.xml
trunk/mod/eis_widget/locales/en_en/default/css/widget.css
trunk/mod/eis_widget/services/MainService.php
Added Paths:
-----------
trunk/mod/eis_engine/locales/en_en/default/servermanager/css/login.css
trunk/mod/eis_engine/locales/en_en/default/servermanager/login.html
trunk/mod/eis_user/elements/Logout.php
trunk/mod/eis_user/locales/en_en/default/
trunk/mod/eis_user/locales/en_en/default/element-templates/
trunk/mod/eis_user/locales/en_en/default/element-templates/Login/
trunk/mod/eis_user/locales/en_en/default/element-templates/Login/basic.html
trunk/mod/eis_user/locales/en_en/default/element-templates/Login/tiny.html
trunk/mod/eis_user/locales/en_en/default/js/
trunk/mod/eis_user/locales/en_en/default/js/login.js
trunk/mod/eis_user/locales/en_en/default/js/md5.js
Removed Paths:
-------------
trunk/mod/eis_user/elements/Login_tpl/
trunk/mod/eis_user/maps/user/
Modified: trunk/lib/engine/application.lib.php
===================================================================
--- trunk/lib/engine/application.lib.php 2007-09-12 00:45:37 UTC (rev 207)
+++ trunk/lib/engine/application.lib.php 2007-09-14 09:08:02 UTC (rev 208)
@@ -340,18 +340,10 @@
}
}
function getPageNotFound() {
- if(isset($this->page_notfound['/'])) {
- return $this->page_notfound['/'];
- } else {
- return null;
- }
+ return $this->page_notfound;
}
function getPageNotAllowed() {
- if(isset($this->page_notallowed['/'])) {
- return $this->page_notallowed['/'];
- } else {
- return null;
- }
+ return $this->page_notallowed;
}
/**
* Gets the element instance information from the page map.
Modified: trunk/lib/engine/engine.lib.php
===================================================================
--- trunk/lib/engine/engine.lib.php 2007-09-12 00:45:37 UTC (rev 207)
+++ trunk/lib/engine/engine.lib.php 2007-09-14 09:08:02 UTC (rev 208)
@@ -698,12 +698,14 @@
}
//Check security clearance
- if($page['permission'] > 0 && ! $this->session->hasClearance($page['permission']) ) {
+ if($page['permission'] != null && !$this->user->hasPermission($page['permission'])) {
+
$page = $this->application->getPageNotAllowed();
if($page == null) {
$this->error(403);
}
+
}
//Check if this page should redirect
@@ -728,21 +730,7 @@
$mode = $instance->getMode();
//Add element to areas list
- if (!isset($this->areas[$area]))
- $this->areas[$area] = '';
-
- switch($mode) {
- default:
- case 'append':
- $this->areas[$area] = $this->areas[$area].$content;
- break;
- case 'prepend':
- $this->areas[$area] = $content.$this->areas[$area];
- break;
- case 'replace':
- $this->areas[$area] = $content;
- break;
- }
+ $this->addAreaContent($area, $content, $mode);
}
//Show Headers
@@ -1278,6 +1266,31 @@
else
return '';
}
+ /**
+ * Add content to an area
+ *
+ * @param area the area where the content needs to be added
+ * @param content the content to add to the area
+ * @param mode how should the content be added: 'prepend', 'replace' or 'append'
+ */
+ function addAreaContent($area, $content, $mode = 'append') {
+
+ if (!isset($this->areas[$area])) {
+ $this->areas[$area] = '';
+ }
+ switch($mode) {
+ default:
+ case 'append':
+ $this->areas[$area] = $this->areas[$area].$content;
+ break;
+ case 'prepend':
+ $this->areas[$area] = $content.$this->areas[$area];
+ break;
+ case 'replace':
+ $this->areas[$area] = $content;
+ break;
+ }
+ }
/**
* Get a reference to a service object.
*
Modified: trunk/lib/engine/user.lib.php
===================================================================
--- trunk/lib/engine/user.lib.php 2007-09-12 00:45:37 UTC (rev 207)
+++ trunk/lib/engine/user.lib.php 2007-09-14 09:08:02 UTC (rev 208)
@@ -32,6 +32,10 @@
$this->displayname = 'Anonymous';
$this->permissions = array();
$this->preferences = array();
+
+ //Add pseudo permissions
+ $this->permissions[] = 'public';
+ $this->permissions[] = 'unauthenticated';
}
/**
* Sets user related properties based on the user object
@@ -44,6 +48,10 @@
$this->displayname = $user['displayname'];
$this->permissions = $user['permissions'];
$this->preferences = $user['preferences'];
+
+ //Add pseudo permissions
+ $this->permissions[] = 'public';
+ $this->permissions[] = 'authenticated';
}
/**
* Checks if the authentication service returned a valid user
Modified: trunk/mod/eis_engine/applications/servermanager.xml
===================================================================
--- trunk/mod/eis_engine/applications/servermanager.xml 2007-09-12 00:45:37 UTC (rev 207)
+++ trunk/mod/eis_engine/applications/servermanager.xml 2007-09-14 09:08:02 UTC (rev 208)
@@ -14,6 +14,7 @@
<page_root>
<meta><name>menu-entry</name><value>eis_engine.l.home</value></meta>
+ <permission>eis_engine.administrator</permission>
<element>
<module>eis_engine</module>
<element>Version</element>
@@ -28,6 +29,13 @@
<inherit><depth>100</depth></inherit>
</element>
<element>
+ <module>eis_user</module>
+ <element>Logout</element>
+ <area>LOGOUT</area>
+ <config><name>logout_page</name><value>/login</value></config>
+ <inherit><depth>100</depth></inherit>
+ </element>
+ <element>
<module>eis_widget</module>
<element>Includes</element>
<area>HEAD</area>
@@ -72,8 +80,43 @@
<area>OUT</area>
<config><name>file</name><value>eis_engine/servermanager/layout.html</value></config>
<inherit><depth>100</depth></inherit>
+ <inherit><page>login</page><depth>0</depth></inherit>
</element>
<page>
+ <name>login</name>
+ <permission>public</permission>
+ <element>
+ <module>eis_widget</module>
+ <element>Includes</element>
+ <area>HEAD</area>
+ <inherit><depth>100</depth></inherit>
+ </element>
+ <element>
+ <module>eis_layout</module>
+ <element>String</element>
+ <area>TITLE</area>
+ <config><name>string</name><value>eis_engine.t.login</value></config>
+ </element>
+ <element>
+ <module>eis_layout</module>
+ <element>Message</element>
+ <area>MAIN</area>
+ <mode>prepend</mode>
+ </element>
+ <element>
+ <module>eis_user</module>
+ <element>Login</element>
+ <area>MAIN</area>
+ <config><name>redirect_login</name><value>/</value></config>
+ </element>
+ <element>
+ <module>eis_layout</module>
+ <element>Template</element>
+ <area>OUT</area>
+ <config><name>file</name><value>eis_engine/servermanager/login.html</value></config>
+ </element>
+ </page>
+ <page>
<name>applications</name>
<meta><name>menu-entry</name><value>eis_engine.t.select.application</value></meta>
<element>
@@ -266,4 +309,7 @@
</catchall>
</page>
</page_root>
+ <page_notallowed>
+ <redirect>/login</redirect>
+ <page_notallowed>
</application>
Modified: trunk/mod/eis_engine/config/module.php
===================================================================
--- trunk/mod/eis_engine/config/module.php 2007-09-12 00:45:37 UTC (rev 207)
+++ trunk/mod/eis_engine/config/module.php 2007-09-14 09:08:02 UTC (rev 208)
@@ -1,5 +1,5 @@
<?php
- $cfg['admin_password'] = 'eisroxx';
+ $cfg['admin_password'] = 'admin';
$cfg['redirect_404'] = null;
$cfg['redirect_403'] = null;
Added: trunk/mod/eis_engine/locales/en_en/default/servermanager/css/login.css
===================================================================
--- trunk/mod/eis_engine/locales/en_en/default/servermanager/css/login.css (rev 0)
+++ trunk/mod/eis_engine/locales/en_en/default/servermanager/css/login.css 2007-09-14 09:08:02 UTC (rev 208)
@@ -0,0 +1,49 @@
+body {
+ margin: 0px;
+ background-color: #fff;
+ font-family: Verdana, Helvetica, sans-serif;
+}
+body, td, th {
+ font-size: 12px;
+}
+a {
+ color: #9ccf51;
+ font-weight: bold;
+}
+img {
+ border: none;
+}
+table {
+ empty-cells: show;
+}
+#area-header {
+ text-align: center;
+ background-image: url('../img/header_bg.png');
+}
+#area-header img {
+ position: relative;
+ left: -30px;
+}
+#area-spacer {
+ color: #fff;
+ background-color: #9ccf51;
+ padding-left: 15px;
+ padding-top: 5px;
+}
+#area-main {
+ vertical-align: top;
+ padding-top: 10px;
+}
+#area-main-content {
+ position: relative;
+ left: 50%;
+ margin-left: -150px;
+ width: 300px;
+}
+div.error {
+ font-weight: bold;
+ color: #c30000;
+}
+div.message {
+ font-style: italic;
+}
Modified: trunk/mod/eis_engine/locales/en_en/default/servermanager/css/main.css
===================================================================
--- trunk/mod/eis_engine/locales/en_en/default/servermanager/css/main.css 2007-09-12 00:45:37 UTC (rev 207)
+++ trunk/mod/eis_engine/locales/en_en/default/servermanager/css/main.css 2007-09-14 09:08:02 UTC (rev 208)
@@ -63,6 +63,9 @@
#area-left-content, #area-main-content, #area-right-content {
margin: 10px;
}
+#area-left-content {
+ margin: 10px 10px 0px 10px;
+}
#area-left-content ul {
padding: 0px;
margin: 0px;
@@ -84,6 +87,14 @@
#area-left-content li.active a {
color: #fff;
}
+#area-left-logout {
+ margin: 0px 10px 0px 10px;
+ padding: 2px 0px 2px 10px;
+}
+#area-left-logout a {
+ text-decoration: none;
+ color: #000;
+}
#area-footer {
font-size: 10px;
text-align: center;
Modified: trunk/mod/eis_engine/locales/en_en/default/servermanager/layout.html
===================================================================
--- trunk/mod/eis_engine/locales/en_en/default/servermanager/layout.html 2007-09-12 00:45:37 UTC (rev 207)
+++ trunk/mod/eis_engine/locales/en_en/default/servermanager/layout.html 2007-09-14 09:08:02 UTC (rev 208)
@@ -16,6 +16,7 @@
<td width="200" id="area-left">
<div id="area-left-title"><h1>{AREA_MENUTITLE}</h1></div>
<div id="area-left-content">{AREA_LEFT}</div>
+ <div id="area-left-logout">{AREA_LOGOUT}</div>
</td>
<td id="area-main">
<div id="area-main-title"><h1>{AREA_TITLE}</h1></div>
Added: trunk/mod/eis_engine/locales/en_en/default/servermanager/login.html
===================================================================
--- trunk/mod/eis_engine/locales/en_en/default/servermanager/login.html (rev 0)
+++ trunk/mod/eis_engine/locales/en_en/default/servermanager/login.html 2007-09-14 09:08:02 UTC (rev 208)
@@ -0,0 +1,23 @@
+<html>
+<head>
+ <title>EIS :: {AREA_TITLE}</title>
+ <link rel="stylesheet" href="{URL_STATIC}eis_engine/servermanager/css/login.css" type="text/css" />
+ {AREA_HEAD}
+</head>
+<body>
+<table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0" id="area-layout">
+ <tr>
+ <td height="100" id="area-top"></td>
+ </tr>
+ <tr>
+ <td height="70" id="area-header"><a href="{URL_HOME}"><img src="{URL_STATIC}eis_engine/servermanager/img/header_logo.png" /></a></td>
+ </tr>
+ <tr>
+ <td height="5" id="area-spacer"></td>
+ </tr>
+ <tr>
+ <td id="area-main"><div id="area-main-content">{AREA_MAIN}</div></td>
+ </tr>
+</table>
+</body>
+</html>
Modified: trunk/mod/eis_engine/locales/en_en/strings.xml
===================================================================
--- trunk/mod/eis_engine/locales/en_en/strings.xml 2007-09-12 00:45:37 UTC (rev 207)
+++ trunk/mod/eis_engine/locales/en_en/strings.xml 2007-09-14 09:08:02 UTC (rev 208)
@@ -17,7 +17,7 @@
Is this not the page you expected? The site is probably temporarily unavailable. Please try again on a later time.
</p>
<p>
-If you are the administrator of this site, you can now start <a href="eis-server/">setting up</a> EIS.
+If you are the administrator of this site, you can now start <a href="eis-server/">setting up</a> EIS. If you have just installed EIS, you can log in as 'admin' with password 'admin'.
</p>]]></value>
</string>
<string>
Modified: trunk/mod/eis_engine/services/AuthService.php
===================================================================
--- trunk/mod/eis_engine/services/AuthService.php 2007-09-12 00:45:37 UTC (rev 207)
+++ trunk/mod/eis_engine/services/AuthService.php 2007-09-14 09:08:02 UTC (rev 208)
@@ -8,6 +8,7 @@
if($username == 'admin' && $password == $this->mc['admin_password']) {
return $this->_getAdminUser();
} else {
+ $this->setError(0,'eis_user.e.login.incorrect');
return null;
}
}
@@ -18,6 +19,7 @@
if($username == 'admin' && md5(md5($this->mc['admin_password']).$seed) == $hash) {
return $this->_getAdminUser();
} else {
+ $this->setError(0,'eis_user.e.login.incorrect');
return null;
}
}
Modified: trunk/mod/eis_user/config/elements.php
===================================================================
--- trunk/mod/eis_user/config/elements.php 2007-09-12 00:45:37 UTC (rev 207)
+++ trunk/mod/eis_user/config/elements.php 2007-09-14 09:08:02 UTC (rev 208)
@@ -1,8 +1,10 @@
<?php
- $cfg['Login']['layout'] = null;
+ $cfg['Login']['template'] = null;
$cfg['Login']['redirect_login'] = null;
$cfg['Login']['redirect_logout'] = null;
+ $cfg['Logout']['redirect_logout'] = null;
+
$cfg['SelectUser']['type'] = 'person';
$cfg['SelectUser']['var'] = 'user.persons.current';
$cfg['SelectUser']['user_var'] = null;
Modified: trunk/mod/eis_user/elements/Login.php
===================================================================
--- trunk/mod/eis_user/elements/Login.php 2007-09-12 00:45:37 UTC (rev 207)
+++ trunk/mod/eis_user/elements/Login.php 2007-09-14 09:08:02 UTC (rev 208)
@@ -1,110 +1,122 @@
<?php
/**
- *@ingroup elements_user
- *@{
+ * Login element
*/
- /** Login element */
+ class eis_user_Login extends Element {
- class user_Login extends Element {
function view_default() {
- $sWidget =& $this->e->getService('widget');
+ $sWidget =& $this->e->getService('eis_widget');
//Get user id
- $uid = $this->e->session->getUid();
+ $uid = $this->e->user->getId();
if ($uid > 0) {
- print '<br />'.$this->e->language->getString('logged_in').': '.$this->e->user->getFullName();
- print '<br /><a href="'.$this->e->hrefAction('logout').'">'.$this->e->language->getString('do_logout').'</a><br /><br />';
+ print $this->e->getString('eis_user.l.logged_in',array($this->e->user->getDisplayName()));
+ print '<br /><br /><a href="'.$this->e->hrefAction('logout').'">';
+ print $this->e->getString('eis_user.l.logout').'</a><br /><br />';
} else {
+ //Load javascript libraries
+ $this->e->addAreaContent('HEAD',$sWidget->jsLoadLib('eis_user/js/md5.js'));
+ $this->e->addAreaContent('HEAD',$sWidget->jsLoadLib('eis_user/js/login.js'));
- //Display the form
- $t = new Template();
+ $fields = array('username','password');
+ $posted = $this->getPost();
+ $vals = $sWidget->fillValues($fields,null,$posted);
- $error =& $this->e->session->getReference('error');
+ $seed = $this->_genSeed();
+ $this->e->session->set('seed',$seed);
+ $this->e->session->save();
- if($this->elementConfig['layout'] != null) {
- $t->assign('FORM','form_' . $this->elementConfig['layout'] . '.tpl');
+ //Show form
+ if($this->ec['template'] == null) { //Use widgets...
- $t->addkey('_LOGIN_LABEL',ucfirst($this->e->language->getString('username')));
- $t->addkey('_PASSWORD_LABEL',ucfirst($this->e->language->getString('password')));
- $t->addkey('_SUBMIT_LABEL',ucfirst($this->e->language->getString('do_login')));
- if($error != null) {
- $t->addkey('_MSG',$this->e->language->getString($error));
- }
- } else {
- $t->assign('FORM','form.tpl');
+ $form = "";
- $rows[0][0] = ucfirst($this->e->language->getString('username'));
- $rows[0][1] = $sWidget->inputString('login','',null,'login_username');
+ $labels = array();
+ $values = array();
+
+ $labels[] = 'eis_user.l.username';
+ $values[] = $sWidget->inputString('username',$vals['username']);
- $rows[1][0] = ucfirst($this->e->language->getString('password'));
- $rows[1][1] = $sWidget->inputPassword('password','',null,'login_password');
+ $labels[] = 'eis_user.l.password';
+ $values[] = $sWidget->inputPassword('password',$vals['password']);
+
+ $button = $sWidget->buttonSubmit('eis_user.l.login');
- $t->addkey('_TABLE',$sWidget->formTable($rows));
- $t->addkey('_LOGIN',$sWidget->buttonSubmit('Inloggen'));
+ if($this->ec['template'] != null) { //Use a custom template
- if($error != null) {
- $errors[] = $this->e->language->getString($error);
- $t->addkey('_ERROR',$sWidget->errorList($errors));
+ } else { //Use standard form table
+ $form .= $sWidget->formTable($labels,$values);
+ $form .= $sWidget->buttonSet($button);
}
- }
- $t->assign('SCRIPT','script.tpl');
+ $form .= $sWidget->inputHidden('seed',$seed);
+ $form .= $sWidget->inputHidden('hash','');
- $t->addkey('_ACTION',$this->e->hrefAction('login'));
- $t->addkey('_JSMD5_URL',$this->e->hrefDetach('jsmd5'));
- $t->addkey('_KEY',$this->e->user->getLoginSeed());
- $t->addkey('_HASHED',($this->moduleConfig['password_type'] == 'md5') ? 1 : 0);
+ print $sWidget->form($form, $this->e->hrefAction('login'), 'loginform');
+ print $sWidget->jsAttachHandler('loginform','onsubmit','hashPassword');
- $error = null;
- $this->e->session->save();
+ } else { //Use a custom template...
+ require_once("lib/utils/template.lib.php");
+ $t = new Template();
+ $t->assign('MAIN',$this->e->getStatic($this->ec['template']));
- $t->parse('_SCRIPT','SCRIPT');
- $t->parse('OUT','FORM');
- $t->show('OUT');
- }
- }
+ //Labels
+ $t->addkey('_LABEL_USERNAME',$this->e->getString('eis_user.l.username'));
+ $t->addkey('_LABEL_PASSWORD',$this->e->getString('eis_user.l.password'));
+ $t->addkey('_LABEL_LOGIN',$this->e->getString('eis_user.l.login'));
- function view_jsmd5() {
- header('Content-Type: text/javascript');
+ //Inputs
+ $t->addkey('_VALUE_USERNAME',$vals['username']);
+ $t->addkey('_VALUE_SEED',$seed);
- $t = new Template();
- $t->assign('MAIN','jsmd5.tpl');
- $t->parse('OUT','MAIN');
- $t->show('OUT');
+ //Form action
+ $t->addkey('_ACTION',$this->e->hrefAction('login'));
+
+ $t->parse('OUT','MAIN');
+ $t->show('OUT');
+ }
+ }
}
- function action_login($data) {
+ function action_login($args) {
- // Fetch login parameters from action data
- $login = isset($data['login']) ? $data['login'] : null;
- $hash = isset($data['hash']) ? $data['hash'] : null;
+ $seed = $this->e->session->get('seed');
// Attempt login
- if($this->e->user->logIn($login, $hash)) {
- if($this->elementConfig['redirect_login'] != null) {
- $this->e->redirect($this->e->hrefPage($this->elementConfig['redirect_login']));
- exit;
+ if($this->e->user->loginByMD5($args['username'], $seed, $args['hash'])) {
+
+ if($this->ec['redirect_login'] != null) {
+ $this->e->redirect($this->e->hrefPage($this->ec['redirect_login']));
+ } else {
+ $this->e->redirect($this->e->hrefCurrentPage());
}
} else {
- //Store errormessage in session
- $error =& $this->e->session->getReference('error');
- $error = $this->e->user->getMessage();
- $this->e->session->save();
+ //Show error message
+ $this->setPost($args);
+ $this->e->showServiceError($this->e->user->getError());
+ $this->e->redirect($this->e->hrefCurrentPage());
}
}
function action_logout($data) {
- // Attempt logout
- if($this->e->user->logOut()) {
- if($this->elementConfig['redirect_logout'] != null) {
- $this->e->redirect($this->e->hrefPage($this->elementConfig['redirect_logout']));
- exit;
- }
+ $this->e->user->logout();
+
+ if($this->ec['redirect_logout'] != null) {
+ $this->e->redirect($this->e->hrefPage($this->ec['redirect_logout']));
+ } else {
+ $this->e->redirect($this->e->hrefCurrentPage());
}
}
+
+ function _genSeed() {
+ $seed = "";
+ for($i = 0; $i < 32; $i++) {
+ $seed .= chr(rand(97,122));
+ }
+ return $seed;
+ }
}
- /**@}*/
?>
Added: trunk/mod/eis_user/elements/Logout.php
===================================================================
--- trunk/mod/eis_user/elements/Logout.php (rev 0)
+++ trunk/mod/eis_user/elements/Logout.php 2007-09-14 09:08:02 UTC (rev 208)
@@ -0,0 +1,20 @@
+<?php
+ class eis_user_Logout extends Element {
+
+ function view_default() {
+ print '<a href="'.$this->e->hrefAction('logout').'">'.$this->e->getString('eis_user.l.logout').'</a>';
+ }
+
+ function action_logout($data) {
+
+ $this->e->user->logout();
+
+ if($this->ec['redirect_logout'] != null) {
+ $this->e->redirect($this->e->hrefPage($this->ec['redirect_logout']));
+ } else {
+ $this->e->redirect($this->e->hrefCurrentPage());
+ }
+ }
+
+ }
+?>
Added: trunk/mod/eis_user/locales/en_en/default/element-templates/Login/basic.html
===================================================================
--- trunk/mod/eis_user/locales/en_en/default/element-templates/Login/basic.html (rev 0)
+++ trunk/mod/eis_user/locales/en_en/default/element-templates/Login/basic.html 2007-09-14 09:08:02 UTC (rev 208)
@@ -0,0 +1,26 @@
+<table border="0" cellspacing="0" cellpadding="0">
+ <tr>
+ <td nowrap="1">
+ <form id="loginform" method="post" onsubmit="return hashPassword();" action="{_ACTION}">
+ <table border="0" cellspacing="0" cellpadding="0">
+ <tr>
+ <td>{_LABEL_USERNAME}: </td>
+ <td><input type="text" name="username" id="input-username" value="{_VALUE_USERNAME}"></td>
+ </tr>
+ <tr>
+ <td>{_LABEL_PASSWORD}: </td>
+ <td><input type="password" name="password" id="input-password"></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td align="right" nowrap="1">
+ <input type="submit" value="{_LABEL_LOGIN}" ></span>
+ </td>
+ </tr>
+ </table>
+ <input type="hidden" name="seed" id="input-seed" value="{_VALUE_SEED}" />
+ <input type="hidden" name="hash" id="input-hash" />
+ </form>
+ </td>
+ </tr>
+</table>
Property changes on: trunk/mod/eis_user/locales/en_en/default/element-templates/Login/basic.html
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/mod/eis_user/locales/en_en/default/element-templates/Login/tiny.html
===================================================================
--- trunk/mod/eis_user/locales/en_en/default/element-templates/Login/tiny.html (rev 0)
+++ trunk/mod/eis_user/locales/en_en/default/element-templates/Login/tiny.html 2007-09-14 09:08:02 UTC (rev 208)
@@ -0,0 +1,15 @@
+<script type="text/javascript" />
+function revealPassword() {
+ $('fake-password').style.display = 'none';
+ $('input-password').style.display = 'inline';
+ $('input-password').focus();
+}
+</script>
+<form id="loginform" method="post" onsubmit="return hashPassword();" action="{_ACTION}">
+<input type="text" name="username" value="{_LABEL_USERNAME}" onclick="this.value = '';" /><br />
+<input type="text" id="fake-password" value="{_LABEL_PASSWORD}" onfocus="revealPassword();" /><input type="password" name="password" id="input-password" style="display: none;" /><br />
+<input type="submit" value="{_LABEL_LOGIN}" />
+
+<input type="hidden" name="seed" id="input-seed" value="{_VALUE_SEED}"/>
+<input type="hidden" name="hash" id="input-hash" />
+</form>
Property changes on: trunk/mod/eis_user/locales/en_en/default/element-templates/Login/tiny.html
___________________________________________________________________
Name: svn:executable
+ *
Copied: trunk/mod/eis_user/locales/en_en/default/js/login.js (from rev 205, trunk/mod/eis_user/elements/Login_tpl/script.tpl)
===================================================================
--- trunk/mod/eis_user/locales/en_en/default/js/login.js (rev 0)
+++ trunk/mod/eis_user/locales/en_en/default/js/login.js 2007-09-14 09:08:02 UTC (rev 208)
@@ -0,0 +1,6 @@
+function hashPassword () {
+ $('input-hash').value = calcMD5(calcMD5($F('input-password')) + $F('input-seed'));
+ $('input-password').value = '';
+
+ return true;
+}
Copied: trunk/mod/eis_user/locales/en_en/default/js/md5.js (from rev 205, trunk/mod/eis_user/elements/Login_tpl/jsmd5.tpl)
===================================================================
--- trunk/mod/eis_user/locales/en_en/default/js/md5.js (rev 0)
+++ trunk/mod/eis_user/locales/en_en/default/js/md5.js 2007-09-14 09:08:02 UTC (rev 208)
@@ -0,0 +1,174 @@
+/*
+ * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
+ * Digest Algorithm, as defined in RFC 1321.
+ * Copyright (C) Paul Johnston 1999 - 2000.
+ * Updated by Greg Holt 2000 - 2001.
+ * See http://pajhome.org.uk/site/legal.html for details.
+ */
+
+/*
+ * Convert a 32-bit number to a hex string with ls-byte first
+ */
+var hex_chr = "0123456789abcdef";
+function rhex(num)
+{
+ str = "";
+ for(j = 0; j <= 3; j++)
+ str += hex_chr.charAt((num >> (j * 8 + 4)) & 0x0F) +
+ hex_chr.charAt((num >> (j * 8)) & 0x0F);
+ return str;
+}
+
+/*
+ * Convert a string to a sequence of 16-word blocks, stored as an array.
+ * Append padding bits and the length, as described in the MD5 standard.
+ */
+function str2blks_MD5(str)
+{
+ nblk = ((str.length + 8) >> 6) + 1;
+ blks = new Array(nblk * 16);
+ for(i = 0; i < nblk * 16; i++) blks[i] = 0;
+ for(i = 0; i < str.length; i++)
+ blks[i >> 2] |= str.charCodeAt(i) << ((i % 4) * 8);
+ blks[i >> 2] |= 0x80 << ((i % 4) * 8);
+ blks[nblk * 16 - 2] = str.length * 8;
+ return blks;
+}
+
+/*
+ * Add integers, wrapping at 2^32. This uses 16-bit operations internally
+ * to work around bugs in some JS interpreters.
+ */
+function add(x, y)
+{
+ var lsw = (x & 0xFFFF) + (y & 0xFFFF);
+ var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
+ return (msw << 16) | (lsw & 0xFFFF);
+}
+
+/*
+ * Bitwise rotate a 32-bit number to the left
+ */
+function rol(num, cnt)
+{
+ return (num << cnt) | (num >>> (32 - cnt));
+}
+
+/*
+ * These functions implement the basic operation for each round of the
+ * algorithm.
+ */
+function cmn(q, a, b, x, s, t)
+{
+ return add(rol(add(add(a, q), add(x, t)), s), b);
+}
+function ff(a, b, c, d, x, s, t)
+{
+ return cmn((b & c) | ((~b) & d), a, b, x, s, t);
+}
+function gg(a, b, c, d, x, s, t)
+{
+ return cmn((b & d) | (c & (~d)), a, b, x, s, t);
+}
+function hh(a, b, c, d, x, s, t)
+{
+ return cmn(b ^ c ^ d, a, b, x, s, t);
+}
+function ii(a, b, c, d, x, s, t)
+{
+ return cmn(c ^ (b | (~d)), a, b, x, s, t);
+}
+
+/*
+ * Take a string and return the hex representation of its MD5.
+ */
+function calcMD5(str)
+{
+ x = str2blks_MD5(str);
+ a = 1732584193;
+ b = -271733879;
+ c = -1732584194;
+ d = 271733878;
+
+ for(i = 0; i < x.length; i += 16)
+ {
+ olda = a;
+ oldb = b;
+ oldc = c;
+ oldd = d;
+
+ a = ff(a, b, c, d, x[i+ 0], 7 , -680876936);
+ d = ff(d, a, b, c, x[i+ 1], 12, -389564586);
+ c = ff(c, d, a, b, x[i+ 2], 17, 606105819);
+ b = ff(b, c, d, a, x[i+ 3], 22, -1044525330);
+ a = ff(a, b, c, d, x[i+ 4], 7 , -176418897);
+ d = ff(d, a, b, c, x[i+ 5], 12, 1200080426);
+ c = ff(c, d, a, b, x[i+ 6], 17, -1473231341);
+ b = ff(b, c, d, a, x[i+ 7], 22, -45705983);
+ a = ff(a, b, c, d, x[i+ 8], 7 , 1770035416);
+ d = ff(d, a, b, c, x[i+ 9], 12, -1958414417);
+ c = ff(c, d, a, b, x[i+10], 17, -42063);
+ b = ff(b, c, d, a, x[i+11], 22, -1990404162);
+ a = ff(a, b, c, d, x[i+12], 7 , 1804603682);
+ d = ff(d, a, b, c, x[i+13], 12, -40341101);
+ c = ff(c, d, a, b, x[i+14], 17, -1502002290);
+ b = ff(b, c, d, a, x[i+15], 22, 1236535329);
+
+ a = gg(a, b, c, d, x[i+ 1], 5 , -165796510);
+ d = gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
+ c = gg(c, d, a, b, x[i+11], 14, 643717713);
+ b = gg(b, c, d, a, x[i+ 0], 20, -373897302);
+ a = gg(a, b, c, d, x[i+ 5], 5 , -701558691);
+ d = gg(d, a, b, c, x[i+10], 9 , 38016083);
+ c = gg(c, d, a, b, x[i+15], 14, -660478335);
+ b = gg(b, c, d, a, x[i+ 4], 20, -405537848);
+ a = gg(a, b, c, d, x[i+ 9], 5 , 568446438);
+ d = gg(d, a, b, c, x[i+14], 9 , -1019803690);
+ c = gg(c, d, a, b, x[i+ 3], 14, -187363961);
+ b = gg(b, c, d, a, x[i+ 8], 20, 1163531501);
+ a = gg(a, b, c, d, x[i+13], 5 , -1444681467);
+ d = gg(d, a, b, c, x[i+ 2], 9 , -51403784);
+ c = gg(c, d, a, b, x[i+ 7], 14, 1735328473);
+ b = gg(b, c, d, a, x[i+12], 20, -1926607734);
+
+ a = hh(a, b, c, d, x[i+ 5], 4 , -378558);
+ d = hh(d, a, b, c, x[i+ 8], 11, -2022574463);
+ c = hh(c, d, a, b, x[i+11], 16, 1839030562);
+ b = hh(b, c, d, a, x[i+14], 23, -35309556);
+ a = hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
+ d = hh(d, a, b, c, x[i+ 4], 11, 1272893353);
+ c = hh(c, d, a, b, x[i+ 7], 16, -155497632);
+ b = hh(b, c, d, a, x[i+10], 23, -1094730640);
+ a = hh(a, b, c, d, x[i+13], 4 , 681279174);
+ d = hh(d, a, b, c, x[i+ 0], 11, -358537222);
+ c = hh(c, d, a, b, x[i+ 3], 16, -722521979);
+ b = hh(b, c, d, a, x[i+ 6], 23, 76029189);
+ a = hh(a, b, c, d, x[i+ 9], 4 , -640364487);
+ d = hh(d, a, b, c, x[i+12], 11, -421815835);
+ c = hh(c, d, a, b, x[i+15], 16, 530742520);
+ b = hh(b, c, d, a, x[i+ 2], 23, -995338651);
+
+ a = ii(a, b, c, d, x[i+ 0], 6 , -198630844);
+ d = ii(d, a, b, c, x[i+ 7], 10, 1126891415);
+ c = ii(c, d, a, b, x[i+14], 15, -1416354905);
+ b = ii(b, c, d, a, x[i+ 5], 21, -57434055);
+ a = ii(a, b, c, d, x[i+12], 6 , 1700485571);
+ d = ii(d, a, b, c, x[i+ 3], 10, -1894986606);
+ c = ii(c, d, a, b, x[i+10], 15, -1051523);
+ b = ii(b, c, d, a, x[i+ 1], 21, -2054922799);
+ a = ii(a, b, c, d, x[i+ 8], 6 , 1873313359);
+ d = ii(d, a, b, c, x[i+15], 10, -30611744);
+ c = ii(c, d, a, b, x[i+ 6], 15, -1560198380);
+ b = ii(b, c, d, a, x[i+13], 21, 1309151649);
+ a = ii(a, b, c, d, x[i+ 4], 6 , -145523070);
+ d = ii(d, a, b, c, x[i+11], 10, -1120210379);
+ c = ii(c, d, a, b, x[i+ 2], 15, 718787259);
+ b = ii(b, c, d, a, x[i+ 9], 21, -343485551);
+
+ a = add(a, olda);
+ b = add(b, oldb);
+ c = add(c, oldc);
+ d = add(d, oldd);
+ }
+ return rhex(a) + rhex(b) + rhex(c) + rhex(d);
+}
Modified: trunk/mod/eis_user/locales/en_en/strings.xml
===================================================================
--- trunk/mod/eis_user/locales/en_en/strings.xml 2007-09-12 00:45:37 UTC (rev 207)
+++ trunk/mod/eis_user/locales/en_en/strings.xml 2007-09-14 09:08:02 UTC (rev 208)
@@ -4,4 +4,24 @@
<name>l.logged_in</name>
<value><![CDATA[You are logged in as: %s]]></value>
</string>
+ <string>
+ <name>l.username</name>
+ <value><![CDATA[Username]]></value>
+ </string>
+ <string>
+ <name>l.password</name>
+ <value><![CDATA[Password]]></value>
+ </string>
+ <string>
+ <name>l.login</name>
+ <value><![CDATA[Log in]]></value>
+ </string>
+ <string>
+ <name>l.logout</name>
+ <value><![CDATA[Log out]]></value>
+ </string>
+ <string>
+ <name>e.login.incorrect</name>
+ <value><![CDATA[Incorrect username or password]]></value>
+ </string>
</strings>
Modified: trunk/mod/eis_widget/locales/en_en/default/css/widget.css
===================================================================
--- trunk/mod/eis_widget/locales/en_en/default/css/widget.css 2007-09-12 00:45:37 UTC (rev 207)
+++ trunk/mod/eis_widget/locales/en_en/default/css/widget.css 2007-09-14 09:08:02 UTC (rev 208)
@@ -26,7 +26,7 @@
border: solid 1px #999;
}
input.widget-input-password {
- width: 100%;
+ width: 200px;
border: solid 1px #999;
}
Modified: trunk/mod/eis_widget/services/MainService.php
===================================================================
--- trunk/mod/eis_widget/services/MainService.php 2007-09-12 00:45:37 UTC (rev 207)
+++ trunk/mod/eis_widget/services/MainService.php 2007-09-14 09:08:02 UTC (rev 208)
@@ -240,6 +240,9 @@
case 'password':
$html = $this->inputPassword($name, $value, $options, $id, $conf);
break;
+ case 'hidden':
+ $html = $this->inputHidden($name, $value, $options, $id, $conf);
+ break;
case 'currency':
$html = $this->inputCurrency($name, $value, $options, $id, $conf);
break;
@@ -467,9 +470,29 @@
$html .= 'id="'.$id.'" ';
$html .= 'class="widget-input-password" />';
- return $input;
+ return $html;
}
/**
+ * Input widget for a hidden value
+ * @param $name the identifying name of the input in a form
+ * @param $value the current value of the input
+ * @param $options an optional list of possible values for the input
+ * @param $id an optional html dom id to identify the widget with javascript or stylesheets
+ * @param $conf optional configuration of the widget
+ * @return html rendering of the widget
+ */
+ function inputHidden($name, $value, $options = null, $id = null, $conf = null) {
+ if($id == null) {
+ $id = 'input-'.$name;
+ }
+
+ $html = '<input type="hidden" name="'.$name.'" value="'.$value.'" ';
+ $html .= 'id="'.$id.'" ';
+ $html .= 'class="widget-input-hidden" />';
+
+ return $html;
+ }
+ /**
* Input widget for a url value
* @param $name the identifying name of the input in a form
* @param $value the current value of the input
@@ -481,7 +504,6 @@
function inputURL($name, $value, $options = null, $id = null, $conf = null) {
return $this->inputScalar('url', $name, $value, $options, $id, $conf);
}
-
/**
* Input widget for a currency value
* @param $name the identifying name of the input in a form
@@ -802,11 +824,15 @@
//UTILITY FUNCTIONS
- function form($body, $action, $conf = null) {
+ function form($body, $action, $id = null, $conf = null) {
$method = (isset($conf['method']) && $conf['method']) ? $conf['method'] : 'post';
- $html = '<form action="'.$action.'" method="'.$method.'" enctype="multipart/form-data" >';
+ $html = '<form action="'.$action.'" method="'.$method.'" enctype="multipart/form-data" ';
+ if($id != null) {
+ $html .= 'id="'.$id.'" ';
+ }
+ $html .= '>';
$html .= $body.'</form>';
return $html;
@@ -842,7 +868,19 @@
//JAVASCRIPT GENERATION
- function jsUpdateSelect($src,$dest,$url) {
+ /**
+ * Attaches a javascript event handler to html element
+ * For example jsAttachHandler('mybutton','onclick','doStuff') attaches the 'doStuff'
+ * Javascript function to the 'onclick' event of the element with id 'mybutton'.
+ *
+ * @param $id the DOM id of the html element
+ * @param $event the event that triggers the handler (e.g. onclick, onsubmit, onfocus)
+ * @param $handler the javascript function that serves as the event handler
+ */
+ function jsAttachHandler($id, $event, $handler) {
+ return '<script type="text/javascript"> $(\''.$id.'\').'.$event.' = '.$handler.'; </script>';
+ }
+ function jsUpdateSelect($src, $dest, $url) {
$js = '<script type="text/javascript" >';
$js .= '$(\'input-'.$src.'\').onchange = function () {';
$js .= 'new Ajax.Request(\''.$url.'\',{';
@@ -856,7 +894,6 @@
return $js;
}
-
function jsEncodeOptions($options) {
$html = array();
foreach($options as $option) {
@@ -864,6 +901,15 @@
}
return "[".implode(",",$html)."]";
}
+ /**
+ * Loads a separate javascript library
+ *
+ * @param file the file (static resource) that has to be loaded.
+ */
+ function jsLoadLib($file) {
+ $href = $this->e->hrefStatic($file);
+ return '<script type="text/javascript" src="'.$href.'"></script>';
+ }
/**
*Converts a php array into a javascript array.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|