Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Passed
Push — master ( 9930ea...2671bd )
by Cristian
15:11 queued 11s
created

LicenseCheck::validCode()   B

Complexity

Conditions 8
Paths 12

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 8
eloc 1
nc 12
nop 1
dl 0
loc 3
rs 8.4444
c 0
b 0
f 0
1
<?php
2
3
namespace Backpack\CRUD;
4
5
trait LicenseCheck
6
{
7
    /**
8
     * Check to to see if a license code exists.
9
     * If it does not, throw a notification bubble.
10
     *
11
     * @return void
12
     */
13
    private function checkLicenseCodeExists()
14
    {
15
        // don't even check if it's a console command or unit tests
16
        if ($this->app->runningInConsole() || $this->app->runningUnitTests()) 
17
        {
18
            return;
19
        }
20
21
        // don't show notice bubble on localhost
22
        if (in_array($_SERVER['REMOTE_ADDR'] ?? [], ['127.0.0.1', '::1'])) {
23
            return;
24
        }
25
26
        // don't show notice bubble if debug is true
27
        if (config('app.debug') == 'true' && config('app.env') == 'local') {
28
            return;
29
        }
30
31
        if (! $this->validCode(config('backpack.base.license_code'))) {
32
            \Alert::add('warning', "<strong>You're using unlicensed software.</strong> Please ask your web developer to <a target='_blank' class='alert-link text-white' href='http://backpackforlaravel.com'>purchase a license code</a> to hide this message.");
0 ignored issues
show
Bug introduced by
The type Alert was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
33
        }
34
    }
35
36
    /**
37
     * Check that the license code is valid for the version of software being run.
38
     * 
39
     * This method is intentionally obfuscated. It's not terribly difficult to crack, but consider how 
40
     * much time it will take you to do so. It might be cheaper to just buy a license code. 
41
     * And in the process, you'd support the people who have created it, and who keep putting in time, 
42
     * every day, to make it better.
43
     * 
44
     * @param  string $j License Code
45
     * @return Boolean
46
     */
47
    private function validCode($j)
48
    {
49
        $k = str_replace('-', '', $j); $s = substr($k, 0, 8); $c = substr($k, 8, 2); $a = substr($k, 10, 2); $l = substr($k, 12, 2); $p = substr($k, 14, 2); $n = substr($k, 16, 2); $m = substr($k, 18, 2); $z = substr($k, 20, 24); $w = 'ADEFHKLMVWXYZ146'; $x = $s; for ($i = 0; $i < strlen($w); $i++) { $r = $w[$i]; $x = str_replace($r, '-', $x); } $x = str_replace('-', '', $x); if ($x != '') { return false; } if (substr_count($j, '-') != 5) { return false; } $e = substr(hexdec(hash('crc32b', substr($k, 0, 20))), -4); if ($z !== $e) { return false; } $o = strrev(substr(preg_replace('/[0-9]+/', '', strtoupper(sha1($a.'sand('.$s.')'.$n.'tos()'))), 2, 2)); if ($m !== $o) { return false; } $o2 = substr(((int)preg_replace('/[^0-9]/','', $s.$c)==0 ? 8310 : (int)preg_replace('/[^0-9]/','', $s.$c) )*9971, -2);if ($a !== $o2) {return false;} return true; 
0 ignored issues
show
Unused Code introduced by
The assignment to $p is dead and can be removed.
Loading history...
Unused Code introduced by
The assignment to $l is dead and can be removed.
Loading history...
50
    }
51
}
52