1
|
|
|
<?php
|
2
|
|
|
|
3
|
|
|
/*
|
4
|
|
|
* To change this template, choose Tools | Templates
|
5
|
|
|
* and open the template in the editor.
|
6
|
|
|
*/
|
7
|
|
|
|
8
|
|
|
/**
|
9
|
|
|
* Description of Imagenes
|
10
|
|
|
*
|
11
|
|
|
* @author matiasfuster
|
12
|
|
|
*/
|
13
|
|
|
|
14
|
|
|
namespace ExpressApi\V1\Rpc\Statistics;
|
15
|
|
|
|
16
|
|
|
class SystemStatus {
|
17
|
|
|
|
18
|
|
|
public static function right_upload_size() {
|
19
|
|
|
$maxSize = self::max_upload_size();
|
20
|
|
|
return $maxSize >= 15 * 1024 * 1024;
|
21
|
|
|
}
|
22
|
|
|
|
23
|
|
|
/**
|
24
|
|
|
* Retorna si esta correctamente configurado el htaccess para que levante el php.ini correspondiente.
|
25
|
|
|
* @param type $file Ruta hacia el .htaccess
|
26
|
|
|
* @return type
|
27
|
|
|
*/
|
28
|
|
|
public static function right_env($file) {
|
29
|
|
|
$retorno = true;
|
30
|
|
|
if(is_file($file)) {
|
31
|
|
|
$env = "suPHP_ConfigPath ".dirname(realpath($file));
|
32
|
|
|
$htaccess = file($file);
|
33
|
|
|
for($i = 0; $i < count($htaccess); $i++) {
|
|
|
|
|
34
|
|
|
$htaccess[$i] = trim($htaccess[$i]);
|
35
|
|
|
}
|
36
|
|
|
$retorno = array_search($env, $htaccess) !== false;
|
37
|
|
|
}
|
38
|
|
|
return $retorno;
|
39
|
|
|
}
|
40
|
|
|
|
41
|
|
|
public static function ffmeg_loaded() {
|
42
|
|
|
return extension_loaded('ffmpeg');
|
43
|
|
|
}
|
44
|
|
|
|
45
|
|
|
public static function magic_quotes_active() {
|
46
|
|
|
return (boolean) get_magic_quotes_gpc();
|
47
|
|
|
}
|
48
|
|
|
|
49
|
|
|
public static function max_upload_size_format() {
|
50
|
|
|
return self::format_bytes(self::max_upload_size(), 0);
|
51
|
|
|
}
|
52
|
|
|
|
53
|
|
|
public static function max_upload_size() {
|
54
|
|
|
return min(self::let_to_num(ini_get('post_max_size')), self::let_to_num(ini_get('upload_max_filesize')));
|
55
|
|
|
}
|
56
|
|
|
|
57
|
|
|
public static function let_to_num($v) {
|
58
|
|
|
$l = substr($v, -1);
|
59
|
|
|
$ret = substr($v, 0, -1);
|
60
|
|
|
switch(strtoupper($l)) {
|
61
|
|
|
case 'P':
|
62
|
|
|
$ret *= 1024;
|
63
|
|
|
case 'T':
|
64
|
|
|
$ret *= 1024;
|
65
|
|
|
case 'G':
|
66
|
|
|
$ret *= 1024;
|
67
|
|
|
case 'M':
|
68
|
|
|
$ret *= 1024;
|
69
|
|
|
case 'K':
|
70
|
|
|
$ret *= 1024;
|
71
|
|
|
break;
|
72
|
|
|
}
|
73
|
|
|
return $ret;
|
74
|
|
|
}
|
75
|
|
|
|
76
|
|
|
public static function format_bytes($bytes, $precision = 2) {
|
77
|
|
|
$units = array('B', 'KB', 'MB', 'GB', 'TB', 'PB');
|
78
|
|
|
$bytes = max($bytes, 0);
|
79
|
|
|
$pow = floor(($bytes ? log($bytes) : 0) / log(1024));
|
80
|
|
|
$pow = min($pow, count($units) - 1);
|
81
|
|
|
$bytes /= pow(1024, $pow);
|
82
|
|
|
return round($bytes, $precision).$units[$pow];
|
83
|
|
|
}
|
84
|
|
|
}
|
85
|
|
|
|
If the size of the collection does not change during the iteration, it is generally a good practice to compute it beforehand, and not on each iteration: