Páginas (2):    1 2
DarkFinder   14 Jan, 2013, 9:54 pm
#11
Tal vez no sea la mas ortodoxa o tenga algún bug de seguridad pero me funcionado de maravilla Big Grin

function portalimg_upload($input_img, $path = "uploads/posts/", $img_error = FALSE) {
	$input_img = preg_replace("#script:#i", "", $input_img);
	$ext = get_extension($input_img);	
	$input_img = file_get_contents($input_img);	
	if(preg_match("#^(gif|jpg|jpeg|jpe|bmp|png)$#i", $ext)) {
		$filename_1 = gmdate("Y_m")."_".TIME_NOW.".".$ext;
		$filename = $path.$filename_1;
		$temp = $path.md5(time().rand()); 
		$f = @fopen($temp, 'wb');
		if (!($f = @fopen($temp, 'wb'))) { 
			$img_error = TRUE;  
		} 
		fwrite($f, $input_img); 
		fclose($f); 
		if (!@rename($temp, $filename)) { 
			@unlink($filename); 
			@rename($temp, $filename); 
		}  
		@my_chmod($path.$filename, '0644');
	}
	else {
		$img_error == TRUE;
	}
	$portal_array = array(
		"error" => $img_error,
		"src"		=> $filename_1,
	);
	return $portal_array;
}

Si ven algún fallo de seguridad me gustaría que me lo hicieran saber Big Grin
Omar G.   14 Jan, 2013, 11:59 pm
#12
Puedes obtener el contenido de la imagen después de verificar que la extensión es valida.

Envía un DM o MP si te interesa patrocinar alguna actualización o complemento a alguno de mis plugins.

[Imagen: signature.png]

Discord omar.gonzalez (Omar G.#6117); Telegram at @omarugc;
DarkFinder   15 Jan, 2013, 12:27 am
#13
Buen punto, gracias por avisarme de ese detallito

Enviado desde mi móvil utilizando Tapatalk 2
Páginas (2):    1 2
  
Powered By MyBB, © 2002-2025 MyBB Group.
Made with by Curves UI.