1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
|
<?php
/***************************************************************************
* functions_posting.php
* -------------------
* begin : Saturday, Feb 13, 2001
* copyright : (C) 2001 The phpBB Group
* email : support@phpbb.com
*
* $Id$
*
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
// Fill smiley templates (or just the variables) with smileys
// Either in a window or inline
function generate_smilies($mode)
{
global $SID, $auth, $db, $user, $config, $template;
global $starttime, $phpEx, $phpbb_root_path;
// TODO: To be added to the schema
$config['max_smilies_inline'] = 20;
if ($mode == 'window')
{
$page_title = $user->lang['TOPIC_REVIEW'] . " - $topic_title";
include($phpbb_root_path . 'includes/page_header.'.$phpEx);
$template->set_filenames(array(
'body' => 'posting_smilies.html')
);
}
$where_sql = ($mode == 'inline') ? 'WHERE display_on_posting = 1 ' : '';
$sql = "SELECT emoticon, code, smile_url, smile_width, smile_height
FROM " . SMILIES_TABLE . "
$where_sql
ORDER BY smile_order";
$result = $db->sql_query($sql);
$num_smilies = 0;
$smile_array = array();
if ($row = $db->sql_fetchrow($result))
{
do
{
if (!in_array($row['smile_url'], $smile_array))
{
if ($mode == 'window' || ($mode == 'inline' && $num_smilies < $config['max_smilies_inline']))
{
$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'])
);
}
$smile_array[] = $row['smile_url'];
$num_smilies++;
}
}
while ($row = $db->sql_fetchrow($result));
$db->sql_freeresult($result);
if ($mode == 'inline' && $num_smilies >= $config['max_smilies_inline'])
{
$template->assign_vars(array(
'S_SHOW_EMOTICON_LINK' => true,
'U_MORE_SMILIES' => "posting.$phpEx$SID&mode=smilies")
);
}
}
if ($mode == 'window')
{
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
}
}
// Generate Topic Icons
function generate_topic_icons($mode, $enable_icons)
{
global $template, $config;
if (!$enable_icons)
{
return (false);
}
$result = false;
// Grab icons
$icons = array();
obtain_icons($icons);
if (sizeof($icons))
{
$result = true;
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 ($result);
}
// DECODE TEXT -> This will/should be handled by bbcode.php eventually
function decode_text(&$message)
{
global $config, $censors;
$server_protocol = ($config['cookie_secure']) ? 'https://' : 'http://';
$server_port = ($config['server_port'] <> 80) ? ':' . trim($config['server_port']) . '/' : '/';
$match = array(
'#<!\-\- b \-\-><b>(.*?)</b><!\-\- b \-\->#s',
'#<!\-\- u \-\-><u>(.*?)</u><!\-\- u \-\->#s',
'#<!\-\- 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 \-\->#',
);
$replace = array(
'[b]\1[/b]',
'[u]\1[/u]',
'\1',
'\1',
'\1',
$server_protocol . trim($config['server_name']) . $server_port . preg_replace('/^\/?(.*?)(\/)?$/', '\1', trim($config['script_path'])) . '/\1',
'\1',
);
if (empty($censors))
{
$censors = array();
obtain_word_list($censors);
}
$message = preg_replace($match, $replace, $message);
return;
}
// Quote Text
function quote_text(&$message, $username = '')
{
$message = ' [quote' . ( (empty($username)) ? ']' : '="]' . addslashes(trim($username)) . '"]') . trim($message) . '[/quote] ';
}
?>
|