|
1
|
|
|
<?php |
|
|
|
|
|
|
2
|
|
|
/** |
|
3
|
|
|
* |
|
4
|
|
|
* @author Erwan NADER (ErnadoO) [email protected] |
|
5
|
|
|
* @package phpBB3 |
|
6
|
|
|
* @version $Id$ |
|
7
|
|
|
* @copyright (c) 2008 http://www.phpbb-services.com |
|
8
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GNU Public License |
|
9
|
|
|
* |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* @ignore |
|
14
|
|
|
*/ |
|
15
|
|
|
if (!defined('IN_PHPBB')) |
|
16
|
|
|
{ |
|
17
|
|
|
exit; |
|
18
|
|
|
} |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* link class |
|
22
|
|
|
* @package phpBB3 |
|
23
|
|
|
*/ |
|
24
|
|
|
class link |
|
|
|
|
|
|
25
|
|
|
{ |
|
26
|
|
|
/** |
|
27
|
|
|
* Add a link into db |
|
28
|
|
|
* |
|
29
|
|
|
* @param array $data contains all datas to insert in db |
|
30
|
|
|
*/ |
|
31
|
|
|
function add($data) |
|
|
|
|
|
|
32
|
|
|
{ |
|
33
|
|
|
global $db, $auth, $config, $categorie; |
|
34
|
|
|
|
|
35
|
|
|
$db->sql_transaction('begin'); |
|
36
|
|
|
|
|
37
|
|
|
$sql = 'INSERT INTO ' . DIR_LINK_TABLE . ' ' . $db->sql_build_array('INSERT', $data); |
|
38
|
|
|
$db->sql_query($sql); |
|
39
|
|
|
|
|
40
|
|
|
if (!$categorie->data['cat_validate'] || $auth->acl_get('a_') || $auth->acl_get('m_')) |
|
41
|
|
|
{ |
|
42
|
|
|
$sql = 'UPDATE ' . DIR_CAT_TABLE . ' |
|
43
|
|
|
SET cat_links = cat_links + 1 |
|
44
|
|
|
WHERE cat_id = ' . (int)$data['link_cat']; |
|
45
|
|
|
$db->sql_query($sql); |
|
46
|
|
|
} |
|
47
|
|
|
elseif ($config['dir_mail'] && $config['email_enable']) |
|
48
|
|
|
{ |
|
49
|
|
|
$this->notify_admin(); |
|
50
|
|
|
} |
|
51
|
|
|
$db->sql_transaction('commit'); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* Edit a link of the db |
|
56
|
|
|
* |
|
57
|
|
|
* @param array $data contains all datas to edit in db |
|
58
|
|
|
* @param int $u is link's id, for WHERE clause |
|
|
|
|
|
|
59
|
|
|
*/ |
|
60
|
|
|
function edit($data, $url_id, $need_approval) |
|
|
|
|
|
|
61
|
|
|
{ |
|
62
|
|
|
global $db, $cache; |
|
63
|
|
|
|
|
64
|
|
|
$old_cat = array_pop($data); |
|
65
|
|
|
|
|
66
|
|
|
if ($old_cat != $data['link_cat'] || $need_approval) |
|
67
|
|
|
{ |
|
68
|
|
|
$db->sql_transaction('begin'); |
|
69
|
|
|
|
|
70
|
|
|
$sql = 'UPDATE ' . DIR_CAT_TABLE . ' SET cat_links = cat_links - 1 |
|
71
|
|
|
WHERE cat_id = ' . (int)$old_cat; |
|
72
|
|
|
$db->sql_query($sql); |
|
73
|
|
|
|
|
74
|
|
|
if(!$need_approval) |
|
75
|
|
|
{ |
|
76
|
|
|
$sql = 'UPDATE ' . DIR_CAT_TABLE . ' SET cat_links = cat_links + 1 |
|
77
|
|
|
WHERE cat_id = ' . (int)$data['link_cat']; |
|
78
|
|
|
$db->sql_query($sql); |
|
79
|
|
|
} |
|
80
|
|
|
else |
|
81
|
|
|
{ |
|
82
|
|
|
$data['link_active'] = false; |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
$db->sql_transaction('commit'); |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
$sql = 'UPDATE ' . DIR_LINK_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $data) . ' |
|
89
|
|
|
WHERE link_id = ' . (int)$url_id; |
|
90
|
|
|
$db->sql_query($sql); |
|
91
|
|
|
|
|
92
|
|
|
$cache->destroy('sql', DIR_LINK_TABLE); |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
/** |
|
96
|
|
|
* Del a link of the db |
|
97
|
|
|
* |
|
98
|
|
|
* @param int $u is link's id, for WHERE clause |
|
|
|
|
|
|
99
|
|
|
*/ |
|
100
|
|
|
function del($url_id, $cat_id, $cron = false) |
|
|
|
|
|
|
101
|
|
|
{ |
|
102
|
|
|
global $db, $mode, $phpEx, $phpbb_root_path, $user; |
|
103
|
|
|
|
|
104
|
|
|
if (confirm_box(true) || $cron) |
|
105
|
|
|
{ |
|
106
|
|
|
$db->sql_transaction('begin'); |
|
107
|
|
|
|
|
108
|
|
|
$url_array = is_array($url_id) ? $url_id : array($url_id); |
|
109
|
|
|
|
|
110
|
|
|
// Delete links datas |
|
111
|
|
|
$link_datas_ary = array( |
|
112
|
|
|
DIR_LINK_TABLE => 'link_id', |
|
113
|
|
|
DIR_COMMENT_TABLE => 'comment_link_id', |
|
114
|
|
|
DIR_VOTE_TABLE => 'vote_link_id', |
|
115
|
|
|
); |
|
116
|
|
|
|
|
117
|
|
|
$sql = 'SELECT link_banner FROM ' . DIR_LINK_TABLE . ' WHERE '. $db->sql_in_set('link_id', $url_array); |
|
118
|
|
|
$result = $db->sql_query($sql); |
|
119
|
|
|
|
|
120
|
|
|
while ($row = $db->sql_fetchrow($result)) |
|
121
|
|
|
{ |
|
122
|
|
View Code Duplication |
if($row['link_banner'] && !preg_match('/^(http:\/\/|https:\/\/|ftp:\/\/|ftps:\/\/|www\.).+/si', $row['link_banner'])) |
|
|
|
|
|
|
123
|
|
|
{ |
|
124
|
|
|
if (file_exists($phpbb_root_path . 'images/directory/banners' .'/'. basename($row['link_banner']))) |
|
125
|
|
|
{ |
|
126
|
|
|
@unlink($phpbb_root_path . 'images/directory/banners' .'/'. basename($row['link_banner'])); |
|
127
|
|
|
} |
|
128
|
|
|
} |
|
129
|
|
|
} |
|
130
|
|
|
|
|
131
|
|
|
foreach ($link_datas_ary as $table => $field) |
|
132
|
|
|
{ |
|
133
|
|
|
$db->sql_query("DELETE FROM $table WHERE ".$db->sql_in_set($field, $url_array)); |
|
|
|
|
|
|
134
|
|
|
} |
|
135
|
|
|
|
|
136
|
|
|
$sql = 'UPDATE ' . DIR_CAT_TABLE . ' |
|
137
|
|
|
SET cat_links = cat_links - '.sizeof($url_array).' |
|
138
|
|
|
WHERE cat_id = ' . (int)$cat_id; |
|
139
|
|
|
$db->sql_query($sql); |
|
140
|
|
|
|
|
141
|
|
|
$db->sql_transaction('commit'); |
|
142
|
|
|
|
|
143
|
|
|
if($cron) |
|
144
|
|
|
{ |
|
145
|
|
|
include($phpbb_root_path.'includes/acp/acp_directory.'.$phpEx); |
|
146
|
|
|
sync_dir_cat($this->categorie['cat_id']); |
|
|
|
|
|
|
147
|
|
|
} |
|
148
|
|
|
else |
|
149
|
|
|
{ |
|
150
|
|
|
$meta_info = append_sid("{$phpbb_root_path}directory.$phpEx", "mode=cat&id=$cat_id"); |
|
|
|
|
|
|
151
|
|
|
meta_refresh(3, $meta_info); |
|
152
|
|
|
$message = $user->lang['DIR_DELETE_OK'] . "<br /><br />" . $user->lang('DIR_CLICK_RETURN_DIR', '<a href="' . append_sid("{$phpbb_root_path}directory.$phpEx") . '">', '</a>') . '<br /><br />' . $user->lang('DIR_CLICK_RETURN_CAT', '<a href="' . append_sid("{$phpbb_root_path}directory.$phpEx", "mode=cat&id=$cat_id") . '">', '</a>'); |
|
|
|
|
|
|
153
|
|
|
trigger_error($message); |
|
154
|
|
|
} |
|
155
|
|
|
} |
|
156
|
|
|
else |
|
157
|
|
|
{ |
|
158
|
|
|
$s_hidden_fields = build_hidden_fields(array( |
|
159
|
|
|
'mode' => $mode, |
|
160
|
|
|
'id' => (int)$cat_id, |
|
161
|
|
|
'u' => (int)$url_id, |
|
162
|
|
|
)); |
|
163
|
|
|
|
|
164
|
|
|
confirm_box(false, 'DIR_DELETE_SITE', $s_hidden_fields); |
|
165
|
|
|
} |
|
166
|
|
|
} |
|
167
|
|
|
|
|
168
|
|
|
/** |
|
169
|
|
|
* Increments link view counter |
|
170
|
|
|
* |
|
171
|
|
|
* @param int $u is link's id, for WHERE clause |
|
|
|
|
|
|
172
|
|
|
*/ |
|
173
|
|
|
function view($url_id) |
|
|
|
|
|
|
174
|
|
|
{ |
|
175
|
|
|
global $db, $user; |
|
176
|
|
|
|
|
177
|
|
|
$sql = 'SELECT link_id, link_url FROM ' . DIR_LINK_TABLE . ' |
|
178
|
|
|
WHERE link_id = ' . (int)$url_id; |
|
179
|
|
|
$result = $db->sql_query($sql); |
|
180
|
|
|
$data = $db->sql_fetchrow($result); |
|
181
|
|
|
|
|
182
|
|
|
if (empty($data['link_id'])) |
|
183
|
|
|
{ |
|
184
|
|
|
trigger_error($user->lang['DIR_ERROR_NO_LINKS'], E_USER_ERROR); |
|
185
|
|
|
} |
|
186
|
|
|
|
|
187
|
|
|
$sql = 'UPDATE ' . DIR_LINK_TABLE . ' |
|
188
|
|
|
SET link_view = link_view + 1 |
|
189
|
|
|
WHERE link_id = ' . (int)$url_id; |
|
190
|
|
|
$db->sql_query($sql); |
|
191
|
|
|
|
|
192
|
|
|
redirect($data['link_url'], false, true); |
|
193
|
|
|
exit_handler(); |
|
194
|
|
|
} |
|
195
|
|
|
|
|
196
|
|
|
/** |
|
197
|
|
|
* Verify that an URL exist before add into db |
|
198
|
|
|
* |
|
199
|
|
|
* @param string $url |
|
200
|
|
|
* |
|
201
|
|
|
* @return true if ok, else false. |
|
202
|
|
|
*/ |
|
203
|
|
|
function checkurl($url) |
|
|
|
|
|
|
204
|
|
|
{ |
|
205
|
|
|
$details = parse_url($url); |
|
206
|
|
|
|
|
207
|
|
|
if (!isset($details['port'])) |
|
208
|
|
|
{ |
|
209
|
|
|
$details['port'] = 80; |
|
210
|
|
|
} |
|
211
|
|
|
if (!isset($details['path'])) |
|
212
|
|
|
{ |
|
213
|
|
|
$details['path'] = "/"; |
|
|
|
|
|
|
214
|
|
|
} |
|
215
|
|
|
|
|
216
|
|
|
if ($sock = @fsockopen($details['host'], $details['port'], $errno, $errstr, 1)) |
|
217
|
|
|
{ |
|
218
|
|
|
$requete = "GET ".$details['path']." HTTP/1.1\r\n"; |
|
|
|
|
|
|
219
|
|
|
$requete .= "Host: ".$details['host']."\r\n\r\n"; |
|
|
|
|
|
|
220
|
|
|
|
|
221
|
|
|
// Send a HTTP GET header |
|
222
|
|
|
fputs($sock, $requete); |
|
223
|
|
|
// answer from server |
|
224
|
|
|
$str = fgets($sock, 1024); |
|
225
|
|
|
preg_match("'HTTP/1\.. (.*) (.*)'U", $str, $parts); |
|
226
|
|
|
fclose($sock); |
|
227
|
|
|
|
|
228
|
|
|
if ($parts[1] == '404') |
|
229
|
|
|
{ |
|
230
|
|
|
return false; |
|
231
|
|
|
} |
|
232
|
|
|
else |
|
233
|
|
|
{ |
|
234
|
|
|
return true; |
|
235
|
|
|
} |
|
236
|
|
|
} |
|
237
|
|
|
return false; |
|
238
|
|
|
} |
|
239
|
|
|
|
|
240
|
|
|
/** |
|
241
|
|
|
* Delete the final '/', if no path |
|
242
|
|
|
* |
|
243
|
|
|
* @param string $url to clean |
|
244
|
|
|
* |
|
245
|
|
|
* @return the correct string. |
|
246
|
|
|
*/ |
|
247
|
|
|
function clean_url($url) |
|
|
|
|
|
|
248
|
|
|
{ |
|
249
|
|
|
$details = parse_url($url); |
|
250
|
|
|
|
|
251
|
|
|
if(isset($details['path']) && $details['path'] == '/' && !isset($details['query'])) |
|
252
|
|
|
{ |
|
253
|
|
|
return substr($url, 0, -1); |
|
254
|
|
|
} |
|
255
|
|
|
return $url; |
|
256
|
|
|
} |
|
257
|
|
|
|
|
258
|
|
|
/** |
|
259
|
|
|
* Display a flag |
|
260
|
|
|
* |
|
261
|
|
|
* @param array $data link's data from db |
|
262
|
|
|
* |
|
263
|
|
|
* @return flag image. |
|
264
|
|
|
*/ |
|
265
|
|
|
function display_flag($data) |
|
|
|
|
|
|
266
|
|
|
{ |
|
267
|
|
|
global $phpbb_root_path, $user, $phpEx; |
|
268
|
|
|
|
|
269
|
|
|
$extra = ''; |
|
270
|
|
|
|
|
271
|
|
|
if(!empty($data['link_flag'])) |
|
272
|
|
|
{ |
|
273
|
|
|
if (file_exists('images/directory/flags/'.$data['link_flag'])) |
|
274
|
|
|
{ |
|
275
|
|
|
if (file_exists("{$user->lang_path}{$user->lang_name}/mods/directory_flags.$phpEx")) |
|
|
|
|
|
|
276
|
|
|
{ |
|
277
|
|
|
// include the file containing flags |
|
278
|
|
|
include("{$user->lang_path}{$user->lang_name}/mods/directory_flags.$phpEx"); |
|
|
|
|
|
|
279
|
|
|
|
|
280
|
|
|
$iso_code = substr($data['link_flag'], 0, strpos($data['link_flag'], '.')); |
|
281
|
|
|
$country = (isset($flags[strtoupper($iso_code)])) ? $flags[strtoupper($iso_code)] : ''; |
|
|
|
|
|
|
282
|
|
|
$extra = 'alt = "'.$country.'" title = "'.$country.'"'; |
|
283
|
|
|
} |
|
284
|
|
|
|
|
285
|
|
|
return '<img src="' . $phpbb_root_path . 'images/directory/flags/' . $data['link_flag'] . '" '.$extra.' /> '; |
|
286
|
|
|
} |
|
287
|
|
|
} |
|
288
|
|
|
|
|
289
|
|
|
return '<img src="' . $phpbb_root_path . 'images/directory/flags/no_flag.png" /> '; |
|
290
|
|
|
|
|
291
|
|
|
} |
|
292
|
|
|
|
|
293
|
|
|
/** |
|
294
|
|
|
* Calculate the link's note |
|
295
|
|
|
* |
|
296
|
|
|
* @param int $total_note is sum of all link's notes |
|
297
|
|
|
* @param int $nb_vote is nb of votes |
|
298
|
|
|
* |
|
299
|
|
|
* @return the calculated note. |
|
300
|
|
|
*/ |
|
301
|
|
|
function display_note($total_note, $nb_vote, $votes_status) |
|
|
|
|
|
|
302
|
|
|
{ |
|
303
|
|
|
if(!$votes_status) |
|
304
|
|
|
{ |
|
305
|
|
|
return; |
|
306
|
|
|
} |
|
307
|
|
|
|
|
308
|
|
|
global $user; |
|
309
|
|
|
|
|
310
|
|
|
$note = ($nb_vote < 1) ? '' : $total_note / $nb_vote; |
|
311
|
|
|
$note = (strlen($note) > 2) ? number_format($note, 1) : $note; |
|
312
|
|
|
$note = ($nb_vote) ? '<b>' . $user->lang('DIR_FROM_TEN', $note) . '</b>' : $user->lang['DIR_NO_NOTE']; |
|
313
|
|
|
|
|
314
|
|
|
return $note; |
|
315
|
|
|
} |
|
316
|
|
|
|
|
317
|
|
|
/** |
|
318
|
|
|
* Display the vote form for auth users |
|
319
|
|
|
* |
|
320
|
|
|
* @param array $data link's data from db |
|
321
|
|
|
* |
|
322
|
|
|
* @return the html code. |
|
323
|
|
|
*/ |
|
324
|
|
|
function display_vote($data, $votes_status) |
|
|
|
|
|
|
325
|
|
|
{ |
|
326
|
|
|
if(!$votes_status) |
|
327
|
|
|
{ |
|
328
|
|
|
return; |
|
329
|
|
|
} |
|
330
|
|
|
|
|
331
|
|
|
global $user, $order, $start, $phpEx; |
|
332
|
|
|
global $directory_root_path, $auth; |
|
333
|
|
|
|
|
334
|
|
|
if ($user->data['is_registered']) |
|
335
|
|
|
{ |
|
336
|
|
|
if ($auth->acl_get('u_vote_dir')) |
|
337
|
|
|
{ |
|
338
|
|
|
if (empty($data['vote_user_id'])) |
|
339
|
|
|
{ |
|
340
|
|
|
$list = '<select name="vote">'; |
|
341
|
|
|
for ( $i = 0; $i <= 10; $i++ ) |
|
342
|
|
|
{ |
|
343
|
|
|
$list .= '<option value="' . $i . '"' . (($i == 5) ? ' selected="selected"' : '') . '>' . $i . '</option>'; |
|
344
|
|
|
} |
|
345
|
|
|
$list .= '</select>'; |
|
346
|
|
|
|
|
347
|
|
|
$params = array( |
|
348
|
|
|
'mode' => 'cat', |
|
349
|
|
|
'id' => (int)$data['link_cat'], |
|
350
|
|
|
'start' => $start, |
|
351
|
|
|
'u' => (int)$data['link_id'], |
|
352
|
|
|
'order' => $order); |
|
353
|
|
|
|
|
354
|
|
|
return '<br /><form action="' . append_sid("{$directory_root_path}directory.$phpEx", $params, true) . '" method="post"><div>' . $list . ' <input type="submit" name="submit_vote" value="' . $user->lang['DIR_VOTE'] . '" class="mainoption" /></div></form>'; |
|
|
|
|
|
|
355
|
|
|
} |
|
356
|
|
|
} |
|
357
|
|
|
} |
|
358
|
|
|
return '<br />'; |
|
359
|
|
|
} |
|
360
|
|
|
|
|
361
|
|
|
/** |
|
362
|
|
|
* Display link's thumb if thumb service enabled. |
|
363
|
|
|
* if thumb don't exists in db or if a new service was choosen in acp |
|
364
|
|
|
* thumb is research |
|
365
|
|
|
* |
|
366
|
|
|
* @param array $data link's data from db |
|
367
|
|
|
* |
|
368
|
|
|
* @return thumb or nothing. |
|
369
|
|
|
*/ |
|
370
|
|
|
function display_thumb($data) |
|
|
|
|
|
|
371
|
|
|
{ |
|
372
|
|
|
global $config, $db; |
|
373
|
|
|
|
|
374
|
|
|
if($config['dir_activ_thumb']) |
|
375
|
|
|
{ |
|
376
|
|
|
if (!$data['link_thumb'] || ($config['dir_thumb_service_reverse'] && (!strstr($data['link_thumb'], 'ascreen.jpg') && (!strstr($data['link_thumb'], $config['dir_thumb_service']))))) |
|
377
|
|
|
{ |
|
378
|
|
|
$thumb = $this->thumb_process($data['link_url']); |
|
379
|
|
|
|
|
380
|
|
|
$sql = 'UPDATE ' . DIR_LINK_TABLE . ' SET link_thumb = "' . $db->sql_escape($thumb) . '" |
|
381
|
|
|
WHERE link_id = ' . (int)$data['link_id']; |
|
382
|
|
|
$db->sql_query($sql); |
|
383
|
|
|
|
|
384
|
|
|
return $thumb; |
|
385
|
|
|
} |
|
386
|
|
|
return $data['link_thumb']; |
|
387
|
|
|
} |
|
388
|
|
|
} |
|
389
|
|
|
|
|
390
|
|
|
/** |
|
391
|
|
|
* Display and calculate PageRank if needed |
|
392
|
|
|
* |
|
393
|
|
|
* @param array $data link's data from db |
|
394
|
|
|
* |
|
395
|
|
|
* @return pr image, false or 'n/a'. |
|
396
|
|
|
*/ |
|
397
|
|
|
function display_pagerank($data) |
|
|
|
|
|
|
398
|
|
|
{ |
|
399
|
|
|
global $config, $db, $user; |
|
400
|
|
|
|
|
401
|
|
|
if($config['dir_activ_pagerank']) |
|
402
|
|
|
{ |
|
403
|
|
|
if ($data['link_pagerank'] == '') |
|
404
|
|
|
{ |
|
405
|
|
|
$pagerank = $this->pagerank_process($data['link_url']); |
|
406
|
|
|
|
|
407
|
|
|
$sql = 'UPDATE ' . DIR_LINK_TABLE . ' SET link_pagerank = ' . (int)$pagerank . ' |
|
408
|
|
|
WHERE link_id = ' . (int)$data['link_id']; |
|
409
|
|
|
$db->sql_query($sql); |
|
410
|
|
|
} |
|
411
|
|
|
else |
|
412
|
|
|
{ |
|
413
|
|
|
$pagerank = (int)$data['link_pagerank']; |
|
414
|
|
|
} |
|
415
|
|
|
|
|
416
|
|
|
$prpos=40*$pagerank/10; |
|
417
|
|
|
$prneg=40-$prpos; |
|
418
|
|
|
$html='<img src="http://www.google.com/images/pos.gif" width="'.$prpos.'" height="4" alt="'.$pagerank.'" /><img src="http://www.google.com/images/neg.gif" width="'.$prneg.'" height="4" alt="'.$pagerank.'" /> '; |
|
419
|
|
|
|
|
420
|
|
|
$pagerank = $pagerank == '-1' ? $user->lang['DIR_PAGERANK_NOT_AVAILABLE'] : $user->lang('DIR_FROM_TEN', $pagerank); |
|
421
|
|
|
return $html.$pagerank; |
|
422
|
|
|
} |
|
423
|
|
|
return false; |
|
424
|
|
|
} |
|
425
|
|
|
|
|
426
|
|
|
/** |
|
427
|
|
|
* Display and resize a banner |
|
428
|
|
|
* |
|
429
|
|
|
* @param array $data link's data from db |
|
430
|
|
|
* @param bool $have_banner |
|
|
|
|
|
|
431
|
|
|
* |
|
432
|
|
|
* @return banner image. |
|
433
|
|
|
*/ |
|
434
|
|
|
function display_bann($data) |
|
|
|
|
|
|
435
|
|
|
{ |
|
436
|
|
|
global $config, $phpbb_root_path; |
|
437
|
|
|
|
|
438
|
|
|
$s_banner = $path = ''; |
|
439
|
|
|
|
|
440
|
|
|
if (!empty($data['link_banner'])) |
|
441
|
|
|
{ |
|
442
|
|
|
if (!preg_match('/^(http:\/\/|https:\/\/|ftp:\/\/|ftps:\/\/|www\.).+/si', $data['link_banner'])) |
|
443
|
|
|
{ |
|
444
|
|
|
$path = "{$phpbb_root_path}images/directory/banners/"; |
|
|
|
|
|
|
445
|
|
|
} |
|
446
|
|
|
$path .= $data['link_banner']; |
|
447
|
|
|
|
|
448
|
|
|
list($width, $height, $type, $attr) = @getimagesize($path); |
|
|
|
|
|
|
449
|
|
View Code Duplication |
if (($width > $config['dir_banner_width'] || $height > $config['dir_banner_height']) && $config['dir_banner_width'] > 0 && $config['dir_banner_height'] > 0) |
|
|
|
|
|
|
450
|
|
|
{ |
|
451
|
|
|
$coef_w = $width / $config['dir_banner_width']; |
|
452
|
|
|
$coef_h = $height / $config['dir_banner_height']; |
|
453
|
|
|
$coef_max = max($coef_w, $coef_h); |
|
454
|
|
|
$width /= $coef_max; |
|
455
|
|
|
$height /= $coef_max; |
|
456
|
|
|
} |
|
457
|
|
|
|
|
458
|
|
|
$s_banner = '<img src="' . $path . '" width="' . $width . '" height="' . $height . '" alt="'.$data['link_name'].'" title="'.$data['link_name'].'" />'; |
|
459
|
|
|
} |
|
460
|
|
|
|
|
461
|
|
|
return $s_banner; |
|
462
|
|
|
} |
|
463
|
|
|
|
|
464
|
|
|
/** |
|
465
|
|
|
* Display number of comments and link for posting |
|
466
|
|
|
* |
|
467
|
|
|
* @param int $u is link_id from db |
|
468
|
|
|
* @param int $nb_comments si number of comments for this link |
|
|
|
|
|
|
469
|
|
|
* |
|
470
|
|
|
* @return html code (counter + link). |
|
471
|
|
|
*/ |
|
472
|
|
|
function display_comm($u, $nb_comment, $comments_status) |
|
|
|
|
|
|
473
|
|
|
{ |
|
474
|
|
|
if(!$comments_status) |
|
475
|
|
|
{ |
|
476
|
|
|
return; |
|
477
|
|
|
} |
|
478
|
|
|
|
|
479
|
|
|
global $user, $directory_root_path, $phpEx; |
|
480
|
|
|
|
|
481
|
|
|
$comment_url = append_sid("{$directory_root_path}directory_comment.$phpEx", array('u' => (int)$u)); |
|
|
|
|
|
|
482
|
|
|
$l_nb_comment = ($nb_comment > 1) ? $user->lang['DIR_COMMENTS']: $user->lang['DIR_COMMENT']; |
|
483
|
|
|
$s_comment = ' <a href="' . $comment_url . '" onclick="window.open(\'' . $comment_url . '\', \'phpBB_dir_comment\', \'HEIGHT=600, resizable=yes, scrollbars=yes, WIDTH=905\');return false;" class="gen"><b>' . $nb_comment . '</b> ' . $l_nb_comment . '</a>'; |
|
484
|
|
|
|
|
485
|
|
|
return $s_comment; |
|
486
|
|
|
} |
|
487
|
|
|
|
|
488
|
|
|
/** |
|
489
|
|
|
* Add a vote in db, for a specifi link |
|
490
|
|
|
* |
|
491
|
|
|
* @param int $u is link_id from db |
|
492
|
|
|
*/ |
|
493
|
|
|
function add_vote($u) |
|
|
|
|
|
|
494
|
|
|
{ |
|
495
|
|
|
global $user, $db, $id, $start, $phpEx; |
|
496
|
|
|
global $directory_root_path, $order; |
|
497
|
|
|
|
|
498
|
|
|
if (!$user->data['is_registered']) |
|
499
|
|
|
{ |
|
500
|
|
|
trigger_error('DIR_ERROR_VOTE_LOGGED'); |
|
501
|
|
|
} |
|
502
|
|
|
|
|
503
|
|
|
$data = array( |
|
504
|
|
|
'vote_link_id' => (int)$u, |
|
505
|
|
|
'vote_user_id' => (int)$user->data['user_id'], |
|
506
|
|
|
); |
|
507
|
|
|
|
|
508
|
|
|
// We check if user had already vot for this website. |
|
509
|
|
|
$sql = 'SELECT vote_link_id FROM ' . DIR_VOTE_TABLE . ' WHERE ' . $db->sql_build_array('SELECT', $data); |
|
510
|
|
|
$result = $db->sql_query($sql); |
|
511
|
|
|
$data = $db->sql_fetchrow($result); |
|
512
|
|
|
|
|
513
|
|
|
if (!empty($data['vote_link_id'])) |
|
514
|
|
|
{ |
|
515
|
|
|
trigger_error('DIR_ERROR_VOTE'); |
|
516
|
|
|
} |
|
517
|
|
|
|
|
518
|
|
|
$data = array( |
|
519
|
|
|
'vote_link_id' => (int)$u, |
|
520
|
|
|
'vote_user_id' => $user->data['user_id'], |
|
521
|
|
|
'vote_note' => request_var('vote', 0), |
|
522
|
|
|
); |
|
523
|
|
|
|
|
524
|
|
|
$db->sql_transaction('begin'); |
|
525
|
|
|
|
|
526
|
|
|
$sql = 'INSERT INTO ' . DIR_VOTE_TABLE . ' ' . $db->sql_build_array('INSERT', $data); |
|
527
|
|
|
$db->sql_query($sql); |
|
528
|
|
|
|
|
529
|
|
|
$sql = 'UPDATE ' . DIR_LINK_TABLE . ' SET link_vote = link_vote + 1, |
|
530
|
|
|
link_note = link_note + ' . (int)$data['vote_note'] . ' |
|
531
|
|
|
WHERE link_id = ' . (int)$u; |
|
532
|
|
|
$db->sql_query($sql); |
|
533
|
|
|
|
|
534
|
|
|
$db->sql_transaction('commit'); |
|
535
|
|
|
|
|
536
|
|
|
$params = array( |
|
537
|
|
|
'mode' => 'cat', |
|
538
|
|
|
'id' => $id, |
|
539
|
|
|
'start' => $start, |
|
540
|
|
|
'order' => $order); |
|
541
|
|
|
|
|
542
|
|
|
$meta_info = append_sid("{$directory_root_path}directory.$phpEx", $params, true); |
|
|
|
|
|
|
543
|
|
|
meta_refresh(3, $meta_info); |
|
544
|
|
|
$message = $user->lang['DIR_VOTE_OK'] . '<br /><br />' . sprintf($user->lang['DIR_CLICK_RETURN_LIEN'], '<a href="' . append_sid("{$directory_root_path}directory.$phpEx", $params, true) . '">', '</a>'); |
|
|
|
|
|
|
545
|
|
|
trigger_error($message); |
|
546
|
|
|
} |
|
547
|
|
|
|
|
548
|
|
|
/** |
|
549
|
|
|
* Send a email to administrator for notify a new link |
|
550
|
|
|
* when approbation enabled |
|
551
|
|
|
*/ |
|
552
|
|
|
function notify_admin() |
|
|
|
|
|
|
553
|
|
|
{ |
|
554
|
|
|
global $config, $db, $user; |
|
555
|
|
|
global $phpbb_root_path, $phpEx; |
|
556
|
|
|
|
|
557
|
|
|
if ($config['email_enable']) |
|
558
|
|
|
{ |
|
559
|
|
|
// Get the appropriate username, etc. |
|
560
|
|
|
$sql = 'SELECT username, user_email, user_lang, user_jabber, user_notify_type |
|
561
|
|
|
FROM ' . USERS_TABLE . ' u, '. GROUPS_TABLE .' g, ' . USER_GROUP_TABLE . ' ug |
|
562
|
|
|
WHERE ug.user_id = u.user_id |
|
563
|
|
|
AND ug.user_pending = 0 |
|
564
|
|
|
AND ug.group_id = g.group_id |
|
565
|
|
|
AND g.group_name = "ADMINISTRATORS"'; |
|
566
|
|
|
$result = $db->sql_query($sql); |
|
567
|
|
|
|
|
568
|
|
|
if (!class_exists('messenger')) |
|
569
|
|
|
{ |
|
570
|
|
|
include($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); |
|
571
|
|
|
} |
|
572
|
|
|
$messenger = new messenger(false); |
|
573
|
|
|
|
|
574
|
|
|
while ($row = $db->sql_fetchrow($result)) |
|
575
|
|
|
{ |
|
576
|
|
|
$messenger->template('mods/directory/validation', $row['user_lang']); |
|
577
|
|
|
$messenger->replyto($user->data['user_email']); |
|
578
|
|
|
$messenger->to($row['user_email'], $row['username']); |
|
579
|
|
|
|
|
580
|
|
|
$messenger->im($row['user_jabber'], $row['username']); |
|
581
|
|
|
$notify_type = $row['user_notify_type']; |
|
|
|
|
|
|
582
|
|
|
|
|
583
|
|
|
$messenger->headers('X-AntiAbuse: Board servername - ' . $config['server_name']); |
|
584
|
|
|
$messenger->headers('X-AntiAbuse: User_id - ' . $user->data['user_id']); |
|
585
|
|
|
$messenger->headers('X-AntiAbuse: Username - ' . $user->data['username']); |
|
586
|
|
|
$messenger->headers('X-AntiAbuse: User IP - ' . $user->ip); |
|
587
|
|
|
|
|
588
|
|
|
$messenger->assign_vars(array( |
|
589
|
|
|
'USERNAME' => htmlspecialchars_decode($row['username']), |
|
590
|
|
|
)); |
|
591
|
|
|
|
|
592
|
|
|
$messenger->send($row['user_notify_type']); |
|
593
|
|
|
} |
|
594
|
|
|
$db->sql_freeresult($result); |
|
595
|
|
|
} |
|
596
|
|
|
} |
|
597
|
|
|
|
|
598
|
|
|
/** |
|
599
|
|
|
* Send a email to user who want be notify of a new publication link |
|
600
|
|
|
* |
|
601
|
|
|
* @param array $data link's data from db |
|
|
|
|
|
|
602
|
|
|
*/ |
|
603
|
|
|
function notify_member($site) |
|
|
|
|
|
|
604
|
|
|
{ |
|
605
|
|
|
global $config, $db, $user; |
|
606
|
|
|
global $phpbb_root_path, $phpEx; |
|
607
|
|
|
|
|
608
|
|
|
$sql_array = array( |
|
609
|
|
|
'SELECT' => 'u.username, u.user_email, u.user_lang, u.user_jabber, u.user_notify_type', |
|
610
|
|
|
'FROM' => array( |
|
611
|
|
|
DIR_NOTIFICATION_TABLE => 'an'), |
|
612
|
|
|
'LEFT_JOIN' => array( |
|
613
|
|
|
array( |
|
614
|
|
|
'FROM' => array(USERS_TABLE => 'u'), |
|
615
|
|
|
'ON' => 'an.n_user_id = u.user_id' |
|
616
|
|
|
) |
|
617
|
|
|
), |
|
618
|
|
|
'WHERE' => 'an.n_cat_id = ' . (int)$site['link_cat']); |
|
619
|
|
|
$sql = $db->sql_build_query('SELECT', $sql_array); |
|
620
|
|
|
$result = $db->sql_query($sql); |
|
621
|
|
|
|
|
622
|
|
|
if (!class_exists('messenger')) |
|
623
|
|
|
{ |
|
624
|
|
|
include($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); |
|
625
|
|
|
} |
|
626
|
|
|
$messenger = new messenger(false); |
|
627
|
|
|
|
|
628
|
|
|
$row = array(); |
|
|
|
|
|
|
629
|
|
|
while ($row = $db->sql_fetchrow($result)) |
|
630
|
|
|
{ |
|
631
|
|
|
$username = $row['username']; |
|
632
|
|
|
$email = $row['user_email']; |
|
633
|
|
|
strip_bbcode($site['link_description']); |
|
634
|
|
|
|
|
635
|
|
|
$messenger->template('mods/directory/notification', $row['user_lang']); |
|
636
|
|
|
$messenger->replyto($config['board_email']); |
|
637
|
|
|
$messenger->to($email, $username); |
|
638
|
|
|
|
|
639
|
|
|
$messenger->im($row['user_jabber'], $row['username']); |
|
640
|
|
|
|
|
641
|
|
|
$messenger->headers('X-AntiAbuse: Board servername - ' . $config['server_name']); |
|
642
|
|
|
$messenger->headers('X-AntiAbuse: User_id - ' . $user->data['user_id']); |
|
643
|
|
|
$messenger->headers('X-AntiAbuse: Username - ' . $user->data['username']); |
|
644
|
|
|
$messenger->headers('X-AntiAbuse: User IP - ' . $user->ip); |
|
645
|
|
|
|
|
646
|
|
|
$messenger->assign_vars(array( |
|
647
|
|
|
'USERNAME' => $row['username'], |
|
648
|
|
|
'CAT_NAME' => strip_tags($site['cat_name']), |
|
649
|
|
|
'LINK_NAME' => $site['link_name'], |
|
650
|
|
|
'LINK_URL' => $site['link_url'], |
|
651
|
|
|
'LINK_DESCRIPTION' => $site['link_description'], |
|
652
|
|
|
)); |
|
653
|
|
|
|
|
654
|
|
|
$messenger->send($row['user_notify_type']); |
|
655
|
|
|
} |
|
656
|
|
|
$db->sql_freeresult($result); |
|
657
|
|
|
} |
|
658
|
|
|
|
|
659
|
|
|
/** |
|
660
|
|
|
* Search an appropriate thumb for url |
|
661
|
|
|
* |
|
662
|
|
|
* @param string $url is link's url |
|
663
|
|
|
* |
|
664
|
|
|
* @return the thumb url |
|
665
|
|
|
*/ |
|
666
|
|
|
function thumb_process($url) |
|
|
|
|
|
|
667
|
|
|
{ |
|
668
|
|
|
global $config, $phpbb_root_path; |
|
669
|
|
|
|
|
670
|
|
|
if(!$config['dir_activ_thumb']) |
|
671
|
|
|
{ |
|
672
|
|
|
return $phpbb_root_path.'images/directory/nothumb.gif'; |
|
673
|
|
|
} |
|
674
|
|
|
|
|
675
|
|
|
$details = parse_url($url); |
|
676
|
|
|
|
|
677
|
|
|
$root_url = $details['scheme'].'://'.$details['host']; |
|
678
|
|
|
$absolute_url = isset($details['path']) ? $root_url.$details['path'] : $root_url; |
|
679
|
|
|
|
|
680
|
|
|
if($config['dir_activ_thumb_remote']) |
|
681
|
|
|
{ |
|
682
|
|
|
if ($this->ascreen_exist($details['scheme'], $details['host'])) |
|
683
|
|
|
{ |
|
684
|
|
|
return $root_url.'/ascreen.jpg'; |
|
685
|
|
|
} |
|
686
|
|
|
} |
|
687
|
|
|
return $config['dir_thumb_service'].$absolute_url; |
|
688
|
|
|
} |
|
689
|
|
|
|
|
690
|
|
|
/** |
|
691
|
|
|
* Check if ascreen thumb exists |
|
692
|
|
|
*/ |
|
693
|
|
|
function ascreen_exist($protocol, $host) |
|
|
|
|
|
|
694
|
|
|
{ |
|
695
|
|
|
if ($thumb_info = @getimagesize($protocol.'://'.$host.'/ascreen.jpg')) |
|
696
|
|
|
{ |
|
697
|
|
|
// Obviously this is an image, we did some additional tests |
|
698
|
|
|
if ($thumb_info[0] == '120' && $thumb_info[1] == '90' && $thumb_info['mime'] == 'image/jpeg') |
|
699
|
|
|
{ |
|
700
|
|
|
return true; |
|
701
|
|
|
} |
|
702
|
|
|
} |
|
703
|
|
|
return false; |
|
704
|
|
|
} |
|
705
|
|
|
|
|
706
|
|
|
/** |
|
707
|
|
|
* primary work on banner, can edit, copy or check a banner |
|
708
|
|
|
* |
|
709
|
|
|
* @param string $banner is banner's remote url |
|
710
|
|
|
*/ |
|
711
|
|
|
function banner_process(&$banner, &$error) |
|
|
|
|
|
|
712
|
|
|
{ |
|
713
|
|
|
global $config, $phpbb_root_path; |
|
714
|
|
|
|
|
715
|
|
|
$old_banner = request_var('old_banner', ''); |
|
716
|
|
|
|
|
717
|
|
|
$destination = 'images/directory/banners'; |
|
718
|
|
|
|
|
719
|
|
|
// Can we upload? |
|
720
|
|
|
$can_upload = ($config['dir_storage_banner'] && file_exists($phpbb_root_path . $destination) && phpbb_is_writable($phpbb_root_path . $destination) && (@ini_get('file_uploads') || strtolower(@ini_get('file_uploads')) == 'on')) ? true : false; |
|
721
|
|
|
|
|
722
|
|
|
if ($banner && $can_upload) |
|
723
|
|
|
{ |
|
724
|
|
|
$file = $this->banner_upload($banner, $error); |
|
725
|
|
|
} |
|
726
|
|
|
else if ($banner) |
|
727
|
|
|
{ |
|
728
|
|
|
$file = $this->banner_remote($banner, $error); |
|
729
|
|
|
} |
|
730
|
|
|
else if (isset($_POST['delete_banner']) && $old_banner) |
|
731
|
|
|
{ |
|
732
|
|
|
$this->banner_delete($destination, $old_banner); |
|
733
|
|
|
$banner = ''; |
|
734
|
|
|
return; |
|
735
|
|
|
} |
|
736
|
|
|
|
|
737
|
|
|
if (!sizeof($error)) |
|
738
|
|
|
{ |
|
739
|
|
|
if ($banner && $old_banner && !preg_match('/^(http:\/\/|https:\/\/|ftp:\/\/|ftps:\/\/|www\.).+/si', $old_banner)) |
|
740
|
|
|
{ |
|
741
|
|
|
$this->banner_delete($destination, $old_banner); |
|
742
|
|
|
} |
|
743
|
|
|
|
|
744
|
|
|
$banner = isset($file) ? $file : ''; |
|
745
|
|
|
} |
|
746
|
|
|
elseif(isset($file)) |
|
747
|
|
|
{ |
|
748
|
|
|
$this->banner_delete($destination, $file); |
|
|
|
|
|
|
749
|
|
|
} |
|
750
|
|
|
} |
|
751
|
|
|
|
|
752
|
|
|
/** |
|
753
|
|
|
* Copy a remonte banner to server. |
|
754
|
|
|
* called by banner_process() |
|
755
|
|
|
* |
|
756
|
|
|
* @param string $banner is banner's remote url |
|
757
|
|
|
* |
|
758
|
|
|
* @return file's name of the local banner |
|
|
|
|
|
|
759
|
|
|
*/ |
|
760
|
|
|
function banner_upload($banner, &$error) |
|
|
|
|
|
|
761
|
|
|
{ |
|
762
|
|
|
global $phpbb_root_path, $config, $db, $user, $phpEx; |
|
763
|
|
|
|
|
764
|
|
|
// Init upload class |
|
765
|
|
|
if(!class_exists('fileupload')) |
|
766
|
|
|
{ |
|
767
|
|
|
include($phpbb_root_path . 'includes/functions_upload.' . $phpEx); |
|
768
|
|
|
} |
|
769
|
|
|
$upload = new fileupload('DIR_BANNER_', array('jpg', 'jpeg', 'gif', 'png'), $config['dir_banner_filesize']); |
|
770
|
|
|
|
|
771
|
|
|
$file = $upload->remote_upload($banner); |
|
772
|
|
|
|
|
773
|
|
|
$prefix = unique_id() . '_'; |
|
774
|
|
|
$file->clean_filename('real', $prefix); |
|
775
|
|
|
|
|
776
|
|
|
$destination = 'images/directory/banners'; |
|
777
|
|
|
|
|
778
|
|
|
// Move file and overwrite any existing image |
|
779
|
|
|
$file->move_file($destination, true); |
|
780
|
|
|
|
|
781
|
|
|
if (sizeof($file->error)) |
|
782
|
|
|
{ |
|
783
|
|
|
$file->remove(); |
|
784
|
|
|
$error = array_merge($error, $file->error); |
|
785
|
|
|
} |
|
786
|
|
|
@chmod($file->destination_file, 0644); |
|
787
|
|
|
|
|
788
|
|
|
return $prefix .strtolower($file->uploadname); |
|
789
|
|
|
} |
|
790
|
|
|
|
|
791
|
|
|
/** |
|
792
|
|
|
* Check than remote banner exists |
|
793
|
|
|
* called by banner_process() |
|
794
|
|
|
* |
|
795
|
|
|
* @param string $banner is banner's remote url |
|
796
|
|
|
* |
|
797
|
|
|
* @return false if error, true for ok |
|
798
|
|
|
*/ |
|
799
|
|
|
function banner_remote($banner, &$error) |
|
|
|
|
|
|
800
|
|
|
{ |
|
801
|
|
|
global $config, $db, $user, $phpbb_root_path, $phpEx; |
|
802
|
|
|
|
|
803
|
|
|
if (!preg_match('#^(http|https|ftp)://#i', $banner)) |
|
804
|
|
|
{ |
|
805
|
|
|
$banner = 'http://' . $banner; |
|
806
|
|
|
} |
|
807
|
|
|
if (!preg_match('#^(http|https|ftp)://(?:(.*?\.)*?[a-z0-9\-]+?\.[a-z]{2,4}|(?:\d{1,3}\.){3,5}\d{1,3}):?([0-9]*?).*?\.(gif|jpg|jpeg|png)$#i', $banner)) |
|
808
|
|
|
{ |
|
809
|
|
|
$error[] = $user->lang['DIR_BANNER_URL_INVALID']; |
|
810
|
|
|
return false; |
|
811
|
|
|
} |
|
812
|
|
|
|
|
813
|
|
|
// Make sure getimagesize works... |
|
814
|
|
|
if (($image_data = @getimagesize($banner)) === false) |
|
815
|
|
|
{ |
|
816
|
|
|
$error[] = $user->lang['DIR_BANNER_UNABLE_GET_IMAGE_SIZE']; |
|
817
|
|
|
return false; |
|
818
|
|
|
} |
|
819
|
|
|
|
|
820
|
|
|
if (!empty($image_data) && ($image_data[0] < 2 || $image_data[1] < 2)) |
|
821
|
|
|
{ |
|
822
|
|
|
$error[] = $user->lang['DIR_BANNER_UNABLE_GET_IMAGE_SIZE']; |
|
823
|
|
|
return false; |
|
824
|
|
|
} |
|
825
|
|
|
|
|
826
|
|
|
$width = $image_data[0]; |
|
827
|
|
|
$height = $image_data[1]; |
|
828
|
|
|
|
|
829
|
|
|
// Check image type |
|
830
|
|
|
if(!class_exists('fileupload')) |
|
831
|
|
|
{ |
|
832
|
|
|
include($phpbb_root_path . 'includes/functions_upload.' . $phpEx); |
|
833
|
|
|
} |
|
834
|
|
|
$types = fileupload::image_types(); |
|
835
|
|
|
$extension = strtolower(filespec::get_extension($banner)); |
|
836
|
|
|
|
|
837
|
|
|
if (!empty($image_data) && (!isset($types[$image_data[2]]) || !in_array($extension, $types[$image_data[2]]))) |
|
838
|
|
|
{ |
|
839
|
|
|
if (!isset($types[$image_data[2]])) |
|
840
|
|
|
{ |
|
841
|
|
|
$error[] = $user->lang['UNABLE_GET_IMAGE_SIZE']; |
|
842
|
|
|
} |
|
843
|
|
|
else |
|
844
|
|
|
{ |
|
845
|
|
|
$error[] = sprintf($user->lang['DIR_BANNER_IMAGE_FILETYPE_MISMATCH'], $types[$image_data[2]][0], $extension); |
|
846
|
|
|
} |
|
847
|
|
|
return false; |
|
848
|
|
|
} |
|
849
|
|
|
|
|
850
|
|
|
if ($config['dir_banner_width'] || $config['dir_banner_height']) |
|
851
|
|
|
{ |
|
852
|
|
|
if ($width > $config['dir_banner_width'] || $height > $config['dir_banner_height']) |
|
853
|
|
|
{ |
|
854
|
|
|
$error[] = sprintf($user->lang['DIR_BANNER_WRONG_SIZE'], $config['dir_banner_width'], $config['dir_banner_height'], $width, $height); |
|
855
|
|
|
return false; |
|
856
|
|
|
} |
|
857
|
|
|
} |
|
858
|
|
|
|
|
859
|
|
|
return $banner; |
|
860
|
|
|
} |
|
861
|
|
|
|
|
862
|
|
|
/** |
|
863
|
|
|
* Delete a banner from server |
|
864
|
|
|
* |
|
865
|
|
|
* @param string $destination path to banner directory |
|
866
|
|
|
* @param string $file is file's name |
|
867
|
|
|
* |
|
868
|
|
|
* @return true if delete success, else false |
|
869
|
|
|
*/ |
|
870
|
|
|
function banner_delete($destination, $file) |
|
|
|
|
|
|
871
|
|
|
{ |
|
872
|
|
|
global $phpbb_root_path; |
|
873
|
|
|
|
|
874
|
|
|
if (substr($destination, -1, 1) == '/' || substr($destination, -1, 1) == '\\') |
|
875
|
|
|
{ |
|
876
|
|
|
$destination = substr($destination, 0, -1); |
|
877
|
|
|
} |
|
878
|
|
|
|
|
879
|
|
|
if (file_exists($phpbb_root_path . $destination .'/'.$file)) |
|
880
|
|
|
{ |
|
881
|
|
|
@unlink($phpbb_root_path . $destination .'/'.$file); |
|
882
|
|
|
return true; |
|
883
|
|
|
} |
|
884
|
|
|
|
|
885
|
|
|
return false; |
|
886
|
|
|
} |
|
887
|
|
|
|
|
888
|
|
|
/** |
|
889
|
|
|
* PageRank Lookup (Based on Google Toolbar for Mozilla Firefox) |
|
890
|
|
|
* |
|
891
|
|
|
* @copyright 2012 HM2K <[email protected]> |
|
892
|
|
|
* @link http://pagerank.phurix.net/ |
|
893
|
|
|
* @author James Wade <[email protected]> |
|
894
|
|
|
* @version $Revision: 2.1 $ |
|
895
|
|
|
* @require PHP 4.3.0 (file_get_contents) |
|
896
|
|
|
* @updated 06/10/11 |
|
897
|
|
|
*/ |
|
898
|
|
|
function pagerank_process($q) |
|
|
|
|
|
|
899
|
|
|
{ |
|
900
|
|
|
global $user; |
|
901
|
|
|
|
|
902
|
|
|
$googleDomains = Array(".com", ".com.tr", ".de", ".fr", ".be", ".ca", ".ro", ".ch"); |
|
|
|
|
|
|
903
|
|
|
$seed = $user->lang['SEED']; |
|
904
|
|
|
$result = 0x01020345; |
|
905
|
|
|
$len = strlen($q); |
|
906
|
|
|
for ($i=0; $i<$len; $i++) |
|
907
|
|
|
{ |
|
908
|
|
|
$result ^= ord($seed{$i%strlen($seed)}) ^ ord($q{$i}); |
|
909
|
|
|
$result = (($result >> 23) & 0x1ff) | $result << 9; |
|
910
|
|
|
} |
|
911
|
|
|
if (PHP_INT_MAX != 2147483647) |
|
912
|
|
|
{ |
|
913
|
|
|
$result = -(~($result & 0xFFFFFFFF) + 1); |
|
914
|
|
|
} |
|
915
|
|
|
$ch=sprintf('8%x', $result); |
|
916
|
|
|
$url='http://%s/tbr?client=navclient-auto&ch=%s&features=Rank&q=info:%s'; |
|
917
|
|
|
$host = 'toolbarqueries.google'.$googleDomains[mt_rand(0,count($googleDomains)-1)]; |
|
918
|
|
|
|
|
919
|
|
|
$url=sprintf($url,$host,$ch,$q); |
|
920
|
|
|
@$pr=trim(file_get_contents($url,false,$context)); |
|
|
|
|
|
|
921
|
|
|
|
|
922
|
|
|
if(is_numeric(substr(strrchr($pr, ':'), 1))) |
|
923
|
|
|
{ |
|
924
|
|
|
return substr(strrchr($pr, ':'), 1); |
|
925
|
|
|
} |
|
926
|
|
|
return '-1'; |
|
927
|
|
|
} |
|
928
|
|
|
} |
|
929
|
|
|
|
|
930
|
|
|
/** |
|
931
|
|
|
* comment class |
|
932
|
|
|
* @package phpBB3 |
|
933
|
|
|
*/ |
|
934
|
|
|
class comment |
|
|
|
|
|
|
935
|
|
|
{ |
|
936
|
|
|
/** |
|
937
|
|
|
* Add a comment |
|
938
|
|
|
* |
|
939
|
|
|
* @param array $data is link's data from db |
|
940
|
|
|
*/ |
|
941
|
|
|
function add($data) |
|
|
|
|
|
|
942
|
|
|
{ |
|
943
|
|
|
global $db, $config; |
|
944
|
|
|
|
|
945
|
|
|
$db->sql_transaction('begin'); |
|
946
|
|
|
|
|
947
|
|
|
$sql = 'INSERT INTO ' . DIR_COMMENT_TABLE . ' ' . $db->sql_build_array('INSERT', $data); |
|
948
|
|
|
$db->sql_query($sql); |
|
949
|
|
|
|
|
950
|
|
|
$sql = 'UPDATE ' . DIR_LINK_TABLE . ' |
|
951
|
|
|
SET link_comment = link_comment + 1 |
|
952
|
|
|
WHERE link_id = ' . (int)$data['comment_link_id']; |
|
953
|
|
|
$db->sql_query($sql); |
|
954
|
|
|
|
|
955
|
|
|
$db->sql_transaction('commit'); |
|
956
|
|
|
} |
|
957
|
|
|
|
|
958
|
|
|
/** |
|
959
|
|
|
* Edit a comment |
|
960
|
|
|
* |
|
961
|
|
|
* @param array $data is datas to edit |
|
962
|
|
|
* @param $id comment_id from db |
|
963
|
|
|
* |
|
964
|
|
|
*/ |
|
965
|
|
|
function edit($data, $id) |
|
|
|
|
|
|
966
|
|
|
{ |
|
967
|
|
|
global $db; |
|
968
|
|
|
|
|
969
|
|
|
$sql = 'UPDATE ' . DIR_COMMENT_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $data) . ' |
|
970
|
|
|
WHERE comment_id = ' . (int)$id; |
|
971
|
|
|
$db->sql_query($sql); |
|
972
|
|
|
} |
|
973
|
|
|
|
|
974
|
|
|
/** |
|
975
|
|
|
* Delete a comment |
|
976
|
|
|
* |
|
977
|
|
|
* @param string $id is comment_id from db |
|
978
|
|
|
* @param string $u is link_db |
|
979
|
|
|
*/ |
|
980
|
|
|
function del($id, $u) |
|
|
|
|
|
|
981
|
|
|
{ |
|
982
|
|
|
global $user, $db, $phpEx; |
|
983
|
|
|
global $directory_root_path; |
|
984
|
|
|
|
|
985
|
|
|
if (confirm_box(true)) |
|
986
|
|
|
{ |
|
987
|
|
|
$db->sql_transaction('begin'); |
|
988
|
|
|
|
|
989
|
|
|
$requete = 'DELETE FROM ' . DIR_COMMENT_TABLE . ' |
|
990
|
|
|
WHERE comment_id = ' . (int)$id; |
|
991
|
|
|
$db->sql_query($requete); |
|
992
|
|
|
|
|
993
|
|
|
$sql = 'UPDATE ' . DIR_LINK_TABLE . ' |
|
994
|
|
|
SET link_comment = link_comment - 1 |
|
995
|
|
|
WHERE link_id = ' . (int)$u; |
|
996
|
|
|
$db->sql_query($sql); |
|
997
|
|
|
|
|
998
|
|
|
$db->sql_transaction('commit'); |
|
999
|
|
|
|
|
1000
|
|
|
$redirect_url = append_sid("{$directory_root_path}directory_comment.$phpEx", array('u' => (int)$u)); |
|
|
|
|
|
|
1001
|
|
|
redirect($redirect_url); |
|
1002
|
|
|
//meta_refresh(3, $redirect_url); |
|
|
|
|
|
|
1003
|
|
|
//$message = $user->lang['DIR_COMMENT_DELETE_OK']; |
|
|
|
|
|
|
1004
|
|
|
//trigger_error($message); |
|
1005
|
|
|
} |
|
1006
|
|
|
else |
|
1007
|
|
|
{ |
|
1008
|
|
|
confirm_box(false, 'DIR_COMMENT_DELETE', '', 'mods/directory/comment_body.html'); |
|
1009
|
|
|
} |
|
1010
|
|
|
} |
|
1011
|
|
|
} |
|
1012
|
|
|
|
|
1013
|
|
|
/** |
|
1014
|
|
|
* categorie class |
|
1015
|
|
|
* @package phpBB3 |
|
1016
|
|
|
*/ |
|
1017
|
|
|
class categorie |
|
|
|
|
|
|
1018
|
|
|
{ |
|
1019
|
|
|
var $data = array(); |
|
1020
|
|
|
|
|
1021
|
|
|
/** |
|
1022
|
|
|
* Get somes categorie infos |
|
1023
|
|
|
*/ |
|
1024
|
|
|
function categorie($id = 0) |
|
|
|
|
|
|
1025
|
|
|
{ |
|
1026
|
|
|
global $db; |
|
1027
|
|
|
|
|
1028
|
|
|
if ($id) |
|
1029
|
|
|
{ |
|
1030
|
|
|
$sql = 'SELECT cat_id, cat_name, parent_id, left_id, right_id, cat_parents, cat_must_describe, cat_allow_votes, cat_allow_comments, cat_links, cat_validate, cat_link_back, cat_cron_enable, cat_cron_next, cat_cron_freq, cat_cron_enable, cat_cron_nb_check |
|
1031
|
|
|
FROM ' . DIR_CAT_TABLE . ' |
|
1032
|
|
|
WHERE cat_id = ' . (int)$id; |
|
1033
|
|
|
$result = $db->sql_query($sql); |
|
1034
|
|
|
if(!$this->data = $db->sql_fetchrow($result)) |
|
1035
|
|
|
{ |
|
1036
|
|
|
send_status_line(410, 'Gone'); |
|
1037
|
|
|
|
|
1038
|
|
|
trigger_error('DIR_ERROR_NO_CATS'); |
|
1039
|
|
|
} |
|
1040
|
|
|
$db->sql_freeresult($result); |
|
1041
|
|
|
} |
|
1042
|
|
|
} |
|
1043
|
|
|
|
|
1044
|
|
|
/** |
|
1045
|
|
|
* static function for get approval setting |
|
1046
|
|
|
* used in edit mode for test the setting of new category's link |
|
1047
|
|
|
*/ |
|
1048
|
|
|
function need_approval($id) |
|
|
|
|
|
|
1049
|
|
|
{ |
|
1050
|
|
|
global $db; |
|
1051
|
|
|
|
|
1052
|
|
|
$sql = 'SELECT cat_validate |
|
1053
|
|
|
FROM ' . DIR_CAT_TABLE . ' |
|
1054
|
|
|
WHERE cat_id = ' . (int)$id; |
|
1055
|
|
|
$result = $db->sql_query($sql); |
|
1056
|
|
|
$row = $db->sql_fetchrow($result); |
|
1057
|
|
|
|
|
1058
|
|
|
return (int)$row['cat_validate']; |
|
1059
|
|
|
} |
|
1060
|
|
|
|
|
1061
|
|
|
/** |
|
1062
|
|
|
* Generate a list of directory'scategories |
|
1063
|
|
|
* |
|
1064
|
|
|
* @param int $select_id is selected cat |
|
1065
|
|
|
* |
|
1066
|
|
|
* @retur html code |
|
1067
|
|
|
*/ |
|
1068
|
|
|
function make_cat_select($select_id) |
|
|
|
|
|
|
1069
|
|
|
{ |
|
1070
|
|
|
global $db, $user; |
|
1071
|
|
|
|
|
1072
|
|
|
// This query is identical to the jumpbox one |
|
1073
|
|
|
$sql = 'SELECT cat_id, cat_name, parent_id, left_id, right_id |
|
1074
|
|
|
FROM ' . DIR_CAT_TABLE . ' |
|
1075
|
|
|
ORDER BY left_id ASC'; |
|
1076
|
|
|
$result = $db->sql_query($sql, 600); |
|
1077
|
|
|
|
|
1078
|
|
|
$right = 0; |
|
1079
|
|
|
$padding_store = array('0' => ''); |
|
1080
|
|
|
$padding = ''; |
|
1081
|
|
|
$cat_list = ($select_id) ? '' : '<option value="0" selected="selected" style="font-weight:bold;">'.$user->lang['DIR_NONE']. '</option>'; |
|
1082
|
|
|
|
|
1083
|
|
|
while ($row = $db->sql_fetchrow($result)) |
|
1084
|
|
|
{ |
|
1085
|
|
View Code Duplication |
if ($row['left_id'] < $right) |
|
|
|
|
|
|
1086
|
|
|
{ |
|
1087
|
|
|
$padding .= ' '; |
|
1088
|
|
|
$padding_store[$row['parent_id']] = $padding; |
|
1089
|
|
|
} |
|
1090
|
|
|
else if ($row['left_id'] > $right + 1) |
|
1091
|
|
|
{ |
|
1092
|
|
|
$padding = (isset($padding_store[$row['parent_id']])) ? $padding_store[$row['parent_id']] : ''; |
|
1093
|
|
|
} |
|
1094
|
|
|
|
|
1095
|
|
|
$right = $row['right_id']; |
|
1096
|
|
|
|
|
1097
|
|
|
$selected = (($row['cat_id'] == $select_id) ? ' selected="selected"' : ''); |
|
1098
|
|
|
$cat_list .= '<option value="' . $row['cat_id'] . '"' . $selected . '>' . $padding . $row['cat_name'] . '</option>'; |
|
1099
|
|
|
} |
|
1100
|
|
|
$db->sql_freeresult($result); |
|
1101
|
|
|
unset($padding_store); |
|
1102
|
|
|
|
|
1103
|
|
|
return $cat_list; |
|
1104
|
|
|
} |
|
1105
|
|
|
|
|
1106
|
|
|
/** |
|
1107
|
|
|
* Display cat or subcat |
|
1108
|
|
|
*/ |
|
1109
|
|
|
function display() |
|
|
|
|
|
|
1110
|
|
|
{ |
|
1111
|
|
|
global $db, $template, $phpbb_root_path; |
|
1112
|
|
|
global $directory_root_path, $auth, $phpEx; |
|
1113
|
|
|
|
|
1114
|
|
|
$cat_rows = $subcats = array(); |
|
1115
|
|
|
$parent_id = $visible_cats = 0; |
|
1116
|
|
|
$sql_from = ''; |
|
|
|
|
|
|
1117
|
|
|
|
|
1118
|
|
|
$body = ($this->data) ? 'mods/directory/view_cat.html' : 'mods/directory/body.html'; |
|
1119
|
|
|
|
|
1120
|
|
|
$sql_array = array( |
|
1121
|
|
|
'SELECT' => 'cat_id, left_id, right_id, parent_id, cat_name, cat_desc, display_subcat_list, cat_desc_uid, cat_desc_bitfield, cat_desc_options, cat_links, cat_icon, cat_count_all', |
|
1122
|
|
|
'FROM' => array( |
|
1123
|
|
|
DIR_CAT_TABLE => '' |
|
1124
|
|
|
), |
|
1125
|
|
|
); |
|
1126
|
|
|
|
|
1127
|
|
|
if (!$this->data) |
|
|
|
|
|
|
1128
|
|
|
{ |
|
1129
|
|
|
$root_data = array('cat_id' => 0); |
|
1130
|
|
|
$sql_where = ''; |
|
1131
|
|
|
} |
|
1132
|
|
|
else |
|
1133
|
|
|
{ |
|
1134
|
|
|
$root_data = $this->data; |
|
1135
|
|
|
$sql_where = 'left_id > ' . $root_data['left_id'] . ' AND left_id < ' . $root_data['right_id']; |
|
1136
|
|
|
} |
|
1137
|
|
|
|
|
1138
|
|
|
$sql = $db->sql_build_query('SELECT', array( |
|
1139
|
|
|
'SELECT' => $sql_array['SELECT'], |
|
1140
|
|
|
'FROM' => $sql_array['FROM'], |
|
1141
|
|
|
|
|
1142
|
|
|
'WHERE' => $sql_where, |
|
1143
|
|
|
|
|
1144
|
|
|
'ORDER_BY' => 'left_id', |
|
1145
|
|
|
)); |
|
1146
|
|
|
|
|
1147
|
|
|
$result = $db->sql_query($sql); |
|
1148
|
|
|
|
|
1149
|
|
|
$branch_root_id = $root_data['cat_id']; |
|
1150
|
|
|
while ($row = $db->sql_fetchrow($result)) |
|
1151
|
|
|
{ |
|
1152
|
|
|
$dir_cat_id = $row['cat_id']; |
|
1153
|
|
|
|
|
1154
|
|
|
if ($row['parent_id'] == $root_data['cat_id'] || $row['parent_id'] == $branch_root_id) |
|
1155
|
|
|
{ |
|
1156
|
|
|
// Direct child of current branch |
|
1157
|
|
|
$parent_id = $dir_cat_id; |
|
1158
|
|
|
$cat_rows[$dir_cat_id] = $row; |
|
1159
|
|
|
} |
|
1160
|
|
|
else |
|
1161
|
|
|
{ |
|
1162
|
|
|
$subcats[$parent_id][$dir_cat_id]['display'] = ($row['display_subcat_list']) ? true : false; |
|
1163
|
|
|
$subcats[$parent_id][$dir_cat_id]['name'] = $row['cat_name']; |
|
1164
|
|
|
$subcats[$parent_id][$dir_cat_id]['links'] = $row['cat_links']; |
|
1165
|
|
|
$subcats[$parent_id][$dir_cat_id]['parent_id'] = $row['parent_id']; |
|
1166
|
|
|
} |
|
1167
|
|
|
} |
|
1168
|
|
|
$db->sql_freeresult($result); |
|
1169
|
|
|
|
|
1170
|
|
|
// Used to tell whatever we have to create a dummy category or not. |
|
1171
|
|
|
$last_catless = true; |
|
|
|
|
|
|
1172
|
|
|
|
|
1173
|
|
|
foreach ($cat_rows as $row) |
|
1174
|
|
|
{ |
|
1175
|
|
|
$visible_cats++; |
|
1176
|
|
|
$dir_cat_id = $row['cat_id']; |
|
1177
|
|
|
|
|
1178
|
|
|
$folder_image = $folder_alt = ''; |
|
|
|
|
|
|
1179
|
|
|
$subcats_list = array(); |
|
1180
|
|
|
|
|
1181
|
|
|
// Generate list of subcats if we need to |
|
1182
|
|
|
if (isset($subcats[$dir_cat_id])) |
|
1183
|
|
|
{ |
|
1184
|
|
|
foreach ($subcats[$dir_cat_id] as $subcat_id => $subcat_row) |
|
1185
|
|
|
{ |
|
1186
|
|
|
$row['cat_links'] = ($row['cat_count_all']) ? ($row['cat_links']+$subcat_row['links']) : $row['cat_links']; |
|
1187
|
|
|
|
|
1188
|
|
|
if ($subcat_row['display'] && $subcat_row['parent_id'] == $dir_cat_id) |
|
1189
|
|
|
{ |
|
1190
|
|
|
$subcats_list[] = array( |
|
1191
|
|
|
'link' => append_sid("{$directory_root_path}directory.$phpEx", array('mode' => 'cat', 'id' => $subcat_id)), |
|
|
|
|
|
|
1192
|
|
|
'name' => $subcat_row['name'], |
|
1193
|
|
|
'links' => $subcat_row['links'] |
|
1194
|
|
|
); |
|
1195
|
|
|
} |
|
1196
|
|
|
else |
|
1197
|
|
|
{ |
|
1198
|
|
|
unset($subcats[$dir_cat_id][$subcat_id]); |
|
1199
|
|
|
} |
|
1200
|
|
|
} |
|
1201
|
|
|
} |
|
1202
|
|
|
|
|
1203
|
|
|
$template->assign_block_vars('cat', array( |
|
1204
|
|
|
'CAT_NAME' => $row['cat_name'], |
|
1205
|
|
|
'CAT_DESC' => generate_text_for_display($row['cat_desc'], $row['cat_desc_uid'], $row['cat_desc_bitfield'], $row['cat_desc_options']), |
|
1206
|
|
|
'CAT_LINKS' => $row['cat_links'], |
|
1207
|
|
|
'CAT_IMG' => $phpbb_root_path . 'images/directory/icons/'.$row['cat_icon'], |
|
1208
|
|
|
|
|
1209
|
|
|
'U_CAT' => append_sid("{$directory_root_path}directory.$phpEx", array('mode' => 'cat', 'id' => $row['cat_id'])) |
|
|
|
|
|
|
1210
|
|
|
)); |
|
1211
|
|
|
|
|
1212
|
|
|
// Assign subcats loop for style authors |
|
1213
|
|
|
foreach ($subcats_list as $subcat) |
|
1214
|
|
|
{ |
|
1215
|
|
|
$template->assign_block_vars('cat.subcat', array( |
|
1216
|
|
|
'U_CAT' => $subcat['link'], |
|
1217
|
|
|
'CAT_NAME' => $subcat['name'], |
|
1218
|
|
|
'CAT_LINKS' => $subcat['links'] |
|
1219
|
|
|
)); |
|
1220
|
|
|
} |
|
1221
|
|
|
} |
|
1222
|
|
|
if ($this->data) |
|
|
|
|
|
|
1223
|
|
|
{ |
|
1224
|
|
|
$param = '&id='.$this->data['cat_id']; |
|
1225
|
|
|
} |
|
1226
|
|
|
else |
|
1227
|
|
|
{ |
|
1228
|
|
|
$param = ''; |
|
1229
|
|
|
} |
|
1230
|
|
|
|
|
1231
|
|
|
$template->assign_vars(array( |
|
1232
|
|
|
'S_AUTH_ADD' => $auth->acl_get('u_submit_dir') && $root_data['cat_id'], |
|
1233
|
|
|
'S_AUTH_SEARCH' => $auth->acl_get('u_search_dir'), |
|
1234
|
|
|
'S_HAS_SUBCAT' => ($visible_cats) ? true : false, |
|
1235
|
|
|
|
|
1236
|
|
|
'U_MAKE_SEARCH' => append_sid("{$directory_root_path}directory_search.$phpEx"), |
|
|
|
|
|
|
1237
|
|
|
'U_NEW_SITE' => append_sid("{$directory_root_path}directory.$phpEx", "mode=new" . $param, true), |
|
|
|
|
|
|
1238
|
|
|
)); |
|
1239
|
|
|
|
|
1240
|
|
|
$template->set_filenames(array('body' => $body)); |
|
1241
|
|
|
|
|
1242
|
|
|
return $root_data; |
|
1243
|
|
|
} |
|
1244
|
|
|
} |
|
1245
|
|
|
|
|
1246
|
|
|
/** |
|
1247
|
|
|
* directory_cron class |
|
1248
|
|
|
* @package phpBB3 |
|
1249
|
|
|
*/ |
|
1250
|
|
|
class directory_cron extends link { |
|
|
|
|
|
|
1251
|
|
|
|
|
1252
|
|
|
var $categorie = array(); |
|
1253
|
|
|
|
|
1254
|
|
|
/** |
|
1255
|
|
|
* Constructor |
|
1256
|
|
|
*/ |
|
1257
|
|
|
function directory_cron($catrow) |
|
|
|
|
|
|
1258
|
|
|
{ |
|
1259
|
|
|
$this->categorie = $catrow; |
|
1260
|
|
|
} |
|
1261
|
|
|
|
|
1262
|
|
|
function check() |
|
|
|
|
|
|
1263
|
|
|
{ |
|
1264
|
|
|
global $db, $user; |
|
1265
|
|
|
|
|
1266
|
|
|
$del_array = $update_array = array(); |
|
1267
|
|
|
|
|
1268
|
|
|
$sql_array = array( |
|
1269
|
|
|
'SELECT' => 'l.link_id, l.link_back, l.link_guest_email, l.link_nb_check, l.link_user_id, l.link_name, l.link_url, l.link_description, u.user_lang, u.user_email, u.username, u.user_jabber, u.user_notify_type, u.user_dateformat', |
|
1270
|
|
|
'FROM' => array( |
|
1271
|
|
|
DIR_LINK_TABLE => 'l'), |
|
1272
|
|
|
'LEFT_JOIN' => array( |
|
1273
|
|
|
array( |
|
1274
|
|
|
'FROM' => array(USERS_TABLE => 'u'), |
|
1275
|
|
|
'ON' => 'l.link_user_id = u.user_id' |
|
1276
|
|
|
), |
|
1277
|
|
|
), |
|
1278
|
|
|
'WHERE' => "l.link_back <> '' |
|
1279
|
|
|
AND l.link_active = 1 |
|
1280
|
|
|
AND link_cat = " . (int)$this->categorie['cat_id'] |
|
1281
|
|
|
); |
|
1282
|
|
|
$sql = $db->sql_build_query('SELECT', $sql_array); |
|
1283
|
|
|
$result = $db->sql_query($sql); |
|
1284
|
|
|
|
|
1285
|
|
|
while ($row = $db->sql_fetchrow($result)) |
|
1286
|
|
|
{ |
|
1287
|
|
|
if(validate_link_back($row['link_back'], false, true) !== false) |
|
1288
|
|
|
{ |
|
1289
|
|
|
if(!$this->categorie['cat_cron_nb_check'] || ($row['link_nb_check']+1) >= $this->categorie['cat_cron_nb_check']) |
|
1290
|
|
|
{ |
|
1291
|
|
|
$del_array[] = $row['link_id']; |
|
1292
|
|
|
} |
|
1293
|
|
|
else |
|
1294
|
|
|
{ |
|
1295
|
|
|
// A first table containing links ID to update |
|
1296
|
|
|
$update_array[] = $row['link_id']; |
|
1297
|
|
|
// A second array containing several information used when sending the reminder email |
|
1298
|
|
|
$mail_array[] = $row; |
|
|
|
|
|
|
1299
|
|
|
} |
|
1300
|
|
|
} |
|
1301
|
|
|
} |
|
1302
|
|
|
$db->sql_freeresult($result); |
|
1303
|
|
|
|
|
1304
|
|
|
if (sizeof($del_array)) |
|
1305
|
|
|
{ |
|
1306
|
|
|
$this->del($del_array, $this->categorie['cat_id'], true); |
|
1307
|
|
|
} |
|
1308
|
|
|
if (sizeof($update_array)) |
|
1309
|
|
|
{ |
|
1310
|
|
|
$this->update($update_array, $mail_array); |
|
|
|
|
|
|
1311
|
|
|
} |
|
1312
|
|
|
} |
|
1313
|
|
|
|
|
1314
|
|
|
function auto_check($prune_freq) |
|
|
|
|
|
|
1315
|
|
|
{ |
|
1316
|
|
|
global $db; |
|
1317
|
|
|
|
|
1318
|
|
|
$sql = 'SELECT cat_name |
|
1319
|
|
|
FROM ' . DIR_CAT_TABLE . ' |
|
1320
|
|
|
WHERE cat_id = ' . (int)$this->categorie['cat_id']; |
|
1321
|
|
|
$result = $db->sql_query($sql, 3600); |
|
1322
|
|
|
$row = $db->sql_fetchrow($result); |
|
1323
|
|
|
$db->sql_freeresult($result); |
|
1324
|
|
|
|
|
1325
|
|
|
if ($row) |
|
1326
|
|
|
{ |
|
1327
|
|
|
$next_prune = time() + ($prune_freq * 86400); |
|
1328
|
|
|
|
|
1329
|
|
|
$this->check(); |
|
1330
|
|
|
|
|
1331
|
|
|
$sql = 'UPDATE ' . DIR_CAT_TABLE . " |
|
|
|
|
|
|
1332
|
|
|
SET cat_cron_next = $next_prune |
|
1333
|
|
|
WHERE cat_id = " . (int)$this->categorie['cat_id']; |
|
1334
|
|
|
$db->sql_query($sql); |
|
1335
|
|
|
|
|
1336
|
|
|
add_log('admin', 'LOG_DIR_AUTO_PRUNE', $row['cat_name']); |
|
1337
|
|
|
} |
|
1338
|
|
|
|
|
1339
|
|
|
return; |
|
1340
|
|
|
} |
|
1341
|
|
|
|
|
1342
|
|
|
function update($u_array, $m_array) |
|
|
|
|
|
|
1343
|
|
|
{ |
|
1344
|
|
|
global $db, $phpbb_root_path; |
|
1345
|
|
|
|
|
1346
|
|
|
|
|
1347
|
|
|
$sql = 'UPDATE ' . DIR_LINK_TABLE . ' |
|
1348
|
|
|
SET link_nb_check = link_nb_check + 1 |
|
1349
|
|
|
WHERE ' . $db->sql_in_set('link_id', $u_array); |
|
1350
|
|
|
$db->sql_query($sql); |
|
1351
|
|
|
|
|
1352
|
|
|
$this->notify($m_array); |
|
1353
|
|
|
} |
|
1354
|
|
|
|
|
1355
|
|
|
function notify($m_array) |
|
|
|
|
|
|
1356
|
|
|
{ |
|
1357
|
|
|
global $phpbb_root_path, $phpEx, $user, $config; |
|
1358
|
|
|
|
|
1359
|
|
|
$user->add_lang(array('common', 'mods/directory')); |
|
1360
|
|
|
|
|
1361
|
|
|
if(!class_exists('messenger')) |
|
1362
|
|
|
{ |
|
1363
|
|
|
include($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); |
|
1364
|
|
|
} |
|
1365
|
|
|
$messenger = new messenger(false); |
|
1366
|
|
|
|
|
1367
|
|
|
$row = array(); |
|
1368
|
|
|
$next = (time() + ($this->categorie['cat_cron_freq'] * 86400)); |
|
1369
|
|
|
foreach($m_array as $row) |
|
1370
|
|
|
{ |
|
1371
|
|
|
strip_bbcode($row['link_description']); |
|
1372
|
|
|
|
|
1373
|
|
|
$messenger->template('mods/directory/error_check', $row['user_lang']); |
|
1374
|
|
|
$messenger->replyto($config['board_email']); |
|
1375
|
|
|
$messenger->to($row['user_email'], $row['username']); |
|
1376
|
|
|
|
|
1377
|
|
|
$messenger->im($row['user_jabber'], $row['username']); |
|
1378
|
|
|
|
|
1379
|
|
|
$messenger->headers('X-AntiAbuse: Board servername - ' . $config['server_name']); |
|
1380
|
|
|
$messenger->headers('X-AntiAbuse: User_id - ' . $user->data['user_id']); |
|
1381
|
|
|
$messenger->headers('X-AntiAbuse: Username - ' . $user->data['username']); |
|
1382
|
|
|
$messenger->headers('X-AntiAbuse: User IP - ' . $user->ip); |
|
1383
|
|
|
|
|
1384
|
|
|
$messenger->assign_vars(array( |
|
1385
|
|
|
'USERNAME' => $row['username'], |
|
1386
|
|
|
'CAT_NAME' => strip_tags($this->categorie['cat_name']), |
|
1387
|
|
|
'LINK_NAME' => $row['link_name'], |
|
1388
|
|
|
'LINK_URL' => $row['link_url'], |
|
1389
|
|
|
'LINK_DESCRIPTION' => $row['link_description'], |
|
1390
|
|
|
'NEXT_CRON' => $user->format_date($next, 'd M Y, H:i') |
|
1391
|
|
|
)); |
|
1392
|
|
|
|
|
1393
|
|
|
$messenger->send($row['user_notify_type']); |
|
1394
|
|
|
} |
|
1395
|
|
|
} |
|
1396
|
|
|
} |
|
1397
|
|
|
|
|
1398
|
|
|
/* |
|
|
|
|
|
|
1399
|
|
|
function _unaccent_compare_ci($a, $b) |
|
1400
|
|
|
{ |
|
1401
|
|
|
return strcasecmp(_remove_accents($a), _remove_accents($b)); |
|
1402
|
|
|
} |
|
1403
|
|
|
|
|
1404
|
|
|
function _remove_accents($str) |
|
1405
|
|
|
{ |
|
1406
|
|
|
if (version_compare(PHP_VERSION, '5.2.3', '>=')) |
|
1407
|
|
|
{ |
|
1408
|
|
|
$str = htmlentities($str, ENT_NOQUOTES, "UTF-8", false); |
|
1409
|
|
|
} |
|
1410
|
|
|
else |
|
1411
|
|
|
{ |
|
1412
|
|
|
$str = htmlentities($str, ENT_NOQUOTES, "UTF-8"); |
|
1413
|
|
|
} |
|
1414
|
|
|
|
|
1415
|
|
|
$str = preg_replace('#&([A-za-z])(?:acute|breve|caron|cedil|circ|grave|ogon|orn|ring|slash|th|tilde|uml);#', '\1', $str); |
|
1416
|
|
|
$str = preg_replace('#&([A-za-z]{2})(?:lig);#', '\1', $str); |
|
1417
|
|
|
$str = preg_replace('#&[^;]+;#', '', $str); |
|
1418
|
|
|
|
|
1419
|
|
|
return $str; |
|
1420
|
|
|
} |
|
1421
|
|
|
*/ |
|
1422
|
|
|
|
|
1423
|
|
|
/** |
|
1424
|
|
|
* List flags |
|
1425
|
|
|
* |
|
1426
|
|
|
* @param string $dir is flag directory path |
|
|
|
|
|
|
1427
|
|
|
* @param $value selected flag |
|
1428
|
|
|
* |
|
1429
|
|
|
* @return html code |
|
1430
|
|
|
*/ |
|
1431
|
|
|
function get_dir_flag_list($value) |
|
1432
|
|
|
{ |
|
1433
|
|
|
global $user, $phpEx; |
|
1434
|
|
|
|
|
1435
|
|
|
$flags = array(); |
|
1436
|
|
|
$list = ''; |
|
1437
|
|
|
|
|
1438
|
|
|
if (file_exists("{$user->lang_path}{$user->lang_name}/mods/directory_flags.$phpEx")) |
|
|
|
|
|
|
1439
|
|
|
{ |
|
1440
|
|
|
// include the file containing flags |
|
1441
|
|
|
include("{$user->lang_path}{$user->lang_name}/mods/directory_flags.$phpEx"); |
|
|
|
|
|
|
1442
|
|
|
} |
|
1443
|
|
|
//uasort($flags, '_unaccent_compare_ci'); |
|
|
|
|
|
|
1444
|
|
|
asort($flags); |
|
1445
|
|
|
|
|
1446
|
|
|
foreach ($flags as $file => $name) |
|
1447
|
|
|
{ |
|
1448
|
|
|
$img_file = strtolower($file).'.png'; |
|
1449
|
|
|
if (file_exists('images/directory/flags/'.$img_file)) |
|
1450
|
|
|
{ |
|
1451
|
|
|
$list .= '<option value="' . $img_file . '" ' . (($img_file == $value) ? 'selected="selected"' : '') . '>' . $name . '</option>'; |
|
1452
|
|
|
} |
|
1453
|
|
|
} |
|
1454
|
|
|
|
|
1455
|
|
|
return ($list); |
|
1456
|
|
|
} |
|
1457
|
|
|
|
|
1458
|
|
|
/* |
|
1459
|
|
|
* Return good key language |
|
1460
|
|
|
* |
|
1461
|
|
|
* @param int $validate true if approbation needed before publication |
|
1462
|
|
|
*/ |
|
1463
|
|
|
function dir_submit_type($validate) |
|
1464
|
|
|
{ |
|
1465
|
|
|
global $user, $auth; |
|
1466
|
|
|
|
|
1467
|
|
|
if ($validate && !$auth->acl_get('a_')) |
|
1468
|
|
|
{ |
|
1469
|
|
|
return ($user->lang['DIR_SUBMIT_TYPE_1']); |
|
1470
|
|
|
} |
|
1471
|
|
|
else if (!$validate && !$auth->acl_get('a_')) |
|
1472
|
|
|
{ |
|
1473
|
|
|
return ($user->lang['DIR_SUBMIT_TYPE_2']); |
|
1474
|
|
|
} |
|
1475
|
|
|
else if ($auth->acl_get('a_')) |
|
1476
|
|
|
{ |
|
1477
|
|
|
return ($user->lang['DIR_SUBMIT_TYPE_3']); |
|
1478
|
|
|
} |
|
1479
|
|
|
else if ($auth->acl_get('m_')) |
|
1480
|
|
|
{ |
|
1481
|
|
|
return ($user->lang['DIR_SUBMIT_TYPE_4']); |
|
1482
|
|
|
} |
|
1483
|
|
|
trigger_error('DIR_ERROR_SUBMIT_TYPE'); |
|
1484
|
|
|
} |
|
1485
|
|
|
|
|
1486
|
|
|
/** |
|
1487
|
|
|
* Generate directory navigation for navbar |
|
1488
|
|
|
*/ |
|
1489
|
|
|
function generate_dir_nav(&$dir_cat_data) |
|
1490
|
|
|
{ |
|
1491
|
|
|
global $template, $phpEx; |
|
1492
|
|
|
global $directory_root_path; |
|
1493
|
|
|
|
|
1494
|
|
|
// Get cat parents |
|
1495
|
|
|
$dir_cat_parents = get_cat_parents($dir_cat_data); |
|
1496
|
|
|
|
|
1497
|
|
|
// Build navigation links |
|
1498
|
|
|
if (!empty($dir_cat_parents)) |
|
1499
|
|
|
{ |
|
1500
|
|
|
foreach ($dir_cat_parents as $parent_cat_id => $parent_name) |
|
1501
|
|
|
{ |
|
1502
|
|
|
$template->assign_block_vars('navlinks', array( |
|
1503
|
|
|
'FORUM_NAME' => $parent_name, |
|
1504
|
|
|
'FORUM_ID' => $parent_cat_id, |
|
1505
|
|
|
'U_VIEW_FORUM' => append_sid("{$directory_root_path}directory.$phpEx", array('mode' => 'cat', 'id' => $parent_cat_id)) |
|
|
|
|
|
|
1506
|
|
|
)); |
|
1507
|
|
|
} |
|
1508
|
|
|
} |
|
1509
|
|
|
|
|
1510
|
|
|
$template->assign_block_vars('navlinks', array( |
|
1511
|
|
|
'FORUM_NAME' => $dir_cat_data['cat_name'], |
|
1512
|
|
|
'FORUM_ID' => $dir_cat_data['cat_id'], |
|
1513
|
|
|
'U_VIEW_FORUM' => append_sid("{$directory_root_path}directory.$phpEx", array('mode' => 'cat', 'id' => $dir_cat_data['cat_id'])) |
|
|
|
|
|
|
1514
|
|
|
)); |
|
1515
|
|
|
|
|
1516
|
|
|
return; |
|
1517
|
|
|
} |
|
1518
|
|
|
|
|
1519
|
|
|
/** |
|
1520
|
|
|
* Returns cat parents as an array. Get them from cat_data if available, or update the database otherwise |
|
1521
|
|
|
* |
|
1522
|
|
|
* @param array $dir_cat_data fatas from db |
|
1523
|
|
|
*/ |
|
1524
|
|
|
function get_cat_parents(&$dir_cat_data) |
|
1525
|
|
|
{ |
|
1526
|
|
|
global $db; |
|
1527
|
|
|
|
|
1528
|
|
|
$dir_cat_parents = array(); |
|
1529
|
|
|
|
|
1530
|
|
|
if ($dir_cat_data['parent_id'] > 0) |
|
1531
|
|
|
{ |
|
1532
|
|
|
if ($dir_cat_data['cat_parents'] == '') |
|
1533
|
|
|
{ |
|
1534
|
|
|
$sql = 'SELECT cat_id, cat_name |
|
1535
|
|
|
FROM ' . DIR_CAT_TABLE . ' |
|
1536
|
|
|
WHERE left_id < ' . (int)$dir_cat_data['left_id'] . ' |
|
1537
|
|
|
AND right_id > ' . (int)$dir_cat_data['right_id'] . ' |
|
1538
|
|
|
ORDER BY left_id ASC'; |
|
1539
|
|
|
$result = $db->sql_query($sql); |
|
1540
|
|
|
|
|
1541
|
|
|
while ($row = $db->sql_fetchrow($result)) |
|
1542
|
|
|
{ |
|
1543
|
|
|
$dir_cat_parents[$row['cat_id']] = $row['cat_name']; |
|
1544
|
|
|
} |
|
1545
|
|
|
$db->sql_freeresult($result); |
|
1546
|
|
|
|
|
1547
|
|
|
$dir_cat_data['cat_parents'] = serialize($dir_cat_parents); |
|
1548
|
|
|
|
|
1549
|
|
|
$sql = 'UPDATE ' . DIR_CAT_TABLE . " |
|
1550
|
|
|
SET cat_parents = '" . $db->sql_escape($dir_cat_data['cat_parents']) . "' |
|
1551
|
|
|
WHERE parent_id = " . (int)$dir_cat_data['parent_id']; |
|
1552
|
|
|
$db->sql_query($sql); |
|
1553
|
|
|
} |
|
1554
|
|
|
else |
|
1555
|
|
|
{ |
|
1556
|
|
|
$dir_cat_parents = unserialize($dir_cat_data['cat_parents']); |
|
1557
|
|
|
} |
|
1558
|
|
|
} |
|
1559
|
|
|
|
|
1560
|
|
|
return $dir_cat_parents; |
|
1561
|
|
|
} |
|
1562
|
|
|
|
|
1563
|
|
|
function recent_links() |
|
1564
|
|
|
{ |
|
1565
|
|
|
global $config, $db, $template, $user; |
|
1566
|
|
|
global $directory_root_path, $phpEx; |
|
1567
|
|
|
|
|
1568
|
|
|
if($config['dir_recent_block']) |
|
1569
|
|
|
{ |
|
1570
|
|
|
$limit_sql = $config['dir_recent_rows'] * $config['dir_recent_columns']; |
|
1571
|
|
|
$exclude_array = explode(',', str_replace(' ', '', $config['dir_recent_exclude'])); |
|
1572
|
|
|
|
|
1573
|
|
|
$sql_array = array( |
|
1574
|
|
|
'SELECT' => 'l.link_id, l.link_cat, l.link_url, l.link_user_id, l.link_comment, l. link_description, l.link_vote, l.link_note, l.link_view, l.link_time, l.link_name, l.link_thumb, u.user_id, u.username, u.user_colour, c.cat_name', |
|
1575
|
|
|
'FROM' => array( |
|
1576
|
|
|
DIR_LINK_TABLE => 'l'), |
|
1577
|
|
|
'LEFT_JOIN' => array( |
|
1578
|
|
|
array( |
|
1579
|
|
|
'FROM' => array(USERS_TABLE => 'u'), |
|
1580
|
|
|
'ON' => 'l.link_user_id = u.user_id' |
|
1581
|
|
|
), |
|
1582
|
|
|
array( |
|
1583
|
|
|
'FROM' => array(DIR_CAT_TABLE => 'c'), |
|
1584
|
|
|
'ON' => 'l.link_cat = c.cat_id' |
|
1585
|
|
|
) |
|
1586
|
|
|
), |
|
1587
|
|
|
'WHERE' => $db->sql_in_set('l.link_cat', $exclude_array, true).' AND l.link_active = 1', |
|
1588
|
|
|
'ORDER_BY' => 'l.link_time DESC'); |
|
1589
|
|
|
|
|
1590
|
|
|
$sql = $db->sql_build_query('SELECT', $sql_array); |
|
1591
|
|
|
$result = $db->sql_query_limit($sql, $limit_sql, 0); |
|
1592
|
|
|
$num = 0; |
|
1593
|
|
|
$rowset = array(); |
|
1594
|
|
|
|
|
1595
|
|
|
while ($site = $db->sql_fetchrow($result)) |
|
1596
|
|
|
{ |
|
1597
|
|
|
$rowset[$site['link_id']] = $site; |
|
1598
|
|
|
} |
|
1599
|
|
|
$db->sql_freeresult($result); |
|
1600
|
|
|
|
|
1601
|
|
|
if(sizeof($rowset)) |
|
1602
|
|
|
{ |
|
1603
|
|
|
$template->assign_block_vars('block', array( |
|
1604
|
|
|
'S_COL_WIDTH' => (100 / $config['dir_recent_columns']) . '%', |
|
1605
|
|
|
)); |
|
1606
|
|
|
|
|
1607
|
|
|
foreach($rowset as $row) |
|
1608
|
|
|
{ |
|
1609
|
|
|
if (($num % $config['dir_recent_columns']) == 0) |
|
1610
|
|
|
{ |
|
1611
|
|
|
$template->assign_block_vars('block.row', array()); |
|
1612
|
|
|
} |
|
1613
|
|
|
|
|
1614
|
|
|
$template->assign_block_vars('block.row.col', array( |
|
1615
|
|
|
'UC_THUMBNAIL' => '<a href="'.$row['link_url'].'" onclick="window.open(\''.$directory_root_path.'directory.'.$phpEx.'?mode=view_url&u='.$row['link_id'].'\'); return false;"><img src="'.$row['link_thumb'].'" title="'.$row['link_name'].'" alt="'.$row['link_name'].'" /></a>', |
|
1616
|
|
|
'NAME' => $row['link_name'], |
|
1617
|
|
|
'USER' => get_username_string('full', $row['link_user_id'], $row['username'], $row['user_colour']), |
|
1618
|
|
|
'TIME' => ($row['link_time']) ? $user->format_date($row['link_time']) : '', |
|
1619
|
|
|
'CAT' => $row['cat_name'], |
|
1620
|
|
|
'COUNT' => $row['link_view'], |
|
1621
|
|
|
'COMMENT' => $row['link_comment'], |
|
1622
|
|
|
|
|
1623
|
|
|
'U_CAT' => append_sid("{$directory_root_path}directory.$phpEx", array('mode' => 'cat', 'id' => (int)$row['link_cat'])), |
|
|
|
|
|
|
1624
|
|
|
'U_COMMENT' => append_sid("{$directory_root_path}directory_comment.$phpEx", array('u' => (int)$row['link_id'])), |
|
|
|
|
|
|
1625
|
|
|
|
|
1626
|
|
|
'L_DIR_SEARCH_NB_CLIC' => ($row['link_view'] > 1) ? $user->lang['DIR_SEARCH_NB_CLICS'] : $user->lang['DIR_SEARCH_NB_CLIC'], |
|
1627
|
|
|
'L_DIR_SEARCH_NB_COMM' => ($row['link_comment'] > 1) ? $user->lang['L_DIR_SEARCH_NB_COMMS']: $user->lang['L_DIR_SEARCH_NB_COMM'], |
|
1628
|
|
|
)); |
|
1629
|
|
|
$num++; |
|
1630
|
|
|
} |
|
1631
|
|
|
|
|
1632
|
|
|
while (($num % $config['dir_recent_columns']) != 0) |
|
1633
|
|
|
{ |
|
1634
|
|
|
$template->assign_block_vars('block.row.col2', array()); |
|
1635
|
|
|
$num++; |
|
1636
|
|
|
} |
|
1637
|
|
|
} |
|
1638
|
|
|
} |
|
1639
|
|
|
} |
|
1640
|
|
|
|
|
1641
|
|
|
function validate_link_back($remote_url, $optional, $cron = false) |
|
1642
|
|
|
{ |
|
1643
|
|
|
global $config; |
|
1644
|
|
|
|
|
1645
|
|
|
if(!$cron) |
|
1646
|
|
|
{ |
|
1647
|
|
|
if (empty($remote_url) && $optional) |
|
1648
|
|
|
{ |
|
1649
|
|
|
return false; |
|
1650
|
|
|
} |
|
1651
|
|
|
|
|
1652
|
|
|
if (!preg_match('#^http[s]?://(.*?\.)*?[a-z0-9\-]+\.[a-z]{2,4}#i', $remote_url)) |
|
1653
|
|
|
{ |
|
1654
|
|
|
return 'DIR_ERROR_WRONG_DATA_BACK'; |
|
1655
|
|
|
} |
|
1656
|
|
|
} |
|
1657
|
|
|
|
|
1658
|
|
|
if (false === ($handle = @fopen($remote_url, 'r'))) |
|
1659
|
|
|
{ |
|
1660
|
|
|
return 'DIR_ERROR_NOT_FOUND_BACK'; |
|
1661
|
|
|
} |
|
1662
|
|
|
|
|
1663
|
|
|
$buff = ''; |
|
1664
|
|
|
|
|
1665
|
|
|
// Read by packet, faster than file_get_contents() |
|
1666
|
|
|
while (!feof($handle)) |
|
1667
|
|
|
{ |
|
1668
|
|
|
$buff .= fgets($handle, 256); |
|
1669
|
|
|
|
|
1670
|
|
|
if(stristr($buff, $config['server_name'])) |
|
1671
|
|
|
{ |
|
1672
|
|
|
@fclose($handle); |
|
1673
|
|
|
return false; |
|
1674
|
|
|
} |
|
1675
|
|
|
} |
|
1676
|
|
|
@fclose($handle); |
|
1677
|
|
|
|
|
1678
|
|
|
return 'DIR_ERROR_NO_LINK_BACK'; |
|
1679
|
|
|
} |
|
1680
|
|
|
|
|
1681
|
|
|
$link = new link; |
|
1682
|
|
|
|
|
1683
|
|
|
?> |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.