Vergleich inc/functions_upload.php - 1.02 - 1.17

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 12Zeile 12
function remove_attachment($pid, $posthash, $aid)
{
global $db, $mybb;

function remove_attachment($pid, $posthash, $aid)
{
global $db, $mybb;

 
	$aid = intval($aid);
$posthash = addslashes($posthash);

	if($posthash != "" && !$pid)
{
$query = $db->query("SELECT * FROM ".TABLE_PREFIX."attachments WHERE aid='$aid' AND posthash='$posthash'");

	if($posthash != "" && !$pid)
{
$query = $db->query("SELECT * FROM ".TABLE_PREFIX."attachments WHERE aid='$aid' AND posthash='$posthash'");

Zeile 33Zeile 35
function remove_attachments($pid, $posthash="")
{
global $db, $mybb;

function remove_attachments($pid, $posthash="")
{
global $db, $mybb;

 
	$posthash = addslashes($posthash);

	if($posthash != "" && !$pid)
{
$query = $db->query("SELECT * FROM ".TABLE_PREFIX."attachments WHERE posthash='$posthash'");

	if($posthash != "" && !$pid)
{
$query = $db->query("SELECT * FROM ".TABLE_PREFIX."attachments WHERE posthash='$posthash'");

Zeile 107Zeile 110
	{
$ret['error'] = $lang->error_uploadfailed;
return $ret;

	{
$ret['error'] = $lang->error_uploadfailed;
return $ret;

 
	}

// Check if this is a valid image or not
$img_dimensions = @getimagesize($mybb->settings['avataruploadpath']."/".$filename);

// Check a list of known MIME types to establish what kind of avatar we're uploading
switch(strtolower($avatar['type']))
{
case "image/gif":
$img_type = 1;
break;
case "image/jpeg":
case "image/x-jpeg":
case "image/pjpeg":
$img_type = 2;
break;
case "image/png":
case "image/x-png":
$img_type = 3;
break;
default:
$img_type = 0;
}

// Check if the uploaded file type matches the correct image type (returned by getimagesize)
if($img_dimensions[2] != $img_type || $img_type == 0)
{
@unlink($mybb->settings['avataruploadpath']."/".$filename);
$ret['error'] = $lang->error_uploadfailed;
return $ret;

	}


	}


 
	if(!is_array($img_dimensions))
{
$ret['error'] = $lang->error_uploadfailed;
return $ret;
}


	// If we've got this far check dimensions
if(preg_match("#(gif|jpg|jpeg|jpe|bmp|png)$#i", $ext) && $mybb->settings['maxavatardims'] != "")
{

	// If we've got this far check dimensions
if(preg_match("#(gif|jpg|jpeg|jpe|bmp|png)$#i", $ext) && $mybb->settings['maxavatardims'] != "")
{

		list($width, $height) = @getimagesize($mybb->settings['avataruploadpath']."/".$filename);

 
		list($maxwidth, $maxheight) = @explode("x", $mybb->settings['maxavatardims']);

		list($maxwidth, $maxheight) = @explode("x", $mybb->settings['maxavatardims']);

		if(($maxwidth && $width > $maxwidth) || ($maxheight && $height > $maxheight))

		if(($maxwidth && $img_dimensions[0] > $maxwidth) || ($maxheight && $img_dimensions[1] > $maxheight))

		{
$ret['error'] = sprintf($lang->error_avatartoobig, $maxwidth, $maxheight);
@unlink($mybb->settings['avataruploadpath']."/".$filename);

		{
$ret['error'] = sprintf($lang->error_avatartoobig, $maxwidth, $maxheight);
@unlink($mybb->settings['avataruploadpath']."/".$filename);

Zeile 135Zeile 173
	
$posthash = addslashes($mybb->input['posthash']);
$attachment['name'] = addslashes($attachment['name']);

	
$posthash = addslashes($mybb->input['posthash']);
$attachment['name'] = addslashes($attachment['name']);





	if(!is_uploaded_file($attachment['tmp_name']))
{
$ret['error'] = $lang->error_uploadfailed;

	if(!is_uploaded_file($attachment['tmp_name']))
{
$ret['error'] = $lang->error_uploadfailed;

Zeile 184Zeile 222
	$filename = "post_".$mybb->user['uid']."_".time().".attach";
$file = upload_file($attachment, $mybb->settings['uploadspath'], $filename);
if($file['error'])

	$filename = "post_".$mybb->user['uid']."_".time().".attach";
$file = upload_file($attachment, $mybb->settings['uploadspath'], $filename);
if($file['error'])

	{
$ret['error'] = $lang->error_uploadfailed;

	{
$ret['error'] = $lang->error_uploadfailed;

		return $ret;
}


		return $ret;
}


Zeile 211Zeile 249
	// Alls well that ends well? Lets generate a thumbnail (if image) and insert it all in to the database
if($ext == "gif" || $ext == "png" || $ext == "jpg" || $ext == "jpeg" || $ext == "jpe")
{

	// Alls well that ends well? Lets generate a thumbnail (if image) and insert it all in to the database
if($ext == "gif" || $ext == "png" || $ext == "jpg" || $ext == "jpeg" || $ext == "jpe")
{

 
		// Check a list of known MIME types to establish what kind of image we're uploading
switch(strtolower($file['type']))
{
case "image/gif":
$img_type = 1;
break;
case "image/jpeg":
case "image/x-jpeg":
case "image/pjpeg":
$img_type = 2;
break;
case "image/png":
case "image/x-png":
$img_type = 3;
break;
default:
$img_type = 0;
}

// Check if the uploaded file type matches the correct image type (returned by getimagesize)
$img_dimensions = @getimagesize($mybb->settings['uploadspath']."/".$filename);
if($img_dimensions[2] != $img_type)
{
@unlink($mybb->settings['uploadspath']."/".$filename);
$ret['error'] = $lang->error_uploadfailed;
return $ret;
}


		require "functions_image.php";
$thumbname = str_replace(".attach", "_thumb.$ext", $filename);
$thumbnail = generate_thumbnail($mybb->settings['uploadspath']."/".$filename, $mybb->settings['uploadspath'], $thumbname, $mybb->settings['attachthumbh'], $mybb->settings['attachthumbw']);

		require "functions_image.php";
$thumbname = str_replace(".attach", "_thumb.$ext", $filename);
$thumbnail = generate_thumbnail($mybb->settings['uploadspath']."/".$filename, $mybb->settings['uploadspath'], $thumbname, $mybb->settings['attachthumbh'], $mybb->settings['attachthumbw']);