Ejemplo n.º 1
0
 /**
  * Show the login form
  *
  * @param	string		Message to show on login form
  * @return	string		Login form HTML
  */
 public function loginForm($message = "", $replacement = '')
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $extra_form = "";
     $show_form = 1;
     $template = '';
     $serviceClick = trim($this->request['serviceClick']);
     //-----------------------------------------
     // Are they banned?
     //-----------------------------------------
     if (IPSMember::isBanned('ip', $this->member->ip_address)) {
         $this->registry->getClass('output')->showError('you_are_banned', 2011, null, null, 403);
     }
     if ($message != "") {
         if ($replacement) {
             $message = sprintf($this->lang->words[$message], $replacement);
         } else {
             $message = $this->lang->words[$message];
         }
         $name = $this->request['UserName'] ? $this->request['UserName'] : $this->request['address'];
         $message = str_replace("<#NAME#>", "<b>" . $name . "</b>", $message);
         $template .= $this->registry->getClass('output')->getTemplate('login')->errors($message);
     }
     //-----------------------------------------
     // Using an alternate log in form?
     //-----------------------------------------
     $this->han_login->checkLoginUrlRedirect();
     /* Did we click a service? */
     if ($serviceClick) {
         switch ($serviceClick) {
             case 'facebook':
                 $this->registry->getClass('output')->silentRedirect($this->settings['_original_base_url'] . "/interface/facebook/index.php?_reg=1");
                 break;
             case 'twitter':
                 $this->registry->getClass('output')->silentRedirect($this->settings['_original_base_url'] . "/interface/twitter/index.php?_reg=1");
                 break;
         }
     }
     //-----------------------------------------
     // Extra  HTML?
     //-----------------------------------------
     $additionalForm = $this->han_login->additionalFormHTML();
     if (count($additionalForm[1])) {
         if ($additionalForm[0] == 'add') {
             $extra_form = $additionalForm[1];
             $show_form = 1;
         } else {
             if (is_array($additionalForm[1])) {
                 foreach ($additionalForm[1] as $_form) {
                     $template .= $_form;
                 }
             } else {
                 $template .= $additionalForm[1];
             }
             $show_form = 0;
         }
     }
     //-----------------------------------------
     // Continue...
     //-----------------------------------------
     if ($show_form) {
         if ($this->request['referer']) {
             $http_referrer = $this->request['referer'];
         } else {
             /* @link	http://community.invisionpower.com/tracker/issue-32302-login-redirect-when-activating */
             $_urlPieces = @parse_url($this->settings['board_url']);
             if (strpos(my_getenv('HTTP_REFERER'), $_urlPieces['host'] ? $_urlPieces['host'] : $this->settings['board_url']) !== false) {
                 $http_referrer = my_getenv('HTTP_REFERER');
             } else {
                 $http_referrer = '';
             }
         }
         $login_methods = false;
         $uses_name = false;
         $uses_email = false;
         foreach ($this->cache->getCache('login_methods') as $method) {
             $login_methods[$method['login_folder_name']] = $method['login_folder_name'];
             if ($method['login_user_id'] == 'username' or $method['login_user_id'] == 'either') {
                 $uses_name = true;
             }
             if ($method['login_user_id'] == 'email' or $method['login_user_id'] == 'either') {
                 $uses_email = true;
             }
         }
         if ($uses_name and $uses_email) {
             $this->lang->words['enter_name'] = $this->lang->words['enter_name_and_email'];
         } else {
             if ($uses_email) {
                 $this->lang->words['enter_name'] = $this->lang->words['enter_useremail'];
             } else {
                 $this->lang->words['enter_name'] = $this->lang->words['enter_username'];
             }
         }
         $template .= $this->registry->getClass('output')->getTemplate('login')->showLogInForm($this->lang->words['please_log_in'], htmlentities(urldecode($http_referrer)), $extra_form, $login_methods);
     }
     $this->registry->getClass('output')->addNavigation($this->lang->words['log_in'], '');
     $this->registry->getClass('output')->setTitle($this->lang->words['log_in'] . ' - ' . ipsRegistry::$settings['board_name']);
     $this->registry->getClass('output')->addContent($template);
     $this->registry->getClass('output')->sendOutput();
 }
 /**
  * Show the login form
  *
  * @access	public
  * @param	string		Message to show on login form
  * @return	string		Login form HTML
  */
 public function loginForm($message = "", $replacement = '')
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $extra_form = "";
     $show_form = 1;
     $template = '';
     //-----------------------------------------
     // Are they banned?
     //-----------------------------------------
     if (IPSMember::isBanned('ip', $this->member->ip_address)) {
         $this->registry->getClass('output')->showError('you_are_banned', 2011);
     }
     if ($message != "") {
         if ($replacement) {
             $message = sprintf($this->lang->words[$message], $replacement);
         } else {
             $message = $this->lang->words[$message];
         }
         $name = $this->request['UserName'] ? $this->request['UserName'] : $this->request['address'];
         $message = str_replace("<#NAME#>", "<b>" . $name . "</b>", $message);
         $template .= $this->registry->getClass('output')->getTemplate('login')->errors($message);
     }
     //-----------------------------------------
     // Using an alternate log in form?
     //-----------------------------------------
     $this->han_login->checkLoginUrlRedirect();
     //-----------------------------------------
     // Extra  HTML?
     //-----------------------------------------
     $additionalForm = $this->han_login->additionalFormHTML();
     if (count($additionalForm[1])) {
         if ($additionalForm[0] == 'add') {
             $extra_form = $additionalForm[1];
             $show_form = 1;
         } else {
             $template .= $additionalForm[1];
             $show_form = 0;
         }
     }
     //-----------------------------------------
     // Continue...
     //-----------------------------------------
     if ($show_form) {
         if ($this->request['referer']) {
             $http_referrer = $this->request['referer'];
         } else {
             if (!my_getenv('HTTP_REFERER') or stripos(my_getenv('HTTP_REFERER'), $this->settings['board_url']) === false) {
                 // HTTP_REFERER isn't set when force_login is enabled
                 // This method will piece together the base url, and the querystring arguments
                 // This is not anymore secure/insecure than IPB, as IPB will have to process
                 // those arguments whether force_login is enabled or not.
                 $argv = is_array(my_getenv('argv')) && count(my_getenv('argv')) > 0 ? my_getenv('argv') : array();
                 $http_referrer = $this->settings['base_url'] . @implode("&amp;", $argv);
             } else {
                 $http_referrer = my_getenv('HTTP_REFERER');
             }
         }
         $facebookOpts = array();
         $login_methods = false;
         $uses_name = false;
         $uses_email = false;
         foreach ($this->cache->getCache('login_methods') as $method) {
             $login_methods[$method['login_folder_name']] = $method['login_folder_name'];
             if ($method['login_user_id'] == 'username') {
                 $uses_name = true;
             }
             if ($method['login_user_id'] == 'email') {
                 $uses_email = true;
             }
         }
         if ($uses_name and $uses_email) {
             $this->lang->words['enter_name'] = $this->lang->words['enter_name_and_email'];
         } else {
             if ($uses_email) {
                 $this->lang->words['enter_name'] = $this->lang->words['enter_useremail'];
             } else {
                 $this->lang->words['enter_name'] = $this->lang->words['enter_username'];
             }
         }
         $template .= $this->registry->getClass('output')->getTemplate('login')->showLogInForm($this->lang->words['please_log_in'], htmlentities(urldecode($http_referrer)), $extra_form, $login_methods, $facebookOpts);
     }
     /* Work around for bug http://bugs.developers.facebook.com/show_bug.cgi?id=3237 */
     if (IPSLib::fbc_enabled()) {
         $this->_facebook->testConnectSession();
     }
     $this->registry->getClass('output')->addNavigation($this->lang->words['log_in'], '');
     $this->registry->getClass('output')->setTitle($this->lang->words['log_in']);
     $this->registry->getClass('output')->addContent($template);
     $this->registry->getClass('output')->sendOutput();
 }