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/CalendarSettings/Jalali.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
use OpenCafe\Datium as Datium;
4
use OpenCafe\Tools\Leap as Leap;
5
6
return array (
7
8
  'timezone' => 'Asia/Tehran',
9
10
  'language' =>  'fa',
11
12
  'events' => array(),
13
14
  'numbers' => array( '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'),
15
16
  'am_time' => 'AM',
17
18
  'pm_time' => 'PM',
19
20
  'end_of_days' => array( 'th', 'st', 'nd', 'rd' ),
21
22
23
24
/************************************************************
25
 *                        Convert to
26
 ************************************************************
27
 *
28
 * Convert algorith to convert Gregorian to Jalali calerndar
29
 *
30
 *\_________________________________________________________/
31
 */
32
  'convert_to' => function ($date_time) {
33
34
        $config = include 'Gregorian.php';
35
36
        $year = $date_time->format('Y');
37
38
        $month = $date_time->format('m');
39
40
        $day = $date_time->format('d');
41
42
        $temp_day = 0;
43
44 View Code Duplication
    for ($i = 1; $i < $month; $i++) {
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...
45
        $temp_day += $config[ 'month_days_number' ][ $i ];
46
    }
47
48
         $temp_day += $day;
49
50
         $leap = new Leap($year);
51
52
    if ($leap->get() && $month > 2) {
53
        $temp_day++;
54
    }
55
56
    if ($temp_day <= 79) {
57
        if (( $year - 1 ) % 4 == 0) {
58
            $temp_day = $temp_day + 11;
59
        } else {
60
            $temp_day = $temp_day + 10;
61
        }
62
63
        $year = $year - 622;
64
65 View Code Duplication
        if ($temp_day % 30 == 0) {
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...
66
            $month = ( $temp_day / 30 ) + 9;
67
68
            $day = 30;
69
        } else {
70
            $month = ( $temp_day / 30 ) + 10;
71
72
            $day = $temp_day % 30;
73
        }
74
    } else {
75
        $year = $year - 621;
76
77
        $temp_day = $temp_day - 79;
78
79
        if ($temp_day <= 186) {
80 View Code Duplication
            if ($temp_day % 31 == 0) {
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...
81
                $month = ( $temp_day / 31 );
82
83
                $day = 31;
84
            } else {
85
                $month = ( $temp_day / 31 ) + 1;
86
87
                $day = ( $temp_day % 31 );
88
            }
89 View Code Duplication
        } else {
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...
90
            $temp_day = $temp_day - 186;
91
92
            if ($temp_day % 30 == 0) {
93
                $month = ( $temp_day / 30 ) + 6;
94
95
                $day = 30;
96
            } else {
97
                $month = ( $temp_day / 30 ) + 7;
98
99
                $day = $temp_day % 30;
100
            }
101
        }
102
    }
103
104
         $date_time->setDate($year, $month, $day);
105
106
         return $date_time;
107
108
  },
109
110
  /************************************************************
111
   *                        Convert From
112
   ************************************************************
113
   *
114
   * Convert algorith to convert Jalali to Gregorian calerndar
115
   *
116
   *\_________________________________________________________/
117
   */
118
  'convert_from' => function ($date_time) {
119
120
    $config = include 'Jalali.php';
121
122
    $year = $date_time->format('Y');
123
124
    $month = $date_time->format('m');
125
126
    $day = $date_time->format('d');
127
128
    $days_of_year = 0;
129
130
    foreach ($config[ 'month_days_number' ] as $mon => $value) {
131
        if ($month > $mon) {
132
            $days_of_year += $value;
133
        }
134
    }
135
136
    $days_of_year += $day;
137
138
    $days_of_leap_years =  intval(( ( $year - 1 ) / 4 ));
139
140
    $days_of_shamsi_years = ( ( ( $year - 1 ) * 365 ) + $days_of_year + $days_of_leap_years );
141
142
    $days_of_gregorain_years = $days_of_shamsi_years + 226899;
143
144
    if ($month < 10) {
145
        $days_of_gregorain_years = $days_of_gregorain_years - intval(( ( $year + 621 ) / 4 ));
146
    } elseif (( ( 10 == $month ) && ( $day > 10 ) ) || ( $month > 10 )) {
147
        $days_of_gregorain_years = $days_of_gregorain_years - intval(( ( $year + 622 ) / 4 ));
148
    }
149
150
    $gregorian_month = ( $days_of_gregorain_years % 365 );
151
152
    $gregorian_year = intval($days_of_gregorain_years / 365) + 1;
153
154
    $config = include 'Gregorian.php';
155
156
    foreach ($config[ 'month_days_number' ] as $month => $value) {
157
        if ($gregorian_month < $value) {
158
            break;
159
        }
160
161
        $gregorian_month -= $value;
162
    }
163
164
    $gregorian_day = $gregorian_month;
165
166
    $gregorian_month = $month;
167
168
    if ( ( ( $gregorian_year % 4 ) == 0 ) && ( ( ( $gregorian_year % 100 ) != 0 ) || ( ( $gregorian_year % 400 ) == 0 ) ) ) {
169
170
        if ( $gregorian_month < 3 || ( $gregorian_month == 3 && $gregorian_day < 22 ) ) {
171
172
          $gregorian_day++;
173
174
        }
175
176
    }
177
178
    if (! $gregorian_day || $config['leap_year']($gregorian_year - 1) ) {
179
        $gregorian_day++;
180
    }
181
182
    $date_time->setDate($gregorian_year, $gregorian_month, $gregorian_day);
183
184
    return $date_time;
185
186
  },
187
188
  /************************************************************
189
   *               Shorthand for jalali calendar
190
   ************************************************************
191
   *
192
   * Jalali calendar shorthand
193
   *
194
   *\_________________________________________________________/
195
   */
196
  'shorthand' => 'ja',
197
198
  /************************************************************
199
   *                        Month's name
200
   ************************************************************
201
   *
202
   * Jalali month name
203
   *
204
   *\_________________________________________________________/
205
   */
206
  'month' => array (
207
208
    'Farvardin',
209
210
    'Ordibehesht',
211
212
    'Khordad',
213
214
    'Tir',
215
216
    'Mordad',
217
218
    'Shahrivar',
219
220
    'Mehr',
221
222
    'Aban',
223
224
    'Azar',
225
226
    'Dey',
227
228
    'Bahman',
229
230
    'Esfand'
231
232
    ),
233
234
  /************************************************************
235
   *                        Days of Week
236
   ************************************************************
237
   *
238
   * Here is week days on jalali calendar, offset 0 is first
239
   * day of week and offset 6 is the last one.
240
   *
241
   *\_________________________________________________________/
242
   */
243
244
245
  'days_of_week' => array (
246
247
     'Yekshanbe',
248
     'Doshanbe',
249
     'Seshanbe',
250
     'Chaharshanbe',
251
     'Panjshanbe',
252
     'Jome',
253
     'Shanbe',
254
255
  ),
256
257
  'start_day_of_week' => 'Shanbe',
258
259
  'month_days_number' => array(      1 => 31,
260
                                     2 => 31,
261
                                     3 => 31,
262
                                     4 => 31,
263
                                     5 => 31,
264
                                     6 => 31,
265
                                     7 => 30,
266
                                     8 => 30,
267
                                     9 => 30,
268
                                     10 => 30,
269
                                     11 => 30,
270
                                     12 => 29 ),
271
272
  /************************************************************
273
  *                      Day of year
274
  ************************************************************
275
  *
276
  *  Return days of year on ghamari cleander
277
  *
278
  *\_________________________________________________________/
279
  */
280 View Code Duplication
  'day_of_year' => function ($date_time) {
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...
281
282
    $result = null;
283
284
    $config = include 'Jalali.php';
285
286
    $month = $date_time->format('n');
287
288
    $day = $date_time->format('d');
289
290
    foreach ($config[ 'month_days_number' ] as $_month => $value) {
291
        if ($_month < $month) {
292
            $result += $value;
293
        }
294
    }
295
296
    $result += $day;
297
298
    return $result;
299
300
  },
301
302
  /************************************************************
303
   *                       Day of Week
304
   ************************************************************
305
   *
306
   *  Return day of week on shamsi cleander
307
   *  example : Yekshanbe = result is 2
308
   *\_________________________________________________________/
309
  */
310 View Code Duplication
  'day_of_week' => function ($date_timem, $day_of_week) {
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...
311
312
      $days_of_week = array(
313
          'Doshanbe',
314
          'Seshanbe',
315
          'Chaharshanbe',
316
          'Panjshanbe',
317
          'Jome',
318
          'Shanbe',
319
          'Yekshanbe',
320
      );
321
322
        $days = array(
323
          1 => 'Shanbe',
324
          2 => 'Yekshanbe',
325
          3 => 'Doshanbe',
326
          4 => 'Seshanbe',
327
          5 => 'Chaharshanbe',
328
          6 => 'Panjshanbe',
329
          7 => 'Jome' );
330
331
        $configGregorian = include 'Gregorian.php';
332
333
        $day = str_replace(
334
            $configGregorian[ 'days_of_week' ],
335
            $days_of_week,
336
            $day_of_week
337
        );
338
339
        foreach ($days as $key => $value) {
340
            if ($day == $value) {
341
                return $key;
342
            }
343
        }
344
345
  },
346
347
  /************************************************************
348
   *                       Leap year
349
   ************************************************************
350
   *
351
   * Leap Year formula on jalali calendar
352
   *
353
   *\_________________________________________________________/
354
   */
355 View Code Duplication
  'leap_year' => function ($year) {
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...
356
357
     $a = 0.025;
358
359
     $b = 266;
360
361
    if ($year > 0) {
362
        $leapDays0 = (($year + 38) % 2820)*0.24219 + $a;
363
        // 0.24219 ~ extra days of one year
364
        $leapDays1 = (($year + 39) % 2820)*0.24219 + $a;
365
        // 38 days is the difference of epoch to 2820-year cycle
366
    } elseif ($year < 0) {
367
        $leapDays0 = (($year + 39) % 2820)*0.24219 + $a;
368
        $leapDays1 = (($year + 40) % 2820)*0.24219 + $a;
369
    } else {
370
        return false;
371
    }
372
373
     $frac0 = intval(($leapDays0 - intval($leapDays0))*1000);
374
     $frac1 = intval(($leapDays1 - intval($leapDays1))*1000);
375
376
    if ($frac0 <= $b && $frac1 > $b) {
377
        return true;
378
    } else {
379
        return false;
380
    }
381
382
  },
383
384
  /************************************************************
385
   *                        Weekend
386
   ************************************************************
387
   *
388
   * Jalali weekend
389
   *
390
   *\_________________________________________________________/
391
   */
392
  'weekend' => array( 'friday' )
393
394
 );
395