/** * * Render a login box * * @param string $module The module we are in or will go to * @param boolean $ajaxLogin Whether or not to do ajax login * @return string The login box * @access public * */ public function renderLoginBox($module = NULL, $ajaxLogin = FALSE) { try { // Determine if we need to use https $useHTTPS = $this->objSysConfig->getValue('MOD_SECURITY_HTTPS', 'security'); // Set the formaction depending on whether it is going to use ajax or not. if (!$ajaxLogin) { // Set the action for the login form depending on if there is a module or not. if ($module != NULL) { $formAction = $this->uri(array('action' => 'login', 'mod' => $module), 'security'); } else { $formAction = $this->uri(array('action' => 'login'), 'login'); } if ($useHTTPS == '1' || $useHTTPS == 'TRUE') { $formAction = str_replace("http:", "https:", $formAction); } } else { // We want an ajax login. $formAction = 'javascript:void(0);'; } // Create a Form object. $objForm = new form('loginform', $formAction); $objFields = new fieldset(); $objFields->setLegend(' '); //--Create an element for the username $objInput = new textinput('username', '', 'text', '15'); $objInput->extra = 'maxlength="255"'; $objInput->setCss('required minlength(2)'); $objLabel = new label($this->objLanguage->languageText('word_username') . ': ', 'input_username'); //Add the username box to the form $objFields->addContent($objLabel->show() . '<br />'); $objFields->addContent($objInput->show() . '<br />'); //--- Create an element for the password $objInput = new textinput('password', '', 'password', '15'); $objInput->extra = 'maxlength="255"'; $objInput->setCss('required'); $objLabel = new label($this->objLanguage->languageText('word_password') . ': ', 'input_password'); $objFields->addContent($objLabel->show() . '<br />'); $objFields->addContent($objInput->show()); //--- Create an element for the network login radio $objElement = new checkbox("useLdap"); $objElement->setCSS("transparentbgnb"); $objElement->label = $this->objLanguage->languageText("phrase_networkid") . ' '; $ldap = ''; $objSysConfig = $this->getObject('dbsysconfig', 'sysconfig'); $showLDAPCheckBox = $objSysConfig->getValue('show_ldap_checkbox', 'security'); // Get a nonce $objNonce = $this->getObject('nonce', 'login'); $nonce = $objNonce->storeNonce(); // Create a hidden field for the nonce $objNonce = new hiddeninput('nonce', $nonce); $objNonce->extra = ' id=\'nonce\''; $nonce = $objNonce->show(); //----------------------------------------------------------------------------------------Checking this is a violation of the principle of chain of responsiblity @todo fix it if ($this->objConfig->getuseLDAP() && $showLDAPCheckBox == 'true') { $ldap .= $objElement->label . ' ' . $objElement->show(); } //--- Create an element for the remember me checkbox $objRElement = new checkbox("remember"); $objRElement->setCSS("transparentbgnb noborder"); $objRElement->label = $this->objLanguage->languageText("phrase_rememberme", "security"); $rem = $objRElement->show() . "<br />"; //--- Create a submit button $objButton = new button('submit', $this->objLanguage->languageText("word_login")); // Add the login icon $objButton->setIconClass("user"); // Set the button type to submit $objButton->setToSubmit(); // Give the button an ID for jQuery to grab. $objButton->setId('loginButton'); // Add the button to the form ----------------------------------------------------------- Note LDAP breaks the COR pattern $objFields->addContent($ldap . '<br />' . $nonce . $rem . "<div class='loginbuttonwrap'>" . $objButton->show() . '</div>'); $helpText = strtoupper($this->objLanguage->languageText('word_help', 'system')); $helpIcon = $this->objHelp->show('register', 'useradmin', $helpText); $resetLink = new Link($this->uri(array('action' => 'needpassword'), 'security')); $resetLink->link = $this->objLanguage->languageText('mod_security_forgotpassword'); // the help link $p = '<br/>' . $resetLink->show() . '<br />' . $helpIcon; $objFields->addContent($p); $objForm->addToForm($objFields->show()); return '<div id="login_block_wrapper">' . $objForm->show() . '</div>'; } catch (Exception $e) { customException::cleanUp(); } }
/** * Method to render a login box * @returns string */ public function renderLoginBox($module = NULL) { try { //set the action for the login form if ($module != NULL) { $formAction = $this->objEngine->uri(array('action' => 'login', 'mod' => $module), 'security'); } else { $formAction = $this->objEngine->uri(array('action' => 'login'), 'security'); } $useHTTPS = $this->objSysConfig->getValue('MOD_SECURITY_HTTPS', 'security'); if ($useHTTPS == '1') { $formAction = str_replace("http:", "https:", $formAction); } //Load up the various HTML classes $this->loadClass('button', 'htmlelements'); $this->loadClass('textinput', 'htmlelements'); $this->loadClass('checkbox', 'htmlelements'); $this->loadClass('link', 'htmlelements'); $this->loadClass('label', 'htmlelements'); $this->loadClass('fieldset', 'htmlelements'); $objBox = $this->newObject('alertbox', 'htmlelements'); $objIcon = $this->getObject('geticon', 'htmlelements'); // prepare the link for the oAuth providers $box = $this->oauthDisp(); $fb = $this->fbButton(); //fbConnect(); // Create a Form object $objForm = new form('loginform', $formAction); $objFields = new fieldset(); $objFields->setLegend(' '); //--Create an element for the username $objInput = new textinput('username', '', 'text', '15'); $objInput->extra = 'maxlength="255" placeholder="' . $this->objLanguage->languageText('word_username', 'system') . '"'; $objLabel = new label($this->objLanguage->languageText('word_username') . ': ', 'input_username'); //Add validation for username $objForm->addRule('username', $this->objLanguage->languageText("mod_login_unrequired", 'security', 'Please enter a username. A username is required in order to login.'), 'required'); //Add the username box to the form $this->objIcon->setIcon('user'); $objFields->addContent($this->objIcon->show()); $objFields->addContent($objInput->show() . '<br />'); //$objForm->addToForm(); //--- Create an element for the password $objInput = new textinput('password', '', 'password', '15'); $objInput->extra = 'maxlength="255" placeholder="' . $this->objLanguage->languageText('word_password', 'system') . '"'; $objLabel = new label($this->objLanguage->languageText('word_password') . ': ', 'input_password'); //Add the password box to the form //$objForm->addToForm(); $this->objIcon->setIcon('key'); $objFields->addContent($this->objIcon->show()); // $objFields->addContent($objLabel->show() . '<br />'); $objFields->addContent($objInput->show()); //--- Create an element for the network login radio $objElement = new checkbox("useLdap"); $objElement->setCSS("transparentbgnb"); $objElement->label = $this->objLanguage->languageText("phrase_networkid") . ' '; $ldap = ''; $objSysConfig = $this->getObject('dbsysconfig', 'sysconfig'); $showLDAPCheckBox = $objSysConfig->getValue('show_ldap_checkbox', 'security'); if ($this->objConfig->getuseLDAP() && $showLDAPCheckBox == 'true') { $ldap .= $objElement->label . ' ' . $objElement->show(); } //--- Create an element for the remember me checkbox $objRElement = new checkbox("remember"); $objRElement->setCSS("transparentbgnb noborder"); $objRElement->label = $this->objLanguage->languageText("phrase_rememberme", "security"); $rem = $objRElement->show() . "<br />"; //--- Create a submit button $objButton = new button('submit', $this->objLanguage->languageText("word_login")); // Add the login icon $objButton->setIconClass("user"); // Set the button type to submit $objButton->setToSubmit(); // Add the button to the form // openid / google /yahoo login // Open ID login code. $showOpenIdLogin = $objSysConfig->getValue('show_openidconnect_auth', 'security'); $openidlink = ""; if ($showOpenIdLogin == 'true') { // OpenId auth page is used for Google and Yahoo $objAltConfig = $this->getObject('altconfig', 'config'); $siteRoot = $objAltConfig->getSiteRoot(); $OPENID_AUTH_PAGE = $this->uri(array("action" => "openidconnect"), "security"); // Google icon $gIcon = $this->newObject('geticon', 'htmlelements'); $gIcon->setIcon('google'); $gIcon->alt = "Google ID"; $gIcon->extra = ' name="but_google" id="but_google2" onload="" '; // Facebook icon $fIcon = $this->newObject('geticon', 'htmlelements'); $fIcon->setIcon('facebook'); $fIcon->alt = "FB ID"; $fIcon->extra = ' name="but_fb" id="but_fb" onload="" '; $FB_AUTH_PAGE = $this->uri(array("action" => "initfacebooklogin", 'auth_site' => 'facebook'), "security"); // Yahoo icon $yIcon = $this->newObject('geticon', 'htmlelements'); $yIcon->setIcon('yahoo'); $yIcon->alt = "Yahoo ID"; $yIcon->extra = ' name="but_yahoo" id="but_yahoo" onload="" '; //Twitter icon $tIcon = $this->newObject('geticon', 'htmlelements'); $tIcon->setIcon('twitter', 'png'); $tIcon->alt = "TWITTER ID"; $tIcon->extra = ' name="but_twitter" id="but_twitter" onload="" '; $TWITTER_AUTH_PAGE = $this->uri(array("action" => "dotwitterlogin", 'auth_site' => 'twitter'), "security"); $TWITTER_AUTH_PAGE = str_replace("&", "&", $TWITTER_AUTH_PAGE); $openidloginlink = new link($this->uri(array("action" => "openidconnect"), "security")); $openidloginlink->link = '<h3>' . $this->objLanguage->languageText('mod_security_oauthheading', 'security') . '</h3>'; $sitePath = $objAltConfig->getSitePath(); // A google login icon linked to OpenID login with gooogle id. $googleTD = '<a href="' . $OPENID_AUTH_PAGE . '&auth_site=google" target="_top">' . $gIcon->show() . '</a>'; // A Yahoo login icon linked to OpenId login with Yahoo ID. $yahooTD = '<a href="' . $OPENID_AUTH_PAGE . '&auth_site=yahoo" target="_top">' . $yIcon->show() . '</a>'; // Facebook login icon with link to login page. $fbTD = '<a href="' . $FB_AUTH_PAGE . '" target="_top">' . $fIcon->show() . '</a>'; // Twitter login icon with link to login page. $twitterTD = '<a href="' . $TWITTER_AUTH_PAGE . '" target="_top">' . $tIcon->show() . '</a>'; //$twitterTD = NULL; <--- uncomment for commit until TWITTER AUTH is fixed // Explanation text for the textbox and Choose button $explainBox = '<div class="oid_explain">' . $this->objLanguage->languageText('mod_security_openidexplainbox', 'security') . '</div>'; // Title for the fieldset. $title = '<h3>' . $this->objLanguage->languageText('mod_security_openidlogintitle', 'security') . '</h3>'; $allowOpenIdForm = FALSE; if ($allowOpenIdForm) { // Allow login via any Open ID url, use mainly for testing. $openIdForm = new form('openlogiidnform', $this->uri(array("action" => "openidconnect", "auth_site" => "openid"))); $objInput = new textinput('openIDField', '', 'text', '30'); $objInput->extra = 'maxlength="255"'; $openIdForm->addToForm($explainBox . $objInput->show()); // The login via provided open ID URL button $openIdButton = new button('submit', $this->objLanguage->languageText("mod_security_openidlogin", 'security')); // Add the login icon $openIdButton->setIconClass("user"); // Set the button type to submit $openIdButton->setToSubmit(); $openIdForm->addToForm($openIdButton->show()); $opForm = '<hr/><br/>' . $openIdForm->show(); } else { $opForm = NULL; } $openIdFields = new fieldset(); $openIdFields->setLegend('<h3>' . $title . '</h3>'); $openIdFields->addContent($this->objLanguage->languageText('mod_security_oidliinstr', 'security', 'Login with one of the accounts indicated by the icons below')); $openIdFields->addContent('<hr>'); $openIdFields->addContent($fbTD . ' ' . $twitterTD . ' ' . $googleTD . ' ' . $yahooTD . ' ' . $opForm); $openidlink = '<div class="openidlogin">' . $openIdFields->show() . "</div>"; } $objFields->addContent($ldap . '<br />' . $rem . $box . "<div class='loginbuttonwrap'>" . $objButton->show() . '</div>' . $fb); $notice = $this->objLanguage->languageText('mod_security_forgotpassword'); $helpText = strtoupper($this->objLanguage->languageText('mod_security_helpmelogin', 'security', 'Yes, please help me to login')); $resetLink = new Link($this->uri(array('action' => 'needpassword'), 'security')); $resetLink->link = $helpText; // the help link $p = '<br />' . $notice . '<br/>' . $resetLink->show() . '<br />'; $objFields->addContent($p); $objForm->addToForm($objFields->show()); return $objForm->show() . $openidlink; } catch (Exception $e) { customException::cleanUp(); } }