Skip to content

Commit b3ce6cb

Browse files
author
Daniel Neto
committed
Update
1 parent 6265f0e commit b3ce6cb

File tree

3 files changed

+31
-17
lines changed

3 files changed

+31
-17
lines changed

objects/functions.php

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -188,24 +188,36 @@ function file_get_intbound_contents($url, $bindto_addr_family)
188188
return file_get_contents($url, false, $stream_context);
189189
}
190190

191-
// Returns a file size limit in bytes based on the PHP upload_max_filesize
192-
// and post_max_size
193-
function file_upload_max_size()
194-
{
195-
static $max_size = -1;
191+
function file_upload_max_size() {
192+
// Retrieve the values from php.ini
193+
$uploadMaxFileSize = ini_get('upload_max_filesize');
194+
$postMaxSize = ini_get('post_max_size');
196195

197-
if ($max_size < 0) {
198-
// Start with post_max_size.
199-
$max_size = parse_size(ini_get('post_max_size'));
196+
// Convert both values to bytes
197+
$uploadMaxFileSizeBytes = convertToBytes($uploadMaxFileSize);
198+
$postMaxSizeBytes = convertToBytes($postMaxSize);
200199

201-
// If upload_max_size is less, then reduce. Except if upload_max_size is
202-
// zero, which indicates no limit.
203-
$upload_max = parse_size(ini_get('upload_max_filesize'));
204-
if ($upload_max > 0 && $upload_max < $max_size) {
205-
$max_size = $upload_max;
206-
}
200+
// Return the smaller of the two values
201+
return min($uploadMaxFileSizeBytes, $postMaxSizeBytes);
202+
}
203+
204+
function convertToBytes($value) {
205+
$unit = strtoupper(substr($value, -1));
206+
$bytes = (int)$value;
207+
208+
switch ($unit) {
209+
case 'G':
210+
$bytes *= 1024 ** 3;
211+
break;
212+
case 'M':
213+
$bytes *= 1024 ** 2;
214+
break;
215+
case 'K':
216+
$bytes *= 1024;
217+
break;
207218
}
208-
return $max_size;
219+
220+
return $bytes;
209221
}
210222

211223
function parse_size($size)

objects/youtube.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,6 @@ def add_user_agent():
8282
("Accept-Language", "en-US,en;q=0.9"),
8383
("Accept", "*/*"),
8484
("Connection", "keep-alive"),
85-
("X-Forwarded-For", "203.0.113.1"), # Example valid IP
86-
("X-Real-IP", "203.0.113.1"), # Example valid IP
8785
]
8886
opener = urllib.request.build_opener()
8987
opener.addheaders = headers

view/streamerResources/info.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,9 @@
1414
<span class="fas fa-user-circle"></span>
1515
<strong><?php echo __('User'); ?>:</strong> <?php echo Login::getStreamerUser(); ?>
1616
</p>
17+
<p>
18+
<span class="fa-solid fa-file-upload"></span>
19+
<strong><?php echo __('Max File Size'); ?>:</strong> <?php echo get_max_file_size(); ?>
20+
</p>
1721
</div>
1822
</div>

0 commit comments

Comments
 (0)