Issues (64)

Security Analysis    no request data  

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.

src/SimpleDiff.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
3
namespace OpenCafe\Tools;
4
5
use OpenCafe\Tools\Lang;
6
use OpenCafe\Datium;
7
8
/**
9
* Calculate Time ago with current date difference
10
*
11
* @package OpenCafe\Datium
12
* @since Jun 17, 2016
13
*/
14
class SimpleDiff
15
{
16
17
    /**
18
     * Used language to setted for simple difference
19
     * @var string
20
     */
21
    private $language;
22
23
    /**
24
     * class final result
25
     * @var object
26
     */
27
    private $result;
28
29
    /**
30
     * @var array
31
     */
32
    private $blockList;
33
34
    /**
35
    * SimpleDiff Class constructure
36
    *
37
    * @param DateTime $time_difference The time to calculate with now
0 ignored issues
show
There is no parameter named $time_difference. Did you maybe mean $difference?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.

Consider the following example. The parameter $ireland is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $ireland
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was changed, but the annotation was not.

Loading history...
38
    * @param string $lang Language
0 ignored issues
show
There is no parameter named $lang. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
39
    */
40
    public function __construct($start, $end, $difference )
0 ignored issues
show
The parameter $start is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
The parameter $end is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
41
    {
42
43
      $this->language = 'en';
44
45
      $this->result =  $difference;
46
47
      $this->blockList = [
48
        'just-now'
49
      ];
50
51
    }
52
53
    /**
54
    * Return difference period as an object
55
    *
56
    * @return object
57
    */
58
    public function all()
59
    {
60
61
      return $result->result;
0 ignored issues
show
The variable $result does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
62
63
    }
64
65
    /**
66
    * Read ago config file
67
    *
68
    * @param integer $date date index in ago config file
0 ignored issues
show
There is no parameter named $date. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
69
    * @param string $type duration type on ago config file
70
    */
71
    public function read( $value, $type )
72
    {
73
74
      $config = include __DIR__ . '/config/diff.php';
75
76
      if( $this->result->invert ) {
77
78
        $time = ' ' . Lang::get( $this->language, 'remaining' );
79
80
      } else {
81
82
        $time = ' ' . Lang::get( $this->language, 'ago' );
83
84
      }
85
86
      if( isset( $config[ $type ][ $value ] ) && in_array(
87
88
                $config[ $type ][ $value ],
89
90
                $this->blockList
91
92
                ) ) {
93
94
                $time = null;
95
96
                }
97
98
      if( array_key_exists( $value, $config[ $type ] ) ) {
99
100
        $str = Lang::get( $this->language, $config[ $type ][ $value ] )
101
               . $time;
102
103
        return $str;
104
105
      } else {
106
107
        return Lang::getNumbers( $this->language, $value ) . " " . Lang::get(
108
                                          $this->language,
109
                                          $config[ $type ][ '*' ]
110
                                        ) . $time;
111
112
      }
113
114
    }
115
116
    /**
117
    * Show priority of duration
118
    *
119
    * @param integer $date date index in ago config file
120
    * @param string $type duration type on ago config file
121
    */
122
    public function priority( $date, $type )
123
    {
124
125
      if( $date != 0 ) {
126
127
        return $this->read( $date, $type );
128
129
      } else {
130
131
        return false;
132
133
      }
134
135
    }
136
137
    public function lang( $value )
138
    {
139
140
      $this->language = $value;
141
142
      return $this;
143
144
    }
145
146
    /**
147
    * Return fainal SimpleDiff result
148
    *
149
    * @return string
150
    */
151
    public function get()
152
    {
153
154
      $duration = [
155
        'year'   =>  $this->result->year,
156
        'month'  =>  $this->result->month,
157
        'day'    =>  $this->result->day,
158
        'hour'   =>  $this->result->hour,
159
        'minute' =>  $this->result->minute,
160
        'second' =>  $this->result->second
161
      ];
162
163
      foreach( $duration as $index => $value ) {
164
165
        if( $this->priority( $value, $index ) != false ) {
0 ignored issues
show
It seems like you are loosely comparing $this->priority($value, $index) of type string|false against false; this is ambiguous if the string can be empty. Consider using a strict comparison !== instead.
Loading history...
166
167
          return $this->priority( $value, $index );
168
169
        }
170
171
      }
172
173
    }
174
}
175