Example #1
0
/**
 * Rewritten by Nathan Codding - Feb 6, 2001.
 * - Goes through the given string, and replaces xxxx://yyyy with an HTML <a> tag linking
 * 	to that URL
 * - Goes through the given string, and replaces www.xxxx.yyyy[zzzz] with an HTML <a> tag linking
 * 	to http://www.xxxx.yyyy[/zzzz]
 * - Goes through the given string, and replaces xxxx@yyyy with an HTML mailto: tag linking
 *		to that email address
 * - Only matches these 2 patterns either after a space, or at the beginning of a line
 *
 * Notes: the email one might get annoying - it's easy to make it more restrictive, though.. maybe
 * have it require something like xxxx@yyyy.zzzz or such. We'll see.
 */
function ed2k_link_callback($m)
{
    $max_len = 120;
    $href = 'href="' . $m[2] . '" class="postlink"';
    $size = humn_size($m[4]);
    $fname = urldecode($m[3]);
    if (strlen($fname) > $max_len) {
        $fname = substr($fname, 0, $max_len - 19) . '...' . substr($fname, -16);
    }
    if (preg_match('#[<>"]#', $fname)) {
        $fname = htmlspecialchars($fname);
    }
    return "<a {$href}>{$fname}&nbsp;({$size})</a>";
}
Example #2
0
        $releasing[] = $rowset;
    } elseif ($rowset['seeder']) {
        $seeding[] = $rowset;
    } else {
        $leeching[] = $rowset;
    }
}
if ($releasing) {
    foreach ($releasing as $i => $row) {
        $topic_title = wbr($row['topic_title']);
        $template->assign_block_vars('released', array('ROW_CLASS' => !($i % 2) ? 'row1' : 'row2', 'FORUM_NAME' => htmlCHR($row['forum_name']), 'TOPIC_TITLE' => $row['update_time'] ? $topic_title : "<s>{$topic_title}</s>", 'U_VIEW_FORUM' => FORUM_URL . $row['forum_id'], 'U_VIEW_TOPIC' => TOPIC_URL . $row['topic_id'], 'TOR_TYPE' => is_gold($row['tor_type']), 'TOPIC_SEEDERS' => $row['seeders'] ? $row['seeders'] : 0, 'TOPIC_LEECHERS' => $row['leechers'] ? $row['leechers'] : 0, 'SPEED_UP' => $row['speed_up'] ? humn_size($row['speed_up'], 0, 'KB') . '/s' : '-'));
        $releasing_count++;
    }
}
if ($seeding) {
    foreach ($seeding as $i => $row) {
        $topic_title = wbr($row['topic_title']);
        $template->assign_block_vars('seed', array('ROW_CLASS' => !($i % 2) ? 'row1' : 'row2', 'FORUM_NAME' => htmlCHR($row['forum_name']), 'TOPIC_TITLE' => $row['update_time'] ? $topic_title : "<s>{$topic_title}</s>", 'U_VIEW_FORUM' => FORUM_URL . $row['forum_id'], 'U_VIEW_TOPIC' => TOPIC_URL . $row['topic_id'], 'TOR_TYPE' => is_gold($row['tor_type']), 'TOPIC_SEEDERS' => $row['seeders'] ? $row['seeders'] : 0, 'TOPIC_LEECHERS' => $row['leechers'] ? $row['leechers'] : 0, 'SPEED_UP' => $row['speed_up'] ? humn_size($row['speed_up'], 0, 'KB') . '/s' : '-'));
        $seeding_count++;
    }
}
if ($leeching) {
    foreach ($leeching as $i => $row) {
        $compl_size = $row['remain'] && $row['size'] && $row['size'] > $row['remain'] ? $row['size'] - $row['remain'] : 0;
        $compl_perc = $compl_size ? floor($compl_size * 100 / $row['size']) : 0;
        $topic_title = wbr($row['topic_title']);
        $template->assign_block_vars('leech', array('ROW_CLASS' => !($i % 2) ? 'row1' : 'row2', 'FORUM_NAME' => htmlCHR($row['forum_name']), 'TOPIC_TITLE' => $row['update_time'] ? $topic_title : "<s>{$topic_title}</s>", 'U_VIEW_FORUM' => FORUM_URL . $row['forum_id'], 'U_VIEW_TOPIC' => TOPIC_URL . $row['topic_id'], 'COMPL_PERC' => $compl_perc, 'TOR_TYPE' => is_gold($row['tor_type']), 'TOPIC_SEEDERS' => $row['seeders'] ? $row['seeders'] : 0, 'TOPIC_LEECHERS' => $row['leechers'] ? $row['leechers'] : 0, 'SPEED_DOWN' => $row['speed_down'] ? humn_size($row['speed_down'], 0, 'KB') . '/s' : '-'));
        $leeching_count++;
    }
}
$template->assign_vars(array('SHOW_SEARCH_DL' => IS_AM || $profile_user_id, 'USERNAME' => $profiledata['username'], 'L_RELEASINGS' => "{$lang['RELEASING']}: " . ($releasing_count ? "<b>{$releasing_count}</b>" : '0'), 'L_SEEDINGS' => "{$lang['SEEDING']}: " . ($seeding_count ? "<b>{$seeding_count}</b>" : '0'), 'L_LEECHINGS' => "{$lang['LEECHING']}: " . ($leeching_count ? "<b>{$leeching_count}</b>" : '0'), 'USER_DLS' => $releasing_count || $seeding_count || $leeching_count));
Example #3
0
        $new = is_unread($f['last_post_time'], $f['last_topic_id'], $f['forum_id']) ? '_new' : '';
        $folder_image = $is_sf ? $images["icon_minipost{$new}"] : $images["forum{$new}"];
        if ($f['forum_status'] == FORUM_LOCKED) {
            $folder_image = $is_sf ? $images['icon_minipost'] : $images['forum_locked'];
        }
        if ($is_sf) {
            $template->assign_block_vars('c.f.sf', array('SF_ID' => $fid, 'SF_NAME' => $fname_html, 'SF_NEW' => $new ? ' new' : ''));
            continue;
        }
        $template->assign_block_vars('c.f', array('FORUM_FOLDER_IMG' => $folder_image, 'FORUM_ID' => $fid, 'FORUM_NAME' => $fname_html, 'FORUM_DESC' => $f['forum_desc'], 'POSTS' => commify($f['forum_posts']), 'TOPICS' => commify($f['forum_topics']), 'LAST_SF_ID' => isset($f['last_sf_id']) ? $f['last_sf_id'] : null, 'MODERATORS' => isset($moderators[$fid]) ? join(', ', $moderators[$fid]) : '', 'FORUM_FOLDER_ALT' => $new ? $lang['NEW'] : $lang['OLD']));
        if ($f['last_post_id']) {
            $template->assign_block_vars('c.f.last', array('LAST_TOPIC_ID' => $f['last_topic_id'], 'LAST_TOPIC_TIP' => $f['last_topic_title'], 'LAST_TOPIC_TITLE' => wbr(str_short($f['last_topic_title'], $last_topic_max_len)), 'LAST_POST_TIME' => bb_date($f['last_post_time'], $bb_cfg['last_post_date_format']), 'LAST_POST_USER' => profile_url(array('username' => str_short($f['last_post_username'], 15), 'user_id' => $f['last_post_user_id'], 'user_rank' => $f['last_post_user_rank']))));
        }
    }
}
$template->assign_vars(array('SHOW_FORUMS' => $forums_count, 'SHOW_MAP' => isset($_GET['map']) && !IS_GUEST, 'PAGE_TITLE' => $viewcat ? $cat_title_html[$viewcat] : $lang['HOME'], 'NO_FORUMS_MSG' => $only_new ? $lang['NO_NEW_POSTS'] : $lang['NO_FORUMS'], 'TOTAL_TOPICS' => sprintf($lang['POSTED_TOPICS_TOTAL'], $stats['topiccount']), 'TOTAL_POSTS' => sprintf($lang['POSTED_ARTICLES_TOTAL'], $stats['postcount']), 'TOTAL_USERS' => sprintf($lang['REGISTERED_USERS_TOTAL'], $stats['usercount']), 'TOTAL_GENDER' => $bb_cfg['gender'] ? sprintf($lang['USERS_TOTAL_GENDER'], $stats['male'], $stats['female'], $stats['unselect']) : '', 'NEWEST_USER' => sprintf($lang['NEWEST_USER'], profile_url($stats['newestuser'])), 'TORRENTS_STAT' => $bb_cfg['tor_stats'] ? sprintf($lang['TORRENTS_STAT'], $stats['torrentcount'], humn_size($stats['size'])) : '', 'PEERS_STAT' => $bb_cfg['tor_stats'] ? sprintf($lang['PEERS_STAT'], $stats['peers'], $stats['seeders'], $stats['leechers']) : '', 'SPEED_STAT' => $bb_cfg['tor_stats'] ? sprintf($lang['SPEED_STAT'], humn_size($stats['speed']) . '/s') : '', 'SHOW_MOD_INDEX' => $bb_cfg['show_mod_index'], 'FORUM_IMG' => $images['forum'], 'FORUM_NEW_IMG' => $images['forum_new'], 'FORUM_LOCKED_IMG' => $images['forum_locked'], 'SHOW_ONLY_NEW_MENU' => true, 'ONLY_NEW_POSTS_ON' => $only_new == ONLY_NEW_POSTS, 'ONLY_NEW_TOPICS_ON' => $only_new == ONLY_NEW_TOPICS, 'U_SEARCH_NEW' => "search.php?new=1", 'U_SEARCH_SELF_BY_MY' => "search.php?uid={$userdata['user_id']}&amp;o=1", 'U_SEARCH_LATEST' => "search.php?search_id=latest", 'U_SEARCH_UNANSWERED' => "search.php?search_id=unanswered", 'SHOW_LAST_TOPIC' => $show_last_topic));
// Set tpl vars for bt_userdata
if ($bb_cfg['bt_show_dl_stat_on_index'] && !IS_GUEST) {
    show_bt_userdata($userdata['user_id']);
}
// Latest news
if ($bb_cfg['show_latest_news']) {
    if (!($latest_news = $datastore->get('latest_news'))) {
        $datastore->update('latest_news');
        $latest_news = $datastore->get('latest_news');
    }
    $template->assign_vars(array('SHOW_LATEST_NEWS' => true));
    foreach ($latest_news as $news) {
        $template->assign_block_vars('news', array('NEWS_TOPIC_ID' => $news['topic_id'], 'NEWS_TITLE' => str_short($news['topic_title'], $bb_cfg['max_news_title']), 'NEWS_TIME' => bb_date($news['topic_time'], 'd-M', false), 'NEWS_IS_NEW' => is_unread($news['topic_time'], $news['topic_id'], $news['forum_id'])));
    }
}
Example #4
0
/**
* Assign Variables and Definitions based on the fetched Attachments - internal
* used by all displaying functions, the Data was collected before, it's only dependend on the template used. :)
* before this function is usable, init_display_attachments have to be called for specific pages (pm, posting, review etc...)
*/
function display_attachments($post_id)
{
    global $template, $upload_dir, $userdata, $allowed_extensions, $display_categories, $download_modes, $lang, $attachments, $upload_icons, $attach_config;
    $num_attachments = @sizeof($attachments['_' . $post_id]);
    if ($num_attachments == 0) {
        return;
    }
    $template->assign_block_vars('postrow.attach', array());
    for ($i = 0; $i < $num_attachments; $i++) {
        // Some basic things...
        $filename = $upload_dir . '/' . basename($attachments['_' . $post_id][$i]['physical_filename']);
        $thumbnail_filename = $upload_dir . '/' . THUMB_DIR . '/t_' . basename($attachments['_' . $post_id][$i]['physical_filename']);
        $upload_image = '';
        if ($attach_config['upload_img'] && empty($upload_icons[$attachments['_' . $post_id][$i]['extension']])) {
            $upload_image = '<img src="' . $attach_config['upload_img'] . '" alt="" border="0" />';
        } else {
            if (trim($upload_icons[$attachments['_' . $post_id][$i]['extension']]) != '') {
                $upload_image = '<img src="' . $upload_icons[$attachments['_' . $post_id][$i]['extension']] . '" alt="" border="0" />';
            }
        }
        $filesize = humn_size($attachments['_' . $post_id][$i]['filesize']);
        $display_name = htmlspecialchars($attachments['_' . $post_id][$i]['real_filename']);
        $comment = htmlspecialchars($attachments['_' . $post_id][$i]['comment']);
        $comment = str_replace("\n", '<br />', $comment);
        $denied = false;
        // Admin is allowed to view forbidden Attachments, but the error-message is displayed too to inform the Admin
        if (!in_array($attachments['_' . $post_id][$i]['extension'], $allowed_extensions)) {
            $denied = true;
            $template->assign_block_vars('postrow.attach.denyrow', array('L_DENIED' => sprintf($lang['EXTENSION_DISABLED_AFTER_POSTING'], $attachments['_' . $post_id][$i]['extension'])));
        }
        if (!$denied || IS_ADMIN) {
            // define category
            $image = FALSE;
            $thumbnail = FALSE;
            $link = FALSE;
            if (@intval($display_categories[$attachments['_' . $post_id][$i]['extension']]) == IMAGE_CAT && intval($attach_config['img_display_inlined'])) {
                if (intval($attach_config['img_link_width']) != 0 || intval($attach_config['img_link_height']) != 0) {
                    list($width, $height) = image_getdimension($filename);
                    if ($width == 0 && $height == 0) {
                        $image = TRUE;
                    } else {
                        if ($width <= intval($attach_config['img_link_width']) && $height <= intval($attach_config['img_link_height'])) {
                            $image = TRUE;
                        }
                    }
                } else {
                    $image = TRUE;
                }
            }
            if (@intval($display_categories[$attachments['_' . $post_id][$i]['extension']]) == IMAGE_CAT && $attachments['_' . $post_id][$i]['thumbnail'] == 1) {
                $thumbnail = TRUE;
                $image = FALSE;
            }
            if (!$image && !$thumbnail) {
                $link = TRUE;
            }
            if ($image) {
                // Images
                if ($attach_config['upload_dir'][0] == '/' || $attach_config['upload_dir'][0] != '/' && $attach_config['upload_dir'][1] == ':') {
                    $img_source = BB_ROOT . DOWNLOAD_URL . $attachments['_' . $post_id][$i]['attach_id'];
                    $download_link = TRUE;
                } else {
                    $img_source = $filename;
                    $download_link = FALSE;
                }
                $template->assign_block_vars('postrow.attach.cat_images', array('DOWNLOAD_NAME' => $display_name, 'S_UPLOAD_IMAGE' => $upload_image, 'IMG_SRC' => $img_source, 'FILESIZE' => $filesize, 'COMMENT' => $comment));
                // Directly Viewed Image ... update the download count
                if (!$download_link) {
                    $sql = 'UPDATE ' . BB_ATTACHMENTS_DESC . '
						SET download_count = download_count + 1
						WHERE attach_id = ' . (int) $attachments['_' . $post_id][$i]['attach_id'];
                    if (!DB()->sql_query($sql)) {
                        bb_die('Could not update attachment download count');
                    }
                }
            }
            if ($thumbnail) {
                // Images, but display Thumbnail
                if ($attach_config['upload_dir'][0] == '/' || $attach_config['upload_dir'][0] != '/' && $attach_config['upload_dir'][1] == ':') {
                    $thumb_source = BB_ROOT . DOWNLOAD_URL . $attachments['_' . $post_id][$i]['attach_id'] . '&thumb=1';
                } else {
                    $thumb_source = $thumbnail_filename;
                }
                $template->assign_block_vars('postrow.attach.cat_thumb_images', array('DOWNLOAD_NAME' => $display_name, 'S_UPLOAD_IMAGE' => $upload_image, 'IMG_SRC' => BB_ROOT . DOWNLOAD_URL . $attachments['_' . $post_id][$i]['attach_id'], 'IMG_THUMB_SRC' => $thumb_source, 'FILESIZE' => $filesize, 'COMMENT' => $comment));
            }
            // bt
            if ($link && $attachments['_' . $post_id][$i]['extension'] === TORRENT_EXT) {
                include ATTACH_DIR . 'displaying_torrent.php';
            } else {
                if ($link) {
                    $target_blank = @intval($display_categories[$attachments['_' . $post_id][$i]['extension']]) == IMAGE_CAT ? 'target="_blank"' : '';
                    // display attachment
                    $template->assign_block_vars('postrow.attach.attachrow', array('U_DOWNLOAD_LINK' => BB_ROOT . DOWNLOAD_URL . $attachments['_' . $post_id][$i]['attach_id'], 'S_UPLOAD_IMAGE' => $upload_image, 'DOWNLOAD_NAME' => $display_name, 'FILESIZE' => $filesize, 'COMMENT' => $comment, 'TARGET_BLANK' => $target_blank, 'DOWNLOAD_COUNT' => sprintf($lang['DOWNLOAD_NUMBER'], $attachments['_' . $post_id][$i]['download_count'])));
                }
            }
        }
    }
}
Example #5
0
                    $topic_check_status = '<span style="color:blue;">&#8734;</span>';
                    break;
                default:
                    $topic_check_status = '<span style="color:red;">?</span>';
            }
        }
        $template->assign_block_vars('topicrow', array('ROW_CLASS' => !($i % 2) ? 'row1' : 'row2', 'FORUM_ID' => $forum_id, 'TOPIC_ID' => $topic_id, 'TOPIC_FOLDER_IMG' => $folder_image, 'TOPIC_AUTHOR' => $topic_author, 'GOTO_PAGE' => $goto_page, 'REPLIES' => $replies, 'NEWEST_POST_IMG' => $newest_post_img, 'TOPIC_ATTACHMENT_IMG' => topic_attachment_image($topic_rowset[$i]['topic_attachment']), 'TOPIC_TITLE' => $topic_title, 'TOPIC_TYPE' => $topic_type, 'VIEWS' => $views, 'FIRST_POST_TIME' => $first_post_time, 'LAST_POST_TIME' => $last_post_time, 'LAST_POST_AUTHOR' => $last_post_author, 'LAST_POST_IMG' => $last_post_url, 'TOPIC_CHECK_STATUS' => isset($topic_tor[$topic_id]) ? $topic_check_status . " &#183; " : "", 'TOPICS_SEPARATOR' => $topics_separator, 'L_TOPIC_FOLDER_ALT' => $folder_alt, 'U_VIEW_TOPIC' => $view_topic_url));
        //bt
        if (isset($topic_tor[$topic_id])) {
            $seeds = isset($topic_tor[$topic_id]['seeders']) ? $topic_tor[$topic_id]['seeders'] : 0;
            $leechs = isset($topic_tor[$topic_id]['leechers']) ? $topic_tor[$topic_id]['leechers'] : 0;
            $s_last = $topic_tor[$topic_id]['seeder_last_seen'];
            $compl = $topic_tor[$topic_id]['complete_count'];
            $att_id = $topic_tor[$topic_id]['attach_id'];
            $size = $topic_tor[$topic_id]['size'];
            $template->assign_block_vars('topicrow.tor', array('SEEDERS' => $seeds ? $seeds : 0, 'SEEDERS_TITLE' => $seeds ? 'Seeders' : " Seeder last seen: \n " . ($s_last ? create_date($ft_cfg['default_dateformat'], $s_last, $ft_cfg['board_timezone']) : 'Never'), 'LEECHERS' => $leechs ? $leechs : 0, 'TORRENT_SIZE' => humn_size($size), 'DL_TORRENT_HREF' => append_sid("download.php?id=" . $att_id)));
        }
        $template->assign_block_vars('topicrow.compl', array('COMPLETED' => isset($compl) ? $compl : ''));
        unset($compl);
        //bt end
    }
    ////	$topics_count -= $total_announcements;
    $template->assign_vars(array('PAGINATION' => generate_pagination("viewforum.php?" . POST_FORUM_URL . "={$forum_id}&amp;topicdays={$topic_days}&amp;sort={$sort_value}&amp;order={$order_value}", $topics_count, $ft_cfg['topics_per_page'], $start), 'PAGE_NUMBER' => sprintf($lang['Page_of'], floor($start / $ft_cfg['topics_per_page']) + 1, ceil($topics_count / $ft_cfg['topics_per_page'])), 'L_GOTO_PAGE' => $lang['Goto_page']));
} else {
    //
    // No topics
    //
    $no_topics_msg = $forum_row['forum_status'] == FORUM_LOCKED ? $lang['Forum_locked'] : $lang['No_topics_post_one'];
    $template->assign_vars(array('L_NO_TOPICS' => $no_topics_msg));
    $template->assign_block_vars('switch_no_topics', array());
}
Example #6
0
             $pr_data['avatar_ext_id'] = 0;
             $db_data['avatar_ext_id'] = 0;
         } else {
             if (!empty($_FILES['avatar']['name']) && $bb_cfg['avatars']['up_allowed']) {
                 require INC_DIR . 'functions_upload.php';
                 $upload = new upload_common();
                 if ($upload->init($bb_cfg['avatars'], $_FILES['avatar']) and $upload->store('avatar', $pr_data)) {
                     $pr_data['avatar_ext_id'] = $upload->file_ext_id;
                     $db_data['avatar_ext_id'] = (int) $upload->file_ext_id;
                 } else {
                     $errors = array_merge($errors, $upload->errors);
                 }
             }
         }
     }
     $tp_data['AVATARS_MAX_SIZE'] = humn_size($bb_cfg['avatars']['max_size']);
     break;
     /**
      *  ICQ (edit)
      */
 /**
  *  ICQ (edit)
  */
 case 'user_icq':
     $icq = isset($_POST['user_icq']) ? (string) $_POST['user_icq'] : $pr_data['user_icq'];
     if ($submit && $icq != $pr_data['user_icq']) {
         if ($icq == '' || preg_match('#^\\d{6,15}$#', $icq)) {
             $pr_data['user_icq'] = $icq;
             $db_data['user_icq'] = (string) $icq;
         } else {
             $pr_data['user_icq'] = '';
Example #7
0
}
$sql = " SELECT DISTINCT u.username, u.user_id, u.user_regdate, tr.user_id, tr.u_up_total, tr.u_down_total, tr.u_bonus_total, (tr.u_up_total + tr.u_bonus_total)/tr.u_down_total AS rat, bl.ban_userid\r\n        FROM ( " . USERS_TABLE . " u LEFT JOIN " . BT_USERS_TABLE . " tr ON u.user_id=tr.user_id)LEFT JOIN " . BANLIST_TABLE . " bl ON u.user_id=bl.ban_userid\r\n        WHERE bl.ban_userid Is Null\r\n        AND tr.u_up_total > 2147483648\r\n \r\n        ORDER BY rat DESC\r\n        LIMIT {$medal_num_recent}";
if (!($result = DB()->sql_query($sql))) {
    message_die(GENERAL_ERROR, "Could not query users {$sql}", '', __LINE__, __FILE__, $sql);
}
if ($row = DB()->sql_fetchrow($result)) {
    $i = 0;
    do {
        $username = $row['username'];
        $user_id = $row['user_id'];
        $joined = create_date($lang['DATE_FORMAT'], $row['user_regdate'], $ft_cfg['board_timezone']);
        $upload = $row['u_up_total'];
        $bonus = $row['u_bonus_total'];
        $download = $row['u_down_total'];
        $ratio = $download ? round(($upload + $bonus) / $download, 2) : '';
        $template->assign_block_vars('memberrow3', array('ROW_NUMBER' => $i + ($start + 1), 'ROW_CLASS' => !($i % 2) ? 'row1' : 'row2', 'USERNAME' => $username, 'JOINED' => $joined, 'UP' => humn_size($upload), 'BONUS' => humn_size($bonus), 'DOWN' => humn_size($download), 'UP_DOWN_RATIO' => $ratio, 'U_VIEWPROFILE' => append_sid("profile.php?mode=viewprofile&amp;" . POST_USERS_URL . "={$user_id}")));
        $i++;
    } while ($row = DB()->sql_fetchrow($result));
    DB()->sql_freeresult($result);
}
$sql = "SELECT count(uds.compl_count) AS complete, tor.*, t.*, u.username, u.user_id, f.forum_id, f.forum_name, cat.cat_id, cat.cat_title, t.topic_title, t.topic_id\r\n       FROM " . BT_TORRENTS_TABLE . " tor, " . TOPICS_TABLE . " t , " . FORUMS_TABLE . " f , " . USERS_TABLE . " u , " . CATEGORIES_TABLE . " cat, " . BT_USR_DL_STAT_TABLE . " uds\r\n       WHERE\r\n                                 tor.topic_id = t.topic_id\r\n                                AND tor.poster_id = u.user_id\r\n                                AND t.forum_id = f.forum_id\r\n                                AND f.cat_id = cat.cat_id\r\n                                AND uds.topic_id = tor.topic_id\r\n                                AND uds.user_status = 2\r\n       GROUP BY uds.topic_id\r\n       ORDER BY complete DESC\r\n       LIMIT 10";
if (!($result = DB()->sql_query($sql))) {
    message_die(GENERAL_ERROR, "Could not query torrent {$sql}", '', __LINE__, __FILE__, $sql);
}
if ($row = DB()->sql_fetchrow($result)) {
    $i = 0;
    do {
        $username = $row['username'];
        $user_id = $row['user_id'];
        $category = $row['cat_id'];
        $forum_name = $row['forum_name'];
Example #8
0
                        $tcs_id = '<span style="color:#E6C506;">&#8776;</span>';
                        $tcs_title = 'Недоофолмлено';
                        break;
                    case 4:
                        $tcs_id = '<span style="color:red;">&#8800;</span>';
                        $tcs_title = 'Неоформлено';
                        break;
                    case 5:
                        $tcs_id = '<span style="color:blue;">&#8734;</span>';
                        $tcs_title = 'Повтор';
                        break;
                    default:
                        $tcs_id = '<span style="color:red;">?</span>';
                        $tcs_title = 'Не проверено';
                }
                $template->assign_block_vars('tor', array('CAT_ID' => $tor_row['cat_id'], 'CAT_HREF' => append_sid("{$tracker_basename}?{$cat_key}=" . $tor_row['cat_id']), 'CAT_TITLE' => $tor_row['cat_title'], 'FORUM_ID' => $tor_row['forum_id'], 'FORUM_HREF' => append_sid("{$tracker_basename}?{$forum_key}=" . $tor_row['forum_id']), 'FORUM_NAME' => $tor_row['forum_name'], 'TOPIC_ID' => $tor_row['topic_id'], 'TOPIC_HREF' => append_sid("viewtopic.php?{$topic_key}=" . $tor_row['topic_id']), 'TOPIC_TITLE' => $tor_row['topic_title'], 'POSTER_ID' => $tor_row['poster_id'], 'POSTER_HREF' => append_sid("{$tracker_basename}?{$poster_id_key}=" . $tor_row['poster_id']), 'USERNAME' => $tor_row['username'], 'TITLE_AUTHOR' => $show_author_val ? '' : ' by: ' . $tor_row['username'] . ' ', 'TCS_ID' => $tcs_id, 'TCS_TITLE' => $tcs_title, 'TITLE_SPEED' => $show_speed_val ? '' : ($dl ? " {$dl_sp} " : ''), 'ROW_CLASS' => $row_class, 'ROW_NUM' => $row_num, 'DL_CLASS' => $dl_class, 'POST_IMG' => $post_img, 'USER_AUTHOR' => !$guest && $tor_row['poster_id'] == $user_id ? TRUE : FALSE, 'DL_TOR_HREF' => append_sid("download.php?id=" . $att_id), 'TOR_SIZE_RAW' => $size, 'TOR_SIZE' => humn_size($size, '', '', ' '), 'UL_SPEED' => $ul_sp, 'DL_SPEED' => $dl_sp, 'SEEDS' => $seeds ? $seeds : 0, 'SEEDS_TITLE' => $seeds ? 'Seeders' : " Last seen: \n " . ($s_last ? create_date($date_format, $s_last, $ft_cfg['board_timezone']) : 'Never'), 'LEECHS' => $leechs ? $leechs : 0, 'COMPLETED' => $compl ? $compl : 0, 'ADDED_RAW' => $tor_row['reg_time'], 'ADDED_TIME' => create_date($time_format, $tor_row['reg_time'], $ft_cfg['board_timezone']), 'ADDED_DATE' => create_date($date_format, $tor_row['reg_time'], $ft_cfg['board_timezone'])));
            }
        }
    }
} else {
    $template->assign_block_vars('tor_not_found', array('L_NO_MATCH' => $lang['Bt_No_searchable_forums']));
}
// Pagination
if ($tor_count) {
    $base_url = $tracker_basename . '?search_id=' . $search_id;
    $l_search_matches = $tor_count == 1 ? sprintf($lang['Found_search_match'], $tor_count) : sprintf($lang['Found_search_matches'], $tor_count);
    $l_search_max = "(max: {$tor_search_limit})";
    $template->assign_vars(array('L_MATCHES' => $l_search_matches, 'L_SERACH_MAX' => $l_search_max, 'PAGINATION' => generate_pagination($base_url, $tor_count, $tor_per_page, $start), 'PAGE_NUMBER' => sprintf($lang['Page_of'], floor($start / $tor_per_page) + 1, ceil($tor_count / $tor_per_page))));
}
// Forum select
$select_size = $cat_forum_size < $max_forum_sel_size ? $cat_forum_size : $max_forum_sel_size;
Example #9
0
    if ($t_type == POST_ANNOUNCE && !defined('ANNOUNCE_SEP')) {
        define('ANNOUNCE_SEP', true);
        $separator = $lang['TOPICS_ANNOUNCEMENT'];
    } elseif ($t_type == POST_STICKY && !defined('STICKY_SEP')) {
        define('STICKY_SEP', true);
        $separator = $lang['TOPICS_STICKY'];
    } elseif ($t_type == POST_NORMAL && !defined('NORMAL_SEP')) {
        if (defined('ANNOUNCE_SEP') || defined('STICKY_SEP')) {
            define('NORMAL_SEP', true);
            $separator = $lang['TOPICS_NORMAL'];
        }
    }
    $template->assign_block_vars('t', array('FORUM_ID' => $forum_id, 'TOPIC_ID' => $topic_id, 'HREF_TOPIC_ID' => $moved ? $topic['topic_moved_id'] : $topic['topic_id'], 'TOPIC_TITLE' => wbr($topic['topic_title']), 'TOPICS_SEPARATOR' => $separator, 'IS_UNREAD' => $is_unread, 'TOPIC_ICON' => get_topic_icon($topic, $is_unread), 'PAGINATION' => $moved ? '' : build_topic_pagination(TOPIC_URL . $topic_id, $replies, $bb_cfg['posts_per_page']), 'REPLIES' => $replies, 'VIEWS' => $topic['topic_views'], 'TOR_STALED' => $forum_data['allow_reg_tracker'] && !($t_type == POST_ANNOUNCE || $t_type == POST_STICKY || $topic['tor_size']), 'TOR_FROZEN' => isset($topic['tor_status']) ? !IS_AM ? isset($bb_cfg['tor_frozen'][$topic['tor_status']]) : '' : '', 'TOR_TYPE' => isset($topic['tor_type']) ? is_gold($topic['tor_type']) : '', 'TOR_STATUS_ICON' => isset($topic['tor_status']) ? $bb_cfg['tor_icons'][$topic['tor_status']] : '', 'TOR_STATUS_TEXT' => isset($topic['tor_status']) ? $lang['TOR_STATUS_NAME'][$topic['tor_status']] : '', 'ATTACH' => $topic['topic_attachment'], 'STATUS' => $topic['topic_status'], 'TYPE' => $topic['topic_type'], 'DL' => $topic['topic_dl_type'] == TOPIC_DL_TYPE_DL && !$forum_data['allow_reg_tracker'], 'POLL' => $topic['topic_vote'], 'DL_CLASS' => isset($topic['dl_status']) ? $dl_link_css[$topic['dl_status']] : '', 'TOPIC_AUTHOR' => profile_url(array('username' => str_short($topic['first_username'], 15), 'user_id' => $topic['first_user_id'], 'user_rank' => $topic['first_user_rank'])), 'LAST_POSTER' => profile_url(array('username' => str_short($topic['last_username'], 15), 'user_id' => $topic['last_user_id'], 'user_rank' => $topic['last_user_rank'])), 'LAST_POST_TIME' => bb_date($topic['topic_last_post_time']), 'LAST_POST_ID' => $topic['topic_last_post_id']));
    if (isset($topic['tor_size'])) {
        $tor_magnet = create_magnet($topic['info_hash'], $topic['auth_key'], $userdata['session_logged_in']);
        $template->assign_block_vars('t.tor', array('SEEDERS' => (int) $topic['seeders'], 'LEECHERS' => (int) $topic['leechers'], 'TOR_SIZE' => humn_size($topic['tor_size']), 'COMPL_CNT' => (int) $topic['complete_count'], 'ATTACH_ID' => $topic['attach_id'], 'MAGNET' => $tor_magnet));
    }
    $found_topics++;
}
unset($topic_rowset);
$pg_url = FORUM_URL . $forum_id;
$pg_url .= $sort_value ? "&sort={$sort_value}" : '';
$pg_url .= $order_value ? "&order={$order_value}" : '';
$template->assign_var('MOD_URL', $pg_url);
$pg_url = FORUM_URL . $forum_id;
$pg_url .= $topic_days ? "&amp;topicdays={$topic_days}" : '';
$pg_url .= $sort_value ? "&amp;sort={$sort_value}" : '';
$pg_url .= $order_value ? "&amp;order={$order_value}" : '';
$pg_url .= $moderation ? "&amp;mod=1" : '';
$pg_url .= $topics_per_page != $bb_cfg['topics_per_page'] ? "&amp;tpp={$topics_per_page}" : '';
if ($found_topics) {
Example #10
0
function show_bt_userdata($user_id)
{
    global $lang, $template;
    $btu = get_bt_userdata($user_id);
    $template->assign_vars(array('SHOW_BT_USERDATA' => true, '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'));
}
    /**
     * Upload an Attachment to Filespace (intern)
     */
    function upload_attachment()
    {
        global $error, $error_msg, $lang, $attach_config, $userdata, $upload_dir, $forum_id;
        $this->post_attach = $this->filename != '' ? TRUE : FALSE;
        if ($this->post_attach) {
            $r_file = trim(basename($this->filename));
            $file = $_FILES['fileupload']['tmp_name'];
            $this->type = $_FILES['fileupload']['type'];
            if (isset($_FILES['fileupload']['size']) && $_FILES['fileupload']['size'] == 0) {
                bb_die('Tried to upload empty file');
            }
            $this->type = strtolower($this->type);
            $this->extension = strtolower(get_extension($this->filename));
            $this->filesize = @filesize($file);
            $this->filesize = intval($this->filesize);
            $sql = 'SELECT g.allow_group, g.max_filesize, g.cat_id, g.forum_permissions
				FROM ' . BB_EXTENSION_GROUPS . ' g, ' . BB_EXTENSIONS . " e\n\t\t\t\tWHERE g.group_id = e.group_id\n\t\t\t\t\tAND e.extension = '" . attach_mod_sql_escape($this->extension) . "'\n\t\t\t\tLIMIT 1";
            if (!($result = DB()->sql_query($sql))) {
                bb_die('Could not query extensions');
            }
            $row = DB()->sql_fetchrow($result);
            DB()->sql_freeresult($result);
            $allowed_filesize = $row['max_filesize'] ? $row['max_filesize'] : $attach_config['max_filesize'];
            $cat_id = intval($row['cat_id']);
            $auth_cache = trim($row['forum_permissions']);
            // check Filename
            if (preg_match("#[\\/:*?\"<>|]#i", $this->filename)) {
                $error = TRUE;
                if (!empty($error_msg)) {
                    $error_msg .= '<br />';
                }
                $error_msg .= sprintf($lang['INVALID_FILENAME'], htmlspecialchars($this->filename));
            }
            // check php upload-size
            if (!$error && $file == 'none') {
                $error = TRUE;
                if (!empty($error_msg)) {
                    $error_msg .= '<br />';
                }
                $ini_val = 'ini_get';
                $max_size = @$ini_val('upload_max_filesize');
                if ($max_size == '') {
                    $error_msg .= $lang['ATTACHMENT_PHP_SIZE_NA'];
                } else {
                    $error_msg .= sprintf($lang['ATTACHMENT_PHP_SIZE_OVERRUN'], $max_size);
                }
            }
            // Check Extension
            if (!$error && intval($row['allow_group']) == 0) {
                $error = TRUE;
                if (!empty($error_msg)) {
                    $error_msg .= '<br />';
                }
                $error_msg .= sprintf($lang['DISALLOWED_EXTENSION'], htmlspecialchars($this->extension));
            }
            // Check Forum Permissions
            if (!$error && !IS_ADMIN && !is_forum_authed($auth_cache, $forum_id) && trim($auth_cache) != '') {
                $error = TRUE;
                if (!empty($error_msg)) {
                    $error_msg .= '<br />';
                }
                $error_msg .= sprintf($lang['DISALLOWED_EXTENSION_WITHIN_FORUM'], htmlspecialchars($this->extension));
            }
            //bt
            // Check if user can post torrent
            global $post_data;
            if (!$error && $this->extension === TORRENT_EXT && !$post_data['first_post']) {
                $error = TRUE;
                if (!empty($error_msg)) {
                    $error_msg .= '<br />';
                }
                $error_msg .= $lang['ALLOWED_ONLY_1ST_POST_ATTACH'];
            }
            //bt end
            // Upload File
            $this->thumbnail = 0;
            if (!$error) {
                //
                // Prepare Values
                $this->filetime = TIMENOW;
                $this->filename = $r_file;
                // physical filename
                //$this->attach_filename = strtolower($this->filename);
                $this->attach_filename = $this->filename;
                //bt
                if (FILENAME_CRYPTIC) {
                    $this->attach_filename = make_rand_str(FILENAME_CRYPTIC_LENGTH);
                } else {
                    // original
                    $this->attach_filename = html_entity_decode(trim(stripslashes($this->attach_filename)));
                    $this->attach_filename = delete_extension($this->attach_filename);
                    $this->attach_filename = str_replace(array(' ', '-'), array('_', '_'), $this->attach_filename);
                    $this->attach_filename = str_replace('__', '_', $this->attach_filename);
                    $this->attach_filename = str_replace(array(',', '.', '!', '?', 'ь', 'Ь', 'ц', 'Ц', 'д', 'Д', ';', ':', '@', "'", '"', '&'), array('', '', '', '', 'ue', 'ue', 'oe', 'oe', 'ae', 'ae', '', '', '', '', '', 'and'), $this->attach_filename);
                    $this->attach_filename = str_replace(array('$', 'Я', '>', '<', '§', '%', '=', '/', '(', ')', '#', '*', '+', "\\", '{', '}', '[', ']'), array('dollar', 'ss', 'greater', 'lower', 'paragraph', 'percent', 'equal', '', '', '', '', '', '', '', '', '', '', ''), $this->attach_filename);
                    // Remove non-latin characters
                    $this->attach_filename = preg_replace('#([\\xC2\\xC3])([\\x80-\\xBF])#', 'chr(ord(\'$1\')<<6&0xC0|ord(\'$2\')&0x3F)', $this->attach_filename);
                    $this->attach_filename = rawurlencode($this->attach_filename);
                    $this->attach_filename = preg_replace("/(%[0-9A-F]{1,2})/i", '', $this->attach_filename);
                    $this->attach_filename = trim($this->attach_filename);
                }
                $this->attach_filename = str_replace(array('&amp;', '&', ' '), '_', $this->attach_filename);
                $this->attach_filename = str_replace('php', '_php_', $this->attach_filename);
                $this->attach_filename = substr(trim($this->attach_filename), 0, FILENAME_MAX_LENGTH);
                for ($i = 0, $max_try = 5; $i <= $max_try; $i++) {
                    $fn_prefix = make_rand_str(FILENAME_PREFIX_LENGTH) . '_';
                    $new_physical_filename = clean_filename($fn_prefix . $this->attach_filename);
                    if (!physical_filename_already_stored($new_physical_filename)) {
                        break;
                    }
                    if ($i == $max_try) {
                        bb_die('Could not create filename for attachment');
                    }
                }
                $this->attach_filename = $new_physical_filename;
                // Do we have to create a thumbnail ?
                if ($cat_id == IMAGE_CAT && intval($attach_config['img_create_thumbnail'])) {
                    $this->thumbnail = 1;
                }
            }
            if ($error) {
                $this->post_attach = FALSE;
                return;
            }
            // Upload Attachment
            if (!$error) {
                // Descide the Upload method
                $ini_val = 'ini_get';
                $safe_mode = @$ini_val('safe_mode');
                if (@$ini_val('open_basedir')) {
                    $upload_mode = 'move';
                } else {
                    if (@$ini_val('safe_mode')) {
                        $upload_mode = 'move';
                    } else {
                        $upload_mode = 'copy';
                    }
                }
                // Ok, upload the Attachment
                if (!$error) {
                    $this->move_uploaded_attachment($upload_mode, $file);
                }
            }
            // Now, check filesize parameters
            if (!$error) {
                if (!$this->filesize) {
                    $this->filesize = intval(@filesize($upload_dir . '/' . $this->attach_filename));
                }
            }
            // Check Image Size, if it's an image
            if (!$error && !IS_ADMIN && $cat_id == IMAGE_CAT) {
                list($width, $height) = image_getdimension($upload_dir . '/' . $this->attach_filename);
                if ($width != 0 && $height != 0 && intval($attach_config['img_max_width']) != 0 && intval($attach_config['img_max_height']) != 0) {
                    if ($width > intval($attach_config['img_max_width']) || $height > intval($attach_config['img_max_height'])) {
                        $error = TRUE;
                        if (!empty($error_msg)) {
                            $error_msg .= '<br />';
                        }
                        $error_msg .= sprintf($lang['ERROR_IMAGESIZE'], intval($attach_config['img_max_width']), intval($attach_config['img_max_height']));
                    }
                }
            }
            // check Filesize
            if (!$error && $allowed_filesize != 0 && $this->filesize > $allowed_filesize && !(IS_ADMIN || IS_MOD || IS_GROUP_MEMBER)) {
                $allowed_filesize = humn_size($allowed_filesize);
                $error = TRUE;
                if (!empty($error_msg)) {
                    $error_msg .= '<br />';
                }
                $error_msg .= sprintf($lang['ATTACHMENT_TOO_BIG'], $allowed_filesize);
            }
            // Check our complete quota
            if ($attach_config['attachment_quota']) {
                $sql = 'SELECT sum(filesize) as total FROM ' . BB_ATTACHMENTS_DESC;
                if (!($result = DB()->sql_query($sql))) {
                    bb_die('Could not query total filesize #1');
                }
                $row = DB()->sql_fetchrow($result);
                DB()->sql_freeresult($result);
                $total_filesize = $row['total'];
                if ($total_filesize + $this->filesize > $attach_config['attachment_quota']) {
                    $error = TRUE;
                    if (!empty($error_msg)) {
                        $error_msg .= '<br />';
                    }
                    $error_msg .= $lang['ATTACH_QUOTA_REACHED'];
                }
            }
            $this->get_quota_limits($userdata);
            // Check our user quota
            if ($attach_config['upload_filesize_limit']) {
                $sql = 'SELECT attach_id
					FROM ' . BB_ATTACHMENTS . '
					WHERE user_id_1 = ' . (int) $userdata['user_id'] . '
					GROUP BY attach_id';
                if (!($result = DB()->sql_query($sql))) {
                    bb_die('Could not query attachments');
                }
                $attach_ids = DB()->sql_fetchrowset($result);
                $num_attach_ids = DB()->num_rows($result);
                DB()->sql_freeresult($result);
                $attach_id = array();
                for ($i = 0; $i < $num_attach_ids; $i++) {
                    $attach_id[] = intval($attach_ids[$i]['attach_id']);
                }
                if ($num_attach_ids > 0) {
                    // Now get the total filesize
                    $sql = 'SELECT sum(filesize) as total
						FROM ' . BB_ATTACHMENTS_DESC . '
						WHERE attach_id IN (' . implode(', ', $attach_id) . ')';
                    if (!($result = DB()->sql_query($sql))) {
                        bb_die('Could not query total filesize #2');
                    }
                    $row = DB()->sql_fetchrow($result);
                    DB()->sql_freeresult($result);
                    $total_filesize = $row['total'];
                } else {
                    $total_filesize = 0;
                }
                if ($total_filesize + $this->filesize > $attach_config['upload_filesize_limit']) {
                    $upload_filesize_limit = $attach_config['upload_filesize_limit'];
                    $size_lang = $upload_filesize_limit >= 1048576 ? $lang['MB'] : ($upload_filesize_limit >= 1024 ? $lang['KB'] : $lang['BYTES']);
                    if ($upload_filesize_limit >= 1048576) {
                        $upload_filesize_limit = round($upload_filesize_limit / 1048576 * 100) / 100;
                    } else {
                        if ($upload_filesize_limit >= 1024) {
                            $upload_filesize_limit = round($upload_filesize_limit / 1024 * 100) / 100;
                        }
                    }
                    $error = TRUE;
                    if (!empty($error_msg)) {
                        $error_msg .= '<br />';
                    }
                    $error_msg .= sprintf($lang['USER_UPLOAD_QUOTA_REACHED'], $upload_filesize_limit, $size_lang);
                }
            }
            if ($error) {
                unlink_attach($this->attach_filename);
                unlink_attach($this->attach_filename, MODE_THUMBNAIL);
                $this->post_attach = FALSE;
            }
        }
    }
Example #12
0
    require FT_ROOT . 'includes/functions_torrent.php';
    @($torrent = get_torrent_info($attach_id));
    @($filename = FT_ROOT . $attach_config['upload_dir'] . '/' . $torrent['physical_filename']);
    @($tor = bdecode_file($filename));
    @($info = $tor['info']);
    $html = '<table width="95%" border="0" cellpadding="2" cellspacing="1" class="btTbl" align=center>';
    $html .= '<tbody><tr class="row2">';
    $html .= '<td class="genmed" align="center"> ' . (@$info["length"] ? "‘айл" : "ѕапка") . '</td>';
    $html .= '<td class="genmed" align="left"> ' . utf8_to_win($info["name"]) . '</td>';
    $html .= '<td class="genmed" align="right"> ' . (@$info["length"] ? humn_size($info["length"]) : "") . '</td>';
    $html .= '</tr>';
    if (@$info['files'] && is_array($info['files'])) {
        foreach ($info['files'] as $fn => $f) {
            $html .= '<tr class="row1">';
            $html .= '<td class="genmed" align="center"> ' . ($fn + 1) . '</td>';
            $html .= '<td class="genmed" align="left"> ' . utf8_to_win(implode('/', $f['path'])) . '</td>';
            $html .= '<td class="genmed" align="right"> ' . humn_size($f['length']) . '</td>';
            $html .= '</tr>';
        }
    }
    $html .= '</tbody></table>';
    // Escape data
    $html = str_replace("'", "\\'", $html);
    $html = str_replace("\r\n", '\\n', $html);
    $html = str_replace("\r", '\\n', $html);
    $html = str_replace("\n", '\\n', $html);
    $template->assign_vars(array('INSIDE' => $html));
}
// Inside torrent END!!!!
$template->pparse('body');
require FT_ROOT . 'includes/page_tail.php';
Example #13
0
        $user_ratio = $btu['u_down_total'] > MIN_DL_FOR_RATIO ? '<b class="gen">' . get_bt_ratio($btu) . '</b>' : $lang['IT_WILL_BE_DOWN'] . ' <b>' . humn_size(MIN_DL_FOR_RATIO) . '</b>';
        $html = '
			<tr class="row3">
				<th style="padding: 0;"></th>
				<th>' . $lang['DOWNLOADED'] . '</th>
				<th>' . $lang['UPLOADED'] . '</th>
				<th>' . $lang['RELEASED'] . '</th>
				<th>' . $lang['BONUS'] . '</th>';
        $html .= $bb_cfg['seed_bonus_enabled'] ? '<th>' . $lang['SEED_BONUS'] . '</th>' : '';
        $html .= '</tr>
			<tr class="row1">
				<td>' . $lang['TOTAL_TRAF'] . '</td>
				<td id="u_down_total"><span class="editable bold leechmed">' . humn_size($btu['u_down_total']) . '</span></td>
				<td id="u_up_total"><span class="editable bold seedmed">' . humn_size($btu['u_up_total']) . '</span></td>
				<td id="u_up_release"><span class="editable bold seedmed">' . humn_size($btu['u_up_release']) . '</span></td>
				<td id="u_up_bonus"><span class="editable bold seedmed">' . humn_size($btu['u_up_bonus']) . '</span></td>';
        $html .= $bb_cfg['seed_bonus_enabled'] ? '<td id="user_points"><span class="editable bold points">' . $profiledata['user_points'] . '</b></td>' : '';
        $html .= '</tr>
			<tr class="row5">
				<td colspan="1">' . $lang['MAX_SPEED'] . '</td>
				<td colspan="2">' . $lang['DL_DL_SPEED'] . ': ' . $speed_down . '</span></td>
				<td colspan="2">' . $lang['DL_UL_SPEED'] . ': ' . $speed_up . '</span></td>';
        $html .= $bb_cfg['seed_bonus_enabled'] ? '<td colspan="1"></td>' : '';
        $html .= '</tr>';
        $this->response['user_ratio'] = '
			<th><a href="' . $bb_cfg['ratio_url_help'] . '" class="bold">' . $lang['USER_RATIO'] . '</a>:</th>
			<td>' . $user_ratio . '</td>
		';
        break;
}
$this->response['html'] = $html;
Example #14
0
/**
* Returns the filesize of the upload directory in human readable format
*/
function get_formatted_dirsize()
{
    global $attach_config, $upload_dir, $lang;
    $upload_dir_size = 0;
    if ($dirname = @opendir($upload_dir)) {
        while ($file = @readdir($dirname)) {
            if ($file != 'index.php' && $file != '.htaccess' && !is_dir($upload_dir . '/' . $file) && !is_link($upload_dir . '/' . $file)) {
                $upload_dir_size += @filesize($upload_dir . '/' . $file);
            }
        }
        @closedir($dirname);
    } else {
        $upload_dir_size = $lang['NOT_AVAILABLE'];
        return $upload_dir_size;
    }
    return humn_size($upload_dir_size);
}
Example #15
0
 if ($result = DB()->sql_query($sql)) {
     $row = DB()->sql_fetchrow($result);
     $version = $row['mysql_version'];
     if (preg_match('/^(3\\.23|4\\.|5\\.|10\\.)/', $version)) {
         $dblist = array();
         foreach ($ft_cfg['database'] as $name => $row) {
             $sql = "SHOW TABLE STATUS FROM {$row[1]}";
             if ($result = DB()->sql_query($sql)) {
                 $tabledata_ary = DB()->sql_fetchrowset($result);
                 $dbsize = 0;
                 for ($i = 0; $i < count($tabledata_ary); $i++) {
                     if (@$tabledata_ary[$i]['Type'] != 'MRG_MYISAM') {
                         $dbsize += $tabledata_ary[$i]['Data_length'] + $tabledata_ary[$i]['Index_length'];
                     }
                 }
                 $dblist[] = '<span title="' . $name . '">' . humn_size($dbsize) . '</span>';
             }
         }
         $dbsize = implode('&nbsp;|&nbsp;', $dblist);
     } else {
         $dbsize = $lang['Not_available'];
     }
 } else {
     $dbsize = $lang['Not_available'];
 }
 $template->assign_vars(array("NUMBER_OF_POSTS" => $total_posts, "NUMBER_OF_TOPICS" => $total_topics, "NUMBER_OF_USERS" => $total_users, "START_DATE" => $start_date, "POSTS_PER_DAY" => $posts_per_day, "TOPICS_PER_DAY" => $topics_per_day, "USERS_PER_DAY" => $users_per_day, "AVATAR_DIR_SIZE" => $avatar_dir_size, "DB_SIZE" => $dbsize, "GZIP_COMPRESSION" => $ft_cfg['gzip_compress'] ? $lang['ON'] : $lang['OFF']));
 $sql = "SELECT u.user_id, u.username, u.user_session_time, u.user_allow_viewonline, s.session_logged_in, s.session_ip, s.session_start\n\t\tFROM " . USERS_TABLE . " u, " . SESSIONS_TABLE . " s\n\t\tWHERE s.session_logged_in = " . TRUE . "\n\t\t\tAND u.user_id = s.session_user_id\n\t\t\tAND u.user_id <> " . GUEST_UID . "\n\t\t\tAND s.session_time >= " . (time() - 300) . "\n\t\tORDER BY s.session_ip ASC, u.user_session_time DESC";
 if (!($result = DB()->sql_query($sql))) {
     message_die(GENERAL_ERROR, "Couldn't obtain regd user/online information.", "", __LINE__, __FILE__, $sql);
 }
 $onlinerow_reg = @DB()->sql_fetchrowset($result);
