Changeset 331

Show
Ignore:
Timestamp:
12/28/10 12:24:38 (1 year ago)
Author:
Nafania
Message:

фича - похожие торренты

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • details.php

    r324 r331  
    421421                )); 
    422422 
     423                // www.phpBB-SEO.com SEO TOOLKIT BEGIN 
     424                $seo->set_torrent_url($id, $row['name'], $row['category']); 
     425                $seo->set_user_url($row['username'], $row['owner']); 
     426                // www.phpBB-SEO.com SEO TOOLKIT END 
     427 
    423428                if ( isset($cats[$cats[$row['category']]['cat_parent']]['cat_name']) ) { 
    424429                        $cat_parent = $cats[$cats[$row['category']]['cat_parent']]; 
    425  
    426                         // www.phpBB-SEO.com SEO TOOLKIT BEGIN 
    427                         $seo->set_url($cat_parent['cat_name'], $cat_parent['cat_id'], $seo->seo_static['browse']); 
    428                         $seo->set_parent($cats[$row['category']]['cat_id'], $seo->seo_static['browse'], $cat_parent['cat_id'], $seo->seo_static['browse']); 
    429                         // www.phpBB-SEO.com SEO TOOLKIT END 
    430  
    431430                        $cat_parent_name = '<a href="' . append_sid($root_path . 'browse.php?cat=' . $cat_parent['cat_id']) . '">' . $cat_parent['cat_name'] . '</a> -> '; 
    432431                } 
     
    434433                        $cat_parent_name = ''; 
    435434                } 
    436  
    437                 // www.phpBB-SEO.com SEO TOOLKIT BEGIN 
    438                 $seo->set_url($cats[$row['category']]['cat_name'], $cats[$row['category']]['cat_id'], $seo->seo_static['browse']); 
    439                 $seo->set_parent($id, $seo->seo_static['details'], $cats[$row['category']]['cat_id'], $seo->seo_static['browse']); 
    440                 $seo->set_url($torrent_name, $id, $seo->seo_static['details']); 
    441                 $seo->set_user_url($row['username'], $row['owner']); 
    442                 // www.phpBB-SEO.com SEO TOOLKIT END 
    443435 
    444436                if ( $view <> 'comments' ) { 
     
    535527                                'RATING_VOTED' => $rating_voted, 
    536528 
     529                                'SHOW_SOS_BUTTON' => ( $userdata['session_logged_in'] && ( $row['completed'] && $row['seeders'] < $config['min_seeders_for_sos_button'] ) && ( $row['seeders'] < $row['completed'] + 1 ) ? 1 : 0 ), 
     530 
     531                                'BOOKMARKS_TITLE' => sprintf($lang['torrent_details'], $torrent_name), 
     532 
    537533                        )); 
    538534 
     
    551547                        if ( $userdata['uid'] == $row['owner'] || $userdata['class'] >= UC_MODERATOR ) { 
    552548                                $template->assign_block_vars( 'switch_owner_section', array() ); 
    553                         } 
    554  
    555                         if ( $userdata['session_logged_in'] && ( $row['completed'] && $row['seeders'] < $config['min_seeders_for_sos_button'] ) && ( $row['seeders'] < $row['completed'] + 1 ) ) { 
    556                                 $sql = 'SELECT COUNT(*) AS peers_count 
    557                                                 FROM ' . PEERS_TABLE . ' p 
    558                                                 WHERE p.`left` > 0 AND p.fid = ' . $id . ' AND p.uid = ' . $userdata['uid'] . ( defined( 'USE_XBTT' ) ? ' AND p.active = 1' : '' ); 
    559                                 $result = $db->sql_query( $sql ); 
    560                                 $peer_count = ( $sos_row = $db->sql_fetchrow( $result ) ) ? intval( $sos_row['peers_count'] ) : 0; 
    561                                 if ( $peer_count ) { 
    562                                         $template->assign_block_vars( 'switch_sos_section', array() ); 
    563                                 } 
    564549                        } 
    565550 
     
    584569                        /* end tags */ 
    585570 
     571                        /* start similiar torrents */ 
     572                        require ($root_path . 'include/functions_search.php'); 
     573 
     574                        $sim_name = $row['name']; 
     575                        //delimeters which used to determine base name, first have highest order 
     576                        $delims = array('/', '-'); 
     577 
     578                        for ( $i = 0; $i < sizeof($delims); ++$i ) { 
     579                                if ( $pos = strpos($sim_name, $delims[$i]) ) { 
     580                                        $sim_name = substr($sim_name, 0, $pos); 
     581                                        $sim_name = trim($sim_name); 
     582 
     583                                        //we found small name, try another part 
     584                                        if ( utf_strlen($sim_name) <= $config['search_min_chars'] ) { 
     585                                                $sim_name = substr($row['name'], $pos + 1); 
     586                                                //reset loop 
     587                                                $i = -1; 
     588                                                continue; 
     589                                        } 
     590                                        break; 
     591                                } 
     592                        } 
     593 
     594                        //delete all double words 
     595                        $sim_name = implode(' ', array_unique(explode(' ', $sim_name))); 
     596                        //delete all in () and in [] 
     597                        $sim_name = preg_replace('/(\[|\()(.*?)(\]|\))/si', '', $sim_name); 
     598                        //delete year (four digits) 
     599                        $sim_name = preg_replace('/[0-9]{4}/si', '', $sim_name); 
     600                        //some clean 
     601                        $sim_name = searchfield($sim_name); 
     602                        //delete all small worlds 
     603                        $sim_name = preg_replace('/(^|[\s])[\S]{1,3}(?=[\s]|$)/iu', '', $sim_name); 
     604                        //delete double spaces 
     605                        $sim_name = str_replace('  ', ' ', $sim_name); 
     606                        //trim and lower case 
     607                        $sim_name = trim(utf_strtolower($sim_name)); 
     608 
     609                        $size_sim = 0; 
     610 
     611                        $show_similiar_torrents = false; 
     612 
     613                        if ( utf_strlen($sim_name) >= $config['search_min_chars'] ) { 
     614 
     615                                $sql = 'SELECT fid, name, category, seeders, leechers, free, size 
     616                                                FROM ' . TORRENTS_TABLE . ' 
     617                                                WHERE moderated = 1 
     618                                                AND name LIKE \'%' . str_replace(' ', '%', $sim_name)  . '%\' 
     619                                                AND fid <> ' . $id . ' 
     620                                                ORDER BY category = ' . (int) $row['category'] . ' DESC, ctime DESC'; 
     621                                $result = $db->sql_query_limit($sql, 50); 
     622                                if ( $subrow = $db->sql_fetchrow($result) ) { 
     623 
     624                                        require ($root_path . 'include/functions_torrenttable.php'); 
     625 
     626                                        $show_similiar_torrents = true; 
     627 
     628                                        do { 
     629                                                $cat_id = $subrow['category']; 
     630                                                $cat_parent_id = ( isset($cats[$cats[$cat_id]['cat_parent']]['cat_id']) ? $cats[$cats[$cat_id]['cat_parent']]['cat_id'] : 0 ); 
     631 
     632                                                if ( !$cats[$cat_id]['anonymous_view'] && !$userdata['session_logged_in'] ) { 
     633                                                        continue; 
     634                                                } 
     635                                                $sim_fid = $subrow['fid']; 
     636                                                $dispname = $subrow['name']; 
     637                                                $dispname = censor_text($dispname); 
     638 
     639                                                if ( $subrow['seeders'] ) { 
     640                                                        $ratio = ( $subrow['leechers'] ? $subrow['seeders'] / $subrow['leechers'] : 1 ); 
     641                                                        $slr_color = get_slr_color($ratio); 
     642                                                } 
     643                                                else { 
     644                                                        $slr_color = 'FF0000'; 
     645                                                } 
     646 
     647                                                $seo->set_torrent_url($sim_fid, $subrow['name'], $cat_id); 
     648 
     649                                                $cat_parent_name = ''; 
     650                                                if ( $cat_parent_id ) { 
     651                                                        $cat_parent_name = '<a href="' . append_sid($root_path . 'browse.php?cat=' . $cat_parent_id) . '">' . $cats[$cat_parent_id]['cat_name'] . '</a> -> '; 
     652                                                } 
     653                                                $cat_name_display = $cat_parent_name . '<a href="' . append_sid($root_path . 'browse.php?cat=' . $cat_id) . '">' . $cats[$cat_id]['cat_name'] . '</a>'; 
     654 
     655                                                $template->assign_block_vars('similiar_torrents', array( 
     656                                                        'U_CATEGORY' => append_sid($root_path . 'browse.php?cat=' . $cat_id), 
     657                                                        'U_DETAILS'  => append_sid($root_path . 'details.php?id=' . $sim_fid), 
     658                                                        'U_DOWNLOAD' => append_sid($root_path . 'details.php?id=' . $sim_fid . '&amp;action=download'), 
     659                                                        'U_PEERLIST' => append_sid($root_path . 'details.php?id=' . $sim_fid . '&amp;view=peerlist'), 
     660                                                        'U_ADD_BOOKMARK' => append_sid($root_path . 'bookmarks.php?torrent=' . $sim_fid), 
     661                                                        'DISPNAME' => $dispname, 
     662                                                        'TORRENT_FREE_ICON' => get_free_icon($subrow['free']), 
     663                                                        'TORRENT_SEEDERS' => $subrow['seeders'], 
     664                                                        'TORRENT_LEECHERS' => $subrow['leechers'], 
     665                                                        'SLR_COLOR' => $slr_color, 
     666                                                        'CAT_PIC' => $cats[$cat_id]['cat_pic'], 
     667                                                        'CAT_NAME' => $cats[$cat_id]['cat_name'], 
     668                                                        'CAT_NAME_DISPLAY' => $cat_name_display, 
     669                                                        'SIZE' => mksize($subrow['size']), 
     670                                                )); 
     671 
     672                                                $size_sim++; 
     673 
     674                                        } 
     675                                        while ( $subrow = $db->sql_fetchrow($result) ); 
     676                                } 
     677                        } 
     678                        /* end similiar torrents */ 
    586679 
    587680                        $include_header = false; 
     
    598691 
    599692                        $include_header = true; 
     693                        $show_similiar_torrents = false; 
     694                        $size_sim = 0; 
    600695 
    601696                        $body = 'details_comments.html'; 
     
    649744 
    650745                        'PAGERBOTTOM' => $pagerbottom, 
     746 
     747                        'SHOW_SIMILIAR_TORRENTS' => $show_similiar_torrents, 
     748                        'SIZE_SIM' => ( $size_sim < 5 ? $size_sim * $config['similiar_torrents_height'] : 5 * $config['similiar_torrents_height'] ), 
    651749                )); 
    652750        } 
  • include/class.cleanup.php

    r238 r331  
    1919                // make sure cleanup doesn't run multiple times in parallel 
    2020                if ( $config['cleanup_lock'] ) { 
    21                         // if the other process is running more than an hour already we have to assume it 
     21                        // if the other process is running more than an half-hour already we have to assume it 
    2222                        // aborted without cleaning the lock 
    2323                        $time = explode(' ', $config['cleanup_lock']); 
    2424                        $time = $time[0]; 
    2525 
    26                         if ( $time + 3600 >= time() ) { 
     26                        if ( $time + 1800 >= time() ) { 
    2727                                return; 
    2828                        } 
  • include/details/download.php

    r324 r331  
    1818$seo->set_torrent_url($id, $row['name'], $row['category']); 
    1919// www.phpBB-SEO.com SEO TOOLKIT END 
    20 $ref = ( !empty($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '' ); 
    21 if ( strpos($ref, generate_base_url()) === false ) { 
    22         redirect(append_sid($root_path . 'details.php?id=' . $id)); 
    23 
     20 
     21//$ref = ( !empty($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '' ); 
     22//if ( strpos($ref, generate_base_url()) === false ) { 
     23//      redirect(append_sid($root_path . 'details.php?id=' . $id)); 
     24//} 
    2425 
    2526if ( $row['hidden'] && ( !$userdata['hiddentorrents'] && $userdata['class'] < UC_MODERATOR ) ) { 
  • include/functions.php

    r324 r331  
    369369                        $pics .= '<img src="' . $images['warned'] . '" alt="' . $lang['warned'] . '" />'; 
    370370                } 
    371                 elseif ( !empty($data['enabled']) && !$data['enabled'] ) { 
    372                         $pics .= '<img src="' . $images['disabled'] . '" alt="' . $lang['disabled'] . '" />'; 
     371                if ( isset($data['enabled']) && !$data['enabled'] ) { 
     372                        $pics = '<img src="' . $images['disabled'] . '" alt="' . $lang['disabled'] . '" />'; 
    373373                } 
    374374 
     
    12411241} 
    12421242 
    1243 function send_pm ( $pm_ary ) { 
     1243function send_pm ( $pm_ary, $force_send = false ) { 
    12441244        global $config, $db, $root_path, $lang, $seo; 
    12451245 
     
    12741274 
    12751275 
    1276                 if ( strpos($ary['notifs'], '[pm]') !== false ) { 
     1276                if ( strpos($ary['notifs'], '[pm]') !== false || $force_send ) { 
    12771277                        $receiver_ary[$ary['receiver']] = array( 
    12781278                                'language' => $ary['language'], 
     
    13171317                } 
    13181318 
    1319                 $messenger->replyto($ary['email']); 
    13201319                $messenger->to($ary['email'], $ary['name']); 
    13211320 
  • include/functions_messenger.php

    r324 r331  
    761761        function save() 
    762762        { 
     763                global $root_path; 
     764 
    763765                if (!sizeof($this->data)) 
    764766                { 
  • include/functions_post.php

    r324 r331  
    4747                } 
    4848 
     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 
    4958                if ( $show_comment_user ) { 
    5059                        if ( ( $row['class'] == UC_VIP || $row['privacy'] <> PRIVACY_LEVEL_LOW ) && ( $userdata['class'] < UC_MODERATOR && $userdata['uid'] != $row['comment_user'] ) ) { 
     
    6271 
    6372                        $username = $row['name']; 
    64  
    65                         if ( $row['comment_user'] != $userdata['uid'] && $userdata['session_logged_in'] ) { 
    66                                 $u_respect = append_sid('simpaty.php?action=add&amp;simpaty=1&amp;targetid=' . $row['comment_user'] . '&amp;type=1&amp;simpid=' . $row['comment_id']); 
    67                                 $u_antirespect = append_sid('simpaty.php?action=add&amp;simpaty=0&amp;targetid=' . $row['comment_user'] . '&amp;type=1&amp;simpid=' . $row['comment_id']); 
    68                         } 
    69                         else { 
    70                                 $u_respect = ''; 
    71                                 $u_antirespect = ''; 
    72                         } 
    7373 
    7474                        if ( $row['gender'] ) { 
     
    112112                } 
    113113                else { 
    114                         $username = '<i>' . $lang['unknown'] . '</i>'; 
    115114                $row['comment_user'] = $row['uid'] = ANONYMOUS; 
    116115                        $ratio = ''; 
     
    119118                        $downloaded = ''; 
    120119                        $title = ''; 
    121                         $u_respect = ''; 
    122                         $u_antirespect = ''; 
    123120                        $avatar = $images['default_avatar']; 
    124121                        $gender_img = ''; 
  • include/functions_search.php

    r324 r331  
    100100                                        $match_word = str_replace('*', '%', $split_search[$i]); 
    101101                                        $search = $where_search . ' LIKE \'%' . $db->sql_escape($match_word) . '%\'' . $add_where; 
     102                                        //$search = $where_search . ' REGEXP \'[[:<:]]' . $db->sql_escape($match_word) . '[[:>:]]\'' . $add_where; 
    102103                                } 
    103104 
  • include/modtask/edituser.php

    r321 r331  
    361361                                4 =>  sprintf($lang['warn_week'], 4), 
    362362                                8 =>  sprintf($lang['warn_week'], 8), 
    363                                 100 =>  $lang['for_ever'], 
     363                                //100 =>  $lang['for_ever'], 
    364364                        ); 
    365365 
  • js/ajax_common.js

    r324 r331  
    100100 
    101101        if ( message.length < 2 ) { 
    102                         alert(l_post_something); 
     102                        alert(L_JS_POST_SOMETHING); 
    103103                        return; 
    104104        } 
  • languages/lang_english/lang_main.php

    r324 r331  
    13151315                'replies' =>  'Replies', 
    13161316 
     1317                'links_to_this_torrent' => 'Ссылки на этот торрент', 
     1318                'bbcode' => 'BBCode', 
     1319                'html' => 'HTML', 
     1320                'direct_link' => 'Direct link', 
     1321                'to_bookmarks' => 'Bookmarks', 
     1322 
    13171323        'translated_by' => 'Translation to english made by %s', 
    13181324)); 
  • languages/lang_russian/lang_main.php

    r324 r331  
    721721        'userdetails' => 'Детали пользователя %s', 
    722722        'pending_user' => 'Этот пользователь еще не подтвердил свой аккаунт', 
    723         'remove_from_friends_list' => 'убрать из списка друзей', 
     723        'remove_from_friends_list' => 'убрать из друзей', 
    724724        'remove_from_blocks_list' => 'убрать из списка врагов', 
    725         'add_to_friends_list' => 'добавить в список друзей', 
     725        'add_to_friends_list' => 'добавить в друзья', 
    726726        'add_to_blocks_list' => 'добавить в список врагов', 
    727727        'register_date' => 'Дата регистрации', 
     
    13341334                'replies' =>  'Ответов', 
    13351335 
     1336                'links_to_this_torrent' => 'Ссылки на этот торрент', 
     1337                'bbcode' => 'BBCode', 
     1338                'html' => 'HTML', 
     1339                'direct_link' => 'Прямая', 
     1340                'to_bookmarks' => 'Закладки', 
     1341 
    13361342        'translated_by' => 'На русский язык перевел %s', 
    13371343)); 
  • message.php

    r317 r331  
    2626 
    2727        //here we take first message of messages history 
    28         $sql = 'SELECT p.id, p.receiver, p.added, p.msg, p.subject, u.name, u.uid 
     28        $sql = 'SELECT p.id, p.receiver, p.added, p.msg, p.subject, u.name, u.uid, u.class 
    2929                        FROM ' . PRIVATE_MESSAGES_TABLE . ' p, ' . USERS_TABLE . ' u 
    3030                        WHERE p.id = ' . $message_id . ' AND u.uid = p.sender'; 
     
    3737        } 
    3838 
    39         $sql = 'SELECT p.id, p.receiver, p.added, p.msg, p.subject, u.name, u.uid 
     39        $sql = 'SELECT p.id, p.receiver, p.added, p.msg, p.subject, u.name, u.uid, u.class 
    4040                        FROM ' . PRIVATE_MESSAGES_TABLE . ' p, ' . USERS_TABLE . ' u 
    4141                        WHERE p.reply_to = ' . $message_id . ' AND u.uid = p.sender ORDER BY p.added ASC'; 
     
    5252        krsort($reply_msg); 
    5353 
     54        if ( !sizeof($reply_msg) ) { 
     55                return false; 
     56        } 
     57 
    5458        return array ( $reply_msg, $subject, $origmsg ); 
    5559} 
     
    6367 
    6468                $pm_id = request_var('id', 0); 
    65              if ( !$pm_id ) { 
     69               if ( !$pm_id ) { 
    6670                        trigger_error( sprintf($lang['invalid_id'], $id) ); 
    67              } 
    68  
    69                 $sql = 'SELECT p.*, u.name FROM ' . PRIVATE_MESSAGES_TABLE . ' p, ' . USERS_TABLE . ' u 
     71                } 
     72 
     73                $sql = 'SELECT p.*, u.name, u.uid, u.class 
     74                                FROM ' . PRIVATE_MESSAGES_TABLE . ' p, ' . USERS_TABLE . ' u 
    7075                                WHERE p.id = ' . $pm_id . ' AND p.receiver = ' . $userdata['uid'] . ' AND p.sender = u.uid'; 
    71              $result = $db->sql_query($sql); 
    72  
    73              if ( !$message = $db->sql_fetchrow($result) ) { 
    74                         $sql = 'SELECT p.*, u.name FROM ' . PRIVATE_MESSAGES_TABLE . ' p, ' . USERS_TABLE . ' u 
     76                $result = $db->sql_query($sql); 
     77 
     78                if ( !$message = $db->sql_fetchrow($result) ) { 
     79                        $sql = 'SELECT p.*, u.name, u.uid, u.class 
     80                                        FROM ' . PRIVATE_MESSAGES_TABLE . ' p, ' . USERS_TABLE . ' u 
    7581                                        WHERE p.id = ' . $pm_id . ' AND p.sender = ' . $userdata['uid'] . ' AND p.receiver = u.uid AND p.saved = 1'; 
    76                      $result = $db->sql_query($sql); 
    77                      if ( !$message = $db->sql_fetchrow($result) ) { 
    78                              trigger_error( sprintf($lang['invalid_id'], $pm_id)); 
    79                         } 
    80              
    81  
    82              $bb_code = new bbcode(); 
    83  
    84              if ( $message['sender'] == $userdata['uid'] ) { 
    85                   $sender = '<a href="' . append_sid('userdetails.php?id=' . $message['receiver']) . '">' . $message['name'] . '</a>'
    86                   $id = $message['sender']; 
    87                   $sql = 'SELECT id FROM ' . FRIENDS_TABLE . ' WHERE userid = ' . $userdata['uid'] . ' AND friendid = ' . $id; 
    88                   $result = $db->sql_query($sql); 
    89                   if ( $db->sql_fetchrow($result) ) { 
    90                           $sender .= '&nbsp;<a href="' . append_sid('my.php?type=friends&amp;action=del_friend&amp;fr_type=1&amp;targetid=' . $id) . '">[' . $lang['remove_from_friends_list'] . ']</a>'; 
    91                  
    92                   else { 
    93                        $sender .= '&nbsp;<a href="' . append_sid('my.php?type=friends&amp;action=add_friend&amp;fr_type=1&amp;targetid=' . $id) . '">[' . $lang['add_to_friends_list'] . ']</a>'; 
    94                  
    95                   $reply = ''; 
    96                   $from = $lang['message_to']; 
    97              
    98              else { 
     82                       $result = $db->sql_query($sql); 
     83                       if ( !$message = $db->sql_fetchrow($result) ) { 
     84                               trigger_error( sprintf($lang['invalid_id'], $pm_id)); 
     85                        } 
     86               
     87 
     88               $bb_code = new bbcode(); 
     89 
     90               if ( $message['sender'] == $userdata['uid'] ) { 
     91                       $sender = parse_username($message)
     92                       $id = $message['sender']; 
     93                       $sql = 'SELECT id FROM ' . FRIENDS_TABLE . ' WHERE userid = ' . $userdata['uid'] . ' AND friendid = ' . $id; 
     94                       $result = $db->sql_query($sql); 
     95                       if ( $db->sql_fetchrow($result) ) { 
     96                               $sender .= '&nbsp;<a href="' . append_sid('my.php?type=friends&amp;action=del_friend&amp;fr_type=1&amp;targetid=' . $id) . '">[' . $lang['remove_from_friends_list'] . ']</a>'; 
     97                       
     98                       else { 
     99                            $sender .= '&nbsp;<a href="' . append_sid('my.php?type=friends&amp;action=add_friend&amp;fr_type=1&amp;targetid=' . $id) . '">[' . $lang['add_to_friends_list'] . ']</a>'; 
     100                       
     101                       $reply = ''; 
     102                       $from = $lang['message_to']; 
     103               
     104               else { 
    99105                        $from = $lang['message_from']; 
    100                   if ( !$message['sender'] ) { 
     106                       if ( $message['sender'] == ANONYMOUS ) { 
    101107                                $sender = $lang['system']; 
    102                        $reply = ''; 
    103                  
    104                   else { 
    105                        $sender = '<a href="' . append_sid('userdetails.php?id=' . $message['sender']) . '">' . $message['name'] . '</a>'
    106                        $id = $message['sender']; 
    107                        $reply_to = ( $message['reply_to'] ? $message['reply_to'] : $pm_id ); 
    108                        $sql = 'SELECT id FROM ' . FRIENDS_TABLE . ' WHERE userid = ' . $userdata['uid'] . ' AND friendid = ' . $id; 
    109                        $result = $db->sql_query($sql); 
    110                        if ( $db->sql_fetchrow($result) ) { 
     108                               $reply = ''; 
     109                       
     110                       else { 
     111                            $sender = parse_username($message)
     112                            $id = $message['sender']; 
     113                            $reply_to = ( $message['reply_to'] ? $message['reply_to'] : $pm_id ); 
     114                            $sql = 'SELECT id FROM ' . FRIENDS_TABLE . ' WHERE userid = ' . $userdata['uid'] . ' AND friendid = ' . $id; 
     115                            $result = $db->sql_query($sql); 
     116                            if ( $db->sql_fetchrow($result) ) { 
    111117                                        $sender .= '&nbsp;<a href="' . append_sid('my.php?type=friends&amp;action=del_friend&amp;fr_type=1&amp;targetid=' . $id) . '">[' . $lang['remove_from_friends_list'] . ']</a>'; 
    112                        } 
    113                        elseif ( $userdata['uid'] != $message['sender'] ) { 
     118                            } 
     119                            elseif ( $userdata['uid'] != $message['sender'] ) { 
    114120                                        $sender .= '&nbsp;<a href="' . append_sid('my.php?type=friends&amp;action=add_friend&amp;fr_type=1&amp;targetid=' . $id) . '">[' . $lang['add_to_friends_list'] . ']</a>'; 
    115                        } 
    116                        $reply = ' [ <a href="' . append_sid('message.php?action=send&amp;receiver=' . $message['sender'] . '&amp;replyto=' . $reply_to) . '">' . $lang['message_answer'] . '</a> ]'; 
    117                      
    118              
     121                            } 
     122                            $reply = ' [ <a href="' . append_sid('message.php?action=send&amp;receiver=' . $message['sender'] . '&amp;replyto=' . $reply_to) . '">' . $lang['message_answer'] . '</a> ]'; 
     123                       
     124               
    119125 
    120126                $bb_code->parse($message['msg']); 
    121              $body = $bb_code->get_html(); 
    122              $body = censor_text($body); 
    123  
    124              $added = create_date($message['added']); 
    125              if ( $userdata['class'] >= UC_MODERATOR && $message['sender'] == $userdata['uid'] ) { 
    126                         $unread = ($message['unread'] ? '<span style="color: #FF0000;"><b>(' . $lang['message_new'] . ')</b></span>' : ''); 
    127              
    128              else { 
     127               $body = $bb_code->get_html(); 
     128               $body = censor_text($body); 
     129 
     130               $added = create_date($message['added']); 
     131               if ( $message['sender'] == $userdata['uid'] ) { 
     132                        $unread = ( $message['unread'] ? '<span style="color: #FF0000;"><b>(' . $lang['message_new'] . ')</b></span>' : '' ); 
     133               
     134               else { 
    129135                        $unread = ''; 
    130              
    131              $subject = $message['subject']; 
    132  
    133              if ( $message['unread'] ) { 
     136               
     137               $subject = $message['subject']; 
     138 
     139               if ( $message['unread'] ) { 
    134140                        $sql = 'UPDATE ' . PRIVATE_MESSAGES_TABLE . ' SET unread = 0 WHERE id = ' . $pm_id . ' AND receiver=' . $userdata['uid'] . ' LIMIT 1'; 
    135141                        $db->sql_query($sql); 
    136                      if ( $db->sql_affectedrows() && $message['location'] == PM_INBOX ) { 
     142                       if ( $db->sql_affectedrows() && $message['location'] == PM_INBOX ) { 
    137143                                $sql = 'UPDATE ' . USERS_TABLE . ' SET user_unread_pms = user_unread_pms - 1 WHERE uid = ' . $userdata['uid']; 
    138                               $db->sql_query($sql); 
    139                      
    140              
    141  
    142              // Display message 
    143              $template->assign_vars(array( 
     144                              $db->sql_query($sql); 
     145                       
     146               
     147 
     148               // Display message 
     149               $template->assign_vars(array( 
    144150                        'U_DELETE' => append_sid('message.php?action=moveordel&amp;id=' . $pm_id . '&amp;delete=1'), 
    145                   'U_FORWARD' => append_sid('message.php?action=forward&amp;id=' . $pm_id), 
    146                   'SUBJECT' => $subject, 
    147                   'FROM' => $from, 
    148                   'SENDER' => $sender, 
    149                   'ADDED' => $added, 
    150                   'UNREAD' => $unread, 
    151                   'BODY' => $body, 
    152                   'PM_ID'=> $pm_id, 
    153                   'REPLY' => $reply 
     151                       'U_FORWARD' => append_sid('message.php?action=forward&amp;id=' . $pm_id), 
     152                       'SUBJECT' => $subject, 
     153                       'FROM' => $from, 
     154                       'SENDER' => $sender, 
     155                       'ADDED' => $added, 
     156                       'UNREAD' => $unread, 
     157                       'BODY' => $body, 
     158                       'PM_ID'=> $pm_id, 
     159                       'REPLY' => $reply 
    154160                )); 
    155161 
    156              if ( list ( $msg_history_ary ) = return_messages_history($message['reply_to'], true) ) { 
    157                      $template->assign_block_vars('messages_history', array()); 
     162               if ( list ( $msg_history_ary ) = return_messages_history($message['reply_to'], true) ) { 
     163                       $template->assign_block_vars('messages_history', array()); 
    158164                        foreach ( $msg_history_ary AS $msg_id => $ary ) { 
    159165                                $added = create_date($ary['added']); 
     
    161167                                $body = censor_text($ary['msg']); 
    162168                                $bb_code->parse($body); 
    163                              $body = $bb_code->get_html(); 
     169                                $body = $bb_code->get_html(); 
     170 
     171                                $user_name = parse_username($ary); 
    164172 
    165173                                $template->assign_block_vars('messages_history.messages_history_row', array( 
     
    167175                                        'MESSAGE' => $body, 
    168176                                        'ADDED' => $added, 
    169                                         'USERNAME' => ( $ary['uid'] == ANONYMOUS ? $lang['system'] : $ary['name'] ) 
     177                                        'USERNAME' => $user_name, 
    170178                                )); 
    171179                        } 
    172              
    173  
    174              stdhead(sprintf($lang['message_pm_subject'], $subject)); 
     180               
     181 
     182               stdhead(sprintf($lang['message_pm_subject'], $subject)); 
    175183                $template->set_filenames(array( 
    176184                        'body' => 'message_viewmessage_body.html' 
    177185                )); 
    178              stdfoot(); 
     186               stdfoot(); 
    179187 
    180188        break; 
     
    196204                        //flood control 
    197205                        $sql = 'SELECT MAX(added) AS max_added FROM ' . PRIVATE_MESSAGES_TABLE . ' WHERE sender = ' . $userdata['uid']; 
    198                       $result = $db->sql_query($sql); 
     206                      $result = $db->sql_query($sql); 
    199207                        $max_added = ( $flood_row = $db->sql_fetchrow($result) ) ? $flood_row['max_added'] : 0; 
    200208 
     
    202210                                trigger_error($lang['flood_error']); 
    203211                        } 
    204              
     212               
    205213 
    206214                if ( isset($_POST['submit']) ) { 
    207215                        $origmsg = request_var('origmsg', 0); 
    208                      $save = ( isset($_POST['save']) ? 1 : 0 ); 
    209                      $delete = ( isset($_POST['delete']) ? 1 : 0 ); 
    210                      $returnto = request_var('returnto', ''); 
    211                      $msg = request_var('message', ''); 
    212                      $subject = request_var('subject', ''); 
     216                       $save = ( isset($_POST['save']) ? 1 : 0 ); 
     217                       $delete = ( isset($_POST['delete']) ? 1 : 0 ); 
     218                       $returnto = request_var('returnto', ''); 
     219                       $msg = request_var('message', ''); 
     220                       $subject = request_var('subject', ''); 
    213221                        if ( !$msg ) { 
    214222                                trigger_error($lang['post_something']); 
    215                      
    216                      if ( !$subject ) { 
    217                              trigger_error($lang['please_enter_subject']); 
    218                      
     223                       
     224                       if ( !$subject ) { 
     225                               trigger_error($lang['please_enter_subject']); 
     226                       
    219227 
    220228                        $sql = 'SELECT email, acceptpms, notifs, parked, user_session_time, language, name, class FROM ' . USERS_TABLE . ' WHERE uid = ' . $receiver; 
    221                      $result = $db->sql_query($sql); 
    222                      if ( !($user = $db->sql_fetchrow($result)) || !$receiver ) { 
     229                       $result = $db->sql_query($sql); 
     230                       if ( !($user = $db->sql_fetchrow($result)) || !$receiver ) { 
    223231                                trigger_error(sprintf($lang['invalid_id'], $receiver)); 
    224                      
     232                       
    225233                        //Make sure recipient wants this message 
    226                      if ( $userdata['class'] < UC_MODERATOR ) { 
     234                       if ( $userdata['class'] < UC_MODERATOR ) { 
    227235                                if ( $user['acceptpms'] == 1 ) { 
    228236                                        $sql = 'SELECT * FROM ' . FRIENDS_TABLE . ' WHERE userid = ' . $receiver . ' AND blockid = ' . $userdata['uid']; 
    229                                $result = $db->sql_query($sql); 
     237                                    $result = $db->sql_query($sql); 
    230238                                        if ( $row = $db->sql_fetchrow($result) ) { 
    231239                                                trigger_error($lang['you_in_block_list']); 
    232                                } 
    233                          
     240                                    } 
     241                               
    234242                                elseif ( $user['acceptpms'] == 2 ) { 
    235243                                        $sql = 'SELECT * FROM ' . FRIENDS_TABLE . ' WHERE userid = ' . $receiver . ' AND friendid=' . $userdata['uid']; 
    236                                $result = $db->sql_query($sql); 
    237                                if ( !($row = $db->sql_fetchrow($result)) ) { 
    238                                        trigger_error($lang['only_from_friends']); 
    239                                } 
    240                          
     244                                    $result = $db->sql_query($sql); 
     245                                    if ( !($row = $db->sql_fetchrow($result)) ) { 
     246                                            trigger_error($lang['only_from_friends']); 
     247                                    } 
     248                               
    241249                                elseif ( !$user['acceptpms'] ) { 
    242250                                        trigger_error($lang['only_from_admins']); 
    243                          
     251                               
    244252 
    245253                                if ( $user['parked'] ) { 
    246254                                        trigger_error($lang['this_account_parked']); 
    247                              } 
    248                      } 
    249  
    250                   $pm_ary = array(); 
    251  
    252                         $pm_ary[] = array( 
     255                                } 
     256                        } 
     257 
     258                        $pm_ary = array(array( 
    253259                                'sender' => $userdata['uid'], 
    254260                                'sender_name' => $userdata['name'], 
     
    264270                                'language' => $user['language'], 
    265271                                'class' => $user['class'] 
    266                         )
     272                        ))
    267273 
    268274                        send_pm($pm_ary); 
     
    282288                                        elseif ( $arr['saved'] ) { 
    283289                                                $sql = 'UPDATE ' . PRIVATE_MESSAGES_TABLE . ' SET location = 0 WHERE id = ' . $origmsg; 
    284                                     $db->sql_query($sql); 
    285                                } 
    286                          
    287                      
    288  
    289                      $returnto = ( $returnto ? $returnto : 'message.php' ); 
    290                      $returnto = append_sid($returnto); 
     290                                         $db->sql_query($sql); 
     291                                    } 
     292                               
     293                       
     294 
     295                       $returnto = ( $returnto ? $returnto : 'message.php' ); 
     296                       $returnto = append_sid($returnto); 
    291297 
    292298                        meta_refresh(3, $returnto); 
    293                      trigger_error($lang['sucefully_sended']); 
     299                       trigger_error($lang['sucefully_sended']); 
    294300                } 
    295301                else { 
    296302                        if ( $receiver == $userdata['uid'] && $userdata['class'] < UC_SYSOP ) { 
    297303                                trigger_error(sprintf($lang['invalid_id'], $receiver)); 
    298                      
    299  
    300                         $sql = 'SELECT name FROM ' . USERS_TABLE . ' WHERE uid = ' . $receiver; 
     304                       
     305 
     306                        $sql = 'SELECT name, uid, class FROM ' . USERS_TABLE . ' WHERE uid = ' . $receiver; 
    301307                        $result = $db->sql_query($sql); 
    302308                        if ( !($user = $db->sql_fetchrow($result)) || !$receiver ) { 
     
    318324                                        $added = create_date($ary['added']); 
    319325                                        $bb_code->parse($ary['msg']); 
    320                                      $msg = $bb_code->get_html(); 
    321                                      $msg = censor_text($msg); 
     326                                       $msg = $bb_code->get_html(); 
     327                                       $msg = censor_text($msg); 
    322328 
    323329                                        $template->assign_block_vars('reply_to.reply_to_row', array( 
     
    333339 
    334340                        $template->assign_vars(array( 
    335                                 'U_USERDETAILS_RECEIVER' => append_sid('userdetails.php?id=' . $receiver), 
    336                           'S_FORM_ACTION' => append_sid('message.php'), 
    337                           'RECEIVER_ID' => $receiver, 
    338                           'REPLY_TO' => $reply_to, 
    339                           'ORIGMSG' => $origmsg, 
    340                           'RECEIVER_USERNAME' => $user['name'], 
    341                           'SUBJECT' => $subject, 
    342                           'DELETEPM_CHECKED' => ( $userdata['deletepms'] ? 'checked="checked"' : '' ), 
    343                           'SAVEPM_CHECKED' => ( $userdata['savepms'] ? 'checked="checked"' :'' ), 
    344  
    345                           'TEXTBBCODE' => $tpl 
     341                                'S_FORM_ACTION' => append_sid('message.php'), 
     342                                'RECEIVER_ID' => $receiver, 
     343                                'REPLY_TO' => $reply_to, 
     344                                'ORIGMSG' => $origmsg, 
     345                                'RECEIVER_USERNAME' => parse_username($user), 
     346                                'SUBJECT' => $subject, 
     347                                'DELETEPM_CHECKED' => ( $userdata['deletepms'] ? 'checked="checked"' : '' ), 
     348                                'SAVEPM_CHECKED' => ( $userdata['savepms'] ? 'checked="checked"' :'' ), 
     349 
     350                                'TEXTBBCODE' => $tpl 
    346351                        )); 
    347352 
     
    377382                if ( $delete ) { 
    378383                        do { 
    379                        if ( ( $message['receiver'] == $userdata['uid'] && !$message['saved'] ) || ( $message['sender'] == $userdata['uid'] && $message['location'] == PM_DELETED ) ) { 
    380                                $sql = 'DELETE FROM ' . PRIVATE_MESSAGES_TABLE . ' WHERE id = ' . $message['id']; 
     384                            if ( ( $message['receiver'] == $userdata['uid'] && !$message['saved'] ) || ( $message['sender'] == $userdata['uid'] && $message['location'] == PM_DELETED ) ) { 
     385                                    $sql = 'DELETE FROM ' . PRIVATE_MESSAGES_TABLE . ' WHERE id = ' . $message['id']; 
    381386                         $db->sql_query($sql); 
    382387                    } 
    383388                    elseif ( $message['receiver'] == $userdata['uid'] && $message['saved'] ) { 
    384                             $sql = 'UPDATE ' . PRIVATE_MESSAGES_TABLE . ' SET location = 0 WHERE id = ' . $message['id']; 
     389                                 $sql = 'UPDATE ' . PRIVATE_MESSAGES_TABLE . ' SET location = 0 WHERE id = ' . $message['id']; 
    385390                         $db->sql_query($sql); 
    386391                    } 
    387392                    elseif ( $message['sender'] == $userdata['uid'] && $message['location'] != PM_DELETED ) { 
    388                             $sql = 'UPDATE ' . PRIVATE_MESSAGES_TABLE . ' SET saved = 0 WHERE id = ' . $message['id']; 
     393                                 $sql = 'UPDATE ' . PRIVATE_MESSAGES_TABLE . ' SET saved = 0 WHERE id = ' . $message['id']; 
    389394                         $db->sql_query($sql); 
    390395                    } 
     
    399404                if ( $markread ) { 
    400405                        do { 
    401                        if ( $message['receiver'] == $userdata['uid'] ) { 
    402                             $sql = 'UPDATE ' . PRIVATE_MESSAGES_TABLE . ' SET unread = 0 WHERE id = ' . $message['id']; 
    403                             $db->sql_query($sql); 
     406                            if ( $message['receiver'] == $userdata['uid'] ) { 
     407                                 $sql = 'UPDATE ' . PRIVATE_MESSAGES_TABLE . ' SET unread = 0 WHERE id = ' . $message['id']; 
     408                                 $db->sql_query($sql); 
    404409                                if ( $db->sql_affectedrows() && $message['unread'] && $message['location'] == PM_INBOX ) { 
    405                                       $sql = 'UPDATE ' . USERS_TABLE . ' SET user_unread_pms = user_unread_pms - 1 WHERE uid = ' . $userdata['uid']; 
     410                                      $sql = 'UPDATE ' . USERS_TABLE . ' SET user_unread_pms = user_unread_pms - 1 WHERE uid = ' . $userdata['uid']; 
    406411                                                $db->sql_query($sql); 
    407412                                        } 
     
    423428                        } 
    424429 
    425                       //flood control 
     430                      //flood control 
    426431                        $sql = 'SELECT MAX(added) AS max_added FROM ' . PRIVATE_MESSAGES_TABLE . ' WHERE sender = ' . $userdata['uid']; 
    427                       $result = $db->sql_query($sql); 
     432                      $result = $db->sql_query($sql); 
    428433                        $max_added = ( $flood_row = $db->sql_fetchrow($result) ) ? $flood_row['max_added'] : 0; 
    429434 
    430                       if ( intval($flood_row['max_added']) > 0 && (time() - intval($flood_row['max_added'])) < intval($config['flood_interval']) ) { 
    431                               trigger_error($lang['flood_error']); 
    432                         } 
    433              
     435                      if ( intval($flood_row['max_added']) > 0 && (time() - intval($flood_row['max_added'])) < intval($config['flood_interval']) ) { 
     436                              trigger_error($lang['flood_error']); 
     437                        } 
     438               
    434439 
    435440                if ( isset($_GET['id']) ) { 
     
    437442 
    438443                        // Get the message 
    439                   $sql = 'SELECT * FROM ' . PRIVATE_MESSAGES_TABLE . ' WHERE id=' . $pm_id . ' AND (receiver=' . $userdata['uid'] . ' OR sender=' . $userdata['uid'] . ') LIMIT 1'; 
    440                   $result = $db->sql_query($sql); 
    441                   if ( !($message = $db->sql_fetchrow($result)) ) { 
     444                        $sql = 'SELECT * 
     445                                        FROM ' . PRIVATE_MESSAGES_TABLE . ' 
     446                                        WHERE id=' . $pm_id . ' AND (receiver=' . $userdata['uid'] . ' OR sender=' . $userdata['uid'] . ') LIMIT 1'; 
     447                        $result = $db->sql_query($sql); 
     448                        if ( !$message = $db->sql_fetchrow($result) ) { 
    442449                                trigger_error(sprintf($lang['invalid_id'], $pm_id) ); 
    443                   } 
    444  
    445                   // Prepare variables 
    446                   $subject = 'Fwd: ' . $message['subject']; 
    447                   $from = $message['sender']; 
    448                   $orig = $message['receiver']; 
    449  
    450                   $sql = 'SELECT name FROM ' . USERS_TABLE . ' WHERE uid = ' . $from; 
    451                   $result = $db->sql_query($sql); 
    452                   if ( !($orig2 = $db->sql_fetchrow($result)) ) { 
    453                           trigger_error(sprintf($lang['invalid_id'], $pm_id) ); 
    454                   } 
    455  
    456                   if ( !$from ) { 
    457                                 $orig_name = $lang['system']; 
    458                        $from_name = '<a href="' . append_sid('userdetails.php?id=' . $userdata['uid']) . '">' . $userdata['name'] . '</a>'; 
    459                   } 
    460                   else { 
    461                        $from_name = '<a href="' . append_sid('userdetails.php?id=' . $userdata['uid']) . '">' . $userdata['name'] . '</a>'; 
    462                        $orig_name = '<a href="' . append_sid('userdetails.php?id=' . $from) . '">' . $orig2['name'] . '</a>'; 
    463                   } 
    464  
    465                   $bb_code = new bbcode(); 
    466  
    467                   $body = sprintf($lang['pm_message_separator'],  $orig2['name'], $message['msg']); 
     450                        } 
     451 
     452                        // Prepare variables 
     453                        $subject = 'Fwd: ' . $message['subject']; 
     454                        $from = $message['sender']; 
     455                        $orig = $message['receiver']; 
     456 
     457                        $sql = 'SELECT name, uid, class 
     458                                        FROM ' . USERS_TABLE . ' 
     459                                        WHERE uid = ' . $from; 
     460                        $result = $db->sql_query($sql); 
     461                        if ( !$orig2 = $db->sql_fetchrow($result) ) { 
     462                                trigger_error(sprintf($lang['invalid_id'], $pm_id) ); 
     463                        } 
     464 
     465                        $from_name = parse_username($userdata); 
     466                        $orig_name = parse_username($orig2); 
     467 
     468                        $bb_code = new bbcode(); 
     469 
     470                        $body = sprintf($lang['pm_message_separator'],  $orig2['name'], $message['msg']); 
    468471                        $bb_code->parse($body); 
    469472                        $body = $bb_code->get_html(); 
    470473                        $body = censor_text($body); 
    471474 
    472                   $template->assign_vars(array( 
    473                        'S_FORM_ACTION' => append_sid('message.php'), 
    474                        'SUBJECT' => $subject, 
    475                        'PM_ID' => $pm_id, 
    476                        'FROM_NAME' => $from_name, 
    477                        'BODY' => $body, 
    478                        'SAVE_PM_CHECKED' => ( $userdata['savepms'] ? 'checked="checked"' : '' ), 
    479                        'ORIG_NAME' => $orig_name 
     475                       $template->assign_vars(array( 
     476                            'S_FORM_ACTION' => append_sid('message.php'), 
     477                            'SUBJECT' => $subject, 
     478                            'PM_ID' => $pm_id, 
     479                            'FROM_NAME' => $from_name, 
     480                            'BODY' => $body, 
     481                            'SAVE_PM_CHECKED' => ( $userdata['savepms'] ? 'checked="checked"' : '' ), 
     482                            'ORIG_NAME' => $orig_name 
    480483                        )); 
    481484 
    482                   stdhead($subject); 
     485                       stdhead($subject); 
    483486                        $template->set_filenames(array( 
    484                               'body' => 'message_forward_message.html' 
     487                              'body' => 'message_forward_message.html' 
    485488                        )); 
    486                   stdfoot(); 
    487              
    488              else { 
     489                       stdfoot(); 
     490               
     491               else { 
    489492                        // Forward the message 
    490                   $pm_id = request_var('id', 0); 
    491                   $subject = request_var('subject', ''); 
    492                   $username = request_var('to', ''); 
    493                   $body = request_var('msg', ''); 
    494                   $save = isset($_POST['save']); 
     493                       $pm_id = request_var('id', 0); 
     494                       $subject = request_var('subject', ''); 
     495                       $username = request_var('to', ''); 
     496                       $body = request_var('msg', ''); 
     497                       $save = isset($_POST['save']); 
    495498 
    496499                        // Get the message 
    497                   $sql = 'SELECT * FROM ' . PRIVATE_MESSAGES_TABLE . ' WHERE id = ' . $pm_id . ' AND (receiver=' . $userdata['uid'] . ' OR sender=' . $userdata['uid'] . ') LIMIT 1'; 
    498                   $result = $db->sql_query($sql); 
    499  
    500                   if ( !($message = $db->sql_fetchrow($result)) ) { 
    501                           trigger_error(sprintf($lang['invalid_id'], $pm_id) ); 
    502                  
     500                       $sql = 'SELECT * FROM ' . PRIVATE_MESSAGES_TABLE . ' WHERE id = ' . $pm_id . ' AND (receiver=' . $userdata['uid'] . ' OR sender=' . $userdata['uid'] . ') LIMIT 1'; 
     501                       $result = $db->sql_query($sql); 
     502 
     503                       if ( !($message = $db->sql_fetchrow($result)) ) { 
     504                               trigger_error(sprintf($lang['invalid_id'], $pm_id) ); 
     505                       
    503506 
    504507                        // Try finding a user with specified name 
    505                   $sql = 'SELECT uid, email, language, name, class, notifs FROM ' . USERS_TABLE . ' WHERE LOWER(name) = ' . "'" . $db->sql_escape(utf_strtolower($username)) . "'" . ' AND uid != ' . ANONYMOUS . ' LIMIT 1'; 
    506                   $result = $db->sql_query($sql); 
    507                   if ( !($to_arr = $db->sql_fetchrow($result)) ) { 
     508                       $sql = 'SELECT uid, email, language, name, class, notifs FROM ' . USERS_TABLE . ' WHERE LOWER(name) = ' . "'" . $db->sql_escape(utf_strtolower($username)) . "'" . ' AND uid != ' . ANONYMOUS . ' LIMIT 1'; 
     509                       $result = $db->sql_query($sql); 
     510                       if ( !($to_arr = $db->sql_fetchrow($result)) ) { 
    508511                                trigger_error($lang['no_user_with_that_username']); 
    509                  
    510                   $to = $to_arr['uid']; 
    511                   $to_email = $to_arr['email']; 
    512                   $to_language = $to_arr['language']; 
    513                   $to_username = $to_arr['name']; 
    514                   if (!check_language($to_language)) { 
     512                       
     513                       $to = $to_arr['uid']; 
     514                       $to_email = $to_arr['email']; 
     515                       $to_language = $to_arr['language']; 
     516                       $to_username = $to_arr['name']; 
     517                       if (!check_language($to_language)) { 
    515518                                $to_language = $config['default_lang']; 
    516                  
     519                       
    517520 
    518521                        // Get Orignal sender's username 
    519                   if ( !($message['sender']) ) { 
     522                       if ( !($message['sender']) ) { 
    520523                                $from_username = $lang['system']; 
    521                  
    522                   else { 
     524                       
     525                       else { 
    523526                                $sql = 'SELECT name, acceptpms, parked FROM ' . USERS_TABLE . ' WHERE uid=' . $message['sender']; 
    524                        $result = $db->sql_query($sql); 
    525                        $from = $db->sql_fetchrow($result); 
    526                        $from_username = $from['name']; 
    527                  
    528                   $body .= sprintf($lang['pm_message_separator'],  $from_username, $message['msg']); 
     527                            $result = $db->sql_query($sql); 
     528                            $from = $db->sql_fetchrow($result); 
     529                            $from_username = $from['name']; 
     530                       
     531                       $body .= sprintf($lang['pm_message_separator'],  $from_username, $message['msg']); 
    529532 
    530533                        //Make sure recipient wants this message 
    531                   if ( $userdata['class'] < UC_MODERATOR ) { 
     534                       if ( $userdata['class'] < UC_MODERATOR ) { 
    532535                                if ( $from['acceptpms'] == 1 ) { 
    533536                                        $sql = 'SELECT * FROM ' . FRIENDS_TABLE . ' WHERE userid=' . $to . ' AND blockid=' . $userdata['uid']; 
    534                             $result = $db->sql_query($sql); 
    535                             if ( $row = $db->sql_fetchrow($result) ) { 
    536                                     trigger_error($lang['you_in_block_list']); 
    537                             } 
    538                        } 
    539                        elseif ( $from['acceptpms'] == 2 ) { 
     537                                 $result = $db->sql_query($sql); 
     538                                 if ( $row = $db->sql_fetchrow($result) ) { 
     539                                         trigger_error($lang['you_in_block_list']); 
     540                                 } 
     541                            } 
     542                            elseif ( $from['acceptpms'] == 2 ) { 
    540543                                        $sql = 'SELECT * FROM ' . FRIENDS_TABLE . ' WHERE userid=' . $to . ' AND friendid=' . $userdata['uid']; 
    541                             $result = $db->sql_query($sql); 
    542                             if ( !($row = $db->sql_fetchrow($result)) ) { 
     544                                 $result = $db->sql_query($sql); 
     545                                 if ( !($row = $db->sql_fetchrow($result)) ) { 
    543546                                                trigger_error($lang['only_from_friends']); 
    544                             } 
    545                        } 
     547                                 } 
     548                            } 
    546549                                elseif ( !$from['acceptpms'] ) { 
    547                             trigger_error($lang['only_from_admins']); 
    548                        } 
    549                        elseif ( $from['parked'] ) { 
    550                             trigger_error($lang['this_account_parked']); 
    551                        } 
    552                   } 
    553  
    554                   $pm_ary = array(); 
    555  
    556                         $pm_ary[] = array( 
     550                                  trigger_error($lang['only_from_admins']); 
     551                             } 
     552                             elseif ( $from['parked'] ) { 
     553                                  trigger_error($lang['this_account_parked']); 
     554                             } 
     555                        } 
     556 
     557                        $pm_ary = array(array( 
    557558                                'sender' => $userdata['uid'], 
    558559                                'sender_name' => $userdata['name'], 
     
    567568                                'language' => $to_arr['language'], 
    568569                                'class' => $to_arr['class'] 
    569                         )
     570                        ))
    570571 
    571572                        send_pm($pm_ary); 
    572573 
    573                   meta_refresh(3, append_sid($root_path . 'message.php')); 
    574                   trigger_error($lang['sucefully_sended']); 
    575              
     574                       meta_refresh(3, append_sid($root_path . 'message.php')); 
     575                       trigger_error($lang['sucefully_sended']); 
     576               
    576577        break; 
    577578 
     
    581582                // Get Mailbox Number 
    582583                $mailbox = request_var('box', PM_INBOX); 
    583                 $mailbox_name = ( $mailbox == PM_INBOX? $lang['inbox'] : $lang['sentbox'] ); 
    584584                $warning_text = ''; 
    585585 
     586                if ( $mailbox == PM_INBOX ) { 
     587                        $mailbox_name = $lang['inbox']; 
     588                        $box_limit = $config['max_inbox_privmsgs']; 
     589                        $sender_title = $lang['sender']; 
     590                        $sql_where = 'm.receiver = ' . $userdata['uid'] . ' AND m.location = ' . $mailbox . ' AND m.sender = u.uid'; 
     591                } 
     592                else{ 
     593                        $mailbox_name = $lang['sentbox']; 
     594                        $box_limit = $config['max_sentbox_privmsgs']; 
     595                        $sender_title = $lang['receiver']; 
     596                        $sql_where = 'm.sender=' . $userdata['uid'] . ' AND m.saved = 1 AND m.receiver = u.uid'; 
     597                } 
     598 
    586599                // Start Page 
    587                 $sql = 'SELECT COUNT(*) as count FROM ' . PRIVATE_MESSAGES_TABLE . ' 
    588                                 WHERE ' . ( $mailbox != PM_SENTBOX ? 'receiver = ' . $userdata['uid'] . ' AND location = ' . $mailbox : 'sender = ' . $userdata['uid'] . '  AND saved = 1' ); 
     600                $sql = 'SELECT COUNT(*) as count 
     601                                FROM ' . PRIVATE_MESSAGES_TABLE . ' m, ' . USERS_TABLE . ' u 
     602                                WHERE ' . $sql_where; 
    589603                $result = $db->sql_query($sql); 
    590604                $count = $count_pager = ( $row = $db->sql_fetchrow($result) ) ? intval($row['count']) : 0; 
    591  
    592                 $box_limit = ( $mailbox != PM_SENTBOX ? $config['max_inbox_privmsgs'] : $config['max_sentbox_privmsgs'] ); 
    593605 
    594606                if ( $box_limit && ( $count > $box_limit ) && ( $userdata['class'] < UC_MODERATOR ) ) { 
     
    598610                        $count_pager = $box_limit; 
    599611                } 
    600                 list($pagertop, $pagerbottom, $offset_pager, $limit_pager) = pager(40, $count_pager, append_sid('message.php?action=viewmailbox&amp;box=' . ( $mailbox == PM_SENTBOX ? PM_SENTBOX : PM_INBOX ) . '&amp;' ) ); 
     612                list($pagertop, $pagerbottom, $offset_pager, $limit_pager) = pager(40, $count_pager, 'message.php?action=viewmailbox&amp;box=' . $mailbox . '&amp;'); 
    601613 
    602614                $limit = ( isset($limit) ? $limit : $limit_pager ); 
     
    604616 
    605617                $pm_box_select = '<select name="box">'; 
    606              $pm_box_select .= '<option value="' . PM_INBOX . '"' . ( $mailbox == PM_INBOX ? ' selected="selected"' : '' ) . '>' . $lang['inbox'] . '</option>'; 
    607              $pm_box_select .= '<option value="' . PM_SENTBOX . '"' . ( $mailbox == PM_SENTBOX ? ' selected="selected"' : '' ) . '>' . $lang['sentbox'] . '</option>'; 
    608              $pm_box_select .= '</select>'; 
    609  
    610              $template->assign_vars(array( 
     618               $pm_box_select .= '<option value="' . PM_INBOX . '"' . ( $mailbox == PM_INBOX ? ' selected="selected"' : '' ) . '>' . $lang['inbox'] . '</option>'; 
     619               $pm_box_select .= '<option value="' . PM_SENTBOX . '"' . ( $mailbox == PM_SENTBOX ? ' selected="selected"' : '' ) . '>' . $lang['sentbox'] . '</option>'; 
     620               $pm_box_select .= '</select>'; 
     621 
     622               $template->assign_vars(array( 
    611623                        'S_FORM_ACTION' => append_sid('message.php'), 
    612                   'MAILBOX' => $mailbox, 
    613                   'MAILBOX_NAME' => $mailbox_name, 
    614                   'PM_BOX_SELECT' => $pm_box_select, 
    615                   'SENDER_RECEIVER' => ( $mailbox == PM_INBOX ? $lang['sender'] : $lang['receiver'] ), 
    616                   'PAGERBOTTOM' => $pagerbottom, 
    617  
    618                   'S_LIMIT_REACHED_WARNING' => $warning_text 
     624                        'MAILBOX' => $mailbox, 
     625                        'MAILBOX_NAME' => $mailbox_name, 
     626                        'PM_BOX_SELECT' => $pm_box_select, 
     627                        'SENDER_RECEIVER' => $sender_title, 
     628                        'PAGERBOTTOM' => $pagerbottom, 
     629 
     630                        'MESSAGES_COUNT' => $count, 
     631 
     632                        'S_LIMIT_REACHED_WARNING' => $warning_text 
    619633                )); 
    620634 
    621                 $where = ( $mailbox != PM_SENTBOX ? 'm.receiver = ' . $userdata['uid'] . ' AND m.location = ' . $mailbox . ' AND m.sender = u.uid' : 'm.sender=' . $userdata['uid'] . ' AND m.saved = 1 AND m.receiver = u.uid' ); 
    622  
    623              $sql = 'SELECT m.*, u.name 
     635                $sql = 'SELECT m.*, u.name, u.uid, u.class 
    624636                                FROM ' . PRIVATE_MESSAGES_TABLE . ' m, ' . USERS_TABLE . ' u 
    625                                 WHERE ' . $where . 
    626                       ' ORDER BY added DESC'; 
    627              $result = $db->sql_query_limit($sql, $limit, $offset); 
     637                                WHERE ' . $sql_where . 
     638                        ' ORDER BY added DESC'; 
     639               $result = $db->sql_query_limit($sql, $limit, $offset); 
    628640 
    629641                if ( !$count ) { 
    630                         $template->assign_block_vars('no_pms', array()); 
    631                                 if ( $userdata['user_unread_pms'] ) { 
    632                                         $sql = 'UPDATE ' . USERS_TABLE . ' SET user_unread_pms = 0 WHERE uid = ' . $userdata['uid']; 
    633                                         $db->sql_query($sql); 
    634                        } 
    635              } 
    636              else { 
     642                        if ( $userdata['user_unread_pms'] ) { 
     643                                $sql = 'UPDATE ' . USERS_TABLE . ' SET user_unread_pms = 0 WHERE uid = ' . $userdata['uid']; 
     644                                $db->sql_query($sql); 
     645                         } 
     646                } 
     647                else { 
    637648                        $unread_pms = 0; 
     649 
    638650                        while ( $row = $db->sql_fetchrow($result) ) { 
    639                                 if ( $mailbox != PM_SENTBOX ) { 
    640                                         $username = ( $row['sender'] <> ANONYMOUS ? '<a href="' . append_sid('userdetails.php?id=' . $row['sender']) . '">' . $row['name'] . '</a>' : $lang['system'] ); 
    641                        } 
    642                        else { 
    643                                         $username = ( $row['receiver'] <> ANONYMOUS ? '<a href="' . append_sid('userdetails.php?id=' . $row['receiver']) . '">' . $row['name'] . '</a>' : $lang['system'] ); 
    644                        } 
    645  
    646                        $subject = ( !$row['subject'] ? $lang['no_subject'] : $row['subject'] ); 
     651                                $username = parse_username($row); 
     652 
     653                                $subject = ( !$row['subject'] ? $lang['no_subject'] : $row['subject'] ); 
    647654 
    648655                                $template->assign_block_vars('messages_row', array( 
    649656                                        'U_MESSAGE' => append_sid('message.php?action=viewmessage&amp;id=' . $row['id']), 
    650                             'ID' => $row['id'], 
    651                             'SENDER_RECEIVER_NAME' => $username, 
    652                             'SUBJECT' => $row['subject'], 
    653                             'IMG_SRC' => ( $row['unread'] && $mailbox != PM_SENTBOX ? $images['inboxnew'] : $images['inbox'] ), 
    654                             'IMG_TITLE' => ( $row['unread'] && $mailbox != PM_SENTBOX ? $lang['new_unread_pm'] : $lang['old_read_pm'] ), 
    655                             'DATE' => create_date($row['added']) 
     657                                       'ID' => $row['id'], 
     658                                       'SENDER_RECEIVER_NAME' => $username, 
     659                                       'SUBJECT' => $row['subject'], 
     660                                       'IMG_SRC' => ( $row['unread'] && $mailbox != PM_SENTBOX ? $images['inboxnew'] : $images['inbox'] ), 
     661                                       'IMG_TITLE' => ( $row['unread'] && $mailbox != PM_SENTBOX ? $lang['new_unread_pm'] : $lang['old_read_pm'] ), 
     662                                       'DATE' => create_date($row['added']) 
    656663                                )); 
    657                        if ( $row['unread'] && $mailbox != PM_SENTBOX ) { 
     664 
     665                                if ( $row['unread'] && $mailbox != PM_SENTBOX ) { 
    658666                                        ++$unread_pms; 
    659                        
    660  
    661                  
    662                   //if ( $unread_pms <> $userdata['user_unread_pms'] && $mailbox != PM_SENTBOX ) { 
     667                               
     668 
     669                       
     670                       //if ( $unread_pms <> $userdata['user_unread_pms'] && $mailbox != PM_SENTBOX ) { 
    663671                        //      $sql = 'UPDATE ' . USERS_TABLE . ' SET user_unread_pms = ' . $unread_pms . ' WHERE uid = ' . $userdata['uid']; 
    664672                        //      $db->sql_query($sql); 
    665                   //} 
    666              
    667  
    668              stdhead($mailbox_name); 
     673                       //} 
     674               
     675 
     676               stdhead($mailbox_name); 
    669677                $template->set_filenames(array( 
    670678                        'body' => 'message_viewmailbox.html' 
    671679                )); 
    672              stdfoot(); 
     680               stdfoot(); 
    673681        break; 
    674682} 
  • phpBB2/includes/functions_search.php

    r318 r331  
    210210                                { 
    211211                                        case 'mysql': 
     212                                        case 'mysqli': 
    212213                                        case 'mysql4': 
    213214                                                $value_sql .= ( ( $value_sql != '' ) ? ', ' : '' ) . '(\'' . $word[$i] . '\', 0)'; 
     
    231232                        { 
    232233                                case 'mysql': 
     234                                case 'mysqli': 
    233235                                case 'mysql4': 
    234236                                        $sql = "INSERT IGNORE INTO " . SEARCH_WORD_TABLE . " (word_text, word_common) 
     
    343345                case 'mysql': 
    344346                case 'mysql4': 
     347                case 'mysqli': 
    345348                        $sql = "SELECT word_id 
    346349                                FROM " . SEARCH_MATCH_TABLE . " 
  • phpBB2/search.php

    r324 r331  
    11<?php 
    22/*************************************************************************** 
    3  *                                search.php 
    4  *                            ------------------- 
    5  *   begin                : Saturday, Feb 13, 2001 
    6  *   copyright            : (C) 2001 The phpBB Group 
    7  *   email                : support@phpbb.com 
     3 *                             search.php 
     4 *                         ------------------- 
     5 *   begin             : Saturday, Feb 13, 2001 
     6 *   copyright     : (C) 2001 The phpBB Group 
     7 *   email             : support@phpbb.com 
    88 * 
    99 *   $Id: search.php,v 1.72.2.17 2005/09/14 18:14:30 acydburn Exp $ 
     
    8484if ( $mode == 'searchuser' ) 
    8585{ 
    86         // 
    87         // This handles the simple windowed user search functions called from various other scripts 
    88         // 
    89         if ( isset($_POST['search_username']) ) 
    90         { 
    91                 username_search($_POST['search_username']); 
    92         } 
    93         else 
    94         { 
    95                 username_search(''); 
    96         } 
    97  
    98         gc(); 
     86        $search_username = request_var('search_username', ''); 
     87        username_search($search_username); 
     88        gc(); 
    9989} 
    10090else if ( $search_keywords != '' || $search_author != '' || $search_id ) 
    10191{ 
    102         $store_vars = array('search_results', 'total_match_count', 'split_search', 'sort_by', 'sort_dir', 'show_results', 'return_chars'); 
    103         $search_results = ''; 
    104         // Topic search MOD 
    105         $tid = request_var('topic_id', 0); 
    106         // Topic search MOD 
    107  
    108         // 
    109         // Search ID Limiter, decrease this value if you experience further timeout problems with searching forums 
    110         $limiter = 5000; 
    111         $current_time = time(); 
    112         $total_match_count = 0; 
    113  
    114         // 
    115         // Cycle through options ... 
    116         // 
    117         if ( $search_id == 'newposts' || $search_id == 'egosearch' || $search_id == 'unanswered' || $search_keywords != '' || $search_author != '' ) 
    118         { 
    119                                 // 
    120                 // Flood control 
    121                 // 
    122                 $where_sql = ($userdata['uid'] == ANONYMOUS) ? "se.session_ip = '$user_ip'" : 'se.session_user_id = ' . $userdata['uid']; 
    123                 $sql = 'SELECT MAX(sr.search_time) AS last_search_time 
    124                         FROM ' . SEARCH_TABLE . ' sr, ' . SESSIONS_TABLE . " se 
    125                         WHERE sr.session_id = se.session_id 
    126                                 AND $where_sql"; 
    127                 if ($result = $db->sql_query($sql)) 
    128                 { 
    129                         if ($row = $db->sql_fetchrow($result)) 
    130                         { 
    131                                 if (intval($row['last_search_time']) > 0 && ($current_time - intval($row['last_search_time'])) < intval($config['search_flood_interval'])) 
    132                                 { 
    133                                         $wait_time = intval($config['search_flood_interval']) - ($current_time - intval($row['last_search_time'])); 
    134                                         trigger_error(sprintf($lang['search_flood_error'], $wait_time)); 
    135                                         return; 
    136                                 } 
    137                         } 
    138                 } 
    139                 if ( $search_id == 'newposts' || $search_id == 'egosearch' || ( $search_author != '' && $search_keywords == '' )  ) 
    140                 { 
    141                         if ( $search_id == 'newposts' ) 
    142                         { 
    143                                 if ( $userdata['session_logged_in'] ) 
    144                                 { 
    145                                         $sql = "SELECT post_id 
    146                                                 FROM " . POSTS_TABLE . " 
    147                                                 WHERE post_time >= " . $userdata['user_lastvisit']; 
    148                                 } 
    149                                 else 
    150                                 { 
    151                                         loggedinorreturn(); 
    152                                         //redirect(append_sid($root_path . "login.php?returnto=" . rawurlencode("phpbb2.$phpEx?page=search&search_id=newposts"))); 
    153                                 } 
    154  
    155                                 $show_results = 'topics'; 
    156                                 $sort_by = 0; 
    157                                 $sort_dir = 'DESC'; 
    158                         } 
    159                         else if ( $search_id == 'egosearch' ) 
    160                         { 
    161                                 if ( $userdata['session_logged_in'] ) 
    162                                 { 
    163                                         $sql = "SELECT post_id 
    164                                                 FROM " . POSTS_TABLE . " 
    165                                                 WHERE poster_id = " . $userdata['uid']; 
    166                                 } 
    167                                 else 
    168                                 { 
    169                                         loggedinorreturn(); 
    170                                         //redirect(append_sid($root_path . "login.php?returnto=" . rawurlencode("phpbb2.$phpEx?page=search&search_id=egosearch"))); 
    171                                 } 
    172  
    173                                 $show_results = 'topics'; 
    174                                 $sort_by = 0; 
    175                                 $sort_dir = 'DESC'; 
    176                         } 
    177                         else 
    178                         { 
    179                                 $search_author = str_replace('*', '%', trim($search_author)); 
    180  
    181                                 if( ( strpos($search_author, '%') !== false ) && ( utf_strlen(str_replace('%', '', $search_author)) < $config['search_min_chars'] ) ) 
    182                                 { 
    183                                         $search_author = ''; 
    184                                 } 
    185  
    186                                 $sql = "SELECT uid 
    187                                         FROM " . USERS_TABLE . " 
    188                                         WHERE name LIKE '" . str_replace("\'", "''", $search_author) . "'"; 
    189                                 $result = $db->sql_query($sql); 
    190  
    191                                 $matching_userids = ''; 
    192                                 if ( $row = $db->sql_fetchrow($result) ) 
    193                                 { 
    194                                         do 
    195                                         { 
    196                                                 $matching_userids .= ( ( $matching_userids != '' ) ? ', ' : '' ) . $row['uid']; 
    197                                         } 
    198                                         while( $row = $db->sql_fetchrow($result) ); 
    199                                 } 
    200                                 else 
    201                                 { 
    202                                         trigger_error($lang['no_search_match']); 
    203                                         return; 
    204                                 } 
    205  
    206                                 $sql = "SELECT post_id 
    207                                         FROM " . POSTS_TABLE . " 
    208                                         WHERE poster_id IN ($matching_userids)"; 
    209  
    210                                 if ($search_time) 
    211                                 { 
    212                                         $sql .= " AND post_time >= " . $search_time; 
    213                                 } 
    214                         } 
    215  
    216                         $result = $db->sql_query($sql); 
    217  
    218                         $search_ids = array(); 
    219                         while( $row = $db->sql_fetchrow($result) ) 
    220                         { 
    221                                 $search_ids[] = $row['post_id']; 
    222                         } 
    223                         $db->sql_freeresult($result); 
    224  
    225                         $total_match_count = sizeof($search_ids); 
    226  
    227                 } 
    228                 else if ( $search_keywords != '' ) 
    229                 { 
    230                         $stopword_array = @file($root_path . 'languages/lang_' . $config['default_lang'] . '/search_stopwords.txt'); 
    231                         $synonym_array = @file($root_path . 'languages/lang_' . $config['default_lang'] . '/search_synonyms.txt'); 
    232  
    233                         $stripped_keywords = ( STRIP ? stripslashes($search_keywords) : $search_keywords ); 
    234                         $split_search = split_words(clean_words('search', $stripped_keywords, $stopword_array, $synonym_array), 'search'); 
    235                         unset($stripped_keywords); 
    236  
    237                         $search_msg_only = ( !$search_fields ) ? "AND m.title_match = 0" : ''; 
    238  
    239                         $word_count = 0; 
    240                         $current_match_type = 'or'; 
    241  
    242                         $word_match = array(); 
    243                         $result_list = array(); 
    244  
    245                         for($i = 0; $i < sizeof($split_search); $i++) 
    246                         { 
    247                                 if ( utf_strlen(str_replace(array('*', '%'), '', trim($split_search[$i]))) < $config['search_min_chars'] ) 
    248                                 { 
    249                                         $split_search[$i] = ''; 
    250                                         continue; 
    251                                 } 
    252  
    253                                 switch ( $split_search[$i] ) 
    254                                 { 
    255                                         case 'and': 
    256                                                 $current_match_type = 'and'; 
    257                                                 break; 
    258  
    259                                         case 'or': 
    260                                                 $current_match_type = 'or'; 
    261                                                 break; 
    262  
    263                                         case 'not': 
    264                                                 $current_match_type = 'not'; 
    265                                                 break; 
    266  
    267                                         default: 
    268                                                 if ( !empty($search_terms) ) 
    269                                                 { 
    270                                                         $current_match_type = 'and'; 
    271                                                 } 
    272  
    273                                                 $match_word = str_replace('*', '%', $split_search[$i]); 
    274                                                 $sql = "SELECT m.post_id 
    275                                                                 FROM " . SEARCH_WORD_TABLE . " w, " . SEARCH_MATCH_TABLE . " m 
    276                                                                 WHERE w.word_text LIKE '$match_word' 
    277                                                                         AND m.word_id = w.word_id 
    278                                                                         AND w.word_common <> 1 
    279                                                                         $search_msg_only"; 
    280                                                 $result = $db->sql_query($sql); 
    281  
    282                                                 $row = array(); 
    283                                                 while( $temp_row = $db->sql_fetchrow($result) ) 
    284                                                 { 
    285                                                         $row[$temp_row['post_id']] = 1; 
    286  
    287                                                         if ( !$word_count ) 
    288                                                         { 
    289                                                                 $result_list[$temp_row['post_id']] = 1; 
    290                                                         } 
    291                                                         else if ( $current_match_type == 'or' ) 
    292                                                         { 
    293                                                                 $result_list[$temp_row['post_id']] = 1; 
    294                                                         } 
    295                                                         else if ( $current_match_type == 'not' ) 
    296                                                         { 
    297                                                                 $result_list[$temp_row['post_id']] = 0; 
    298                                                         } 
    299                                                 } 
    300  
    301                                                 if ( $current_match_type == 'and' && $word_count ) 
    302                                                 { 
    303                                                         @reset($result_list); 
    304                                                         while( list($post_id, $match_count) = @each($result_list) ) 
    305                                                         { 
    306                                                                 if ( !$row[$post_id] ) 
    307                                                                 { 
    308                                                                         $result_list[$post_id] = 0; 
    309                                                                 } 
    310                                                         } 
    311                                                 } 
    312  
    313                                                 $word_count++; 
    314  
    315                                                 $db->sql_freeresult($result); 
    316                                         } 
    317                         } 
    318  
    319                         @reset($result_list); 
    320  
    321                         $search_ids = array(); 
    322                         while( list($post_id, $matches) = each($result_list) ) 
    323                         { 
    324                                 if ( $matches ) 
    325                                 { 
    326  
    327                                         // Topic Search MOD 
    328                                         if($tid) 
    329                                         { 
    330                                                 $sql = "SELECT post_id 
    331                                                         FROM " . POSTS_TABLE . " 
    332                                                         WHERE topic_id = '$tid'"; 
    333                                                 $result = $db->sql_query($sql); 
    334                                                 while( $test = $db->sql_fetchrow($result) ) 
    335                                                 { 
    336                                                         if($test['post_id'] == $post_id) 
    337                                                         { 
    338                                                                 $search_ids[] = $post_id; 
    339                                                         } 
    340                                                 } 
    341                                                 $show_results = 'posts'; 
    342                                         } 
    343                                         else 
    344                                         { // End Topic Search MOD 
    345  
    346                                         $search_ids[] = $post_id; 
    347                                         // Topic Search MOD 
    348                                         } 
    349                                         // End Topic search MOD 
    350                                 } 
    351                         } 
    352  
    353                         unset($result_list); 
    354                         $total_match_count = sizeof($search_ids); 
    355                 } 
    356  
    357                 // 
    358                 // If user is logged in then we'll check to see which (if any) private 
    359                 // forums they are allowed to view and include them in the search. 
    360                 // 
    361                 // If not logged in we explicitly prevent searching of private forums 
    362                 // 
    363                 $auth_sql = ''; 
    364                 if ( $search_forum != -1 ) 
    365                 { 
    366                         $is_auth = auth(AUTH_READ, $search_forum, $userdata); 
    367  
    368                         if ( !$is_auth['auth_read'] ) 
    369                         { 
    370                                 trigger_error($lang['no_searchable_forums']); 
    371                                 return; 
    372                         } 
    373  
    374                         $auth_sql = "f.forum_id = $search_forum"; 
    375                 } 
    376                 else 
    377                 { 
    378                         $is_auth_ary = auth(AUTH_READ, AUTH_LIST_ALL, $userdata); 
    379  
    380                         if ( $search_cat != -1 ) 
    381                         { 
    382                                 $auth_sql = "f.cat_id = $search_cat"; 
    383                         } 
    384  
    385                         $ignore_forum_sql = ''; 
    386                         while( list($key, $value) = each($is_auth_ary) ) 
    387                         { 
    388                                 if ( !$value['auth_read'] ) 
    389                                 { 
    390                                         $ignore_forum_sql .= ( ( $ignore_forum_sql != '' ) ? ', ' : '' ) . $key; 
    391                                 } 
    392                         } 
    393  
    394                         if ( $ignore_forum_sql != '' ) 
    395                         { 
    396                                 $auth_sql .= ( $auth_sql != '' ) ? " AND f.forum_id NOT IN ($ignore_forum_sql) " : "f.forum_id NOT IN ($ignore_forum_sql) "; 
    397                         } 
    398                 } 
    399  
    400                 // 
    401                 // Author name search 
    402                 // 
    403                 if ( $search_author != '' ) 
    404                 { 
    405                         $search_author = str_replace('*', '%', trim($search_author)); 
    406  
    407                         if( ( strpos($search_author, '%') !== false ) && ( utf_strlen(str_replace('%', '', $search_author)) < $config['search_min_chars'] ) ) 
    408                         { 
    409                                 $search_author = ''; 
    410                         } 
    411                 } 
    412  
    413                 if ( $total_match_count ) 
    414                 { 
    415                         if ( $show_results == 'topics' ) 
    416                         { 
    417                                 // 
    418                                 // This one is a beast, try to seperate it a bit (workaround for connection timeouts) 
    419                                 // 
    420                                 $search_id_chunks = array(); 
    421                                 $count = 0; 
    422                                 $chunk = 0; 
    423  
    424                                 if (sizeof($search_ids) > $limiter) 
    425                                 { 
    426                                         for ($i = 0; $i < sizeof($search_ids); $i++) 
    427                                         { 
    428                                                 if ($count == $limiter) 
    429                                                 { 
    430                                                         $chunk++; 
    431                                                         $count = 0; 
    432                                                 } 
    433  
    434                                                 $search_id_chunks[$chunk][$count] = $search_ids[$i]; 
    435                                                 $count++; 
    436                                         } 
    437                                 } 
    438                                 else 
    439                                 { 
    440                                         $search_id_chunks[0] = $search_ids; 
    441                                 } 
    442  
    443                                 $search_ids = array(); 
    444  
    445                                 for ($i = 0; $i < sizeof($search_id_chunks); $i++) 
    446                                 { 
    447                                         $where_sql = ''; 
    448  
    449                                         if ( $search_time ) 
    450                                         { 
    451                                                 $where_sql .= ( $search_author == '' && $auth_sql == ''  ) ? " AND post_time >= $search_time " : " AND p.post_time >= $search_time "; 
    452                                         } 
    453  
    454                                         if ( $search_author == '' && $auth_sql == '' ) 
    455                                         { 
    456                                                 $sql = "SELECT topic_id 
    457                                                         FROM " . POSTS_TABLE . " 
    458                                                         WHERE post_id IN (" . implode(", ", $search_id_chunks[$i]) . ") 
    459                                                         $where_sql 
    460                                                         GROUP BY topic_id"; 
    461                                         } 
    462                                         else 
    463                                         { 
    464                                                 $from_sql = POSTS_TABLE . " p"; 
    465  
    466                                                 if ( $search_author != '' ) 
    467                                                 { 
    468                                                         $from_sql .= ", " . USERS_TABLE . " u"; 
    469                                                         $where_sql .= " AND u.uid = p.poster_id AND u.name LIKE '$search_author' "; 
    470                                                 } 
    471  
    472                                                 if ( $auth_sql != '' ) 
    473                                                 { 
    474                                                         $from_sql .= ", " . FORUMS_TABLE . " f"; 
    475                                                         $where_sql .= " AND f.forum_id = p.forum_id AND $auth_sql"; 
    476                                                 } 
    477  
    478                                                 $sql = "SELECT p.topic_id 
    479                                                         FROM $from_sql 
    480                                                         WHERE p.post_id IN (" . implode(", ", $search_id_chunks[$i]) . ") 
    481                                                                 $where_sql 
    482                                                         GROUP BY p.topic_id"; 
    483                                         } 
    484  
    485                                         $result = $db->sql_query($sql); 
    486  
    487                                         while ($row = $db->sql_fetchrow($result)) 
    488                                         { 
    489                                                 $search_ids[] = $row['topic_id']; 
    490                                         } 
    491                                         $db->sql_freeresult($result); 
    492                                 } 
    493  
    494                                 $total_match_count = sizeof($search_ids); 
    495  
    496                         } 
    497                         else if ( $search_author != '' || $search_time || $auth_sql != '' ) 
    498                         { 
    499                                 $search_id_chunks = array(); 
    500                                 $count = 0; 
    501                                 $chunk = 0; 
    502  
    503                                 if (count($search_ids) > $limiter) 
    504                                 { 
    505                                         for ($i = 0; $i < count($search_ids); $i++) 
    506                                         { 
    507                                                 if ($count == $limiter) 
    508                                                 { 
    509                                                         $chunk++; 
    510                                                         $count = 0; 
    511                                                 } 
    512  
    513                                                 $search_id_chunks[$chunk][$count] = $search_ids[$i]; 
    514                                                 $count++; 
    515                                         } 
    516                                 } 
    517                                 else 
    518                                 { 
    519                                         $search_id_chunks[0] = $search_ids; 
    520                                 } 
    521  
    522                                 $search_ids = array(); 
    523  
    524                                 for ($i = 0; $i < count($search_id_chunks); $i++) 
    525                                 { 
    526                                         $where_sql = ( $search_author == '' && $auth_sql == '' ) ? 'post_id IN (' . implode(', ', $search_id_chunks[$i]) . ')' : 'p.post_id IN (' . implode(', ', $search_id_chunks[$i]) . ')'; 
    527                                         $select_sql = ( $search_author == '' && $auth_sql == '' ) ? 'post_id' : 'p.post_id'; 
    528                                         $from_sql = (  $search_author == '' && $auth_sql == '' ) ? POSTS_TABLE : POSTS_TABLE . ' p'; 
    529  
    530                                         if ( $search_time ) 
    531                                         { 
    532                                                 $where_sql .= ( $search_author == '' && $auth_sql == '' ) ? " AND post_time >= $search_time " : " AND p.post_time >= $search_time"; 
    533                                         } 
    534  
    535                                         if ( $auth_sql != '' ) 
    536                                         { 
    537                                                 $from_sql .= ", " . FORUMS_TABLE . " f"; 
    538                                                 $where_sql .= " AND f.forum_id = p.forum_id AND $auth_sql"; 
    539                                         } 
    540  
    541                                         if ( $search_author != '' ) 
    542                                         { 
    543                                                 $from_sql .= ", " . USERS_TABLE . " u"; 
    544                                                 $where_sql .= " AND u.uid = p.poster_id AND u.name LIKE '$search_author'"; 
    545                                         } 
    546  
    547                                         $sql = "SELECT " . $select_sql . " 
    548                                                 FROM $from_sql 
    549                                                 WHERE $where_sql"; 
    550                                         $result = $db->sql_query($sql); 
    551  
    552                                         while( $row = $db->sql_fetchrow($result) ) 
    553                                         { 
    554                                                 $search_ids[] = $row['post_id']; 
    555                                         } 
    556                                         $db->sql_freeresult($result); 
    557                                 } 
    558  
    559                                 $total_match_count = count($search_ids); 
    560                         } 
    561                 } 
    562                 else if ( $search_id == 'unanswered' ) 
    563                 { 
    564                         if ( $auth_sql != '' ) 
    565                         { 
    566                                 $sql = "SELECT t.topic_id, f.forum_id 
    567                                         FROM " . TOPICS_TABLE . "  t, " . FORUMS_TABLE . " f 
    568                                         WHERE t.topic_replies = 0 
    569                                                 AND t.forum_id = f.forum_id 
    570                                                 AND t.topic_moved_id = 0 
    571                                                 AND $auth_sql"; 
    572                         } 
    573                         else 
    574                         { 
    575                                 $sql = "SELECT topic_id 
    576                                         FROM " . TOPICS_TABLE . " 
    577                                         WHERE topic_replies = 0 
    578                                                 AND topic_moved_id = 0"; 
    579                         } 
    580  
    581                         $result = $db->sql_query($sql); 
    582  
    583                         $search_ids = array(); 
    584                         while( $row = $db->sql_fetchrow($result) ) 
    585                         { 
    586                                 $search_ids[] = $row['topic_id']; 
    587                         } 
    588                         $db->sql_freeresult($result); 
    589  
    590                         $total_match_count = count($search_ids); 
    591  
    592                         // 
    593                         // Basic requirements 
    594                         // 
    595                         $show_results = 'topics'; 
    596                         $sort_by = 0; 
    597                         $sort_dir = 'DESC'; 
    598                 } 
    599                 else 
    600                 { 
    601                         trigger_error($lang['no_search_match']); 
    602                         return; 
    603                 } 
    604  
    605                 // 
    606                 // Store new result data 
    607                 // 
    608                 $search_results = implode(', ', $search_ids); 
    609                 $per_page = ( $show_results == 'posts' ) ? $config['posts_per_page'] : $config['topics_per_page']; 
    610  
    611                 // 
    612                 // Combine both results and search data (apart from original query) 
    613                 // so we can serialize it and place it in the DB 
    614                 // 
    615                 $store_search_data = array(); 
    616  
    617                 // 
    618                 // Limit the character length (and with this the results displayed at all following pages) to prevent 
    619                 // truncated result arrays. Normally, search results above 12000 are affected. 
    620                 // - to include or not to include 
    621                 /* 
    622                 $max_result_length = 60000; 
    623                 if (utf_strlen($search_results) > $max_result_length) 
    624                 { 
    625                         $search_results = substr($search_results, 0, $max_result_length); 
    626                         $search_results = substr($search_results, 0, strrpos($search_results, ',')); 
    627                         $total_match_count = count(explode(', ', $search_results)); 
    628                 } 
    629                 */ 
    630  
    631                 for($i = 0; $i < sizeof($store_vars); $i++) 
    632                 { 
    633                         $store_search_data[$store_vars[$i]] = $$store_vars[$i]; 
    634                 } 
    635  
    636                 $result_array = serialize($store_search_data); 
    637                 unset($store_search_data); 
    638  
    639                 $search_id = md5(dss_rand()); 
    640  
    641                 $sql = "UPDATE " . SEARCH_TABLE . " 
    642                         SET search_id = '" . $db->sql_escape($search_id) . "', search_time = $current_time, search_array = '" . $db->sql_escape($result_array) . "' 
    643                         WHERE session_id = '" . $userdata['session_id'] . "'"; 
    644                 if ( !($result = $db->sql_query($sql)) || !$db->sql_affectedrows() ) 
    645                 { 
    646                         $sql = "INSERT INTO " . SEARCH_TABLE . " (search_id, session_id, search_time, search_array) 
    647                                 VALUES('" . $db->sql_escape($search_id) . "', '" . $userdata['session_id'] . "', $current_time, '" . $db->sql_escape($result_array) . "')"; 
    648                         $result = $db->sql_query($sql); 
    649                 } 
    650         } 
    651         else 
    652         { 
    653                 $search_id = intval($search_id); 
    654                 if ( $search_id ) 
    655                 { 
    656                         $sql = "SELECT search_array 
    657                                 FROM " . SEARCH_TABLE . " 
    658                                 WHERE search_id = '" . $db->sql_escape($search_id) . "' 
    659                                         AND session_id = '". $userdata['session_id'] . "'"; 
    660                         $result = $db->sql_query($sql); 
    661  
    662                         if ( $row = $db->sql_fetchrow($result) ) 
    663                         { 
    664                                 $search_data = unserialize($row['search_array']); 
    665                                 for($i = 0; $i < sizeof($store_vars); $i++) 
    666                                 { 
    667                                         $$store_vars[$i] = $search_data[$store_vars[$i]]; 
    668                                 } 
    669                         } 
    670                 } 
    671         } 
    672         // 
    673         // Look up data ... 
    674         // 
    675         if ( $search_results != '' ) 
    676         { 
    677                 if ( $show_results == 'posts' ) 
    678                 { 
    679                         $sql = "SELECT pt.post_text, pt.post_subject, p.*, f.forum_id, f.forum_name, t.*, u.name AS username, u.uid, c.cat_id, c.cat_title, f2.forum_id AS p_forum_id, f2.forum_name AS p_forum_name 
    680                                 FROM " . FORUMS_TABLE . " f LEFT JOIN " . FORUMS_TABLE . " f2 ON ( f.forum_parent = f2.forum_id ), 
    681                                                 " . FORUM_CATEGORIES_TABLE . " c, " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . POSTS_TEXT_TABLE . " pt 
    682                                 WHERE p.post_id IN ($search_results) 
    683                                         AND pt.post_id = p.post_id 
    684                                         AND f.forum_id = p.forum_id 
    685                                         AND p.topic_id = t.topic_id 
    686                                         AND p.poster_id = u.uid 
    687                                                                 AND f.cat_id = c.cat_id"; 
    688                 } 
    689                 else 
    690                 { 
    691                         $sql = "SELECT t.*, f.forum_id, f.forum_name, u.name AS username, u.uid, u2.name as user2, u2.uid as id2, p.post_username, p2.post_username AS post_username2, p2.post_time, c.cat_id, c.cat_title, f2.forum_id AS p_forum_id, f2.forum_name AS p_forum_name 
    692                                 FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f LEFT JOIN " . FORUMS_TABLE . " f2 ON ( f.forum_parent = f2.forum_id )," . FORUM_CATEGORIES_TABLE . " c, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . POSTS_TABLE . " p2, " . USERS_TABLE . " u2 
    693                                 WHERE t.topic_id IN ($search_results) 
    694                                         AND t.topic_poster = u.uid 
    695                                         AND f.forum_id = t.forum_id 
    696                                         AND p.post_id = t.topic_first_post_id 
    697                                         AND p2.post_id = t.topic_last_post_id 
    698                                         AND u2.uid = p2.poster_id 
    699                                                                 AND f.cat_id = c.cat_id"; 
    700                 } 
    701  
    702                 $per_page = ( $show_results == 'posts' ) ? $config['posts_per_page'] : $config['topics_per_page']; 
    703  
    704                         /*if ($userdata['session_logged_in']) 
    705                         { 
    706                                 if ($config['load_db_track'] && $author_id !== $userdata['uid']) 
    707                                 { 
    708                                         $sql_from .= ' LEFT JOIN ' . TOPICS_POSTED_TABLE . ' tp ON (tp.user_id = ' . $userdata['uid'] . ' 
    709                                                 AND t.topic_id = tp.topic_id)'; 
    710                                         $sql_select .= ', tp.topic_posted'; 
    711                                 } 
    712  
    713                                 if ($config['load_db_lastread']) 
    714                                 { 
    715                                         $sql_from .= ' LEFT JOIN ' . TOPICS_TRACK_TABLE . ' tt ON (tt.user_id = ' . $userdata['uid'] . ' 
    716                                                         AND t.topic_id = tt.topic_id) 
    717                                                 LEFT JOIN ' . FORUMS_TRACK_TABLE . ' ft ON (ft.user_id = ' . $userdata['uid'] . ' 
    718                                                         AND ft.forum_id = f.forum_id)'; 
    719                                         $sql_select .= ', tt.mark_time, ft.mark_time as f_mark_time'; 
    720                                 } 
    721                         } 
    722  
    723                         if ($config['load_anon_lastread'] || ($userdata['session_logged_in'] && !$config['load_db_lastread'])) 
    724                         {*/ 
    725                                 $tracking_topics = (isset($_COOKIE[$config['cookie_name'] . '_track'])) ? ((STRIP) ? stripslashes($_COOKIE[$config['cookie_name'] . '_track']) : $_COOKIE[$config['cookie_name'] . '_track']) : ''; 
    726                                 $tracking_topics = ($tracking_topics) ? tracking_unserialize($tracking_topics) : array(); 
    727                         //} 
    728                         $topic_tracking_info = array(); 
    729  
    730                 $sql .= " ORDER BY "; 
    731                 switch ( $sort_by ) 
    732                 { 
    733                         case 1: 
    734                                 $sql .= ( $show_results == 'posts' ) ? 'pt.post_subject' : 't.topic_title'; 
    735                                 break; 
    736                         case 2: 
    737                                 $sql .= 't.topic_title'; 
    738                                 break; 
    739                         case 3: 
    740                                 $sql .= 'u.name'; 
    741                                 break; 
    742                         case 4: 
    743                                 $sql .= 'f.forum_id'; 
    744                                 break; 
    745                         default: 
    746                                 $sql .= ( $show_results == 'posts' ) ? 'p.post_time' : 'p2.post_time'; 
    747                                 break; 
    748                 } 
    749  
    750                 $sql .= ' ' . $sort_dir . ' LIMIT ' . $start . ', ' . $per_page; 
    751  
    752                 $result = $db->sql_query($sql); 
    753  
    754                 $searchset = array(); 
    755                 $forums = array(); 
    756                 while( $row = $db->sql_fetchrow($result) ) 
    757                 { 
    758                         $searchset[] = $row; 
    759  
    760                                         $forums[$row['forum_id']]['topic_list'][] = $row['topic_id']; 
    761                 } 
    762  
    763                         foreach ($forums as $forum_id => $forum) 
    764                         { 
    765                                 /*if ($userdata['session_logged_in'] && $config['load_db_lastread']) 
    766                                 { 
    767                                         $topic_tracking_info[$forum_id] = get_topic_tracking($forum_id, $forum['topic_list'], $forum['rowset'], array($forum_id => $forum['mark_time']), ($forum_id) ? false : $forum['topic_list']); 
    768                                 } 
    769                                 else if ($config['load_anon_lastread'] || $userdata['session_logged_in']) 
    770                                 {*/ 
    771                                         $topic_tracking_info[$forum_id] = get_complete_topic_tracking($forum_id, $forum['topic_list'], ($forum_id) ? false : $forum['topic_list']); 
    772  
    773                                         if (!$userdata['session_logged_in']) 
    774                                         { 
    775                                                 $userdata['user_lastmark'] = (isset($tracking_topics['l'])) ? (int) (base_convert($tracking_topics['l'], 36, 10) + $config['onlinesince']) : 0; 
    776                                         } 
    777                                 //} 
    778                         } 
    779                         unset($forums); 
    780  
    781                 $db->sql_freeresult($result); 
    782  
    783                 // 
    784                 // Define censored word matches 
    785                 // 
    786                 $orig_word = array(); 
    787                 $replacement_word = array(); 
    788                 $cache->obtain_word_list($orig_word, $replacement_word); 
    789  
    790                 // 
    791                 // Output header 
    792                 // 
    793                 stdhead($lang['forums'] . ' :: ' . $lang['search'], false); 
    794  
    795                 if ( $show_results == 'posts' ) 
    796                 { 
    797                         // Topic search MOD 
    798                         if( !$tid ) 
    799                         { 
    800                                 // End Topic search MOD 
    801                                 $template->set_filenames(array( 
    802                                         'body' => 'forum/search_results_posts.tpl') 
    803                                 ); 
    804                         // Topic search MOD 
    805                         } 
    806                         else 
    807                         { 
    808                                 $template->set_filenames(array( 
    809                                         'body' => 'forum/topic_search_results.tpl') 
    810                                 ); 
    811                         } 
    812                         // End Topic search MOD 
    813                 } 
    814                 else 
    815                 { 
    816                         $template->set_filenames(array( 
    817                                 'body' => 'forum/search_results_topics.tpl') 
    818                         ); 
    819                 } 
    820                 //make_jumpbox('viewforum.'.$phpEx); 
    821                 make_jumpbox('phpbb2.php?page=viewforum'); 
    822  
    823                 $l_search_matches = ( $total_match_count == 1 ) ? sprintf($lang['found_search_match'], $total_match_count) : sprintf($lang['found_search_matches'], $total_match_count); 
    824  
    825                 $template->assign_vars(array( 
    826                         'L_SEARCH_MATCHES' => $l_search_matches) 
    827                 ); 
    828  
    829                 $highlight_active = ''; 
    830                 $highlight_match = array(); 
    831                 for($j = 0; $j < sizeof($split_search); $j++ ) 
    832                 { 
    833                         $split_word = $split_search[$j]; 
    834  
    835                         if ( $split_word != 'and' && $split_word != 'or' && $split_word != 'not' ) 
    836                         { 
    837                                 $highlight_match[] = '#\b(' . str_replace("*", "([\w]+)?", $split_word) . ')\b#is'; 
    838                                 $highlight_active .= " " . $split_word; 
    839  
    840                                 for ($k = 0; $k < sizeof($synonym_array); $k++) 
    841                                 { 
    842                                         list($replace_synonym, $match_synonym) = split(' ', trim(utf_strtolower($synonym_array[$k]))); 
    843  
    844                                         if ( $replace_synonym == $split_word ) 
    845                                         { 
    846                                                 $highlight_match[] = '#\b(' . str_replace("*", "([\w]+)?", $replace_synonym) . ')\b#is'; 
    847                                                 $highlight_active .= ' ' . $match_synonym; 
    848                                         } 
    849                                 } 
    850                         } 
    851                 } 
    852  
    853                 $highlight_active = urlencode(trim($highlight_active)); 
    854  
    855                 for($i = 0; $i < sizeof($searchset); $i++) 
    856                 { 
    857  
    858                         $topic_title = $searchset[$i]['topic_title']; 
    859  
    860                         $forum_id = $searchset[$i]['forum_id']; 
    861                         $topic_id = $searchset[$i]['topic_id']; 
    862  
    863                                         // www.phpBB-SEO.com SEO TOOLKIT BEGIN 
    864                                         $seo->set_url($searchset[$i]['cat_id'], $searchset[$i]['cat_title'], $seo->seo_static['forum_cat']); 
    865  
    866                                         if ( !empty($searchset[$i]['p_forum_id']) ) { 
    867                                                 $seo->set_parent($searchset[$i]['p_forum_id'], $seo->seo_static['forum'], $searchset[$i]['cat_id'], $seo->seo_static['forum_cat']); 
    868                                                 $seo->set_url($searchset[$i]['p_forum_name'], $searchset[$i]['p_forum_id'], $seo->seo_static['forum']); 
    869                                                 $seo->set_parent($forum_id, $seo->seo_static['forum'], $searchset[$i]['p_forum_id'], $seo->seo_static['forum']); 
    870                                         } 
    871                                         else { 
    872                                                 $seo->set_parent($forum_id, $seo->seo_static['forum'], $searchset[$i]['cat_id'], $seo->seo_static['forum_cat']); 
    873                                         } 
    874                                         $seo->set_url($searchset[$i]['forum_name'], $forum_id, $seo->seo_static['forum']); 
    875  
    876                                         $seo->set_parent($topic_id, $seo->seo_static['topic'], $forum_id, $seo->seo_static['forum']); 
    877                                         $seo->set_url($topic_title, $topic_id, $seo->seo_static['topic']); 
    878  
    879                                         if ( $show_results != 'posts' ) { 
    880  
    881                                                 $seo->set_user_url($searchset[$i]['username'], $searchset[$i]['uid']); 
    882                                                 $seo->set_user_url($searchset[$i]['user2'], $searchset[$i]['id2']); 
    883                                         } 
    884                                         // www.phpBB-SEO.com SEO TOOLKIT END 
    885  
    886                         //$forum_url = append_sid("viewforum.$phpEx?" . POST_FORUM_URL . '=' . $searchset[$i]['forum_id']); 
    887                         $forum_url = append_sid($root_path . "phpbb2.php?page=viewforum&amp;" . POST_FORUM_URL . '=' . $searchset[$i]['forum_id']); 
    888                         //$topic_url = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . '=' . $searchset[$i]['topic_id'] . "&amp;highlight=$highlight_active"); 
    889                         $topic_url = append_sid($root_path . "phpbb2.php?page=viewtopic&amp;" . POST_TOPIC_URL . '=' . $searchset[$i]['topic_id'] . "&amp;highlight=$highlight_active"); 
    890                         //$post_url = append_sid("viewtopic.$phpEx?" . POST_POST_URL . '=' . $searchset[$i]['post_id'] . "&amp;highlight=$highlight_active") . '#' . $searchset[$i]['post_id']; 
    891  
    892                         $post_date = create_date($searchset[$i]['post_time']); 
    893  
    894                         if ( $show_results == 'posts' ) 
    895                         { 
    896                                         $message = $searchset[$i]['post_text']; 
    897                                         $post_url = append_sid($root_path . "phpbb2.php?page=viewtopic&amp;" . POST_POST_URL . '=' . $searchset[$i]['post_id'] . "&amp;highlight=$highlight_active") . '#' . $searchset[$i]['post_id']; 
    898  
    899                                 if ( isset($return_chars) ) 
    900                                 { 
    901  
    902                                         // 
    903                                         // If the board has HTML off but the post has HTML 
    904                                         // on then we process it, else leave it alone 
    905                                         // 
    906                                         if ( $return_chars != -1 ) 
    907                                         { 
    908                                                 $message = strip_tags($message); 
    909                                                 $message = preg_replace('/\[url\]|\[\/url\]/si', '', $message); 
    910                                                 $message = ( utf_strlen($message) > $return_chars ) ? substr($message, 0, $return_chars) . ' ...' : $message; 
    911                                         } 
    912                                         else 
    913                                         { 
    914                                                 if ( !$config['allow_html'] ) 
    915                                                 { 
    916                                                         if ( $searchset[$i]['enable_html'] ) 
    917                                                         { 
    918                                                                 $message = preg_replace('#(<)([\/]?.*?)(>)#is', '&lt;\\2&gt;', $message); 
    919                                                         } 
    920                                                 } 
    921  
    922                                                                         $bb_code->parse($message); 
    923                                                                         $message = $bb_code->get_html(); 
    924  
    925                                                 if ( $highlight_active ) 
    926                                                 { 
    927                                                         if ( preg_match('/<.*>/', $message) ) 
    928                                                         { 
    929                                                                 $message = preg_replace($highlight_match, '<!-- #sh -->\1<!-- #eh -->', $message); 
    930  
    931                                                                 $end_html = 0; 
    932                                                                 $start_html = 1; 
    933                                                                 $temp_message = ''; 
    934                                                                 $message = ' ' . $message . ' '; 
    935  
    936                                                                 while( $start_html = strpos($message, '<', $start_html) ) 
    937                                                                 { 
    938                                                                         $grab_length = $start_html - $end_html - 1; 
    939                                                                         $temp_message .= substr($message, $end_html + 1, $grab_length); 
    940  
    941                                                                         if ( $end_html = strpos($message, '>', $start_html) ) 
    942                                                                         { 
    943                                                                                 $length = $end_html - $start_html + 1; 
    944                                                                                 $hold_string = substr($message, $start_html, $length); 
    945  
    946                                                                                 if ( strrpos(' ' . $hold_string, '<') != 1 ) 
    947                                                                                 { 
    948                                                                                         $end_html = $start_html + 1; 
    949                                                                                         $end_counter = 1; 
    950  
    951                                                                                         while ( $end_counter && $end_html < utf_strlen($message) ) 
    952                                                                                         { 
    953                                                                                                 if ( substr($message, $end_html, 1) == '>' ) 
    954                                                                                                 { 
    955                                                                                                         $end_counter--; 
    956                                                                                                 } 
    957                                                                                                 else if ( substr($message, $end_html, 1) == '<' ) 
    958                                                                                                 { 
    959                                                                                                         $end_counter++; 
    960                                                                                                 } 
    961  
    962                                                                                                 $end_html++; 
    963                                                                                         } 
    964  
    965                                                                                         $length = $end_html - $start_html + 1; 
    966                                                                                         $hold_string = substr($message, $start_html, $length); 
    967                                                                                         $hold_string = str_replace('<!-- #sh -->', '', $hold_string); 
    968                                                                                         $hold_string = str_replace('<!-- #eh -->', '', $hold_string); 
    969                                                                                 } 
    970                                                                                 else if ( $hold_string == '<!-- #sh -->' ) 
    971                                                                                 { 
    972                                                                                         $hold_string = str_replace('<!-- #sh -->', '<span style="color:#' . $theme['fontcolor3'] . '"><b>', $hold_string); 
    973                                                                                 } 
    974                                                                                 else if ( $hold_string == '<!-- #eh -->' ) 
    975                                                                                 { 
    976                                                                                         $hold_string = str_replace('<!-- #eh -->', '</b></span>', $hold_string); 
    977                                                                                 } 
    978  
    979                                                                                 $temp_message .= $hold_string; 
    980  
    981                                                                                 $start_html += $length; 
    982                                                                         } 
    983                                                                         else 
    984                                                                         { 
    985                                                                                 $start_html = utf_strlen($message); 
    986                                                                         } 
    987                                                                 } 
    988  
    989                                                                 $grab_length = utf_strlen($message) - $end_html - 1; 
    990                                                                 $temp_message .= substr($message, $end_html + 1, $grab_length); 
    991  
    992                                                                 $message = trim($temp_message); 
    993                                                         } 
    994                                                         else 
    995                                                         { 
    996                                                                 $message = preg_replace($highlight_match, '<span style="color:#' . $theme['fontcolor3'] . '"><b>\1</b></span>', $message); 
    997                                                         } 
    998                                                 } 
    999                                         } 
    1000  
    1001                                         $topic_title = censor_text($topic_title); 
    1002                                         $post_subject = ( $searchset[$i]['post_subject'] != '' ) ? censor_text($searchset[$i]['post_subject']) : $topic_title; 
    1003                                         $message = censor_text($message); 
    1004  
    1005                                         $message = str_replace("\n", '<br />', $message); 
    1006  
    1007                                 } 
    1008  
    1009                                 $poster = ( $searchset[$i]['uid'] != ANONYMOUS ) ? '<a href="' . append_sid($root_path . "userdetails.php?id=" . $searchset[$i]['uid']) . '">' : ''; 
    1010                                 $poster .= ( $searchset[$i]['uid'] != ANONYMOUS ) ? $searchset[$i]['username'] : ( ( $searchset[$i]['post_username'] != "" ) ? $searchset[$i]['post_username'] : $lang['guest'] ); 
    1011                                 $poster .= ( $searchset[$i]['uid'] != ANONYMOUS ) ? '</a>' : ''; 
    1012  
    1013                                 /*if ( $userdata['session_logged_in'] && $searchset[$i]['post_time'] > $userdata['user_lastvisit'] ) 
    1014                                 { 
    1015                                         $topic_last_read = 0; 
    1016                                         if ( !empty($tracking_topics[$topic_id]) && !empty($tracking_forums[$forum_id]) ) 
    1017                                         { 
    1018                                                 $topic_last_read = ( $tracking_topics[$topic_id] > $tracking_forums[$forum_id] ) ? $tracking_topics[$topic_id] : $tracking_forums[$forum_id]; 
    1019                                         } 
    1020                                         else if ( !empty($tracking_topics[$topic_id]) || !empty($tracking_forums[$forum_id]) ) 
    1021                                         { 
    1022                                                 $topic_last_read = ( !empty($tracking_topics[$topic_id]) ) ? $tracking_topics[$topic_id] : $tracking_forums[$forum_id]; 
    1023                                         } 
    1024  
    1025                                         if ( $searchset[$i]['post_time'] > $topic_last_read ) 
    1026                                         { 
    1027                                                 $mini_post_img = $images['icon_minipost_new']; 
    1028                                                 $mini_post_alt = $lang['new_post']; 
    1029                                         } 
    1030                                         else 
    1031                                         { 
    1032                                                 $mini_post_img = $images['icon_minipost']; 
    1033                                                 $mini_post_alt = $lang['post']; 
    1034                                         } 
    1035                                 } 
    1036                                 else 
    1037                                 { 
    1038                                         $mini_post_img = $images['icon_minipost']; 
    1039                                         $mini_post_alt = $lang['post']; 
    1040                                 }*/ 
    1041  
    1042                                 $unread_topic = (isset($topic_tracking_info[$forum_id][$topic_id]) && $searchset[$i]['post_time'] > $topic_tracking_info[$forum_id][$topic_id]) ? true : false; 
    1043  
    1044                                 if ( $unread_topic ) 
    1045                                         { 
    1046                                                 $mini_post_img = $images['icon_minipost_new']; 
    1047                                                 $mini_post_alt = $lang['new_post']; 
    1048                                         } 
    1049                                         else 
    1050                                         { 
    1051                                                 $mini_post_img = $images['icon_minipost']; 
    1052                                                 $mini_post_alt = $lang['post']; 
    1053                                         } 
    1054  
    1055                                 $template->assign_block_vars("searchresults", array( 
    1056                                         'TOPIC_TITLE' => $topic_title, 
    1057                                         'FORUM_NAME' => $searchset[$i]['forum_name'], 
    1058                                         'POST_SUBJECT' => $post_subject, 
    1059                                         'POST_DATE' => $post_date, 
    1060                                         'POSTER_NAME' => $poster, 
    1061                                         'TOPIC_REPLIES' => $searchset[$i]['topic_replies'], 
    1062                                         'TOPIC_VIEWS' => $searchset[$i]['topic_views'], 
    1063                                         'MESSAGE' => $message, 
    1064                                         'MINI_POST_IMG' => $mini_post_img, 
    1065  
    1066                                         'L_MINI_POST_ALT' => $mini_post_alt, 
    1067  
    1068                                         'U_POST' => $post_url, 
    1069                                         'U_TOPIC' => $topic_url, 
    1070                                         'U_FORUM' => $forum_url) 
    1071                                 ); 
    1072                         } 
    1073                         else 
    1074                         { 
    1075                                 $message = ''; 
    1076  
    1077                                 if ( count($orig_word) ) 
    1078                                 { 
    1079                                         $topic_title = preg_replace($orig_word, $replacement_word, $searchset[$i]['topic_title']); 
    1080                                 } 
    1081  
    1082                                 $topic_type = $searchset[$i]['topic_type']; 
    1083  
    1084                                 if ($topic_type == POST_ANNOUNCE) 
    1085                                 { 
    1086                                         $topic_type = $lang['topic_announcement'] . ' '; 
    1087                                 } 
    1088                                 else if ($topic_type == POST_STICKY) 
    1089                                 { 
    1090                                         $topic_type = $lang['topic_sticky'] . ' '; 
    1091                                 } 
    1092                                 else 
    1093                                 { 
    1094                                         $topic_type = ''; 
    1095                                 } 
    1096  
    1097                                 if ( $searchset[$i]['topic_vote'] ) 
    1098                                 { 
    1099                                         $topic_type .= $lang['topic_poll'] . ' '; 
    1100                                 } 
    1101  
    1102                                 $views = $searchset[$i]['topic_views']; 
    1103                                 $replies = $searchset[$i]['topic_replies']; 
    1104  
    1105                                 if ( ( $replies + 1 ) > $config['posts_per_page'] ) 
    1106                                 { 
    1107                                         $total_pages = ceil( ( $replies + 1 ) / $config['posts_per_page'] ); 
    1108                                         //$goto_page = ' [ <img src="' . $images['icon_gotopost'] . '" alt="' . $lang['goto_page'] . '" title="' . $lang['goto_page'] . '" />' . $lang['goto_page'] . ': '; 
    1109                                         $goto_page = ' [ <img src="' . $images['icon_gotopost'] . '" alt="' . $lang['goto_page'] . '" title="' . $lang['goto_page'] . '" />' . $lang['goto_page'] . ': '; 
    1110  
    1111                                         $times = 1; 
    1112                                         for($j = 0; $j < $replies + 1; $j += $config['posts_per_page']) 
    1113                                         { 
    1114                                                 //$goto_page .= '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=" . $topic_id . "&amp;start=$j") . '">' . $times . '</a>'; 
    1115                                                 $goto_page .= '<a href="' . append_sid($root_path . "phpbb2.php?page=viewtopic&amp;" . POST_TOPIC_URL . "=" . $topic_id . "&amp;start=$j") . '">' . $times . '</a>'; 
    1116                                                 if ( $times == 1 && $total_pages > 4 ) 
    1117                                                 { 
    1118                                                         $goto_page .= ' ... '; 
    1119                                                         $times = $total_pages - 3; 
    1120                                                         $j += ( $total_pages - 4 ) * $config['posts_per_page']; 
    1121                                                 } 
    1122                                                 else if ( $times < $total_pages ) 
    1123                                                 { 
    1124                                                         $goto_page .= ', '; 
    1125                                                 } 
    1126                                                 $times++; 
    1127                                         } 
    1128                                         $goto_page .= ' ] '; 
    1129                                 } 
    1130                                 else 
    1131                                 { 
    1132                                         $goto_page = ''; 
    1133                                 } 
    1134  
    1135                                 if ( $searchset[$i]['topic_status'] == TOPIC_MOVED ) 
    1136                                 { 
    1137                                         $topic_type = $lang['topic_moved'] . ' '; 
    1138                                         $topic_id = $searchset[$i]['topic_moved_id']; 
    1139  
    1140                                         //$folder_image = '<img src="' . $images['folder'] . '" alt="' . $lang['no_new_posts'] . '" />'; 
    1141                                         $folder_image = '<img src="' . $images['folder'] . '" alt="' . $lang['no_new_posts'] . '" />'; 
    1142                                         $newest_post_img = ''; 
    1143                                 } 
    1144                                 else 
    1145                                 { 
    1146                                         if ( $searchset[$i]['topic_status'] == TOPIC_LOCKED ) 
    1147                                         { 
    1148                                                 $folder = $images['folder_locked']; 
    1149                                                 $folder_new = $images['folder_locked_new']; 
    1150                                         } 
    1151                                         else if ( $searchset[$i]['topic_type'] == POST_ANNOUNCE ) 
    1152                                         { 
    1153                                                 $folder = $images['folder_announce']; 
    1154                                                 $folder_new = $images['folder_announce_new']; 
    1155                                         } 
    1156                                         else if ( $searchset[$i]['topic_type'] == POST_STICKY ) 
    1157                                         { 
    1158                                                 $folder = $images['folder_sticky']; 
    1159                                                 $folder_new = $images['folder_sticky_new']; 
    1160                                         } 
    1161                                         else 
    1162                                         { 
    1163                                                 if ( $replies >= $config['hot_threshold'] ) 
    1164                                                 { 
    1165                                                         $folder = $images['folder_hot']; 
    1166                                                         $folder_new = $images['folder_hot_new']; 
    1167                                                 } 
    1168                                                 else 
    1169                                                 { 
    1170                                                         $folder = $images['folder']; 
    1171                                                         $folder_new = $images['folder_new']; 
    1172                                                 } 
    1173                                         } 
    1174  
    1175                                         /*if ( $userdata['session_logged_in'] ) 
    1176                                         { 
    1177                                                 if ( $searchset[$i]['post_time'] > $userdata['user_lastvisit'] ) 
    1178                                                 { 
    1179                                                         if ( !empty($tracking_topics) || !empty($tracking_forums) || isset($_COOKIE[$config['cookie_name'] . '_f_all']) ) 
    1180                                                         { 
    1181  
    1182                                                                 $unread_topics = true; 
    1183  
    1184                                                                 if ( !empty($tracking_topics[$topic_id]) ) 
    1185                                                                 { 
    1186                                                                         if ( $tracking_topics[$topic_id] > $searchset[$i]['post_time'] ) 
    1187                                                                         { 
    1188                                                                                 $unread_topics = false; 
    1189                                                                         } 
    1190                                                                 } 
    1191  
    1192                                                                 if ( !empty($tracking_forums[$forum_id]) ) 
    1193                                                                 { 
    1194                                                                         if ( $tracking_forums[$forum_id] > $searchset[$i]['post_time'] ) 
    1195                                                                         { 
    1196                                                                                 $unread_topics = false; 
    1197                                                                         } 
    1198                                                                 } 
    1199  
    1200                                                                 if ( isset($_COOKIE[$config['cookie_name'] . '_f_all']) ) 
    1201                                                                 { 
    1202                                                                         if ( $_COOKIE[$config['cookie_name'] . '_f_all'] > $searchset[$i]['post_time'] ) 
    1203                                                                         { 
    1204                                                                                 $unread_topics = false; 
    1205                                                                         } 
    1206                                                                 }*/ 
    1207  
    1208                                                                 $unread_topics = (isset($topic_tracking_info[$forum_id][$topic_id]) && $searchset[$i]['post_time'] > $topic_tracking_info[$forum_id][$topic_id]) ? true : false; 
    1209  
    1210                                                                 if ( $unread_topics ) 
    1211                                                                 { 
    1212                                                                         $folder_image = $folder_new; 
    1213                                                                         $folder_alt = $lang['new_posts']; 
    1214  
    1215                                                                         //$newest_post_img = '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;view=newest") . '"><img src="' . $images['icon_newest_reply'] . '" alt="' . $lang['view_newest_post'] . '" title="' . $lang['view_newest_post'] . '" border="0" /></a> '; 
    1216                                                                         $newest_post_img = '<a href="' . append_sid($root_path . "phpbb2.php?page=viewtopic&amp;" . POST_TOPIC_URL . "=$topic_id&amp;view=newest") . '"><img src="' . $images['icon_newest_reply'] . '" alt="' . $lang['view_newest_post'] . '" title="' . $lang['view_newest_post'] . '" border="0" /></a> '; 
    1217                                                                 } 
    1218                                                                 else 
    1219                                                                 { 
    1220                                                                         $folder_alt = ( $searchset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['topic_locked'] : $lang['no_new_posts']; 
    1221  
    1222                                                                         $folder_image = $folder; 
    1223                                                                         $folder_alt = $folder_alt; 
    1224                                                                         $newest_post_img = ''; 
    1225                                                                 } 
    1226  
    1227                                                         /*} 
    1228                                                         else if ( $searchset[$i]['post_time'] > $userdata['user_lastvisit'] ) 
    1229                                                         { 
    1230                                                                 $folder_image = $folder_new; 
    1231                                                                 $folder_alt = $lang['new_posts']; 
    1232  
    1233                                                                 //$newest_post_img = '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;view=newest") . '"><img src="' . $images['icon_newest_reply'] . '" alt="' . $lang['view_newest_post'] . '" title="' . $lang['view_newest_post'] . '" border="0" /></a> '; 
    1234                                                                 $newest_post_img = '<a href="' . append_sid($root_path . "phpbb2.php?page=viewtopic&amp;" . POST_TOPIC_URL . "=$topic_id&amp;view=newest") . '"><img src="' . $images['icon_newest_reply'] . '" alt="' . $lang['view_newest_post'] . '" title="' . $lang['view_newest_post'] . '" border="0" /></a> '; 
    1235                                                         } 
    1236                                                         else 
    1237                                                         { 
    1238                                                                 $folder_image = $folder; 
    1239                                                                 $folder_alt = ( $searchset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['topic_locked'] : $lang['no_new_posts']; 
    1240                                                                 $newest_post_img = ''; 
    1241                                                         } 
    1242                                                 } 
    1243                                                 else 
    1244                                                 { 
    1245                                                         $folder_image = $folder; 
    1246                                                         $folder_alt = ( $searchset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['topic_locked'] : $lang['no_new_posts']; 
    1247                                                         $newest_post_img = ''; 
    1248                                                 } 
    1249                                         } 
    1250                                         else 
    1251                                         { 
    1252                                                 $folder_image = $folder; 
    1253                                                 $folder_alt = ( $searchset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['topic_locked'] : $lang['no_new_posts']; 
    1254                                                 $newest_post_img = ''; 
    1255                                         }*/ 
    1256                                 } 
    1257  
    1258  
    1259                                 $topic_author = ( $searchset[$i]['uid'] != ANONYMOUS ) ? '<a href="' . append_sid($root_path . "userdetails.php?id=" . $searchset[$i]['uid']) . '">' : ''; 
    1260                                 $topic_author .= ( $searchset[$i]['uid'] != ANONYMOUS ) ? $searchset[$i]['username'] : ( ( $searchset[$i]['post_username'] != '' ) ? $searchset[$i]['post_username'] : $lang['guest'] ); 
    1261  
    1262                                 $topic_author .= ( $searchset[$i]['uid'] != ANONYMOUS ) ? '</a>' : ''; 
    1263  
    1264                                 $first_post_time = create_date($searchset[$i]['topic_time']); 
    1265  
    1266                                 $last_post_time = create_date($searchset[$i]['post_time']); 
    1267  
    1268                                 $last_post_author = ( $searchset[$i]['id2'] == ANONYMOUS ) ? ( ($searchset[$i]['post_username2'] != '' ) ? $searchset[$i]['post_username2'] . ' ' : $lang['guest'] . ' ' ) : '<a href="' . append_sid($root_path . "userdetails.php?id="  . $searchset[$i]['id2']) . '">' . $searchset[$i]['user2'] . '</a>'; 
    1269  
    1270                                 $last_post_url = '<a href="' . append_sid($root_path . "phpbb2.php?page=viewtopic&amp;"  . POST_POST_URL . '=' . $searchset[$i]['topic_last_post_id']) . '#' . $searchset[$i]['topic_last_post_id'] . '"><img src="' . $images['icon_latest_reply'] . '" alt="' . $lang['view_latest_post'] . '" title="' . $lang['view_latest_post'] . '" border="0" /></a>'; 
    1271  
    1272                                 $template->assign_block_vars('searchresults', array( 
    1273                                         'FORUM_NAME' => $searchset[$i]['forum_name'], 
    1274                                         'FORUM_ID' => $forum_id, 
    1275                                         'TOPIC_ID' => $topic_id, 
    1276                                         'FOLDER' => $folder_image, 
    1277                                         'NEWEST_POST_IMG' => $newest_post_img, 
    1278                                         'TOPIC_FOLDER_IMG' => $folder_image, 
    1279                                         'GOTO_PAGE' => $goto_page, 
    1280                                         'REPLIES' => $replies, 
    1281                                         'TOPIC_TITLE' => $topic_title, 
    1282                                         'TOPIC_TYPE' => $topic_type, 
    1283                                         'VIEWS' => $views, 
    1284                                         'TOPIC_AUTHOR' => $topic_author, 
    1285                                         'FIRST_POST_TIME' => $first_post_time, 
    1286                                         'LAST_POST_TIME' => $last_post_time, 
    1287                                         'LAST_POST_AUTHOR' => $last_post_author, 
    1288                                         'LAST_POST_IMG' => $last_post_url, 
    1289  
    1290                                         'L_TOPIC_FOLDER_ALT' => $folder_alt, 
    1291  
    1292                                         'U_VIEW_FORUM' => $forum_url, 
    1293                                         'U_VIEW_TOPIC' => $topic_url) 
    1294                                 ); 
    1295                         } 
    1296                 } 
    1297                 // Topic search MOD 
    1298                 if( !$tid ) 
    1299                 { 
    1300                 // End Topic search MOD 
    1301                         $base_url = "phpbb2.php?page=search&amp;search_id=$search_id&amp;search_author=$search_author"; 
    1302                 // Topic search MOD 
    1303                 } 
    1304                 else 
    1305                 { 
    1306                         $base_url = "phpbb2.php?page=search&amp;search_id=$search_id&amp;topic_id=$tid"; 
    1307                 } 
    1308                 // End Topic search MOD 
    1309  
    1310                 $template->assign_vars(array( 
    1311                         'PAGINATION' => generate_pagination($root_path . $base_url, $total_match_count, $per_page, $start), 
    1312                         'PAGE_NUMBER' => sprintf($lang['page_of'], ( floor( $start / $per_page ) + 1 ), ceil( $total_match_count / $per_page )), 
    1313                 )); 
    1314                 return; 
    1315         } 
    1316         else 
    1317         { 
    1318                 trigger_error($lang['no_search_match']); 
    1319                 return; 
    1320         } 
     92        $store_vars = array('search_results', 'total_match_count', 'split_search', 'sort_by', 'sort_dir', 'show_results', 'return_chars'); 
     93        $search_results = ''; 
     94        // Topic search MOD 
     95        $tid = request_var('topic_id', 0); 
     96        // Topic search MOD 
     97 
     98        // 
     99        // Search ID Limiter, decrease this value if you experience further timeout problems with searching forums 
     100        $limiter = 5000; 
     101        $current_time = time(); 
     102        $total_match_count = 0; 
     103 
     104        // 
     105        // Cycle through options ... 
     106        // 
     107        if ( $search_id == 'newposts' || $search_id == 'egosearch' || $search_id == 'unanswered' || $search_keywords != '' || $search_author != '' ) 
     108        { 
     109                // 
     110                // Flood control 
     111                // 
     112                $where_sql = ($userdata['uid'] == ANONYMOUS) ? "se.session_ip = '$user_ip'" : 'se.session_user_id = ' . $userdata['uid']; 
     113                $sql = 'SELECT MAX(sr.search_time) AS last_search_time 
     114                                FROM ' . SEARCH_TABLE . ' sr, ' . SESSIONS_TABLE . " se 
     115                                WHERE sr.session_id = se.session_id 
     116                                AND $where_sql"; 
     117                $result = $db->sql_query($sql); 
     118                if ( $row = $db->sql_fetchrow($result) ) { 
     119                        if ( $row['last_search_time'] > 0 && ($current_time - $row['last_search_time']) < $config['search_flood_interval'] ) { 
     120                                $wait_time = intval($config['search_flood_interval']) - ($current_time - intval($row['last_search_time'])); 
     121                                trigger_error(sprintf($lang['search_flood_error'], $wait_time)); 
     122                        } 
     123                } 
     124 
     125                if ( $search_id == 'newposts' || $search_id == 'egosearch' || ( $search_author != '' && $search_keywords == '' )  ) 
     126                { 
     127                        if ( $search_id == 'newposts' ) 
     128                        { 
     129 
     130                                loggedinorreturn(); 
     131 
     132                                $topic_ids = get_unread_topics(); 
     133 
     134                                if ( sizeof($topic_ids) ) { 
     135                                        $topic_ids = array_keys($topic_ids); 
     136                                        $sql = 'SELECT post_id FROM ' . POSTS_TABLE . ' WHERE ' . $db->sql_in_set('topic_id', $topic_ids); 
     137                                } 
     138                                else { 
     139                                        $sql = false; 
     140                                } 
     141 
     142                                $show_results = 'topics'; 
     143                                $sort_by = 0; 
     144                                $sort_dir = 'DESC'; 
     145                        } 
     146                        else if ( $search_id == 'egosearch' ) 
     147                        { 
     148                                loggedinorreturn(); 
     149 
     150                                $sql = "SELECT post_id FROM " . POSTS_TABLE . " WHERE poster_id = " . $userdata['uid']; 
     151 
     152                                $show_results = 'topics'; 
     153                                $sort_by = 0; 
     154                                $sort_dir = 'DESC'; 
     155                        } 
     156                        else 
     157                        { 
     158                                $search_author = str_replace('*', '%', trim($search_author)); 
     159 
     160                                if( ( strpos($search_author, '%') !== false ) && ( utf_strlen(str_replace('%', '', $search_author)) < $config['search_min_chars'] ) ) 
     161                                { 
     162                                        $search_author = ''; 
     163                                } 
     164 
     165                                $sql = "SELECT uid FROM " . USERS_TABLE . " WHERE name LIKE '" . $db->sql_escape($search_author) . "'"; 
     166                                $result = $db->sql_query($sql); 
     167 
     168                                $matching_userids = ''; 
     169                                if ( $row = $db->sql_fetchrow($result) ) 
     170                                { 
     171                                        do 
     172                                        { 
     173                                                $matching_userids .= ( ( $matching_userids != '' ) ? ', ' : '' ) . $row['uid']; 
     174                                        } 
     175                                        while( $row = $db->sql_fetchrow($result) ); 
     176                                } 
     177                                else 
     178                                { 
     179                                        trigger_error($lang['no_search_match']); 
     180                                } 
     181 
     182                                $sql = "SELECT post_id FROM " . POSTS_TABLE . " WHERE poster_id IN ($matching_userids)"; 
     183 
     184                                if ($search_time) 
     185                                { 
     186                                        $sql .= " AND post_time >= " . $search_time; 
     187                                } 
     188                        } 
     189 
     190                        $result = $db->sql_query($sql); 
     191 
     192                        $search_ids = array(); 
     193                        while( $row = $db->sql_fetchrow($result) ) 
     194                        { 
     195                                $search_ids[] = $row['post_id']; 
     196                        } 
     197 
     198                        $db->sql_freeresult($result); 
     199 
     200                        $total_match_count = sizeof($search_ids); 
     201 
     202                } 
     203                else if ( $search_keywords != '' ) 
     204                { 
     205                        $stopword_array = @file($root_path . 'languages/lang_' . $config['default_lang'] . '/search_stopwords.txt'); 
     206                        $synonym_array = @file($root_path . 'languages/lang_' . $config['default_lang'] . '/search_synonyms.txt'); 
     207 
     208                        $stripped_keywords = ( STRIP ? stripslashes($search_keywords) : $search_keywords ); 
     209                        $split_search = split_words(clean_words('search', $stripped_keywords, $stopword_array, $synonym_array), 'search'); 
     210                        unset($stripped_keywords); 
     211 
     212                        $search_msg_only = ( !$search_fields ) ? "AND m.title_match = 0" : ''; 
     213 
     214                        $word_count = 0; 
     215                        $current_match_type = 'or'; 
     216 
     217                        $word_match = array(); 
     218                        $result_list = array(); 
     219 
     220                        for($i = 0; $i < sizeof($split_search); $i++) 
     221                        { 
     222                                if ( utf_strlen(str_replace(array('*', '%'), '', trim($split_search[$i]))) < $config['search_min_chars'] ) 
     223                                { 
     224                                        $split_search[$i] = ''; 
     225                                        continue; 
     226                                } 
     227 
     228                                switch ( $split_search[$i] ) 
     229                                { 
     230                                        case 'and': 
     231                                                $current_match_type = 'and'; 
     232                                                break; 
     233 
     234                                        case 'or': 
     235                                                $current_match_type = 'or'; 
     236                                                break; 
     237 
     238                                        case 'not': 
     239                                                $current_match_type = 'not'; 
     240                                                break; 
     241 
     242                                        default: 
     243                                                if ( !empty($search_terms) ) 
     244                                                { 
     245                                                        $current_match_type = 'and'; 
     246                                                } 
     247 
     248                                                $match_word = str_replace('*', '%', $split_search[$i]); 
     249                                                $sql = "SELECT m.post_id 
     250                                                                FROM " . SEARCH_WORD_TABLE . " w, " . SEARCH_MATCH_TABLE . " m 
     251                                                                WHERE w.word_text LIKE '$match_word' 
     252                                                                        AND m.word_id = w.word_id 
     253                                                                        AND w.word_common <> 1 
     254                                                                        $search_msg_only"; 
     255                                                $result = $db->sql_query($sql); 
     256 
     257                                                $row = array(); 
     258                                                while( $temp_row = $db->sql_fetchrow($result) ) 
     259                                                { 
     260                                                        $row[$temp_row['post_id']] = 1; 
     261 
     262                                                        if ( !$word_count ) 
     263                                                        { 
     264                                                                $result_list[$temp_row['post_id']] = 1; 
     265                                                        } 
     266                                                        else if ( $current_match_type == 'or' ) 
     267                                                        { 
     268                                                                $result_list[$temp_row['post_id']] = 1; 
     269                                                        } 
     270                                                        else if ( $current_match_type == 'not' ) 
     271                                                        { 
     272                                                                $result_list[$temp_row['post_id']] = 0; 
     273                                                        } 
     274                                                } 
     275 
     276                                                if ( $current_match_type == 'and' && $word_count ) 
     277                                                { 
     278                                                        @reset($result_list); 
     279                                                        while( list($post_id, $match_count) = @each($result_list) ) 
     280                                                        { 
     281                                                                if ( !$row[$post_id] ) 
     282                                                                { 
     283                                                                        $result_list[$post_id] = 0; 
     284                                                                } 
     285                                                        } 
     286                                                } 
     287 
     288                                                $word_count++; 
     289 
     290                                                $db->sql_freeresult($result); 
     291                                        } 
     292                        } 
     293 
     294                        @reset($result_list); 
     295 
     296                        $search_ids = array(); 
     297                        while( list($post_id, $matches) = each($result_list) ) 
     298                        { 
     299                                if ( $matches ) 
     300                                { 
     301 
     302                                        // Topic Search MOD 
     303                                        if($tid) 
     304                                        { 
     305                                                $sql = "SELECT post_id 
     306                                                        FROM " . POSTS_TABLE . " 
     307                                                        WHERE topic_id = '$tid'"; 
     308                                                $result = $db->sql_query($sql); 
     309                                                while( $test = $db->sql_fetchrow($result) ) 
     310                                                { 
     311                                                        if($test['post_id'] == $post_id) 
     312                                                        { 
     313                                                                $search_ids[] = $post_id; 
     314                                                        } 
     315                                                } 
     316                                                $show_results = 'posts'; 
     317                                        } 
     318                                        else 
     319                                        { // End Topic Search MOD 
     320 
     321                                        $search_ids[] = $post_id; 
     322                                        // Topic Search MOD 
     323                                        } 
     324                                        // End Topic search MOD 
     325                                } 
     326                        } 
     327 
     328                        unset($result_list); 
     329                        $total_match_count = sizeof($search_ids); 
     330                } 
     331 
     332                // 
     333                // If user is logged in then we'll check to see which (if any) private 
     334                // forums they are allowed to view and include them in the search. 
     335                // 
     336                // If not logged in we explicitly prevent searching of private forums 
     337                // 
     338                $auth_sql = ''; 
     339                if ( $search_forum != -1 ) 
     340                { 
     341                        $is_auth = auth(AUTH_READ, $search_forum, $userdata); 
     342 
     343                        if ( !$is_auth['auth_read'] ) 
     344                        { 
     345                                trigger_error($lang['no_searchable_forums']); 
     346                                return; 
     347                        } 
     348 
     349                        $auth_sql = "f.forum_id = $search_forum"; 
     350                } 
     351                else 
     352                { 
     353                        $is_auth_ary = auth(AUTH_READ, AUTH_LIST_ALL, $userdata); 
     354 
     355                        if ( $search_cat != -1 ) 
     356                        { 
     357                                $auth_sql = "f.cat_id = $search_cat"; 
     358                        } 
     359 
     360                        $ignore_forum_sql = ''; 
     361                        while( list($key, $value) = each($is_auth_ary) ) 
     362                        { 
     363                                if ( !$value['auth_read'] ) 
     364                                { 
     365                                        $ignore_forum_sql .= ( ( $ignore_forum_sql != '' ) ? ', ' : '' ) . $key; 
     366                                } 
     367                        } 
     368 
     369                        if ( $ignore_forum_sql != '' ) 
     370                        { 
     371                                $auth_sql .= ( $auth_sql != '' ) ? " AND f.forum_id NOT IN ($ignore_forum_sql) " : "f.forum_id NOT IN ($ignore_forum_sql) "; 
     372                        } 
     373                } 
     374 
     375                // 
     376                // Author name search 
     377                // 
     378                if ( $search_author != '' ) 
     379                { 
     380                        $search_author = str_replace('*', '%', trim($search_author)); 
     381 
     382                        if( ( strpos($search_author, '%') !== false ) && ( utf_strlen(str_replace('%', '', $search_author)) < $config['search_min_chars'] ) ) 
     383                        { 
     384                                $search_author = ''; 
     385                        } 
     386                } 
     387 
     388                if ( $total_match_count ) 
     389                { 
     390                        if ( $show_results == 'topics' ) 
     391                        { 
     392                                // 
     393                                // This one is a beast, try to seperate it a bit (workaround for connection timeouts) 
     394                                // 
     395                                $search_id_chunks = array(); 
     396                                $count = 0; 
     397                                $chunk = 0; 
     398 
     399                                if (sizeof($search_ids) > $limiter) 
     400                                { 
     401                                        for ($i = 0; $i < sizeof($search_ids); $i++) 
     402                                        { 
     403                                                if ($count == $limiter) 
     404                                                { 
     405                                                        $chunk++; 
     406                                                        $count = 0; 
     407                                                } 
     408 
     409                                                $search_id_chunks[$chunk][$count] = $search_ids[$i]; 
     410                                                $count++; 
     411                                        } 
     412                                } 
     413                                else 
     414                                { 
     415                                        $search_id_chunks[0] = $search_ids; 
     416                                } 
     417 
     418                                $search_ids = array(); 
     419 
     420                                for ($i = 0; $i < sizeof($search_id_chunks); $i++) 
     421                                { 
     422                                        $where_sql = ''; 
     423 
     424                                        if ( $search_time ) 
     425                                        { 
     426                                                $where_sql .= ( $search_author == '' && $auth_sql == ''  ) ? " AND post_time >= $search_time " : " AND p.post_time >= $search_time "; 
     427                                        } 
     428 
     429                                        if ( $search_author == '' && $auth_sql == '' ) 
     430                                        { 
     431                                                $sql = "SELECT topic_id 
     432                                                        FROM " . POSTS_TABLE . " 
     433                                                        WHERE post_id IN (" . implode(", ", $search_id_chunks[$i]) . ") 
     434                                                        $where_sql 
     435                                                        GROUP BY topic_id"; 
     436                                        } 
     437                                        else 
     438                                        { 
     439                                                $from_sql = POSTS_TABLE . " p"; 
     440 
     441                                                if ( $search_author != '' ) 
     442                                                { 
     443                                                        $from_sql .= ", " . USERS_TABLE . " u"; 
     444                                                        $where_sql .= " AND u.uid = p.poster_id AND u.name LIKE '$search_author' "; 
     445                                                } 
     446 
     447                                                if ( $auth_sql != '' ) 
     448                                                { 
     449                                                        $from_sql .= ", " . FORUMS_TABLE . " f"; 
     450                                                        $where_sql .= " AND f.forum_id = p.forum_id AND $auth_sql"; 
     451                                                } 
     452 
     453                                                $sql = "SELECT p.topic_id 
     454                                                        FROM $from_sql 
     455                                                        WHERE p.post_id IN (" . implode(", ", $search_id_chunks[$i]) . ") 
     456                                                                $where_sql 
     457                                                        GROUP BY p.topic_id"; 
     458                                        } 
     459 
     460                                        $result = $db->sql_query($sql); 
     461 
     462                                        while ($row = $db->sql_fetchrow($result)) 
     463                                        { 
     464                                                $search_ids[] = $row['topic_id']; 
     465                                        } 
     466                                        $db->sql_freeresult($result); 
     467                                } 
     468 
     469                                $total_match_count = sizeof($search_ids); 
     470 
     471                        } 
     472                        else if ( $search_author != '' || $search_time || $auth_sql != '' ) 
     473                        { 
     474                                $search_id_chunks = array(); 
     475                                $count = 0; 
     476                                $chunk = 0; 
     477 
     478                                if (count($search_ids) > $limiter) 
     479                                { 
     480                                        for ($i = 0; $i < count($search_ids); $i++) 
     481                                        { 
     482                                                if ($count == $limiter) 
     483                                                { 
     484                                                        $chunk++; 
     485                                                        $count = 0; 
     486                                                } 
     487 
     488                                                $search_id_chunks[$chunk][$count] = $search_ids[$i]; 
     489                                                $count++; 
     490                                        } 
     491                                } 
     492                                else 
     493                                { 
     494                                        $search_id_chunks[0] = $search_ids; 
     495                                } 
     496 
     497                                $search_ids = array(); 
     498 
     499                                for ($i = 0; $i < count($search_id_chunks); $i++) 
     500                                { 
     501                                        $where_sql = ( $search_author == '' && $auth_sql == '' ) ? 'post_id IN (' . implode(', ', $search_id_chunks[$i]) . ')' : 'p.post_id IN (' . implode(', ', $search_id_chunks[$i]) . ')'; 
     502                                        $select_sql = ( $search_author == '' && $auth_sql == '' ) ? 'post_id' : 'p.post_id'; 
     503                                        $from_sql = (  $search_author == '' && $auth_sql == '' ) ? POSTS_TABLE : POSTS_TABLE . ' p'; 
     504 
     505                                        if ( $search_time ) 
     506                                        { 
     507                                                $where_sql .= ( $search_author == '' && $auth_sql == '' ) ? " AND post_time >= $search_time " : " AND p.post_time >= $search_time"; 
     508                                        } 
     509 
     510                                        if ( $auth_sql != '' ) 
     511                                        { 
     512                                                $from_sql .= ", " . FORUMS_TABLE . " f"; 
     513                                                $where_sql .= " AND f.forum_id = p.forum_id AND $auth_sql"; 
     514                                        } 
     515 
     516                                        if ( $search_author != '' ) 
     517                                        { 
     518                                                $from_sql .= ", " . USERS_TABLE . " u"; 
     519                                                $where_sql .= " AND u.uid = p.poster_id AND u.name LIKE '$search_author'"; 
     520                                        } 
     521 
     522                                        $sql = "SELECT " . $select_sql . " 
     523                                                FROM $from_sql 
     524                                                WHERE $where_sql"; 
     525                                        $result = $db->sql_query($sql); 
     526 
     527                                        while( $row = $db->sql_fetchrow($result) ) 
     528                                        { 
     529                                                $search_ids[] = $row['post_id']; 
     530                                        } 
     531                                        $db->sql_freeresult($result); 
     532                                } 
     533 
     534                                $total_match_count = count($search_ids); 
     535                        } 
     536                } 
     537                else if ( $search_id == 'unanswered' ) 
     538                { 
     539                        if ( $auth_sql != '' ) 
     540                        { 
     541                                $sql = "SELECT t.topic_id, f.forum_id 
     542                                        FROM " . TOPICS_TABLE . "  t, " . FORUMS_TABLE . " f 
     543                                        WHERE t.topic_replies = 0 
     544                                                AND t.forum_id = f.forum_id 
     545                                                AND t.topic_moved_id = 0 
     546                                                AND $auth_sql"; 
     547                        } 
     548                        else 
     549                        { 
     550                                $sql = "SELECT topic_id 
     551                                        FROM " . TOPICS_TABLE . " 
     552                                        WHERE topic_replies = 0 
     553                                                AND topic_moved_id = 0"; 
     554                        } 
     555 
     556                        $result = $db->sql_query($sql); 
     557 
     558                        $search_ids = array(); 
     559                        while( $row = $db->sql_fetchrow($result) ) 
     560                        { 
     561                                $search_ids[] = $row['topic_id']; 
     562                        } 
     563                        $db->sql_freeresult($result); 
     564 
     565                        $total_match_count = count($search_ids); 
     566 
     567                        // 
     568                        // Basic requirements 
     569                        // 
     570                        $show_results = 'topics'; 
     571                        $sort_by = 0; 
     572                        $sort_dir = 'DESC'; 
     573                } 
     574                else 
     575                { 
     576                        trigger_error($lang['no_search_match']); 
     577                        return; 
     578                } 
     579 
     580                // 
     581                // Store new result data 
     582                // 
     583                $search_results = implode(', ', $search_ids); 
     584                $per_page = ( $show_results == 'posts' ) ? $config['posts_per_page'] : $config['topics_per_page']; 
     585 
     586                // 
     587                // Combine both results and search data (apart from original query) 
     588                // so we can serialize it and place it in the DB 
     589                // 
     590                $store_search_data = array(); 
     591 
     592                // 
     593                // Limit the character length (and with this the results displayed at all following pages) to prevent 
     594                // truncated result arrays. Normally, search results above 12000 are affected. 
     595                // - to include or not to include 
     596                /* 
     597                $max_result_length = 60000; 
     598                if (utf_strlen($search_results) > $max_result_length) 
     599                { 
     600                        $search_results = substr($search_results, 0, $max_result_length); 
     601                        $search_results = substr($search_results, 0, strrpos($search_results, ',')); 
     602                        $total_match_count = count(explode(', ', $search_results)); 
     603                } 
     604                */ 
     605 
     606                for($i = 0; $i < sizeof($store_vars); $i++) 
     607                { 
     608                        $store_search_data[$store_vars[$i]] = $$store_vars[$i]; 
     609                } 
     610 
     611                $result_array = serialize($store_search_data); 
     612                unset($store_search_data); 
     613 
     614                $search_id = md5(dss_rand()); 
     615 
     616                $sql = "UPDATE " . SEARCH_TABLE . " 
     617                        SET search_id = '" . $db->sql_escape($search_id) . "', search_time = $current_time, search_array = '" . $db->sql_escape($result_array) . "' 
     618                        WHERE session_id = '" . $userdata['session_id'] . "'"; 
     619                if ( !($result = $db->sql_query($sql)) || !$db->sql_affectedrows() ) 
     620                { 
     621                        $sql = "INSERT INTO " . SEARCH_TABLE . " (search_id, session_id, search_time, search_array) 
     622                                VALUES('" . $db->sql_escape($search_id) . "', '" . $userdata['session_id'] . "', $current_time, '" . $db->sql_escape($result_array) . "')"; 
     623                        $result = $db->sql_query($sql); 
     624                } 
     625        } 
     626        else 
     627        { 
     628                $search_id = intval($search_id); 
     629                if ( $search_id ) 
     630                { 
     631                        $sql = "SELECT search_array 
     632                                FROM " . SEARCH_TABLE . " 
     633                                WHERE search_id = '" . $db->sql_escape($search_id) . "' 
     634                                        AND session_id = '". $userdata['session_id'] . "'"; 
     635                        $result = $db->sql_query($sql); 
     636 
     637                        if ( $row = $db->sql_fetchrow($result) ) 
     638                        { 
     639                                $search_data = unserialize($row['search_array']); 
     640                                for($i = 0; $i < sizeof($store_vars); $i++) 
     641                                { 
     642                                        $$store_vars[$i] = $search_data[$store_vars[$i]]; 
     643                                } 
     644                        } 
     645                } 
     646        } 
     647        // 
     648        // Look up data ... 
     649        // 
     650        if ( $search_results != '' ) 
     651        { 
     652                if ( $show_results == 'posts' ) 
     653                { 
     654                        $sql = "SELECT pt.post_text, pt.post_subject, p.*, f.forum_id, f.forum_name, t.*, u.name AS username, u.uid, c.cat_id, c.cat_title, f2.forum_id AS p_forum_id, f2.forum_name AS p_forum_name 
     655                                FROM " . FORUMS_TABLE . " f LEFT JOIN " . FORUMS_TABLE . " f2 ON ( f.forum_parent = f2.forum_id ), 
     656        " . FORUM_CATEGORIES_TABLE . " c, " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . POSTS_TEXT_TABLE . " pt 
     657                                WHERE p.post_id IN ($search_results) 
     658                                        AND pt.post_id = p.post_id 
     659                                        AND f.forum_id = p.forum_id 
     660                                        AND p.topic_id = t.topic_id 
     661                                        AND p.poster_id = u.uid 
     662        AND f.cat_id = c.cat_id"; 
     663                } 
     664                else 
     665                { 
     666                        $sql = "SELECT t.*, f.forum_id, f.forum_name, u.name AS username, u.uid, u2.name as user2, u2.uid as id2, p.post_username, p2.post_username AS post_username2, p2.post_time, c.cat_id, c.cat_title, f2.forum_id AS p_forum_id, f2.forum_name AS p_forum_name 
     667                                FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f LEFT JOIN " . FORUMS_TABLE . " f2 ON ( f.forum_parent = f2.forum_id )," . FORUM_CATEGORIES_TABLE . " c, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . POSTS_TABLE . " p2, " . USERS_TABLE . " u2 
     668                                WHERE t.topic_id IN ($search_results) 
     669                                        AND t.topic_poster = u.uid 
     670                                        AND f.forum_id = t.forum_id 
     671                                        AND p.post_id = t.topic_first_post_id 
     672                                        AND p2.post_id = t.topic_last_post_id 
     673                                        AND u2.uid = p2.poster_id 
     674        AND f.cat_id = c.cat_id"; 
     675                } 
     676 
     677                $per_page = ( $show_results == 'posts' ) ? $config['posts_per_page'] : $config['topics_per_page']; 
     678 
     679        /*if ($userdata['session_logged_in']) 
     680        { 
     681        if ($config['load_db_track'] && $author_id !== $userdata['uid']) 
     682        { 
     683        $sql_from .= ' LEFT JOIN ' . TOPICS_POSTED_TABLE . ' tp ON (tp.user_id = ' . $userdata['uid'] . ' 
     684        AND t.topic_id = tp.topic_id)'; 
     685        $sql_select .= ', tp.topic_posted'; 
     686        } 
     687 
     688        if ($config['load_db_lastread']) 
     689        { 
     690        $sql_from .= ' LEFT JOIN ' . TOPICS_TRACK_TABLE . ' tt ON (tt.user_id = ' . $userdata['uid'] . ' 
     691        AND t.topic_id = tt.topic_id) 
     692        LEFT JOIN ' . FORUMS_TRACK_TABLE . ' ft ON (ft.user_id = ' . $userdata['uid'] . ' 
     693        AND ft.forum_id = f.forum_id)'; 
     694        $sql_select .= ', tt.mark_time, ft.mark_time as f_mark_time'; 
     695        } 
     696        } 
     697 
     698        if ($config['load_anon_lastread'] || ($userdata['session_logged_in'] && !$config['load_db_lastread'])) 
     699        {*/ 
     700        $tracking_topics = (isset($_COOKIE[$config['cookie_name'] . '_track'])) ? ((STRIP) ? stripslashes($_COOKIE[$config['cookie_name'] . '_track']) : $_COOKIE[$config['cookie_name'] . '_track']) : ''; 
     701        $tracking_topics = ($tracking_topics) ? tracking_unserialize($tracking_topics) : array(); 
     702        //} 
     703        $topic_tracking_info = array(); 
     704 
     705                $sql .= " ORDER BY "; 
     706                switch ( $sort_by ) 
     707                { 
     708                        case 1: 
     709                                $sql .= ( $show_results == 'posts' ) ? 'pt.post_subject' : 't.topic_title'; 
     710                                break; 
     711                        case 2: 
     712                                $sql .= 't.topic_title'; 
     713                                break; 
     714                        case 3: 
     715                                $sql .= 'u.name'; 
     716                                break; 
     717                        case 4: 
     718                                $sql .= 'f.forum_id'; 
     719                                break; 
     720                        default: 
     721                                $sql .= ( $show_results == 'posts' ) ? 'p.post_time' : 'p2.post_time'; 
     722                                break; 
     723                } 
     724 
     725                $sql .= ' ' . $sort_dir . ' LIMIT ' . $start . ', ' . $per_page; 
     726 
     727                $result = $db->sql_query($sql); 
     728 
     729                $searchset = array(); 
     730                $forums = array(); 
     731                while( $row = $db->sql_fetchrow($result) ) 
     732                { 
     733                        $searchset[] = $row; 
     734 
     735        $forums[$row['forum_id']]['topic_list'][] = $row['topic_id']; 
     736                } 
     737 
     738        foreach ($forums as $forum_id => $forum) 
     739        { 
     740        /*if ($userdata['session_logged_in'] && $config['load_db_lastread']) 
     741        { 
     742        $topic_tracking_info[$forum_id] = get_topic_tracking($forum_id, $forum['topic_list'], $forum['rowset'], array($forum_id => $forum['mark_time']), ($forum_id) ? false : $forum['topic_list']); 
     743        } 
     744        else if ($config['load_anon_lastread'] || $userdata['session_logged_in']) 
     745        {*/ 
     746        $topic_tracking_info[$forum_id] = get_complete_topic_tracking($forum_id, $forum['topic_list'], ($forum_id) ? false : $forum['topic_list']); 
     747 
     748        if (!$userdata['session_logged_in']) 
     749        { 
     750        $userdata['user_lastmark'] = (isset($tracking_topics['l'])) ? (int) (base_convert($tracking_topics['l'], 36, 10) + $config['onlinesince']) : 0; 
     751        } 
     752        //} 
     753        } 
     754        unset($forums); 
     755 
     756                $db->sql_freeresult($result); 
     757 
     758                // 
     759                // Define censored word matches 
     760                // 
     761                $orig_word = array(); 
     762                $replacement_word = array(); 
     763                $cache->obtain_word_list($orig_word, $replacement_word); 
     764 
     765                // 
     766                // Output header 
     767                // 
     768                stdhead($lang['forums'] . ' :: ' . $lang['search'], false); 
     769 
     770                if ( $show_results == 'posts' ) 
     771                { 
     772                        // Topic search MOD 
     773                        if( !$tid ) 
     774                        { 
     775                                // End Topic search MOD 
     776                                $template->set_filenames(array( 
     777                                        'body' => 'forum/search_results_posts.tpl') 
     778                                ); 
     779                        // Topic search MOD 
     780                        } 
     781                        else 
     782                        { 
     783                                $template->set_filenames(array( 
     784                                        'body' => 'forum/topic_search_results.tpl') 
     785                                ); 
     786                        } 
     787                        // End Topic search MOD 
     788                } 
     789                else 
     790                { 
     791                        $template->set_filenames(array( 
     792                                'body' => 'forum/search_results_topics.tpl') 
     793                        ); 
     794                } 
     795                //make_jumpbox('viewforum.'.$phpEx); 
     796                make_jumpbox('phpbb2.php?page=viewforum'); 
     797 
     798                $l_search_matches = ( $total_match_count == 1 ) ? sprintf($lang['found_search_match'], $total_match_count) : sprintf($lang['found_search_matches'], $total_match_count); 
     799 
     800                $template->assign_vars(array( 
     801                        'L_SEARCH_MATCHES' => $l_search_matches) 
     802                ); 
     803 
     804                $highlight_active = ''; 
     805                $highlight_match = array(); 
     806                for($j = 0; $j < sizeof($split_search); $j++ ) 
     807                { 
     808                        $split_word = $split_search[$j]; 
     809 
     810                        if ( $split_word != 'and' && $split_word != 'or' && $split_word != 'not' ) 
     811                        { 
     812                                $highlight_match[] = '#\b(' . str_replace("*", "([\w]+)?", $split_word) . ')\b#is'; 
     813                                $highlight_active .= " " . $split_word; 
     814 
     815                                for ($k = 0; $k < sizeof($synonym_array); $k++) 
     816                                { 
     817                                        list($replace_synonym, $match_synonym) = split(' ', trim(utf_strtolower($synonym_array[$k]))); 
     818 
     819                                        if ( $replace_synonym == $split_word ) 
     820                                        { 
     821                                                $highlight_match[] = '#\b(' . str_replace("*", "([\w]+)?", $replace_synonym) . ')\b#is'; 
     822                                                $highlight_active .= ' ' . $match_synonym; 
     823                                        } 
     824                                } 
     825                        } 
     826                } 
     827 
     828                $highlight_active = urlencode(trim($highlight_active)); 
     829 
     830                for($i = 0; $i < sizeof($searchset); $i++) 
     831                { 
     832 
     833                        $topic_title = $searchset[$i]['topic_title']; 
     834 
     835                        $forum_id = $searchset[$i]['forum_id']; 
     836                        $topic_id = $searchset[$i]['topic_id']; 
     837 
     838        // www.phpBB-SEO.com SEO TOOLKIT BEGIN 
     839        $seo->set_url($searchset[$i]['cat_id'], $searchset[$i]['cat_title'], $seo->seo_static['forum_cat']); 
     840 
     841        if ( !empty($searchset[$i]['p_forum_id']) ) { 
     842        $seo->set_parent($searchset[$i]['p_forum_id'], $seo->seo_static['forum'], $searchset[$i]['cat_id'], $seo->seo_static['forum_cat']); 
     843        $seo->set_url($searchset[$i]['p_forum_name'], $searchset[$i]['p_forum_id'], $seo->seo_static['forum']); 
     844        $seo->set_parent($forum_id, $seo->seo_static['forum'], $searchset[$i]['p_forum_id'], $seo->seo_static['forum']); 
     845        } 
     846        else { 
     847        $seo->set_parent($forum_id, $seo->seo_static['forum'], $searchset[$i]['cat_id'], $seo->seo_static['forum_cat']); 
     848        } 
     849        $seo->set_url($searchset[$i]['forum_name'], $forum_id, $seo->seo_static['forum']); 
     850 
     851        $seo->set_parent($topic_id, $seo->seo_static['topic'], $forum_id, $seo->seo_static['forum']); 
     852        $seo->set_url($topic_title, $topic_id, $seo->seo_static['topic']); 
     853 
     854        if ( $show_results != 'posts' ) { 
     855 
     856        $seo->set_user_url($searchset[$i]['username'], $searchset[$i]['uid']); 
     857        $seo->set_user_url($searchset[$i]['user2'], $searchset[$i]['id2']); 
     858        } 
     859        // www.phpBB-SEO.com SEO TOOLKIT END 
     860 
     861                        //$forum_url = append_sid("viewforum.$phpEx?" . POST_FORUM_URL . '=' . $searchset[$i]['forum_id']); 
     862                        $forum_url = append_sid($root_path . "phpbb2.php?page=viewforum&amp;" . POST_FORUM_URL . '=' . $searchset[$i]['forum_id']); 
     863                        //$topic_url = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . '=' . $searchset[$i]['topic_id'] . "&amp;highlight=$highlight_active"); 
     864                        $topic_url = append_sid($root_path . "phpbb2.php?page=viewtopic&amp;" . POST_TOPIC_URL . '=' . $searchset[$i]['topic_id'] . "&amp;highlight=$highlight_active"); 
     865                        //$post_url = append_sid("viewtopic.$phpEx?" . POST_POST_URL . '=' . $searchset[$i]['post_id'] . "&amp;highlight=$highlight_active") . '#' . $searchset[$i]['post_id']; 
     866 
     867                        $post_date = create_date($searchset[$i]['post_time']); 
     868 
     869                        if ( $show_results == 'posts' ) 
     870                        { 
     871                                        $message = $searchset[$i]['post_text']; 
     872                                        $post_url = append_sid($root_path . "phpbb2.php?page=viewtopic&amp;" . POST_POST_URL . '=' . $searchset[$i]['post_id'] . "&amp;highlight=$highlight_active") . '#' . $searchset[$i]['post_id']; 
     873 
     874                                if ( isset($return_chars) ) 
     875                                { 
     876 
     877                                        // 
     878                                        // If the board has HTML off but the post has HTML 
     879                                        // on then we process it, else leave it alone 
     880                                        // 
     881                                        if ( $return_chars != -1 ) 
     882                                        { 
     883                                                $message = strip_tags($message); 
     884                                                $message = preg_replace('/\[url\]|\[\/url\]/si', '', $message); 
     885                                                $message = ( utf_strlen($message) > $return_chars ) ? substr($message, 0, $return_chars) . ' ...' : $message; 
     886                                        } 
     887                                        else 
     888                                        { 
     889                                                if ( !$config['allow_html'] ) 
     890                                                { 
     891                                                        if ( $searchset[$i]['enable_html'] ) 
     892                                                        { 
     893                                                                $message = preg_replace('#(<)([\/]?.*?)(>)#is', '&lt;\\2&gt;', $message); 
     894                                                        } 
     895                                                } 
     896 
     897                $bb_code->parse($message); 
     898                $message = $bb_code->get_html(); 
     899 
     900                                                if ( $highlight_active ) 
     901                                                { 
     902                                                        if ( preg_match('/<.*>/', $message) ) 
     903                                                        { 
     904                                                                $message = preg_replace($highlight_match, '<!-- #sh -->\1<!-- #eh -->', $message); 
     905 
     906                                                                $end_html = 0; 
     907                                                                $start_html = 1; 
     908                                                                $temp_message = ''; 
     909                                                                $message = ' ' . $message . ' '; 
     910 
     911                                                                while( $start_html = strpos($message, '<', $start_html) ) 
     912                                                                { 
     913                                                                        $grab_length = $start_html - $end_html - 1; 
     914                                                                        $temp_message .= substr($message, $end_html + 1, $grab_length); 
     915 
     916                                                                        if ( $end_html = strpos($message, '>', $start_html) ) 
     917                                                                        { 
     918                                                                                $length = $end_html - $start_html + 1; 
     919                                                                                $hold_string = substr($message, $start_html, $length); 
     920 
     921                                                                                if ( strrpos(' ' . $hold_string, '<') != 1 ) 
     922                                                                                { 
     923                                                                                        $end_html = $start_html + 1; 
     924                                                                                        $end_counter = 1; 
     925 
     926                                                                                        while ( $end_counter && $end_html < utf_strlen($message) ) 
     927                                                                                        { 
     928                                                                                                if ( substr($message, $end_html, 1) == '>' ) 
     929                                                                                                { 
     930                                                                                                        $end_counter--; 
     931                                                                                                } 
     932                                                                                                else if ( substr($message, $end_html, 1) == '<' ) 
     933                                                                                                { 
     934                                                                                                        $end_counter++; 
     935                                                                                                } 
     936 
     937                                                                                                $end_html++; 
     938                                                                                        } 
     939 
     940                                                                                        $length = $end_html - $start_html + 1; 
     941                                                                                        $hold_string = substr($message, $start_html, $length); 
     942                                                                                        $hold_string = str_replace('<!-- #sh -->', '', $hold_string); 
     943                                                                                        $hold_string = str_replace('<!-- #eh -->', '', $hold_string); 
     944                                                                                } 
     945                                                                                else if ( $hold_string == '<!-- #sh -->' ) 
     946                                                                                { 
     947                                                                                        $hold_string = str_replace('<!-- #sh -->', '<span style="color:#' . $theme['fontcolor3'] . '"><b>', $hold_string); 
     948                                                                                } 
     949                                                                                else if ( $hold_string == '<!-- #eh -->' ) 
     950                                                                                { 
     951                                                                                        $hold_string = str_replace('<!-- #eh -->', '</b></span>', $hold_string); 
     952                                                                                } 
     953 
     954                                                                                $temp_message .= $hold_string; 
     955 
     956                                                                                $start_html += $length; 
     957                                                                        } 
     958                                                                        else 
     959                                                                        { 
     960                                                                                $start_html = utf_strlen($message); 
     961                                                                        } 
     962                                                                } 
     963 
     964                                                                $grab_length = utf_strlen($message) - $end_html - 1; 
     965                                                                $temp_message .= substr($message, $end_html + 1, $grab_length); 
     966 
     967                                                                $message = trim($temp_message); 
     968                                                        } 
     969                                                        else 
     970                                                        { 
     971                                                                $message = preg_replace($highlight_match, '<span style="color:#' . $theme['fontcolor3'] . '"><b>\1</b></span>', $message); 
     972                                                        } 
     973                                                } 
     974                                        } 
     975 
     976                                        $topic_title = censor_text($topic_title); 
     977                                        $post_subject = ( $searchset[$i]['post_subject'] != '' ) ? censor_text($searchset[$i]['post_subject']) : $topic_title; 
     978                                        $message = censor_text($message); 
     979 
     980                                        $message = str_replace("\n", '<br />', $message); 
     981 
     982                                } 
     983 
     984                                $poster = ( $searchset[$i]['uid'] != ANONYMOUS ) ? '<a href="' . append_sid($root_path . "userdetails.php?id=" . $searchset[$i]['uid']) . '">' : ''; 
     985                                $poster .= ( $searchset[$i]['uid'] != ANONYMOUS ) ? $searchset[$i]['username'] : ( ( $searchset[$i]['post_username'] != "" ) ? $searchset[$i]['post_username'] : $lang['guest'] ); 
     986                                $poster .= ( $searchset[$i]['uid'] != ANONYMOUS ) ? '</a>' : ''; 
     987 
     988                                /*if ( $userdata['session_logged_in'] && $searchset[$i]['post_time'] > $userdata['user_lastvisit'] ) 
     989                                { 
     990                                        $topic_last_read = 0; 
     991                                        if ( !empty($tracking_topics[$topic_id]) && !empty($tracking_forums[$forum_id]) ) 
     992                                        { 
     993                                                $topic_last_read = ( $tracking_topics[$topic_id] > $tracking_forums[$forum_id] ) ? $tracking_topics[$topic_id] : $tracking_forums[$forum_id]; 
     994                                        } 
     995                                        else if ( !empty($tracking_topics[$topic_id]) || !empty($tracking_forums[$forum_id]) ) 
     996                                        { 
     997                                                $topic_last_read = ( !empty($tracking_topics[$topic_id]) ) ? $tracking_topics[$topic_id] : $tracking_forums[$forum_id]; 
     998                                        } 
     999 
     1000                                        if ( $searchset[$i]['post_time'] > $topic_last_read ) 
     1001                                        { 
     1002                                                $mini_post_img = $images['icon_minipost_new']; 
     1003                                                $mini_post_alt = $lang['new_post']; 
     1004                                        } 
     1005                                        else 
     1006                                        { 
     1007                                                $mini_post_img = $images['icon_minipost']; 
     1008                                                $mini_post_alt = $lang['post']; 
     1009                                        } 
     1010                                } 
     1011                                else 
     1012                                { 
     1013                                        $mini_post_img = $images['icon_minipost']; 
     1014                                        $mini_post_alt = $lang['post']; 
     1015                                }*/ 
     1016 
     1017                                $unread_topic = (isset($topic_tracking_info[$forum_id][$topic_id]) && $searchset[$i]['post_time'] > $topic_tracking_info[$forum_id][$topic_id]) ? true : false; 
     1018 
     1019                                if ( $unread_topic ) 
     1020                                        { 
     1021                                                $mini_post_img = $images['icon_minipost_new']; 
     1022                                                $mini_post_alt = $lang['new_post']; 
     1023                                        } 
     1024                                        else 
     1025                                        { 
     1026                                                $mini_post_img = $images['icon_minipost']; 
     1027                                                $mini_post_alt = $lang['post']; 
     1028                                        } 
     1029 
     1030                                $template->assign_block_vars("searchresults", array( 
     1031                                        'TOPIC_TITLE' => $topic_title, 
     1032                                        'FORUM_NAME' => $searchset[$i]['forum_name'], 
     1033                                        'POST_SUBJECT' => $post_subject, 
     1034                                        'POST_DATE' => $post_date, 
     1035                                        'POSTER_NAME' => $poster, 
     1036                                        'TOPIC_REPLIES' => $searchset[$i]['topic_replies'], 
     1037                                        'TOPIC_VIEWS' => $searchset[$i]['topic_views'], 
     1038                                        'MESSAGE' => $message, 
     1039                                        'MINI_POST_IMG' => $mini_post_img, 
     1040 
     1041                                        'L_MINI_POST_ALT' => $mini_post_alt, 
     1042 
     1043                                        'U_POST' => $post_url, 
     1044                                        'U_TOPIC' => $topic_url, 
     1045                                        'U_FORUM' => $forum_url) 
     1046                                ); 
     1047                        } 
     1048                        else 
     1049                        { 
     1050                                $message = ''; 
     1051 
     1052                                if ( count($orig_word) ) 
     1053                                { 
     1054                                        $topic_title = preg_replace($orig_word, $replacement_word, $searchset[$i]['topic_title']); 
     1055                                } 
     1056 
     1057                                $topic_type = $searchset[$i]['topic_type']; 
     1058 
     1059                                if ($topic_type == POST_ANNOUNCE) 
     1060                                { 
     1061                                        $topic_type = $lang['topic_announcement'] . ' '; 
     1062                                } 
     1063                                else if ($topic_type == POST_STICKY) 
     1064                                { 
     1065                                        $topic_type = $lang['topic_sticky'] . ' '; 
     1066                                } 
     1067                                else 
     1068                                { 
     1069                                        $topic_type = ''; 
     1070                                } 
     1071 
     1072                                if ( $searchset[$i]['topic_vote'] ) 
     1073                                { 
     1074                                        $topic_type .= $lang['topic_poll'] . ' '; 
     1075                                } 
     1076 
     1077                                $views = $searchset[$i]['topic_views']; 
     1078                                $replies = $searchset[$i]['topic_replies']; 
     1079 
     1080                                if ( ( $replies + 1 ) > $config['posts_per_page'] ) 
     1081                                { 
     1082                                        $total_pages = ceil( ( $replies + 1 ) / $config['posts_per_page'] ); 
     1083                                        //$goto_page = ' [ <img src="' . $images['icon_gotopost'] . '" alt="' . $lang['goto_page'] . '" title="' . $lang['goto_page'] . '" />' . $lang['goto_page'] . ': '; 
     1084                                        $goto_page = ' [ <img src="' . $images['icon_gotopost'] . '" alt="' . $lang['goto_page'] . '" title="' . $lang['goto_page'] . '" />' . $lang['goto_page'] . ': '; 
     1085 
     1086                                        $times = 1; 
     1087                                        for($j = 0; $j < $replies + 1; $j += $config['posts_per_page']) 
     1088                                        { 
     1089                                                //$goto_page .= '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=" . $topic_id . "&amp;start=$j") . '">' . $times . '</a>'; 
     1090                                                $goto_page .= '<a href="' . append_sid($root_path . "phpbb2.php?page=viewtopic&amp;" . POST_TOPIC_URL . "=" . $topic_id . "&amp;start=$j") . '">' . $times . '</a>'; 
     1091                                                if ( $times == 1 && $total_pages > 4 ) 
     1092                                                { 
     1093                                                        $goto_page .= ' ... '; 
     1094                                                        $times = $total_pages - 3; 
     1095                                                        $j += ( $total_pages - 4 ) * $config['posts_per_page']; 
     1096                                                } 
     1097                                                else if ( $times < $total_pages ) 
     1098                                                { 
     1099                                                        $goto_page .= ', '; 
     1100                                                } 
     1101                                                $times++; 
     1102                                        } 
     1103                                        $goto_page .= ' ] '; 
     1104                                } 
     1105                                else 
     1106                                { 
     1107                                        $goto_page = ''; 
     1108                                } 
     1109 
     1110                                if ( $searchset[$i]['topic_status'] == TOPIC_MOVED ) 
     1111                                { 
     1112                                        $topic_type = $lang['topic_moved'] . ' '; 
     1113                                        $topic_id = $searchset[$i]['topic_moved_id']; 
     1114 
     1115                                        //$folder_image = '<img src="' . $images['folder'] . '" alt="' . $lang['no_new_posts'] . '" />'; 
     1116                                        $folder_image = '<img src="' . $images['folder'] . '" alt="' . $lang['no_new_posts'] . '" />'; 
     1117                                        $newest_post_img = ''; 
     1118                                } 
     1119                                else 
     1120                                { 
     1121                                        if ( $searchset[$i]['topic_status'] == TOPIC_LOCKED ) 
     1122                                        { 
     1123                                                $folder = $images['folder_locked']; 
     1124                                                $folder_new = $images['folder_locked_new']; 
     1125                                        } 
     1126                                        else if ( $searchset[$i]['topic_type'] == POST_ANNOUNCE ) 
     1127                                        { 
     1128                                                $folder = $images['folder_announce']; 
     1129                                                $folder_new = $images['folder_announce_new']; 
     1130                                        } 
     1131                                        else if ( $searchset[$i]['topic_type'] == POST_STICKY ) 
     1132                                        { 
     1133                                                $folder = $images['folder_sticky']; 
     1134                                                $folder_new = $images['folder_sticky_new']; 
     1135                                        } 
     1136                                        else 
     1137                                        { 
     1138                                                if ( $replies >= $config['hot_threshold'] ) 
     1139                                                { 
     1140                                                        $folder = $images['folder_hot']; 
     1141                                                        $folder_new = $images['folder_hot_new']; 
     1142                                                } 
     1143                                                else 
     1144                                                { 
     1145                                                        $folder = $images['folder']; 
     1146                                                        $folder_new = $images['folder_new']; 
     1147                                                } 
     1148                                        } 
     1149 
     1150                                        /*if ( $userdata['session_logged_in'] ) 
     1151                                        { 
     1152                                                if ( $searchset[$i]['post_time'] > $userdata['user_lastvisit'] ) 
     1153                                                { 
     1154                                                        if ( !empty($tracking_topics) || !empty($tracking_forums) || isset($_COOKIE[$config['cookie_name'] . '_f_all']) ) 
     1155                                                        { 
     1156 
     1157                                                                $unread_topics = true; 
     1158 
     1159                                                                if ( !empty($tracking_topics[$topic_id]) ) 
     1160                                                                { 
     1161                                                                        if ( $tracking_topics[$topic_id] > $searchset[$i]['post_time'] ) 
     1162                                                                        { 
     1163                                                                                $unread_topics = false; 
     1164                                                                        } 
     1165                                                                } 
     1166 
     1167                                                                if ( !empty($tracking_forums[$forum_id]) ) 
     1168                                                                { 
     1169                                                                        if ( $tracking_forums[$forum_id] > $searchset[$i]['post_time'] ) 
     1170                                                                        { 
     1171                                                                                $unread_topics = false; 
     1172                                                                        } 
     1173                                                                } 
     1174 
     1175                                                                if ( isset($_COOKIE[$config['cookie_name'] . '_f_all']) ) 
     1176                                                                { 
     1177                                                                        if ( $_COOKIE[$config['cookie_name'] . '_f_all'] > $searchset[$i]['post_time'] ) 
     1178                                                                        { 
     1179                                                                                $unread_topics = false; 
     1180                                                                        } 
     1181                                                                }*/ 
     1182 
     1183                                                                $unread_topics = (isset($topic_tracking_info[$forum_id][$topic_id]) && $searchset[$i]['post_time'] > $topic_tracking_info[$forum_id][$topic_id]) ? true : false; 
     1184 
     1185                                                                if ( $unread_topics ) 
     1186                                                                { 
     1187                                                                        $folder_image = $folder_new; 
     1188                                                                        $folder_alt = $lang['new_posts']; 
     1189 
     1190                                                                        //$newest_post_img = '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;view=newest") . '"><img src="' . $images['icon_newest_reply'] . '" alt="' . $lang['view_newest_post'] . '" title="' . $lang['view_newest_post'] . '" border="0" /></a> '; 
     1191                                                                        $newest_post_img = '<a href="' . append_sid($root_path . "phpbb2.php?page=viewtopic&amp;" . POST_TOPIC_URL . "=$topic_id&amp;view=newest") . '"><img src="' . $images['icon_newest_reply'] . '" alt="' . $lang['view_newest_post'] . '" title="' . $lang['view_newest_post'] . '" border="0" /></a> '; 
     1192                                                                } 
     1193                                                                else 
     1194                                                                { 
     1195                                                                        $folder_alt = ( $searchset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['topic_locked'] : $lang['no_new_posts']; 
     1196 
     1197                                                                        $folder_image = $folder; 
     1198                                                                        $folder_alt = $folder_alt; 
     1199                                                                        $newest_post_img = ''; 
     1200                                                                } 
     1201 
     1202                                                        /*} 
     1203                                                        else if ( $searchset[$i]['post_time'] > $userdata['user_lastvisit'] ) 
     1204                                                        { 
     1205                                                                $folder_image = $folder_new; 
     1206                                                                $folder_alt = $lang['new_posts']; 
     1207 
     1208                                                                //$newest_post_img = '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;view=newest") . '"><img src="' . $images['icon_newest_reply'] . '" alt="' . $lang['view_newest_post'] . '" title="' . $lang['view_newest_post'] . '" border="0" /></a> '; 
     1209                                                                $newest_post_img = '<a href="' . append_sid($root_path . "phpbb2.php?page=viewtopic&amp;" . POST_TOPIC_URL . "=$topic_id&amp;view=newest") . '"><img src="' . $images['icon_newest_reply'] . '" alt="' . $lang['view_newest_post'] . '" title="' . $lang['view_newest_post'] . '" border="0" /></a> '; 
     1210                                                        } 
     1211                                                        else 
     1212                                                        { 
     1213                                                                $folder_image = $folder; 
     1214                                                                $folder_alt = ( $searchset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['topic_locked'] : $lang['no_new_posts']; 
     1215                                                                $newest_post_img = ''; 
     1216                                                        } 
     1217                                                } 
     1218                                                else 
     1219                                                { 
     1220                                                        $folder_image = $folder; 
     1221                                                        $folder_alt = ( $searchset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['topic_locked'] : $lang['no_new_posts']; 
     1222                                                        $newest_post_img = ''; 
     1223                                                } 
     1224                                        } 
     1225                                        else 
     1226                                        { 
     1227                                                $folder_image = $folder; 
     1228                                                $folder_alt = ( $searchset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['topic_locked'] : $lang['no_new_posts']; 
     1229                                                $newest_post_img = ''; 
     1230                                        }*/ 
     1231                                } 
     1232 
     1233 
     1234                                $topic_author = ( $searchset[$i]['uid'] != ANONYMOUS ) ? '<a href="' . append_sid($root_path . "userdetails.php?id=" . $searchset[$i]['uid']) . '">' : ''; 
     1235                                $topic_author .= ( $searchset[$i]['uid'] != ANONYMOUS ) ? $searchset[$i]['username'] : ( ( $searchset[$i]['post_username'] != '' ) ? $searchset[$i]['post_username'] : $lang['guest'] ); 
     1236 
     1237                                $topic_author .= ( $searchset[$i]['uid'] != ANONYMOUS ) ? '</a>' : ''; 
     1238 
     1239                                $first_post_time = create_date($searchset[$i]['topic_time']); 
     1240 
     1241                                $last_post_time = create_date($searchset[$i]['post_time']); 
     1242 
     1243                                $last_post_author = ( $searchset[$i]['id2'] == ANONYMOUS ) ? ( ($searchset[$i]['post_username2'] != '' ) ? $searchset[$i]['post_username2'] . ' ' : $lang['guest'] . ' ' ) : '<a href="' . append_sid($root_path . "userdetails.php?id="  . $searchset[$i]['id2']) . '">' . $searchset[$i]['user2'] . '</a>'; 
     1244 
     1245                                $last_post_url = '<a href="' . append_sid($root_path . "phpbb2.php?page=viewtopic&amp;"  . POST_POST_URL . '=' . $searchset[$i]['topic_last_post_id']) . '#' . $searchset[$i]['topic_last_post_id'] . '"><img src="' . $images['icon_latest_reply'] . '" alt="' . $lang['view_latest_post'] . '" title="' . $lang['view_latest_post'] . '" border="0" /></a>'; 
     1246 
     1247                                $template->assign_block_vars('searchresults', array( 
     1248                                        'FORUM_NAME' => $searchset[$i]['forum_name'], 
     1249                                        'FORUM_ID' => $forum_id, 
     1250                                        'TOPIC_ID' => $topic_id, 
     1251                                        'FOLDER' => $folder_image, 
     1252                                        'NEWEST_POST_IMG' => $newest_post_img, 
     1253                                        'TOPIC_FOLDER_IMG' => $folder_image, 
     1254                                        'GOTO_PAGE' => $goto_page, 
     1255                                        'REPLIES' => $replies, 
     1256                                        'TOPIC_TITLE' => $topic_title, 
     1257                                        'TOPIC_TYPE' => $topic_type, 
     1258                                        'VIEWS' => $views, 
     1259                                        'TOPIC_AUTHOR' => $topic_author, 
     1260                                        'FIRST_POST_TIME' => $first_post_time, 
     1261                                        'LAST_POST_TIME' => $last_post_time, 
     1262                                        'LAST_POST_AUTHOR' => $last_post_author, 
     1263                                        'LAST_POST_IMG' => $last_post_url, 
     1264 
     1265                                        'L_TOPIC_FOLDER_ALT' => $folder_alt, 
     1266 
     1267                                        'U_VIEW_FORUM' => $forum_url, 
     1268                                        'U_VIEW_TOPIC' => $topic_url) 
     1269                                ); 
     1270                        } 
     1271                } 
     1272                // Topic search MOD 
     1273                if( !$tid ) 
     1274                { 
     1275                // End Topic search MOD 
     1276                        $base_url = "phpbb2.php?page=search&amp;search_id=$search_id&amp;search_author=$search_author"; 
     1277                // Topic search MOD 
     1278                } 
     1279                else 
     1280                { 
     1281                        $base_url = "phpbb2.php?page=search&amp;search_id=$search_id&amp;topic_id=$tid"; 
     1282                } 
     1283                // End Topic search MOD 
     1284 
     1285                $template->assign_vars(array( 
     1286                        'PAGINATION' => generate_pagination($root_path . $base_url, $total_match_count, $per_page, $start), 
     1287                        'PAGE_NUMBER' => sprintf($lang['page_of'], ( floor( $start / $per_page ) + 1 ), ceil( $total_match_count / $per_page )), 
     1288                )); 
     1289                return; 
     1290        } 
     1291        else 
     1292        { 
     1293                trigger_error($lang['no_search_match']); 
     1294                return; 
     1295        } 
    13211296} 
    13221297 
     
    13251300// 
    13261301$sql = "SELECT c.cat_title, c.cat_id, f.forum_name, f.forum_id, f.forum_parent 
    1327         FROM " . FORUM_CATEGORIES_TABLE . " c, " . FORUMS_TABLE . " f 
    1328         WHERE f.cat_id = c.cat_id 
    1329         ORDER BY c.cat_order, f.forum_order"; 
     1302       FROM " . FORUM_CATEGORIES_TABLE . " c, " . FORUMS_TABLE . " f 
     1303       WHERE f.cat_id = c.cat_id 
     1304       ORDER BY c.cat_order, f.forum_order"; 
    13301305$result = $db->sql_query($sql); 
    13311306$is_auth_ary = auth(AUTH_READ, AUTH_LIST_ALL, $userdata); 
     
    13351310while( $row = $db->sql_fetchrow($result) ) 
    13361311{ 
    1337         if ( $is_auth_ary[$row['forum_id']]['auth_read'] ) 
    1338        
    1339                       $list[] = $row; 
     1312       if ( $is_auth_ary[$row['forum_id']]['auth_read'] ) 
     1313       
     1314              $list[] = $row; 
    13401315        } 
    13411316} 
     
    13451320        if( !$list[$i]['forum_parent'] ) 
    13461321        { 
    1347                $row = $list[$i]; 
    1348                 $s_forums .= '<option value="' . $row['forum_id'] . '">' . $row['forum_name'] . '</option>'; 
    1349                 if ( empty($list_cat[$row['cat_id']]) ) 
    1350                
    1351                         $list_cat[$row['cat_id']] = $row['cat_title']; 
    1352                
    1353                 $parent_id = $row['forum_id']; 
    1354                for( $j = 0; $j < count($list); $j++ ) 
    1355                
    1356                        if( $list[$j]['forum_parent'] == $parent_id ) 
    1357                        
    1358                                $row = $list[$j]; 
    1359                                $s_forums .= '<option value="' . $row['forum_id'] . '">-- ' . $row['forum_name'] . '</option>'; 
    1360                        
    1361                
    1362        
     1322        $row = $list[$i]; 
     1323               $s_forums .= '<option value="' . $row['forum_id'] . '">' . $row['forum_name'] . '</option>'; 
     1324               if ( empty($list_cat[$row['cat_id']]) ) 
     1325               
     1326                       $list_cat[$row['cat_id']] = $row['cat_title']; 
     1327               
     1328               $parent_id = $row['forum_id']; 
     1329        for( $j = 0; $j < count($list); $j++ ) 
     1330       
     1331        if( $list[$j]['forum_parent'] == $parent_id ) 
     1332       
     1333        $row = $list[$j]; 
     1334        $s_forums .= '<option value="' . $row['forum_id'] . '">-- ' . $row['forum_name'] . '</option>'; 
     1335       
     1336       
     1337       
    13631338} 
    13641339 
    13651340if ( $s_forums != '' ) 
    13661341{ 
    1367         $s_forums = '<option value="-1">' . $lang['all_available'] . '</option>' . $s_forums; 
    1368  
    1369         // 
    1370         // Category to search 
    1371         // 
    1372         $s_categories = '<option value="-1">' . $lang['all_available'] . '</option>'; 
    1373         while( list($cat_id, $cat_title) = @each($list_cat)) 
    1374        
    1375                 $s_categories .= '<option value="' . $cat_id . '">' . $cat_title . '</option>'; 
    1376        
     1342       $s_forums = '<option value="-1">' . $lang['all_available'] . '</option>' . $s_forums; 
     1343 
     1344       // 
     1345       // Category to search 
     1346       // 
     1347       $s_categories = '<option value="-1">' . $lang['all_available'] . '</option>'; 
     1348       while( list($cat_id, $cat_title) = @each($list_cat)) 
     1349       
     1350               $s_categories .= '<option value="' . $cat_id . '">' . $cat_title . '</option>'; 
     1351       
    13771352} 
    13781353else 
    13791354{ 
    1380         trigger_error($lang['no_searchable_forums']); 
    1381         return; 
     1355       trigger_error($lang['no_searchable_forums']); 
     1356       return; 
    13821357} 
    13831358 
     
    13921367for($i = 100; $i < 1100 ; $i += 100) 
    13931368{ 
    1394         $selected = ( $i == 200 ) ? ' selected="selected"' : ''; 
    1395         $s_characters .= '<option value="' . $i . '"' . $selected . '>' . $i . '</option>'; 
     1369       $selected = ( $i == 200 ) ? ' selected="selected"' : ''; 
     1370       $s_characters .= '<option value="' . $i . '"' . $selected . '>' . $i . '</option>'; 
    13961371} 
    13971372 
     
    14021377for($i = 0; $i < count($sort_by_types); $i++) 
    14031378{ 
    1404         $s_sort_by .= '<option value="' . $i . '">' . $sort_by_types[$i] . '</option>'; 
     1379       $s_sort_by .= '<option value="' . $i . '">' . $sort_by_types[$i] . '</option>'; 
    14051380} 
    14061381 
     
    14141389for($i = 0; $i < count($previous_days); $i++) 
    14151390{ 
    1416         $selected = ( $topic_days == $previous_days[$i] ) ? ' selected="selected"' : ''; 
    1417         $s_time .= '<option value="' . $previous_days[$i] . '"' . $selected . '>' . $previous_days_text[$i] . '</option>'; 
     1391       $selected = ( $topic_days == $previous_days[$i] ) ? ' selected="selected"' : ''; 
     1392       $s_time .= '<option value="' . $previous_days[$i] . '"' . $selected . '>' . $previous_days_text[$i] . '</option>'; 
    14181393} 
    14191394 
     
    14241399 
    14251400$template->set_filenames(array( 
    1426         'body' => 'forum/search_body.tpl') 
     1401       'body' => 'forum/search_body.tpl') 
    14271402); 
    14281403//make_jumpbox('viewforum.'.$phpEx); 
     
    14301405 
    14311406$template->assign_vars(array( 
    1432         'L_SEARCH_ANY_TERMS' => $lang['search_for_any'], 
    1433         'L_SEARCH_ALL_TERMS' => $lang['search_for_all'], 
    1434         'L_SEARCH_MESSAGE_ONLY' => $lang['search_msg_only'], 
    1435         'L_SEARCH_MESSAGE_TITLE' => $lang['search_title_msg'], 
    1436         'L_CHARACTERS' => $lang['characters_posts'], 
    1437  
    1438         //'S_SEARCH_ACTION' => append_sid("search.$phpEx?mode=results"), 
    1439         'S_SEARCH_ACTION' => append_sid($root_path . 'phpbb2.php?page=search&amp;mode=results'), 
    1440         'S_CHARACTER_OPTIONS' => $s_characters, 
    1441         'S_FORUM_OPTIONS' => $s_forums, 
    1442         'S_CATEGORY_OPTIONS' => $s_categories, 
    1443         'S_TIME_OPTIONS' => $s_time, 
    1444         'S_SORT_OPTIONS' => $s_sort_by, 
    1445         'S_HIDDEN_FIELDS' => '') 
     1407       'L_SEARCH_ANY_TERMS' => $lang['search_for_any'], 
     1408       'L_SEARCH_ALL_TERMS' => $lang['search_for_all'], 
     1409       'L_SEARCH_MESSAGE_ONLY' => $lang['search_msg_only'], 
     1410       'L_SEARCH_MESSAGE_TITLE' => $lang['search_title_msg'], 
     1411       'L_CHARACTERS' => $lang['characters_posts'], 
     1412 
     1413       //'S_SEARCH_ACTION' => append_sid("search.$phpEx?mode=results"), 
     1414       'S_SEARCH_ACTION' => append_sid($root_path . 'phpbb2.php?page=search&amp;mode=results'), 
     1415       'S_CHARACTER_OPTIONS' => $s_characters, 
     1416       'S_FORUM_OPTIONS' => $s_forums, 
     1417       'S_CATEGORY_OPTIONS' => $s_categories, 
     1418       'S_TIME_OPTIONS' => $s_time, 
     1419       'S_SORT_OPTIONS' => $s_sort_by, 
     1420       'S_HIDDEN_FIELDS' => '') 
    14461421); 
    14471422 
  • templates/bithdtv/bithdtv.cfg

    r324 r331  
    160160 
    161161$config['rating_pic_width'] = 20; 
     162 
     163$config['similiar_torrents_height'] = 55; 
    162164?> 
  • templates/bithdtv/details.html

    r324 r331  
    134134    <td class="detail" valign="top" align="left">{REPORT}</td> 
    135135        </tr> 
    136         <!-- BEGIN switch_sos_section --> 
     136        <!-- IF SHOW_SOS_BUTTON --> 
    137137        <tr> 
    138138        <td class="detail" valign="top" align="right">{L_SOS}</td> 
    139             <td class="detail" valign="top" align="left"><input type="button" id="sos_button" value="{L_SOS}" onclick="sos('{ID}');return false;" />{L_SOS_DESCR}</td> 
     139            <td class="detail" valign="top" align="left"><input type="button" id="sos_button" value="{L_SOS}" onclick="sos('{ID}');return false;" /> {L_SOS_DESCR}</td> 
    140140        </tr> 
    141         <!-- END switch_sos_section --> 
     141        <!-- ENDIF --> 
    142142 
    143143</table> 
    144144 
     145<!-- IF SHOW_SIMILIAR_TORRENTS --> 
    145146 
    146 <br /> 
     147<!-- INCLUDE details_similiar_torrents_body.html --> 
     148 
     149<!-- ENDIF --> 
    147150 
    148151<table class="detail" width="700"> 
     152        <caption>{L_LINKS_TO_THIS_TORRENT}</caption> 
     153        <tr> 
     154                <td class="detail" width="100">{L_BBCODE}</td> 
     155                <td><input onclick="this.select();" type="text" style="width:98%" value="[url=&quot;{U_DETAILS_NO_SID}&quot;]{BOOKMARKS_TITLE}[/url]" /></td> 
     156        </tr> 
     157 
     158        <tr> 
     159                <td class="detail">{L_HTML}</td> 
     160                <td><input onclick="this.select();" type="text" style="width:98%" value="&lt;a href=&quot;{U_DETAILS_NO_SID}&quot;&gt;{BOOKMARKS_TITLE}&lt;a&gt;" /></td> 
     161        </tr> 
     162 
     163        <tr> 
     164                <td class="detail">{L_DIRECT_LINK}</td> 
     165                <td><input onclick="this.select();" type="text" style="width:98%" value="{U_DETAILS_NO_SID}" /></td> 
     166        </tr> 
     167 
     168        <tr> 
     169                <td class="detail">{L_TO_BOOKMARKS}</td> 
     170                <td id="add_to_bookmarks"><script type="text/javascript" src="{ROOT_PATH}js/bookmarks.js"></script></td> 
     171        </tr> 
     172</table> 
     173 
     174<table class="detail" width="700"> 
     175<caption>{L_TAGS}</caption> 
    149176  <tr> 
    150     <td width="100">{L_TAGS}</td> 
    151     <td id="details_tags"><!-- INCLUDE tags_view_form.html --></td> 
     177    <td class="detail" width="100">{L_TAGS}</td> 
     178    <td class="detail" id="details_tags"><!-- INCLUDE tags_view_form.html --></td> 
    152179  </tr> 
    153180</table> 
  • templates/bithdtv/message_sendmessage.html

    r259 r331  
    1111<table width="550" border="0" cellspacing="0" cellpadding="5"> 
    1212        <tr> 
    13                 <td colspan="2" class="detail">{L_MESSAGE_FOR} <a href="{U_USERDETAILS_RECEIVER}">{RECEIVER_USERNAME}</a></td> 
     13                <td colspan="2" class="detail">{L_MESSAGE_FOR} {RECEIVER_USERNAME}</td> 
    1414        </tr> 
    1515        <tr> 
  • templates/bithdtv/message_viewmailbox.html

    r249 r331  
    2323        <td class="colhead" width="2%"><input type="checkbox" onclick="this.value=check(document.form1.elements);" /></td> 
    2424        </tr> 
    25     <!-- BEGIN no_pms --> 
     25    <!-- IF not MESSAGES_COUNT --> 
    2626    <tr> 
    2727        <td colspan="6" align="center"><h1>{L_NO_PMS}</h1></td> 
    2828    </tr> 
    29     <!-- END no_pms --> 
     29    <!-- ENDIF --> 
    3030    <!-- BEGIN messages_row --> 
    3131    <tr> 
  • templates/main/details.html

    r328 r331  
    141141    <td valign="top">{REPORT}</td> 
    142142  </tr> 
    143   <!-- BEGIN switch_sos_section --> 
     143 
     144  <!-- IF SHOW_SOS_BUTTON --> 
     145 
    144146  <tr> 
    145147    <td valign="top">{L_SOS}</td> 
    146     <td valign="top"><input type="button" id="sos_button" value="{L_SOS}" onclick="sos('{ID}');return false;" />{L_SOS_DESCR}</td> 
    147   </tr> 
    148   <!-- END switch_sos_section --> 
     148    <td valign="top"><input type="button" id="sos_button" value="{L_SOS}" onclick="sos('{ID}');return false;" /> {L_SOS_DESCR}</td> 
     149  </tr> 
     150 
     151  <!-- ENDIF --> 
     152 
    149153  <tr> 
    150154    <td valign="top">{L_THANKS_USERS}</td> 
     
    157161</table> 
    158162 
     163<!-- IF SHOW_SIMILIAR_TORRENTS --> 
     164 
     165<!-- INCLUDE details_similiar_torrents_body.html --> 
     166 
     167<!-- ENDIF --> 
     168 
     169<table class="border torrent_details"> 
     170        <caption>{L_LINKS_TO_THIS_TORRENT}</caption> 
     171        <tr> 
     172                <td width="100">{L_BBCODE}</td> 
     173                <td><input onclick="this.select();" type="text" style="width:98%" value="[url=&quot;{U_DETAILS_NO_SID}&quot;]{BOOKMARKS_TITLE}[/url]" /></td> 
     174        </tr> 
     175 
     176        <tr> 
     177                <td>{L_HTML}</td> 
     178                <td><input onclick="this.select();" type="text" style="width:98%" value="&lt;a href=&quot;{U_DETAILS_NO_SID}&quot;&gt;{BOOKMARKS_TITLE}&lt;a&gt;" /></td> 
     179        </tr> 
     180 
     181        <tr> 
     182                <td>{L_DIRECT_LINK}</td> 
     183                <td><input onclick="this.select();" type="text" style="width:98%" value="{U_DETAILS_NO_SID}" /></td> 
     184        </tr> 
     185 
     186        <tr> 
     187                <td>{L_TO_BOOKMARKS}</td> 
     188                <td id="add_to_bookmarks"><script type="text/javascript" src="{ROOT_PATH}js/bookmarks.js"></script></td> 
     189        </tr> 
     190</table> 
     191 
    159192<table class="border torrent_details"> 
    160193<caption>{L_TAGS}</caption> 
  • templates/main/main.cfg

    r324 r331  
    167167 
    168168$config['rating_pic_width'] = 20; 
     169 
     170$config['similiar_torrents_height'] = 54; 
    169171?> 
  • templates/main/message_forward_message.html

    r259 r331  
    44<script type="text/javascript" src="{ROOT_PATH}js/ajax_common.js"></script> 
    55 
    6 <div id="preview_box" style="width: 550px;">&nbsp;</div> 
     6<div id="preview_box" style="width: 550px;"></div> 
    77 
    8 <h1>{SUBJECT}</h1> 
    98<form action="{S_FORM_ACTION}" method="post"> 
    10 <input type="hidden" name="action" value="forward" /> 
    11 <input type="hidden" name="id" value="{PM_ID}" /> 
    12 <table width="550" class="border"> 
    13 <tr> 
    14 <td colspan="2">{L_FORWARD_MESSAGE}</td> 
    15 </tr> 
     9 
     10<div class="caption-index">{SUBJECT}</div> 
     11 
     12<table width="100%" class="border"> 
    1613<tr> 
    1714<td>{L_MESSAGE_TO}:</td> 
     
    3835</tr> 
    3936<tr> 
    40 <td colspan="2" align="center"><input type="submit" value="{L_FORWARD}" /> <input type="button" name="preview" onclick="dopreview(this.form.msg.value ,'');" value="{L_PREVIEW}" /></td> 
     37<td colspan="2" align="center"><input type="submit" value="{L_FORWARD}" /> <input type="button" name="preview" onclick="dopreview(this.form.msg.value ,'', '');" value="{L_PREVIEW}" /></td> 
    4138</tr> 
    4239</table> 
     40<input type="hidden" name="action" value="forward" /> 
     41<input type="hidden" name="id" value="{PM_ID}" /> 
    4342</form> 
    4443 
  • templates/main/message_sendmessage.html

    r259 r331  
    99<input type="hidden" name="action" value="send" /> 
    1010<input type="hidden" name="receiver" value="{RECEIVER_ID}" /> 
     11 
    1112<table class="border" width="550"> 
    1213        <tr> 
    13                 <td colspan="2">{L_MESSAGE_FOR} <a href="{U_USERDETAILS_RECEIVER}">{RECEIVER_USERNAME}</a></td> 
     14                <td colspan="2">{L_MESSAGE_FOR} {RECEIVER_USERNAME}</td> 
    1415        </tr> 
    1516        <tr> 
  • templates/main/message_viewmailbox.html

    r228 r331  
    99           <!-- ENDIF --> 
    1010</script> 
    11 <h1>{MAILBOX_NAME}</h1> 
    1211<form action="{S_FORM_ACTION}" method="get"> 
    13   <input type="hidden" name="action" value="viewmailbox" />{L_GOTO}:{PM_BOX_SELECT} <input type="submit" value="{L_GO}" /> 
     12<p align="left"> 
     13<input type="hidden" name="action" value="viewmailbox" />{L_GOTO}:{PM_BOX_SELECT} <input type="submit" value="{L_GO}" /> 
     14</p> 
    1415</form> 
    1516 
    1617<form action="{S_FORM_ACTION}" method="post" name="form1"> 
    17   <table width="600" class="torrents"> 
    18     <thead> 
    19       <tr> 
    20         <th width="2%">&nbsp;&nbsp;</th> 
    21         <th width="65%">{L_SUBJECT} </th> 
    22         <th width="20%">{SENDER_RECEIVER}</th> 
    23         <th width="15%">{L_DATE}</th> 
    24         <th width="2%"><input type="checkbox" onclick="this.value=check(document.form1.elements);" /></th> 
    25       </tr> 
    26     </thead> 
    27       <tbody> 
    28         <!-- BEGIN no_pms --> 
    29         <tr> 
    30           <td colspan="6" align="center"><h1>{L_NO_PMS}</h1></td> 
    31         </tr> 
    32         <!-- END no_pms --> 
    33         <!-- BEGIN messages_row --> 
    34         <tr> 
    35           <td onmousedown="document.getElementById('checkbox_tbl_{messages_row.ID}').checked = (document.getElementById('checkbox_tbl_{messages_row.ID}').checked ? false : true);"><img src="{messages_row.IMG_SRC}" alt="{messages_row.IMG_TITLE}" title="{messages_row.IMG_TITLE}" /></td> 
    36           <td align="left" onmousedown="document.getElementById('checkbox_tbl_{messages_row.ID}').checked = (document.getElementById('checkbox_tbl_{messages_row.ID}').checked ? false : true);"><a href="{messages_row.U_MESSAGE}">{messages_row.SUBJECT}</a></td> 
    37           <td align="center" onmousedown="document.getElementById('checkbox_tbl_{messages_row.ID}').checked = (document.getElementById('checkbox_tbl_{messages_row.ID}').checked ? false : true);">{messages_row.SENDER_RECEIVER_NAME}</td> 
    38           <td align="center" onmousedown="document.getElementById('checkbox_tbl_{messages_row.ID}').checked = (document.getElementById('checkbox_tbl_{messages_row.ID}').checked ? false : true);">{messages_row.DATE}</td> 
    39           <td align="center"><input type="checkbox" name="messages[]" value="{messages_row.ID}" id="checkbox_tbl_{messages_row.ID}" /></td> 
    40         </tr> 
     18<div class="caption-index">{MAILBOX_NAME}</div> 
     19 
     20<div class="index-block"> 
     21        <table class="torrents" width="100%"> 
     22                <thead> 
     23                        <tr> 
     24                                <th width="20">&nbsp;&nbsp;</th> 
     25                                <th width="65%">{L_SUBJECT} </th> 
     26                                <th width="20%" align="center">{SENDER_RECEIVER}</th> 
     27                                <th width="15%" align="center">{L_DATE}</th> 
     28                                <th width="2%"><input type="checkbox" onclick="this.value=check(document.form1.elements);" /></th> 
     29                        </tr> 
     30                </thead> 
     31 
     32                <tbody> 
     33 
     34                <!-- IF not MESSAGES_COUNT --> 
     35 
     36                        <tr> 
     37                                <td colspan="6" align="center"><h1>{L_NO_PMS}</h1></td> 
     38                        </tr> 
     39 
     40                <!-- ENDIF --> 
     41 
     42                <!-- BEGIN messages_row --> 
     43 
     44                <tr> 
     45                        <td><img src="{messages_row.IMG_SRC}" alt="{messages_row.IMG_TITLE}" title="{messages_row.IMG_TITLE}" /></td> 
     46                        <td align="left"><a href="{messages_row.U_MESSAGE}">{messages_row.SUBJECT}</a></td> 
     47                        <td align="center">{messages_row.SENDER_RECEIVER_NAME}</td> 
     48                        <td align="center">{messages_row.DATE}</td> 
     49                        <td align="center"><input type="checkbox" name="messages[]" value="{messages_row.ID}" id="checkbox_tbl_{messages_row.ID}" /></td> 
     50                </tr> 
     51 
    4152        <!-- END messages_row --> 
    42       </tbody> 
     53 
     54                </tbody> 
     55 
     56        </table> 
     57 
     58        <table width="100%"> 
     59                <tr> 
     60                        <td colspan="2" align="left"> 
     61                                <img src="{TEMPLATE_PATH}/images/pn_inboxnew.gif" alt="{L_NEW_UNREAD_PM}" title="{L_NEW_UNREAD_PM}" /> {L_NEW_UNREAD_PM}<br /> 
     62                                <img src="{TEMPLATE_PATH}/images/pn_inbox.gif" alt="{L_OLD_READ_PM}" title="{L_OLD_READ_PM}" /> {L_OLD_READ_PM} 
     63                        </td> 
     64 
     65                        <td colspan="3" align="right"><input type="hidden" name="action" value="moveordel" /><input type="hidden" name="box" value="{MAILBOX}" /> 
     66                        <input type="submit" name="delete" value="{L_DELETE}" onclick="return confirm('{L_DELETE_CONFIRM}')" /> <input type="submit" name="markread" value="{L_READ}" onclick="return confirm('{L_READ_CONFIRM}')" /> 
     67                        </td> 
     68                </tr> 
    4369  </table> 
    44   <table width="600"> 
    45       <tr> 
    46         <td colspan="2" align="left"> 
    47           <img src="{TEMPLATE_PATH}/images/pn_inboxnew.gif" alt="{L_NEW_UNREAD_PM}" title="{L_NEW_UNREAD_PM}" /> {L_NEW_UNREAD_PM}<br /> 
    48           <img src="{TEMPLATE_PATH}/images/pn_inbox.gif" alt="{L_OLD_READ_PM}" title="{L_OLD_READ_PM}" /> {L_OLD_READ_PM} 
    49         </td> 
    50         <td colspan="3" align="right"><input type="hidden" name="action" value="moveordel" /><input type="hidden" name="box" value="{MAILBOX}" /> 
    51           <input type="submit" name="delete" value="{L_DELETE}" onclick="return confirm('{L_DELETE_CONFIRM}')" /> <input type="submit" name="markread" value="{L_READ}" onclick="return confirm('{L_READ_CONFIRM}')" /> 
    52         </td> 
    53       </tr> 
    54   </table> 
     70</div> 
    5571</form> 
     72 
    5673{PAGERBOTTOM} 
    5774 
  • templates/main/message_viewmessage_body.html

    r83 r331  
    11<!-- INCLUDE overall_header.html --> 
    22 
    3 <h1>{SUBJECT}</h1> 
    4 <table width="550" class="border"> 
     3<div class="caption-index">{SUBJECT}</div> 
     4 
     5<table width="100%" class="border"> 
    56        <tr> 
    67                <td width="50%">{FROM}</td> 
     
    2324                <div id="messages_history" style="height:100px;overflow:auto;"> 
    2425                <!-- BEGIN messages_history_row --> 
     26 
     27                <div style="padding:10px 0 5px 0;"> 
     28 
    2529                <strong>{L_SUBJECT}: </strong>{messages_history.messages_history_row.SUBJECT} <strong>{L_ADDED}: </strong>{messages_history.messages_history_row.ADDED} <strong>{L_FROM}: </strong>{messages_history.messages_history_row.USERNAME}<br /> 
    2630                <hr /> 
    2731                {messages_history.messages_history_row.MESSAGE} 
    2832                <hr /> 
     33                </div> 
    2934                <!-- END messages_history_row --> 
    3035                </div> 
     
    3439</table> 
    3540 
     41 
     42 
    3643<!-- INCLUDE overall_footer.html --> 
  • templates/reflection/details.html

    r324 r331  
    5353<div class="torrentViewRight">{TYPE}</div> 
    5454 
    55 <div class="torrentViewLeft">{L_TAGS}</div> 
    56 <div class="torrentViewRight" id="details_tags"><!-- INCLUDE tags_view_form.html --></div> 
    57  
    5855<div class="torrentViewLeft">{L_LAST_SEEDER}</div> 
    5956<div class="torrentViewRight">{LAST_ACTIVITY}</div> 
     
    109106    <a href="javascript:void(0);" onclick="view_details_ext('filelist', '{ID}', 'details');" id="filelist_href">[<!-- IF FILELIST_TPL -->{L_HIDE_LIST}<!-- ELSE -->{L_SEE_FULL_LIST}<!-- ENDIF -->]</a></div> 
    110107<div class="torrentViewRight">{NUM_FILES}<div id="filelist_row">{FILELIST_TPL}</div></div> 
    111 <br /><br /><br /><br /> 
     108<br /><br /> 
    112109<div class="torrentViewLeft">{L_PEERS}<br /><a href="javascript:void(0);" onclick="view_details_ext('peerlist', '{ID}', 'details');" id="peerlist_href">[<!-- IF PEERLIST_TPL -->{L_HIDE_LIST}<!-- ELSE -->{L_SEE_FULL_LIST}<!-- ENDIF -->]</a></div> 
    113110<div class="torrentViewRight">{PEERS_COUNT}<div id="peerlist_row">{PEERLIST_TPL}</div></div> 
    114 <br /><br /><br /><br /> 
     111<br /><br /> 
    115112<div class="torrentViewLeft">{L_REPORT}</div> 
    116113<div class="torrentViewRight">{REPORT}</div> 
    117114 
    118 <!-- BEGIN switch_sos_section --> 
     115<!-- IF SHOW_SOS_BUTTON --> 
    119116<div class="torrentViewLeft">{L_SOS}</div> 
    120 <div class="torrentViewRight"><input type="button" id="sos_button" value="{L_SOS}" onclick="sos('{ID}');return false;" />{L_SOS_DESCR}</div> 
    121 <!-- END switch_sos_section --> 
     117<div class="torrentViewRight"><input type="button" id="sos_button" value="{L_SOS}" onclick="sos('{ID}');return false;" /> {L_SOS_DESCR}</div> 
     118<!-- ENDIF --> 
    122119 
    123120<div class="torrentViewLeft">{L_THANKS_USERS}</div> 
     
    130127<br clear="all" /> 
    131128 
     129 
     130 
     131<!-- IF SHOW_SIMILIAR_TORRENTS --> 
     132 
     133<!-- INCLUDE details_similiar_torrents_body.html --> 
     134 
     135<!-- ENDIF --> 
     136 
     137<p><span class="header">{L_LINKS_TO_THIS_TORRENT}</span></p> 
     138<div class="torrentViewDetails"> 
     139        <div class="torrentViewLeft">{L_BBCODE}</div> 
     140        <div class="torrentViewRight"><input onclick="this.select();" type="text" style="width:98%" value="[url=&quot;{U_DETAILS_NO_SID}&quot;]{BOOKMARKS_TITLE}[/url]" /></div> 
     141 
     142        <div class="torrentViewLeft">{L_HTML}</div> 
     143        <div class="torrentViewRight"><input onclick="this.select();" type="text" style="width:98%" value="&lt;a href=&quot;{U_DETAILS_NO_SID}&quot;&gt;{BOOKMARKS_TITLE}&lt;a&gt;" /></div> 
     144 
     145        <div class="torrentViewLeft">{L_DIRECT_LINK}</div> 
     146        <div class="torrentViewRight"><input onclick="this.select();" type="text" style="width:98%" value="{U_DETAILS_NO_SID}" /></div> 
     147 
     148        <div class="torrentViewLeft">{L_TO_BOOKMARKS}</div> 
     149        <div id="add_to_bookmarks" class="torrentViewRight"><script type="text/javascript" src="{ROOT_PATH}js/bookmarks.js"></script></div> 
     150</div> 
     151 
     152<p><span class="header">{L_TAGS}</span></p> 
     153<p id="details_tags"><!-- INCLUDE tags_view_form.html --></p> 
     154 
    132155<!-- INCLUDE details_comments.html --> 
    133156 
  • templates/reflection/message_sendmessage.html

    r259 r331  
    1212<div class="table"> 
    1313        <div class="tableRow"> 
    14                 <div class="leftCell">{L_MESSAGE_FOR} <a href="{U_USERDETAILS_RECEIVER}">{RECEIVER_USERNAME}</a></div> 
     14                <div class="leftCell">{L_MESSAGE_FOR} {RECEIVER_USERNAME}</div> 
    1515                <div class="clear">&nbsp;</div> 
    1616        </div> 
  • templates/reflection/message_viewmailbox.html

    r228 r331  
    1717<div class="table"> 
    1818        <div class="tableRowHeader"> 
    19                 <div class="leftCellHeader" style="width:5%">&nbsp;&nbsp;</div> 
    20                 <div class="middleCellHeader" style="width:35%">{L_SUBJECT} </div> 
     19                <div class="leftCellHeader" style="width:20px">&nbsp;&nbsp;</div> 
     20                <div class="middleCellHeader" style="width:45%">{L_SUBJECT} </div> 
    2121                <div class="middleCellHeader" style="width:20%">{SENDER_RECEIVER}</div> 
    22                 <div class="middleCellHeader" style="width:25%">{L_DATE}</div> 
    23                 <div class="rightCellHeader" style="width:5%"><input type="checkbox" onclick="this.value=check(document.form1.elements);" /></div> 
     22                <div class="middleCellHeader" style="width:15%">{L_DATE}</div> 
     23                <div class="rightCellHeader" style="width:20px"><input type="checkbox" onclick="this.value=check(document.form1.elements);" /></div> 
    2424                <div class="clear">&nbsp;</div> 
    2525        </div> 
    26      <!-- BEGIN no_pms --> 
     26 
     27     <!-- IF not MESSAGES_COUNT --> 
    2728     <div class="tableRowHeader"> 
    2829             <div class="leftCellHeader"><h1>{L_NO_PMS}</h1></div> 
    2930             <div class="clear">&nbsp;</div> 
    3031     </div> 
    31      <!-- END no_pms --> 
     32     <!-- ENDIF --> 
     33 
     34 
    3235     <!-- BEGIN messages_row --> 
    3336        <div class="tableRow"> 
    34                 <div class="leftCell" style="width:5%" onmousedown="document.getElementById('checkbox_tbl_{messages_row.ID}').checked = (document.getElementById('checkbox_tbl_{messages_row.ID}').checked ? false : true);"><img src="{messages_row.IMG_SRC}" alt="{messages_row.IMG_TITLE}" title="{messages_row.IMG_TITLE}" /></div> 
    35                 <div class="middleCell" style="width:35%" onmousedown="document.getElementById('checkbox_tbl_{messages_row.ID}').checked = (document.getElementById('checkbox_tbl_{messages_row.ID}').checked ? false : true);"><a href="{messages_row.U_MESSAGE}">{messages_row.SUBJECT}</a></div> 
     37                <div class="leftCell" style="width:20px" onmousedown="document.getElementById('checkbox_tbl_{messages_row.ID}').checked = (document.getElementById('checkbox_tbl_{messages_row.ID}').checked ? false : true);"><img src="{messages_row.IMG_SRC}" alt="{messages_row.IMG_TITLE}" title="{messages_row.IMG_TITLE}" /></div> 
     38                <div class="middleCell" style="width:45%" onmousedown="document.getElementById('checkbox_tbl_{messages_row.ID}').checked = (document.getElementById('checkbox_tbl_{messages_row.ID}').checked ? false : true);"><a href="{messages_row.U_MESSAGE}">{messages_row.SUBJECT}</a></div> 
    3639                <div class="middleCell" style="width:20%" onmousedown="document.getElementById('checkbox_tbl_{messages_row.ID}').checked = (document.getElementById('checkbox_tbl_{messages_row.ID}').checked ? false : true);">{messages_row.SENDER_RECEIVER_NAME}</div> 
    37                 <div class="middleCell" style="width:25%" onmousedown="document.getElementById('checkbox_tbl_{messages_row.ID}').checked = (document.getElementById('checkbox_tbl_{messages_row.ID}').checked ? false : true);">{messages_row.DATE}</div> 
    38                 <div class="rightCell" style="width:5%"><input type="checkbox" name="messages[]" value="{messages_row.ID}" id="checkbox_tbl_{messages_row.ID}" /></div> 
     40                <div class="middleCell" style="width:15%" onmousedown="document.getElementById('checkbox_tbl_{messages_row.ID}').checked = (document.getElementById('checkbox_tbl_{messages_row.ID}').checked ? false : true);">{messages_row.DATE}</div> 
     41                <div class="rightCell" style="width:20px"><input type="checkbox" name="messages[]" value="{messages_row.ID}" id="checkbox_tbl_{messages_row.ID}" /></div> 
    3942                <div class="clear">&nbsp;</div> 
    4043        </div> 
     
    4447<div class="table"> 
    4548        <div class="tableRow"> 
    46                 <div class="leftCellHeader" style="width:40%"> 
     49                <div class="leftCellHeader" style="width:90%"> 
    4750          <img src="{TEMPLATE_PATH}/images/pn_inboxnew.gif" alt="{L_NEW_UNREAD_PM}" title="{L_NEW_UNREAD_PM}" /> {L_NEW_UNREAD_PM}<br /> 
    4851          <img src="{TEMPLATE_PATH}/images/pn_inbox.gif" alt="{L_OLD_READ_PM}" title="{L_OLD_READ_PM}" /> {L_OLD_READ_PM} 
    4952          </div> 
    50                 <div class="rightCellHeader" style="width:60%"><input type="hidden" name="action" value="moveordel" /><input type="hidden" name="box" value="{MAILBOX}" /> 
     53                <div class="rightCellHeader" style="width:10%;text-align:right;"><input type="hidden" name="action" value="moveordel" /><input type="hidden" name="box" value="{MAILBOX}" /> 
    5154          <input type="submit" name="delete" value="{L_DELETE}" onclick="return confirm('{L_DELETE_CONFIRM}')" /> <input type="submit" name="markread" value="{L_READ}" onclick="return confirm('{L_READ_CONFIRM}')" /> 
    5255                </div> 
  • templates/reflection/reflection.cfg

    r324 r331  
    162162 
    163163$config['rating_pic_width'] = 20; 
     164 
     165$config['similiar_torrents_height'] = 50; 
    164166?> 
  • templates/reflection/reflection.css

    r324 r331  
    332332 
    333333.torrentViewRight { 
    334 margin-left:7em; 
    335334padding-left:1em; 
    336 width:75%; 
     335margin-left:12%; 
    337336padding-bottom:1em; 
    338337} 
     
    482481list-style:none; 
    483482margin:20px 0; 
    484 padding:0 10px 15px; 
     483padding:10px 5px 5px 5px; 
    485484} 
    486485 
    487486.comment_header { 
    488487position:relative; 
    489 top:-13px; 
     488top:-20px; 
    490489} 
    491490 
    492491.commentLeftPart { 
    493492float:left; 
    494 margin-right:12px; 
    495 min-width:100px; 
     493width:130px; 
    496494margin-bottom:10px; 
    497495min-height:100px; 
     
    500498.commenttext { 
    501499margin-bottom:10px; 
    502 margin-left:120px; 
     500margin-left:140px; 
    503501} 
    504502