Issues (3)

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/Common/BaseDateTime.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
3
/*
4
 * This file is part of the EasyBanglaDate package.
5
 *
6
 * Copyright (c) 2015 Roni Saha
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace EasyBanglaDate\Common;
13
14
15
abstract class BaseDateTime extends  \DateTime
16
{
17
    protected static $enDigit = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9');
18
19
    protected static $bnDigit = array('০', '১', '২', '৩', '৪', '৫', '৬', '৭', '৮', '৯');
20
21
    protected static $enArray = array(
22
        'l' => array('Saturday', 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'),
23
        'D' => array('Sat', 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri'),
24
        'F' => array('January','February','March','April','May','June','July','August','September','October','November','December'),
25
        'M' => array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec')
26
    );
27
28
    protected static $bnArray = array(
29
        'l' => array('শনিবার', 'রবিবার', 'সোমবার', 'মঙ্গলবার', 'বুধবার', 'বৃহঃস্পতিবার', 'শুক্রবার'),
30
        'D' => array('শনি', 'রবি', 'সোম', 'মঙ্গল', 'বুধ', 'বৃহ', 'শুক্র'),
31
        'F' => array('জানুয়ারী','ফেব্রুয়ারি','মার্চ','এপ্রিল','মে','জুন','জুলাই','আগস্ট','সেপ্টেম্বর','অক্টোবর','নভেম্বর','ডিসেম্বর'),
32
        'M' => array('জানু','ফেব্রু','মার্চ','এপ্রিল','মে','জুন','জুলাই','আগস্ট','সেপ্টে','অক্টো','নভে','ডিসে')
33
    );
34
35
    protected static $enAmPm = array('am', 'pm');
36
37
    protected static $bnAmPM = array('পূর্বাহ্ন', 'অপরাহ্ন');
38
    protected static $bnSuffix = array('', 'লা', 'রা', 'রা', 'ঠা', 'ই', 'শে');
39
    protected static $bnPrefix = array('ভোর', 'সকাল', 'দুপুর', 'বিকাল', 'সন্ধ্যা', 'রাত');
40
    protected static $enTimeSlot = array('Dawn', 'Morning', 'Noon', 'Afternoon', 'Evening', 'Night');
41
42
    public function __construct($time = 'now', \DateTimeZone $timezone = null)
43
    {
44
        parent::__construct($time, $timezone);
45
    }
46
47
    protected function translateNumbers($number)
48
    {
49
        return str_replace(BaseDateTime::$enDigit, BaseDateTime::$bnDigit, $number);
50
    }
51
52
    protected function replaceSuffix($format)
53
    {
54
        return str_replace('S', $this->getBnSuffix($this->_format('j')), $format);
55
    }
56
57
    protected function _format($format) {
58
        return parent::format($format);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (format() instead of _format()). Are you sure this is correct? If so, you might want to change this to $this->format().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
59
    }
60
61
    protected function getBnSuffix($date)
62
    {
63
        $index = (int)$date;
64
65
        if ($index < 19 && $index > 4) {
66
            $index = 5;
67
        } elseif($index > 18) {
68
            $index = 6;
69
        }
70
71
        return BaseDateTime::$bnSuffix[$index];
72
    }
73
74
    protected function replaceTimes($format)
75
    {
76
        $numbersItems = array('G', 'g', 'H', 'h', 'i', 's');
77
        $out = $format;
78
79
        foreach ($numbersItems as $item) {
80
            $out = str_replace($item, $this->_format($item), $out);
81
        }
82
83
        return $out;
84
    }
85
86
    protected function getAmPm()
87
    {
88
        return str_replace(BaseDateTime::$enAmPm, BaseDateTime::$bnAmPM, $this->_format('a'));
89
    }
90
91
    /**
92
     * @param $format
93
     * @param $items
94
     * @return mixed
95
     */
96
    protected function getInBengali($format, $items)
97
    {
98
        foreach ($items as $item) {
99
            $format = str_replace(
100
                $item,
101
                str_replace(BaseDateTime::$enArray[$item], BaseDateTime::$bnArray[$item], $this->_format($item)),
102
                $format
103
            );
104
        }
105
106
        return $format;
107
    }
108
109
    protected function replaceMeridian($str)
110
    {
111
112
        $mValue = $this->getAmPm();
113
114
        $str = str_replace('a', $mValue, $str);
115
        $str = str_replace('A', $mValue, $str);
116
117
        return $str;
118
    }
119
120
    protected function replaceDays($format)
121
    {
122
        return $this->getInBengali($format, array('D', 'l'));
123
    }
124
125
    protected function replaceTimePrefix($str)
126
    {
127
        return str_replace('b', $this->getTimePrefix(), $str);
128
    }
129
130
    protected function getTimePrefix()
131
    {
132
        return BaseDateTime::$bnPrefix[$this->getPrefixIndex()];
133
    }
134
135
    protected function getPrefixIndex()
136
    {
137
        $hour = (int)$this->_format('G');
138
        $items = count(self::$enTimeSlot) - 1;
139
140
        for ($i = 0; $i < $items; $i++) {
141
            if ($this->isInTimeSlot(self::$enTimeSlot[$i], $hour)) {
142
                return $i;
143
            }
144
        }
145
146
        return $i;
147
    }
148
149
150
    /**
151
     * @param $hour
152
     * @return bool
153
     */
154
    protected function isDawn($hour)
155
    {
156
        return $hour < 6 && $hour > 3;
157
    }
158
159
    /**
160
     * @param $hour
161
     * @return bool
162
     */
163
    protected function isMorning($hour)
164
    {
165
        return $hour < 12 && $hour > 5;
166
    }
167
168
    /**
169
     * @param $hour
170
     * @return bool
171
     */
172
    protected function isNoon($hour)
173
    {
174
        return $hour < 15 && $hour > 11;
175
    }
176
177
    /**
178
     * @param $hour
179
     * @return bool
180
     */
181
    protected function isAfternoon($hour)
182
    {
183
        return $hour < 18 && $hour > 14;
184
    }
185
186
    /**
187
     * @param $hour
188
     * @return bool
189
     */
190
    protected function isEvening($hour)
191
    {
192
        return $hour < 20 && $hour > 17;
193
    }
194
195
    /**
196
     * @param $slot
197
     * @param $hour
198
     * @return mixed
199
     */
200
    protected function isInTimeSlot($slot, $hour)
201
    {
202
        return call_user_func(array($this, "is{$slot}"), $hour);
203
    }
204
}