/** * control * * The controlling structure for this page. * * @return void */ function control() { if (!isRegistrationOn()) { $this->displayClosed(); } elseif (isset($_GET['ajax'])) { $this->checkUsername(); } elseif (isset($_GET['facebook'])) { $this->handleFacebookRegister(); } elseif (isset($_POST['submit'])) { $this->displaySubmit(); } else { $this->displayForm(); } }
/** * displayLogin * * @return void */ function displayLogin() { $sitename = getSiteName(); if (isset($_GET['url'])) { $hidden = '<input type="hidden" name="url" id="url" value="' . cleanOutput($_GET['url']) . '"/>'; } else { $hidden = ''; } // Get available languages $lang_dir = "language/"; $lang_options = ''; if (is_dir($lang_dir)) { if ($dh = opendir($lang_dir)) { while (($file = readdir($dh)) !== false) { // Skip directories that start with a period if ($file[0] === '.') { continue; } // Skip files (messages.pot) if (!is_dir("{$lang_dir}{$file}")) { continue; } // Skip directories that don't include a messages.mo file if (!file_exists($lang_dir . $file . '/LC_MESSAGES/messages.mo')) { continue; } $arr[$file] = getLangName($file); } closedir($dh); asort($arr); foreach ($arr as $key => $val) { $lang_options .= '<option value="' . $key . '"'; if (isset($_SESSION['language'])) { if ($_SESSION['language'] == $key) { $lang_options .= ' selected="selected"'; } } $lang_options .= '>' . $val . '</option>'; } } } $forgotPassLink = '<a href="lostpw.php">' . T_('Forgot Password?') . '</a>'; $registerLink = ''; $facebookLogin = ''; if (isRegistrationOn()) { $registerLink = ' | <a href="register.php">' . T_('Register') . '</a>'; } $fbData = getFacebookConfigData(); $params = array('scope' => 'user_about_me,user_birthday,user_location,email,publish_stream,offline_access'); // Print the facebook register button if (!empty($fbData['fb_app_id']) && !empty($fbData['fb_secret'])) { $facebook = new Facebook(array('appId' => $fbData['fb_app_id'], 'secret' => $fbData['fb_secret'])); $facebookLogin = '******' . $facebook->getLoginUrl($params) . '" title="' . T_('Login using Facebook') . '"><img src="ui/img/facebook_tiny.png"/></a>'; } echo ' <div id="login_box"> <h1 id="login_header">' . T_('Login to') . ' ' . $sitename . '</h1> <form action="index.php" method="post"> <div style="float:right"> <select style="background-color:#e9f3fb; border:none;" onchange="window.location.href=\'?lang=\'+this.options[this.selectedIndex].value;"> <option>' . T_('Language') . ':</option> ' . $lang_options . ' </select> </div> <p><label for="user">' . T_('Username') . ':</label><input type="text" name="user" id="user"/></p> <p><label for="pass">' . T_('Password') . ':</label><input type="password" name="pass" id="pass"/></p> <p> <label class="rem" for="rem">' . T_('Remember Me') . '</label> <input class="rem" name="rem" id="rem" type="checkbox" value="1"/> ' . $hidden . ' <input type="submit" name="submit" id="submit" value="' . T_('Login') . '"/> </p> <div class="clear"></div> </form> <p style="text-align:center; margin-bottom:20px;">' . $forgotPassLink . $registerLink . '</p> <div style="color:silver; font-size:11px; float:left;">' . getCurrentVersion() . '</div> <div style="float:right"> ' . $facebookLogin . ' </div> </div> </body> </html>'; }