Changeset 216

Show
Ignore:
Timestamp:
02/08/09 13:53:55 (3 years ago)
Author:
Nafania
Message:

Механизм отсылки ЛС изменен.
Теперь ЛС везде отсылается с высылкой уведомления на емаил, а не только при отсылке через личные сообщения.

Изменен чат. Отныне он вписывается в дизайн трекера через iframe.

Исправлена ошибка в редакторе категорий, где невозможно было выставить лимит загрузки торрентов.

Идет переход на новую систему репутации и добавляется система званий, на базе репутации.

Апдейт sql базы, увеличивающий значения полей в таблице config. Varchar 255 может не хватить, меняем на TEXT.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • admin/admin_categories.php

    r212 r216  
    4747switch ( $mode ) { 
    4848        case 'edit': 
    49                 $cat_name = request_var('cat_name', array(''=>'')); 
    50                 $cat_image = request_var('cat_image', array(''=>'')); 
     49                $cat_name = request_var('cat_name', array(0=>'')); 
     50                $cat_image = request_var('cat_image', array(0=>'')); 
    5151                $allow_upload = request_var('allow_upload', array(0=>0)); 
    5252                $anonymous_view = request_var('anonymous_view', array(0=>0)); 
     53                $torrent_limit = request_var('torrent_limit', array(0=>0)); 
    5354 
    5455                foreach ( $cat_name AS $cat_id => $cat_new_name ) { 
     
    5859                        $allow_upload_val = ( isset($allow_upload[$cat_id]) ? 1 : 0 ); 
    5960                        $anonymous_view_val = ( isset($anonymous_view[$cat_id]) ? 1 : 0 ); 
    60  
    61                         $sql = 'UPDATE ' . CATEGORIES_TABLE . ' SET name = \'' . $db->sql_escape($cat_new_name) . '\', allow_upload = ' . $allow_upload_val . ', anonymous_view = ' . $anonymous_view_val . ' WHERE id = ' . intval($cat_id); 
     61                        $torrent_limit_val = ( isset($torrent_limit[$cat_id]) ? $torrent_limit[$cat_id] : 0 ); 
     62 
     63                        $sql = 'UPDATE ' . CATEGORIES_TABLE . ' SET name = \'' . $db->sql_escape($cat_new_name) . '\', allow_upload = ' . $allow_upload_val . ', anonymous_view = ' . $anonymous_view_val . ', torrents_limit = ' . $torrent_limit_val . ' WHERE id = ' . $cat_id; 
    6264                        $db->sql_query($sql); 
    6365                } 
     
    6567                foreach ( $cat_image AS $cat_id => $cat_new_image ) { 
    6668                        $cat_new_image = ( in_array($cat_new_image, $cat_images_ary) ? $cat_new_image : '' ); 
    67                         $sql = 'UPDATE ' . CATEGORIES_TABLE . ' SET image = \'' . $db->sql_escape($cat_new_image) . '\' WHERE id = ' . intval($cat_id)
     69                        $sql = 'UPDATE ' . CATEGORIES_TABLE . ' SET image = \'' . $db->sql_escape($cat_new_image) . '\' WHERE id = ' . $cat_id
    6870                        $db->sql_query($sql); 
    6971                } 
  • admin/admin_ranks.php

    r212 r216  
    9292                ); 
    9393 
     94                $fields_ary = array('rank_name', 'rank_points', 'rank_image'); 
     95                foreach ( $fields_ary AS $_null => $field ) { 
     96                        $$field = ( isset($rank_info[$field]) ? $rank_info[$field] : '' ); 
     97                } 
     98 
    9499                $template->assign_vars(array( 
    95                         "RANK" => $rank_info['rank_name']
    96                         "MINIMUM" => $rank_info['rank_points']
    97                         "IMAGE" => ( $rank_info['rank_image'] != "" ) ? $rank_info['rank_image'] : ""
    98                         "IMAGE_DISPLAY" => ( $rank_info['rank_image'] != "" ) ? '<img src="../' . $rank_info['rank_image'] . '" />' : "", 
     100                        "RANK" => $rank_name
     101                        "MINIMUM" => $rank_points
     102                        "IMAGE" => $rank_image
     103                        "IMAGE_DISPLAY" => ( $rank_image != "" ) ? '<img src="../' . $rank_image . '" />' : "", 
    99104 
    100105                        "S_RANK_ACTION" => append_sid("admin_ranks.$phpEx"), 
  • chat.php

    r215 r216  
    99loggedinorreturn(); 
    1010 
     11$request = ''; 
     12if ( isset($_GET) ) { 
     13        foreach ( $_GET AS $param => $query ) { 
     14                $request .= ( $request ? '&' : '' ) . $param . '=' . $query; 
     15        } 
     16} 
     17 
     18if ( isset($_POST) ) { 
     19        foreach ( $_POST AS $param => $query ) { 
     20                $request .= ( $request ? '&' : '' ) . $param . '=' . $query; 
     21        } 
     22} 
     23 
     24$chat_url = $root_path . 'chat/index.php' . ( $request ? '?' . $request : '' ); 
     25 
     26$template->assign_vars( array( 
     27        'CHAT_URL' => append_sid($chat_url) 
     28)); 
     29 
    1130stdhead($lang['chat']); 
    1231$template->set_filenames(array( 
    13         'body' => 'chat.html') 
    14 )
     32        'body' => 'chat.html' 
     33))
    1534stdfoot(); 
    1635?> 
  • db_updater.php

    r211 r216  
    248248        $db->sql_query('CREATE TABLE IF NOT EXISTS `ranks` (`rank_id` int(10) NOT NULL auto_increment, `rank_name` varchar(255) NOT NULL, `rank_points` int(10) NOT NULL,`rank_image` varchar(255) NOT NULL,PRIMARY KEY  (`rank_id`))'); 
    249249 
     250        $db->sql_query('ALTER TABLE ' . CONFIG_TABLE . ' CHANGE `value` `value` TEXT NOT NULL'); 
     251 
    250252 
    251253        $message .= 'Database updated sucefully. Now you must delete this file!'; 
  • include/details/delete.php

    r213 r216  
    55 
    66$reason = request_var('delete_reason', ''); 
     7$pm_ary = array(); 
    78 
    8 $sql = 'SELECT t.name, t.owner, t.seeders, u.language FROM ' . TORRENTS_TABLE . ' t, ' . USERS_TABLE . ' u WHERE t.fid = ' . $id . ' AND t.owner = u.uid'; 
     9$sql = 'SELECT t.name, t.owner, t.seeders, u.language, u.name AS username, u.email, u.notifs, u.language, u.class FROM ' . TORRENTS_TABLE . ' t, ' . USERS_TABLE . ' u WHERE t.fid = ' . $id . ' AND t.owner = u.uid'; 
    910$result = $db->sql_query( $sql ); 
    1011if ( !( $row = $db->sql_fetchrow( $result ) ) ) { 
     
    1920 
    2021if ( $userdata['uid'] != $row['owner'] && $row['owner'] != ANONYMOUS ) { 
    21         @include( $root_path . 'languages/lang_' . $row['language'] . '/lang_pms.php' ); 
    22         $sql = 'INSERT INTO ' . PRIVATE_MESSAGES_TABLE . ' ' . $db->sql_build_array( 'INSERT', array( 'sender' => 0, 
    23                         'receiver' => $row['owner'], 
    24                         'added' => time(), 
    25                         'msg' => sprintf( $lang['pm_yours_torrent_deleted_body'], $row['name'], $reason ), 
    26                         'location' => 1, 
    27                         'subject' => $lang['pm_yours_torrent_deleted_subject'] ) ); 
    28         $db->sql_query( $sql ); 
     22        require_once ($root_path . 'languages/lang_' . $row['language'] . '/lang_pms.php'); 
    2923 
    30         $sql = 'UPDATE ' . USERS_TABLE . ' SET user_unread_pms = user_unread_pms + 1 WHERE uid = ' . $row['owner']; 
    31         $db->sql_query( $sql ); 
     24        $pm_ary[] = array( 
     25                'sender' => 0, 
     26                'receiver' => $row['owner'], 
     27                'msg' => sprintf( $lang['pm_yours_torrent_deleted_body'], $row['name'], $reason ), 
     28                'subject' => $lang['pm_yours_torrent_deleted_subject'], 
     29                'name' => $row['username'], 
     30                'email' => $row['email'], 
     31                'notifs' => $row['notifs'], 
     32                'language' => $row['language'], 
     33                'class' => $row['class'] 
     34        ); 
     35        send_pm($pm_ary); 
     36 
    3237} 
    3338$delete_arr = array( $id ); 
  • include/modtask/edituser.php

    r215 r216  
    33$updateset = array(); 
    44$modcomment = array(); 
     5$pm_ary = array(); 
    56$user_limit_ary_torrents = unserialize($config['user_limit_ary_torrents']); 
    67$user_limit_ary_allow_download = unserialize($config['user_limit_ary_allow_download']); 
     
    5657                $modcomment[] = sprintf($lang['modcomment_demoted_promoted_to_class'], 't' . time(), ($class > $this_userdata['class'] ? $lang['promote'] : $lang['demote'] ), get_user_class_name($class), $userdata['name'] ); 
    5758 
    58                 $sql_ary = array( 
    59                                 'sender'   => 0, 
    60                                 'receiver' => $userid, 
    61                        'subject'  => sprintf($lang['pm_class_changed_subject'], ($class > $this_userdata['class'] ? $lang['promote'] : $lang['demote'] ) ), 
    62                        'msg'      => sprintf($lang['pm_class_changed_body'], ($class > $this_userdata['class'] ? $lang['promoted'] : $lang['demoted']), get_user_class_name($class), $userdata['name'] ), 
    63                        'added'    => time(), 
    64                        'location' => 1 
     59                $pm_ary[] = array( 
     60                        'sender' => 0, 
     61                        'receiver' => $userid, 
     62                        'msg' => sprintf($lang['pm_class_changed_body'], ($class > $this_userdata['class'] ? $lang['promoted'] : $lang['demoted']), get_user_class_name($class), $userdata['name'] ), 
     63                        'subject' => sprintf($lang['pm_class_changed_subject'], ($class > $this_userdata['class'] ? $lang['promote'] : $lang['demote'] ) ), 
     64 
     65                        'name' => $this_userdata['name'], 
     66                        'email' => $this_userdata['email'], 
     67                        'notifs' => $this_userdata['notifs'], 
     68                        'language' => $this_userdata['language'], 
     69                        'class' => $this_userdata['class'] 
    6570                ); 
    6671 
    67                 $db->sql_query('INSERT INTO ' . PRIVATE_MESSAGES_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); 
     72                send_pm($pm_ary); 
    6873 
    6974                $sql = 'UPDATE ' . USERS_TABLE . ' SET user_unread_pms = user_unread_pms + 1 WHERE uid = ' . $userid; 
     
    8691        require_once ($root_path . 'languages/lang_' . $this_userdata['language'] . '/lang_pms.php'); 
    8792 
    88         $sql_ary = array( 
    89                         'sender'   => 0, 
    90                         'receiver' => $userid, 
    91                'subject'  => $lang['pm_warn_deleted_subject'], 
    92                'msg'      => sprintf($lang['pm_warn_deleted_body'], $userdata['name']), 
    93                'added'    => time(), 
    94                'location' => 1 
    95      ); 
    96      $db->sql_query('INSERT INTO ' . PRIVATE_MESSAGES_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); 
     93        $pm_ary[] = array( 
     94                'sender' => 0, 
     95                'receiver' => $userid, 
     96                'msg' => sprintf($lang['pm_warn_deleted_body'], $userdata['name']), 
     97                'subject' => $lang['pm_warn_deleted_subject'], 
    9798 
    98      $sql = 'UPDATE ' . USERS_TABLE . ' SET user_unread_pms = user_unread_pms + 1 WHERE uid = ' . $userid; 
    99      $db->sql_query($sql); 
     99                'name' => $this_userdata['name'], 
     100                'email' => $this_userdata['email'], 
     101                'notifs' => $this_userdata['notifs'], 
     102                'language' => $this_userdata['language'], 
     103                'class' => $this_userdata['class'] 
     104        ); 
     105        send_pm($pm_ary); 
    100106 
    101107     $updateset[] = 'warneduntil = 0'; 
     
    113119     $dur = ( $warnlength * 7 ); 
    114120 
    115      $sql_ary = array( 
    116                         'sender'   => 0, 
    117                'receiver' => $userid, 
    118                'subject'  => $lang['pm_warn_received_subject'], 
    119                'msg'      => sprintf($lang['pm_warn_received_body'], $dur, $userdata['name'], $warnpm), 
    120                'added'    => time(), 
    121                'location' => 1 
    122      ); 
    123      $db->sql_query('INSERT INTO ' . PRIVATE_MESSAGES_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); 
     121        $pm_ary[] = array( 
     122                'sender' => 0, 
     123                'receiver' => $userid, 
     124                'msg' => sprintf($lang['pm_warn_received_body'], $dur, $userdata['name'], $warnpm), 
     125                'subject' => $lang['pm_warn_received_subject'], 
    124126 
    125      $sql = 'UPDATE ' . USERS_TABLE . ' SET user_unread_pms = user_unread_pms + 1 WHERE uid = ' . $userid; 
    126      $db->sql_query($sql); 
     127                'name' => $this_userdata['name'], 
     128                'email' => $this_userdata['email'], 
     129                'notifs' => $this_userdata['notifs'], 
     130                'language' => $this_userdata['language'], 
     131                'class' => $this_userdata['class'] 
     132        ); 
     133        send_pm($pm_ary); 
    127134 
    128135     $updateset[] = 'warneduntil = ' . $warneduntil; 
  • include/modtask/mass_torrent_actions.php

    r213 r216  
    2626$cats = genrelist(); 
    2727 
    28 $sql = 'SELECT t.fid, t.name, t.owner, u.language, t.category 
     28$sql = 'SELECT t.fid, t.name, t.owner, t.category, u.name AS username, u.language, u.email, u.notifs, u.language, u.class 
    2929                FROM ' . TORRENTS_TABLE . ' t, ' . USERS_TABLE . ' u 
    3030                WHERE t.fid IN (' . $ids . ') 
     
    3838        $torrents_ary[] = $torrents_row; 
    3939 
    40         $cat_name_display = ( isset($cats[$cats[$torrents_row['category']]['cat_parent']]['cat_name']) ? '<a href="' . append_sid('browse.php?cat=' . $cats[$cats[$torrents_row['category']]['cat_parent']]['cat_id']) . '">' . $cats[$cats[$ary[$i]['category']]['cat_parent']]['cat_name'] . '</a> -> <a href="' . append_sid('browse.php?cat=' . $torrents_row['category']) . '">' . $cats[$torrents_row['category']]['cat_name'] . '</a>' : '' ); 
     40        $cat_name_display = ( isset($cats[$cats[$torrents_row['category']]['cat_parent']]['cat_name']) ? '<a href="' . append_sid('browse.php?cat=' . $cats[$cats[$torrents_row['category']]['cat_parent']]['cat_id']) . '">' . $cats[$cats[$torrents_row['category']]['cat_parent']]['cat_name'] . '</a> -> <a href="' . append_sid('browse.php?cat=' . $torrents_row['category']) . '">' . $cats[$torrents_row['category']]['cat_name'] . '</a>' : '' ); 
    4141 
    4242        $template->assign_block_vars('torrents_row', array( 
     
    8181 
    8282                        $delete_arr = array(); 
     83                        $pm_ary = array(); 
    8384 
    8485                        foreach ( $torrents_ary AS $_null => $ary ) { 
     
    8687                                        require_once ($root_path . 'languages/lang_' . $ary['language'] . '/lang_pms.php'); 
    8788 
    88                                         $sql = 'INSERT INTO ' . PRIVATE_MESSAGES_TABLE . ' ' . $db->sql_build_array( 'INSERT', array( 
     89                                        $pm_ary[] = array( 
    8990                                                'sender' => 0, 
    9091                                                'receiver' => $ary['owner'], 
    91                                                 'added' => time(), 
    9292                                                'msg' => sprintf( $lang['pm_yours_torrent_deleted_body'], $ary['name'], $reason ), 
    93                                                 'location' => 1, 
    94                                                 'subject' => $lang['pm_yours_torrent_deleted_subject'] ) 
     93                                                'subject' => $lang['pm_yours_torrent_deleted_subject'], 
     94 
     95                                                'name' => $ary['username'], 
     96                                                'email' => $ary['email'], 
     97                                                'notifs' => $ary['notifs'], 
     98                                                'language' => $ary['language'], 
     99                                                'class' => $ary['class'] 
    95100                                        ); 
    96                                         $db->sql_query($sql); 
    97  
    98                                         $sql = 'UPDATE ' . USERS_TABLE . ' SET user_unread_pms = user_unread_pms + 1 WHERE uid = ' . $ary['owner']; 
    99                                         $db->sql_query($sql); 
    100101                                } 
    101102 
     
    105106 
    106107                        } 
     108 
     109                        send_pm($pm_ary); 
    107110 
    108111                        deletetorrent( $delete_arr ); 
  • index.php

    r191 r216  
    2626        if ( $birthday_arr = $db->sql_fetchrow($result) ) { 
    2727                do { 
    28                         $age = get_age($birthday_arr['birthday']); 
    29                         if ( $birthday_users ) { 
    30                                 $birthday_users .= ",\n"; 
    31                         } 
    32                         $birthday_arr['name'] = get_user_class_color($birthday_arr['class'], $birthday_arr['name']); 
    33                         $birthday_users .= '<a href="' . append_sid('userdetails.php?id=' . $birthday_arr['uid']) . '">' . $birthday_arr['name'] . '</a> (' . $age . ')' . get_user_icons($birthday_arr); 
     28               $age = get_age($birthday_arr['birthday']); 
     29                    $birthday_arr['name'] = get_user_class_color($birthday_arr['class'], $birthday_arr['name']); 
     30                    $birthday_users .= ( $birthday_users ? ', ' : '' ) . '<a href="' . append_sid('userdetails.php?id=' . $birthday_arr['uid']) . '">' . $birthday_arr['name'] . '</a> (' . $age . ')' . get_user_icons($birthday_arr); 
    3431 
    3532                } 
    3633                while ($birthday_arr = $db->sql_fetchrow($result)); 
    37        
    38         $db->sql_freeresult($result); 
    39         //end birthday users 
    40  
    41         $template->assign_vars(array( 
    42                 'BIRTHDAY_USERS' => $birthday_users ) 
    43         ); 
    44  
    45         /* start poll */ 
    46         $sql = 'SELECT vote_id, vote_start, vote_length 
    47                 FROM ' . VOTE_DESC_TABLE . ' 
    48                 WHERE topic_id = 0 
    49                 ORDER by vote_id DESC'; 
    50         $result = $db->sql_query_limit($sql, 1, 0, 24 * 60 * 60); 
    51         $poll_id = 0; 
    52         $poll_until = 0; 
    53         if ( $row = $db->sql_fetchrow($result) ) { 
    54               $poll_id = $row['vote_id']; 
    55               $poll_until = ( $row['vote_length'] ) ? ( 5 * 24 * 60 * 60 ) + $row['vote_start'] + $row['vote_length'] : 0; 
     34       
     35       $db->sql_freeresult($result); 
     36       //end birthday users 
     37 
     38       $template->assign_vars(array( 
     39               'BIRTHDAY_USERS' => $birthday_users ) 
     40       ); 
     41 
     42       /* start poll */ 
     43       $sql = 'SELECT vote_id, vote_start, vote_length 
     44               FROM ' . VOTE_DESC_TABLE . ' 
     45               WHERE topic_id = 0 
     46               ORDER by vote_id DESC'; 
     47               $result = $db->sql_query_limit($sql, 1, 0, 24 * 60 * 60); 
     48       $poll_id = 0; 
     49       $poll_until = 0; 
     50       if ( $row = $db->sql_fetchrow($result) ) { 
     51              $poll_id = $row['vote_id']; 
     52              $poll_until = ( $row['vote_length'] ) ? ( 5 * 24 * 60 * 60 ) + $row['vote_start'] + $row['vote_length'] : 0; 
    5653        } 
    57         $db->sql_freeresult($result); 
    58         if ( $poll_id && ( !$poll_until || $poll_until > time() ) ) { 
    59                 $template->assign_block_vars('poll', array( 
    60                         'POLL_ID' => $poll_id, 
    61                         'U_VIEW_RESULT' => append_sid($root_path . '?vote=viewresult'), 
    62                         'IMG_BAR_LEFT' => $images['bar_left'], 
    63                         'IMG_BAR' => $images['bar'], 
    64                         'IMG_BAR_RIGHT' => $images['bar_right']) 
    65                 ); 
    66  
    67                 $sql = 'SELECT vd.vote_id, vd.vote_text, vd.vote_start, vd.vote_length, vr.vote_option_id, vr.vote_option_text, vr.vote_result 
    68                         FROM ' . VOTE_DESC_TABLE . ' vd, ' . VOTE_RESULTS_TABLE . ' vr 
    69                         WHERE vd.topic_id = 0 
    70                         AND vr.vote_id = vd.vote_id 
    71                         AND vd.vote_id = ' . $poll_id . ' 
    72                         ORDER BY vr.vote_option_id ASC'; 
    73                 $result = $db->sql_query($sql); 
    74  
    75                 if ( $vote_info = $db->sql_fetchrowset($result) ) { 
    76                         $db->sql_freeresult($result); 
    77                         $vote_options = sizeof($vote_info); 
    78  
    79                         $vote_id = $vote_info[0]['vote_id']; 
    80                         $vote_title = $vote_info[0]['vote_text']; 
    81  
    82                         $sql = 'SELECT vote_id 
    83                                 FROM ' . VOTE_USERS_TABLE . ' 
    84                                 WHERE vote_id = ' . $vote_id . ' 
    85                                 AND vote_user_id = ' . $userdata['uid']; 
    86                         $result = $db->sql_query($sql); 
    87  
    88                         $user_voted = ( $row = $db->sql_fetchrow($result) ) ? TRUE : 0; 
    89                         $db->sql_freeresult($result); 
    90  
    91                         if ( isset($_GET['vote']) || isset($_POST['vote']) ) { 
    92                                 $view_result = ( ( ( isset($_GET['vote']) ) ? $_GET['vote'] : $_POST['vote'] ) == 'viewresult' ) ? TRUE : 0; 
    93                                 if ( isset($_POST['vote_option_id']) ) { 
    94                                         if ( $user_voted ) { 
    95                                                 trigger_error($lang['dupe_vote']); 
    96                                         } 
    97                                         else { 
    98                                                 $vote_option_id = intval($_POST['vote_option_id']); 
    99                                                 $sql = "UPDATE " . VOTE_RESULTS_TABLE . " 
    100                                                         SET vote_result = vote_result + 1 
    101                                                         WHERE vote_id = $vote_id 
    102                                                         AND vote_option_id = $vote_option_id"; 
    103  
    104                                                 $db->sql_query($sql); 
    105                                                 $sql = "INSERT INTO " . VOTE_USERS_TABLE . " (vote_id, vote_user_id, vote_user_ip, vote_cast) 
    106                                                         VALUES ($vote_id, " . $userdata['uid'] . ", '$user_ip', $vote_option_id)"; 
    107                                                 $db->sql_query($sql); 
    108  
    109                                                 $user_voted_option_id = $vote_option_id; 
    110                                                 $user_voted = TRUE; 
    111                                         } 
    112                                 } 
    113                         } 
    114                         else { 
    115                                 $view_result = 0; 
    116                         } 
    117  
    118                         $poll_expired = ( $vote_info[0]['vote_length'] ) ? ( ( $vote_info[0]['vote_start'] + $vote_info[0]['vote_length'] < time() ) ? TRUE : 0 ) : 0; 
    119  
    120                         if ( $user_voted || $view_result || $poll_expired ) { 
    121                                 $template->assign_block_vars("poll.voted", array()); 
    122  
    123                                 $vote_results_sum = 0; 
    124  
    125                                 for($i = 0; $i < $vote_options; $i++) { 
    126                                         $vote_results_sum += $vote_info[$i]['vote_result']; 
    127                                 } 
    128  
    129                                 $vote_graphic = 0; 
    130                                 $vote_graphic_max = sizeof($images['voting_graphic']); 
    131  
    132                                 for($i = 0; $i < $vote_options; $i++) { 
    133                                         if ( isset($user_voted_option_id) && $vote_info[$i]['vote_option_id'] == $user_voted_option_id ) { 
    134                                                 $vote_info[$i]['vote_result'] = $vote_info[$i]['vote_result'] + 1; 
    135                                                 $vote_results_sum = $vote_results_sum + 1; 
    136                                         } 
    137                                         $vote_percent = ( $vote_results_sum > 0 ) ? $vote_info[$i]['vote_result'] / $vote_results_sum : 0; 
    138                                         $vote_graphic_length = round($vote_percent * $config['vote_graphic_length'] * 2); 
    139                                         $vote_graphic = ($vote_graphic < $vote_graphic_max - 1) ? $vote_graphic + 1 : 0; 
    140  
    141  
    142                                         $vote_info[$i]['vote_option_text'] = censor_text(format_comment($vote_info[$i]['vote_option_text'])); 
    143  
    144                                         $template->assign_block_vars("poll.voted.voted_row", array( 
    145                                                 'POLL_OPTION_CAPTION' => $vote_info[$i]['vote_option_text'], 
    146                                                 'POLL_OPTION_RESULT' => $vote_info[$i]['vote_result'], 
    147                                                 'POLL_OPTION_PERCENT' => sprintf("%.1d%%", ($vote_percent * 100)), 
    148                                                 'POLL_OPTION_IMG_WIDTH' => $vote_graphic_length) 
    149                                         ); 
    150                                 } 
    151  
    152                                 $template->assign_vars(array( 
    153                                         'TOTAL_VOTES' => $vote_results_sum) 
    154                                 ); 
    155  
    156                         } 
    157                         else { 
    158                                 $template->assign_block_vars("poll.no_voted", array( 
    159                                         'S_FORM_ACTION' => append_sid('index.php') ) 
    160                                 ); 
    161  
    162                                 for($i = 0; $i < $vote_options; $i++) { 
    163                                         $vote_info[$i]['vote_option_text'] = censor_text($vote_info[$i]['vote_option_text']); 
    164  
    165                                         $template->assign_block_vars("poll.no_voted.novoted_row", array( 
    166                                                 'POLL_OPTION_ID' => $vote_info[$i]['vote_option_id'], 
    167                                                 'POLL_OPTION_CAPTION' => format_comment($vote_info[$i]['vote_option_text']) ) 
    168                                         ); 
    169                                 } 
    170                         } 
    171                         $vote_title = censor_text($vote_title); 
    172  
    173                         $expire_time = ( $vote_info[0]['vote_length'] ? create_date($config['default_dateformat'], $vote_info[0]['vote_start'] + $vote_info[0]['vote_length'], $userdata['tzoffset']) : 0 ); 
    174  
    175                         $template->assign_vars(array( 
    176                                 'POLL_QUESTION' => format_comment($vote_title), 
    177                                 'S_THIS_POLL_WILL_EXPIRE_AT' => ( $expire_time ? ( $poll_expired ? sprintf($lang['this_poll_expired_at'], $expire_time ) : sprintf($lang['this_poll_will_expire_at'], $expire_time ) ) : '') ) 
    178                         ); 
    179                 } 
    180         } 
    181         /* end poll */ 
     54        $db->sql_freeresult($result); 
     55 
     56        if ( $poll_id && ( !$poll_until || $poll_until > time() ) ) { 
     57                $template->assign_block_vars('poll', array( 
     58                        'POLL_ID' => $poll_id, 
     59                        'U_VIEW_RESULT' => append_sid($root_path . '?vote=viewresult'), 
     60                        'IMG_BAR_LEFT' => $images['bar_left'], 
     61                        'IMG_BAR' => $images['bar'], 
     62                        'IMG_BAR_RIGHT' => $images['bar_right'] 
     63                )); 
     64 
     65                $sql = 'SELECT vd.vote_id, vd.vote_text, vd.vote_start, vd.vote_length, vr.vote_option_id, vr.vote_option_text, vr.vote_result 
     66                        FROM ' . VOTE_DESC_TABLE . ' vd, ' . VOTE_RESULTS_TABLE . ' vr 
     67                        WHERE vd.topic_id = 0 
     68                        AND vr.vote_id = vd.vote_id 
     69                        AND vd.vote_id = ' . $poll_id . ' 
     70                        ORDER BY vr.vote_option_id ASC'; 
     71                $result = $db->sql_query($sql); 
     72 
     73                if ( $vote_info = $db->sql_fetchrowset($result) ) { 
     74 
     75                        $db->sql_freeresult($result); 
     76 
     77                        $vote_options = sizeof($vote_info); 
     78 
     79                        $vote_id = $vote_info[0]['vote_id']; 
     80                        $vote_title = $vote_info[0]['vote_text']; 
     81 
     82                        $sql = 'SELECT vote_id 
     83                                FROM ' . VOTE_USERS_TABLE . ' 
     84                                WHERE vote_id = ' . $vote_id . ' 
     85                                AND vote_user_id = ' . $userdata['uid']; 
     86                        $result = $db->sql_query($sql); 
     87 
     88                        $user_voted = ( $row = $db->sql_fetchrow($result) ) ? TRUE : 0; 
     89                        $db->sql_freeresult($result); 
     90 
     91                        $vote = request_var('vote', ''); 
     92                        $vote_option_id = request_var('vote_option_id', 0); 
     93 
     94                        if ( $vote ) { 
     95 
     96                                $view_result = ( $vote == 'viewresult' ) ? TRUE : 0; 
     97 
     98                                if ( $vote_option_id ) { 
     99                                        if ( $user_voted ) { 
     100                                                trigger_error($lang['dupe_vote']); 
     101                                        } 
     102                                        else { 
     103                                                $sql = "UPDATE " . VOTE_RESULTS_TABLE . " 
     104                                                        SET vote_result = vote_result + 1 
     105                                                        WHERE vote_id = $vote_id 
     106                                                        AND vote_option_id = $vote_option_id"; 
     107 
     108                                                $db->sql_query($sql); 
     109                                                $sql = "INSERT INTO " . VOTE_USERS_TABLE . " (vote_id, vote_user_id, vote_user_ip, vote_cast) 
     110                                                        VALUES ($vote_id, " . $userdata['uid'] . ", '$user_ip', $vote_option_id)"; 
     111                                                $db->sql_query($sql); 
     112 
     113                                                $user_voted_option_id = $vote_option_id; 
     114                                                $user_voted = TRUE; 
     115                                        } 
     116                                } 
     117                        } 
     118                        else { 
     119                                $view_result = 0; 
     120                        } 
     121 
     122                        $poll_expired = ( $vote_info[0]['vote_length'] ) ? ( ( $vote_info[0]['vote_start'] + $vote_info[0]['vote_length'] < time() ) ? TRUE : 0 ) : 0; 
     123 
     124                        if ( $user_voted || $view_result || $poll_expired ) { 
     125                                $template->assign_block_vars("poll.voted", array()); 
     126 
     127                                $vote_results_sum = 0; 
     128 
     129                                for($i = 0; $i < $vote_options; $i++) { 
     130                                        $vote_results_sum += $vote_info[$i]['vote_result']; 
     131                                } 
     132 
     133                                $vote_graphic = 0; 
     134                                $vote_graphic_max = sizeof($images['voting_graphic']); 
     135 
     136                                for($i = 0; $i < $vote_options; $i++) { 
     137                                        if ( isset($user_voted_option_id) && $vote_info[$i]['vote_option_id'] == $user_voted_option_id ) { 
     138                                                $vote_info[$i]['vote_result'] = $vote_info[$i]['vote_result'] + 1; 
     139                                                $vote_results_sum = $vote_results_sum + 1; 
     140                                        } 
     141 
     142                                        if ( $vote_results_sum ) { 
     143                                                $vote_percent = $vote_info[$i]['vote_result'] / $vote_results_sum * 100; 
     144                                        } 
     145                                        else { 
     146                                                $vote_percent = 0; 
     147                                        } 
     148                                        $vote_graphic_length = round($vote_percent / 100 * $config['vote_graphic_length'] * 2); 
     149                                        $vote_graphic = ($vote_graphic < $vote_graphic_max - 1) ? $vote_graphic + 1 : 0; 
     150 
     151 
     152                                        $vote_info[$i]['vote_option_text'] = censor_text(format_comment($vote_info[$i]['vote_option_text'])); 
     153 
     154                                        $template->assign_block_vars("poll.voted.voted_row", array( 
     155                                                'POLL_OPTION_CAPTION' => $vote_info[$i]['vote_option_text'], 
     156                                                'POLL_OPTION_RESULT' => $vote_info[$i]['vote_result'], 
     157                                                'POLL_OPTION_PERCENT' => round($vote_percent) . '%', 
     158                                                'POLL_OPTION_IMG_WIDTH' => $vote_graphic_length) 
     159                                        ); 
     160                                } 
     161 
     162                                $template->assign_vars(array( 
     163                                        'TOTAL_VOTES' => $vote_results_sum 
     164                                )); 
     165 
     166                        } 
     167                        else { 
     168                                $template->assign_block_vars("poll.no_voted", array( 
     169                                        'S_FORM_ACTION' => append_sid('index.php') 
     170                                )); 
     171 
     172                                for($i = 0; $i < $vote_options; $i++) { 
     173                                        $vote_info[$i]['vote_option_text'] = censor_text($vote_info[$i]['vote_option_text']); 
     174 
     175                                        $template->assign_block_vars("poll.no_voted.novoted_row", array( 
     176                                                'POLL_OPTION_ID' => $vote_info[$i]['vote_option_id'], 
     177                                                'POLL_OPTION_CAPTION' => format_comment($vote_info[$i]['vote_option_text']) 
     178                                        )); 
     179                                } 
     180                        } 
     181                        $vote_title = censor_text($vote_title); 
     182 
     183                        $expire_time = ( $vote_info[0]['vote_length'] ? create_date($config['default_dateformat'], $vote_info[0]['vote_start'] + $vote_info[0]['vote_length'], $userdata['tzoffset']) : 0 ); 
     184 
     185                        $template->assign_vars(array( 
     186                                'POLL_QUESTION' => format_comment($vote_title), 
     187                                'S_THIS_POLL_WILL_EXPIRE_AT' => ( $expire_time ? ( $poll_expired ? sprintf($lang['this_poll_expired_at'], $expire_time ) : sprintf($lang['this_poll_will_expire_at'], $expire_time ) ) : '') ) 
     188                        ); 
     189                } 
     190        } 
     191        /* end poll */ 
    182192 
    183193        //chat start 
     
    197207 
    198208$template->assign_vars(array( 
    199         'RETURN_TO' => 'index.php', 
    200         'GREETINGS_NEW_USER' => ( isset($latestuser) ? sprintf($lang['greetings_new_user'], $latestuser) : '' ), 
    201         'U_RELEASES' => append_sid('releases.php'), 
    202         'SHOUTBOX' => ( isset($shoutbox) ? $shoutbox : '' ) 
     209       'RETURN_TO' => 'index.php', 
     210       'GREETINGS_NEW_USER' => ( isset($latestuser) ? sprintf($lang['greetings_new_user'], $latestuser) : '' ), 
     211       'U_RELEASES' => append_sid('releases.php'), 
     212       'SHOUTBOX' => ( isset($shoutbox) ? $shoutbox : '' ) 
    203213)); 
    204214 
    205 if ($userdata['class'] >= UC_ADMINISTRATOR) { 
    206         $template->assign_block_vars('switch_admin_section', array()); 
     215if ( $userdata['class'] >= UC_ADMINISTRATOR ) { 
     216       $template->assign_block_vars('switch_admin_section', array()); 
    207217} 
    208218 
     
    218228                     $show_news = true; 
    219229                        $news_ary[] = array( 
    220                               'id' => $row['id'], 
    221                               'added' => $row['added'], 
    222                               'title' => $row['title'], 
    223                               'body' =>  $row['body'] 
     230                              'id' => $row['id'], 
     231                              'added' => $row['added'], 
     232                              'title' => $row['title'], 
     233                              'body' =>  $row['body'] 
    224234                        ); 
    225               } 
     235              } 
    226236     } 
    227237     while ( $row = $db->sql_fetchrow($result) ); 
     
    231241             $template->assign_block_vars('news', array()); 
    232242             foreach ( $news_ary AS $key => $ary ) { 
    233                       $template->assign_block_vars('news.news_row', array( 
    234                               'ID' => $ary['id'], 
    235                               'ADDED' => create_date('M d', $ary['added'], $userdata['tzoffset']), 
    236                               'STYLE_DISPLAY' => ( $i ? 'none' : 'block' ), 
    237                               'PIC' => $root_path . 'pic/' . ( $i ? 'plus.gif' : 'minus.gif' ), 
    238                               'TITLE' => $ary['title'], 
    239                               'BODY' =>  format_comment($ary['body']) ) 
    240                       ); 
    241                       ++$i; 
     243                      $template->assign_block_vars('news.news_row', array( 
     244                              'ID' => $ary['id'], 
     245                              'ADDED' => create_date('M d', $ary['added'], $userdata['tzoffset']), 
     246                              'STYLE_DISPLAY' => ( $i ? 'none' : 'block' ), 
     247                              'PIC' => $root_path . 'pic/' . ( $i ? 'plus.gif' : 'minus.gif' ), 
     248                              'TITLE' => $ary['title'], 
     249                              'BODY' =>  format_comment($ary['body']) ) 
     250                      ); 
     251                      ++$i; 
    242252             } 
    243253     } 
     
    246256 
    247257$sql = 'SELECT COUNT(i.id) AS count FROM ' . INDEXRELEASES_TABLE . ' i, ' . CATEGORIES_TABLE . ' c, ' . TORRENTS_TABLE . ' t 
    248         WHERE t.category = c.id AND i.torrent_id = t.fid AND t.banned = 0 AND t.hidden = 0' . ( $userdata['uid'] == ANONYMOUS ? ' AND c.anonymous_view = 1' : '' ); 
     258       WHERE t.category = c.id AND i.torrent_id = t.fid AND t.banned = 0 AND t.hidden = 0' . ( $userdata['uid'] == ANONYMOUS ? ' AND c.anonymous_view = 1' : '' ); 
    249259$result = $db->sql_query($sql, 31536000); 
    250260$count = ( $row = $db->sql_fetchrow($result) ) ? $row['count'] : 0; 
     
    255265 
    256266$sql = 'SELECT i.*, c.image AS category_image, c.name AS category_name, t.name AS torrent_name, t.category 
    257         FROM ' . INDEXRELEASES_TABLE . ' i, ' . CATEGORIES_TABLE . ' c, ' . TORRENTS_TABLE . ' t 
    258         WHERE t.category = c.id AND i.torrent_id = t.fid AND t.banned = 0 AND t.hidden = 0' . ( $userdata['uid'] == ANONYMOUS ? ' AND c.anonymous_view = 1' : '' ) 
    259         . ' ORDER BY t.ctime DESC ' . $limit; 
     267       FROM ' . INDEXRELEASES_TABLE . ' i, ' . CATEGORIES_TABLE . ' c, ' . TORRENTS_TABLE . ' t 
     268       WHERE t.category = c.id AND i.torrent_id = t.fid AND t.banned = 0 AND t.hidden = 0' . ( $userdata['uid'] == ANONYMOUS ? ' AND c.anonymous_view = 1' : '' ) 
     269       . ' ORDER BY t.ctime DESC ' . $limit; 
    260270$result = $db->sql_query($sql, 31536000); 
    261271 
    262272if ( $row = $db->sql_fetchrow($result) ) { 
    263273        $template->assign_block_vars('releases', array( 
    264                 'PAGERBOTTOM' => $pagerbottom ) 
     274               'PAGERBOTTOM' => $pagerbottom ) 
    265275        ); 
    266276        do { 
    267277                $template->assign_block_vars('releases.releases_row', array( 
    268                         'NAME'           => ( $row['name'] ? $row['name'] : $row['torrent_name'] ), 
    269                'ID'             => $row['id'], 
    270                     'U_EDIT'        => append_sid('releases.php?action=add&amp;id=' . $row['id'] . '&amp;returnto=index.php'), 
    271                    'U_DELETE'       => append_sid('releases.php?action=delete&amp;id=' . $row['id'] . '&amp;returnto=index.php'), 
    272                    'U_CATEGORY'     => append_sid('browse.php?cat=' . $row['category']), 
    273                    'U_DETAILS'      => append_sid('details.php?id=' . $row['torrent_id']), 
    274                'COVER'          => $row['cover'], 
    275                'CATEGORY'       => $row['category'], 
    276                'CATEGORY_IMAGE' => $root_path . 'pic/categories/' . $row['category_image'], 
    277                'CATEGORY_NAME'  => $row['category_name'], 
    278                'DESCRIPTION'    => format_comment(censor_text($row['description'])), 
    279                'IMDB_LINK'      => ( $row['imdb_link'] ? '  [<a href="redir.php?url=' . $row['imdb_link'] . '" target="_blank">IMDB</a>]' : '' ), 
    280                'FORUM_LINK'     => ( $row['forum_link'] ? '  [<a href="' . append_sid('phpbb2.php?page=viewtopic&amp;t=' . $row['forum_link']) . '" target="_blank">' . $lang['talk_at_forum'] . '</a>]' : '' ) 
     278                        'NAME'    => ( $row['name'] ? $row['name'] : $row['torrent_name'] ), 
     279              'ID'          => $row['id'], 
     280                    'U_EDIT'    => append_sid('releases.php?action=add&amp;id=' . $row['id'] . '&amp;returnto=index.php'), 
     281                   'U_DELETE'       => append_sid('releases.php?action=delete&amp;id=' . $row['id'] . '&amp;returnto=index.php'), 
     282                   'U_CATEGORY'     => append_sid('browse.php?cat=' . $row['category']), 
     283                   'U_DETAILS'      => append_sid('details.php?id=' . $row['torrent_id']), 
     284              'COVER'    => $row['cover'], 
     285              'CATEGORY'       => $row['category'], 
     286              'CATEGORY_IMAGE' => $root_path . 'pic/categories/' . $row['category_image'], 
     287              'CATEGORY_NAME'  => $row['category_name'], 
     288              'DESCRIPTION'    => format_comment(censor_text($row['description'])), 
     289              'IMDB_LINK'      => ( $row['imdb_link'] ? '  [<a href="redir.php?url=' . $row['imdb_link'] . '" target="_blank">IMDB</a>]' : '' ), 
     290              'FORUM_LINK'     => ( $row['forum_link'] ? '  [<a href="' . append_sid('phpbb2.php?page=viewtopic&amp;t=' . $row['forum_link']) . '" target="_blank">' . $lang['talk_at_forum'] . '</a>]' : '' ) 
    281291                )); 
    282292 
    283293                if ($userdata['class'] >= UC_ADMINISTRATOR) { 
    284                   $template->assign_block_vars('releases.releases_row.switch_admin_section', array()); 
    285           } 
     294                 $template->assign_block_vars('releases.releases_row.switch_admin_section', array()); 
     295         } 
    286296        } 
    287297     while ( $row = $db->sql_fetchrow($result) ); 
     
    316326 
    317327$template->assign_vars(array( 
    318         'ONLINE_SINCE' => create_date('Y-m-d', $config['onlinesince'], $userdata['tzoffset']), 
    319         'REGISTERED_USERS' => $stats['registered'], 
    320         'TOTAL_TORRENTS' => $stats['torrents'], 
    321         'DEAD_TORRENTS' => $stats['dead_torrents'], 
    322         'TOTAL_PEERS' => $stats['total_peers'], 
    323         'UNIQUE_PEERS' => $stats['unique_peers'], 
    324         'UNIQUE_SEEDERS' => $stats['unique_seeders'], 
    325         'UNIQUE_LEECHERS' => $stats['unique_leechers'], 
    326         'SEEDERS' => $stats['seeders'], 
    327         'LEECHERS' => $stats['leechers'], 
    328         'UNIQUE_RATIO' => ( $stats['unique_leechers'] ? round($stats['unique_seeders'] / $stats['unique_leechers'] * 100) : 'Inf.'), 
    329         'RATIO' => $stats['ratio'], 
    330         'TOTAL_DOWNLOADED' => mksize($stats['totaldownloaded']), 
    331         'TOTAL_UPLOADED' => mksize($stats['totaluploaded']) 
     328       'ONLINE_SINCE' => create_date('Y-m-d', $config['onlinesince'], $userdata['tzoffset']), 
     329       'REGISTERED_USERS' => $stats['registered'], 
     330       'TOTAL_TORRENTS' => $stats['torrents'], 
     331       'DEAD_TORRENTS' => $stats['dead_torrents'], 
     332       'TOTAL_PEERS' => $stats['total_peers'], 
     333       'UNIQUE_PEERS' => $stats['unique_peers'], 
     334       'UNIQUE_SEEDERS' => $stats['unique_seeders'], 
     335       'UNIQUE_LEECHERS' => $stats['unique_leechers'], 
     336       'SEEDERS' => $stats['seeders'], 
     337       'LEECHERS' => $stats['leechers'], 
     338       'UNIQUE_RATIO' => ( $stats['unique_leechers'] ? round($stats['unique_seeders'] / $stats['unique_leechers'] * 100) : 'Inf.'), 
     339       'RATIO' => $stats['ratio'], 
     340       'TOTAL_DOWNLOADED' => mksize($stats['totaldownloaded']), 
     341       'TOTAL_UPLOADED' => mksize($stats['totaluploaded']) 
    332342)); 
    333343if ( $stats['total_peers'] ) { 
    334         $template->assign_block_vars('statistic_peers', array()); 
     344       $template->assign_block_vars('statistic_peers', array()); 
    335345} 
    336346 
    337347stdhead($lang['index']); 
    338348$template->set_filenames(array( 
    339         'body' => 'index_body.html') 
     349       'body' => 'index_body.html') 
    340350); 
    341351stdfoot(); 
  • message.php

    r214 r216  
    236236                          } 
    237237                     } 
    238                         $sql = 'INSERT INTO ' . PRIVATE_MESSAGES_TABLE . ' ' . $db->sql_build_array('INSERT', array( 
    239                              'sender'   => $userdata['uid'], 
    240                              'receiver' => $receiver, 
    241                              'added'    => time(), 
    242                              'msg'      => $msg, 
    243                              'subject'  => $subject, 
    244                              'saved'    => $save, 
    245                              'location' => 1, 
    246                                 'reply_to' => $reply_to 
    247                         )); 
    248                      $db->sql_query($sql); 
    249                         $sended_id = $db->sql_nextid(); 
    250  
    251                      $sql = 'UPDATE ' . USERS_TABLE . ' SET user_unread_pms = user_unread_pms + 1 WHERE uid = ' . $receiver; 
    252                      $db->sql_query($sql); 
    253  
    254                         if ( strpos($user['notifs'], '[pm]') !== false ) { 
    255                                 $to_language = $user['language']; 
    256                                 if (!check_language($to_language)) { 
    257                                         $to_language = $config['default_lang']; 
    258                           } 
    259                                 include_once($root_path . 'include/functions_messenger.php'); 
    260                           $messenger = new messenger(false); 
    261  
    262                                 $count = 0; 
    263                                 if ( $user['class'] < UC_MODERATOR ) { 
    264                                         $sql = 'SELECT COUNT(*) AS count FROM ' . PRIVATE_MESSAGES_TABLE . ' WHERE receiver = ' . $receiver . ' AND location=' . PM_INBOX; 
    265                                $result = $db->sql_query($sql); 
    266                                $count = ( $row = $db->sql_fetchrow($result) ) ? intval($row['count']) : 0; 
    267                                         if ( $count > $config['max_inbox_privmsgs'] ) { 
    268                                                 $messenger->template('pm_received_but_limit_reached', $to_language); 
    269                                } 
    270                                         else { 
    271                                        $messenger->template('pm_received', $to_language); 
    272                                } 
    273                           } 
    274                                 else { 
    275                                         $messenger->template('pm_received', $to_language); 
    276                           } 
    277  
    278                                 $messenger->replyto($user['email']); 
    279                           $messenger->to($user['email'], $user['name']); 
    280  
    281                                 $messenger->assign_vars(array( 
    282                                         'BOARD_EMAIL' => $config['sitemail'], 
    283                                         'USERNAME' => html_entity_decode($userdata['name']), 
    284                                         'U_LINK' => generate_base_url() . '/message.php' . ( $count > $config['max_inbox_privmsgs'] ? '' : '?action=viewmessage&id=' . $sended_id ) 
    285                                 )); 
    286                           $messenger->send(NOTIFY_EMAIL); 
    287                           $messenger->reset(); 
    288                      } 
     238 
     239                  $pm_ary = array(); 
     240 
     241                        $pm_ary[] = array( 
     242                                'sender' => $userdata['uid'], 
     243                                'sender_name' => $userdata['name'], 
     244                                'receiver' => $receiver, 
     245                                'msg' => $msg, 
     246                                'subject' => $subject, 
     247                                'saved'    => $save, 
     248                                'reply_to' => $reply_to, 
     249 
     250                                'name' => $user['name'], 
     251                                'email' => $user['email'], 
     252                                'notifs' => $user['notifs'], 
     253                                'language' => $user['language'], 
     254                                'class' => $user['class'] 
     255                        ); 
     256 
     257                        send_pm($pm_ary); 
    289258 
    290259                        if ( $origmsg && $delete ) { 
     
    511480 
    512481                        // Try finding a user with specified name 
    513                   $sql = 'SELECT uid, email, language, name, class FROM ' . USERS_TABLE . ' WHERE LOWER(name) = ' . "'" . $db->sql_escape(strtolower($username)) . "'" . ' AND uid != ' . ANONYMOUS . ' LIMIT 1'; 
     482                  $sql = 'SELECT uid, email, language, name, class, notifs FROM ' . USERS_TABLE . ' WHERE LOWER(name) = ' . "'" . $db->sql_escape(strtolower($username)) . "'" . ' AND uid != ' . ANONYMOUS . ' LIMIT 1'; 
    514483                  $result = $db->sql_query($sql); 
    515484                  if ( !($to_arr = $db->sql_fetchrow($result)) ) { 
     
    559528                       } 
    560529                  } 
    561                      $sql = 'INSERT INTO ' . PRIVATE_MESSAGES_TABLE . ' ' . $db->sql_build_array('INSERT', array( 
    562                             'sender'   => $userdata['uid'], 
    563                              'receiver' => $to, 
    564                              'added'    => time(), 
    565                              'msg'      => $body, 
    566                              'subject'  => $subject, 
    567                              'saved'    => $save, 
    568                              'location' => PM_INBOX 
    569                         )); 
    570                   $db->sql_query($sql); 
    571  
    572                   $sended_id = $db->sql_nextid(); 
    573  
    574                         $sql = 'UPDATE ' . USERS_TABLE . ' SET user_unread_pms = user_unread_pms + 1 WHERE uid = ' . $to; 
    575                         $db->sql_query($sql); 
    576  
    577                   include_once($root_path . 'include/functions_messenger.php'); 
    578                   $messenger = new messenger(false); 
    579  
    580                   $count = 0; 
    581                   if ( $to_arr['class'] < UC_MODERATOR ) { 
    582                           $sql = 'SELECT COUNT(*) AS count FROM ' . PRIVATE_MESSAGES_TABLE . ' WHERE receiver = ' . $to . ' AND location=' . PM_INBOX; 
    583                        $result = $db->sql_query($sql); 
    584                        $count = ( $row = $db->sql_fetchrow($result) ) ? intval($row['count']) : 0; 
    585                        if ( $count > $config['max_inbox_privmsgs'] ) { 
    586                                $messenger->template('pm_received_but_limit_reached', $to_language); 
    587                        } 
    588                        else { 
    589                                         $messenger->template('pm_received', $to_language); 
    590                        } 
    591                   } 
    592                   else { 
    593                           $messenger->template('pm_received', $to_language); 
    594                   } 
    595  
    596                   $messenger->replyto($to_email); 
    597                   $messenger->to($to_email, $to_username); 
    598  
    599                   $messenger->assign_vars(array( 
    600                           'BOARD_EMAIL' => $config['sitemail'], 
    601                                 'USERNAME' => html_entity_decode($userdata['name']), 
    602                                 'U_LINK' => generate_base_url() . '/message.php' . ( $count > $config['max_inbox_privmsgs'] ? '' : '?action=viewmessage&id=' . $sended_id ) 
    603                         )); 
    604                   $messenger->send(NOTIFY_EMAIL); 
    605                   $messenger->reset(); 
     530 
     531                  $pm_ary = array(); 
     532 
     533                        $pm_ary[] = array( 
     534                                'sender' => $userdata['uid'], 
     535                                'sender_name' => $userdata['name'], 
     536                                'receiver' => $to, 
     537                                'msg' => $body, 
     538                                'subject' => $subject, 
     539                                'saved'    => $save, 
     540 
     541                                'name' => $to_arr['name'], 
     542                                'email' => $to_arr['email'], 
     543                                'notifs' => $to_arr['notifs'], 
     544                                'language' => $to_arr['language'], 
     545                                'class' => $to_arr['class'] 
     546                        ); 
     547 
     548                        send_pm($pm_ary); 
    606549 
    607550                  meta_refresh(3, append_sid($root_path . 'message.php')); 
  • offers.php

    r211 r216  
    158158                $torrent_name = $row['name']; 
    159159 
    160                 $sql = 'SELECT o.userid, u.language 
     160                $sql = 'SELECT o.userid, u.language, u.name, u.email, u.notifs, u.language, u.class 
    161161                                FROM ' . OFFERS_VOTES_TABLE . ' o, ' . USERS_TABLE . ' u 
    162162                                WHERE o.offerid = ' . $id . ' AND o.userid = u.uid'; 
    163163                $result = $db->sql_query($sql); 
     164 
     165                $pm_ary = array(); 
     166 
    164167                while ( $arr = $db->sql_fetchrow($result) ) { 
    165168                        require_once($root_path . 'languages/lang_' . $arr['language'] . '/lang_pms.php'); 
    166169 
    167                         $sql = 'INSERT INTO ' . PRIVATE_MESSAGES_TABLE . ' ' . $db->sql_build_array('INSERT', array('sender'   => 0, 
    168                                                                                                'receiver' => $arr['userid'], 
    169                                                                                                'added'    => time(), 
    170                                                                                                'msg'      => sprintf($lang['pm_offer_filled_body'], generate_base_url() , $id, $offer_name, generate_base_url(), $userdata['uid'], $userdata['name'], generate_base_url() , $filled_torrent_id, $torrent_name), 
    171                                                                                                'location' => 1, 
    172                                                                                                'subject'  => $lang['pm_offer_filled_subject'])); 
    173                         $db->sql_query($sql); 
    174  
    175                         $sql = 'UPDATE ' . USERS_TABLE . ' SET user_unread_pms = user_unread_pms + 1 WHERE uid = ' . $arr['userid']; 
    176                         $db->sql_query($sql); 
    177                 } 
     170                        $pm_ary[] = array( 
     171                                'sender' => 0, 
     172                                'receiver' => $arr['userid'], 
     173                                'msg' => sprintf($lang['pm_offer_filled_body'], generate_base_url() , $id, $offer_name, generate_base_url(), $userdata['uid'], $userdata['name'], generate_base_url() , $filled_torrent_id, $torrent_name), 
     174                                'subject' => $lang['pm_offer_filled_subject'], 
     175                                'name' => $arr['name'], 
     176                                'email' => $arr['email'], 
     177                                'notifs' => $arr['notifs'], 
     178                                'language' => $arr['language'], 
     179                                'class' => $arr['class'] 
     180                        ); 
     181                } 
     182 
     183                send_pm($pm_ary); 
     184 
    178185                $sql = 'UPDATE ' . OFFERS_TABLE . ' SET filled = ' . $filled_torrent_id . ', filledby = ' . $userdata['uid'] . ' WHERE id = ' . $id; 
    179186                $db->sql_query($sql); 
  • requests.php

    r211 r216  
    167167                $torrent_name = $row['name']; 
    168168 
    169                 $sql = 'SELECT a.userid, u.language 
     169                $sql = 'SELECT a.userid, u.language, u.name, u.email, u.notifs, u.language, u.class 
    170170                           FROM ' . REQUESTS_VOTES_TABLE . ' a, ' . USERS_TABLE . ' u 
    171171                           WHERE a.requestid = ' . $id . ' AND a.userid = u.uid'; 
    172172                $result = $db->sql_query($sql); 
     173 
     174                $pm_ary = array(); 
     175 
    173176                while ( $arr = $db->sql_fetchrow($result) ) { 
    174177                        require_once($root_path . 'languages/lang_' . $arr['language'] . '/lang_pms.php'); 
    175178 
    176                         $sql = 'INSERT INTO ' . PRIVATE_MESSAGES_TABLE . ' ' . $db->sql_build_array('INSERT', array( 
    177                                 'sender'        => 0, 
    178                                 'receiver'=> $arr['userid'], 
    179                                 'added' => time(), 
    180                                 'msg'   => sprintf($lang['pm_request_filled_body'], generate_base_url(), $id , $requests_name, generate_base_url(), $userdata['uid'], $userdata['name'], generate_base_url(), $filled_torrent_id, $torrent_name), 
    181                                 'location'=> 1, 
    182                                 'subject' => $lang['pm_request_filled_subject'] 
    183                         )); 
    184                         $db->sql_query($sql); 
    185  
    186                         $sql = 'UPDATE ' . USERS_TABLE . ' SET user_unread_pms = user_unread_pms + 1 WHERE uid = ' . $arr['userid']; 
    187                         $db->sql_query($sql); 
    188                 } 
     179                        $pm_ary[] = array( 
     180                                'sender' => 0, 
     181                                'receiver' => $arr['userid'], 
     182                                'msg' => sprintf($lang['pm_request_filled_body'], generate_base_url(), $id , $requests_name, generate_base_url(), $userdata['uid'], $userdata['name'], generate_base_url(), $filled_torrent_id, $torrent_name), 
     183                                'subject' => $lang['pm_request_filled_subject'], 
     184                                'name' => $arr['name'], 
     185                                'email' => $arr['email'], 
     186                                'notifs' => $arr['notifs'], 
     187                                'language' => $arr['language'], 
     188                                'class' => $arr['class'] 
     189                        ); 
     190                } 
     191 
     192                send_pm($pm_ary); 
     193 
    189194                $sql = 'UPDATE ' . REQUESTS_TABLE . ' SET filled = ' . $filled_torrent_id . ', filledby = ' . $userdata['uid'] . ' WHERE id =  ' . $id; 
    190195                $db->sql_query($sql); 
  • templates/bithdtv/chat.html

    r215 r216  
    11<!-- INCLUDE overall_header.html --> 
    22 
    3 <iframe src="chat/index.php" width="100%" height="700" style="border:none"></iframe> 
     3<iframe src="{CHAT_URL}" width="100%" height="700" style="border:none"></iframe> 
    44 
    55<!-- INCLUDE overall_footer.html --> 
  • templates/main/chat.html

    r215 r216  
    11<!-- INCLUDE overall_header.html --> 
    22 
    3 <iframe src="chat/index.php" width="100%" height="700" style="border:none"></iframe> 
     3<iframe src="{CHAT_URL}" width="100%" height="700" style="border:none"></iframe> 
    44 
    55<!-- INCLUDE overall_footer.html --> 
  • templates/reflection/chat.html

    r215 r216  
    22 
    33<br /> 
    4 <iframe src="chat/index.php" width="100%" height="700" style="border:none"></iframe> 
     4<iframe src="{CHAT_URL}" width="100%" height="700" style="border:none"></iframe> 
    55 
    66<!-- INCLUDE overall_footer.html --> 
  • uploadapp.php

    r184 r216  
    107107                } 
    108108                $pollid = request_var('pollid', 0); 
    109                 $sql = 'SELECT upl.* , u.name AS username, u.language 
     109                $sql = 'SELECT upl.* , u.name AS username, u.language, u.email, u.notifs, u.class 
    110110                        FROM ' . UPLOADAPP_TABLE . ' upl, ' . USERS_TABLE . ' u 
    111111                        WHERE upl.id = ' . $pollid . ' AND upl.userid = u.uid'; 
     
    145145                        } 
    146146                        else { 
     147                                $pm_ary = array(); 
     148 
    147149                                $sql = 'UPDATE ' . UPLOADAPP_TABLE . ' SET active = 0 WHERE id = ' . $pollid; 
    148150                                $db->sql_query($sql); 
     
    174176                                } 
    175177 
    176                                 $db->sql_query('INSERT INTO ' . PRIVATE_MESSAGES_TABLE . ' ' . $db->sql_build_array('INSERT', array('sender'   => 0, 
    177                                                                                                               'receiver' => $row['userid'], 
    178                                                                                                               'added'    => time(), 
    179                                                                                                               'msg'      => $msg, 
    180                                                                                                               'location' => 1, 
    181                                                                                                               'subject'  => $lang['pm_uploadapp_subject']))); 
    182  
    183                                 $sql = 'UPDATE ' . USERS_TABLE . ' SET user_unread_pms = user_unread_pms + 1 WHERE uid = ' . $row['userid']; 
    184                                 $db->sql_query($sql); 
     178                                                        $pm_ary[] = array( 
     179                                                                'sender' => 0, 
     180                                                                'receiver' => $row['userid'], 
     181                                                                'msg' => $msg, 
     182                                                                'subject' => $lang['pm_uploadapp_subject'], 
     183                                                                'name' => $row['username'], 
     184                                                                'email' => $row['email'], 
     185                                                                'notifs' => $row['notifs'], 
     186                                                                'language' => $row['language'], 
     187                                                                'class' => $row['class'] 
     188                                                        ); 
     189 
     190                                                        send_pm($pm_ary); 
    185191                        } 
    186192                 }