- Совместимость
- проверялся на совместимость
- Изменения в БД
- не требуются
- Автор
- frost444
- Общественное достояние
- да
Описание: добавляет возможность обновления статистики пользователя по AJAX-запросу.
- Инструкция по установке
-
PHP:
Автор мода: frost444 ####[ОТКРЫТЬ]----- ajax.php -----[найти]----- 'manage_group' => array('user'), -----[после вставить]----- 'UserStats' => array('user'), -----[найти]----- function manage_user() { require(AJAX_DIR . 'manage_user.php'); } -----[после вставить]----- function UserStats() { require(AJAX_DIR .'UserStats.php'); } ####[ОТКРЫТЬ]----- config.php -----[найти]----- // Atom feed $bb_cfg['atom'] = array( 'path' => INT_DATA_DIR .'atom', // without ending slash 'url' => './internal_data/atom', // without ending slash ); -----[после вставить]----- $bb_cfg['userstat'] = array( 'cache' => 60, ); ####[ОТКРЫТЬ]----- page_header.php -----[найти]----- $template->assign_vars(array( 'SIMPLE_HEADER' => !empty($gen_simple_header), -----[выше вставить]----- if ($bb_cfg['bt_show_dl_stat_on_index'] && !IS_GUEST) { show_bt_userdata_only(); } ####[СОХРАНИТЬ_ФАЙЛ]#### ####[ОТКРЫТЬ]----- page_header.tpl -----[найти]----- <!-- IF SHOW_BT_USERDATA --><div id="user_ratio"> <h3>{L_USER_RATIO}</h3> <table cellpadding="0"> <div align="center">{THIS_AVATAR}</div> <tr><td>{L_USER_RATIO}</td><td><!-- IF DOWN_TOTAL_BYTES gt MIN_DL_BYTES --><b>{USER_RATIO}</b><!-- ELSE --><b>{L_NONE}</b> (DL < {MIN_DL_FOR_RATIO})<!-- ENDIF --></td></tr> <tr><td>{L_DOWNLOADED}</td><td class="leechmed"><b>{DOWN_TOTAL}</b></td></tr> <tr><td>{L_UPLOADED}</td><td class="seedmed"><b>{UP_TOTAL}</b></td></tr> <tr><td>{L_RELEASED}</td><td class="seedmed">{RELEASED}</td></tr> <tr><td>{L_BONUS}</td><td class="seedmed">{UP_BONUS}</td></tr> <!-- IF $bb_cfg['seed_bonus_enabled'] --><tr><td>{L_SEED_BONUS}</td><td><a href="profile.php?mode=bonus"><span class="points bold">{POINTS}</span></a></td></tr><!-- ENDIF --> </table> </div><!-- ENDIF --> -----[заменить]----- <!-- IF SHOW_BT_RATE --> <!-- BEGIN rate --> <div id="user_ratio" class="ajax_user_{rate.USER_ID}" data-userstats="true"> <h3>{L_USER_RATIO} <span id="update_userstat" onclick="user_stats({rate.USER_ID}, 'stats')" class="clickable" data-tooltip="true" title="Обновить статистику.(Авто обновление будет: {rate.TIME_UDATE_STATS} )">[{L_UPDATE}]</span></h3> <table cellpadding="0"> <div align="center">{rate.AVATAR}</div> <tr><td>{L_USER_RATIO}</td><td id="ajax_userratio"><!-- IF rate.DOWN_TOTAL_BYTES gt rate.MIN_DL_BYTES --><b>{rate.USER_RATIO}</b><!-- ELSE --><b>{L_NONE}</b> (DL < {rate.MIN_DL_FOR_RATIO})<!-- ENDIF --></td></tr> <tr><td>{L_DOWNLOADED}</td><td class="leechmed"><b id="ajax_userdownloaded">{rate.DOWN_TOTAL}</b></td></tr> <tr><td>{L_UPLOADED}</td><td class="seedmed"><b id="ajax_useruploaded">{rate.UP_TOTAL}</b></td></tr> <tr><td>{L_RELEASED}</td><td class="seedmed" id="ajax_userrelesed">{rate.RELEASED}</td></tr> <tr><td>{L_BONUS}</td><td class="seedmed" id="ajax_userbonus">{rate.UP_BONUS}</td></tr> <!-- IF $bb_cfg['seed_bonus_enabled'] --><tr><td>{L_SEED_BONUS}</td><td><a href="profile.php?mode=bonus"><span class="points bold" id="ajax_userseedbonus">{rate.POINTS}</span></a></td></tr><!-- ENDIF --> </table> </div> <!-- END rate --> <!-- ENDIF --> ####[СОХРАНИТЬ_ФАЙЛ]#### ####[ОТКРЫТЬ]----- usercp_register.tpl -----[найти]----- function get_bt_userdata ($user_id, $update = true) { ... } -----[заменить]----- function get_bt_userdata ($user_id, $update = true) { global $bb_cfg; if($update) { $resoult = DB()->fetch_row(" SELECT bt.*, SUM(tr.speed_up) as speed_up, SUM(tr.speed_down) as speed_down FROM ". BB_BT_USERS ." bt LEFT JOIN ". BB_BT_TRACKER ." tr ON (bt.user_id = tr.user_id) WHERE bt.user_id = ". (int) $user_id ." GROUP BY bt.user_id "); if($resoult) { $resoult['expire'] = TIMENOW + $bb_cfg['userstat']['cache']*60*60; CACHE('bb_cache')->set('userstat['.$user_id.']', $resoult, $bb_cfg['userstat']['cache']*60*60); } } else { if (!$resoult = CACHE('bb_cache')->get('userstat['.$user_id.']')) { $resoult = DB()->fetch_row(" SELECT bt.*, SUM(tr.speed_up) as speed_up, SUM(tr.speed_down) as speed_down FROM ". BB_BT_USERS ." bt LEFT JOIN ". BB_BT_TRACKER ." tr ON (bt.user_id = tr.user_id) WHERE bt.user_id = ". (int) $user_id ." GROUP BY bt.user_id "); if($resoult) { $resoult['expire'] = TIMENOW + $bb_cfg['userstat']['cache']*60*60; CACHE('bb_cache')->set('userstat['.$user_id.']', $resoult, $bb_cfg['userstat']['cache']*60*60); } } else { $resoult = CACHE('bb_cache')->get('userstat['.$user_id.']'); } } return $resoult; } function show_bt_userdata_only () { global $lang, $userdata; $btu = get_bt_userdata($userdata['user_id'], false); $GLOBALS['template']->assign_vars(array( 'SHOW_BT_RATE' => true, )); $GLOBALS['template']->assign_block_vars('rate', array( 'UP_TOTAL' => humn_size($btu['u_up_total']), 'UP_BONUS' => humn_size($btu['u_up_bonus']), 'RELEASED' => humn_size($btu['u_up_release']), 'DOWN_TOTAL' => humn_size($btu['u_down_total']), 'DOWN_TOTAL_BYTES' => $btu['u_down_total'], 'USER_RATIO' => get_bt_ratio($btu), 'MIN_DL_FOR_RATIO' => humn_size(MIN_DL_FOR_RATIO), 'MIN_DL_BYTES' => MIN_DL_FOR_RATIO, 'AUTH_KEY' => ($btu['auth_key']) ? $btu['auth_key'] : $lang['NONE'], 'TD_DL' => humn_size($btu['down_today']), 'TD_UL' => humn_size($btu['up_today']), 'TD_REL' => humn_size($btu['up_release_today']), 'TD_BONUS' => humn_size($btu['up_bonus_today']), 'TD_POINTS' => ($btu['auth_key']) ? $btu['points_today'] : '0.00', 'YS_DL' => humn_size($btu['down_yesterday']), 'YS_UL' => humn_size($btu['up_yesterday']), 'YS_REL' => humn_size($btu['up_release_yesterday']), 'YS_BONUS' => humn_size($btu['up_bonus_yesterday']), 'YS_POINTS' => ($btu['auth_key']) ? $btu['points_yesterday'] : '0.00', 'SPEED_UP' => humn_size($btu['speed_up'], 0, 'KB') .'/s', 'SPEED_DOWN' => humn_size($btu['speed_down'], 0, 'KB') .'/s', 'TIME_UDATE_STATS' => bb_date($btu['expire']), 'POINTS' => $userdata['user_points'], 'USER_ID' => $userdata['user_id'], 'AVATAR' => get_avatar($userdata['user_id'], $userdata['avatar_ext_id'], !bf($userdata['user_opt'], 'user_opt', 'dis_avatar')), )); } ####[СОХРАНИТЬ_ФАЙЛ]####