Vergleich inc/functions_upload.php - 1.01 - 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 134Zeile 172
	global $db, $theme, $templates, $posthash, $pid, $tid, $forum, $mybb, $lang;

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

	global $db, $theme, $templates, $posthash, $pid, $tid, $forum, $mybb, $lang;

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




	$attachment['name'] = addslashes($attachment['name']);


	if(!is_uploaded_file($attachment['tmp_name']))

	if(!is_uploaded_file($attachment['tmp_name']))

	{

	{

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

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

Zeile 147Zeile 186
	if(!$attachtype['atid'])
{
$ret['error'] = $lang->error_attachtype;

	if(!$attachtype['atid'])
{
$ret['error'] = $lang->error_attachtype;

		return $ret;

		return $ret;

	}
// Check the size
if($attachment['size'] > $attachtype['maxsize']*1024 && $attachtype['maxsize'] != "")

	}
// Check the size
if($attachment['size'] > $attachtype['maxsize']*1024 && $attachtype['maxsize'] != "")

Zeile 171Zeile 210
	}

// Check if an attachment with this name is already in the post

	}

// Check if an attachment with this name is already in the post

	$query = $db->query("SELECT * FROM ".TABLE_PREFIX."attachments WHERE filename='".addslashes($attachment['name'])."' AND (posthash='$posthash' OR (pid='$pid' AND pid!='0'))");

	$query = $db->query("SELECT * FROM ".TABLE_PREFIX."attachments WHERE filename='".$attachment['name']."' AND (posthash='$posthash' OR (pid='$pid' AND pid!='0'))");

	$prevattach = $db->fetch_array($query);
if($prevattach['aid'])
{

	$prevattach = $db->fetch_array($query);
if($prevattach['aid'])
{

Zeile 183Zeile 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;
return $ret;

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

	}

// Lets just double check that it exists

	}

// Lets just double check that it exists

Zeile 210Zeile 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']);