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 92 | Zeile 107 |
---|
{ $ret['error'] = $lang->error_uploadfailed; return $ret;
|
{ $ret['error'] = $lang->error_uploadfailed; return $ret;
|
}
| } // Check if this is a valid image or not $img_dimensions = @getimagesize($mybb->settings['avataruploadpath']."/".$filename); if(!is_array($img_dimensions)) { $ret['error'] = $lang->error_uploadfailed; return $ret; }
|
// 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($maxwidth, $maxheight) = @explode("x", $mybb->settings['maxavatardims']);
|
if(($maxwidth && $width > $maxwidth) || ($maxheight && $height > $maxheight))
| if(($maxwidth && $img_dimensions[0] > $maxwidth) || ($maxheight && $img_dimensions[1] > $maxheight))
|
{ $ret['error'] = sprintf($lang->error_avatartoobig, $maxwidth, $maxheight); @unlink($mybb->settings['avataruploadpath']."/".$filename);
| { $ret['error'] = sprintf($lang->error_avatartoobig, $maxwidth, $maxheight); @unlink($mybb->settings['avataruploadpath']."/".$filename);
|
Zeile 109 | Zeile 131 |
---|
// Everything is okay so lets delete old avatars for this user remove_avatars($mybb->user['uid'], $filename);
|
// Everything is okay so lets delete old avatars for this user remove_avatars($mybb->user['uid'], $filename);
|
|
|
$ret['avatar'] = $mybb->settings['avataruploadpath']."/".$filename; return $ret; }
| $ret['avatar'] = $mybb->settings['avataruploadpath']."/".$filename; return $ret; }
|
Zeile 119 | Zeile 141 |
---|
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 152 | Zeile 175 |
---|
$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'))"); $prevattach = $db->fetch_array($query);
| // 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'))"); $prevattach = $db->fetch_array($query);
|
Zeile 179 | Zeile 202 |
---|
$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;
|