Example #16
0
function show_bt_userdata($user_id)
{
    global $lang, $template;
    $btu = get_bt_userdata($user_id);
    $template->assign_vars(array('SHOW_BT_USERDATA' => true, 'UP_TOTAL' => humn_size($btu['u_up_total']), 'UP_BONUS' => humn_size($btu['u_bonus_total']), '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'], 'SPEED_UP' => humn_size($btu['speed_up'], 0, 'KB') . '/s', 'SPEED_DOWN' => humn_size($btu['speed_down'], 0, 'KB') . '/s'));
}
Example #17
0
if ($seeding_count = count($seed)) {
    $template->assign_block_vars('seed', array());
    for ($i = 0; $i < $seeding_count; $i++) {
        $template->assign_block_vars('seed.seedrow', array('F_SEED_COUNT' => $seed[$i]['seed_count'], 'F_LEECH_COUNT' => $seed[$i]['leech_count'], 'F_SPEED_UP' => humn_size($seed[$i]['speed_up']) . '/s', 'FORUM_NAME' => $seed[$i]['forum_name'], 'TOPIC_TITLE' => $seed[$i]['topic_title'], 'U_VIEW_FORUM' => "viewforum.php?" . POST_FORUM_URL . '=' . $seed[$i]['forum_id'], 'U_VIEW_TOPIC' => "viewtopic.php?" . POST_TOPIC_URL . '=' . $seed[$i]['topic_id'] . '&amp;spmode=full#seeders'));
    }
} else {
    $template->assign_block_vars('switch_seeding_none', array());
}
//release output
if ($release_count = count($release)) {
    $template->assign_block_vars('release', array());
    for ($i = 0; $i < $release_count; $i++) {
        $template->assign_block_vars('release.releaserow', array('F_SEED_COUNT' => $release[$i]['seed_count'], 'F_LEECH_COUNT' => $release[$i]['leech_count'], 'F_SPEED_UP' => humn_size($release[$i]['speed_up']) . '/s', 'FORUM_NAME' => $release[$i]['forum_name'], 'TOPIC_TITLE' => $release[$i]['topic_title'], 'U_VIEW_FORUM' => "viewforum.php?" . POST_FORUM_URL . '=' . $release[$i]['forum_id'], 'U_VIEW_TOPIC' => "viewtopic.php?" . POST_TOPIC_URL . '=' . $release[$i]['topic_id'] . '&amp;spmode=full#seeders'));
    }
} else {
    $template->assign_block_vars('switch_release_none', array());
}
//leech output
if ($leeching_count = count($leech)) {
    $template->assign_block_vars('leech', array());
    for ($i = 0; $i < $leeching_count; $i++) {
        $template->assign_block_vars('leech.leechrow', array('F_SEED_COUNT' => $leech[$i]['seed_count'], 'F_LEECH_COUNT' => $leech[$i]['leech_count'], 'F_SPEED_DOWN' => humn_size($leech[$i]['speed_down']) . '/s', 'FORUM_NAME' => $leech[$i]['forum_name'], 'TOPIC_TITLE' => $leech[$i]['topic_title'], 'U_VIEW_FORUM' => "viewforum.php?" . POST_FORUM_URL . '=' . $leech[$i]['forum_id'], 'U_VIEW_TOPIC' => "viewtopic.php?" . POST_TOPIC_URL . '=' . $leech[$i]['topic_id'] . '&amp;spmode=full#leechers'));
    }
} else {
    $template->assign_block_vars('switch_leeching_none', array());
}
$template->assign_vars(array('USERNAME' => $username, 'L_NONE' => $lang['None'], 'L_FORUM' => $lang['Forum'], 'L_TOPICS' => $lang['Topics'], 'L_INFO' => $lang['Info'], 'L_SEEDING' => '<b>' . $lang['Seeding'] . '</b>' . ($seeding_count ? "<br />[ <b>{$seeding_count}</b> ]" : ''), 'L_LEECHING' => '<b>' . $lang['Leeching'] . '</b>' . ($leeching_count ? "<br />[ <b>{$leeching_count}</b> ]" : ''), 'L_RELEASING' => '<b>' . $lang['Releasing'] . '</b>' . ($release_count ? "<br />[ <b>{$release_count}</b> ]" : ''), 'L_VIEW_TOR_PROF' => sprintf($lang['Viewing_user_bt_profile'], $username), 'L_CUR_ACTIVE_DLS' => $lang['Cur_active_dls'], 'SEED_ROWSPAN' => $seeding_count ? 'rowspan="' . ($seeding_count + 1) . '"' : '', 'RELEASE_ROWSPAN' => $release_count ? 'rowspan="' . ($release_count + 1) . '"' : '', 'LEECH_ROWSPAN' => $leeching_count ? 'rowspan="' . ($leeching_count + 1) . '"' : ''));
$s_link_start = "search.php?search_id=dl&amp;dl_status=";
$s_link_end = "&amp;dl_uid={$profile_user_id}";
$template->assign_vars(array('L_SEARCH_DL' => $lang['Search_DL'], 'L_SEARCH_DL_WILL' => $lang['Search_DL_Will'], 'L_SEARCH_DL_DOWN' => $lang['Search_DL_Down'], 'L_SEARCH_DL_COMPLETE' => $lang['Search_DL_Complete'], 'L_SEARCH_DL_CANCEL' => $lang['Search_DL_Cancel'], 'U_SEARCH_DL_WILL' => $s_link_start . DL_STATUS_WILL . $s_link_end, 'U_SEARCH_DL_DOWN' => $s_link_start . DL_STATUS_DOWN . $s_link_end, 'U_SEARCH_DL_COMPLETE' => $s_link_start . DL_STATUS_COMPLETE . $s_link_end, 'U_SEARCH_DL_CANCEL' => $s_link_start . DL_STATUS_CANCEL . $s_link_end));
$template->assign_vars(array('U_TORRENT_PROFILE' => append_sid("profile.php?mode=viewprofile&amp;u=" . $profiledata['user_id']) . '#torrent', 'L_TORRENT_PROFILE' => $lang['View_torrent_profile'], 'U_SEARCH_RELEASES' => "tracker.php?pid={$profiledata['user_id']}"));
Example #18
0
                 $template->assign_block_vars("{$x_full}.iphead", array());
             }
             if ($port !== false) {
                 $template->assign_block_vars("{$x_full}.porthead", array());
             }
         }
         $compl_size = $peer['remain'] && $tor_size && $tor_size > $peer['remain'] ? $tor_size - $peer['remain'] : 0;
         $compl_perc = $compl_size ? floor($compl_size * 100 / $tor_size) : 0;
     }
     $rel_sign = !$guest && $peer['releaser'] ? '&nbsp;<b><sup>&reg;</sup></b>' : '';
     $name = profile_url($peer) . $rel_sign;
     $up_tot = $p_max_up ? humn_size($p_max_up) : '-';
     $down_tot = $p_max_down ? humn_size($p_max_down) : '-';
     $up_ratio = $p_max_down ? round($p_max_up / $p_max_down, 2) : '';
     $sp_up = $peer['speed_up'] ? humn_size($peer['speed_up'], 0, 'KB') . '/s' : '-';
     $sp_down = $peer['speed_down'] ? humn_size($peer['speed_down'], 0, 'KB') . '/s' : '-';
     $bgr_class = !($tr[$x] % 2) ? $bgr_class_1 : $bgr_class_2;
     $row_bgr = $change_peers_bgr_over ? " class=\"{$bgr_class}\" onmouseover=\"this.className='{$bgr_class_over}';\" onmouseout=\"this.className='{$bgr_class}';\"" : '';
     $tr[$x]++;
     $template->assign_block_vars("{$x_full}.{$x_row}", array('ROW_BGR' => $row_bgr, 'NAME' => $peer['update_time'] ? $name : "<s>{$name}</s>", 'COMPL_PRC' => $compl_perc, 'UP_TOTAL' => $max_up_id[$x] == $pid ? "<b>{$up_tot}</b>" : $up_tot, 'DOWN_TOTAL' => $max_down_id[$x] == $pid ? "<b>{$down_tot}</b>" : $down_tot, 'SPEED_UP' => $max_sp_up_id[$x] == $pid ? "<b>{$sp_up}</b>" : $sp_up, 'SPEED_DOWN' => $max_sp_down_id[$x] == $pid ? "<b>{$sp_down}</b>" : $sp_down, 'UP_TOTAL_RAW' => $peer['uploaded'], 'DOWN_TOTAL_RAW' => $peer['downloaded'], 'SPEED_UP_RAW' => $peer['speed_up'], 'SPEED_DOWN_RAW' => $peer['speed_down'], 'UPD_EXP_TIME' => $peer['update_time'] ? $lang['DL_UPD'] . bb_date($peer['update_time'], 'd-M-y H:i') . ' &middot; ' . delta_time($peer['update_time']) . $lang['TOR_BACK'] : $lang['DL_STOPPED'], 'TOR_RATIO' => $up_ratio ? $lang['USER_RATIO'] . "UL/DL: {$up_ratio}" : ''));
     if ($ip) {
         $template->assign_block_vars("{$x_full}.{$x_row}.ip", array('IP' => $ip));
     }
     if ($port !== false) {
         $template->assign_block_vars("{$x_full}.{$x_row}.port", array('PORT' => $port));
     }
 } else {
     if ($peer['seeder']) {
         $seeders .= '<nobr><a href="' . $u_prof_href . '" class="seedmed">' . $peer['username'] . '</a>,</nobr> ';
         $seed_count = $peer['username'];
     } else {
Example #19
0
 case 'u_down_total':
 case 'u_up_release':
 case 'u_up_bonus':
     if (!IS_ADMIN) {
         $this->ajax_die($lang['NOT_ADMIN']);
     }
     $table = BB_BT_USERS;
     $value = (double) str_replace(',', '.', $this->request['value']);
     foreach (array('KB' => 1, 'MB' => 2, 'GB' => 3, 'TB' => 4) as $s => $m) {
         if (strpos($this->request['value'], $s) !== false) {
             $value *= pow(1024, $m);
             break;
         }
     }
     $value = sprintf('%.0f', $value);
     $this->response['new_value'] = humn_size($value, null, null, ' ');
     if (!($btu = get_bt_userdata($user_id))) {
         require INC_DIR . 'functions_torrent.php';
         generate_passkey($user_id, true);
         $btu = get_bt_userdata($user_id);
     }
     $btu[$field] = $value;
     $this->response['update_ids']['u_ratio'] = (string) get_bt_ratio($btu);
     break;
 case 'user_points':
     $value = htmlCHR($value);
     $value = (double) str_replace(',', '.', $this->request['value']);
     $value = sprintf('%.2f', $value);
     $this->response['new_value'] = $value;
     break;
 default:
Example #20
0
            $seeds = $tor['seeders'];
            $leechs = $tor['leechers'];
            $s_last = $tor['seeder_last_seen'];
            $att_id = $tor['attach_id'];
            $size = $tor['size'];
            $tor_magnet = create_magnet($tor['info_hash'], $passkey['auth_key'], $userdata['session_logged_in']);
            $compl = $tor['complete_count'];
            $dl_sp = $dl ? humn_size($dl, 0, 'KB') . '/s' : '0 KB/s';
            $ul_sp = $ul ? humn_size($ul, 0, 'KB') . '/s' : '0 KB/s';
            $dl_class = isset($tor['dl_status']) ? $dl_link_css[$tor['dl_status']] : 'genmed';
            $row_class = !($row_num & 1) ? $row_class_1 : $row_class_2;
            $row_num++;
            $cat_id = !$hide_cat && isset($tor['cat_id']) ? $tor['cat_id'] : '';
            $forum_id = !$hide_forum && isset($tor['forum_id']) ? $tor['forum_id'] : '';
            $poster_id = !$hide_author && isset($tor['poster_id']) ? $tor['poster_id'] : '';
            $template->assign_block_vars('tor', array('CAT_ID' => $cat_id, 'CAT_TITLE' => $cat_id ? $cat_title_html[$cat_id] : '', 'FORUM_ID' => $forum_id, 'FORUM_NAME' => $forum_id ? $forum_name_html[$forum_id] : '', 'TOPIC_ID' => $tor['topic_id'], 'TOPIC_TITLE' => wbr($tor['topic_title']), 'TOPIC_TIME' => bb_date($tor['topic_time'], 'd-M-y') . ' <b>&middot;</b> ' . delta_time($tor['topic_time']), 'POST_ID' => $tor['post_id'], 'POSTER_ID' => $poster_id, 'USERNAME' => $hide_author ? '' : profile_url(array('username' => $tor['username'], 'user_rank' => $tor['user_rank'])), 'ROW_CLASS' => $row_class, 'ROW_NUM' => $row_num, 'DL_CLASS' => $dl_class, 'IS_NEW' => !IS_GUEST && $tor['reg_time'] > $lastvisit, 'USER_AUTHOR' => !IS_GUEST && $poster_id == $user_id, 'ATTACH_ID' => $att_id, 'MAGNET' => $tor_magnet, 'TOR_TYPE' => is_gold($tor['tor_type']), 'TOR_FROZEN' => !IS_AM ? isset($bb_cfg['tor_frozen'][$tor['tor_status']]) : '', 'TOR_STATUS_ICON' => $bb_cfg['tor_icons'][$tor['tor_status']], 'TOR_STATUS_TEXT' => $lang['TOR_STATUS_NAME'][$tor['tor_status']], 'TOR_SIZE_RAW' => $size, 'TOR_SIZE' => humn_size($size), 'UL_SPEED' => $ul_sp, 'DL_SPEED' => $dl_sp, 'SEEDS' => $seeds ? $seeds : 0, 'SEEDS_TITLE' => $seeds ? $lang['SEEDERS'] : $lang['SEED_NOT_SEEN'] . ":\n " . ($s_last ? bb_date($s_last, $date_format) : $lang['NEVER']), 'LEECHS' => $leechs ? $leechs : 0, 'COMPLETED' => $compl ? $compl : 0, 'REPLIES' => $tor['topic_replies'], 'VIEWS' => $tor['topic_views'], 'ADDED_RAW' => $tor['reg_time'], 'ADDED_TIME' => bb_date($tor['reg_time'], $time_format), 'ADDED_DATE' => bb_date($tor['reg_time'], $date_format, false)));
        }
    }
} else {
    $template->assign_vars(array('TOR_NOT_FOUND' => true, 'NO_MATCH_MSG' => $lang['BT_NO_SEARCHABLE_FORUMS']));
}
// Pagination
if ($tor_count) {
    $base_url = "{$tracker_url}?search_id={$search_id}";
    $search_matches = $tor_count == 1 ? sprintf($lang['FOUND_SEARCH_MATCH'], $tor_count) : sprintf($lang['FOUND_SEARCH_MATCHES'], $tor_count);
    $search_max = "(max: {$tor_search_limit})";
    generate_pagination($base_url, $tor_count, $per_page, $start);
    $template->assign_vars(array('MATCHES' => $search_matches, 'SERACH_MAX' => $search_max));
}
if (empty($cat_forum)) {
    bb_die($lang['BT_NO_SEARCHABLE_FORUMS']);
Example #21
0
function create_atom($file_path, $mode, $id, $title, $topics)
{
    global $bb_cfg;
    $dir = dirname($file_path);
    if (!file_exists($dir)) {
        if (!bb_mkdir($dir)) {
            return false;
        }
    }
    foreach ($topics as $topic) {
        $last_time = $topic['topic_last_post_time'];
        if ($topic['topic_last_post_edit_time']) {
            $last_time = $topic['topic_last_post_edit_time'];
        }
        $date = bb_date($last_time, 'Y-m-d', 0);
        $time = bb_date($last_time, 'H:i:s', 0);
        break;
    }
    $atom = "";
    $atom .= "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n";
    $atom .= "<feed xmlns=\"http://www.w3.org/2005/Atom\" xml:base=\"http://" . $bb_cfg['server_name'] . $bb_cfg['script_path'] . "\">\n";
    $atom .= "<title>{$title}</title>\n";
    $atom .= "<updated>" . $date . "T{$time}+00:00</updated>\n";
    $atom .= "<id>tag:rto.feed,2000:/{$mode}/{$id}</id>\n";
    $atom .= "<link href=\"http://" . $bb_cfg['server_name'] . $bb_cfg['script_path'] . "\" />\n";
    foreach ($topics as $topic) {
        $topic_id = $topic['topic_id'];
        $tor_size = '';
        if (isset($topic['tor_size'])) {
            $tor_size = str_replace('&nbsp;', ' ', ' [' . humn_size($topic['tor_size']) . ']');
        }
        $topic_title = $topic['topic_title'];
        $orig_word = array();
        $replacement_word = array();
        obtain_word_list($orig_word, $replacement_word);
        if (count($orig_word)) {
            $topic_title = preg_replace($orig_word, $replacement_word, $topic_title);
        }
        $topic_title = wbr($topic_title);
        $author_name = $topic['first_username'] ? wbr($topic['first_username']) : 'Гость';
        $last_time = $topic['topic_last_post_time'];
        if ($topic['topic_last_post_edit_time']) {
            $last_time = $topic['topic_last_post_edit_time'];
        }
        $date = bb_date($last_time, 'Y-m-d', 0);
        $time = bb_date($last_time, 'H:i:s', 0);
        $updated = '';
        $checktime = TIMENOW - 604800;
        // неделя (week)
        if ($topic['topic_first_post_edit_time'] && $topic['topic_first_post_edit_time'] > $checktime) {
            $updated = '[Обновлено] ';
        }
        $atom .= "<entry>\n";
        $atom .= "\t<title type=\"html\"><![CDATA[{$updated}{$topic_title}{$tor_size}]]></title>\n";
        $atom .= "\t<author>\n";
        $atom .= "\t\t<name>{$author_name}</name>\n";
        $atom .= "\t</author>\n";
        $atom .= "\t<updated>" . $date . "T{$time}+00:00</updated>\n";
        $atom .= "\t<id>tag:rto.feed," . $date . ":/t/{$topic_id}</id>\n";
        $atom .= "\t<link href=\"viewtopic.php?t={$topic_id}\" />\n";
        $atom .= "</entry>\n";
    }
    $atom .= "</feed>";
    @unlink($file_path);
    $fp = fopen($file_path, "w");
    fwrite($fp, $atom);
    fclose($fp);
    return true;
}
    // get the db sizes
    list($search_data_size, $search_index_size, $search_tables_size) = get_db_sizes();
    // calculate the final (estimated) values
    $final_search_tables_size = '';
    if ($search_tables_size) {
        $start_search_tables_size = $last_session_data['search_size'];
        $final_search_tables_size = $start_search_tables_size + round(($search_tables_size - $start_search_tables_size) * (100 / $session_percent));
    }
    // calculate various times
    $session_time = $last_session_data['session_time'];
    $session_average_cycle_time = round($session_time / $last_session_data['session_cycles']);
    $session_estimated_time = round($session_time * (100 / $session_percent)) - $session_time;
    // create the percent boxes
    create_percent_box('session', create_percent_color($session_percent), $session_percent);
    create_percent_box('total', create_percent_color($total_percent), $total_percent);
    $template->assign_vars(array('L_NEXT' => $next_button, 'L_TIME_LAST_POSTS_ADMIN' => sprintf($lang['TIME_LAST_POSTS'], $num_rows), 'PROCESSING_POSTS' => sprintf($lang['PROCESSED_POST_IDS'], $start_post_id, $end_post_id), 'PROCESSING_MESSAGES' => $processing_messages, 'PROGRESS_BAR_IMG' => $progress_bar_img, 'SESSION_DETAILS' => sprintf($lang['PROCESS_DETAILS'], $session_posts_processed - $num_rows + 1, $session_posts_processed, $session_posts_processing), 'SESSION_PERCENT' => sprintf($lang['PERCENT_COMPLETED'], round($session_percent, 2)), 'TOTAL_DETAILS' => sprintf($lang['PROCESS_DETAILS'], $total_posts_processed - $num_rows + 1, $total_posts_processed, $total_posts), 'TOTAL_PERCENT' => sprintf($lang['PERCENT_COMPLETED'], round($total_percent, 2)), 'LAST_CYCLE_TIME' => delta_time(TIMENOW), 'SESSION_TIME' => delta_time($last_session_data['start_time']), 'SESSION_AVERAGE_CYCLE_TIME' => delta_time($session_average_cycle_time, 0), 'SESSION_ESTIMATED_TIME' => delta_time($session_estimated_time, 0), 'SEARCH_TABLES_SIZE' => humn_size($search_tables_size), 'FINAL_SEARCH_TABLES_SIZE' => humn_size($final_search_tables_size), 'SEARCH_DATA_SIZE' => humn_size($search_data_size), 'SEARCH_INDEX_SIZE' => humn_size($search_index_size), 'START_POST' => $last_session_data['start_post_id'], 'POST_LIMIT' => $num_rows, 'TIME_LIMIT' => $time_limit, 'REFRESH_RATE' => $refresh_rate, 'S_REBUILD_SEARCH_ACTION' => $form_action));
} else {
    // create the page
    // used only with the select input
    $post_limit_hidden = $def_post_limit > $total_posts ? $total_posts : $def_post_limit;
    $s_hidden_fields = '<input type="hidden" name="post_limit_stored" value="' . $post_limit_hidden . '" />';
    $s_hidden_fields .= '<input type="hidden" name="total_posts_stored" value="' . $total_posts . '" />';
    $next_start_post_id = 0;
    $last_saved_processing = '';
    $clear_search_disabled = '';
    if ($last_session_data['rebuild_session_id']) {
        $last_saved_post_id = $last_session_data['end_post_id'];
        $next_start_post_id = $last_saved_post_id + 1;
        $last_saved_date = bb_date($last_session_data['end_time']);
        // check our last status
        if ($last_session_data['rebuild_session_status'] == REBUILD_SEARCH_PROCESSED) {
Example #23
0
 function init($cfg = array(), $post_params = array(), $uploaded_only = true)
 {
     global $bb_cfg, $lang;
     $this->cfg = array_merge($this->cfg, $cfg);
     $this->file = $post_params;
     // upload errors from $_FILES
     if ($this->file['error']) {
         $msg = $lang['UPLOAD_ERROR_COMMON'];
         $msg .= ($err_desc =& $lang['UPLOAD_ERRORS'][$this->file['error']]) ? " ({$err_desc})" : '';
         $this->errors[] = $msg;
         return false;
     }
     // file_exists
     if (!file_exists($this->file['tmp_name'])) {
         $this->errors[] = "Uploaded file not exists: {$this->file['tmp_name']}";
         return false;
     }
     // size
     if (!($this->file_size = filesize($this->file['tmp_name']))) {
         $this->errors[] = "Uploaded file is empty: {$this->file['tmp_name']}";
         return false;
     }
     if ($this->cfg['max_size'] && $this->file_size > $this->cfg['max_size']) {
         $this->errors[] = sprintf($lang['UPLOAD_ERROR_SIZE'], humn_size($this->cfg['max_size']));
         return false;
     }
     // is_uploaded_file
     if ($uploaded_only && !is_uploaded_file($this->file['tmp_name'])) {
         $this->errors[] = "Not uploaded file: {$this->file['tmp_name']}";
         return false;
     }
     // get ext
     $this->ext_ids = array_flip($bb_cfg['file_id_ext']);
     $file_name_ary = explode('.', $this->file['name']);
     $this->file_ext = strtolower(end($file_name_ary));
     // img
     if ($this->cfg['max_width'] || $this->cfg['max_height']) {
         if ($img_info = getimagesize($this->file['tmp_name'])) {
             list($width, $height, $type, $attr) = $img_info;
             // redefine ext
             if (!$width || !$height || !$type || !isset($this->img_types[$type])) {
                 $this->errors[] = $lang['UPLOAD_ERROR_FORMAT'];
                 return false;
             }
             $this->file_ext = $this->img_types[$type];
             // width & height
             if ($this->cfg['max_width'] && $width > $this->cfg['max_width'] || $this->cfg['max_height'] && $height > $this->cfg['max_height']) {
                 $this->errors[] = sprintf($lang['UPLOAD_ERROR_DIMENSIONS'], $this->cfg['max_width'], $this->cfg['max_height']);
                 return false;
             }
         } else {
             $this->errors[] = $lang['UPLOAD_ERROR_NOT_IMAGE'];
             return false;
         }
     }
     // check ext
     if ($uploaded_only && (!isset($this->ext_ids[$this->file_ext]) || !in_array($this->file_ext, $this->cfg['allowed_ext'], true))) {
         $this->errors[] = sprintf($lang['UPLOAD_ERROR_NOT_ALLOWED'], htmlCHR($this->file_ext));
         return false;
     }
     $this->file_ext_id = $this->ext_ids[$this->file_ext];
     return true;
 }
Example #24
0
}
function commify_ob($contents)
{
    return preg_replace_callback("#\\b\\d+\\b#", 'commify_callback', $contents);
}
ob_start('commify_ob');
echo '<html><body><head></head>';
echo '
<br /><br />
<table border="1" cellspacing="0" cellpadding="6" align="center">
<col width="40%">
<col width="60%">
';
echo "\n<tr><td align=center> users: bb-all / bt-all / bt-active </td><td align=center> {$stat['u_bb_all']} / {$stat['u_bt_all']} / <b>{$stat['u_bt_active']}</b> </td></tr>\n";
echo "\n\n\t<tr><td align=center> torrents:  all / active / with seeder </td>\n\t<td align=center>\n\t\t{$stat['tor_all']} / <b>{$stat['tor_active']}</b> / {$stat['tor_with_seeder']}\n\t\t&nbsp;\n\t\t[ " . humn_size($stat['torrents_size']) . " ]\n\t</td></tr>\n\n";
echo "\n\n\t<tr><td align=center> peers: all ({$stat['max_peer_time']} s) / in ann interval ({$announce_interval} s) </td>\n\t<td align=center>\n\t\t{$stat['p_all']} / <b>{$stat['p_within_ann']}</b>\n\t\t&nbsp;\n\t\t[ up:   " . humn_size($stat['speed_up']) . "/s,\n\t\t  down: " . humn_size($stat['speed_down']) . "/s ]\n\t</td></tr>\n\n";
echo "\n<tr><td align=center> peers: in last " . join(' / ', $peers_in_last_minutes) . " min</td>\n";
echo "\n<td align=center>" . join(' / ', $peers_in_last_min) . "</td></tr>\n";
echo "\n<tr><td align=center> peers in last {$peers_in_last_sec_limit} sec <br /> [ per second, DESC order --> ] <br /> last peer: {$stat['last_peer_time']} seconds ago <br /> " . date("j M H:i:s [T O]") . " </td>\n";
echo '<td align=center style="font-size: 13px; font-family: \'Courier New\',Courier,monospace;"><pre> ' . join(' ', $peers_in_last_sec) . "</pre></td></tr>\n";
echo '</table>';
echo '<div align="center"><pre>';
if ($l = sys('la')) {
    $l = explode(' ', $l);
    for ($i = 0; $i < 3; $i++) {
        $l[$i] = round($l[$i], 1);
    }
    echo "\n\n<b>loadavg: </b>{$l['0']} {$l['1']} {$l['2']}\n\n";
}
echo 'gen time: <b>' . sprintf('%.3f', array_sum(explode(' ', microtime())) - TIMESTART) . "</b> sec\n";
echo '</pre></div>';
Example #25
0
    $gen_time = utime() - TIMESTART;
    $gen_time_txt = sprintf('%.3f', $gen_time);
    $gzip_text = UA_GZIP_SUPPORTED ? 'GZIP ' : '<s>GZIP</s> ';
    $gzip_text .= $ft_cfg['gzip_compress'] ? 'Yes' : 'No';
    $stat = '[&nbsp; ' . $lang['EXECUTION_TIME'] . " {$gen_time_txt} " . $lang['SEC'];
    if (!empty($DBS)) {
        $sql_t = $DBS->sql_timetotal;
        $sql_time_txt = $sql_t ? sprintf('%.3f ' . $lang['SEC'] . ' (%d%%) &middot; ', $sql_t, round($sql_t * 100 / $gen_time)) : '';
        $num_q = $DBS->num_queries;
        $stat .= " &nbsp;|&nbsp; MySQL: {$sql_time_txt}{$num_q} " . $lang['QUERIES'];
    }
    $stat .= " &nbsp;|&nbsp; {$gzip_text}";
    $stat .= ' &nbsp;|&nbsp; ' . $lang['MEMORY'];
    $stat .= humn_size($ft_cfg['mem_on_start'], 2) . ' / ';
    $stat .= humn_size(sys('mem_peak'), 2) . ' / ';
    $stat .= humn_size(sys('mem'), 2);
    if ($l = sys('la')) {
        $l = explode(' ', $l);
        for ($i = 0; $i < 3; $i++) {
            $l[$i] = round($l[$i], 1);
        }
        $stat .= " &nbsp;|&nbsp; " . $lang['LIMIT'] . " {$l['0']} {$l['1']} {$l['2']}";
    }
    $stat .= ' &nbsp;]';
    $stat .= !empty($_COOKIE['sql_log']) ? '[ <a href="#" class="med" onclick="$p(\'sqlLog\').className=\'sqlLog sqlLogWrapped\'; return false;">wrap</a> &middot; <a href="#sqlLog" class="med" onclick="$(\'#sqlLog\').css({ height: $(window).height()-50 }); return false;">max</a> ]' : '';
    echo '<div style="margin: 6px; font-size:10px; color: #444444; letter-spacing: -1px; text-align: center;">' . $stat . '</div>';
}
echo '
	</div><!--/body_container-->
';
echo '
Example #26
0
    $id = (int) $_POST['bonus_id'];
    $btu = get_bt_userdata($user_id);
    if (empty($btu)) {
        require INC_DIR . 'functions_torrent.php';
        generate_passkey($user_id, true);
        $btu = get_bt_userdata($user_id);
    }
    $upload = $upload_row[$id] * 1024 * 1024 * 1024;
    $points = $price_row[$id];
    if ($userdata['user_points'] < $points) {
        meta_refresh('index.php', 5);
        $message = $lang['BONUS_NOT_SUCCES'] . '<br /><br /><a href="' . BONUS_URL . '">' . $lang['BONUS_RETURN'] . '</a><br /><br /><a href="' . PROFILE_URL . $userdata['user_id'] . '">' . $lang['RETURN_PROFILE'] . '</a><br /><br />' . sprintf($lang['CLICK_RETURN_INDEX'], '<a href="index.php">', '</a>');
        bb_die($message);
    }
    DB()->query("UPDATE " . BB_BT_USERS . " bu, " . BB_USERS . " u\n\t\tSET\n\t\t\tbu.u_up_total   = u_up_total    + {$upload},\n\t\t\tu.user_points   = u.user_points - {$points}\n\t\tWHERE\n\t\t\tbu.user_id      = {$user_id}\n\t\t\tAND u.user_id   = bu.user_id\n\t");
    cache_rm_user_sessions($user_id);
    meta_refresh(BONUS_URL, 5);
    $message = sprintf($lang['BONUS_SUCCES'], humn_size($upload_row[$id] * 1024 * 1024 * 1024));
    $message .= '<br /><br /><a href="' . BONUS_URL . '">' . $lang['BONUS_RETURN'] . '</a><br /><br /><a href="' . PROFILE_URL . $userdata['user_id'] . '">' . $lang['RETURN_PROFILE'] . '</a><br /><br />' . sprintf($lang['CLICK_RETURN_INDEX'], '<a href="index.php">', '</a>');
    bb_die($message);
} else {
    $template->assign_vars(array('U_USER_PROFILE' => PROFILE_URL . $user_id, 'S_MODE_ACTION' => 'profile.php?mode=bonus', 'PAGE_TITLE' => $lang['EXCHANGE_BONUS'], 'MY_BONUS' => sprintf($lang['MY_BONUS'], $user_points)));
    foreach ($price_row as $i => $price) {
        if (!$price || !$upload_row[$i]) {
            continue;
        }
        $class = $user_points >= $price ? 'seed' : 'leech';
        $template->assign_block_vars('bonus_upload', array('ROW_CLASS' => !($i % 2) ? 'row2' : 'row1', 'ID' => $i, 'DESC' => sprintf($lang['BONUS_UPLOAD_DESC'], humn_size($upload_row[$i] * 1024 * 1024 * 1024)), 'PRICE' => sprintf($lang['BONUS_UPLOAD_PRICE'], $class, sprintf('%.2f', $price))));
    }
    print_page('usercp_bonus.tpl');
}
Example #27
0
//
$sql = " SELECT COUNT(DISTINCT tr.torrent_id) AS active_torrents\r\n                FROM " . BT_TRACKER_TABLE . " tr\r\n                LEFT JOIN " . BT_TORRENTS_TABLE . " tor ON tr.torrent_id = tor.torrent_id\r\n                WHERE tr.expire_time > {$cur_time}";
if ($row = DB()->sql_fetchrow(DB()->sql_query($sql))) {
    $torrents_act = $row['active_torrents'] ? $row['active_torrents'] : 0;
}
//
// torrents active END
//
//
// up, down, total traf
//
$sql = " SELECT SUM(u_up_total) AS up, SUM(u_down_total) AS down\r\n               FROM " . BT_USERS_TABLE;
if ($row = DB()->sql_fetchrow(DB()->sql_query($sql))) {
    $up = humn_size($row['up']);
    $down = humn_size($row['down']);
    $total = humn_size($row['up'] + $row['down']);
}
//
// up, down, total traf
//
//
// peer info end
//
//
// assign vars
//
$template->assign_vars(array('P_PEER' => $peers, 'P_SEED' => $seeds, 'P_LEECH' => $leechs, 'T_TORRENTS' => $torrents, 'T_TORRENTS_SIZE' => $torrents_size, 'T_ACT_TORRENTS' => $torrents_act, 'TR_UP' => $up, 'TR_DOWN' => $down, 'TR_TRANSFER' => $total, 'L_PEER' => $lang['L_PEER'], 'L_SEED' => $lang['L_SEED'], 'L_LEECH' => $lang['L_LEECH'], 'L_TORRENTS' => $lang['L_TORRENTS'], 'L_TORRENTS_SIZE' => $lang['L_TORRENTS_SIZE'], 'L_ACT_TORRENTS' => $lang['L_ACT_TORRENTS'], 'L_UP' => $lang['L_UP'], 'L_DOWN' => $lang['L_DOWN'], 'L_TRANSFER' => $lang['L_TRANSFER'], 'L_STATS' => $lang['L_STATS']));
//
// assign vars END
//
//
Example #28
0
    while ($attachrow = DB()->sql_fetchrow($result)) {
        if (isset($attachments['_' . $attachrow['attach_id']])) {
            if ($attachrow['comment'] != $attachments['_' . $attachrow['attach_id']]['comment'] || $attachrow['download_count'] != $attachments['_' . $attachrow['attach_id']]['download_count']) {
                $sql = "UPDATE " . BB_ATTACHMENTS_DESC . "\n\t\t\t\t\tSET comment = '" . attach_mod_sql_escape($attachments['_' . $attachrow['attach_id']]['comment']) . "', download_count = " . (int) $attachments['_' . $attachrow['attach_id']]['download_count'] . "\n\t\t\t\t\tWHERE attach_id = " . (int) $attachrow['attach_id'];
                if (!DB()->sql_query($sql)) {
                    bb_die('Could not update attachments informations');
                }
            }
        }
    }
    DB()->sql_freeresult($result);
}
// Statistics
if ($view == 'stats') {
    $upload_dir_size = get_formatted_dirsize();
    $attachment_quota = humn_size($attach_config['attachment_quota']);
    // number_of_attachments
    $row = DB()->fetch_row("\n\t\tSELECT COUNT(*) AS total FROM " . BB_ATTACHMENTS_DESC . "\n\t");
    $number_of_attachments = $number_of_posts = $row['total'];
    $number_of_pms = 0;
    // number_of_topics
    $row = DB()->fetch_row("\n\t\tSELECT COUNT(*) AS topics FROM " . BB_TOPICS . " WHERE topic_attachment = 1\n\t");
    $number_of_topics = $row['topics'];
    // number_of_users
    $row = DB()->fetch_row("\n\t\tSELECT COUNT(DISTINCT user_id_1) AS users FROM " . BB_ATTACHMENTS . " WHERE post_id != 0\n\t");
    $number_of_users = $row['users'];
    $template->assign_vars(array('TPL_ATTACH_STATISTICS' => true, 'TOTAL_FILESIZE' => $upload_dir_size, 'ATTACH_QUOTA' => $attachment_quota, 'NUMBER_OF_ATTACHMENTS' => $number_of_attachments, 'NUMBER_OF_POSTS' => $number_of_posts, 'NUMBER_OF_PMS' => $number_of_pms, 'NUMBER_OF_TOPICS' => $number_of_topics, 'NUMBER_OF_USERS' => $number_of_users));
}
// Search
if ($view == 'search') {
    // Get Forums and Categories