UP/DL/Ratio статистика на ajax

B

Boltik

Гость
Пора и СидБонус добавить сюда
7989a9b3f4da23a63e657fd9ba14e421.png
 
B

Boltik

Гость
Boltik, да, но некоторые хотят то готовый) но не я канеш.
PHP:
function user_stats()
{
        global $db, $bb_cfg, $lang, $userdata;
        $user_id = (int) $this->request['user_id'];
        $btu = get_bt_userdata ($user_id);
        $ratio = get_bt_ratio ($btu);
        $act_tor = get_bt_active_torrent ($user_id);
        $u_up_total = humn_size($btu['u_up_total']);
        $u_up_bonus = humn_size($btu['u_up_bonus']);
        $u_up_release = humn_size($btu['u_up_release']);
        $u_down_total = humn_size($btu['u_down_total']);
        $speed_up = humn_size($act_tor['speed_up']);
        $speed_down = humn_size($act_tor['speed_down']);
        $seed_bonus = ($btu['user_bonus']) ? $btu['user_bonus'] : 0;
        if ($btu['u_down_total'] < MIN_DL_FOR_RATIO) $ratio = '---';
############ Закончили ###################
############ Выводим данные ##############
$html = '
<table class="ratio1 table-wrap bCenter borderless w100" cellspacing="1">
<tr class="row3 tCenter">
  <td colspan="2" class="bold">Статистика</td>
</tr>
<tr class="row1 seed">
  <td class="med tLeft">&nbsp;'.$lang['BT_RATIO'].':</p></td>
  <td class="bold tLeft">&nbsp;'.$ratio.'</td>
</tr>
<tr class="row5 leech">
  <td class="med tLeft">&nbsp;<a class="leechsmall" href="'.SEARCH_URL.'?dlu='.$user_id.'&dlc=1#results">'.$lang['DOWNLOADED'].'</a>:&nbsp;</td>
  <td class="tLeft">&nbsp;<b>'.$u_down_total.'</b>&nbsp;('.$act_tor['leecher'].')</td>
</tr>
<tr class="row1 seed">
  <td class="med tLeft">&nbsp;'.$lang['UPLOADED'].':&nbsp;</p></td>
  <td class="tLeft">&nbsp;<b>'.$u_up_total.'</b>&nbsp;('.$act_tor['seeder'].')</td>
</tr>
<tr class="row5 seed">
  <td class="med tLeft">&nbsp;<i><a class="seedsmall" href="'.TRACKER_URL.'?rid='.$user_id.'#results">'.$lang['RELEASED'].'</a>:</i>&nbsp;</td>
  <td class="tLeft">&nbsp;<i>'.$u_up_release.'&nbsp;('.$act_tor['releaser'].')</i></td>
</tr>                         
<tr class="row1 dlWill">
  <td class="med tLeft">&nbsp;<i><a class="small dlWill" href="'.TOPIC_URL.'4">'.$lang['BT_BONUS_UP'].'</a>:</i>&nbsp;</td>
  <td class="tLeft">&nbsp;<i>'.$u_up_bonus.'</i></td>
</tr>
<tr class="row5 tDLCmpl">
  <td class="med tLeft">&nbsp;<a class="small tDLCmpl" href="'.BONUS_URL.'">Сид бонус</a>:&nbsp;</td>
  <td class="tLeft tDLCmpl">&nbsp;'.$seed_bonus.'</td>
</tr>
<tr class="row3">
  <td colspan="2" class="med tCenter bold">Спасибы</td>
</tr>
<tr class="row1">
  <td class="tLeft"><span class="small">Вы:</span></td>
  <td class="tLeft"><span class="small">'.@get_user_thanks($user_id).'</span></td>
</tr>
<tr class="row1">
  <td class="tLeft"><span class="small">Вам:</span></td>
  <td class="tLeft"><span class="small">'.@get_user_thanked($user_id).'</span></td>
</tr>
<tr class="row3">
  <td colspan="2" class="med tCenter bold">Тек. скорость</td>
</tr>
<tr class="row1">
  <td style="text-align: justify;" colspan="2" class="tCenter"><span class="seed small">Upl.&nbsp;'.$speed_up.'</span>&nbsp;|&nbsp;<span class="leech small">Dwnl.&nbsp;'.$speed_down.'</span></td>
</tr>
</table>
';
 
    $this->response['post_id'] = (int) $this->request['post_id'];
    $this->response['html'] = $html;
}

И что тебе даст моя функция если функции писать под ваш двиг надо ?

PHP:
function get_bt_userdata ($user_id)
{
    global $db, $bb_cache;
    $cache_name = 'bt_userdata_'.$user_id;
    if(!$data=$bb_cache->get($cache_name))
    {
        $data = $db->fetch_row('SELECT * FROM '. BT_USERS_TABLE .' WHERE user_id = '. (int) $user_id .' LIMIT 1');
        $bb_cache->set($cache_name, $data, 300);
    }
    return $data;
}
PHP:
function get_bt_active_torrent ($user_id)
{
    global $db, $bb_cache;
    $cache_name = 'bt_active_torrent_'.$user_id;
    $act_tor = array();
    if(!$data=$bb_cache->get($cache_name))
    {
      $data = $db->fetch_row("SELECT SUM(speed_up) AS speed_up, SUM(speed_down) AS speed_down, SUM(releaser) AS releaser, SUM(seeder) AS seeder, COUNT(user_id) AS act_tor FROM " . BT_TRACKER_TABLE . " WHERE user_id = " . (int) $user_id);
      $bb_cache->set($cache_name, $data, 300);
    }
    $act_tor['releaser']  = ($data['releaser']) ? $data['releaser'] : 0;
    $act_tor['seeder']    = ($data['seeder'] - $data['releaser']);
    $act_tor['leecher']    = ($data['act_tor'] - $data['seeder']);
    $act_tor['speed_up']  = ($data['speed_up']) ? $data['speed_up'] : 0;
    $act_tor['speed_down'] = ($data['speed_down']) ? $data['speed_down'] : 0;
    return $act_tor;
}
PHP:
function get_bt_ratio ($btu)
{
return
(!empty($btu['u_down_total']) && $btu['u_down_total'] > MIN_DL_FOR_RATIO)
? round((($btu['u_up_total'] + $btu['u_up_release'] + $btu['u_up_bonus']) / $btu['u_down_total']), 2)
: null
;
}
И сид-бонус у меня свой... И тут всё для СВН... переписывайте...
 
Сверху