| 1 |
2666 |
psotfx |
<?php
|
| 2 |
8146 |
acydburn |
/**
|
| 3 |
5114 |
acydburn |
*
|
| 4 |
5114 |
acydburn |
* @package phpBB3
|
| 5 |
5114 |
acydburn |
* @version $Id$
|
| 6 |
8146 |
acydburn |
* @copyright (c) 2005 phpBB Group
|
| 7 |
8146 |
acydburn |
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
| 8 |
5114 |
acydburn |
*
|
| 9 |
5114 |
acydburn |
*/
|
| 10 |
2666 |
psotfx |
|
| 11 |
5114 |
acydburn |
/**
|
| 12 |
8146 |
acydburn |
* @ignore
|
| 13 |
8146 |
acydburn |
*/
|
| 14 |
8146 |
acydburn |
if (!defined('IN_PHPBB'))
|
| 15 |
8146 |
acydburn |
{
|
| 16 |
8146 |
acydburn |
exit;
|
| 17 |
8146 |
acydburn |
}
|
| 18 |
8146 |
acydburn |
|
| 19 |
8146 |
acydburn |
/**
|
| 20 |
6915 |
acydburn |
* Fill smiley templates (or just the variables) with smilies, either in a window or inline
|
| 21 |
5114 |
acydburn |
*/
|
| 22 |
4544 |
acydburn |
function generate_smilies($mode, $forum_id)
|
| 23 |
2923 |
psotfx |
{
|
| 24 |
9242 |
acydburn |
global $auth, $db, $user, $template;
|
| 25 |
2923 |
psotfx |
|
| 26 |
3013 |
psotfx |
if ($mode == 'window')
|
| 27 |
2923 |
psotfx |
{
|
| 28 |
4883 |
acydburn |
if ($forum_id)
|
| 29 |
4544 |
acydburn |
{
|
| 30 |
4883 |
acydburn |
$sql = 'SELECT forum_style
|
| 31 |
4883 |
acydburn |
FROM ' . FORUMS_TABLE . "
|
| 32 |
4883 |
acydburn |
WHERE forum_id = $forum_id";
|
| 33 |
4883 |
acydburn |
$result = $db->sql_query_limit($sql, 1);
|
| 34 |
4883 |
acydburn |
$row = $db->sql_fetchrow($result);
|
| 35 |
4883 |
acydburn |
$db->sql_freeresult($result);
|
| 36 |
8253 |
kellanved |
|
| 37 |
4883 |
acydburn |
$user->setup('posting', (int) $row['forum_style']);
|
| 38 |
4544 |
acydburn |
}
|
| 39 |
4883 |
acydburn |
else
|
| 40 |
4883 |
acydburn |
{
|
| 41 |
4883 |
acydburn |
$user->setup('posting');
|
| 42 |
4883 |
acydburn |
}
|
| 43 |
4440 |
psotfx |
|
| 44 |
5109 |
acydburn |
page_header($user->lang['SMILIES']);
|
| 45 |
2923 |
psotfx |
|
| 46 |
2923 |
psotfx |
$template->set_filenames(array(
|
| 47 |
2986 |
psotfx |
'body' => 'posting_smilies.html')
|
| 48 |
2923 |
psotfx |
);
|
| 49 |
2923 |
psotfx |
}
|
| 50 |
2923 |
psotfx |
|
| 51 |
4767 |
acydburn |
$display_link = false;
|
| 52 |
4544 |
acydburn |
if ($mode == 'inline')
|
| 53 |
4544 |
acydburn |
{
|
| 54 |
5109 |
acydburn |
$sql = 'SELECT smiley_id
|
| 55 |
4549 |
acydburn |
FROM ' . SMILIES_TABLE . '
|
| 56 |
4550 |
acydburn |
WHERE display_on_posting = 0';
|
| 57 |
4544 |
acydburn |
$result = $db->sql_query_limit($sql, 1, 0, 3600);
|
| 58 |
4578 |
psotfx |
|
| 59 |
4550 |
acydburn |
if ($row = $db->sql_fetchrow($result))
|
| 60 |
4550 |
acydburn |
{
|
| 61 |
4767 |
acydburn |
$display_link = true;
|
| 62 |
4550 |
acydburn |
}
|
| 63 |
4578 |
psotfx |
$db->sql_freeresult($result);
|
| 64 |
4544 |
acydburn |
}
|
| 65 |
4544 |
acydburn |
|
| 66 |
5832 |
davidmj |
$last_url = '';
|
| 67 |
5832 |
davidmj |
|
| 68 |
4451 |
acydburn |
$sql = 'SELECT *
|
| 69 |
8146 |
acydburn |
FROM ' . SMILIES_TABLE .
|
| 70 |
4057 |
acydburn |
(($mode == 'inline') ? ' WHERE display_on_posting = 1 ' : '') . '
|
| 71 |
5109 |
acydburn |
ORDER BY smiley_order';
|
| 72 |
4544 |
acydburn |
$result = $db->sql_query($sql, 3600);
|
| 73 |
2923 |
psotfx |
|
| 74 |
7614 |
acydburn |
$smilies = array();
|
| 75 |
4550 |
acydburn |
while ($row = $db->sql_fetchrow($result))
|
| 76 |
2923 |
psotfx |
{
|
| 77 |
7614 |
acydburn |
if (empty($smilies[$row['smiley_url']]))
|
| 78 |
5832 |
davidmj |
{
|
| 79 |
7614 |
acydburn |
$smilies[$row['smiley_url']] = $row;
|
| 80 |
7614 |
acydburn |
}
|
| 81 |
7614 |
acydburn |
}
|
| 82 |
7614 |
acydburn |
$db->sql_freeresult($result);
|
| 83 |
7614 |
acydburn |
|
| 84 |
7614 |
acydburn |
if (sizeof($smilies))
|
| 85 |
7614 |
acydburn |
{
|
| 86 |
7614 |
acydburn |
foreach ($smilies as $row)
|
| 87 |
7614 |
acydburn |
{
|
| 88 |
5832 |
davidmj |
$template->assign_block_vars('smiley', array(
|
| 89 |
5888 |
naderman |
'SMILEY_CODE' => $row['code'],
|
| 90 |
5888 |
naderman |
'A_SMILEY_CODE' => addslashes($row['code']),
|
| 91 |
9242 |
acydburn |
'SMILEY_IMG' => PHPBB_ROOT_PATH . phpbb::$config['smilies_path'] . '/' . $row['smiley_url'],
|
| 92 |
5888 |
naderman |
'SMILEY_WIDTH' => $row['smiley_width'],
|
| 93 |
5888 |
naderman |
'SMILEY_HEIGHT' => $row['smiley_height'],
|
| 94 |
5888 |
naderman |
'SMILEY_DESC' => $row['emotion'])
|
| 95 |
5832 |
davidmj |
);
|
| 96 |
5832 |
davidmj |
}
|
| 97 |
2923 |
psotfx |
}
|
| 98 |
2923 |
psotfx |
|
| 99 |
4550 |
acydburn |
if ($mode == 'inline' && $display_link)
|
| 100 |
4550 |
acydburn |
{
|
| 101 |
4550 |
acydburn |
$template->assign_vars(array(
|
| 102 |
5109 |
acydburn |
'S_SHOW_SMILEY_LINK' => true,
|
| 103 |
8572 |
acydburn |
'U_MORE_SMILIES' => append_sid('posting', 'mode=smilies&f=' . $forum_id))
|
| 104 |
4550 |
acydburn |
);
|
| 105 |
4550 |
acydburn |
}
|
| 106 |
4550 |
acydburn |
|
| 107 |
2986 |
psotfx |
if ($mode == 'window')
|
| 108 |
2923 |
psotfx |
{
|
| 109 |
4057 |
acydburn |
page_footer();
|
| 110 |
2923 |
psotfx |
}
|
| 111 |
2923 |
psotfx |
}
|
| 112 |
2923 |
psotfx |
|
| 113 |
5114 |
acydburn |
/**
|
| 114 |
6787 |
acydburn |
* Update last post information
|
| 115 |
6650 |
acydburn |
* Should be used instead of sync() if only the last post information are out of sync... faster
|
| 116 |
5902 |
acydburn |
*
|
| 117 |
7355 |
naderman |
* @param string $type Can be forum|topic
|
| 118 |
7355 |
naderman |
* @param mixed $ids topic/forum ids
|
| 119 |
7355 |
naderman |
* @param bool $return_update_sql true: SQL query shall be returned, false: execute SQL
|
| 120 |
5114 |
acydburn |
*/
|
| 121 |
7507 |
davidmj |
function update_post_information($type, $ids, $return_update_sql = false)
|
| 122 |
3887 |
acydburn |
{
|
| 123 |
3887 |
acydburn |
global $db;
|
| 124 |
3887 |
acydburn |
|
| 125 |
7800 |
kellanved |
if (empty($ids))
|
| 126 |
7800 |
kellanved |
{
|
| 127 |
7800 |
kellanved |
return;
|
| 128 |
7800 |
kellanved |
}
|
| 129 |
5486 |
acydburn |
if (!is_array($ids))
|
| 130 |
5486 |
acydburn |
{
|
| 131 |
5486 |
acydburn |
$ids = array($ids);
|
| 132 |
5486 |
acydburn |
}
|
| 133 |
4573 |
acydburn |
|
| 134 |
7800 |
kellanved |
|
| 135 |
6511 |
acydburn |
$update_sql = $empty_forums = $not_empty_forums = array();
|
| 136 |
5088 |
acydburn |
|
| 137 |
7191 |
naderman |
if ($type != 'topic')
|
| 138 |
7191 |
naderman |
{
|
| 139 |
7191 |
naderman |
$topic_join = ', ' . TOPICS_TABLE . ' t';
|
| 140 |
7191 |
naderman |
$topic_condition = 'AND t.topic_id = p.topic_id AND t.topic_approved = 1';
|
| 141 |
7191 |
naderman |
}
|
| 142 |
7191 |
naderman |
else
|
| 143 |
7191 |
naderman |
{
|
| 144 |
7191 |
naderman |
$topic_join = '';
|
| 145 |
7191 |
naderman |
$topic_condition = '';
|
| 146 |
7191 |
naderman |
}
|
| 147 |
7191 |
naderman |
|
| 148 |
6364 |
acydburn |
if (sizeof($ids) == 1)
|
| 149 |
6364 |
acydburn |
{
|
| 150 |
7191 |
naderman |
$sql = 'SELECT MAX(p.post_id) as last_post_id
|
| 151 |
7191 |
naderman |
FROM ' . POSTS_TABLE . " p $topic_join
|
| 152 |
7191 |
naderman |
WHERE " . $db->sql_in_set('p.' . $type . '_id', $ids) . "
|
| 153 |
7191 |
naderman |
$topic_condition
|
| 154 |
7518 |
davidmj |
AND p.post_approved = 1";
|
| 155 |
6364 |
acydburn |
}
|
| 156 |
6364 |
acydburn |
else
|
| 157 |
6364 |
acydburn |
{
|
| 158 |
7191 |
naderman |
$sql = 'SELECT p.' . $type . '_id, MAX(p.post_id) as last_post_id
|
| 159 |
7191 |
naderman |
FROM ' . POSTS_TABLE . " p $topic_join
|
| 160 |
7191 |
naderman |
WHERE " . $db->sql_in_set('p.' . $type . '_id', $ids) . "
|
| 161 |
7191 |
naderman |
$topic_condition
|
| 162 |
7191 |
naderman |
AND p.post_approved = 1
|
| 163 |
7191 |
naderman |
GROUP BY p.{$type}_id";
|
| 164 |
6364 |
acydburn |
}
|
| 165 |
4676 |
acydburn |
$result = $db->sql_query($sql);
|
| 166 |
3887 |
acydburn |
|
| 167 |
5486 |
acydburn |
$last_post_ids = array();
|
| 168 |
5486 |
acydburn |
while ($row = $db->sql_fetchrow($result))
|
| 169 |
4477 |
acydburn |
{
|
| 170 |
6364 |
acydburn |
if (sizeof($ids) == 1)
|
| 171 |
6364 |
acydburn |
{
|
| 172 |
6364 |
acydburn |
$row[$type . '_id'] = $ids[0];
|
| 173 |
6364 |
acydburn |
}
|
| 174 |
6364 |
acydburn |
|
| 175 |
5486 |
acydburn |
if ($type == 'forum')
|
| 176 |
5486 |
acydburn |
{
|
| 177 |
6511 |
acydburn |
$not_empty_forums[] = $row['forum_id'];
|
| 178 |
6511 |
acydburn |
|
| 179 |
6511 |
acydburn |
if (empty($row['last_post_id']))
|
| 180 |
6511 |
acydburn |
{
|
| 181 |
6511 |
acydburn |
$empty_forums[] = $row['forum_id'];
|
| 182 |
6511 |
acydburn |
}
|
| 183 |
5486 |
acydburn |
}
|
| 184 |
5486 |
acydburn |
|
| 185 |
5486 |
acydburn |
$last_post_ids[] = $row['last_post_id'];
|
| 186 |
5486 |
acydburn |
}
|
| 187 |
5486 |
acydburn |
$db->sql_freeresult($result);
|
| 188 |
5486 |
acydburn |
|
| 189 |
5486 |
acydburn |
if ($type == 'forum')
|
| 190 |
5486 |
acydburn |
{
|
| 191 |
6511 |
acydburn |
$empty_forums = array_merge($empty_forums, array_diff($ids, $not_empty_forums));
|
| 192 |
5486 |
acydburn |
|
| 193 |
5486 |
acydburn |
foreach ($empty_forums as $void => $forum_id)
|
| 194 |
5486 |
acydburn |
{
|
| 195 |
5486 |
acydburn |
$update_sql[$forum_id][] = 'forum_last_post_id = 0';
|
| 196 |
6360 |
grahamje |
$update_sql[$forum_id][] = "forum_last_post_subject = ''";
|
| 197 |
6311 |
grahamje |
$update_sql[$forum_id][] = 'forum_last_post_time = 0';
|
| 198 |
5486 |
acydburn |
$update_sql[$forum_id][] = 'forum_last_poster_id = 0';
|
| 199 |
5486 |
acydburn |
$update_sql[$forum_id][] = "forum_last_poster_name = ''";
|
| 200 |
6311 |
grahamje |
$update_sql[$forum_id][] = "forum_last_poster_colour = ''";
|
| 201 |
5486 |
acydburn |
}
|
| 202 |
5486 |
acydburn |
}
|
| 203 |
5486 |
acydburn |
|
| 204 |
5486 |
acydburn |
if (sizeof($last_post_ids))
|
| 205 |
5486 |
acydburn |
{
|
| 206 |
6360 |
grahamje |
$sql = 'SELECT p.' . $type . '_id, p.post_id, p.post_subject, p.post_time, p.poster_id, p.post_username, u.user_id, u.username, u.user_colour
|
| 207 |
4676 |
acydburn |
FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u
|
| 208 |
4676 |
acydburn |
WHERE p.poster_id = u.user_id
|
| 209 |
6271 |
acydburn |
AND ' . $db->sql_in_set('p.post_id', $last_post_ids);
|
| 210 |
4676 |
acydburn |
$result = $db->sql_query($sql);
|
| 211 |
5486 |
acydburn |
|
| 212 |
5486 |
acydburn |
while ($row = $db->sql_fetchrow($result))
|
| 213 |
5486 |
acydburn |
{
|
| 214 |
5486 |
acydburn |
$update_sql[$row["{$type}_id"]][] = $type . '_last_post_id = ' . (int) $row['post_id'];
|
| 215 |
6360 |
grahamje |
$update_sql[$row["{$type}_id"]][] = "{$type}_last_post_subject = '" . $db->sql_escape($row['post_subject']) . "'";
|
| 216 |
5486 |
acydburn |
$update_sql[$row["{$type}_id"]][] = $type . '_last_post_time = ' . (int) $row['post_time'];
|
| 217 |
5486 |
acydburn |
$update_sql[$row["{$type}_id"]][] = $type . '_last_poster_id = ' . (int) $row['poster_id'];
|
| 218 |
6311 |
grahamje |
$update_sql[$row["{$type}_id"]][] = "{$type}_last_poster_colour = '" . $db->sql_escape($row['user_colour']) . "'";
|
| 219 |
5486 |
acydburn |
$update_sql[$row["{$type}_id"]][] = "{$type}_last_poster_name = '" . (($row['poster_id'] == ANONYMOUS) ? $db->sql_escape($row['post_username']) : $db->sql_escape($row['username'])) . "'";
|
| 220 |
5486 |
acydburn |
}
|
| 221 |
4676 |
acydburn |
$db->sql_freeresult($result);
|
| 222 |
5486 |
acydburn |
}
|
| 223 |
5486 |
acydburn |
unset($empty_forums, $ids, $last_post_ids);
|
| 224 |
4676 |
acydburn |
|
| 225 |
5902 |
acydburn |
if ($return_update_sql || !sizeof($update_sql))
|
| 226 |
5486 |
acydburn |
{
|
| 227 |
5902 |
acydburn |
return $update_sql;
|
| 228 |
4477 |
acydburn |
}
|
| 229 |
5486 |
acydburn |
|
| 230 |
5486 |
acydburn |
$table = ($type == 'forum') ? FORUMS_TABLE : TOPICS_TABLE;
|
| 231 |
5486 |
acydburn |
|
| 232 |
5486 |
acydburn |
foreach ($update_sql as $update_id => $update_sql_ary)
|
| 233 |
4477 |
acydburn |
{
|
| 234 |
5486 |
acydburn |
$sql = "UPDATE $table
|
| 235 |
5486 |
acydburn |
SET " . implode(', ', $update_sql_ary) . "
|
| 236 |
5486 |
acydburn |
WHERE {$type}_id = $update_id";
|
| 237 |
5486 |
acydburn |
$db->sql_query($sql);
|
| 238 |
4477 |
acydburn |
}
|
| 239 |
5967 |
acydburn |
|
| 240 |
5967 |
acydburn |
return;
|
| 241 |
3887 |
acydburn |
}
|
| 242 |
3887 |
acydburn |
|
| 243 |
5114 |
acydburn |
/**
|
| 244 |
5902 |
acydburn |
* Generate Topic Icons for display
|
| 245 |
5902 |
acydburn |
*/
|
| 246 |
5902 |
acydburn |
function posting_gen_topic_icons($mode, $icon_id)
|
| 247 |
5902 |
acydburn |
{
|
| 248 |
9242 |
acydburn |
global $template;
|
| 249 |
5902 |
acydburn |
|
| 250 |
5902 |
acydburn |
// Grab icons
|
| 251 |
9226 |
acydburn |
$icons = phpbb_cache::obtain_icons();
|
| 252 |
5902 |
acydburn |
|
| 253 |
5902 |
acydburn |
if (!$icon_id)
|
| 254 |
5902 |
acydburn |
{
|
| 255 |
5902 |
acydburn |
$template->assign_var('S_NO_ICON_CHECKED', ' checked="checked"');
|
| 256 |
5902 |
acydburn |
}
|
| 257 |
6015 |
acydburn |
|
| 258 |
5902 |
acydburn |
if (sizeof($icons))
|
| 259 |
5902 |
acydburn |
{
|
| 260 |
5902 |
acydburn |
foreach ($icons as $id => $data)
|
| 261 |
5902 |
acydburn |
{
|
| 262 |
5902 |
acydburn |
if ($data['display'])
|
| 263 |
5902 |
acydburn |
{
|
| 264 |
5902 |
acydburn |
$template->assign_block_vars('topic_icon', array(
|
| 265 |
5902 |
acydburn |
'ICON_ID' => $id,
|
| 266 |
9242 |
acydburn |
'ICON_IMG' => PHPBB_ROOT_PATH . phpbb::$config['icons_path'] . '/' . $data['img'],
|
| 267 |
5902 |
acydburn |
'ICON_WIDTH' => $data['width'],
|
| 268 |
6015 |
acydburn |
'ICON_HEIGHT' => $data['height'],
|
| 269 |
8351 |
acydburn |
|
| 270 |
5902 |
acydburn |
'S_CHECKED' => ($id == $icon_id) ? true : false,
|
| 271 |
5902 |
acydburn |
'S_ICON_CHECKED' => ($id == $icon_id) ? ' checked="checked"' : '')
|
| 272 |
5902 |
acydburn |
);
|
| 273 |
5902 |
acydburn |
}
|
| 274 |
5902 |
acydburn |
}
|
| 275 |
5902 |
acydburn |
|
| 276 |
5902 |
acydburn |
return true;
|
| 277 |
5902 |
acydburn |
}
|
| 278 |
5902 |
acydburn |
|
| 279 |
5902 |
acydburn |
return false;
|
| 280 |
5902 |
acydburn |
}
|
| 281 |
5902 |
acydburn |
|
| 282 |
5902 |
acydburn |
/**
|
| 283 |
5902 |
acydburn |
* Build topic types able to be selected
|
| 284 |
5902 |
acydburn |
*/
|
| 285 |
5902 |
acydburn |
function posting_gen_topic_types($forum_id, $cur_topic_type = POST_NORMAL)
|
| 286 |
5902 |
acydburn |
{
|
| 287 |
5902 |
acydburn |
global $auth, $user, $template, $topic_type;
|
| 288 |
5902 |
acydburn |
|
| 289 |
5902 |
acydburn |
$toggle = false;
|
| 290 |
5902 |
acydburn |
|
| 291 |
5902 |
acydburn |
$topic_types = array(
|
| 292 |
5902 |
acydburn |
'sticky' => array('const' => POST_STICKY, 'lang' => 'POST_STICKY'),
|
| 293 |
5902 |
acydburn |
'announce' => array('const' => POST_ANNOUNCE, 'lang' => 'POST_ANNOUNCEMENT'),
|
| 294 |
5902 |
acydburn |
'global' => array('const' => POST_GLOBAL, 'lang' => 'POST_GLOBAL')
|
| 295 |
5902 |
acydburn |
);
|
| 296 |
6015 |
acydburn |
|
| 297 |
5902 |
acydburn |
$topic_type_array = array();
|
| 298 |
6015 |
acydburn |
|
| 299 |
5902 |
acydburn |
foreach ($topic_types as $auth_key => $topic_value)
|
| 300 |
5902 |
acydburn |
{
|
| 301 |
5902 |
acydburn |
// We do not have a special post global announcement permission
|
| 302 |
5902 |
acydburn |
$auth_key = ($auth_key == 'global') ? 'announce' : $auth_key;
|
| 303 |
5902 |
acydburn |
|
| 304 |
5902 |
acydburn |
if ($auth->acl_get('f_' . $auth_key, $forum_id))
|
| 305 |
5902 |
acydburn |
{
|
| 306 |
5902 |
acydburn |
$toggle = true;
|
| 307 |
5902 |
acydburn |
|
| 308 |
5902 |
acydburn |
$topic_type_array[] = array(
|
| 309 |
5902 |
acydburn |
'VALUE' => $topic_value['const'],
|
| 310 |
5902 |
acydburn |
'S_CHECKED' => ($cur_topic_type == $topic_value['const'] || ($forum_id == 0 && $topic_value['const'] == POST_GLOBAL)) ? ' checked="checked"' : '',
|
| 311 |
5902 |
acydburn |
'L_TOPIC_TYPE' => $user->lang[$topic_value['lang']]
|
| 312 |
5902 |
acydburn |
);
|
| 313 |
5902 |
acydburn |
}
|
| 314 |
5902 |
acydburn |
}
|
| 315 |
5902 |
acydburn |
|
| 316 |
5902 |
acydburn |
if ($toggle)
|
| 317 |
5902 |
acydburn |
{
|
| 318 |
5902 |
acydburn |
$topic_type_array = array_merge(array(0 => array(
|
| 319 |
5902 |
acydburn |
'VALUE' => POST_NORMAL,
|
| 320 |
5902 |
acydburn |
'S_CHECKED' => ($topic_type == POST_NORMAL) ? ' checked="checked"' : '',
|
| 321 |
8146 |
acydburn |
'L_TOPIC_TYPE' => $user->lang['POST_NORMAL'])),
|
| 322 |
6015 |
acydburn |
|
| 323 |
5902 |
acydburn |
$topic_type_array
|
| 324 |
5902 |
acydburn |
);
|
| 325 |
8351 |
acydburn |
|
| 326 |
5902 |
acydburn |
foreach ($topic_type_array as $array)
|
| 327 |
5902 |
acydburn |
{
|
| 328 |
5902 |
acydburn |
$template->assign_block_vars('topic_type', $array);
|
| 329 |
5902 |
acydburn |
}
|
| 330 |
5902 |
acydburn |
|
| 331 |
5902 |
acydburn |
$template->assign_vars(array(
|
| 332 |
5902 |
acydburn |
'S_TOPIC_TYPE_STICKY' => ($auth->acl_get('f_sticky', $forum_id)),
|
| 333 |
5902 |
acydburn |
'S_TOPIC_TYPE_ANNOUNCE' => ($auth->acl_get('f_announce', $forum_id)))
|
| 334 |
5902 |
acydburn |
);
|
| 335 |
5902 |
acydburn |
}
|
| 336 |
5902 |
acydburn |
|
| 337 |
5902 |
acydburn |
return $toggle;
|
| 338 |
5902 |
acydburn |
}
|
| 339 |
5902 |
acydburn |
|
| 340 |
5902 |
acydburn |
//
|
| 341 |
5902 |
acydburn |
// Attachment related functions
|
| 342 |
5902 |
acydburn |
//
|
| 343 |
5902 |
acydburn |
|
| 344 |
5902 |
acydburn |
/**
|
| 345 |
5114 |
acydburn |
* Upload Attachment - filedata is generated here
|
| 346 |
5114 |
acydburn |
* Uses upload class
|
| 347 |
5114 |
acydburn |
*/
|
| 348 |
6977 |
acydburn |
function upload_attachment($form_name, $forum_id, $local = false, $local_storage = '', $is_message = false, $local_filedata = false)
|
| 349 |
3697 |
acydburn |
{
|
| 350 |
9242 |
acydburn |
global $auth, $user, $db;
|
| 351 |
3697 |
acydburn |
|
| 352 |
5902 |
acydburn |
$filedata = array(
|
| 353 |
5902 |
acydburn |
'error' => array()
|
| 354 |
5902 |
acydburn |
);
|
| 355 |
3697 |
acydburn |
|
| 356 |
8572 |
acydburn |
include_once(PHPBB_ROOT_PATH . 'includes/functions_upload.' . PHP_EXT);
|
| 357 |
5109 |
acydburn |
$upload = new fileupload();
|
| 358 |
6015 |
acydburn |
|
| 359 |
9242 |
acydburn |
if (phpbb::$config['check_attachment_content'])
|
| 360 |
8571 |
Kellanved |
{
|
| 361 |
9242 |
acydburn |
$upload->set_disallowed_content(explode('|', phpbb::$config['mime_triggers']));
|
| 362 |
8571 |
Kellanved |
}
|
| 363 |
8672 |
acydburn |
|
| 364 |
5140 |
acydburn |
if (!$local)
|
| 365 |
5140 |
acydburn |
{
|
| 366 |
5140 |
acydburn |
$filedata['post_attach'] = ($upload->is_valid($form_name)) ? true : false;
|
| 367 |
5140 |
acydburn |
}
|
| 368 |
5140 |
acydburn |
else
|
| 369 |
5140 |
acydburn |
{
|
| 370 |
5140 |
acydburn |
$filedata['post_attach'] = true;
|
| 371 |
5140 |
acydburn |
}
|
| 372 |
5109 |
acydburn |
|
| 373 |
3697 |
acydburn |
if (!$filedata['post_attach'])
|
| 374 |
3697 |
acydburn |
{
|
| 375 |
6364 |
acydburn |
$filedata['error'][] = $user->lang['NO_UPLOAD_FORM_FOUND'];
|
| 376 |
3898 |
acydburn |
return $filedata;
|
| 377 |
3697 |
acydburn |
}
|
| 378 |
3697 |
acydburn |
|
| 379 |
9226 |
acydburn |
$extensions = ($is_message) ? phpbb_cache::obtain_extensions_pm() : phpbb_cache::obtain_extensions_forum($forum_id);
|
| 380 |
5109 |
acydburn |
$upload->set_allowed_extensions(array_keys($extensions['_allowed_']));
|
| 381 |
3697 |
acydburn |
|
| 382 |
6977 |
acydburn |
$file = ($local) ? $upload->local_upload($local_storage, $local_filedata) : $upload->form_upload($form_name);
|
| 383 |
5032 |
acydburn |
|
| 384 |
5109 |
acydburn |
if ($file->init_error)
|
| 385 |
5032 |
acydburn |
{
|
| 386 |
5032 |
acydburn |
$filedata['post_attach'] = false;
|
| 387 |
5032 |
acydburn |
return $filedata;
|
| 388 |
5032 |
acydburn |
}
|
| 389 |
5032 |
acydburn |
|
| 390 |
5109 |
acydburn |
$cat_id = (isset($extensions[$file->get('extension')]['display_cat'])) ? $extensions[$file->get('extension')]['display_cat'] : ATTACHMENT_CATEGORY_NONE;
|
| 391 |
5032 |
acydburn |
|
| 392 |
6364 |
acydburn |
// Make sure the image category only holds valid images...
|
| 393 |
6364 |
acydburn |
if ($cat_id == ATTACHMENT_CATEGORY_IMAGE && !$file->is_image())
|
| 394 |
6364 |
acydburn |
{
|
| 395 |
6364 |
acydburn |
$file->remove();
|
| 396 |
6364 |
acydburn |
|
| 397 |
6364 |
acydburn |
// If this error occurs a user tried to exploit an IE Bug by renaming extensions
|
| 398 |
6364 |
acydburn |
// Since the image category is displaying content inline we need to catch this.
|
| 399 |
6973 |
acydburn |
trigger_error($user->lang['ATTACHED_IMAGE_NOT_IMAGE']);
|
| 400 |
6364 |
acydburn |
}
|
| 401 |
6364 |
acydburn |
|
| 402 |
5109 |
acydburn |
// Do we have to create a thumbnail?
|
| 403 |
9242 |
acydburn |
$filedata['thumbnail'] = ($cat_id == ATTACHMENT_CATEGORY_IMAGE && phpbb::$config['img_create_thumbnail']) ? 1 : 0;
|
| 404 |
5032 |
acydburn |
|
| 405 |
3697 |
acydburn |
// Check Image Size, if it is an image
|
| 406 |
6046 |
naderman |
if (!$auth->acl_get('a_') && !$auth->acl_get('m_', $forum_id) && $cat_id == ATTACHMENT_CATEGORY_IMAGE)
|
| 407 |
3697 |
acydburn |
{
|
| 408 |
9242 |
acydburn |
$file->upload->set_allowed_dimensions(0, 0, phpbb::$config['img_max_width'], phpbb::$config['img_max_height']);
|
| 409 |
3697 |
acydburn |
}
|
| 410 |
4005 |
acydburn |
|
| 411 |
6165 |
acydburn |
// Admins and mods are allowed to exceed the allowed filesize
|
| 412 |
6046 |
naderman |
if (!$auth->acl_get('a_') && !$auth->acl_get('m_', $forum_id))
|
| 413 |
3697 |
acydburn |
{
|
| 414 |
6165 |
acydburn |
if (!empty($extensions[$file->get('extension')]['max_filesize']))
|
| 415 |
6165 |
acydburn |
{
|
| 416 |
6165 |
acydburn |
$allowed_filesize = $extensions[$file->get('extension')]['max_filesize'];
|
| 417 |
6165 |
acydburn |
}
|
| 418 |
6165 |
acydburn |
else
|
| 419 |
6165 |
acydburn |
{
|
| 420 |
9242 |
acydburn |
$allowed_filesize = ($is_message) ? phpbb::$config['max_filesize_pm'] : phpbb::$config['max_filesize'];
|
| 421 |
6165 |
acydburn |
}
|
| 422 |
6165 |
acydburn |
|
| 423 |
5109 |
acydburn |
$file->upload->set_max_filesize($allowed_filesize);
|
| 424 |
5109 |
acydburn |
}
|
| 425 |
6015 |
acydburn |
|
| 426 |
5109 |
acydburn |
$file->clean_filename('unique', $user->data['user_id'] . '_');
|
| 427 |
6015 |
acydburn |
|
| 428 |
7616 |
acydburn |
// Are we uploading an image *and* this image being within the image category? Only then perform additional image checks.
|
| 429 |
7616 |
acydburn |
$no_image = ($cat_id == ATTACHMENT_CATEGORY_IMAGE) ? false : true;
|
| 430 |
7616 |
acydburn |
|
| 431 |
9242 |
acydburn |
$file->move_file(phpbb::$config['upload_path'], false, $no_image);
|
| 432 |
7616 |
acydburn |
|
| 433 |
5109 |
acydburn |
if (sizeof($file->error))
|
| 434 |
5109 |
acydburn |
{
|
| 435 |
5109 |
acydburn |
$file->remove();
|
| 436 |
5109 |
acydburn |
$filedata['error'] = array_merge($filedata['error'], $file->error);
|
| 437 |
4767 |
acydburn |
$filedata['post_attach'] = false;
|
| 438 |
5032 |
acydburn |
|
| 439 |
3898 |
acydburn |
return $filedata;
|
| 440 |
3697 |
acydburn |
}
|
| 441 |
3697 |
acydburn |
|
| 442 |
5109 |
acydburn |
$filedata[ |