Issues (44)

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.

Content.php (7 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
namespace humanity;
3
4
class Content {
5
6
    private static $host;
0 ignored issues
show
The property $host is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
7
    private static $path;
0 ignored issues
show
The property $path is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
8
    private static $config; 
9
    private static $js;
10
    private static $css;
11
    private static $app;
12
    private static $view;
13
    private static $widget;
14
    private static $title;
15
    private static $description;
16
    private static $keywords;
17
    private static $uri;
18
19 View Code Duplication
    public function __construct(){
0 ignored issues
show
This method seems to be duplicated in 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...
20
        # Config
21
        self::$config = (new Config)->get();
22
        # Application
23
        self::$app = new Application;
24
        # View
25
        self::$view = new View;
26
        # Widget
27
        self::$widget = new Widget;
28
        # Js
29
        self::$js = new Js;
30
        # Css
31
        self::$css = new Css;
32
        # Title
33
        self::$title = new Title;
34
        # Desctiption
35
        self::$description = new Description;
36
        # Keywords
37
        self::$keywords = new Keywords;
38
        # Uri
39
        self::$uri = new Uri;
40
    }
41
42
    public function view($name){
43
        $file = $this->file($name);
44
        if(is_file($file)) require $file;
45
    }
46
47
    public function page(){
48
        # get file
49
        $file = $this->file();
50
        # get content
51
        ob_start();
52
        require $file;
53
        $content = ob_get_clean();
54
        # get css
55
        $css = self::$css->get();
56
        # get css
57
        $js = self::$js->get();
58
        # get title
59
        $title = self::$title->get();
60
        # get description
61
        $description = self::$description->get();
62
        # get keywords
63
        $keywords = self::$keywords->get();
64
        # include for page
65
        $content = preg_replace('/<head>/',"<head>$keywords",$content);
66
        $content = preg_replace('/<head>/',"<head>$description",$content);
67
        $content = preg_replace('/<head>/',"<head>$title",$content);
68
        $content = preg_replace('/<\/head>/',"$css</head>",$content);
69
        $content = preg_replace('/<\/body>/',"$js</body>",$content);
70
        $minify = new MinifyHTML($content);
71
        $content = $minify->compress();
72
        echo $content;
73
    }
74
75
    public function js($query){
76
        echo self::$js->compile($query);
77
    }
78
79
    # $type - page,view
80
    public function file($name=false){
81
        if($name === false){
82
            $path = self::$config['core']['page'];
83
        } else {
84
            $path = self::$config['core']['view'].'/'.$name;
85
        }
86
        # Route
87
        $uri = self::$uri->arr();
88
        array_push($uri,'');
89
        foreach($uri as $key=>$value){ if(empty(trim($value))) { unset($uri[$key]); continue; } }
90
        $uri = array_values($uri);
91
        $isFile = null;
0 ignored issues
show
$isFile is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
92
        $currentUri = null;
0 ignored issues
show
$currentUri is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
93
        $filePhtml = null;
94
        for($i=count($uri)-1; $i>=0; $i--){
95
          $nextUri = implode('/',array_slice($uri,0,$i+1));
96
          $getFile = function($type) use($path,$nextUri){
97
            $file = $path.'/'.$nextUri.'/index.'.$type;
98
            if(is_file($file)) return $file;
99
            return null;
100
          };
101
          $filePhtml = $getFile('phtml');
102
          if($filePhtml) { $currentUri = $nextUri; break; }
0 ignored issues
show
$currentUri is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
103
        }
104
        if($filePhtml === null) {
105
          $filePhtml = $path.'/index.phtml';
106
        }
107
        return $filePhtml;
108
    }
109
110
}
111
?>
0 ignored issues
show
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...
112