Vergleich inc/functions_upload.php - 1.2.2 - 1.2.7

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 3Zeile 3
 * MyBB 1.2
* Copyright � 2006 MyBB Group, All Rights Reserved
*

 * MyBB 1.2
* Copyright � 2006 MyBB Group, All Rights Reserved
*

 * Website: http://www.mybboard.com
* License: http://www.mybboard.com/eula.html

 * Website: http://www.mybboard.net
* License: http://www.mybboard.net/eula.html

 *

 *

 * $Id: functions_upload.php 2423 2006-11-20 00:16:03Z CraKteR $

 * $Id: functions_upload.php 3055 2007-05-13 15:01:15Z Tikitiki $

 */



 */



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

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

 
	
if($pid)
{
$post = get_post($pid);
}


	$aid = intval($aid);
$posthash = $db->escape_string($posthash);
if($posthash != "")
{
$query = $db->simple_select(TABLE_PREFIX."attachments", "*", "aid='$aid' AND posthash='$posthash'");

	$aid = intval($aid);
$posthash = $db->escape_string($posthash);
if($posthash != "")
{
$query = $db->simple_select(TABLE_PREFIX."attachments", "*", "aid='$aid' AND posthash='$posthash'");

		$attachment = $db->fetch_array($query);

		$attachment = $db->fetch_array($query);

	}
else
{

	}
else
{

Zeile 37Zeile 43
	if($attachment['thumbnail'])
{
@unlink($mybb->settings['uploadspath']."/".$attachment['thumbnail']);

	if($attachment['thumbnail'])
{
@unlink($mybb->settings['uploadspath']."/".$attachment['thumbnail']);

 
	}
if($attachment['visible'] == 1 && $post['pid'])
{
update_thread_counters($post['tid'], array("attachmentcount" => "-1"));

	}
}


	}
}


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

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

 
	
if($pid)
{
$post = get_post($pid);
}


	$posthash = $db->escape_string($posthash);
if($posthash != "" && !$pid)
{

	$posthash = $db->escape_string($posthash);
if($posthash != "" && !$pid)
{

Zeile 58Zeile 74
	{
$query = $db->simple_select(TABLE_PREFIX."attachments", "*", "pid='$pid'");
}

	{
$query = $db->simple_select(TABLE_PREFIX."attachments", "*", "pid='$pid'");
}

 
	$num_attachments = 0;

	while($attachment = $db->fetch_array($query))
{

	while($attachment = $db->fetch_array($query))
{

 
		if($attachment['visible'] == 1) 
{
$num_attachments++;
}

		$db->delete_query(TABLE_PREFIX."attachments", "aid='".$attachment['aid']."'");
@unlink($mybb->settings['uploadspath']."/".$attachment['attachname']);
if($attachment['thumbnail'])

		$db->delete_query(TABLE_PREFIX."attachments", "aid='".$attachment['aid']."'");
@unlink($mybb->settings['uploadspath']."/".$attachment['attachname']);
if($attachment['thumbnail'])

		{

		{

			@unlink($mybb->settings['uploadspath']."/".$attachment['thumbnail']);

			@unlink($mybb->settings['uploadspath']."/".$attachment['thumbnail']);

		}
}
}





		}
}
if($post['pid'])
{
update_thread_counters($post['tid'], array("attachmentcount" => "-{$num_attachments}"));
}
}


