1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-08 01:36:57 +02:00

bump topic and orphan attachments

changes here and there...


git-svn-id: file:///svn/phpbb/trunk@4614 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Meik Sievertsen
2003-10-19 15:36:45 +00:00
parent de53ffabb4
commit e7c3370a04
13 changed files with 471 additions and 160 deletions

View File

@@ -652,7 +652,8 @@ function delete_attachments($post_id_array = -1, $attach_id_array = -1, $page =
$db->sql_freeresult($result);
}
// TODO - Return number of deleted attachments
// TODO
// Return number of deleted attachments
}
function delete_topic_shadows($max_age, $forum_id = '', $auto_sync = TRUE)
@@ -702,9 +703,11 @@ function delete_topic_shadows($max_age, $forum_id = '', $auto_sync = TRUE)
// Delete File
function phpbb_unlink($filename, $mode = 'file')
{
global $config, $user;
global $config, $user, $phpbb_root_path;
$filename = ($mode == 'thumbnail') ? $config['upload_dir'] . '/thumbs/t_' . $filename : $config['upload_dir'] . '/' . $filename;
$upload_dir = ($config['upload_dir'][0] == '/' || ($config['upload_dir'][0] != '/' && $config['upload_dir'][1] == ':')) ? $config['upload_dir'] : $phpbb_root_path . $config['upload_dir'];
$filename = ($mode == 'thumbnail') ? $upload_dir . '/thumbs/t_' . $filename : $upload_dir . '/' . $filename;
$deleted = @unlink($filename);
if (file_exists($filename))

View File

@@ -445,6 +445,8 @@ function display_attachments($attachment_data, &$update_count, $force_physical =
break;
}
$l_download_count = ($attachment['download_count'] == 0) ? $user->lang['DOWNLOAD_NONE'] : (($attachment['download_count'] == 1) ? sprintf($user->lang['DOWNLOAD_COUNT'], $attachment['download_count']) : sprintf($user->lang['DOWNLOAD_COUNTS'], $attachment['download_count']));
$template_array = array_merge($additional_array, array(
// 'IS_FLASH' => ($display_cat == SWF_CAT) ? true : false,
'IS_WM_STREAM' => ($display_cat == WM_CAT) ? true : false,
@@ -461,7 +463,7 @@ function display_attachments($attachment_data, &$update_count, $force_physical =
'UPLOAD_IMG' => $upload_image,
'L_DOWNLOADED_VIEWED' => $l_downloaded_viewed,
'L_DOWNLOAD_COUNT' => sprintf($user->lang['DOWNLOAD_NUMBER'], $attachment['download_count']))
'L_DOWNLOAD_COUNT' => $l_download_count)
);
$template->assign_block_vars('postrow.attachment', $template_array);

View File

@@ -47,7 +47,6 @@ function generate_smilies($mode, $forum_id)
FROM ' . SMILIES_TABLE . '
WHERE display_on_posting = 0';
$result = $db->sql_query_limit($sql, 1, 0, 3600);
$row = $db->sql_fetchrow($result);
if ($row = $db->sql_fetchrow($result))
{
@@ -194,7 +193,7 @@ function update_last_post_information($type, $id)
}
// Upload Attachment - filedata is generated here
function upload_attachment($filename)
function upload_attachment($filename, $local = false, $local_storage = '')
{
global $auth, $user, $config, $db;
@@ -208,8 +207,8 @@ function upload_attachment($filename)
}
$r_file = $filename;
$file = $_FILES['fileupload']['tmp_name'];
$filedata['mimetype'] = $_FILES['fileupload']['type'];
$file = (!$local) ? $_FILES['fileupload']['tmp_name'] : $local_storage;
$filedata['mimetype'] = (!$local) ? $_FILES['fileupload']['type'] : 'application/octet-stream';
// Opera add the name to the mime type
$filedata['mimetype'] = ( strstr($filedata['mimetype'], '; name') ) ? str_replace(strstr($filedata['mimetype'], '; name'), '', $filedata['mimetype']) : $filedata['mimetype'];
@@ -239,7 +238,7 @@ function upload_attachment($filename)
}
// check php upload-size
if ( ($file == 'none') )
if ($file == 'none')
{
$filedata['error'][] = (@ini_get('upload_max_filesize') == '') ? $user->lang['ATTACHMENT_PHP_SIZE_NA'] : sprintf($user->lang['ATTACHMENT_PHP_SIZE_OVERRUN'], @ini_get('upload_max_filesize'));
$filedata['post_attach'] = FALSE;
@@ -304,6 +303,7 @@ function upload_attachment($filename)
// Descide the Upload method
$upload_mode = (@ini_get('open_basedir') || @ini_get('safe_mode')) ? 'move' : 'copy';
$upload_mode = ($local) ? 'local' : $upload_mode;
// Ok, upload the File
$result = move_uploaded_attachment($upload_mode, $file, $filedata);
@@ -319,40 +319,50 @@ function upload_attachment($filename)
// Move/Upload File - could be used for Avatars too ?
function move_uploaded_attachment($upload_mode, $source_filename, &$filedata)
{
global $user, $config;
global $user, $config, $phpbb_root_path;
$upload_dir = ($config['upload_dir'][0] == '/' || ($config['upload_dir'][0] != '/' && $config['upload_dir'][1] == ':')) ? $config['upload_dir'] : $phpbb_root_path . $config['upload_dir'];
$destination_filename = $filedata['destination_filename'];
$thumbnail = (isset($filedata['thumbnail'])) ? $filedata['thumbnail'] : FALSE;
switch ($upload_mode)
{
case 'copy':
if ( !@copy($source_filename, $config['upload_dir'] . '/' . $destination_filename) )
if ( !@copy($source_filename, $upload_dir . '/' . $destination_filename) )
{
if ( !@move_uploaded_file($source_filename, $config['upload_dir'] . '/' . $destination_filename) )
if ( !@move_uploaded_file($source_filename, $upload_dir . '/' . $destination_filename) )
{
return sprintf($user->lang['GENERAL_UPLOAD_ERROR'], './' . $config['upload_dir'] . '/' . $destination_filename);
return sprintf($user->lang['GENERAL_UPLOAD_ERROR'], $upload_dir . '/' . $destination_filename);
}
}
@chmod($config['upload_dir'] . '/' . $destination_filename, 0666);
@chmod($upload_dir . '/' . $destination_filename, 0666);
break;
case 'move':
if ( !@move_uploaded_file($source_filename, $config['upload_dir'] . '/' . $destination_filename) )
if ( !@move_uploaded_file($source_filename, $upload_dir . '/' . $destination_filename) )
{
if ( !@copy($source_file, $config['upload_dir'] . '/' . $destination_filename) )
if ( !@copy($source_file, $upload_dir . '/' . $destination_filename) )
{
return sprintf($user->lang['GENERAL_UPLOAD_ERROR'], './' . $config['upload_dir'] . '/' . $destination_filename);
return sprintf($user->lang['GENERAL_UPLOAD_ERROR'], $upload_dir . '/' . $destination_filename);
}
}
@chmod($config['upload_dir'] . '/' . $destination_filename, 0666);
@chmod($upload_dir . '/' . $destination_filename, 0666);
break;
case 'local':
if (!@copy($source_filename, $upload_dir . '/' . $destination_filename))
{
return sprintf($user->lang['GENERAL_UPLOAD_ERROR'], $upload_dir . '/' . $destination_filename);
}
@chmod($upload_dir . '/' . $destination_filename, 0666);
@unlink($source_filename);
break;
}
if ($filedata['thumbnail'])
{
$source = $config['upload_dir'] . '/' . $destination_filename;
$destination = $config['upload_dir'] . '/thumbs/t_' . $destination_filename;
$source = $upload_dir . '/' . $destination_filename;
$destination = $upload_dir . '/thumbs/t_' . $destination_filename;
if (!create_thumbnail($source, $destination, $filedata['mimetype']))
{

View File

@@ -62,9 +62,8 @@ class parse_message
// Do some general 'cleanup' first before processing message,
// e.g. remove excessive newlines(?), smilies(?)
// Transform \r\n and \r into \n
$match = array('#\r\n?#', '#sid=[a-z0-9]*?&?#', "#([\n][\s]+){3,}#");
$match = array('#\r\n?#', '#sid=[a-z0-9]*?&?#', "#([\n][\s]+){3,}#");
$replace = array("\n", '', "\n\n");
$this->message = trim(preg_replace($match, $replace, $this->message));
// Message length check
@@ -78,17 +77,13 @@ class parse_message
if ($bbcode)
{
$this->bbcode_init();
if (!$allow_img)
$disallow = array('allow_img', 'allow_flash', 'allow_quote');
foreach ($disallow as $bool)
{
$this->bbcodes['img']['disabled'] = TRUE;
}
if (!$allow_flash)
{
$this->bbcodes['flash']['disabled'] = TRUE;
}
if (!$allow_quote)
{
$this->bbcodes['quote']['disabled'] = TRUE;
if (!$$bool)
{
$this->bbcodes[str_replace('allow_', '', $bool)]['disabled'] = TRUE;
}
}
$this->bbcode();
}