Vergleich inc/functions_upload.php - 1.00 - 1.02

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 6Zeile 6
 * Website: http://www.mybboard.com
* License: http://www.mybboard.com/eula.html
*

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

 * $Id$

 * $Id: functions_upload.php 1009 2005-12-21 18:53:48Z dennis $

 */

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

 */

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

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









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

	$db->query("DELETE FROM ".TABLE_PREFIX."attachments WHERE aid='".$attachment['aid']."'");
@unlink($mybb->settings['uploadspath']."/".$attachment['attachname']);
if($attachment['thumbnail'])
{
@unlink($mybb->settings['uploadspath']."/".$attachment['thumbnail']);

	$db->query("DELETE FROM ".TABLE_PREFIX."attachments WHERE aid='".$attachment['aid']."'");
@unlink($mybb->settings['uploadspath']."/".$attachment['attachname']);
if($attachment['thumbnail'])
{
@unlink($mybb->settings['uploadspath']."/".$attachment['thumbnail']);

	}

	}

}

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

}

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

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








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

	while($attachment = $db->fetch_array($query))
{
$db->query("DELETE FROM ".TABLE_PREFIX."attachments WHERE aid='".$attachment['aid']."'");

	while($attachment = $db->fetch_array($query))
{
$db->query("DELETE FROM ".TABLE_PREFIX."attachments WHERE aid='".$attachment['aid']."'");

Zeile 45Zeile 60
	{
while($file = @readdir($dir))
{

	{
while($file = @readdir($dir))
{

			if(preg_match("#avatar_".$uid."#", $file) && is_file($mybb->settings['avataruploadpath']."/".$file) && $file != $exclude)

			if(preg_match("#avatar_".$uid."\.#", $file) && is_file($mybb->settings['avataruploadpath']."/".$file) && $file != $exclude)

			{
@unlink($mybb->settings['avataruploadpath']."/".$file);
}

			{
@unlink($mybb->settings['avataruploadpath']."/".$file);
}

Zeile 60Zeile 75
	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 = getextention(strtolower($avatar['name']));

	}

// Check we have a valid extension
$ext = getextention(strtolower($avatar['name']));

	if(!preg_match("#[gif|jpg|jpeg|jpe|bmp|png]$#i", $ext)) {

	if(!preg_match("#(gif|jpg|jpeg|jpe|bmp|png)$#i", $ext)) {

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

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

Zeile 81Zeile 96

$filename = "avatar_".$mybb->user['uid'].".".$ext;
$file = upload_file($avatar, $mybb->settings['avataruploadpath'], $filename);


$filename = "avatar_".$mybb->user['uid'].".".$ext;
$file = upload_file($avatar, $mybb->settings['avataruploadpath'], $filename);

	if($file['error'])
{
$ret['error'] = $lang->error_uploadfailed;
return $ret;

	if($file['error'])
{
$ret['error'] = $lang->error_uploadfailed;
return $ret;

	}

// Lets just double check that it exists

	}

// Lets just double check that it exists

Zeile 95Zeile 110
	}

// If we've got this far check dimensions

	}

// If we've got this far check dimensions

	if(preg_match("#gif|jpg|jpeg|jpe|bmp|png#i", $ext) && $mybb->settings['maxavatardims'] != "")

	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($width, $height) = @getimagesize($mybb->settings['avataruploadpath']."/".$filename);
list($maxwidth, $maxheight) = @explode("x", $mybb->settings['maxavatardims']);

Zeile 119Zeile 134
	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']))
{

Zeile 152Zeile 168
			$friendlyquota = getfriendlysize($mybb->usergroup['attachquota']*1000);
$ret['error'] = sprintf($lang->error_reachedattachquota, $friendlyquota);
return $ret;

			$friendlyquota = getfriendlysize($mybb->usergroup['attachquota']*1000);
$ret['error'] = sprintf($lang->error_reachedattachquota, $friendlyquota);
return $ret;

		}
}

		}
}


// Check if an attachment with this name is already in the post
$query = $db->query("SELECT * FROM ".TABLE_PREFIX."attachments WHERE filename='".$attachment['name']."' AND (posthash='$posthash' OR (pid='$pid' AND pid!='0'))");


// Check if an attachment with this name is already in the post
$query = $db->query("SELECT * FROM ".TABLE_PREFIX."attachments WHERE filename='".$attachment['name']."' AND (posthash='$posthash' OR (pid='$pid' AND pid!='0'))");

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

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

 

// Generate the array for the insert_query
$attacharray = array(
"pid" => $pid,
"posthash" => $posthash,
"uid" => $mybb->user['uid'],
"filename" => addslashes($file['original_filename']),
"filetype" => $file['type'],
"filesize" => $file['size'],
"attachname" => $filename,
"downloads" => 0,
);


// 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")

	{

	{

		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']);
if($thumbnail['filename'])

		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']);
if($thumbnail['filename'])

		{
$thumbadd = ",thumbnail";
$thumbadd2 = ",'".$thumbnail['filename']."'";

		{
$attacharray['thumbnail'] = $thumbnail['filename'];


		}
elseif($thumbnail['code'] == 4)
{

		}
elseif($thumbnail['code'] == 4)
{

			$thumbadd = ",thumbnail";
$thumbadd2 = ",'SMALL'";

			$attacharray['thumbnail'] = "SMALL";


		}
}
if($forum['modattachments'] == "yes" && $mybb->usergroup['cancp'] != "yes")

		}
}
if($forum['modattachments'] == "yes" && $mybb->usergroup['cancp'] != "yes")

	{
$attvisible = 0;

	{
$attacharray['visible'] = 0;

	}
else
{

	}
else
{

		$attvisible = 1;

		$attacharray['visible'] = 1;

	}

	}

	$db->query("INSERT INTO ".TABLE_PREFIX."attachments (aid,pid,posthash,uid,filename,filetype,filesize,attachname,downloads,visible$thumbadd) VALUES ('','$pid','$posthash','".$mybb->user['uid']."','".$file['original_filename']."','".$file['type']."','".$file['size']."','$filename','0','$attvisible'$thumbadd2)");



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


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

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