Vergleich inc/functions_upload.php - 1.8.12 - 1.8.26

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 21Zeile 21
	global $db, $mybb, $plugins;
$aid = (int)$aid;
$posthash = $db->escape_string($posthash);

	global $db, $mybb, $plugins;
$aid = (int)$aid;
$posthash = $db->escape_string($posthash);

	if($posthash != "")

	if(!empty($posthash))

	{
$query = $db->simple_select("attachments", "aid, attachname, thumbnail, visible", "aid='{$aid}' AND posthash='{$posthash}'");
$attachment = $db->fetch_array($query);

	{
$query = $db->simple_select("attachments", "aid, attachname, thumbnail, visible", "aid='{$aid}' AND posthash='{$posthash}'");
$attachment = $db->fetch_array($query);

Zeile 33Zeile 33
	}

$plugins->run_hooks("remove_attachment_do_delete", $attachment);

	}

$plugins->run_hooks("remove_attachment_do_delete", $attachment);

 

if($attachment === false)
{
// no attachment found with the given details
return;
}


$db->delete_query("attachments", "aid='{$attachment['aid']}'");



$db->delete_query("attachments", "aid='{$attachment['aid']}'");


Zeile 190Zeile 196
	if(!$uid)
{
$uid = $mybb->user['uid'];

	if(!$uid)
{
$uid = $mybb->user['uid'];

	}


	}


	if(!$avatar['name'] || !$avatar['tmp_name'])
{
$avatar = $_FILES['avatarupload'];

	if(!$avatar['name'] || !$avatar['tmp_name'])
{
$avatar = $_FILES['avatarupload'];

Zeile 250Zeile 256
	// Check avatar dimensions
if($mybb->settings['maxavatardims'] != '')
{

	// Check avatar dimensions
if($mybb->settings['maxavatardims'] != '')
{

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

		list($maxwidth, $maxheight) = @preg_split('/[|x]/', $mybb->settings['maxavatardims']);

		if(($maxwidth && $img_dimensions[0] > $maxwidth) || ($maxheight && $img_dimensions[1] > $maxheight))
{
// Automatic resizing enabled?

		if(($maxwidth && $img_dimensions[0] > $maxwidth) || ($maxheight && $img_dimensions[1] > $maxheight))
{
// Automatic resizing enabled?

Zeile 336Zeile 342
	}

// Next check the file size

	}

// Next check the file size

	if(($avatar['size'] > ($mybb->settings['avatarsize']*1024) && $mybb->settings['avatarsize'] > 0) || $avatar['size'] > $allowed_mime_types[$avatar['type']] && !($mybb->settings['avatarsize'] > 0))

	if(($mybb->settings['avatarsize'] > 0 && $avatar['size'] > ($mybb->settings['avatarsize']*1024)) || $avatar['size'] > ($allowed_mime_types[$avatar['type']]*1024))

	{
delete_uploaded_file($avatarpath."/".$filename);
$ret['error'] = $lang->error_uploadsize;

	{
delete_uploaded_file($avatarpath."/".$filename);
$ret['error'] = $lang->error_uploadsize;

Zeile 350Zeile 356
		"avatar" => $mybb->settings['avataruploadpath']."/".$filename,
"width" => (int)$img_dimensions[0],
"height" => (int)$img_dimensions[1]

		"avatar" => $mybb->settings['avataruploadpath']."/".$filename,
"width" => (int)$img_dimensions[0],
"height" => (int)$img_dimensions[1]

	);

	);

	$ret = $plugins->run_hooks("upload_avatar_end", $ret);
return $ret;
}

	$ret = $plugins->run_hooks("upload_avatar_end", $ret);
return $ret;
}

Zeile 368Zeile 374

$posthash = $db->escape_string($mybb->get_input('posthash'));
$pid = (int)$pid;


$posthash = $db->escape_string($mybb->get_input('posthash'));
$pid = (int)$pid;


if(isset($attachment['error']) && $attachment['error'] != 0)
{
$ret['error'] = $lang->error_uploadfailed.$lang->error_uploadfailed_detail;
switch($attachment['error'])
{
case 1: // UPLOAD_ERR_INI_SIZE
$ret['error'] .= $lang->error_uploadfailed_php1;
break;
case 2: // UPLOAD_ERR_FORM_SIZE
$ret['error'] .= $lang->error_uploadfailed_php2;
break;
case 3: // UPLOAD_ERR_PARTIAL
$ret['error'] .= $lang->error_uploadfailed_php3;
break;
case 4: // UPLOAD_ERR_NO_FILE
$ret['error'] .= $lang->error_uploadfailed_php4;
break;
case 6: // UPLOAD_ERR_NO_TMP_DIR
$ret['error'] .= $lang->error_uploadfailed_php6;
break;
case 7: // UPLOAD_ERR_CANT_WRITE
$ret['error'] .= $lang->error_uploadfailed_php7;
break;
default:
$ret['error'] .= $lang->sprintf($lang->error_uploadfailed_phpx, $attachment['error']);
break;
}
return $ret;
}

 

if(!is_uploaded_file($attachment['tmp_name']) || empty($attachment['tmp_name']))
{


if(!is_uploaded_file($attachment['tmp_name']) || empty($attachment['tmp_name']))
{

Zeile 427Zeile 403
	else
{
$attachtype = $attachtypes[$ext];

	else
{
$attachtype = $attachtypes[$ext];

 
	}

// check the length of the filename
$maxFileNameLength = 255;
if(my_strlen($attachment['name']) > $maxFileNameLength)
{
$ret['error'] = $lang->sprintf($lang->error_attach_filename_length, htmlspecialchars_uni($attachment['name']), $maxFileNameLength);
return $ret;

	}

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

	}

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

		$ret['error'] = $lang->sprintf($lang->error_attachsize, $attachtype['maxsize']);

		$ret['error'] = $lang->sprintf($lang->error_attachsize, htmlspecialchars_uni($attachment['name']), $attachtype['maxsize']);

		return $ret;
}


		return $ret;
}


Zeile 472Zeile 456
			return $ret;
}


			return $ret;
}


		$ret['error'] = $lang->error_alreadyuploaded;

		$ret['error'] = $lang->sprintf($lang->error_alreadyuploaded, htmlspecialchars_uni($attachment['name']));

		return $ret;
}


		return $ret;
}