/**
* Remove any matching avatars for a specific user ID


/**
* Remove any matching avatars for a specific user ID

Zeile 103Zeile 128
	global $db, $mybb, $lang, $_FILES;
$avatar = $_FILES['avatarupload'];
if(!is_uploaded_file($avatar['tmp_name']))

	global $db, $mybb, $lang, $_FILES;
$avatar = $_FILES['avatarupload'];
if(!is_uploaded_file($avatar['tmp_name']))

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

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


// Check we have a valid extension
$ext = get_extension(strtolower($avatar['name']));
if(!preg_match("#(gif|jpg|jpeg|jpe|bmp|png)$#i", $ext)) {
$ret['error'] = $lang->error_avatartype;


// Check we have a valid extension
$ext = get_extension(strtolower($avatar['name']));
if(!preg_match("#(gif|jpg|jpeg|jpe|bmp|png)$#i", $ext)) {
$ret['error'] = $lang->error_avatartype;

		return $ret;

		return $ret;

	}

// Next check the file size
if($avatar['size'] > ($mybb->settings['avatarsize']*1024) && $mybb->settings['avatarsize'] > 0)

	}

// Next check the file size
if($avatar['size'] > ($mybb->settings['avatarsize']*1024) && $mybb->settings['avatarsize'] > 0)

	{

	{

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

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

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

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

	}

// Lets just double check that it exists
if(!file_exists($mybb->settings['avataruploadpath']."/".$filename))
{
$ret['error'] = $lang->error_uploadfailed;
return $ret;

	}

// Lets just double check that it exists
if(!file_exists($mybb->settings['avataruploadpath']."/".$filename))
{
$ret['error'] = $lang->error_uploadfailed;
return $ret;

	}

// Check if this is a valid image or not

	}

// Check if this is a valid image or not

Zeile 150Zeile 175
	{
case "image/gif":
$img_type = 1;

	{
case "image/gif":
$img_type = 1;

			break;

			break;

		case "image/jpeg":
case "image/x-jpg":
case "image/x-jpeg":
case "image/pjpeg":

		case "image/jpeg":
case "image/x-jpg":
case "image/x-jpeg":
case "image/pjpeg":

 
		case "image/jpg":

			$img_type = 2;
break;
case "image/png":

			$img_type = 2;
break;
case "image/png":

Zeile 243Zeile 269
	}
$ext = get_extension($attachment['name']);
// Check if we have a valid extension

	}
$ext = get_extension($attachment['name']);
// Check if we have a valid extension

	$query = $db->simple_select(TABLE_PREFIX."attachtypes", "*", "extension='$ext'");

	$query = $db->simple_select(TABLE_PREFIX."attachtypes", "*", "extension='".$db->escape_string($ext)."'");

	$attachtype = $db->fetch_array($query);
if(!$attachtype['atid'])
{

	$attachtype = $db->fetch_array($query);
if(!$attachtype['atid'])
{

Zeile 263Zeile 289
		$query = $db->simple_select(TABLE_PREFIX."attachments", "SUM(filesize) AS ausage", "uid='".$mybb->user['uid']."'");
$usage = $db->fetch_array($query);
$usage = $usage['ausage']+$attachment['size'];

		$query = $db->simple_select(TABLE_PREFIX."attachments", "SUM(filesize) AS ausage", "uid='".$mybb->user['uid']."'");
$usage = $db->fetch_array($query);
$usage = $usage['ausage']+$attachment['size'];

		if($usage > ($mybb->usergroup['attachquota']*1000))

		if($usage > ($mybb->usergroup['attachquota']*1024))

		{

		{

			$friendlyquota = get_friendly_size($mybb->usergroup['attachquota']*1000);

			$friendlyquota = get_friendly_size($mybb->usergroup['attachquota']*1024);

			$ret['error'] = sprintf($lang->error_reachedattachquota, $friendlyquota);
return $ret;
}

			$ret['error'] = sprintf($lang->error_reachedattachquota, $friendlyquota);
return $ret;
}

Zeile 330Zeile 356
			case "image/x-jpg":
case "image/x-jpeg":
case "image/pjpeg":

			case "image/x-jpg":
case "image/x-jpeg":
case "image/pjpeg":

 
			case "image/jpg":

				$img_type = 2;
break;
case "image/png":

				$img_type = 2;
break;
case "image/png":

Zeile 370Zeile 397
	}

$db->insert_query(TABLE_PREFIX."attachments", $attacharray);

	}

$db->insert_query(TABLE_PREFIX."attachments", $attacharray);

 
	
if($attacharray['pid'] > 0)
{
$post = get_post($attacharray['pid']);
update_thread_counters($post['tid'], array("attachmentcount" => +1));
}


$aid = $db->insert_id();
$ret['aid'] = $aid;


$aid = $db->insert_id();
$ret['aid'] = $aid;