Passed
Push — master ( b3b7d5...a3dae3 )
by Richard
06:43 queued 11s
created

extras/login.php (1 issue)

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>' . $xoopsConfig['sitename'] . '</title>
26
    <link rel="stylesheet" type="text/css" media="all" href="' . XOOPS_URL . '/xoops.css" />
27
';
28
$style = xoops_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)), addslashes($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)) {
0 ignored issues
show
The method insertUser() does not exist on XoopsObjectHandler. Did you maybe mean insert()? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

63
        if (!$member_handler->/** @scrutinizer ignore-call */ insertUser($user)) {

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
64
        }
65
        $_SESSION                    = array();
66
        $_SESSION['xoopsUserId']     = $user->getVar('uid');
67
        $_SESSION['xoopsUserGroups'] = $user->getGroups();
68
        if (!empty($xoopsConfig['use_ssl'])) {
69
            xoops_confirm(array($xoopsConfig['sslpost_name'] => session_id()), XOOPS_URL . '/misc.php?action=showpopups&amp;type=ssllogin', _US_PRESSLOGIN, _LOGIN);
70
        } else {
71
            echo sprintf(_US_LOGGINGU, $user->getVar('uname'));
72
            echo '<div style="text-align:center;"><input value="' . _CLOSE . '" type="button" onclick="document.window.opener.location.reload();document.window.close();" /></div>';
73
        }
74
    } else {
75
        xoops_error(_US_INCORRECTLOGIN . '<br><a href="login.php">' . _BACK . '</a>');
76
    }
77
}
78
79
if ($op === 'login') {
80
    echo '
81
    <div style="text-align: center; padding: 5px; margin: 0;">
82
    <form action="login.php" method="post">
83
      <table class="outer" width="95%">
84
        <tr>
85
          <td class="head">' . _USERNAME . '</td>
86
          <td class="even"><input type="text" name="username" value="" /></td>
87
        </tr>
88
        <tr>
89
          <td class="head">' . _PASSWORD . '</td>
90
          <td class="even"><input type="password" name="userpass" value="" /></td>
91
        </tr>
92
        <tr>
93
          <td class="head">&nbsp;</td>
94
          <td class="even"><input type="hidden" name="op" value="dologin" /><input type="submit" name="submit" value="' . _LOGIN . '" /></td>
95
        </tr>
96
      </table>
97
    </form>
98
    </div>
99
    ';
100
}
101
102
echo '
103
  </body>
104
</html>
105
';
106