-
Notifications
You must be signed in to change notification settings - Fork 1
/
readme.txt
333 lines (257 loc) · 10.7 KB
/
readme.txt
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
##
##
## Mod title: Friendly URL
##
## Mod version: 1.0.9
## Works on FluxBB: 1.4.7
## Release date: 2011-11-16
## Review date: 2011-11-16
## Author: Daris ([email protected])
##
## Description: Backport of FluxBB 1.3 friendly URL feature
##
## Repository URL: http://fluxbb.org/resources/mods/friendly-url/
##
## Affected files: include/common.php
## include/functions.php
## include/cache.php
## viewtopic.php
##
## Upgrading from 1.0.8: overwrite include/friendly_url.php file
##
## Affects DB: Yes
##
## DISCLAIMER: Please note that "mods" are not officially supported by
## FluxBB. Installation of this modification is done at
## your own risk. Backup your forum database and any and
## all applicable files before proceeding.
##
##
#
#---------[ 1. UPLOAD ]-------------------------------------------------
#
files/install_mod.php to /
files/gen.php to /
files/rewrite.php to /
files/.htaccess to /
files/include/friendly_url.php to /include/
files/include/url/ to /include/url/
files/include/js/quick_jump.js to /include/js/ (if directory does not exist, create it)
files/plugins/AP_Friendly_URL.php to /plugins/
files/lang/English/url_replace.php to /lang/English/
files/lang/English/admin_plugin_friendly_url.php to /lang/English/
#
#---------[ 2. RUN ]----------------------------------------------------------
#
install_mod.php
#
#---------[ 3. DELETE ]-------------------------------------------------------
#
install_mod.php
#
#---------[ 4. OPEN ]---------------------------------------------------------
#
include/common.php
#
#---------[ 5. FIND ]---------------------------------------------
#
if (!defined('PUN_ROOT'))
#
#---------[ 6. BEFORE, ADD ]-------------------------------------------------
#
// Do not load common.php twice
if (defined('FORUM_VERSION'))
return;
#
#---------[ 7. FIND ]---------------------------------------------
#
require PUN_ROOT.'include/functions.php';
#
#---------[ 8. AFTER, ADD ]---------------------------------------------------
#
require PUN_ROOT.'include/friendly_url.php';
#
#---------[ 9. FIND ]---------------------------------------------
#
// Define standard date/time formats
#
#---------[ 10. BEFORE, ADD ]---------------------------------------------------
#
// Setup the URL rewriting scheme
if (file_exists(PUN_ROOT.'include/url/'.$pun_config['o_sef'].'/forum_urls.php'))
require PUN_ROOT.'include/url/'.$pun_config['o_sef'].'/forum_urls.php';
else
require PUN_ROOT.'include/url/Default/forum_urls.php';
// Convert rewritten url back to normal url
if (isset($_SERVER['HTTP_REFERER']))
{
$_SERVER['HTTP_REFERER_REWRITTEN'] = $_SERVER['HTTP_REFERER'];
$_SERVER['HTTP_REFERER'] = fix_referer();
}
#
#---------[ 11. OPEN ]---------------------------------------------------------
#
include/functions.php
#
#---------[ 12. FIND ]---------------------------------------------
#
function paginate($num_pages, $cur_page, $link)
{
global $lang_common;
$pages = array();
$link_to_all = false;
// If $cur_page == -1, we link to all pages (used in viewforum.php)
if ($cur_page == -1)
{
$cur_page = 1;
$link_to_all = true;
}
if ($num_pages <= 1)
$pages = array('<strong class="item1">1</strong>');
else
{
// Add a previous page link
if ($num_pages > 1 && $cur_page > 1)
$pages[] = '<a rel="prev" '.(empty($pages) ? ' class="item1"' : '').' href="'.$link.'&p='.($cur_page - 1).'">'.$lang_common['Previous'].'</a>';
if ($cur_page > 3)
{
$pages[] = '<a'.(empty($pages) ? ' class="item1"' : '').' href="'.$link.'&p=1">1</a>';
if ($cur_page > 5)
$pages[] = '<span class="spacer">'.$lang_common['Spacer'].'</span>';
}
// Don't ask me how the following works. It just does, OK? :-)
for ($current = ($cur_page == 5) ? $cur_page - 3 : $cur_page - 2, $stop = ($cur_page + 4 == $num_pages) ? $cur_page + 4 : $cur_page + 3; $current < $stop; ++$current)
{
if ($current < 1 || $current > $num_pages)
continue;
else if ($current != $cur_page || $link_to_all)
$pages[] = '<a'.(empty($pages) ? ' class="item1"' : '').' href="'.$link.'&p='.$current.'">'.forum_number_format($current).'</a>';
else
$pages[] = '<strong'.(empty($pages) ? ' class="item1"' : '').'>'.forum_number_format($current).'</strong>';
}
if ($cur_page <= ($num_pages-3))
{
if ($cur_page != ($num_pages-3) && $cur_page != ($num_pages-4))
$pages[] = '<span class="spacer">'.$lang_common['Spacer'].'</span>';
$pages[] = '<a'.(empty($pages) ? ' class="item1"' : '').' href="'.$link.'&p='.$num_pages.'">'.forum_number_format($num_pages).'</a>';
}
// Add a next page link
if ($num_pages > 1 && !$link_to_all && $cur_page < $num_pages)
$pages[] = '<a rel="next" '.(empty($pages) ? ' class="item1"' : '').' href="'.$link.'&p='.($cur_page +1).'">'.$lang_common['Next'].'</a>';
}
#
#---------[ 13. REPLACE WITH ]---------------------------------------------------
#
function paginate($num_pages, $cur_page, $link, $args = null)
{
global $lang_common, $forum_url;
$pages = array();
$link_to_all = false;
// If $cur_page == -1, we link to all pages (used in viewforum.php)
if ($cur_page == -1)
{
$cur_page = 1;
$link_to_all = true;
}
if ($num_pages <= 1)
$pages = array('<strong class="item1">1</strong>');
else
{
// Add a previous page link
if ($num_pages > 1 && $cur_page > 1)
$pages[] = '<a rel="prev" '.(empty($pages) ? ' class="item1"' : '').' href="'.forum_sublink($link, $forum_url['page'], ($cur_page - 1), $args).'">'.$lang_common['Previous'].'</a>';
if ($cur_page > 3)
{
$pages[] = '<a'.(empty($pages) ? ' class="item1"' : '').' href="'.forum_sublink($link, $forum_url['page'], 1, $args).'">1</a>';
if ($cur_page > 5)
$pages[] = '<span class="spacer">'.$lang_common['Spacer'].'</span>';
}
// Don't ask me how the following works. It just does, OK? :-)
for ($current = ($cur_page == 5) ? $cur_page - 3 : $cur_page - 2, $stop = ($cur_page + 4 == $num_pages) ? $cur_page + 4 : $cur_page + 3; $current < $stop; ++$current)
{
if ($current < 1 || $current > $num_pages)
continue;
else if ($current != $cur_page || $link_to_all)
$pages[] = '<a'.(empty($pages) ? ' class="item1"' : '').' href="'.forum_sublink($link, $forum_url['page'], $current, $args).'">'.forum_number_format($current).'</a>';
else
$pages[] = '<strong'.(empty($pages) ? ' class="item1"' : '').'>'.forum_number_format($current).'</strong>';
}
if ($cur_page <= ($num_pages-3))
{
if ($cur_page != ($num_pages-3) && $cur_page != ($num_pages-4))
$pages[] = '<span class="spacer">'.$lang_common['Spacer'].'</span>';
$pages[] = '<a'.(empty($pages) ? ' class="item1"' : '').' href="'.forum_sublink($link, $forum_url['page'], $num_pages, $args).'">'.forum_number_format($num_pages).'</a>';
}
// Add a next page link
if ($num_pages > 1 && !$link_to_all && $cur_page < $num_pages)
$pages[] = '<a rel="next" '.(empty($pages) ? ' class="item1"' : '').' href="'.forum_sublink($link, $forum_url['page'], ($cur_page + 1), $args).'">'.$lang_common['Next'].'</a>';
}
#
#---------[ 14. OPEN ]---------------------------------------------------------
#
include/cache.php
#
#---------[ 15. FIND ]---------------------------------------------
#
$output .= "\t\t\t\t".'<form id="qjump" method="get" action="viewforum.php">'."\n\t\t\t\t\t".'<div><label><span><?php echo $lang_common[\'Jump to\'] ?>'.'<br /></span>'."\n\t\t\t\t\t".'<select name="id" onchange="window.location=(\'viewforum.php?id=\'+this.options[this.selectedIndex].value)">'."\n";
#
#---------[ 16. REPLACE WITH ]---------------------------------------------------
#
$output .= '<script type="text/javascript" src="<?php echo function_exists(\'forum_link\') ? forum_link(\'include/js/quick_jump.js\') : \'include/js/quick_jump.js\' ?>"></script>'."\n";
$output .= "\t\t\t\t".'<form id="qjump" method="get" action="<?php echo function_exists(\'forum_link\') ? forum_link(\'viewforum.php\') : \'viewforum.php\' ?>">'."\n\t\t\t\t\t".'<div><label><span><?php echo $lang_common[\'Jump to\'] ?>'.'<br /></span>'."\n\t\t\t\t\t".'<select name="id" onchange="return doQuickjumpRedirect(forum_quickjump_url, sef_friendly_url_array);">'."\n";
$sef_friendly_names = array();
#
#---------[ 17. FIND ]---------------------------------------------
#
$redirect_tag = ($cur_forum['redirect_url'] != '') ? ' >>>' : '';
#
#---------[ 18. BEFORE, ADD ]---------------------------------------------------
#
$sef_friendly_names[$cur_forum['fid']] = sef_friendly($cur_forum['forum_name']);
#
#---------[ 19. FIND ]---------------------------------------------
#
$output .= "\t\t\t\t\t\t".'</optgroup>'."\n\t\t\t\t\t".'</select>'."\n\t\t\t\t\t".'<input type="submit" value="<?php echo $lang_common[\'Go\'] ?>" accesskey="g" />'."\n\t\t\t\t\t".'</label></div>'."\n\t\t\t\t".'</form>'."\n";
#
#---------[ 20. REPLACE WITH ]---------------------------------------------------
#
$output .= "\t\t\t\t\t\t".'</optgroup>'."\n\t\t\t\t\t".'</select>'."\n\t\t\t\t\t".'<input type="submit" value="<?php echo $lang_common[\'Go\'] ?>" accesskey="g" onclick="return doQuickjumpRedirect(forum_quickjump_url, sef_friendly_url_array);" />'."\n\t\t\t\t\t".'</label></div>'."\n\t\t\t\t".'</form>'."\n";
$output .= '<script type="text/javascript">'."\n".'var forum_quickjump_url = "<?php echo function_exists(\'forum_link\') ? forum_link($GLOBALS[\'forum_url\'][\'forum\']) : \'viewforum.php?id=$1\' ?>";'."\n".'var sef_friendly_url_array = new Array('.$db->num_rows($result).');';
foreach ($sef_friendly_names as $forum_id => $forum_name)
$output .= "\n".'sef_friendly_url_array['.$forum_id.'] = "'.pun_htmlspecialchars($forum_name).'";';
$output .= "\n".'</script>'."\n";
#
#---------[ 21. OPEN ]---------------------------------------------------------
#
viewtopic.php
#
#---------[ 22. FIND ]---------------------------------------------
#
define('PUN_ALLOW_INDEX', 1);
#
#---------[ 23. REPLACE WITH ]-------------------------------------------------
#
if (!$pid)
define('PUN_ALLOW_INDEX', 1);
#
#---------[ 24. RUN (WARNING: MAKE BACKUP OF FLUXBB DIRECTORY as this script replaces all links with forum_link function!) ]------
#
gen.php
#
#---------[ 25. DELETE ]-------------------------------------------------
#
gen.php
#
#---------[ 26. SAVE/UPLOAD ]-------------------------------------------------
#
#
#---------[ 27. NOTE (for nginx server) ]-------------------------------------------------
#
For nginx server add the following code to server section of the nginx.conf file (assuming you have fluxbb in forum directory)
location /forum {
index index.html index.htm index.php;
if (!-e $request_filename) {
rewrite ^/(.+)$ /forum/rewrite.php last;
break;
}
}