GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Issues (1361)

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.

src/Calendar/CCalendar.php (11 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
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 7 and the first side effect is on line 4.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
3
4
include 'CWeek.php';
5
include 'CDay.php';
6
7
class CCalendar {
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...
8
    private $weeks = array();
9
    private $month;
10
    private $year;
11
    private $events = array();
12
13
    public function setEvents($values = []){
14
        $this->events = $values;
15
    }
16
17 1
    public function getValues($year = null, $month = null){
0 ignored issues
show
getValues uses the super-global variable $_GET which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
18 1
        if($year && $month){
19
            $this->setYear($year)->setMonth($month);
20
        }
21
        else if(isset($_GET['year']) && isset($_GET['month'])){
22
            $this->setYear($_GET['year'])->setMonth($_GET['month']);
23
        }
24
        else {
25
            $this->setYear(date('Y'))->setMonth(date('m'));
26 1
        }
27 1
    }
28
29
    public function getWeeks()
30
    {
31
        return $this->weeks;
32
    }
33
34 View Code Duplication
    public function prev(){
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...
35
      $year = $this->year;
36
      $month = $this->month;
37
38
        if($month == 1){
39
            $month = 12;
40
          	$year--;
41
        } else {
42
            $month--;
43
        }
44
45
      return ["year" => $year, "month"=>$month];
46
    }
47 View Code Duplication
    public function next(){
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...
48
      $year = $this->year;
49
        $month = $this->month;
50
          if($month == 12){
51
              $month = 1;
52
              $year++;
53
          } else {
54
              $month++;
55
          }
56
        return ["year" => $year, "month"=>$month];
57
    }
58
    public function addWeek($week)
59
    {
60
        $this->weeks[] = $week;
61
    }
62
63 1
    public function setMonth($month)
64
    {
65 1
        $this->month = (int)$month;
66 1
        return $this;
67
    }
68
69
    public function getMonthNumber(){
70
        $dateString = strtotime(sprintf('%s-%s-01', $this->year, $this->month));
71
        return $month = date('m', $dateString);
0 ignored issues
show
$month 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...
72
    }
73
    public function getMonthName(){
74
        $dateString = strtotime(sprintf('%s-%s-01', $this->year, $this->month));
75
        return $month = date('F', $dateString);
0 ignored issues
show
$month 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...
76
    }
77
78 1
    public function setYear($year){
79 1
        $this->year = $year;
80 1
        return $this;
81
    }
82
    public function getMonth(){
83
        return $this->month;
84
    }
85
    public function getYear(){
86
        return $this->year;
87
    }
88
89 1
    public function generateCalenderData(){
90 1
        $daysUsed = 0;
91
        $dateString = strtotime(sprintf('%s-%s-01', $this->year, $this->month));
92
        $monthDays = date('t', $dateString);
93
        $dayOfWeek = date('w', $dateString);
94
        $firstWeek = new CWeek();
95
        $emptyDays = $this->getAmountOfEmptyDays($dayOfWeek);
96
        for($i = 1; $i<=$emptyDays; $i++){
97
            $firstWeek->addWeekday(new CDay());
98
        }
99
100
        for($i = 1; $i<=7-$emptyDays;$i++){
101
            $dateString = strtotime(sprintf('%s-%s-%s', $this->year, $this->month, $i));
102
            $day = new CDay();
103
            $day->setName(date('l', $dateString));
104
            $day->setDayOfMonthNumber($i);
105
            $firstWeek->addWeekday($day);
106
            $daysUsed ++;
107
        }
108
109
        $this->addWeek($firstWeek);
110 1
        $week = null;
111
112
        for($date = $daysUsed+1;$date<=$monthDays;$date++){
113
            $dateString = strtotime(sprintf('%s-%s-%s', $this->year, $this->month, $date));
114
            $dayOfWeek = date('w', $dateString);
115
            if($dayOfWeek == 1){
116
                if($week){
117
                    $this->addWeek($week);
118
                }
119
                $week = new CWeek();
120
            }
121
122
            $day = new CDay();
123
            $day->setName(date('l', $dateString));
124
            $day->setDayOfMonthNumber($date);
125
            $week->addWeekday($day);
126
127
        }
128
        $extraDays = 7-$week->getLengthOfDayArray();
129
130
        for($i = 0;$i<$extraDays;$i++){
131
            $week->addWeekday(new CDay());
132 1
        }
133
        $this->addWeek($week);
134
135 1
    }
136
137
138 1
    private function getAmountOfEmptyDays($firstDayOfMonth){
139 1
        $number = 0;
0 ignored issues
show
$number 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...
140 1
        if($firstDayOfMonth == 0){
141
            $number = 6;
142
        } else {
143 1
            $number = $firstDayOfMonth -1;
144
        }
145 1
        return $number;
146
    }
147
148
    public function printCalendar(){
149
        $prevData = $this->prev();
0 ignored issues
show
$prevData 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...
150
        $nextData = $this->next();
0 ignored issues
show
$nextData 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...
151
        $html = "<div class='headerCalendar'>
152
                    <p class='year'> $this->year</p><p class='month'>" . $this->getMonthName() . "</p>
153
                 </div>
154
                 <div>
155
                 <table class='bordered'>";
156
157
        foreach($this->getWeeks() as $week){
158
            $html .= "<tr>";
159
            foreach($week -> getWeekdays() as $day){
160
                $currentDay = $day->getName();
161
                $todaysDay = date('j');
162
                $currentMonth = date('m');
163
                $html .= "<td>";
164
165
                if($currentDay == "Sunday"){
166
                    $html .= "<div class='redNumber'>" . $day->getDayOfMonthNumber() . "</div>";
167
                    $html .= "<div class='redName'>" . $day->getName() . "</div>";
168
                } else {
169
                    if($day->getDayOfMonthNumber() == $todaysDay && $this->month == $currentMonth) {
170
                        $html .= "<div class='current'><div class='monthNumber'>" . $day->getDayOfMonthNumber() . "</div>";
171
                        $html .= "<div class='monthName'>" . $day->getName() . "</div></div>";
172
                    } else {
173
                        if($this->month == 12 && $day->getDayOfMonthNumber() == 24){
174
                            $html .= "<div class='christmas'><div class='monthNumber'>" . $day->getDayOfMonthNumber() . "</div>";
175
                            $html .= "<div class='monthName'>" . $day->getName() . "</div></div>";
176
                        } else {
177
                            $html .= "<div class='monthNumber'>" . $day->getDayOfMonthNumber() . "</div>";
178
                            $html .= "<div class='monthName'>" . $day->getName() . "</div>";
179
                        }
180
                    }
181
                }
182
                $html .= "</td>";
183
            }
184
            $html .= "</tr>";
185
        }
186
187
        $html .= "</table></div>";
188
        return $html;
189
    }
190
191
    public function printMiniCalendar(){
192
        $img = $this->month;
0 ignored issues
show
$img 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...
193
        $prevData = $this->prev();
194
        $nextData = $this->next();
195
        $html = "
196
                 <div class='leftArrow'> <a href='?month=". $prevData["month"] ."&year=" . $prevData["year"] . "'><img src='./img/orangeArrow.png'></a></div>
197
                 <div class='rightArrow'> <a href='?month=". $nextData["month"] ."&year=" . $nextData["year"] . "'><img src='./img/orangeArrow.png'></a></div>
198
                 <div class='bordered'>
199
                 <table>";
200
201
202
203
204
        foreach($this -> getWeeks() as $week){
205
            $html .= "<tr>";
206
            foreach($week -> getWeekdays() as $day){
207
                $currentDay = $day->getName();
208
                $todaysDay = date('j');
209
                $currentMonth = date('m');
210
                $html .= "<td>";
211
212
                if($currentDay == "Sunday"){
213
                    $html .= "<div class='redNumber'>" . $day->getDayOfMonthNumber() . "</div>";
214
                } else {
215
                    if($day->getDayOfMonthNumber() == $todaysDay && $this->month == $currentMonth) {
216
                        $html .= "<div class='current'><div class='monthNumber'>" . $day->getDayOfMonthNumber() . "</div>";
217
                    } else {
218
                        if($this->month == 12 && $day->getDayOfMonthNumber() == 24){
219
                            $html .= "<div class='christmas'><div class='monthNumber'>" . $day->getDayOfMonthNumber() . "</div>";
220
                        } else {
221
                            $html .= "<div class='monthNumber'>" . $day->getDayOfMonthNumber() . "</div>";
222
                        }
223
                    }
224
                }
225
                $html .= "</td>";
226
            }
227
            $html .= "</tr>";
228
        }
229
230
        $html .= "</table></div>";
231
        return $html;
232
    }
233
234
    public function printResponsiveCalendar($count){
235
        $prevData = $this->prev();
236
        $nextData = $this->next();
237
238
        $html = "
239
                    <div class='page-header'>
240
                        <h1 class='text-center'>" . $this->getMonthName() ." ". $this->year ."</h1>
241
                            <button type=\"button\" class=\"btn btn-primary\" data-toggle=\"modal\" data-target=\".bd-example-modal-sm\">Add Event</button>
242
                            <div class='btn-group '>
243
244
                            <a href='?month=". $prevData["month"] ."&year=" . $prevData["year"] . "' class='btn btn-primary btn-md'>Previus</a>
245
                            <a href='?month=". $nextData["month"] ."&year=" . $nextData["year"] . "' class='btn btn-primary btn-md'>Next</a>
246
                        </div>
247
                    </div>
248
                    <div class='col-md-8'>
249
                    <div class='calendar'>
250
        ";
251
252
        $html .= "<ul class='weekdays'>
253
            <li>Mon</li>
254
            <li>Tue</li>
255
            <li>Wed</li>
256
            <li>Thu</li>
257
            <li>Fri</li>
258
            <li>Sat</li>
259
            <li>Sun</li>
260
        </ul>";
261
262
263
264
        foreach($this->getWeeks() as $week){
265
            $html .= "<ul class='days'>";
266
            foreach($week -> getWeekdays() as $day){
267
                if($day->getDayOfMonthNumber() == null){
268
                    $id = 0;
269
270
                } else {
271
                    if($count[$day->getDayOfMonthNumber()] == null){
272
                        $id = 0;
273
                    }
274
                    else{
275
                    $id = $day->getDayOfMonthNumber();
276
                    }
277
278
                }
279
                if($day->getDayOfMonthNumber() == null){
280
                        $html .= "<li class='day-empty'></li>";
281
                } else {
282
283
                    $html .= "
284
                    <a href='calendar?month=".$this->month."&year=".$this->year."&date=". $day->getDayOfMonthNumber() ."'><li class='days'>";
285
                        if($id == 0){
286
                            $html .= "<span class='label label-danger label-pill pull-xs-left'></span>";
287
                        } else {
288
                            $html .= "<span class='label label-danger label-pill pull-right '>$count[$id]</span>";
289
                        }
290
291
                    $html .="<div class='date'>". $day->getDayOfMonthNumber() ."</div>
292
                    </li>
293
                    </a>
294
                    ";
295
                }
296
            }
297
            $html .= "</ul>";
298
        }
299
300
        $html .= "</div></div>";
301
302
        return $html;
303
    }
304
305
}
306