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/ArabicCalendar.php (1 issue)

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 ArabicCalendar - calculations for the Arabic (Hijri) 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 ArabicCalendar 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 ($month === 2) {
37
            return 28;
38
        } elseif ($month % 2 === 1 || $month === 12 && $this->isLeapYear($year)) {
39
            return 30;
40
        } else {
41
            return 29;
42
        }
43
    }
44
45
    /**
46
     * Determine the number of days in a week.
47
     *
48
     * @return int
49
     */
50
    public function daysInWeek()
51
    {
52
        return 7;
53
    }
54
55
    /**
56
     * The escape sequence used to indicate this calendar in GEDCOM files.
57
     *
58
     * @return string
59
     */
60
    public function gedcomCalendarEscape()
61
    {
62
        return '@#DHIJRI@';
63
    }
64
65
    /**
66
     * Determine whether or not a given year is a leap-year.
67
     *
68
     * @param int $year
69
     *
70
     * @return bool
71
     */
72
    public function isLeapYear($year)
73
    {
74
        return ((11 * $year + 14) % 30) < 11;
75
    }
76
77
    /**
78
     * What is the highest Julian day number that can be converted into this calendar.
79
     *
80
     * @return int
81
     */
82
    public function jdEnd()
83
    {
84
        return PHP_INT_MAX;
85
    }
86
87
    /**
88
     * What is the lowest Julian day number that can be converted into this calendar.
89
     *
90
     * @return int
91
     */
92
    public function jdStart()
93
    {
94
        return 1948440; // 1 Muharram 1 AH, 16 July 622 AD
95
    }
96
97
    /**
98
     * Convert a Julian day number into a year/month/day.
99
     *
100
     * @param int $julian_day
101
     *
102
     * @return int[]
103
     */
104
    public function jdToYmd($julian_day)
105
    {
106
        $year  = (int) ((30 * ($julian_day - 1948440) + 10646) / 10631);
107
        $month = (int) ((11 * ($julian_day - $year * 354 - (int) ((3 + 11 * $year) / 30) - 1948086) + 330) / 325);
108
        $day   = $julian_day - 29 * ($month - 1) - (int) ((6 * $month - 1) / 11) - $year * 354 - (int) ((3 + 11 * $year) / 30) - 1948085;
109
110
        return array($year, $month, $day);
111
    }
112
113
    /**
114
     * Determine the number of months in a year (if given),
115
     * or the maximum number of months in any year.
116
     *
117
     * @param int|null $year
118
     *
119
     * @return int
120
     */
121
    public function monthsInYear($year = null)
122
    {
123
        return 12;
124
    }
125
126
    /**
127
     * Convert a year/month/day to a Julian day number.
128
     *
129
     * @param int $year
130
     * @param int $month
131
     * @param int $day
132
     *
133
     * @return int
134
     */
135
    public function ymdToJd($year, $month, $day)
136
    {
137 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...
138
            throw new InvalidArgumentException('Month ' . $month . ' is invalid for this calendar');
139
        }
140
141
        return $day + 29 * ($month - 1) + (int) ((6 * $month - 1) / 11) + $year * 354 + (int) ((3 + 11 * $year) / 30) + 1948085;
142
    }
143
}
144