root/include/functions_post.php

Revision 336, 20.8 kB (checked in by Nafania, 1 year ago)

Мелкие баг-фиксы. Поддержка сфинкса (корявая) в поиске торрентов. sphinxapi.php надо использовать свой - тот что лежит, только для примера.
Список файлов показывается напрямую из торрент файла, а не из базы, но таблицы пока оставлены - на всякий случай.

Line 
1 <?php
2 function commenttable( $type = TYPE_TORRENT, $id, $owner, $offset, $limit ) {</span>
3 <span class="code-keyword">    global $db, $userdata, $lang, $template, $config, $images, $cache, $root_path;
4     global $bb_code;
5     global $seo;
6     static $ranks;
7
8     if ( !isset($ranks) ) {
9         $ranks = $cache->obtain_ranks();
10     }
11     if ( !isset($bb_code) ) {
12         $bb_code = new bbcode();
13     }
14
15     $template->set_filenames(array(
16         'comments_table' => 'comments_table.html'
17     ));
18
19     $last_read = get_tracking($type, $id);
20
21     $sql = 'SELECT c.comment_id, c.comment_text, c.comment_user, c.comment_added, c.comment_editedby, c.comment_editedat, c.comment_reputation, u.avatar, u.warneduntil, u.parked, u.name, u.title, u.class, u.donor, u.downloaded, u.uploaded, u.enabled, u2.name AS edited_by_username, u.birthday, u.gender, u.user_session_time, u.user_sig, u.privacy, u.user_reputation_level, u.user_rank_id, u.name_append, u.uid, u.user_reputation
22             FROM ' . COMMENTS_TABLE . ' c
23             LEFT JOIN ' . USERS_TABLE . ' u2 ON c.comment_editedby = u2.uid,
24             ' . USERS_TABLE . ' u
25             WHERE c.comment_for_id = ' . $id . '
26             AND c.comment_type = ' . $type . '
27             AND c.comment_user = u.uid
28             ORDER BY c.comment_added ASC';
29     $result = $db->sql_query_limit($sql, $limit, $offset);
30
31     $comments_ary = array();
32     $comments = array();
33     $simpaty_ary = array();
34
35     while ( $row = $db->sql_fetchrow($result) ) {
36
37         if ( $row['comment_user'] == ANONYMOUS ) {
38             $show_comment_user = false;
39         }
40         else {
41             if ( $type <> TYPE_NEWS && ( $owner == $row['comment_user'] && $row['privacy'] == PRIVACY_LEVEL_HIGH ) && ( $userdata['class'] < UC_MODERATOR && $userdata['uid'] != $row['comment_user'] ) ) {
42                 $show_comment_user = false;
43             }
44             else {
45                 $show_comment_user = true;
46             }
47         }
48
49         if ( $row['comment_user'] != ANONYMOUS && $row['comment_user'] != $userdata['uid'] && $userdata['session_logged_in'] ) {
50             $u_respect = append_sid('simpaty.php?action=add&amp;simpaty=1&amp;targetid=' . $row['comment_user'] . '&amp;type=1&amp;simpid=' . $row['comment_id']);
51             $u_antirespect = append_sid('simpaty.php?action=add&amp;simpaty=0&amp;targetid=' . $row['comment_user'] . '&amp;type=1&amp;simpid=' . $row['comment_id']);
52         }
53         else {
54             $u_respect = '';
55             $u_antirespect = '';
56         }
57
58         if ( $show_comment_user ) {
59             if ( ( $row['class'] == UC_VIP || $row['privacy'] <> PRIVACY_LEVEL_LOW ) && ( $userdata['class'] < UC_MODERATOR && $userdata['uid'] != $row['comment_user'] ) ) {
60                 $ratio = '---';
61                 $uploaded = '---';
62                 $downloaded = '---';
63                 $ratio_color = '';
64             }
65             else {
66                 $ratio = get_ratio($row['uploaded'], $row['downloaded']);
67                 $ratio_color = get_ratio_color($ratio);
68                 $uploaded = mksize($row['uploaded']);
69                 $downloaded = mksize($row['downloaded']);
70             }
71
72             $username = $row['name'];
73
74             if ( $row['gender'] ) {
75                 $gender_img = $images['female'];
76                 $gender_text = $lang['gender_female'];
77             }
78             else {
79                 $gender_img = $images['male'];
80                 $gender_text = $lang['gender_male'];
81             }
82
83             if ( $userdata['session_logged_in'] && $row['comment_user'] != $userdata['uid'] ) {
84                 $u_report = append_sid('reports.php?action=send_report&amp;type=comment&amp;id=' . $row['comment_id']);
85             }
86             else {
87                 $u_report = '';
88             }
89
90             $avatar = get_user_avatar($row['uid'], $row['avatar']);
91
92             $age = get_age($row['birthday']);
93
94             $user_online = ( $row['user_session_time'] > ( time() - $config['online_time'] ) ? sprintf($lang['user_online'], $username) : sprintf($lang['user_offline'], $username) );
95
96             if ( $row['user_sig'] && $config['allow_sig'] ) {
97                    //now we delete imgs if config allow_sig == 2
98                 $user_sig = ( $config['allow_sig'] == 2 ) ? preg_replace('#((\r)+?(\n)+?)*(\[url?(.*)\])?\[img.*?\]((ht|f)tp://)([^\r\n\t<\"]*?)\[/img.*?\](\[/url\])?#i', '', $row['user_sig']) : $row['user_sig'];
99                     //and now we format sig
100                 $bb_code->parse($user_sig);
101                 $user_sig = $bb_code->get_html();
102                 $user_sig = censor_text($user_sig);
103                     //last preparation :)
104                 $user_sig = ( $user_sig != '' ? '<br />_________________<br />' . $user_sig : '' );
105             }
106             else {
107                 $user_sig = '';
108             }
109
110             $title = ( $row['title'] ? $row['title'] . '<br />' : '' );
111             $title .= ( isset($ranks[$row['user_rank_id']]['rank_name']) ? $ranks[$row['user_rank_id']]['rank_name'] : '' );
112         }
113         else {
114               $row['comment_user'] = $row['uid'] = ANONYMOUS;
115             $ratio = '';
116             $ratio_color = '';
117             $uploaded = '';
118             $downloaded = '';
119             $title = '';
120             $avatar = $images['default_avatar'];
121             $gender_img = '';
122             $gender_text = '';
123             $age = '';
124             $u_report = '';
125             $user_online = '';
126             $user_sig = '';
127         }
128
129         $bb_code->parse($row['comment_text']);
130         $text = $bb_code->get_html();
131         $text = censor_text($text);
132
133         $post_time = create_date($row['comment_added']);
134
135         if ( $row['comment_editedby'] ) {
136             if ( $row['edited_by_username'] ) {
137                 // www.phpBB-SEO.com SEO TOOLKIT START
138                 $seo->set_user_url($row['edited_by_username'], $row['comment_editedby']);
139                 // www.phpBB-SEO.com SEO TOOLKIT END
140
141                 $u_edited_by = append_sid($root_path . 'userdetails.php?id=' . $row['comment_editedby']);
142                 $edited_by_username = $row['edited_by_username'];
143             }
144             else {
145                 $u_edited_by = '';
146                 $edited_by_username = $lang['unknown'];
147             }
148
149             $edited_by = sprintf($lang['edited_by'], $edited_by_username, create_date($row['comment_editedat']));
150         }
151         else {
152             $u_edited_by = '';
153             $edited_by_username = '';
154             $edited_by = '';
155         }
156
157         if ( ( $row['comment_user'] == $userdata['uid'] && $row['comment_user'] <> ANONYMOUS ) || $userdata['class'] >= UC_MODERATOR ) {
158             $u_edit = append_sid($root_path . 'comment.php?type=' . $type . '&amp;action=edit&amp;cid=' . $row['comment_id']);
159         }
160         else {
161             $u_edit = '';
162         }
163
164         if ( $userdata['class'] >= UC_MODERATOR && $row['class'] <= $userdata['class'] ) {
165             $u_delete = append_sid($root_path . 'comment.php?type=' . $type . '&amp;action=delete&amp;cid=' . $row['comment_id']);
166             $s_delete_comment = true;
167         }
168         else {
169             $u_delete = '';
170             $s_delete_comment = false;
171         }
172
173         if ( $userdata['session_logged_in']  ) {
174             $u_quote = append_sid($root_path . 'comment.php?type=' . $type . '&amp;action=quote&amp;cid=' . $row['comment_id']);
175         }
176         else {
177             $u_quote = '';
178         }
179
180         if ( $userdata['session_logged_in'] && $row['comment_added'] > $userdata['user_lastvisit'] && $row['comment_added'] > $last_read )
181         {
182             $mini_post_img = $images['icon_minipost_new'];
183             $mini_post_alt = $lang['new_post'];
184         }
185         else {
186             $mini_post_img = $images['icon_minipost'];
187             $mini_post_alt = $lang['comment'];
188         }
189
190         if ( $row['comment_reputation'] > 0 ) {
191             $current_reputation_show = '+' . $row['comment_reputation'];
192         }
193         else {
194             $current_reputation_show = $row['comment_reputation'];
195         }
196
197           $comments[] = array(
198               'U_USERDETAILS' => append_sid($root_path . 'userdetails.php?id=' . $row['comment_user']),
199                'U_COMMENT'     => append_sid($root_path . 'comment.php?cid=' . $row['comment_id']),
200                'COMM_ID' => $row['comment_id'],
201                'USER_ID' => $row['comment_user'],
202                'USERNAME' => parse_username($row),
203                'TITLE' => $title,
204                'AVATAR' => $avatar,
205                'RATIO' => htmlspecialchars('<span style="color:' . $ratio_color . ';">' . $ratio . '</span>'),
206                'POST_TIME' => $post_time,
207
208               'U_RESPECT' => $u_respect,
209                'U_ANTIRESPECT' => $u_antirespect,
210
211                'U_REPORT' => $u_report,
212
213                'U_EDIT' => $u_edit,
214                'U_DELETE' => $u_delete,
215                'U_QUOTE' => $u_quote,
216                'S_DELETE_COMMENT' => $s_delete_comment,
217
218                'TEXT' => $text,
219                'SIGNATURE' => $user_sig,
220                'EDITED_BY' => $edited_by,
221                'UPLOADED' => htmlspecialchars($uploaded),
222                'DOWNLOADED' => htmlspecialchars($downloaded),
223
224                'GENDER_IMAGE' => $gender_img,
225                'GENDER_TEXT' => htmlspecialchars($gender_text),
226                'AGE' => htmlspecialchars($age),
227                'ONLINE_USER' => $user_online,
228               'MINI_POST_IMG' => $mini_post_img,
229                'MINI_POST_ALT' => $mini_post_alt,
230
231                'SIMPATY_TYPE' => SIMPATY_COMMENT,
232                'CURRENT_REPUTATION' => $row['comment_reputation'],
233                'CURRENT_REPUTATION_SHOW' => $current_reputation_show,
234           );
235
236         $comments_ary[] = $row['comment_id'];
237
238      }
239
240      if ( sizeof($comments_ary) ) {
241         $sql = 'SELECT s.simpaty, u.name, u.uid, s.simpid
242                 FROM ' . SIMPATY_TABLE . ' s, ' . USERS_TABLE . ' u
243                 WHERE s.fromuserid = u.uid
244                 AND simpid IN (' . implode(', ', $comments_ary) . ')
245                 AND type = ' . SIMPATY_COMMENT;
246         $result = $db->sql_query($sql);
247
248         while ( $row = $db->sql_fetchrow($result) ) {
249             $simpaty_ary[$row['simpid']][] = $row;
250         }
251      }
252
253      $last_cid = 0;
254
255      foreach ( $comments AS $_null => $ary ) {
256
257          $userList_ary = ( isset($simpaty_ary[$ary['COMM_ID']]) ? $simpaty_ary[$ary['COMM_ID']] : array() );
258
259         $userslist = '';
260         foreach ( $userList_ary AS $_null => $users ) {
261             $userslist .= ( $userslist ? ', ' : '' );
262
263             // www.phpBB-SEO.com SEO TOOLKIT START
264             $seo->set_user_url($users['name'], $users['uid']);
265             // www.phpBB-SEO.com SEO TOOLKIT END
266
267             $userslist .= '<a href="' . append_sid($root_path . 'userdetails.php?id=' . $users['uid']) . '"><span class="' . ( $users['simpaty'] ? 'usergoodResp' : 'userbadResp' ) . '">' . $users['name'] . '</span></a>';
268         }
269
270         $last_cid = $ary['COMM_ID'];
271
272          $template->assign_block_vars('comments_table_row', array(
273               'U_USERDETAILS' => $ary['U_USERDETAILS'],
274                'U_COMMENT'     => $ary['U_COMMENT'],
275                'COMM_ID' => $ary['COMM_ID'],
276                'USER_ID' => $ary['USER_ID'],
277                'USERNAME' => $ary['USERNAME'],
278                'TITLE' => $ary['TITLE'],
279                'AVATAR' => $ary['AVATAR'],
280                'RATIO' => $ary['RATIO'],
281                'POST_TIME' => $ary['POST_TIME'],
282
283               'U_RESPECT' => $ary['U_RESPECT'],
284                'U_ANTIRESPECT' => $ary['U_ANTIRESPECT'],
285
286                'U_REPORT' => $ary['U_REPORT'],
287
288                'U_EDIT' => $ary['U_EDIT'],
289                'U_DELETE' => $ary['U_DELETE'],
290                'U_QUOTE' => $ary['U_QUOTE'],
291                'S_DELETE_COMMENT' => $ary['S_DELETE_COMMENT'],
292
293                'TEXT' => $ary['TEXT'],
294                'SIGNATURE' => $ary['SIGNATURE'],
295                'EDITED_BY' => $ary['EDITED_BY'],
296                'UPLOADED' => $ary['UPLOADED'],
297                'DOWNLOADED' => $ary['DOWNLOADED'],
298
299                'GENDER_IMAGE' => $ary['GENDER_IMAGE'],
300                'GENDER_TEXT' => $ary['GENDER_TEXT'],
301                'AGE' => $ary['AGE'],
302                'ONLINE_USER' => $ary['ONLINE_USER'],
303               'MINI_POST_IMG' => $ary['MINI_POST_IMG'],
304                'MINI_POST_ALT' => $ary['MINI_POST_ALT'],
305
306                'SIMPATY_TYPE' => $ary['SIMPATY_TYPE'],
307                'CURRENT_REPUTATION' => $ary['CURRENT_REPUTATION'],
308                'CURRENT_REPUTATION_SHOW' => $ary['CURRENT_REPUTATION_SHOW'],
309
310                'USERLIST' => $userslist
311          ));
312      }
313
314      $comment_options_ary = array('mass_delete' => $lang['delete']);
315      $comment_options = '<option value="0">' . $lang['choose'] . '</option>';
316      foreach ( $comment_options_ary AS $action => $lang_var ) {
317          $comment_options .= '<option value="' . $action . '">' . $lang_var . '</option>';
318      }
319
320      $template->assign_vars(array(
321          'COMMENT_OPTIONS' => $comment_options,
322          'S_C_FORM_ACTION' => append_sid($root_path . 'comment.php'),
323          'C_TYPE' => $type,
324          'C_ID' => $id,
325          'LAST_CID' => $last_cid
326      ));
327
328     return;
329 }
330
331 function preview_commentable ( $type = TYPE_TORRENT, $id, $owner ) {
332     global $userdata, $lang, $template, $config, $images, $db, $cache, $root_path;
333     global $bb_code;
334     global $seo;
335     static $ranks;
336
337     if ( !isset($ranks) ) {
338         $ranks = $cache->obtain_ranks();
339     }
340     if ( !isset($bb_code) ) {
341         $bb_code = new bbcode();
342     }
343
344     $sql = 'SELECT c.comment_id, c.comment_text, c.comment_added, c.comment_editedby, c.comment_editedat, c.comment_reputation, u.uid, u.avatar, u.warneduntil, u.parked, u.name, u.title, u.class, u.donor, u.downloaded, u.uploaded, u.enabled, u2.name AS edited_by_username, u.birthday, u.gender, u.user_session_time, u.user_sig, u.privacy, u.user_reputation_level, u.user_rank_id, u.name_append, u.user_reputation
345             FROM ' . COMMENTS_TABLE . ' c
346             LEFT JOIN ' . USERS_TABLE . ' u2 ON c.comment_editedby = u2.uid,
347             ' . USERS_TABLE . ' u
348             WHERE c.comment_for_id = ' . $id . ' AND c.comment_type = ' . $type . '
349             AND c.comment_user = u.uid
350             ORDER BY c.comment_id DESC LIMIT 5';
351     $result = $db->sql_query($sql);
352
353     $last_read = get_tracking($type, $id);
354
355     if ( $row = $db->sql_fetchrow($result) ) {
356         do {
357
358             if ( $row['uid'] == ANONYMOUS ) {
359                 $show_comment_user == false;
360             }
361             else {
362                 if ( $type <> TYPE_NEWS && ( $owner == $row['uid'] && $row['privacy'] == PRIVACY_LEVEL_HIGH ) && ( $userdata['class'] < UC_MODERATOR && $userdata['uid'] != $row['uid'] ) ) {
363                     $show_comment_user = false;
364                 }
365                 else {
366                     $show_comment_user = true;
367                 }
368             }
369
370             if ( $show_comment_user ) {
371                 if ( ( $row['class'] == UC_VIP || $row['privacy'] <> PRIVACY_LEVEL_LOW ) && ( $userdata['class'] < UC_MODERATOR && $userdata['uid'] != $row['uid'] ) ) {
372                     $ratio = '---';
373                      $uploaded = '---';
374                     $downloaded = '---';
375                     $ratio_color = '';
376                 }
377                 else {
378                        $ratio = get_ratio($row['uploaded'], $row['downloaded']);
379                         $ratio_color = get_ratio_color($ratio);
380                         $uploaded = mksize($row['uploaded']);
381                         $downloaded = mksize($row['downloaded']);
382                    }
383                 $username = $row['name'];
384                 $avatar = get_user_avatar($row['uid'], $row['avatar']);
385                 $user_sig = ( isset($row['user_sig']) && $row['user_sig'] != '' && $config['allow_sig'] ) ? $row['user_sig'] : '';
386                 if ( $user_sig ) {
387                     //now we delete imgs if config allow_sig == 2
388                     $user_sig = ( $config['allow_sig'] == 2 ) ? preg_replace('#((\r)+?(\n)+?)*(\[url(.*)\])?\[img.*?\]((ht|f)tp://)([^\r\n\t<\"]*?)\[/img.*?](\[/url\])?#i', '', $user_sig) : $user_sig;
389                     // Replace naughty words
390                     $user_sig = censor_text($user_sig);
391                     //and now we format sig
392                         $bb_code->parse($user_sig);
393                         $user_sig = $bb_code->get_html();
394                     //last preparation :)
395                     $user_sig = ( $user_sig != '' ? '<br />_________________<br />' . $user_sig : '' );
396                 }
397
398                    if ( $row['gender'] ) {
399                     $gender_img = $images['female'];
400                     $gender_text = $lang['gender_female'];
401                 }
402                 else {
403                     $gender_img = $images['male'];
404                     $gender_text = $lang['gender_male'];
405                 }
406
407                 $age = get_age($row['birthday']);
408
409                   $title = ( $row['title'] ? $row['title'] . '<br />' : '' );
410                     $title .= ( isset($ranks[$row['user_rank_id']]['rank_name']) ?  $ranks[$row['user_rank_id']]['rank_name'] : '' );
411             }
412             else {
413                 $username = '<i>' . $lang['unknown'] . '</i>';
414                 $row['comment_user'] = $row['uid'] = ANONYMOUS;
415                 //$title = '';
416                 $avatar = $images['default_avatar'];
417                 $user_sig = '';
418                 $title = '';
419                    $ratio = '';
420                    $ratio_color = '';
421                    $uploaded = '';
422                    $downloaded = '';
423                    $gender_text = '';
424                    $gender_img = '';
425                    $age = '';
426             }
427
428             $text = censor_text($row['comment_text']);
429               $bb_code->parse($text);
430               $text = $bb_code->get_html();
431
432             // www.phpBB-SEO.com SEO TOOLKIT START
433             $seo->set_user_url($row['edited_by_username'], $row['comment_editedby']);
434             $seo->set_user_url($username, $row['uid']);
435             // www.phpBB-SEO.com SEO TOOLKIT END
436
437             $edited_by_link = ( $row['edited_by_username'] ? '<a href="' . append_sid($root_path . 'userdetails.php?id=' . $row['comment_editedby']) . '"><b>' . $row['edited_by_username'] . '</b></a>' : '<i>' . $lang['unknown'] . '</i>');
438             $edited_by = ( $row['comment_editedby'] ? sprintf($lang['edited_by'], $edited_by_link, create_date($row['comment_editedat'])):'');
439             $post_time = create_date($row['comment_added']);
440
441             if ( $userdata['session_logged_in'] && $row['comment_added'] > $userdata['user_lastvisit'] && $row['comment_added'] > $last_read )
442             {
443                 $mini_post_img = $images['icon_minipost_new'];
444                 $mini_post_alt = $lang['new_post'];
445             }
446             else
447             {
448                 $mini_post_img = $images['icon_minipost'];
449                 $mini_post_alt = $lang['comment'];
450             }
451
452                 if ( $row['comment_reputation'] > 0 ) {
453                     $current_reputation_show = '+' . $row['comment_reputation'];
454                 }
455                 else {
456                     $current_reputation_show = $row['comment_reputation'];
457                 }
458
459             $template->assign_block_vars('comments_table_row', array(
460                 'U_USERDETAILS' => append_sid($root_path . 'userdetails.php?id=' . $row['uid']),
461                 'U_COMMENT'     => append_sid($root_path . 'comment.php?cid=' . $row['comment_id']),
462                 'COMM_ID' => $row['comment_id'],
463                 'USER_ID' => $row['uid'],
464                 'USERNAME' => parse_username($row),
465                 'TITLE' => $title,
466                 'AVATAR' => $avatar,
467                 'POST_TIME' => $post_time,
468                 'TEXT' => $text,
469                 'SIGNATURE' => $user_sig,
470                 'EDITED_BY' => $edited_by,
471                 'MINI_POST_IMG' => $mini_post_img,
472                 'MINI_POST_ALT' => $mini_post_alt,
473                 'USER_REPUTATION_LEVEL' => $row['user_reputation_level'],
474
475                    'UPLOADED' => htmlspecialchars($uploaded),
476                    'DOWNLOADED' => htmlspecialchars($downloaded),
477
478                    'GENDER_IMAGE' => $gender_img,
479                    'GENDER_TEXT' => htmlspecialchars($gender_text),
480                    'AGE' => htmlspecialchars($age),
481                    'RATIO' => htmlspecialchars('<span style="color:' . $ratio_color . ';">' . $ratio . '</span>'),
482
483                  'SIMPATY_TYPE' => SIMPATY_COMMENT,
484                    'CURRENT_REPUTATION' => $row['comment_reputation'],
485                    'CURRENT_REPUTATION_SHOW' => $current_reputation_show,
486             ));
487
488         }
489         while ( $row = $db->sql_fetchrow($result) );
490
491         $template->set_filenames(array(
492             'preview_commentable' => 'preview_commentable.html'
493         ));
494     }
495
496     return;
497 }
498
499
500 function textbbcode( $content = '' ) {
501     global $lang, $template, $userdata, $db, $config, $root_path;
502
503     $template->set_filenames(array(
504         'textbbcode_tpl' => 'textbbcode.html'
505     ));
506
507     $template->assign_vars(array(
508         'EDITOR_NAME' => $userdata['name'],
509         'CONTENT' => $content,
510         'U_TAGS' => append_sid($root_path . 'faq.php?mode=tags')
511     ));
512
513     generate_smilies('inline');
514
515     if ( $userdata['class'] >= UC_MODERATOR ) {
516         $template->assign_block_vars('switch_mod_section', array());
517     }
518
519     $tpl = $template->assign_display('textbbcode_tpl');
520
521     return $tpl;
522 }
523
524 function generate_smilies($mode, $form_name = 'post', $textarea_name = 'message' )
525 {
526     global $db, $config, $template, $lang, $images, $theme, $cache, $root_path;
527     global $user_ip, $session_length, $starttime;
528     global $userdata;
529
530     $inline_columns = 4;
531     $inline_rows = 5;
532     $window_columns = 3;
533
534     if ($mode == 'window')
535     {
536         $userdata = session_pagestart($user_ip);
537         init_userprefs($userdata);
538     }
539
540     $smilies = $cache->obtain_smilies();
541
542     $num_smilies = sizeof($smilies);
543
544     if ( $num_smilies )
545     {
546         $smilies_count = ($mode == 'inline') ? min(19, $num_smilies) : $num_smilies;
547         $smilies_split_row = ($mode == 'inline') ? $inline_columns - 1 : $window_columns - 1;
548
549         $s_colspan = 0;
550         $row = 0;
551         $col = 0;
552
553         foreach ( $smilies AS $smile_id => $smile_ary ) {
554             if (!$col)
555             {
556                 $template->assign_block_vars('smilies_row', array());
557             }
558
559             $template->assign_block_vars('smilies_row.smilies_col', array(
560                 'SMILEY_CODE' => str_replace("'", "\'", $smile_ary['code']),
561                 'SMILEY_IMG' => $root_path . $config['smilies_path'] . '/' . $smile_ary['smile_url'],
562                 'SMILEY_DESC' => $smile_ary['emoticon']
563             ));
564
565             $s_colspan = max($s_colspan, $col + 1);
566
567             if ($col == $smilies_split_row)
568             {
569                 if ($mode == 'inline' && $row == $inline_rows - 1)
570                 {
571                     break;
572                 }
573                 $col = 0;
574                 $row++;
575             }
576             else
577             {
578                 $col++;
579             }
580         }
581
582         if ($mode == 'inline' && $num_smilies > $inline_rows * $inline_columns)
583         {
584             $template->assign_block_vars('switch_smilies_extra', array());
585
586             $template->assign_vars(array(
587                 'U_MORE_SMILIES' => append_sid($root_path . 'comment.php?action=smiles&amp;form=post&amp;text=message')
588             ));
589         }
590
591         $template->assign_vars(array(
592             'S_SMILIES_COLSPAN' => $s_colspan
593         ));
594     }
595
596     $template->assign_vars(array(
597         'FORM_NAME' => $form_name,
598         'TEXTAREA_NAME' => $textarea_name,
599     ));
600
601     if ($mode == 'window')
602     {
603         stdhead();
604         $template->set_filenames(array(
605             'body' => 'posting_smilies.html'
606         ));
607         stdfoot();
608         return;
609     }
610 }
611 ?>
Note: See TracBrowser for help on using the browser.