diff options
Diffstat (limited to 'phpBB/includes')
-rwxr-xr-x | phpBB/includes/emailer.php | 2 | ||||
-rw-r--r-- | phpBB/includes/functions_display.php | 39 | ||||
-rw-r--r-- | phpBB/includes/functions_posting.php | 369 | ||||
-rw-r--r-- | phpBB/includes/message_parser.php | 2 |
4 files changed, 27 insertions, 385 deletions
diff --git a/phpBB/includes/emailer.php b/phpBB/includes/emailer.php index f0d330dfbe..594e1e386d 100755 --- a/phpBB/includes/emailer.php +++ b/phpBB/includes/emailer.php @@ -208,7 +208,7 @@ class emailer } // Build header - $this->extra_headers = (($this->replyto !='') ? "Reply-to: <$this->replyto>\r\n" : '') . (($this->from != '') ? "From: <$this->from>\r\n" : "From: <" . $config['board_email'] . ">\r\n") . "Return-Path: <" . $config['board_email'] . ">\r\nMessage-ID: <" . md5(uniqid(time())) . "@" . $config['server_name'] . ">\r\nMIME-Version: 1.0\r\nContent-type: text/plain; charset=" . $this->encoding . "\r\nContent-transfer-encoding: 8bit\r\nDate: " . gmdate('D, d M Y H:i:s Z', time()) . "\r\nX-Priority: 3\r\nX-MSMail-Priority: Normal\r\nX-Mailer: PHP\r\nX-MimeOLE: Produced By phpBB2\r\n" . trim($this->extra_headers) . (($cc != '') ? "Cc:$cc\r\n" : '') . (($bcc != '') ? "Bcc:$bcc\r\n" : ''); + $this->extra_headers = (($this->replyto !='') ? "Reply-to: <$this->replyto>\r\n" : '') . (($this->from != '') ? "From: <$this->from>\r\n" : "From: <" . $config['board_email'] . ">\r\n") . "Return-Path: <" . $config['board_email'] . ">\r\nMessage-ID: <" . md5(uniqid(time())) . "@" . $config['server_name'] . ">\r\nMIME-Version: 1.0\r\nContent-type: text/plain; charset=" . $this->encoding . "\r\nContent-transfer-encoding: 8bit\r\nDate: " . gmdate('D, d M Y H:i:s Z', time()) . "\r\nX-Priority: 3\r\nX-MSMail-Priority: Normal\r\nX-Mailer: PHP\r\nX-MimeOLE: Produced By phpBB2\r\n" . $this->extra_headers . (($cc != '') ? "Cc:$cc\r\n" : '') . (($bcc != '') ? "Bcc:$bcc\r\n" : ''); // Send message ... removed $this->encode() from subject for time being if (!$this->use_queue) diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index e9d9dbd6bd..e80d29c89f 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -386,26 +386,19 @@ function display_attachments($attachment_data, &$update_count, $force_physical = $filesize = $attachment['filesize']; $size_lang = ($filesize >= 1048576) ? $user->lang['MB'] : ( ($filesize >= 1024) ? $user->lang['KB'] : $user->lang['BYTES'] ); - if ($filesize >= 1048576) - { - $filesize = (round((round($filesize / 1048576 * 100) / 100), 2)); - } - else if ($filesize >= 1024) - { - $filesize = (round((round($filesize / 1024 * 100) / 100), 2)); - } + $filesize = ($filesize >= 1048576) ? round((round($filesize / 1048576 * 100) / 100), 2) : (($filesize >= 1024) ? round((round($filesize / 1024 * 100) / 100), 2) : $filesize); $display_name = $attachment['real_filename']; $comment = stripslashes(trim(str_replace("\n", '<br />', $attachment['comment']))); - $denied = false; + $denied = FALSE; if (!in_array($attachment['extension'], $extensions['_allowed_'])) { - $denied = true; + $denied = TRUE; $template->assign_block_vars('postrow.attachment', array( - 'IS_DENIED' => true, + 'IS_DENIED' => TRUE, 'L_DENIED' => sprintf($user->lang['EXTENSION_DISABLED_AFTER_POSTING'], $attachment['extension'])) ); @@ -431,7 +424,7 @@ function display_attachments($attachment_data, &$update_count, $force_physical = { if ($config['img_link_width'] || $config['img_link_height']) { - list($width, $height) = image_getdimension($filename); + list($width, $height) = getimagesize($filename); $display_cat = (!$width && !$height) ? IMAGE_CAT : (($width <= $config['img_link_width'] && $height <= $config['img_link_height']) ? IMAGE_CAT : NONE_CAT); } @@ -440,22 +433,15 @@ function display_attachments($attachment_data, &$update_count, $force_physical = { $display_cat = NONE_CAT; } - } + } } switch ($display_cat) { // Images case IMAGE_CAT: - if (!empty($config['ftp_upload']) && trim($config['upload_dir']) == '' && !$force_physical) - { - $img_source = $phpbb_root_path . "download.$phpEx$SID&id=" . $attachment['attach_id']; - } - else - { - $img_source = $filename; - $update_count[] = $attachment['attach_id']; - } + $img_source = $filename; + $update_count[] = $attachment['attach_id']; $l_downloaded_viewed = $user->lang['VIEWED']; $download_link = $img_source; @@ -463,14 +449,7 @@ function display_attachments($attachment_data, &$update_count, $force_physical = // Images, but display Thumbnail case THUMB_CAT: - if (!empty($config['use_ftp_upload']) && trim($config['upload_dir']) == '' && !$force_physical) - { - $thumb_source = $phpbb_root_path . "download.$phpEx$SID&id=" . $attachment['attach_id'] . '&thumb=1'; - } - else - { - $thumb_source = $thumbnail_filename; - } + $thumb_source = $thumbnail_filename; $l_downloaded_viewed = $user->lang['VIEWED']; $download_link = (!$force_physical) ? $phpbb_root_path . "download.$phpEx$SID&id=" . $attachment['attach_id'] : $filename; diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 8f89d2669b..b27c88c3cf 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -460,14 +460,7 @@ function upload_attachment($filename) { $size_lang = ($allowed_filesize >= 1048576) ? $user->lang['MB'] : ( ($allowed_filesize >= 1024) ? $user->lang['KB'] : $user->lang['BYTES'] ); - if ($allowed_filesize >= 1048576) - { - $allowed_filesize = round($allowed_filesize / 1048576 * 100) / 100; - } - else if($allowed_filesize >= 1024) - { - $allowed_filesize = round($allowed_filesize / 1024 * 100) / 100; - } + $allowed_filesize = ($allowed_filesize >= 1048576) ? round($allowed_filesize / 1048576 * 100) / 100 : (($allowed_filesize >= 1024) ? round($allowed_filesize / 1024 * 100) / 100 : $allowed_filesize); $filedata['error'][] = sprintf($user->lang['ATTACHMENT_TOO_BIG'], $allowed_filesize, $size_lang); $filedata['post_attach'] = false; @@ -502,27 +495,8 @@ function upload_attachment($filename) $filedata['thumbnail'] = 1; } - // Upload Attachment - if (!$config['use_ftp_upload']) - { - // Descide the Upload method - if ( @ini_get('open_basedir') ) - { - $upload_mode = 'move'; - } - else if ( @ini_get('safe_mode') ) - { - $upload_mode = 'move'; - } - else - { - $upload_mode = 'copy'; - } - } - else - { - $upload_mode = 'ftp'; - } + // Descide the Upload method + $upload_mode = (@ini_get('open_basedir') || @ini_get('safe_mode')) ? 'move' : 'copy'; // Ok, upload the File $result = move_uploaded_attachment($upload_mode, $file, $filedata); @@ -546,7 +520,6 @@ function move_uploaded_attachment($upload_mode, $source_filename, &$filedata) switch ($upload_mode) { case 'copy': - if ( !@copy($source_filename, $config['upload_dir'] . '/' . $destination_filename) ) { if ( !@move_uploaded_file($source_filename, $config['upload_dir'] . '/' . $destination_filename) ) @@ -567,41 +540,10 @@ function move_uploaded_attachment($upload_mode, $source_filename, &$filedata) } @chmod($config['upload_dir'] . '/' . $destination_filename, 0666); break; - - case 'ftp': -/* - $conn_id = init_ftp(); - - // Binary or Ascii ? - $mode = FTP_BINARY; - if ( (preg_match("/text/i", $filedata['mimetype'])) || (preg_match("/html/i", $filedata['mimetype'])) ) - { - $mode = FTP_ASCII; - } - - $res = @ftp_put($conn_id, $destination_filename, $source_filename, $mode); - - if (!$res) - { - @ftp_quit($conn_id); - return sprintf($user->lang['Ftp_error_upload'], $config['ftp_path']); - } - - @ftp_site($conn_id, 'CHMOD 0644 ' . $destination_filename); - @ftp_quit($conn_id); - break; -*/ } if ($filedata['thumbnail']) { -/* if ($upload_mode == 'ftp') - { - $source = $source_filename; - $destination = 'thumbs/t_' . $destination_filename; - } - else - {*/ $source = $config['upload_dir'] . '/' . $destination_filename; $destination = $config['upload_dir'] . '/thumbs/t_' . $destination_filename; @@ -621,271 +563,28 @@ function phpbb_unlink($filename, $mode = 'file', $use_ftp = false) { global $config, $user; - if (!$use_ftp) - { - $filename = ($mode == 'thumbnail') ? $config['upload_dir'] . '/thumbs/t_' . $filename : $config['upload_dir'] . '/' . $filename; - $deleted = @unlink($filename); + $filename = ($mode == 'thumbnail') ? $config['upload_dir'] . '/thumbs/t_' . $filename : $config['upload_dir'] . '/' . $filename; + $deleted = @unlink($filename); - if (@file_exists($filename)) - { - $filesys = eregi_replace('/','\\', $filename); - $deleted = @system("del $filesys"); - - if (@file_exists($filename)) - { - @chmod($filename, 0777); - $deleted = @unlink($filename); - if (!$deleted) - { - $deleted = @system("del $filename"); - } - } - } - } - else + if (file_exists($filename)) { -/* $conn_id = attach_init_ftp($mode); + $filesys = eregi_replace('/','\\', $filename); + $deleted = @system("del $filesys"); - if ($mode == MODE_THUMBNAIL) + if (file_exists($filename)) { - $filename = 't_' . $filename; - } - - $res = @ftp_delete($conn_id, $filename); - if (!$res) - { - if (defined('DEBUG_EXTRA')) + @chmod($filename, 0777); + $deleted = @unlink($filename); + if (!$deleted) { - $add = ( $mode == MODE_THUMBNAIL ) ? ('/' . THUMB_DIR) : ''; - message_die(GENERAL_ERROR, sprintf($lang['Ftp_error_delete'], $config['ftp_path'] . $add)); + $deleted = @system("del $filename"); } - - return $deleted; } - - @ftp_quit($conn_id); - - $deleted = TRUE;*/ } return $deleted; } -// Read DWord (4 Bytes) from File -function read_dword($fp) -{ - $data = fread($fp, 4); - $value = ord($data[0]) + (ord($data[1])<<8)+(ord($data[2])<<16)+(ord($data[3])<<24); - if ($value >= 4294967294) - { - $value -= 4294967296; - } - return $value; -} - -// Read Word (2 Bytes) from File - Note: It's an Intel Word -function read_word($fp) -{ - $data = fread($fp, 2); - return ord($data[1]) * 256 + ord($data[0]); -} - -// Read Byte -function read_byte($fp) -{ - $data = fread($fp, 1); - return ord($data); -} - - -// Get Image Dimensions... only a test for now, used within create_thumbnail -function image_getdimension($file) -{ - $size = @getimagesize($file); - - if ($size[0] != 0 || $size[1] != 0) - { - return $size; - } - - // Try to get the Dimension manually, depending on the mimetype - if (!($fp = @fopen($file, 'rb'))) - { - return $size; - } - - $error = FALSE; - - // BMP - IMAGE - $tmp_str = fread($fp, 2); - if ($tmp_str == 'BM') - { - $length = read_dword($fp); - - if ($length <= 6) - { - $error = TRUE; - } - - if (!$error) - { - $i = read_dword($fp); - if ($i != 0) - { - $error = TRUE; - } - } - - if (!$error) - { - $i = read_dword($fp); - - if ($i != 0x3E && $i != 0x76 && $i != 0x436 && $i != 0x36) - { - $error = TRUE; - } - } - - if (!$error) - { - $tmp_str = fread($fp, 4); - $width = read_dword($fp); - $height = read_dword($fp); - - if ($width > 3000 || $height > 3000) - { - $error = TRUE; - } - } - } - else - { - $error = TRUE; - } - - if (!$error) - { - fclose($fp); - return array( - $width, - $height, - '6' - ); - } - - $error = FALSE; - fclose($fp); - - // GIF - IMAGE - $fp = @fopen($file, 'rb'); - - $tmp_str = fread($fp, 3); - - if ($tmp_str == 'GIF') - { - $tmp_str = fread($fp, 3); - $width = read_word($fp); - $height = read_word($fp); - - $info_byte = fread($fp, 1); - $info_byte = ord($info_byte); - if (($info_byte & 0x80) != 0x80 && ($info_byte & 0x80) != 0) - { - $error = TRUE; - } - - if (!$error) - { - if (($info_byte & 8) != 0) - { - $error = TRUE; - } - - } - } - else - { - $error = TRUE; - } - - if (!$error) - { - fclose($fp); - return array( - $width, - $height, - '1' - ); - } - - $error = FALSE; - fclose($fp); - - // JPG - IMAGE - $fp = @fopen($file, 'rb'); - - $tmp_str = fread($fp, 4); - $w1 = read_word($fp); - if (intval($w1) < 16) - { - $error = TRUE; - } - - if (!$error) - { - $tmp_str = fread($fp, 4); - if ($tmp_str == 'JFIF') - { - $o_byte = fread($fp, 1); - if (intval($o_byte) != 0) - { - $error = TRUE; - } - - if (!$error) - { - $str = fread($fp, 2); - $b = read_byte($fp); - - if ($b != 0 && $b != 1 && $b != 2) - { - $error = TRUE; - } - } - - if (!$error) - { - $width = read_word($fp); - $height = read_word($fp); - - if ($width <= 0 || $height <= 0) - { - $error = TRUE; - } - } - } - } - else - { - $error = TRUE; - } - - if (!$error) - { - fclose($fp); - return array( - $width, - $height, - '2' - ); - } - - $error = FALSE; - fclose($fp); - - return $size; -} - // Calculate the needed size for Thumbnail // I am sure i had this grabbed from some site... source: unknown function get_img_size_format($width, $height) @@ -956,16 +655,16 @@ function create_thumbnail($source, $new_file, $mimetype) global $config; $source = realpath($source); - $min_filesize = intval($config['img_min_thumb_filesize']); + $min_filesize = (int) $config['img_min_thumb_filesize']; $img_filesize = (file_exists($source)) ? @filesize($source) : FALSE; - if (!$img_filesize || $img_filesize <= $min_filesize) + if (!$img_filesize || $img_filesize <= $min_filesize) { return FALSE; } - $size = image_getdimension($source); + $size = getimagesize($source); if ($size[0] == 0 && $size[1] == 0) { @@ -977,31 +676,6 @@ function create_thumbnail($source, $new_file, $mimetype) $tmp_path = ''; $old_file = ''; -/* - if ($config['allow_ftp_upload']) - { - $old_file = $new_file; - - $tmp_path = explode('/', $source); - $tmp_path[count($tmp_path)-1] = ''; - $tmp_path = implode('/', $tmp_path); - - if ($tmp_path == '') - { - $tmp_path = '/tmp'; - } - - $value = trim($tmp_path); - - if ($value[strlen($value)-1] == '/') - { - $value[strlen($value)-1] = ' '; - } - - $new_file = trim($value) . '/t00000'; - } -*/ - $used_imagick = FALSE; if ($config['img_imagick']) @@ -1054,17 +728,6 @@ function create_thumbnail($source, $new_file, $mimetype) return FALSE; } -/* if (intval($config['allow_ftp_upload'])) - { - $result = ftp_file($new_file, $old_file, $this->type, TRUE); // True for disable error-mode - if (!$result) - { - return (FALSE); - } - } - else - {*/ - @chmod($new_file, 0666); return TRUE; diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php index 4e04cec0e8..5d58845303 100644 --- a/phpBB/includes/message_parser.php +++ b/phpBB/includes/message_parser.php @@ -672,7 +672,7 @@ class parse_message $error = array(); $num_attachments = count($this->attachment_data); - $this->filename_data['filecomment'] = (isset($_POST['filecomment'])) ? trim( strip_tags($_POST['filecomment'])) : ''; + $this->filename_data['filecomment'] = (isset($_POST['filecomment'])) ? trim(strip_tags($_POST['filecomment'])) : ''; $this->filename_data['filename'] = ($_FILES['fileupload']['name'] != 'none') ? trim($_FILES['fileupload']['name']) : ''; $add_file = (isset($_POST['add_file'])) ? TRUE : FALSE; |