Issues (36)

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/FrenchCalendar.php (2 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 Fisharebest\ExtCalendar;
3
4
use InvalidArgumentException;
5
6
/**
7
 * Class FrenchCalendar - calculations for the French Republican calendar.
8
 *
9
 * @author    Greg Roach <[email protected]>
10
 * @copyright (c) 2014-2020 Greg Roach
11
 * @license   This program is free software: you can redistribute it and/or modify
12
 *            it under the terms of the GNU General Public License as published by
13
 *            the Free Software Foundation, either version 3 of the License, or
14
 *            (at your option) any later version.
15
 *
16
 *            This program is distributed in the hope that it will be useful,
17
 *            but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 *            MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 *            GNU General Public License for more details.
20
 *
21
 *            You should have received a copy of the GNU General Public License
22
 *            along with this program.  If not, see <http://www.gnu.org/licenses/>.
23
 */
24
class FrenchCalendar implements CalendarInterface
25
{
26
    /**
27
     * Determine the number of days in a specified month, allowing for leap years, etc.
28
     *
29
     * @param int $year
30
     * @param int $month
31
     *
32
     * @return int
33
     */
34
    public function daysInMonth($year, $month)
35
    {
36
        if ($year <= 0) {
37
            throw new InvalidArgumentException('Year ' . $year . ' is invalid for this calendar');
38 View Code Duplication
        } elseif ($month < 1 || $month > 13) {
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...
39
            throw new InvalidArgumentException('Month ' . $month . ' is invalid for this calendar');
40
        } elseif ($month !== 13) {
41
            return 30;
42
        } elseif ($this->isLeapYear($year)) {
43
            return 6;
44
        } else {
45
            return 5;
46
        }
47
    }
48
49
    /**
50
     * Determine the number of days in a week.
51
     *
52
     * @return int
53
     */
54
    public function daysInWeek()
55
    {
56
        return 10;
57
    }
58
59
    /**
60
     * The escape sequence used to indicate this calendar in GEDCOM files.
61
     *
62
     * @return string
63
     */
64
    public function gedcomCalendarEscape()
65
    {
66
        return '@#DFRENCH R@';
67
    }
68
69
    /**
70
     * Determine whether or not a given year is a leap-year.
71
     *
72
     * Leap years were based on astronomical observations.  Only years 3, 7 and 11
73
     * were ever observed.  Moves to a gregorian-like (fixed) system were proposed
74
     * but never implemented.
75
     *
76
     * @param int $year
77
     *
78
     * @return bool
79
     */
80
    public function isLeapYear($year)
81
    {
82
        return $year % 4 == 3;
83
    }
84
85
    /**
86
     * What is the highest Julian day number that can be converted into this calendar.
87
     *
88
     * @return int
89
     */
90
    public function jdEnd()
91
    {
92
        return 2380687; // 31 DEC 1805 = 10 NIVO 0014
93
    }
94
95
    /**
96
     * What is the lowest Julian day number that can be converted into this calendar.
97
     *
98
     * @return int
99
     */
100
    public function jdStart()
101
    {
102
        return 2375840; // 22 SEP 1792 = 01 VEND 0001
103
    }
104
105
    /**
106
     * Convert a Julian day number into a year/month/day.
107
     *
108
     * @param int $julian_day
109
     *
110
     * @return int[]
111
     */
112
    public function jdToYmd($julian_day)
113
    {
114
        $year  = (int) (($julian_day - 2375109) * 4 / 1461) - 1;
115
        $month = (int) (($julian_day - 2375475 - $year * 365 - (int) ($year / 4)) / 30) + 1;
116
        $day   = $julian_day - 2375444 - $month * 30 - $year * 365 - (int) ($year / 4);
117
118
        return array($year, $month, $day);
119
    }
120
121
    /**
122
     * Determine the number of months in a year (if given),
123
     * or the maximum number of months in any year.
124
     *
125
     * @param int|null $year
126
     *
127
     * @return int
128
     */
129
    public function monthsInYear($year = null)
130
    {
131
        return 13;
132
    }
133
134
    /**
135
     * Convert a year/month/day to a Julian day number.
136
     *
137
     * @param int $year
138
     * @param int $month
139
     * @param int $day
140
     *
141
     * @return int
142
     */
143
    public function ymdToJd($year, $month, $day)
144
    {
145 View Code Duplication
        if ($month < 1 || $month > $this->monthsInYear()) {
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...
146
            throw new InvalidArgumentException('Month ' . $month . ' is invalid for this calendar');
147
        }
148
149
        return 2375444 + $day + $month * 30 + $year * 365 + (int) ($year / 4);
150
    }
151
}
152