2002-07-14 14:37:47 +00:00
|
|
|
|
<?php
|
2003-08-29 18:06:56 +00:00
|
|
|
|
// -------------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
// $Id$
|
|
|
|
|
//
|
|
|
|
|
// FILENAME : functions_posting.php
|
|
|
|
|
// STARTED : Sun Jul 14, 2002
|
|
|
|
|
// COPYRIGHT : <20> 2001, 2003 phpBB Group
|
|
|
|
|
// WWW : http://www.phpbb.com/
|
|
|
|
|
// LICENCE : GPL vs2.0 [ see /docs/COPYING ]
|
|
|
|
|
//
|
|
|
|
|
// -------------------------------------------------------------
|
2002-07-14 14:37:47 +00:00
|
|
|
|
|
2003-06-23 14:00:57 +00:00
|
|
|
|
// Fill smiley templates (or just the variables) with smileys, either in a window or inline
|
2003-10-10 12:11:18 +00:00
|
|
|
|
function generate_smilies($mode, $forum_id)
|
2002-07-14 14:37:47 +00:00
|
|
|
|
{
|
2002-10-30 18:59:09 +00:00
|
|
|
|
global $SID, $auth, $db, $user, $config, $template;
|
2003-10-10 12:11:18 +00:00
|
|
|
|
global $phpEx, $phpbb_root_path;
|
2003-02-27 23:37:02 +00:00
|
|
|
|
|
2002-11-07 22:02:04 +00:00
|
|
|
|
if ($mode == 'window')
|
2002-07-14 14:37:47 +00:00
|
|
|
|
{
|
2004-05-02 13:06:57 +00:00
|
|
|
|
if ($forum_id)
|
2003-10-10 12:11:18 +00:00
|
|
|
|
{
|
2004-05-02 13:06:57 +00:00
|
|
|
|
$sql = 'SELECT forum_style
|
|
|
|
|
FROM ' . FORUMS_TABLE . "
|
|
|
|
|
WHERE forum_id = $forum_id";
|
|
|
|
|
$result = $db->sql_query_limit($sql, 1);
|
|
|
|
|
$row = $db->sql_fetchrow($result);
|
|
|
|
|
$db->sql_freeresult($result);
|
2003-10-10 12:11:18 +00:00
|
|
|
|
|
2004-05-02 13:06:57 +00:00
|
|
|
|
$user->setup('posting', (int) $row['forum_style']);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
$user->setup('posting');
|
|
|
|
|
}
|
2003-08-27 16:31:54 +00:00
|
|
|
|
|
2003-10-10 12:11:18 +00:00
|
|
|
|
page_header($user->lang['SMILIES']);
|
2002-07-14 14:37:47 +00:00
|
|
|
|
|
2002-10-04 13:09:10 +00:00
|
|
|
|
$template->set_filenames(array(
|
2002-10-30 18:59:09 +00:00
|
|
|
|
'body' => 'posting_smilies.html')
|
2002-10-04 13:09:10 +00:00
|
|
|
|
);
|
|
|
|
|
}
|
2002-07-14 14:37:47 +00:00
|
|
|
|
|
2004-01-25 14:30:15 +00:00
|
|
|
|
$display_link = false;
|
2003-10-10 12:11:18 +00:00
|
|
|
|
if ($mode == 'inline')
|
|
|
|
|
{
|
2003-10-10 16:08:46 +00:00
|
|
|
|
$sql = 'SELECT smile_id
|
2003-10-10 15:59:45 +00:00
|
|
|
|
FROM ' . SMILIES_TABLE . '
|
2003-10-10 16:08:46 +00:00
|
|
|
|
WHERE display_on_posting = 0';
|
2003-10-10 12:11:18 +00:00
|
|
|
|
$result = $db->sql_query_limit($sql, 1, 0, 3600);
|
2003-10-12 11:59:23 +00:00
|
|
|
|
|
2003-10-10 16:08:46 +00:00
|
|
|
|
if ($row = $db->sql_fetchrow($result))
|
|
|
|
|
{
|
2004-01-25 14:30:15 +00:00
|
|
|
|
$display_link = true;
|
2003-10-10 16:08:46 +00:00
|
|
|
|
}
|
2003-10-12 11:59:23 +00:00
|
|
|
|
$db->sql_freeresult($result);
|
2003-10-10 12:11:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-08-28 17:32:18 +00:00
|
|
|
|
$sql = 'SELECT *
|
2003-05-25 14:32:20 +00:00
|
|
|
|
FROM ' . SMILIES_TABLE .
|
|
|
|
|
(($mode == 'inline') ? ' WHERE display_on_posting = 1 ' : '') . '
|
2003-10-10 15:58:34 +00:00
|
|
|
|
GROUP BY smile_url
|
2003-05-25 14:32:20 +00:00
|
|
|
|
ORDER BY smile_order';
|
2003-10-10 12:11:18 +00:00
|
|
|
|
$result = $db->sql_query($sql, 3600);
|
2002-07-14 14:37:47 +00:00
|
|
|
|
|
2003-10-10 16:08:46 +00:00
|
|
|
|
while ($row = $db->sql_fetchrow($result))
|
2002-10-04 13:09:10 +00:00
|
|
|
|
{
|
2003-10-10 16:08:46 +00:00
|
|
|
|
$template->assign_block_vars('emoticon', array(
|
|
|
|
|
'SMILEY_CODE' => $row['code'],
|
|
|
|
|
'SMILEY_IMG' => $config['smilies_path'] . '/' . $row['smile_url'],
|
|
|
|
|
'SMILEY_WIDTH' => $row['smile_width'],
|
|
|
|
|
'SMILEY_HEIGHT' => $row['smile_height'],
|
|
|
|
|
'SMILEY_DESC' => $row['emoticon'])
|
|
|
|
|
);
|
2002-07-14 14:37:47 +00:00
|
|
|
|
}
|
2003-10-10 12:11:18 +00:00
|
|
|
|
$db->sql_freeresult($result);
|
2002-07-14 14:37:47 +00:00
|
|
|
|
|
2003-10-10 16:08:46 +00:00
|
|
|
|
if ($mode == 'inline' && $display_link)
|
|
|
|
|
{
|
|
|
|
|
$template->assign_vars(array(
|
2004-01-25 14:30:15 +00:00
|
|
|
|
'S_SHOW_EMOTICON_LINK' => true,
|
2003-10-10 16:08:46 +00:00
|
|
|
|
'U_MORE_SMILIES' => $phpbb_root_path . "posting.$phpEx$SID&mode=smilies&f=$forum_id")
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2002-10-30 18:59:09 +00:00
|
|
|
|
if ($mode == 'window')
|
2002-07-14 14:37:47 +00:00
|
|
|
|
{
|
2003-05-25 14:32:20 +00:00
|
|
|
|
page_footer();
|
2002-07-14 14:37:47 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-22 15:48:46 +00:00
|
|
|
|
// Format text to be displayed - from viewtopic.php - centralizing this would be nice ;)
|
2004-05-02 13:06:57 +00:00
|
|
|
|
function format_display(&$message, &$signature, $uid, $siguid, $enable_html, $enable_bbcode, $enable_url, $enable_smilies, $enable_sig, $bbcode = '')
|
2003-03-12 14:21:57 +00:00
|
|
|
|
{
|
2004-05-02 13:06:57 +00:00
|
|
|
|
global $auth, $forum_id, $config, $user, $phpbb_root_path;
|
|
|
|
|
|
|
|
|
|
if (!$bbcode)
|
|
|
|
|
{
|
|
|
|
|
global $bbcode;
|
|
|
|
|
}
|
2003-03-12 14:21:57 +00:00
|
|
|
|
|
|
|
|
|
// Second parse bbcode here
|
2003-09-07 17:52:53 +00:00
|
|
|
|
$bbcode->bbcode_second_pass($message, $uid);
|
2003-03-12 14:21:57 +00:00
|
|
|
|
|
2003-06-23 14:00:57 +00:00
|
|
|
|
// If we allow users to disable display of emoticons we'll need an appropriate
|
|
|
|
|
// check and preg_replace here
|
2004-05-02 13:06:57 +00:00
|
|
|
|
$message = smilie_text($message, !$enbale_smilies);
|
2003-03-12 14:21:57 +00:00
|
|
|
|
|
|
|
|
|
// Replace naughty words such as farty pants
|
2004-02-21 12:47:35 +00:00
|
|
|
|
$message = str_replace("\n", '<br />', censor_text($message));
|
2003-03-12 14:21:57 +00:00
|
|
|
|
|
|
|
|
|
// Signature
|
2004-05-02 13:06:57 +00:00
|
|
|
|
if ($enable_sig && $config['allow_sig'] && $signature && $auth->acl_get('f_sigs', $forum_id))
|
2003-03-12 14:21:57 +00:00
|
|
|
|
{
|
2003-06-24 16:46:30 +00:00
|
|
|
|
$signature = trim($signature);
|
|
|
|
|
|
2003-09-07 17:52:53 +00:00
|
|
|
|
$bbcode->bbcode_second_pass($signature, $siguid);
|
2004-02-21 12:47:35 +00:00
|
|
|
|
$signature = smilie_text($signature);
|
2003-06-24 16:46:30 +00:00
|
|
|
|
|
2004-02-21 12:47:35 +00:00
|
|
|
|
$signature = str_replace("\n", '<br />', censor_text($signature));
|
2003-03-12 14:21:57 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2003-06-24 16:46:30 +00:00
|
|
|
|
$signature = '';
|
2003-03-12 14:21:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-06-29 10:59:36 +00:00
|
|
|
|
return $message;
|
2003-03-12 14:21:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-04-19 10:28:37 +00:00
|
|
|
|
// Update Last Post Informations
|
2003-10-11 11:46:29 +00:00
|
|
|
|
function update_last_post_information($type, $id)
|
2003-04-19 10:28:37 +00:00
|
|
|
|
{
|
|
|
|
|
global $db;
|
|
|
|
|
|
2003-11-22 12:43:07 +00:00
|
|
|
|
$update_sql = array();
|
2003-04-19 10:28:37 +00:00
|
|
|
|
|
2003-11-22 12:43:07 +00:00
|
|
|
|
$sql = 'SELECT MAX(post_id) as last_post_id
|
|
|
|
|
FROM ' . POSTS_TABLE . "
|
|
|
|
|
WHERE post_approved = 1
|
|
|
|
|
AND {$type}_id = $id";
|
|
|
|
|
$result = $db->sql_query($sql);
|
2003-04-19 10:28:37 +00:00
|
|
|
|
$row = $db->sql_fetchrow($result);
|
|
|
|
|
|
2004-01-25 14:30:15 +00:00
|
|
|
|
if ($row['last_post_id'])
|
2003-09-07 15:23:55 +00:00
|
|
|
|
{
|
2003-11-22 12:43:07 +00:00
|
|
|
|
$sql = 'SELECT p.post_id, p.poster_id, p.post_time, u.username, p.post_username
|
|
|
|
|
FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u
|
|
|
|
|
WHERE p.poster_id = u.user_id
|
|
|
|
|
AND p.post_id = ' . $row['last_post_id'];
|
|
|
|
|
$result = $db->sql_query($sql);
|
|
|
|
|
$row = $db->sql_fetchrow($result);
|
|
|
|
|
$db->sql_freeresult($result);
|
|
|
|
|
|
2003-09-07 15:23:55 +00:00
|
|
|
|
$update_sql[] = $type . '_last_post_id = ' . (int) $row['post_id'];
|
|
|
|
|
$update_sql[] = $type . '_last_post_time = ' . (int) $row['post_time'];
|
|
|
|
|
$update_sql[] = $type . '_last_poster_id = ' . (int) $row['poster_id'];
|
|
|
|
|
$update_sql[] = "{$type}_last_poster_name = '" . (($row['poster_id'] == ANONYMOUS) ? $db->sql_escape($row['post_username']) : $db->sql_escape($row['username'])) . "'";
|
|
|
|
|
}
|
|
|
|
|
else if ($type == 'forum')
|
|
|
|
|
{
|
|
|
|
|
$update_sql[] = 'forum_last_post_id = 0';
|
|
|
|
|
$update_sql[] = 'forum_last_post_time = 0';
|
|
|
|
|
$update_sql[] = 'forum_last_poster_id = 0';
|
|
|
|
|
$update_sql[] = "forum_last_poster_name = ''";
|
|
|
|
|
}
|
2003-11-22 12:43:07 +00:00
|
|
|
|
|
2003-09-07 15:23:55 +00:00
|
|
|
|
return $update_sql;
|
2003-04-19 10:28:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-04-19 12:58:37 +00:00
|
|
|
|
// Upload Attachment - filedata is generated here
|
2004-05-02 13:06:57 +00:00
|
|
|
|
function upload_attachment($forum_id, $filename, $local = false, $local_storage = '', $is_message = false)
|
2003-04-19 12:58:37 +00:00
|
|
|
|
{
|
2003-06-23 14:00:57 +00:00
|
|
|
|
global $auth, $user, $config, $db;
|
2003-03-12 14:21:57 +00:00
|
|
|
|
|
2003-04-19 12:58:37 +00:00
|
|
|
|
$filedata = array();
|
2003-05-11 16:21:35 +00:00
|
|
|
|
$filedata['error'] = array();
|
2004-01-25 14:30:15 +00:00
|
|
|
|
$filedata['post_attach'] = ($filename) ? true : false;
|
2003-03-12 14:21:57 +00:00
|
|
|
|
|
2003-04-19 12:58:37 +00:00
|
|
|
|
if (!$filedata['post_attach'])
|
2003-03-12 14:21:57 +00:00
|
|
|
|
{
|
2003-04-20 16:49:26 +00:00
|
|
|
|
return $filedata;
|
2003-03-12 14:21:57 +00:00
|
|
|
|
}
|
2003-04-19 12:58:37 +00:00
|
|
|
|
|
|
|
|
|
$r_file = $filename;
|
2003-10-19 15:36:45 +00:00
|
|
|
|
$file = (!$local) ? $_FILES['fileupload']['tmp_name'] : $local_storage;
|
|
|
|
|
$filedata['mimetype'] = (!$local) ? $_FILES['fileupload']['type'] : 'application/octet-stream';
|
2003-03-12 14:21:57 +00:00
|
|
|
|
|
2003-11-16 21:53:56 +00:00
|
|
|
|
// Opera adds the name to the mime type
|
2003-06-20 17:20:22 +00:00
|
|
|
|
$filedata['mimetype'] = ( strstr($filedata['mimetype'], '; name') ) ? str_replace(strstr($filedata['mimetype'], '; name'), '', $filedata['mimetype']) : $filedata['mimetype'];
|
|
|
|
|
$filedata['extension'] = array_pop(explode('.', strtolower($filename)));
|
|
|
|
|
$filedata['filesize'] = (!@filesize($file)) ? intval($_FILES['size']) : @filesize($file);
|
2003-03-12 14:21:57 +00:00
|
|
|
|
|
2003-04-19 12:58:37 +00:00
|
|
|
|
$extensions = array();
|
|
|
|
|
obtain_attach_extensions($extensions);
|
2003-03-12 14:21:57 +00:00
|
|
|
|
|
2003-04-19 12:58:37 +00:00
|
|
|
|
// Check Extension
|
2004-05-02 13:06:57 +00:00
|
|
|
|
if (!extension_allowed($forum_id, $filedata['extension']))
|
2003-03-12 14:21:57 +00:00
|
|
|
|
{
|
2003-05-11 16:21:35 +00:00
|
|
|
|
$filedata['error'][] = sprintf($user->lang['DISALLOWED_EXTENSION'], $filedata['extension']);
|
2004-01-25 14:30:15 +00:00
|
|
|
|
$filedata['post_attach'] = false;
|
2003-04-20 16:49:26 +00:00
|
|
|
|
return $filedata;
|
2004-05-02 13:06:57 +00:00
|
|
|
|
}
|
2003-03-12 14:21:57 +00:00
|
|
|
|
|
2004-05-02 13:06:57 +00:00
|
|
|
|
$cfg = array();
|
|
|
|
|
$cfg['max_filesize'] = ($is_message) ? $config['max_filesize_pm'] : $config['max_filesize'];
|
|
|
|
|
|
|
|
|
|
$allowed_filesize = ($extensions[$filedata['extension']]['max_filesize'] != 0) ? $extensions[$filedata['extension']]['max_filesize'] : $cfg['max_filesize'];
|
2003-04-19 12:58:37 +00:00
|
|
|
|
$cat_id = $extensions[$filedata['extension']]['display_cat'];
|
2003-03-12 14:21:57 +00:00
|
|
|
|
|
2003-04-19 12:58:37 +00:00
|
|
|
|
// check Filename
|
2003-06-23 14:00:57 +00:00
|
|
|
|
if (preg_match("#[\\/:*?\"<>|]#i", $filename))
|
2003-04-19 12:58:37 +00:00
|
|
|
|
{
|
2003-05-11 16:21:35 +00:00
|
|
|
|
$filedata['error'][] = sprintf($user->lang['INVALID_FILENAME'], $filename);
|
2004-01-25 14:30:15 +00:00
|
|
|
|
$filedata['post_attach'] = false;
|
2003-04-20 16:49:26 +00:00
|
|
|
|
return $filedata;
|
2003-04-19 12:58:37 +00:00
|
|
|
|
}
|
2003-03-22 15:48:46 +00:00
|
|
|
|
|
2003-04-19 12:58:37 +00:00
|
|
|
|
// check php upload-size
|
2003-10-19 15:36:45 +00:00
|
|
|
|
if ($file == 'none')
|
2003-03-22 15:48:46 +00:00
|
|
|
|
{
|
2003-05-11 16:21:35 +00:00
|
|
|
|
$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'));
|
2004-01-25 14:30:15 +00:00
|
|
|
|
$filedata['post_attach'] = false;
|
2003-04-20 16:49:26 +00:00
|
|
|
|
return $filedata;
|
2003-03-22 15:48:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-04-19 12:58:37 +00:00
|
|
|
|
// Check Image Size, if it is an image
|
2003-05-11 16:38:43 +00:00
|
|
|
|
if (!$auth->acl_gets('m_', 'a_') && $cat_id == IMAGE_CAT)
|
2003-03-22 15:48:46 +00:00
|
|
|
|
{
|
2003-05-11 16:21:35 +00:00
|
|
|
|
list($width, $height) = getimagesize($file);
|
2003-03-22 15:48:46 +00:00
|
|
|
|
|
2003-06-23 14:00:57 +00:00
|
|
|
|
if ($width != 0 && $height != 0 && $config['img_max_width'] && $config['img_max_height'])
|
2003-03-22 15:48:46 +00:00
|
|
|
|
{
|
2003-06-23 16:59:02 +00:00
|
|
|
|
if ($width > $config['img_max_width'] || $height > $config['img_max_height'])
|
2003-03-22 15:48:46 +00:00
|
|
|
|
{
|
2003-11-16 21:53:56 +00:00
|
|
|
|
$filedata['error'][] = sprintf($user->lang['ERROR_IMAGESIZE'], $config['img_max_width'], $config['img_max_height']);
|
2004-01-25 14:30:15 +00:00
|
|
|
|
$filedata['post_attach'] = false;
|
2003-05-11 16:21:35 +00:00
|
|
|
|
return $filedata;
|
2003-03-22 15:48:46 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2003-04-19 12:58:37 +00:00
|
|
|
|
}
|
2003-05-11 16:21:35 +00:00
|
|
|
|
|
2003-04-19 12:58:37 +00:00
|
|
|
|
// check Filesize
|
2003-11-16 21:53:56 +00:00
|
|
|
|
if ($allowed_filesize && $filedata['filesize'] > $allowed_filesize && !$auth->acl_gets('m_', 'a_'))
|
2003-04-19 12:58:37 +00:00
|
|
|
|
{
|
|
|
|
|
$size_lang = ($allowed_filesize >= 1048576) ? $user->lang['MB'] : ( ($allowed_filesize >= 1024) ? $user->lang['KB'] : $user->lang['BYTES'] );
|
2003-03-22 15:48:46 +00:00
|
|
|
|
|
2003-06-25 19:49:59 +00:00
|
|
|
|
$allowed_filesize = ($allowed_filesize >= 1048576) ? round($allowed_filesize / 1048576 * 100) / 100 : (($allowed_filesize >= 1024) ? round($allowed_filesize / 1024 * 100) / 100 : $allowed_filesize);
|
2003-04-19 12:58:37 +00:00
|
|
|
|
|
2003-05-11 16:21:35 +00:00
|
|
|
|
$filedata['error'][] = sprintf($user->lang['ATTACHMENT_TOO_BIG'], $allowed_filesize, $size_lang);
|
2004-01-25 14:30:15 +00:00
|
|
|
|
$filedata['post_attach'] = false;
|
2003-04-20 16:49:26 +00:00
|
|
|
|
return $filedata;
|
2003-03-22 15:48:46 +00:00
|
|
|
|
}
|
2003-04-19 12:58:37 +00:00
|
|
|
|
|
|
|
|
|
// Check our complete quota
|
2003-11-16 21:53:56 +00:00
|
|
|
|
if ($config['attachment_quota'])
|
2003-03-22 15:48:46 +00:00
|
|
|
|
{
|
2003-11-16 21:53:56 +00:00
|
|
|
|
if ($config['upload_dir_size'] + $filedata['filesize'] > $config['attachment_quota'])
|
2003-03-22 15:48:46 +00:00
|
|
|
|
{
|
2003-05-11 16:21:35 +00:00
|
|
|
|
$filedata['error'][] = $user->lang['ATTACH_QUOTA_REACHED'];
|
2004-01-25 14:30:15 +00:00
|
|
|
|
$filedata['post_attach'] = false;
|
2003-04-20 16:49:26 +00:00
|
|
|
|
return $filedata;
|
2003-03-22 15:48:46 +00:00
|
|
|
|
}
|
2003-04-19 12:58:37 +00:00
|
|
|
|
}
|
2003-03-22 15:48:46 +00:00
|
|
|
|
|
2004-05-02 13:06:57 +00:00
|
|
|
|
// TODO - Check Free Disk Space - need testing under windows
|
2003-11-16 21:53:56 +00:00
|
|
|
|
if ($free_space = disk_free_space($config['upload_dir']))
|
|
|
|
|
{
|
|
|
|
|
if ($free_space <= $filedata['filesize'])
|
|
|
|
|
{
|
|
|
|
|
$filedata['error'][] = $user->lang['ATTACH_QUOTA_REACHED'];
|
2004-01-25 14:30:15 +00:00
|
|
|
|
$filedata['post_attach'] = false;
|
2003-11-16 21:53:56 +00:00
|
|
|
|
return $filedata;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-19 12:58:37 +00:00
|
|
|
|
$filedata['thumbnail'] = 0;
|
|
|
|
|
|
|
|
|
|
// Prepare Values
|
|
|
|
|
$filedata['filetime'] = time();
|
|
|
|
|
$filedata['filename'] = stripslashes($r_file);
|
2003-03-22 15:48:46 +00:00
|
|
|
|
|
2003-04-19 12:58:37 +00:00
|
|
|
|
$filedata['destination_filename'] = strtolower($filedata['filename']);
|
|
|
|
|
$filedata['destination_filename'] = $user->data['user_id'] . '_' . $filedata['filetime'] . '.' . $filedata['extension'];
|
|
|
|
|
|
|
|
|
|
$filedata['filename'] = str_replace("'", "\'", $filedata['filename']);
|
2003-03-22 15:48:46 +00:00
|
|
|
|
|
2003-04-19 12:58:37 +00:00
|
|
|
|
// Do we have to create a thumbnail ?
|
2003-05-11 16:21:35 +00:00
|
|
|
|
if ($cat_id == IMAGE_CAT && $config['img_create_thumbnail'])
|
2003-04-19 12:58:37 +00:00
|
|
|
|
{
|
2003-05-11 16:21:35 +00:00
|
|
|
|
$filedata['thumbnail'] = 1;
|
2003-03-22 15:48:46 +00:00
|
|
|
|
}
|
2003-04-19 12:58:37 +00:00
|
|
|
|
|
2003-06-25 19:49:59 +00:00
|
|
|
|
// Descide the Upload method
|
|
|
|
|
$upload_mode = (@ini_get('open_basedir') || @ini_get('safe_mode')) ? 'move' : 'copy';
|
2003-10-19 15:36:45 +00:00
|
|
|
|
$upload_mode = ($local) ? 'local' : $upload_mode;
|
2003-03-22 15:48:46 +00:00
|
|
|
|
|
2003-04-19 12:58:37 +00:00
|
|
|
|
// Ok, upload the File
|
|
|
|
|
$result = move_uploaded_attachment($upload_mode, $file, $filedata);
|
|
|
|
|
|
2004-01-25 14:30:15 +00:00
|
|
|
|
if ($result)
|
2003-03-22 15:48:46 +00:00
|
|
|
|
{
|
2003-05-11 16:21:35 +00:00
|
|
|
|
$filedata['error'][] = $result;
|
2004-01-25 14:30:15 +00:00
|
|
|
|
$filedata['post_attach'] = false;
|
2003-04-19 12:58:37 +00:00
|
|
|
|
}
|
2003-04-20 16:49:26 +00:00
|
|
|
|
return $filedata;
|
2003-04-19 12:58:37 +00:00
|
|
|
|
}
|
2003-03-22 15:48:46 +00:00
|
|
|
|
|
2003-04-19 12:58:37 +00:00
|
|
|
|
// Move/Upload File - could be used for Avatars too ?
|
|
|
|
|
function move_uploaded_attachment($upload_mode, $source_filename, &$filedata)
|
|
|
|
|
{
|
2003-10-19 15:36:45 +00:00
|
|
|
|
global $user, $config, $phpbb_root_path;
|
2003-03-22 15:48:46 +00:00
|
|
|
|
|
2003-04-19 12:58:37 +00:00
|
|
|
|
$destination_filename = $filedata['destination_filename'];
|
2004-01-25 14:30:15 +00:00
|
|
|
|
$thumbnail = (isset($filedata['thumbnail'])) ? $filedata['thumbnail'] : false;
|
2003-04-19 12:58:37 +00:00
|
|
|
|
|
|
|
|
|
switch ($upload_mode)
|
|
|
|
|
{
|
|
|
|
|
case 'copy':
|
2003-11-16 21:53:56 +00:00
|
|
|
|
if ( !@copy($source_filename, $config['upload_dir'] . '/' . $destination_filename) )
|
2003-03-22 15:48:46 +00:00
|
|
|
|
{
|
2003-11-16 21:53:56 +00:00
|
|
|
|
if ( !@move_uploaded_file($source_filename, $config['upload_dir'] . '/' . $destination_filename) )
|
2003-03-22 15:48:46 +00:00
|
|
|
|
{
|
2003-11-16 21:53:56 +00:00
|
|
|
|
return sprintf($user->lang['GENERAL_UPLOAD_ERROR'], $config['upload_dir'] . '/' . $destination_filename);
|
2003-04-19 12:58:37 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2003-11-16 21:53:56 +00:00
|
|
|
|
@chmod($config['upload_dir'] . '/' . $destination_filename, 0666);
|
2003-04-19 12:58:37 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'move':
|
2003-11-16 21:53:56 +00:00
|
|
|
|
if ( !@move_uploaded_file($source_filename, $config['upload_dir'] . '/' . $destination_filename) )
|
2003-04-19 12:58:37 +00:00
|
|
|
|
{
|
2003-11-16 21:53:56 +00:00
|
|
|
|
if ( !@copy($source_filename, $config['upload_dir'] . '/' . $destination_filename) )
|
2003-04-19 12:58:37 +00:00
|
|
|
|
{
|
2003-11-16 21:53:56 +00:00
|
|
|
|
return sprintf($user->lang['GENERAL_UPLOAD_ERROR'], $config['upload_dir'] . '/' . $destination_filename);
|
2003-03-22 15:48:46 +00:00
|
|
|
|
}
|
2003-04-19 12:58:37 +00:00
|
|
|
|
}
|
2003-11-16 21:53:56 +00:00
|
|
|
|
@chmod($config['upload_dir'] . '/' . $destination_filename, 0666);
|
2003-10-19 15:36:45 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'local':
|
2003-11-16 21:53:56 +00:00
|
|
|
|
if (!@copy($source_filename, $config['upload_dir'] . '/' . $destination_filename))
|
2003-10-19 15:36:45 +00:00
|
|
|
|
{
|
2003-11-16 21:53:56 +00:00
|
|
|
|
return sprintf($user->lang['GENERAL_UPLOAD_ERROR'], $config['upload_dir'] . '/' . $destination_filename);
|
2003-10-19 15:36:45 +00:00
|
|
|
|
}
|
2003-11-16 21:53:56 +00:00
|
|
|
|
@chmod($config['upload_dir'] . '/' . $destination_filename, 0666);
|
2003-10-19 15:36:45 +00:00
|
|
|
|
@unlink($source_filename);
|
2003-04-19 12:58:37 +00:00
|
|
|
|
break;
|
2003-03-22 15:48:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-06-20 17:20:22 +00:00
|
|
|
|
if ($filedata['thumbnail'])
|
2003-03-22 15:48:46 +00:00
|
|
|
|
{
|
2003-11-16 21:53:56 +00:00
|
|
|
|
$source = $config['upload_dir'] . '/' . $destination_filename;
|
|
|
|
|
$destination = $config['upload_dir'] . '/thumb_' . $destination_filename;
|
2003-03-22 15:48:46 +00:00
|
|
|
|
|
2003-11-16 21:53:56 +00:00
|
|
|
|
if (!create_thumbnail($source_filename, $destination_filename, $filedata['mimetype']))
|
2003-03-22 15:48:46 +00:00
|
|
|
|
{
|
2003-11-16 21:53:56 +00:00
|
|
|
|
if (!create_thumbnail($source, $destination, $filedata['mimetype']))
|
2003-03-22 15:48:46 +00:00
|
|
|
|
{
|
2003-04-19 12:58:37 +00:00
|
|
|
|
$filedata['thumbnail'] = 0;
|
2003-03-22 15:48:46 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2003-06-20 17:20:22 +00:00
|
|
|
|
}
|
2003-08-27 16:31:54 +00:00
|
|
|
|
|
|
|
|
|
return;
|
2003-04-19 12:58:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-06-20 17:20:22 +00:00
|
|
|
|
// 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)
|
|
|
|
|
{
|
|
|
|
|
// Change these two values to define the Thumbnail Size
|
2003-08-27 16:31:54 +00:00
|
|
|
|
$max_width = 400;
|
|
|
|
|
$max_height = 200;
|
2003-06-20 17:20:22 +00:00
|
|
|
|
|
|
|
|
|
if ($height > $max_height)
|
|
|
|
|
{
|
|
|
|
|
$new_width = ($max_height / $height) * $width;
|
|
|
|
|
$new_height = $max_height;
|
|
|
|
|
|
|
|
|
|
if ($new_width > $max_width)
|
|
|
|
|
{
|
|
|
|
|
$new_height = ($max_width / $new_width) * $new_height;
|
|
|
|
|
$new_width = $max_width;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if ($width > $max_width)
|
|
|
|
|
{
|
|
|
|
|
$new_height = ($max_width / $width) * $height;
|
|
|
|
|
$new_width = $max_width;
|
|
|
|
|
|
|
|
|
|
if ($new_height > $max_height)
|
|
|
|
|
{
|
|
|
|
|
$new_width = ($max_height / $new_height) * $new_width;
|
|
|
|
|
$new_height = $max_height;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
$new_width = $width;
|
|
|
|
|
$new_height = $height;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return array(
|
|
|
|
|
round($new_width),
|
|
|
|
|
round($new_height)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function get_supported_image_types()
|
|
|
|
|
{
|
|
|
|
|
$types = array();
|
|
|
|
|
|
|
|
|
|
if (@extension_loaded('gd'))
|
|
|
|
|
{
|
|
|
|
|
if (@function_exists('imagegif'))
|
|
|
|
|
{
|
|
|
|
|
$types[] = '1';
|
|
|
|
|
}
|
|
|
|
|
if (@function_exists('imagejpeg'))
|
|
|
|
|
{
|
|
|
|
|
$types[] = '2';
|
|
|
|
|
}
|
|
|
|
|
if (@function_exists('imagepng'))
|
|
|
|
|
{
|
|
|
|
|
$types[] = '3';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return $types;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Create Thumbnail
|
|
|
|
|
function create_thumbnail($source, $new_file, $mimetype)
|
|
|
|
|
{
|
|
|
|
|
global $config;
|
|
|
|
|
|
|
|
|
|
$source = realpath($source);
|
2003-06-25 19:49:59 +00:00
|
|
|
|
$min_filesize = (int) $config['img_min_thumb_filesize'];
|
2003-06-20 17:20:22 +00:00
|
|
|
|
|
2004-01-25 14:30:15 +00:00
|
|
|
|
$img_filesize = (file_exists($source)) ? @filesize($source) : false;
|
2003-06-20 17:20:22 +00:00
|
|
|
|
|
2003-06-25 19:49:59 +00:00
|
|
|
|
if (!$img_filesize || $img_filesize <= $min_filesize)
|
2003-06-20 17:20:22 +00:00
|
|
|
|
{
|
2004-01-25 14:30:15 +00:00
|
|
|
|
return false;
|
2003-06-20 17:20:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-06-25 19:49:59 +00:00
|
|
|
|
$size = getimagesize($source);
|
2003-06-20 17:20:22 +00:00
|
|
|
|
|
|
|
|
|
if ($size[0] == 0 && $size[1] == 0)
|
|
|
|
|
{
|
2004-01-25 14:30:15 +00:00
|
|
|
|
return false;
|
2003-06-20 17:20:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$new_size = get_img_size_format($size[0], $size[1]);
|
|
|
|
|
|
2003-08-27 16:31:54 +00:00
|
|
|
|
$tmp_path = $old_file = '';
|
2003-06-20 17:20:22 +00:00
|
|
|
|
|
2004-01-25 14:30:15 +00:00
|
|
|
|
$used_imagick = false;
|
2003-06-20 17:20:22 +00:00
|
|
|
|
|
2003-06-23 14:00:57 +00:00
|
|
|
|
if ($config['img_imagick'])
|
2003-06-20 17:20:22 +00:00
|
|
|
|
{
|
|
|
|
|
if (is_array($size) && count($size) > 0)
|
|
|
|
|
{
|
2003-08-27 16:31:54 +00:00
|
|
|
|
passthru($config['img_imagick'] . 'convert' . ((defined('PHP_OS') && preg_match('#win#i', PHP_OS)) ? '.exe' : '') . ' -quality 85 -antialias -sample ' . $new_size[0] . 'x' . $new_size[1] . ' "' . str_replace('\\', '/', $source) . '" +profile "*" "' . str_replace('\\', '/', $new_file) . '"');
|
2003-06-20 17:20:22 +00:00
|
|
|
|
if (file_exists($new_file))
|
|
|
|
|
{
|
2004-01-25 14:30:15 +00:00
|
|
|
|
$used_imagick = true;
|
2003-06-20 17:20:22 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!$used_imagick)
|
|
|
|
|
{
|
|
|
|
|
$type = $size[2];
|
|
|
|
|
$supported_types = get_supported_image_types();
|
|
|
|
|
|
|
|
|
|
if (in_array($type, $supported_types))
|
|
|
|
|
{
|
|
|
|
|
switch ($type)
|
|
|
|
|
{
|
|
|
|
|
case '1' :
|
|
|
|
|
$image = imagecreatefromgif($source);
|
|
|
|
|
$new_image = imagecreate($new_size[0], $new_size[1]);
|
|
|
|
|
imagecopyresized($new_image, $image, 0, 0, 0, 0, $new_size[0], $new_size[1], $size[0], $size[1]);
|
|
|
|
|
imagegif($new_image, $new_file);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case '2' :
|
|
|
|
|
$image = imagecreatefromjpeg($source);
|
|
|
|
|
$new_image = imagecreate($new_size[0], $new_size[1]);
|
|
|
|
|
imagecopyresized($new_image, $image, 0, 0, 0, 0, $new_size[0], $new_size[1], $size[0], $size[1]);
|
|
|
|
|
imagejpeg($new_image, $new_file, 90);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case '3' :
|
|
|
|
|
$image = imagecreatefrompng($source);
|
|
|
|
|
$new_image = imagecreate($new_size[0], $new_size[1]);
|
|
|
|
|
imagecopyresized($new_image, $image, 0, 0, 0, 0, $new_size[0], $new_size[1], $size[0], $size[1]);
|
|
|
|
|
imagepng($new_image, $new_file);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!file_exists($new_file))
|
|
|
|
|
{
|
2004-01-25 14:30:15 +00:00
|
|
|
|
return false;
|
2003-06-20 17:20:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-11-16 21:53:56 +00:00
|
|
|
|
@chmod($new_file, 0666);
|
|
|
|
|
|
2004-01-25 14:30:15 +00:00
|
|
|
|
return true;
|
2003-06-20 17:20:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-06-23 14:00:57 +00:00
|
|
|
|
//
|
|
|
|
|
// TODO
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
// DECODE TEXT -> This will/should be handled by bbcode.php eventually
|
2004-05-02 13:06:57 +00:00
|
|
|
|
function decode_text(&$message, $bbcode_uid = '')
|
2003-06-23 14:00:57 +00:00
|
|
|
|
{
|
|
|
|
|
global $config;
|
|
|
|
|
|
|
|
|
|
$server_protocol = ($config['cookie_secure']) ? 'https://' : 'http://';
|
|
|
|
|
$server_port = ($config['server_port'] <> 80) ? ':' . trim($config['server_port']) . '/' : '/';
|
|
|
|
|
|
2004-05-02 13:06:57 +00:00
|
|
|
|
$match = array(
|
2003-06-23 14:00:57 +00:00
|
|
|
|
'<br />',
|
|
|
|
|
"[/*:m:$bbcode_uid]",
|
|
|
|
|
":u:$bbcode_uid",
|
|
|
|
|
":o:$bbcode_uid",
|
|
|
|
|
":$bbcode_uid"
|
|
|
|
|
);
|
2004-02-15 14:03:19 +00:00
|
|
|
|
|
2003-06-23 14:00:57 +00:00
|
|
|
|
$replace = array(
|
|
|
|
|
"\n",
|
|
|
|
|
'',
|
|
|
|
|
'',
|
|
|
|
|
'',
|
|
|
|
|
''
|
|
|
|
|
);
|
2003-09-08 07:05:29 +00:00
|
|
|
|
|
2004-05-02 13:06:57 +00:00
|
|
|
|
$message = ($bbcode_uid) ? str_replace($match, $replace, $message) : str_replace('<br />', "\n", $message);
|
2003-06-23 14:00:57 +00:00
|
|
|
|
|
|
|
|
|
$match = array(
|
|
|
|
|
'#<!\-\- e \-\-><a href="mailto:(.*?)">.*?</a><!\-\- e \-\->#',
|
|
|
|
|
'#<!\-\- m \-\-><a href="(.*?)" target="_blank">.*?</a><!\-\- m \-\->#',
|
|
|
|
|
'#<!\-\- w \-\-><a href="http:\/\/(.*?)" target="_blank">.*?</a><!\-\- w \-\->#',
|
|
|
|
|
'#<!\-\- l \-\-><a href="(.*?)" target="_blank">.*?</a><!\-\- l \-\->#',
|
|
|
|
|
'#<!\-\- s(.*?) \-\-><img src="\{SMILE_PATH\}\/.*? \/><!\-\- s\1 \-\->#',
|
|
|
|
|
'#<.*?>#s'
|
|
|
|
|
);
|
2004-02-15 14:03:19 +00:00
|
|
|
|
|
2003-06-23 14:00:57 +00:00
|
|
|
|
$replace = array(
|
|
|
|
|
'\1',
|
|
|
|
|
'\1',
|
|
|
|
|
'\1',
|
|
|
|
|
$server_protocol . trim($config['server_name']) . $server_port . preg_replace('#^\/?(.*?)(\/)?$#', '\1', trim($config['script_path'])) . '/\1',
|
|
|
|
|
'\1',
|
|
|
|
|
''
|
|
|
|
|
);
|
2004-02-15 14:03:19 +00:00
|
|
|
|
|
2003-06-23 14:00:57 +00:00
|
|
|
|
$message = preg_replace($match, $replace, $message);
|
|
|
|
|
|
2004-03-01 15:24:26 +00:00
|
|
|
|
// HTML
|
|
|
|
|
if ($config['allow_html_tags'])
|
|
|
|
|
{
|
|
|
|
|
// If $html is true then "allowed_tags" are converted back from entity
|
|
|
|
|
// form, others remain
|
|
|
|
|
$allowed_tags = split(',', $config['allow_html_tags']);
|
|
|
|
|
|
|
|
|
|
if (sizeof($allowed_tags))
|
|
|
|
|
{
|
|
|
|
|
$message = preg_replace('#\<(\/?)(' . str_replace('*', '.*?', implode('|', $allowed_tags)) . ')\>#is', '<$1$2>', $message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-06-23 14:00:57 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2004-05-02 13:06:57 +00:00
|
|
|
|
// Temp Function - strtolower - borrowed from php.net
|
|
|
|
|
function phpbb_strtolower($string)
|
|
|
|
|
{
|
|
|
|
|
$new_string = '';
|
|
|
|
|
|
|
|
|
|
for ($i = 0; $i < strlen($string); $i++)
|
|
|
|
|
{
|
|
|
|
|
if (ord(substr($string, $i, 1)) > 0xa0)
|
|
|
|
|
{
|
|
|
|
|
$new_string .= strtolower(substr($string, $i, 2));
|
|
|
|
|
$i++;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
$new_string .= strtolower($string{$i});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $new_string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function posting_gen_topic_icons($mode, $icon_id)
|
|
|
|
|
{
|
|
|
|
|
global $phpbb_root_path, $config, $template;
|
|
|
|
|
|
|
|
|
|
// Grab icons
|
|
|
|
|
$icons = array();
|
|
|
|
|
obtain_icons($icons);
|
|
|
|
|
|
|
|
|
|
if (sizeof($icons))
|
|
|
|
|
{
|
|
|
|
|
foreach ($icons as $id => $data)
|
|
|
|
|
{
|
|
|
|
|
if ($data['display'])
|
|
|
|
|
{
|
|
|
|
|
$template->assign_block_vars('topic_icon', array(
|
|
|
|
|
'ICON_ID' => $id,
|
|
|
|
|
'ICON_IMG' => $phpbb_root_path . $config['icons_path'] . '/' . $data['img'],
|
|
|
|
|
'ICON_WIDTH' => $data['width'],
|
|
|
|
|
'ICON_HEIGHT' => $data['height'],
|
|
|
|
|
|
|
|
|
|
'S_ICON_CHECKED' => ($id == $icon_id && $mode != 'reply') ? ' checked="checked"' : '')
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function posting_gen_inline_attachments($message_parser)
|
|
|
|
|
{
|
|
|
|
|
global $template;
|
|
|
|
|
|
|
|
|
|
if (sizeof($message_parser->attachment_data))
|
|
|
|
|
{
|
|
|
|
|
$s_inline_attachment_options = '';
|
|
|
|
|
|
|
|
|
|
foreach ($message_parser->attachment_data as $i => $attachment)
|
|
|
|
|
{
|
|
|
|
|
$s_inline_attachment_options .= '<option value="' . $i . '">' . $attachment['real_filename'] . '</option>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$template->assign_var('S_INLINE_ATTACHMENT_OPTIONS', $s_inline_attachment_options);
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function posting_gen_topic_types($forum_id, $cur_topic_type = POST_NORMAL)
|
|
|
|
|
{
|
|
|
|
|
global $auth, $user, $template;
|
|
|
|
|
|
|
|
|
|
$toggle = false;
|
|
|
|
|
|
|
|
|
|
$topic_types = array(
|
|
|
|
|
'sticky' => array('const' => POST_STICKY, 'lang' => 'POST_STICKY'),
|
|
|
|
|
'announce' => array('const' => POST_ANNOUNCE, 'lang' => 'POST_ANNOUNCEMENT'),
|
|
|
|
|
'global' => array('const' => POST_GLOBAL, 'lang' => 'POST_GLOBAL')
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$topic_type_array = array();
|
|
|
|
|
|
|
|
|
|
foreach ($topic_types as $auth_key => $topic_value)
|
|
|
|
|
{
|
|
|
|
|
// Temp - we do not have a special post global announcement permission
|
|
|
|
|
$auth_key = ($auth_key == 'global') ? 'announce' : $auth_key;
|
|
|
|
|
|
|
|
|
|
if ($auth->acl_get('f_' . $auth_key, $forum_id))
|
|
|
|
|
{
|
|
|
|
|
$toggle = true;
|
|
|
|
|
|
|
|
|
|
$topic_type_array[] = array(
|
|
|
|
|
'VALUE' => $topic_value['const'],
|
|
|
|
|
'S_CHECKED' => ($cur_topic_type == $topic_value['const'] || ($forum_id == 0 && $topic_value['const'] == POST_GLOBAL)) ? ' checked="checked"' : '',
|
|
|
|
|
'L_TOPIC_TYPE' => $user->lang[$topic_value['lang']]
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($toggle)
|
|
|
|
|
{
|
|
|
|
|
$topic_type_array = array_merge(array(0 => array(
|
|
|
|
|
'VALUE' => POST_NORMAL,
|
|
|
|
|
'S_CHECKED' => ($topic_type == POST_NORMAL) ? ' checked="checked"' : '',
|
|
|
|
|
'L_TOPIC_TYPE' => $user->lang['POST_NORMAL'])),
|
|
|
|
|
|
|
|
|
|
$topic_type_array
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
foreach ($topic_type_array as $array)
|
|
|
|
|
{
|
|
|
|
|
$template->assign_block_vars('topic_type', $array);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$template->assign_vars(array(
|
|
|
|
|
'S_TOPIC_TYPE_STICKY' => ($auth->acl_get('f_sticky', $forum_id)),
|
|
|
|
|
'S_TOPIC_TYPE_ANNOUNCE' => ($auth->acl_get('f_announce', $forum_id)))
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $toggle;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function posting_gen_attachment_entry($message_parser)
|
|
|
|
|
{
|
|
|
|
|
global $template, $config, $phpbb_root_path, $SID, $phpEx;
|
|
|
|
|
|
|
|
|
|
$template->assign_vars(array(
|
|
|
|
|
'S_SHOW_ATTACH_BOX' => true)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (sizeof($message_parser->attachment_data))
|
|
|
|
|
{
|
|
|
|
|
$template->assign_vars(array(
|
|
|
|
|
'S_HAS_ATTACHMENTS' => true)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$count = 0;
|
|
|
|
|
foreach ($message_parser->attachment_data as $attach_row)
|
|
|
|
|
{
|
|
|
|
|
$hidden = '';
|
|
|
|
|
$attach_row['real_filename'] = stripslashes($attach_row['real_filename']);
|
|
|
|
|
|
|
|
|
|
foreach ($attach_row as $key => $value)
|
|
|
|
|
{
|
|
|
|
|
$hidden .= '<input type="hidden" name="attachment_data[' . $count . '][' . $key . ']" value="' . $value . '" />';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$download_link = (!$attach_row['attach_id']) ? $config['upload_dir'] . '/' . $attach_row['physical_filename'] : $phpbb_root_path . "download.$phpEx$SID&id=" . intval($attach_row['attach_id']);
|
|
|
|
|
|
|
|
|
|
$template->assign_block_vars('attach_row', array(
|
|
|
|
|
'FILENAME' => $attach_row['real_filename'],
|
|
|
|
|
'ATTACH_FILENAME' => $attach_row['physical_filename'],
|
|
|
|
|
'FILE_COMMENT' => $attach_row['comment'],
|
|
|
|
|
'ATTACH_ID' => $attach_row['attach_id'],
|
|
|
|
|
'ASSOC_INDEX' => $count,
|
|
|
|
|
|
|
|
|
|
'U_VIEW_ATTACHMENT' => $download_link,
|
|
|
|
|
'S_HIDDEN' => $hidden)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$count++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$template->assign_vars(array(
|
|
|
|
|
'FILE_COMMENT' => $message_parser->filename_data['filecomment'],
|
|
|
|
|
'FILESIZE' => $config['max_filesize'],
|
|
|
|
|
'FILENAME' => $message_parser->filename_data['filename'])
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return sizeof($message_parser->attachment_data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Load Drafts
|
|
|
|
|
function load_drafts($topic_id = 0, $forum_id = 0, $id = 0)
|
|
|
|
|
{
|
|
|
|
|
global $user, $db, $template, $phpEx, $SID, $auth;
|
|
|
|
|
|
|
|
|
|
// Only those fitting into this forum...
|
|
|
|
|
if ($forum_id || $topic_id)
|
|
|
|
|
{
|
|
|
|
|
$sql = 'SELECT d.draft_id, d.topic_id, d.forum_id, d.draft_subject, d.save_time, f.forum_name
|
|
|
|
|
FROM ' . DRAFTS_TABLE . ' d, ' . FORUMS_TABLE . ' f
|
|
|
|
|
WHERE d.user_id = ' . $user->data['user_id'] . '
|
|
|
|
|
AND f.forum_id = d.forum_id ' .
|
|
|
|
|
(($forum_id) ? " AND f.forum_id = $forum_id" : '') . '
|
|
|
|
|
ORDER BY d.save_time DESC';
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
$sql = 'SELECT *
|
|
|
|
|
FROM ' . DRAFTS_TABLE . '
|
|
|
|
|
WHERE user_id = ' . $user->data['user_id'] . '
|
|
|
|
|
AND forum_id = 0
|
|
|
|
|
AND topic_id = 0
|
|
|
|
|
ORDER BY save_time DESC';
|
|
|
|
|
}
|
|
|
|
|
$result = $db->sql_query($sql);
|
|
|
|
|
|
|
|
|
|
$draftrows = $topic_ids = array();
|
|
|
|
|
|
|
|
|
|
while ($row = $db->sql_fetchrow($result))
|
|
|
|
|
{
|
|
|
|
|
if ($row['topic_id'])
|
|
|
|
|
{
|
|
|
|
|
$topic_ids[] = (int) $row['topic_id'];
|
|
|
|
|
}
|
|
|
|
|
$draftrows[] = $row;
|
|
|
|
|
}
|
|
|
|
|
$db->sql_freeresult($result);
|
|
|
|
|
|
|
|
|
|
if (sizeof($topic_ids))
|
|
|
|
|
{
|
|
|
|
|
$sql = 'SELECT topic_id, forum_id, topic_title
|
|
|
|
|
FROM ' . TOPICS_TABLE . '
|
|
|
|
|
WHERE topic_id IN (' . implode(',', array_unique($topic_ids)) . ')';
|
|
|
|
|
$result = $db->sql_query($sql);
|
|
|
|
|
|
|
|
|
|
while ($row = $db->sql_fetchrow($result))
|
|
|
|
|
{
|
|
|
|
|
$topic_rows[$row['topic_id']] = $row;
|
|
|
|
|
}
|
|
|
|
|
$db->sql_freeresult($result);
|
|
|
|
|
}
|
|
|
|
|
unset($topic_ids);
|
|
|
|
|
|
|
|
|
|
if (sizeof($draftrows))
|
|
|
|
|
{
|
|
|
|
|
$row_count = 0;
|
|
|
|
|
$template->assign_var('S_SHOW_DRAFTS', true);
|
|
|
|
|
|
|
|
|
|
foreach ($draftrows as $draft)
|
|
|
|
|
{
|
|
|
|
|
$link_topic = $link_forum = $link_pm = false;
|
|
|
|
|
$insert_url = $view_url = $title = '';
|
|
|
|
|
|
|
|
|
|
if (isset($topic_rows[$draft['topic_id']]) && $auth->acl_get('f_read', $topic_rows[$draft['topic_id']]['forum_id']))
|
|
|
|
|
{
|
|
|
|
|
$link_topic = true;
|
|
|
|
|
$view_url = "viewtopic.$phpEx$SID&f=" . $topic_rows[$draft['topic_id']]['forum_id'] . "&t=" . $draft['topic_id'];
|
|
|
|
|
$title = $topic_rows[$draft['topic_id']]['topic_title'];
|
|
|
|
|
|
|
|
|
|
$insert_url = "posting.$phpEx$SID&f=" . $topic_rows[$draft['topic_id']]['forum_id'] . '&t=' . $draft['topic_id'] . '&mode=reply&d=' . $draft['draft_id'];
|
|
|
|
|
}
|
|
|
|
|
else if ($auth->acl_get('f_read', $draft['forum_id']))
|
|
|
|
|
{
|
|
|
|
|
$link_forum = true;
|
|
|
|
|
$view_url = "viewforum.$phpEx$SID&f=" . $draft['forum_id'];
|
|
|
|
|
$title = $draft['forum_name'];
|
|
|
|
|
|
|
|
|
|
$insert_url = "posting.$phpEx$SID&f=" . $draft['forum_id'] . '&mode=post&d=' . $draft['draft_id'];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
$link_pm = true;
|
|
|
|
|
$insert_url = "ucp.$phpEx$SID&i=$id&mode=compose&d=" . $draft['draft_id'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$template->assign_block_vars('draftrow', array(
|
|
|
|
|
'DRAFT_ID' => $draft['draft_id'],
|
|
|
|
|
'DATE' => $user->format_date($draft['save_time']),
|
|
|
|
|
'DRAFT_SUBJECT' => $draft['draft_subject'],
|
|
|
|
|
|
|
|
|
|
'TITLE' => $title,
|
|
|
|
|
'U_VIEW' => $view_url,
|
|
|
|
|
'U_INSERT' => $insert_url,
|
|
|
|
|
|
|
|
|
|
'S_ROW_COUNT' => $row_count++,
|
|
|
|
|
'S_LINK_PM' => $link_pm,
|
|
|
|
|
'S_LINK_TOPIC' => $link_topic,
|
|
|
|
|
'S_LINK_FORUM' => $link_forum)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-07-14 14:37:47 +00:00
|
|
|
|
?>
|