Issues (501)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

classes/steamlogin.php (14 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
$user = new user;
3
4
class user
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
This class is not in CamelCase format.

Classes in PHP are usually named in CamelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. The whole name starts with a capital letter as well.

Thus the name database provider becomes DatabaseProvider.

Loading history...
5
{
6
    public function GetPlayerSummaries($steamid)
7
    {
8
        $settings = require('config/settings.php');
9
        $response = file_get_contents('http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=' . $settings['steamAPI'] . '&steamids=' . $steamid);
10
        $json = json_decode($response);
11
        return $json->response->players[0];
12
    }
13
14
    public function signIn()
15
    {
16
        $settings = require('config/settings.php');
17
        if ($settings['steamlogin']) {
18
            require_once 'openid.php';
19
            $openid = new LightOpenID($settings['url']);
20
            if (!$openid->mode) {
0 ignored issues
show
The property mode does not exist on object<LightOpenID>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
21
                $openid->identity = 'http://steamcommunity.com/openid';
0 ignored issues
show
The property $identity is declared private in LightOpenID. Since you implemented __set(), maybe consider adding a @property or @property-write annotation. This makes it easier for IDEs to provide auto-completion.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
22
                header('Location: ' . $openid->authUrl());
23
            } elseif ($openid->mode == 'cancel') {
0 ignored issues
show
The property mode does not exist on object<LightOpenID>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
24
                print ('User has canceled authentication!');
25
            } else {
26
                if ($openid->validate()) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $openid->validate() of type false|integer is loosely compared to true; this is ambiguous if the integer can be zero. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For integer values, zero is a special case, in particular the following results might be unexpected:

0   == false // true
0   == null  // true
123 == false // false
123 == null  // false

// It is often better to use strict comparison
0 === false // false
0 === null  // false
Loading history...
27
                    preg_match("/^http:\/\/steamcommunity\.com\/openid\/id\/(7[0-9]{15,25}+)$/", $openid->identity, $matches);
0 ignored issues
show
The property $identity is declared private in LightOpenID. Since you implemented __get(), maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
28
                    $_SESSION['playerid'] = $matches[1];
29
30
                    $db_connection = masterConnect();
31
32
                    $sql = "SELECT user_name, user_email, user_level, user_profile, permissions, user_password_hash, user_id
33
                            FROM users WHERE playerid = '" . $_SESSION['playerid'] . "';";
34
                    $result_of_login_check = $db_connection->query($sql);
0 ignored issues
show
Comprehensibility Naming introduced by
The variable name $result_of_login_check exceeds the maximum configured length of 20.

Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.

Loading history...
35
36
                    if ($result_of_login_check->num_rows == 1) {
37
                        $result_row = $result_of_login_check->fetch_object();
38
                        if ($result_row->user_level <> 0) {
39
                            $_SESSION['user_name'] = $result_row->user_name;
40
                            $_SESSION['user_level'] = $result_row->user_level;
41
                            $_SESSION['user_profile'] = $result_row->user_profile;
42
                            $_SESSION['user_email'] = $result_row->user_email;
43
                            $_SESSION['user_id'] = $result_row->user_id;
44
                            $_SESSION['permissions'] = json_decode($result_row->permissions, true);
45 View Code Duplication
                            if (isset($result_row->items)) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
46
                                $_SESSION['items'] = $result_row->items;
47
                            } else {
48
                                $_SESSION['items'] = $settings['items'];
49
                            }
50
                            if (isset($_POST['lang'])) {
51
                                $_SESSION['lang'] = $_POST['lang'];
52
                            }
53
                            $_SESSION['user_login_status'] = 1;
54
                            $_SESSION['steamsignon'] = false; //used to determine if its a single sign on with no account
55
                            multiDB();
56
57
                            logAction($_SESSION['user_name'], 'Successful Steam Login (' . $_SERVER['REMOTE_ADDR'] . ')', 2);
58 View Code Duplication
                        } else {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
59
                            $this->errors[] = "User is banned.";
0 ignored issues
show
The property errors does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
60
                            logAction($_POST['user_name'], 'Steam Login Failed - Banned User (' . $_SERVER['REMOTE_ADDR'] . ')', 3);
61
                        }
62
                    } else {
63
                        if ($settings['annonlogin']) {
64
                            $permissions = require('config/permissions.php');
65
                            $steam = $this->GetPlayerSummaries($_SESSION['playerid']);
66
                            $_SESSION['user_name'] = $steam->personaname;
67
                            $_SESSION['user_level'] = 1;
68
                            $_SESSION['user_profile'] = $steam->avatarmedium;
69
                            $_SESSION['permissions'] = $permissions[1];
70
                            $_SESSION['items'] = $settings['items'];
71
                            $_SESSION['user_login_status'] = 1;
72
                            $_SESSION['profile_link'] = $steam->profileurl;
73
                            $_SESSION['steamsignon'] = true; //used to determine if its a single sign on with no account
74
                            multiDB();
75
76
                            logAction($_SESSION['user_name'], 'Successful Steam Login (' . $_SERVER['REMOTE_ADDR'] . ')', 2);
77
                        } else {
78
                            errorMessage(7);
0 ignored issues
show
The call to errorMessage() misses a required argument $lang.

This check looks for function calls that miss required arguments.

Loading history...
The call to the function errorMessage() seems unnecessary as the function has no side-effects.
Loading history...
79
                        }
80
                    }
81
                    header('Location: ' . $settings['url']);
82
                    exit;
0 ignored issues
show
Coding Style Compatibility introduced by
The method signIn() contains an exit expression.

An exit expression should only be used in rare cases. For example, if you write a short command line script.

In most cases however, using an exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
83
                } else {
84
                    print ('Error');
85
                }
86
            }
87
        }
88
    }
89
}
90
91
if (isset($_GET['login'])) {
92
    $user->signIn();
93
}
94
if ($settings['steamlogin']) {
95
    print ('<form action="?login" method="post"><input type="image"
96
    src="http://cdn.steamcommunity.com/public/images/signinthroughsteam/sits_large_noborder.png"/>
97
    </form>');
98
}