Zeile 676Zeile 660
		}
}
$ret['aid'] = $aid;

		}
}
$ret['aid'] = $aid;

 
	return $ret;
}

/**
* Check whether the input $FILE variable indicates a PHP file upload error,
* and if so, return an appropriate user-friendly error message.
*
* @param array $FILE File data (as fed by PHP's $_FILE).
*
* @return string Error message or empty if no error detected.
*/
function check_parse_php_upload_err($FILE)
{
global $lang;

$err = '';

if(isset($FILE['error']) && $FILE['error'] != 0 && ($FILE['error'] != UPLOAD_ERR_NO_FILE || $FILE['name']))
{
$err = $lang->error_uploadfailed.$lang->error_uploadfailed_detail;
switch($FILE['error'])
{
case 1: // UPLOAD_ERR_INI_SIZE
$err .= $lang->error_uploadfailed_php1;
break;
case 2: // UPLOAD_ERR_FORM_SIZE
$err .= $lang->error_uploadfailed_php2;
break;
case 3: // UPLOAD_ERR_PARTIAL
$err .= $lang->error_uploadfailed_php3;
break;
case 4: // UPLOAD_ERR_NO_FILE
$err .= $lang->error_uploadfailed_php4;
break;
case 6: // UPLOAD_ERR_NO_TMP_DIR
$err .= $lang->error_uploadfailed_php6;
break;
case 7: // UPLOAD_ERR_CANT_WRITE
$err .= $lang->error_uploadfailed_php7;
break;
default:
$err .= $lang->sprintf($lang->error_uploadfailed_phpx, $FILE['error']);
break;
}
}

return $err;
}

/**
* Process adding attachment(s) when the "Add Attachment" button is pressed.
*
* @param int $pid The ID of the post.
* @param array $forumpermission The permissions for the forum.
* @param string $attachwhere Search string "pid='$pid'" or "posthash='".$db->escape_string($mybb->get_input('posthash'))."'"
* @param string $action Where called from: "newthread", "newreply", or "editpost"
*
* @return array Array of errors if any, empty array otherwise
*/
function add_attachments($pid, $forumpermissions, $attachwhere, $action=false)
{
global $db, $mybb, $editdraftpid, $lang;

$ret = array();

if($forumpermissions['canpostattachments'])
{
$attachments = array();
$fields = array ('name', 'type', 'tmp_name', 'error', 'size');
$aid = array();

$total = isset($_FILES['attachments']['name']) ? count($_FILES['attachments']['name']) : 0;
$filenames = "";
$delim = "";
for($i=0; $i<$total; ++$i)
{
foreach($fields as $field)
{
$attachments[$i][$field] = $_FILES['attachments'][$field][$i];
}

$FILE = $attachments[$i];
if(!empty($FILE['name']) && !empty($FILE['type']) && $FILE['size'] > 0)
{
$filenames .= $delim . "'" . $db->escape_string($FILE['name']) . "'";
$delim = ",";
}
}

if ($filenames != '')
{
$query = $db->simple_select("attachments", "filename", "{$attachwhere} AND filename IN (".$filenames.")");

while ($row = $db->fetch_array($query))
{
$aid[$row['filename']] = true;
}
}

foreach($attachments as $FILE)
{
if($err = check_parse_php_upload_err($FILE))
{
$ret['errors'][] = $err;
$mybb->input['action'] = $action;
}
else if(!empty($FILE['name']) && !empty($FILE['type']))
{
if($FILE['size'] > 0)
{
$filename = $db->escape_string($FILE['name']);
$exists = $aid[$filename];

$update_attachment = false;
if($action == "editpost")
{
if($exists && $mybb->get_input('updateattachment') && ($mybb->usergroup['caneditattachments'] || $forumpermissions['caneditattachments']))
{
$update_attachment = true;
}
}
else
{
if($exists && $mybb->get_input('updateattachment'))
{
$update_attachment = true;
}
}

$attachedfile = upload_attachment($FILE, $update_attachment);

if(!empty($attachedfile['error']))
{
$ret['errors'][] = $attachedfile['error'];
$mybb->input['action'] = $action;
}

}
else
{
$ret['errors'][] = $lang->sprintf($lang->error_uploadempty, htmlspecialchars_uni($FILE['name']));
$mybb->input['action'] = $action;
}
}
}
}


	return $ret;
}


	return $ret;
}