PluginProbe
VikBooking Hotel Booking Engine & PMS / 1.6.4
VikBooking Hotel Booking Engine & PMS v1.6.4
1.8.16 1.8.15 1.8.14 1.8.13 1.8.12 1.8.11 1.8.10 1.8.9 1.8.6 1.8.7 1.8.8 trunk 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 All 37 releases
vikbooking / admin / helpers / html / vikbooking.php

vikbooking.php in VikBooking Hotel Booking Engine & PMS 1.6.4, at admin/helpers/html/vikbooking.php

80 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @package VikBooking
4 * @subpackage core
5 * @author E4J s.r.l.
6 * @copyright Copyright (C) 2022 E4J s.r.l. All Rights Reserved.
7 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
8 * @link https://vikwp.com
9 */
10
11 // No direct access
12 defined('ABSPATH') or die('No script kiddies please!');
13
14 /**
15 * VikBooking HTML main helper.
16 *
17 * @since 1.5
18 */
19 abstract class JHtmlVikbooking
20 {
21 /**
22 * Calculates the maximum upload file size and returns string with unit or the size in bytes.
23 *
24 * @param bool $unitOutput This parameter determines whether the return value
25 * should be a string with a unit.
26 *
27 * @return float|string The maximum upload size of files with the appropriate unit or in bytes.
28 */
29 public static function maxuploadsize($unitOutput = true)
30 {
31 static $max_size = false;
32
33 if ($max_size === false)
34 {
35 $max_size = self::parseSize(ini_get('post_max_size'));
36 $upload_max = self::parseSize(ini_get('upload_max_filesize'));
37
38 // check what is the highest value between post and upload max sizes
39 if ($upload_max > 0 && ($upload_max < $max_size || $max_size == 0))
40 {
41 $max_size = $upload_max;
42 }
43 }
44
45 if (!$unitOutput)
46 {
47 // return numerical max size
48 return $max_size;
49 }
50
51 // format max size
52 return JHtml::fetch('number.bytes', $max_size, 'auto', 0);
53 }
54
55 /**
56 * Returns the size in bytes without the unit for the comparison.
57 *
58 * @param string $size The size which is received from the PHP settings.
59 *
60 * @return float The size in bytes without the unit.
61 */
62 private static function parseSize($size)
63 {
64 // extract the size unit
65 $unit = preg_replace('/[^bkmgtpezy]/i', '', $size);
66 // take only the size numbers
67 $size = preg_replace('/[^0-9\.]/', '', $size);
68
69 $return = round($size);
70
71 if ($unit)
72 {
73 // calculate the correct size according to the specified unit
74 $return = round($size * pow(1024, stripos('bkmgtpezy', $unit[0])));
75 }
76
77 return $return;
78 }
79 }
80