Zeile 6 | Zeile 6 |
---|
* Website: http://www.mybboard.net * License: http://www.mybboard.net/about/license *
|
* Website: http://www.mybboard.net * License: http://www.mybboard.net/about/license *
|
* $Id: functions_upload.php 4036 2008-07-24 11:35:12Z ZiNgaBuRgA $
| * $Id: functions_upload.php 4337 2009-03-30 01:21:51Z Tikitiki $
|
*/
| */
|
Zeile 36 | Zeile 36 |
---|
$plugins->run_hooks("remove_attachment_do_delete", $attachment); $db->delete_query("attachments", "aid='{$attachment['aid']}'");
|
$plugins->run_hooks("remove_attachment_do_delete", $attachment); $db->delete_query("attachments", "aid='{$attachment['aid']}'");
|
@unlink($mybb->settings['uploadspath']."/".$attachment['attachname']);
| if(defined('IN_ADMINCP')) { $uploadpath = '../'.$mybb->settings['uploadspath']; } else { $uploadpath = $mybb->settings['uploadspath']; } @unlink($uploadpath."/".$attachment['attachname']);
|
if($attachment['thumbnail']) {
|
if($attachment['thumbnail']) {
|
@unlink($mybb->settings['uploadspath']."/".$attachment['thumbnail']);
| @unlink($uploadpath."/".$attachment['thumbnail']);
|
}
$date_directory = explode('/', $attachment['attachname']);
|
}
$date_directory = explode('/', $attachment['attachname']);
|
if(@is_dir($mybb->settings['uploadspath']."/".$date_directory[0]))
| if(@is_dir($uploadpath."/".$date_directory[0]))
|
{
|
{
|
@rmdir($mybb->settings['uploadspath']."/".$date_directory[0]);
| @rmdir($uploadpath."/".$date_directory[0]);
|
}
if($attachment['visible'] == 1 && $pid)
|
}
if($attachment['visible'] == 1 && $pid)
|
{
| {
|
$post = get_post($pid); update_thread_counters($post['tid'], array("attachmentcount" => "-1")); }
| $post = get_post($pid); update_thread_counters($post['tid'], array("attachmentcount" => "-1")); }
|
Zeile 77 | Zeile 87 |
---|
else { $query = $db->simple_select("attachments", "*", "pid='$pid'");
|
else { $query = $db->simple_select("attachments", "*", "pid='$pid'");
|
| } if(defined('IN_ADMINCP')) { $uploadpath = '../'.$mybb->settings['uploadspath']; } else { $uploadpath = $mybb->settings['uploadspath'];
|
}
$num_attachments = 0;
| }
$num_attachments = 0;
|
Zeile 91 | Zeile 110 |
---|
$db->delete_query("attachments", "aid='".$attachment['aid']."'");
|
$db->delete_query("attachments", "aid='".$attachment['aid']."'");
|
@unlink($mybb->settings['uploadspath']."/".$attachment['attachname']);
| @unlink($uploadpath."/".$attachment['attachname']);
|
if($attachment['thumbnail']) {
|
if($attachment['thumbnail']) {
|
@unlink($mybb->settings['uploadspath']."/".$attachment['thumbnail']);
| @unlink($uploadpath."/".$attachment['thumbnail']);
|
}
$date_directory = explode('/', $attachment['attachname']);
|
}
$date_directory = explode('/', $attachment['attachname']);
|
if(@is_dir($mybb->settings['uploadspath']."/".$date_directory[0]))
| if(@is_dir($uploadpath."/".$date_directory[0]))
|
{
|
{
|
@rmdir($mybb->settings['uploadspath']."/".$date_directory[0]);
| @rmdir($uploadpath."/".$date_directory[0]);
|
} }
| } }
|
Zeile 133 | Zeile 152 |
---|
if($dir) { while($file = @readdir($dir))
|
if($dir) { while($file = @readdir($dir))
|
{
| {
|
$plugins->run_hooks("remove_avatars_do_delete", $file); if(preg_match("#avatar_".$uid."\.#", $file) && is_file($avatarpath."/".$file) && $file != $exclude)
| $plugins->run_hooks("remove_avatars_do_delete", $file); if(preg_match("#avatar_".$uid."\.#", $file) && is_file($avatarpath."/".$file) && $file != $exclude)
|
Zeile 143 | Zeile 162 |
---|
}
@closedir($dir);
|
}
@closedir($dir);
|
}
| }
|
}
/**
| }
/**
|
Zeile 160 | Zeile 179 |
---|
if(!$uid) { $uid = $mybb->user['uid'];
|
if(!$uid) { $uid = $mybb->user['uid'];
|
}
| }
|
if(!$avatar['name'] || !$avatar['tmp_name']) { $avatar = $_FILES['avatarupload'];
|
if(!$avatar['name'] || !$avatar['tmp_name']) { $avatar = $_FILES['avatarupload'];
|
}
| }
|
if(!is_uploaded_file($avatar['tmp_name'])) { $ret['error'] = $lang->error_uploadfailed;
|
if(!is_uploaded_file($avatar['tmp_name'])) { $ret['error'] = $lang->error_uploadfailed;
|
return $ret; }
| return $ret; }
|
// Check we have a valid extension $ext = get_extension(my_strtolower($avatar['name']));
|
// Check we have a valid extension $ext = get_extension(my_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; }
|
if(defined('IN_ADMINCP')) { $avatarpath = '../'.$mybb->settings['avataruploadpath']; $lang->load("messages", true);
|
if(defined('IN_ADMINCP')) { $avatarpath = '../'.$mybb->settings['avataruploadpath']; $lang->load("messages", true);
|
}
| }
|
else { $avatarpath = $mybb->settings['avataruploadpath'];
|
else { $avatarpath = $mybb->settings['avataruploadpath'];
|
}
| }
|
$filename = "avatar_".$uid.".".$ext; $file = upload_file($avatar, $avatarpath, $filename); if($file['error']) { @unlink($avatarpath."/".$filename);
|
$filename = "avatar_".$uid.".".$ext; $file = upload_file($avatar, $avatarpath, $filename); if($file['error']) { @unlink($avatarpath."/".$filename);
|
$ret['error'] = $lang->error_uploadfailed;
| $ret['error'] = $lang->error_uploadfailed;
|
return $ret; }
// Lets just double check that it exists if(!file_exists($avatarpath."/".$filename))
|
return $ret; }
// Lets just double check that it exists if(!file_exists($avatarpath."/".$filename))
|
{ $ret['error'] = $lang->error_uploadfailed; @unlink($avatarpath."/".$filename); return $ret; }
| { $ret['error'] = $lang->error_uploadfailed; @unlink($avatarpath."/".$filename); return $ret; }
|
// Check if this is a valid image or not $img_dimensions = @getimagesize($avatarpath."/".$filename); if(!is_array($img_dimensions))
|
// Check if this is a valid image or not $img_dimensions = @getimagesize($avatarpath."/".$filename); if(!is_array($img_dimensions))
|
{
| {
|
@unlink($avatarpath."/".$filename); $ret['error'] = $lang->error_uploadfailed; return $ret;
| @unlink($avatarpath."/".$filename); $ret['error'] = $lang->error_uploadfailed; return $ret;
|
Zeile 223 | Zeile 242 |
---|
{ list($maxwidth, $maxheight) = @explode("x", $mybb->settings['maxavatardims']); if(($maxwidth && $img_dimensions[0] > $maxwidth) || ($maxheight && $img_dimensions[1] > $maxheight))
|
{ list($maxwidth, $maxheight) = @explode("x", $mybb->settings['maxavatardims']); if(($maxwidth && $img_dimensions[0] > $maxwidth) || ($maxheight && $img_dimensions[1] > $maxheight))
|
{
| {
|
// Automatic resizing enabled? if($mybb->settings['avatarresizing'] == "auto" || ($mybb->settings['avatarresizing'] == "user" && $mybb->input['auto_resize'] == 1)) {
| // Automatic resizing enabled? if($mybb->settings['avatarresizing'] == "auto" || ($mybb->settings['avatarresizing'] == "user" && $mybb->input['auto_resize'] == 1)) {
|
Zeile 249 | Zeile 268 |
---|
$ret['error'] = $lang->sprintf($lang->error_avatartoobig, $maxwidth, $maxheight); if($mybb->settings['avatarresizing'] == "user") {
|
$ret['error'] = $lang->sprintf($lang->error_avatartoobig, $maxwidth, $maxheight); if($mybb->settings['avatarresizing'] == "user") {
|
$ret['error'] .= "<br /<br />".$lang->error_avataruserresize;
| $ret['error'] .= "<br /><br />".$lang->error_avataruserresize;
|
} @unlink($avatarpath."/".$filename); return $ret;
| } @unlink($avatarpath."/".$filename); return $ret;
|
Zeile 314 | Zeile 333 |
---|
function upload_attachment($attachment) { global $db, $theme, $templates, $posthash, $pid, $tid, $forum, $mybb, $lang, $plugins, $cache;
|
function upload_attachment($attachment) { global $db, $theme, $templates, $posthash, $pid, $tid, $forum, $mybb, $lang, $plugins, $cache;
|
|
|
$posthash = $db->escape_string($mybb->input['posthash']);
if(isset($attachment['error']) && $attachment['error'] != 0)
| $posthash = $db->escape_string($mybb->input['posthash']);
if(isset($attachment['error']) && $attachment['error'] != 0)
|
Zeile 385 | Zeile 404 |
---|
}
// 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->simple_select("attachments", "*", "filename='".$db->escape_string($attachment['name'])."' AND (posthash='$posthash' OR (pid='$pid' AND pid!='0'))");
| $query = $db->simple_select("attachments", "*", "filename='".$db->escape_string($attachment['name'])."' AND (posthash='$posthash' OR (pid='".intval($pid)."' AND pid!='0'))");
|
$prevattach = $db->fetch_array($query); if($prevattach['aid']) {
| $prevattach = $db->fetch_array($query); if($prevattach['aid']) {
|
Zeile 403 | Zeile 422 |
---|
{ $month_dir = ''; }
|
{ $month_dir = ''; }
|
}
| } // If safe_mode is enabled, don't attempt to use the monthly directories as it won't work if(ini_get('safe_mode') == 1 || strtolower(ini_get('safe_mode')) == 'on') { $month_dir = ''; }
|
// All seems to be good, lets move the attachment!
|
// All seems to be good, lets move the attachment!
|
$filename = "post_".$mybb->user['uid']."_".TIME_NOW.".attach";
| $filename = "post_".$mybb->user['uid']."_".TIME_NOW."_".md5(uniqid(rand(),�true)).".attach";
|
$file = upload_file($attachment, $mybb->settings['uploadspath']."/".$month_dir, $filename);
|
$file = upload_file($attachment, $mybb->settings['uploadspath']."/".$month_dir, $filename);
|
| // Failed to create the attachment in the monthly directory, just throw it in the main directory if($file['error'] && $month_dir) { $file = upload_file($attachment, $mybb->settings['uploadspath'].'/', $filename); }
|
if($month_dir) {
| if($month_dir) {
|
Zeile 555 | Zeile 588 |
---|
$upload['error'] = 2; return $upload; }
|
$upload['error'] = 2; return $upload; }
|
@my_chmod($path."/".$filename, 0644);
| @my_chmod($path."/".$filename, '0644');
|
$upload['filename'] = $filename; $upload['path'] = $path; $upload['type'] = $file['type'];
| $upload['filename'] = $filename; $upload['path'] = $path; $upload['type'] = $file['type'];
|