Zeile 6 | Zeile 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 45 | Zeile 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 60 | Zeile 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 81 | Zeile 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 95 | Zeile 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 130 | Zeile 145 |
---|
$query = $db->query("SELECT * FROM ".TABLE_PREFIX."attachtypes WHERE extension='$ext'"); $attachtype = $db->fetch_array($query); if(!$attachtype['atid'])
|
$query = $db->query("SELECT * FROM ".TABLE_PREFIX."attachtypes WHERE extension='$ext'"); $attachtype = $db->fetch_array($query); if(!$attachtype['atid'])
|
{
| {
|
$ret['error'] = $lang->error_attachtype;
|
$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'] != "")
|
{
| {
|
$ret['error'] = sprintf($lang->error_attachsize, $attachtype['maxsize']); return $ret; }
| $ret['error'] = sprintf($lang->error_attachsize, $attachtype['maxsize']); return $ret; }
|
Zeile 152 | Zeile 167 |
---|
$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
|
}
// 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'))");
| $query = $db->query("SELECT * FROM ".TABLE_PREFIX."attachments WHERE filename='".addslashes($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 179 | Zeile 194 |
---|
$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;
|