3v4l.org

run code in 300+ PHP versions simultaneously
<? /* Tipo : classe Nome : UpLoad Data : 29/08/2003 Autor: Wonder Alexandre Luz Alves Desc : esta class faz upload de arquivo gera uma mini imagem p/ visualização e tem tratamento de erros Versão: 1.2 */ class UpLoad { var $arquivo_permissao; var $dir; var $max_filesize; var $idioma; var $error=0; var $file_type; var $file_name; var $file_size; var $arquivo; var $file_path; var $warning=0; var $MINI_name; var $MINI_path="images_mini"; function UpLoad ($permissao="" , $max_file = 300000, $dir = "images",$idioma="portugues"){ if ( empty ($permissao) ) $permissao = array ("image/pjpeg","image/x-png","image/jpeg","image/png","image/gif"); $this->arquivo_permissao = $permissao; $this->max_filesize = $max_file; $this->dir = $dir; $this->idioma = $idioma; } function putFile ($file){ $this->file_type = strtok ( $_FILES[$file]['type'], ";"); $this->file_name = $_FILES[$file]['name']; $this->file_size = $_FILES[$file]['size']; $this->temp = $_FILES[$file]['tmp_name']; // upload para o diretorio temp if(!in_array($this->file_type, $this->arquivo_permissao)) $this->Error(1); if ( ($this->file_size <= 0) || ($this->file_size > $this->max_filesize) ) $this->Error(2); if ($this->error == ""){ $filename = basename ($this->file_name); if (!empty ($this->dir) ) $this->arquivo = $this->dir."/".$filename; else $this->arquivo = $filename; if (file_exists($this->arquivo)){ srand((double)microtime()*1000000); $filename = rand(0,20000).$filename; if (!empty ($this->dir)) $this->arquivo = $this->dir."/".$filename; else $this->arquivo = $filename; } if(!is_uploaded_file($this->temp)) $this->Error(3); if(!@move_uploaded_file($this->temp,$this->arquivo) ) $this->Error(4); return $this->arquivo; } else { return false; } } function checar_gd() { $testGD = get_extension_funcs("gd"); if (!$testGD) $this->error(5); else{ ob_start(); phpinfo(8); $grab = ob_get_contents(); ob_end_clean(); $version = strpos ($grab,"2.0 or higher"); if ( $version ) return "gd2"; else return "gd"; } } function Gerar_mini($new_image_file_path, $max_width=480, $max_height=1600 ) { $return_val = 1; if(eregi("\.png$",$this->arquivo)){ $return_val = ( ($img = ImageCreateFromPNG ( $this->arquivo )) && $return_val == 1 ) ? "1" : "0"; } if(eregi("\.(jpg|jpeg)$",$this->arquivo)){ $return_val = ( ($img = ImageCreateFromJPEG ( $this->arquivo )) && $return_val == 1 ) ? "1" : "0"; } if(eregi("\.gif$",$this->arquivo)){ $return_val = ( ($img = ImageCreateFromGif ( $this->arquivo )) && $return_val == 1 ) ? "1" : "0"; } $FullImage_width = imagesx ($img); $FullImage_height = imagesy ($img); $ratio = ( $FullImage_width > $max_width ) ? (real)($max_width / $FullImage_width) : 1 ; $new_width = ((int)($FullImage_width * $ratio)); //full-size width $new_height = ((int)($FullImage_height * $ratio)); //full-size height $ratio = ( $new_height > $max_height ) ? (real)($max_height / $new_height) : 1 ; $new_width = ((int)($new_width * $ratio)); //mid-size width $new_height = ((int)($new_height * $ratio)); //mid-size height if ( $new_width == $FullImage_width && $new_height == $FullImage_height ) copy ( $this->arquivo, $new_image_file_path ); $gd_version = $this->checar_gd(); if ( $gd_version == "gd2" ) { $full_id = ImageCreateTrueColor ( $new_width , $new_height ); //Crea un'immagine ImageCopyResampled ( $full_id, $img, 0,0,0,0, $new_width, $new_height, $FullImage_width, $FullImage_height ); } elseif ( $gd_version == "gd" ){ $full_id = ImageCreate ( $new_width , $new_height ); //Crea un'immagine ImageCopyResized ( $full_id, $img, 0,0,0,0, $new_width, $new_height, $FullImage_width, $FullImage_height ); } else $this->Error(5); if(eregi("\.(jpg|jpeg)$",$this->arquivo)){ $return_val = ( $full = ImageJPEG( $full_id, $new_image_file_path, 80 ) && $return_val == 1 ) ? "1" : "0"; } if(eregi("\.png$",$this->arquivo)) { $return_val = ( $full = ImagePNG( $full_id, $new_image_file_path ) && $return_val == 1 ) ? "1" : "0"; } if(eregi("\.gif$",$this->arquivo)) { if($gd_version != "gd2") return 0; $return_val = ( $full = imagegif($full_id, $new_image_file_path) && $return_val == 1 ) ? "1" : "0"; } ImageDestroy( $full_id ); return ($return_val) ? TRUE : FALSE ; } function Miniatura($larg=80, $alt=80, $pre_name="MINI_"){ if ((eregi("\.png$", $this->arquivo) || eregi("\.(jpg|jpeg)$", $this->arquivo) || eregi("\.gif$", $this->arquivo)) && $this->arquivo){ $this->MINI_name = $pre_name . $this->file_name; if (!empty ($this->MINI_path)) $thumb_path = $this->MINI_path ."/". $pre_name . $this->file_name; else $thumb_path = $pre_name . $this->file_name; if ($this->Gerar_mini($thumb_path, $larg, $alt)) return $thumb_path; else{ $this->Warning(1); return 0; } } else $this->Warning(2); } function Error($op){ if($this->idioma="portugues"){ switch ($op){ case 0: return; break; case 1: $this->error = "Error 1: Este tipo de arquivo não tem permissão para upload : $this->file_type."; break; case 2: $this->error = "Error 2: Erro no tamanho do arquivo: $this->file_size Kb. Tamanho Maximo é $this->max_filesize."; break; case 3: $this->error = "Error 3: Ocorreu um erro na transferencia do arquivo: $this->file_name."; break; case 4: $this->error = "Error 4: Ocorreu um erro na transferencia de $this->temp para $this->file_name."; break; case 5: $this->error = "Error 5: Biblioteca GD não instalada!";break; } } ?> <SCRIPT> alert("<?= $this->error; ?>"); </SCRIPT> <? exit; } function Warning($op){ if($this->idioma="portugues"){ switch ($op){ case 1: $this->warning = "Aviso 1: Ocorreu um erro na criação da Miniatura.";break; case 2: $this->warning = "Aviso 2: Esse arquivo não tem Miniatuara"; break; } } ?> <SCRIPT> alert("<?= $this->warning; ?>"); </SCRIPT> <? } function Mostrar_MINI($tipo='1'){ if(file_exists($this->MINI_path . "/" . $this->MINI_name)) $url = "<img src=" . $this->MINI_path . "/" . $this->MINI_name . " name=x>"; else $url = "<center>Não Há Amostra!</center>"; if($tipo==2) return $url; ?> <script> WIN = window.open ('', 'NINIatura', 'toolbar=no,width=90,height=90,directories=no,status=no,scrollbars=no,resize=no,menubar=no'); WIN.document.write("<? echo $url ?>"); </script> <? } } ?>

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.3.60.0070.00718.30
8.3.50.0120.00521.14
8.3.40.0120.00319.02
8.3.30.0100.00320.22
8.3.20.0070.00020.21
8.3.10.0050.00321.00
8.3.00.0050.00322.39
8.2.180.0070.01416.63
8.2.170.0140.00322.96
8.2.160.0040.01122.11
8.2.150.0080.00024.18
8.2.140.0000.00824.66
8.2.130.0000.00826.16
8.2.120.0070.00020.87
8.2.110.0070.00419.14
8.2.100.0070.00418.03
8.2.90.0040.00419.27
8.2.80.0060.00317.97
8.2.70.0030.00617.50
8.2.60.0040.00417.80
8.2.50.0050.00318.07
8.2.40.0040.00418.15
8.2.30.0030.00519.53
8.2.20.0000.00817.71
8.2.10.0040.00417.62
8.2.00.0070.00017.70
8.1.280.0040.01125.92
8.1.270.0080.00023.99
8.1.260.0060.00326.35
8.1.250.0040.00428.09
8.1.240.0130.00323.95
8.1.230.0070.00420.88
8.1.220.0080.00018.77
8.1.210.0040.00419.17
8.1.200.0040.00417.10
8.1.190.0000.00717.53
8.1.180.0110.00018.10
8.1.170.0000.00918.51
8.1.160.0000.00718.80
8.1.150.0000.00718.41
8.1.140.0000.00717.36
8.1.130.0030.00317.71
8.1.120.0070.00017.38
8.1.110.0040.00417.39
8.1.100.0000.00817.34
8.1.90.0070.00017.33
8.1.80.0000.00717.32
8.1.70.0000.00817.28
8.1.60.0030.00517.50
8.1.50.0040.00417.47
8.1.40.0050.00317.38
8.1.30.0040.00417.43
8.1.20.0000.00817.64
8.1.10.0040.00417.53
8.1.00.0000.00817.51
8.0.300.0050.00319.97
8.0.290.0040.00417.18
8.0.280.0000.00718.46
8.0.270.0000.00717.29
8.0.260.0000.00716.95
8.0.250.0070.00016.87
8.0.240.0050.00316.95
8.0.230.0030.00316.98
8.0.220.0000.00816.80
8.0.210.0070.00016.91
8.0.200.0030.00316.96
8.0.190.0030.00316.85
8.0.180.0040.00416.95
8.0.170.0070.00016.86
8.0.160.0030.00516.79
8.0.150.0000.00716.77
8.0.140.0000.00716.86
8.0.130.0030.00313.36
8.0.120.0080.00016.86
8.0.110.0000.00716.93
8.0.100.0000.00716.96
8.0.90.0050.00316.88
8.0.80.0100.00716.91
8.0.70.0030.00516.94
8.0.60.0070.00016.89
8.0.50.0000.00716.92
8.0.30.0100.01217.06
8.0.20.0150.00617.40
8.0.10.0040.00416.80
8.0.00.0110.01216.73
7.4.330.0070.00015.17
7.4.320.0000.00716.46
7.4.300.0000.00616.48
7.4.290.0000.00716.41
7.4.280.0030.00316.36
7.4.270.0040.00416.48
7.4.260.0030.00313.25
7.4.250.0040.00416.51
7.4.240.0020.00516.50
7.4.230.0000.00716.54
7.4.220.0030.01216.56
7.4.210.0110.00516.54
7.4.200.0040.00416.35
7.4.190.0000.00716.41
7.4.160.0100.00716.41
7.4.150.0160.00317.40
7.4.140.0140.01917.86
7.4.130.0130.00316.41
7.4.120.0130.00316.57
7.4.110.0180.00616.61
7.4.100.0090.00916.63
7.4.90.0060.01216.30
7.4.80.0040.01319.39
7.4.70.0120.00616.36
7.4.60.0060.01016.22
7.4.50.0090.00016.62
7.4.40.0040.01122.77
7.4.30.0120.00316.59
7.3.330.0000.00513.39
7.3.320.0070.00013.36
7.3.310.0040.00416.32
7.3.300.0000.00616.17
7.3.290.0070.00716.28
7.3.280.0070.01016.28
7.3.270.0070.01017.40
7.3.260.0100.00818.24
7.3.250.0110.01116.42
7.3.240.0110.00716.34
7.3.230.0080.00816.39
7.3.210.0110.00616.34
7.3.200.0130.00719.39
7.3.190.0170.00316.40
7.3.180.0070.00916.34
7.3.170.0080.00816.31
7.3.160.0100.01016.43
7.3.00.0070.00716.66
7.2.330.0130.00316.48
7.2.320.0180.00016.31
7.2.310.0090.00616.57
7.2.300.0070.01016.63
7.2.290.0100.01016.51
7.2.130.0030.00616.63
7.2.120.0030.00916.56
7.2.110.0060.00316.69
7.2.100.0040.00716.80
7.2.90.0080.00816.95
7.2.80.0040.01016.67
7.2.70.0040.01116.69
7.2.60.0090.00616.37
7.2.50.0000.01016.68
7.2.40.0030.01016.61
7.2.30.0000.01016.63
7.2.20.0110.00016.72
7.2.10.0030.01016.77
7.2.00.0070.01016.71
7.1.250.0090.00315.66
7.1.240.0000.01215.51
7.1.230.0030.01415.65
7.1.220.0060.00915.38
7.1.210.0000.01215.79
7.1.200.0070.00415.47
7.1.190.0030.01415.70
7.1.180.0070.00415.68
7.1.170.0100.00315.71
7.1.160.0040.00715.34
7.1.150.0070.00715.70
7.1.140.0040.00815.42
7.1.130.0040.00415.68
7.1.120.0050.00515.51
7.1.110.0060.00915.36
7.1.100.0100.00715.41
7.1.90.0000.00915.46
7.1.80.0000.01615.59
7.1.70.0060.00616.34
7.1.60.0020.01617.28
7.1.50.0070.00916.14
7.1.40.0000.01315.44
7.1.30.0070.00415.71
7.1.20.0040.01115.55
7.1.10.0110.00015.43
7.1.00.0060.03618.84
7.0.330.0000.01115.16
7.0.320.0000.01015.27
7.0.310.0000.01615.02
7.0.300.0040.00815.14
7.0.290.0030.00515.20
7.0.280.0090.00615.02
7.0.270.0040.00814.85
7.0.260.0000.01314.87
7.0.250.0060.00915.27
7.0.240.0000.01115.09
7.0.230.0110.00415.23
7.0.220.0110.00315.14
7.0.210.0000.01515.16
7.0.200.0020.00915.91
7.0.190.0000.01514.83
7.0.180.0090.00615.26
7.0.170.0030.01214.97
7.0.160.0030.00715.17
7.0.150.0030.01015.07
7.0.140.0050.03818.68
7.0.130.0060.00315.03
7.0.120.0000.01015.30
7.0.110.0000.01015.35
7.0.100.0050.04017.61
7.0.90.0130.04317.57
7.0.80.0140.03517.73
7.0.70.0050.03917.73
7.0.60.0040.03517.53
7.0.50.0030.03217.73
7.0.40.0030.05016.76
7.0.30.0020.05516.85
7.0.20.0070.03716.61
7.0.10.0100.02916.69
7.0.00.0080.02516.49
5.6.380.0100.00613.96
5.6.370.0070.00714.36
5.6.360.0040.01214.06
5.6.350.0070.00313.98
5.6.340.0090.00314.38
5.6.330.0040.01113.75
5.6.320.0110.00714.16
5.6.310.0040.01114.43
5.6.300.0000.00814.16
5.6.290.0040.00714.05
5.6.280.0030.03917.60
5.6.270.0030.01014.05
5.6.260.0060.00314.45
5.6.250.0050.02317.45
5.6.240.0140.03817.59
5.6.230.0080.02317.56
5.6.220.0070.02817.54
5.6.210.0080.02217.30
5.6.200.0060.04017.65
5.6.190.0100.03517.60
5.6.180.0070.02217.74
5.6.170.0050.02517.60
5.6.160.0100.04017.64
5.6.150.0050.02717.60
5.6.140.0050.04317.65
5.6.130.0060.03117.64
5.6.120.0050.04417.54
5.6.110.0070.04217.76
5.6.100.0070.03217.79
5.6.90.0130.02217.55
5.6.80.0020.04317.30
5.6.70.0050.04317.15
5.6.60.0100.01917.39
5.6.50.0030.03117.24
5.6.40.0020.02517.13
5.6.30.0000.04317.17
5.6.20.0070.04217.17
5.6.10.0080.04117.28
5.6.00.0140.03517.21
5.5.380.0030.04515.82
5.5.370.0080.02015.52
5.5.360.0090.04015.64
5.5.350.0070.03215.59
5.5.340.0050.03515.80
5.5.330.0010.04615.80
5.5.320.0050.02715.82
5.5.310.0080.04015.95
5.5.300.0070.04015.97
5.5.290.0040.04415.86
5.5.280.0070.04215.71
5.5.270.0070.03615.84
5.5.260.0070.03215.87
5.5.250.0030.02515.83
5.5.240.0080.04015.57
5.5.230.0030.02815.59
5.5.220.0050.02515.43
5.5.210.0040.02415.47
5.5.200.0130.01715.58
5.5.190.0020.04415.60
5.5.180.0050.04015.59
5.5.170.0000.01010.64
5.5.160.0030.02515.42
5.5.150.0040.02015.52
5.5.140.0080.03115.40
5.5.130.0070.03615.25
5.5.120.0120.03315.52
5.5.110.0060.03215.51
5.5.100.0030.04015.48
5.5.90.0020.02815.39
5.5.80.0050.02515.34
5.5.70.0060.03015.42
5.5.60.0030.02615.46
5.5.50.0060.03215.52
5.5.40.0070.03315.49
5.5.30.0030.02115.58
5.5.20.0050.04415.46
5.5.10.0060.03815.53
5.5.00.0020.04715.32
5.4.450.0060.03514.94
5.4.440.0030.04815.13
5.4.430.0020.04315.04
5.4.420.0100.03815.16
5.4.410.0100.02814.98
5.4.400.0050.03914.96
5.4.390.0050.04114.82
5.4.380.0050.02314.89
5.4.370.0070.03714.89
5.4.360.0000.02614.88
5.4.350.0090.03915.08
5.4.340.0050.04114.85
5.4.330.0000.00810.43
5.4.320.0030.02214.96
5.4.310.0040.04414.84
5.4.300.0010.03114.86
5.4.290.0090.03514.72
5.4.280.0090.04014.92
5.4.270.0030.04314.78
5.4.260.0050.04014.97
5.4.250.0090.03314.94
5.4.240.0030.03914.86
5.4.230.0090.02214.82
5.4.220.0120.02714.86
5.4.210.0000.02114.96
5.4.200.0070.04214.89
5.4.190.0020.04714.81
5.4.180.0040.02214.94
5.4.170.0020.04514.67
5.4.160.0080.03114.71
5.4.150.0050.02314.72
5.4.140.0060.02013.76
5.4.130.0050.02213.62
5.4.120.0070.02913.74
5.4.110.0100.01813.59
5.4.100.0050.03613.56
5.4.90.0100.02013.47
5.4.80.0050.01813.70
5.4.70.0030.04113.54
5.4.60.0030.03513.59
5.4.50.0050.02113.67
5.4.40.0110.03113.66
5.4.30.0070.03213.59
5.4.20.0040.03613.64
5.4.10.0020.02313.57
5.4.00.0100.03013.46
5.3.290.0040.02312.96
5.3.280.0040.03512.96
5.3.270.0030.02013.03
5.3.260.0070.04013.02
5.3.250.0050.02212.96
5.3.240.0030.02012.96
5.3.230.0080.04012.96
5.3.220.0070.03612.96
5.3.210.0020.03012.96
5.3.200.0030.03812.96
5.3.190.0050.03012.96
5.3.180.0050.02212.96
5.3.170.0060.03113.04
5.3.160.0030.03512.99
5.3.150.0090.02513.04
5.3.140.0020.02312.96
5.3.130.0030.03612.96
5.3.120.0100.03512.96
5.3.110.0030.04212.97
5.3.100.0050.03812.96
5.3.90.0060.03912.96
5.3.80.0080.03712.96
5.3.70.0060.03912.96
5.3.60.0050.03512.99
5.3.50.0070.03312.96
5.3.40.0050.03512.96
5.3.30.0070.02212.96
5.3.20.0050.02212.96
5.3.10.0030.03812.96
5.3.00.0030.04212.96

preferences:
52.85 ms | 401 KiB | 5 Q