| 1 | <?php |
|---|
| 2 | // This script displays a login screen in a popupbox when SSL is enabled in the preferences. You should use this script only when your server supports SSL. Place this file under your SSL directory |
|---|
| 3 | |
|---|
| 4 | // path to your xoops main directory |
|---|
| 5 | $path = '/path/to/xoops/directory'; |
|---|
| 6 | |
|---|
| 7 | include $path.'/mainfile.php'; |
|---|
| 8 | if (!defined('XOOPS_ROOT_PATH')) { |
|---|
| 9 | exit(); |
|---|
| 10 | } |
|---|
| 11 | include_once XOOPS_ROOT_PATH.'/language/'.$xoopsConfig['language'].'/user.php'; |
|---|
| 12 | $op = (isset($_POST['op']) && $_POST['op'] == 'dologin') ? 'dologin' : 'login'; |
|---|
| 13 | |
|---|
| 14 | $username = isset($_POST['username']) ? trim($_POST['username']) : ''; |
|---|
| 15 | $password = isset($_POST['userpass']) ? trim($_POST['userpass']) : ''; |
|---|
| 16 | if ($username == '' || $password == '') { |
|---|
| 17 | $op ='login'; |
|---|
| 18 | } |
|---|
| 19 | |
|---|
| 20 | echo ' |
|---|
| 21 | <html> |
|---|
| 22 | <head> |
|---|
| 23 | <meta http-equiv="content-type" content="text/html; charset='._CHARSET.'" /> |
|---|
| 24 | <meta http-equiv="content-language" content="'._LANGCODE.'" /> |
|---|
| 25 | <title>'.htmlspecialchars($xoopsConfig['sitename']).'</title> |
|---|
| 26 | <link rel="stylesheet" type="text/css" media="all" href="'.XOOPS_URL.'/xoops.css" /> |
|---|
| 27 | '; |
|---|
| 28 | $style = getcss($xoopsConfig['theme_set']); |
|---|
| 29 | if ($style == '') { |
|---|
| 30 | $style = xoops_getcss($xoopsConfig['theme_set']); |
|---|
| 31 | } |
|---|
| 32 | if ($style != '') { |
|---|
| 33 | echo '<link rel="stylesheet" type="text/css" media="all" href="'.$style.'" />'; |
|---|
| 34 | } |
|---|
| 35 | echo ' |
|---|
| 36 | </head> |
|---|
| 37 | <body> |
|---|
| 38 | '; |
|---|
| 39 | |
|---|
| 40 | if ($op == 'dologin') { |
|---|
| 41 | $member_handler =& xoops_gethandler('member'); |
|---|
| 42 | $myts =& MyTextsanitizer::getInstance(); |
|---|
| 43 | $user =& $member_handler->loginUser(addslashes($myts->stripSlashesGPC($username)), $myts->stripSlashesGPC($password)); |
|---|
| 44 | if (is_object($user)) { |
|---|
| 45 | if (0 == $user->getVar('level')) { |
|---|
| 46 | redirect_header(XOOPS_URL.'/index.php', 5, _US_NOACTTPADM); |
|---|
| 47 | exit(); |
|---|
| 48 | } |
|---|
| 49 | if ($xoopsConfig['closesite'] == 1) { |
|---|
| 50 | $allowed = false; |
|---|
| 51 | foreach ($user->getGroups() as $group) { |
|---|
| 52 | if (in_array($group, $xoopsConfig['closesite_okgrp']) || XOOPS_GROUP_ADMIN == $group) { |
|---|
| 53 | $allowed = true; |
|---|
| 54 | break; |
|---|
| 55 | } |
|---|
| 56 | } |
|---|
| 57 | if (!$allowed) { |
|---|
| 58 | redirect_header(XOOPS_URL.'/index.php', 1, _NOPERM); |
|---|
| 59 | exit(); |
|---|
| 60 | } |
|---|
| 61 | } |
|---|
| 62 | $user->setVar('last_login', time()); |
|---|
| 63 | if (!$member_handler->insertUser($user)) { |
|---|
| 64 | } |
|---|
| 65 | require_once XOOPS_ROOT_PATH . '/include/session.php'; |
|---|
| 66 | xoops_session_regenerate(); |
|---|
| 67 | $_SESSION = array(); |
|---|
| 68 | $_SESSION['xoopsUserId'] = $user->getVar('uid'); |
|---|
| 69 | $_SESSION['xoopsUserGroups'] = $user->getGroups(); |
|---|
| 70 | if (!empty($xoopsConfig['use_ssl'])) { |
|---|
| 71 | xoops_confirm(array($xoopsConfig['sslpost_name'] => session_id()), XOOPS_URL.'/misc.php?action=showpopups&type=ssllogin', _US_PRESSLOGIN, _LOGIN); |
|---|
| 72 | } else { |
|---|
| 73 | echo sprintf(_US_LOGGINGU, $user->getVar('uname')); |
|---|
| 74 | echo '<div style="text-align:center;"><input value="'._CLOSE.'" type="button" onclick="document.window.opener.location.reload();document.window.close();" /></div>'; |
|---|
| 75 | } |
|---|
| 76 | } else { |
|---|
| 77 | xoops_error(_US_INCORRECTLOGIN.'<br /><a href="login.php">'._BACK.'</a>'); |
|---|
| 78 | } |
|---|
| 79 | } |
|---|
| 80 | |
|---|
| 81 | if ($op == 'login') { |
|---|
| 82 | echo ' |
|---|
| 83 | <div style="text-align: center; padding: 5; margin: 0"> |
|---|
| 84 | <form action="login.php" method="post"> |
|---|
| 85 | <table class="outer" width="95%"> |
|---|
| 86 | <tr> |
|---|
| 87 | <td class="head">'._USERNAME.'</td> |
|---|
| 88 | <td class="even"><input type="text" name="username" value="" /></td> |
|---|
| 89 | </tr> |
|---|
| 90 | <tr> |
|---|
| 91 | <td class="head">'._PASSWORD.'</td> |
|---|
| 92 | <td class="even"><input type="password" name="userpass" value="" /></td> |
|---|
| 93 | </tr> |
|---|
| 94 | <tr> |
|---|
| 95 | <td class="head"> </td> |
|---|
| 96 | <td class="even"><input type="hidden" name="op" value="dologin" /><input type="submit" name="submit" value="'._LOGIN.'" /></td> |
|---|
| 97 | </tr> |
|---|
| 98 | </table> |
|---|
| 99 | </form> |
|---|
| 100 | </div> |
|---|
| 101 | '; |
|---|
| 102 | } |
|---|
| 103 | |
|---|
| 104 | echo ' |
|---|
| 105 | </body> |
|---|
| 106 | </html> |
|---|
| 107 | '; |
|---|
| 108 | ?> |
|---|