Vergleich inc/functions_upload.php - 1.2.5 - 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 2598 2007-01-02 17:17:32Z 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 92Zeile 117
		@closedir($dir);
}
}

		@closedir($dir);
}
}





/**
* Upload a new avatar in to the file system
*

/**
* Upload a new avatar in to the file system
*

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)) {

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

Zeile 238Zeile 263
		return $ret;
}
if(!is_uploaded_file($attachment['tmp_name']) || empty($attachment['tmp_name']))

		return $ret;
}
if(!is_uploaded_file($attachment['tmp_name']) || empty($attachment['tmp_name']))

	{

	{

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

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

Zeile 264Zeile 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 372Zeile 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;