Пример #1
0
 public static function init()
 {
     self::$utf8validator = (bool) extension_loaded('utf8validator');
     mb_internal_encoding('UTF-8');
     mb_language('uni');
     mb_regex_encoding('UTF-8');
     mb_detect_order(array('UTF-8', 'ISO-8859-1'));
     mb_substitute_character(0xfffd);
     MCached::connect();
     $trans = MCached::get(self::TRANSKEY);
     if ($trans === MCached::NO_RESULT) {
         $win = "€" . implode('', range("‚", "Œ")) . "Ž" . implode('', range("‘", "œ")) . implode('', range("ž", "ÿ"));
         $win_iso = "�����";
         $iso = implode('', range("€", "ÿ"));
         $winlen = strlen($win);
         $winisolen = strlen($win_iso);
         $isolen = strlen($iso);
         $trans = array('iso_to_utf8' => array(), 'win_to_utf8' => array(), 'from_utf8' => array());
         for ($i = 0; $i < $isolen; $i++) {
             $utf8 = mb_convert_encoding($iso[$i], 'UTF-8', 'ISO-8859-1');
             $trans['iso_to_utf8'][$iso[$i]] = $utf8;
             $trans['from_utf8'][$utf8] = $iso[$i];
         }
         for ($i = 0; $i < $winlen; $i++) {
             $utf8 = mb_convert_encoding($win[$i], 'UTF-8', 'Windows-1252');
             $trans['win_to_utf8'][$win[$i]] = $utf8;
             $trans['from_utf8'][$utf8] = $win[$i];
         }
         for ($i = 0; $i < $winisolen; $i++) {
             $utf8 = mb_convert_encoding($win_iso[$i], 'UTF-8', 'ISO-8859-1');
             $trans['win_to_utf8'][$win_iso[$i]] = $utf8;
         }
         MCached::add(self::TRANSKEY, $trans, 86400);
     }
     self::$trans_table = $trans;
 }
        $leechers = 0 + (int) $row["leechs"];
    } else {
        $seeds = 0;
        $leechers = 0;
    }
    if ($leechers > 0) {
        $percent = number_format($seeds / $leechers * 100, 0);
    } else {
        $percent = number_format($seeds * 100, 0);
    }
    $peers = $seeds + $leechers;
    $row = MCached::get('main::tracker::toolbar::total::traffic');
    if ($row === MCached::NO_RESULT) {
        $res = $db->query("SELECT SUM(downloaded) AS dled, SUM(uploaded) AS upld FROM users");
        $row = $res->fetch_array(MYSQLI_BOTH);
        MCached::add('main::tracker::toolbar::total::traffic', $row, 300);
    }
    $dled = 0 + (double) $row["dled"];
    $upld = 0 + (double) $row["upld"];
    $traffic = misc::makesize($dled + $upld);
    ?>
    <table class='lista' cellpadding='2' cellspacing='0' width='100%'>
    <tr>
    <td class='lista' align='center'><?php 
    echo BLOCK_INFO;
    ?>
:</td>
    <td class='lista' align='center'><?php 
    echo MEMBERS;
    ?>
:</td><td align='right'><?php 
Пример #3
0
function runSpeed($info_hash, $delta)
{
    global $db;
    MCached::connect();
    // stick in our latest data before we calc it out
    quickQuery("INSERT IGNORE INTO timestamps (info_hash, bytes, delta, sequence) SELECT '" . $info_hash . "' AS info_hash, dlbytes, UNIX_TIMESTAMP() - lastSpeedCycle, NULL FROM summary WHERE info_hash = '" . $info_hash . "'");
    $key = 'ann::bytes::timestamps::' . $info_hash;
    $data = MCached::get($key);
    if ($data === MCached::NO_RESULT) {
        $results = $db->query('SELECT (MAX(bytes) - MIN(bytes)) / SUM(delta), COUNT(*), MIN(sequence) FROM timestamps WHERE info_hash = "' . $info_hash . '"');
        $data = $results->fetch_row();
        MCached::add($key, $data, 300);
    }
    summaryAdd("speed", $data[0], true);
    summaryAdd("lastSpeedCycle", "UNIX_TIMESTAMP()", true);
    // if we have more than 20 drop the rest
    if ($data[1] == 21) {
        quickQuery("DELETE FROM timestamps WHERE info_hash='" . $info_hash . "' AND sequence = " . $data['2']);
        MCached::del($key);
    } elseif ($data[1] > 21) {
        quickQuery('DELETE FROM timestamps WHERE info_hash = "' . $info_hash . '" ORDER BY sequence LIMIT ' . ($data['1'] - 20));
        MCached::del($key);
    }
}
Пример #4
0
function insert_compose_frame($id, $newtopic = true, $quote = false)
{
    global $maxsubjectlength, $db;
    MCached::connect();
    if ($newtopic) {
        $arr = MCached::get('forums::name::' . $id);
        if ($arr === MCached::NO_RESULT) {
            $res = $db->query("SELECT name FROM forums WHERE id = " . $id) or sqlerr(__FILE__, __LINE__);
            $arr = $res->fetch_assoc() or die(BAD_FORUM_ID);
            MCached::add('forums::name::' . $id, $arr, 9600);
        }
        $forumname = security::html_safe(unesc($arr["name"]));
        block_begin(WORD_NEW . " " . TOPIC . " " . IN . " <a href='?action=viewforum&forumid=" . $id . "'>" . $forumname . "</a> " . FORUM);
    } else {
        $arr = MCached::get('quick::jump::topics::' . $id);
        if ($arr === MCached::NO_RESULT) {
            $res = $db->query("SELECT * FROM topics WHERE id = " . $id) or sqlerr(__FILE__, __LINE__);
            $arr = $res->fetch_assoc() or stderr(ERROR, FORUM_ERROR . TOPIC_NOT_FOUND);
            MCached::add('quick::jump::topics::' . $id, $arr, 9600);
        }
        $subject = security::html_safe(unesc($arr["subject"]));
        block_begin(REPLY . " " . TOPIC . ": <a href='?action=viewtopic&topicid=" . $id . "'>" . $subject . "</a>");
    }
    begin_frame();
    print "<form method='post' name='compose' action='?action=post'>\n";
    if ($newtopic) {
        print "<input type='hidden' name='forumid' value='" . $id . "'>\n";
    } else {
        print "<input type='hidden' name='topicid' value='" . $id . "'>\n";
    }
    begin_table();
    if ($newtopic) {
        print "<tr><td class='header'>" . SUBJECT . "</td>" . "<td class='lista' align='left' style='padding: 0px'><input type='text' size='50' maxlength='" . $maxsubjectlength . "' name='subject' " . "style='border: 0px; height: 19px'></td></tr>\n";
    }
    if ($quote) {
        $postid = 0 + (int) $_GET["postid"];
        if (!is_valid_id($postid)) {
            die;
        }
        $res = $db->query("SELECT posts.*, users.username FROM posts INNER JOIN users ON posts.userid = users.id WHERE posts.id = " . $postid) or sqlerr(__FILE__, __LINE__);
        if ($res->num_rows != 1) {
            stderr(ERROR, ERR_NO_POST_WITH_ID . "" . $postid);
        }
        $arr = $res->fetch_assoc();
    }
    print "<tr><td class='header'>" . BODY . "</td><td class='lista' align='left' style='padding: 0px'>";
    textbbcode("compose", "body", $quote ? "[quote=" . security::html_safe($arr["username"]) . "]" . security::html_safe(unesc($arr["body"])) . "[/quote]" : "");
    print "<tr><td colspan='2' align='center'><input type='submit' class='btn' value='" . FRM_CONFIRM . "'></td></tr>\n";
    print "</td></tr>";
    end_table();
    print "</form>\n";
    end_frame();
    //------ Get 10 last posts if this is a reply
    if (!$newtopic) {
        $postres = $db->query("SELECT * FROM posts WHERE topicid = " . $id . " ORDER BY id DESC LIMIT 10") or sqlerr(__FILE__, __LINE__);
        begin_frame(LAST_10_POSTS, true);
        while ($post = $postres->fetch_assoc()) {
            //-- Get poster details
            $userres = $db->query("SELECT * FROM users WHERE id = " . (int) $post["userid"] . " LIMIT 1") or sqlerr(__FILE__, __LINE__);
            $user = $userres->fetch_assoc();
            $avatar = $user["avatar"] && $user["avatar"] != "" ? security::html_safe($user["avatar"]) : "";
            begin_table(true);
            print "<tr valign='top'><td width='150' align='center' style='padding: 0px'>#" . (int) $post["id"] . " by " . security::html_safe($user["username"]) . "<br />" . get_date_time($post["added"]) . ($avatar != "" ? "<br /><img width='80' src='" . $avatar . "'>" : "") . "</td><td class='lista'>" . format_comment(unesc($post["body"])) . "</td></tr><br>\n";
            end_table();
        }
        end_frame();
    }
    if (!isset($forumid)) {
        $forumid = 0;
    }
    insert_quick_jump_menu($forumid);
    block_end();
}
Пример #5
0
                }
            }
        }
    }
    $ratio = number_format($sr, 2) . "&nbsp;&nbsp;<img src='" . $s . "'>";
} else {
    $ratio = "&infin;";
}
print "<tr>\n<td class='header'>" . RATIO . "</td>\n<td class='lista' colspan='2'>" . $ratio . "</td></tr>\n";
// Only show if forum is internal
if ($GLOBALS["FORUMLINK"] == '' || $GLOBALS["FORUMLINK"] == 'internal') {
    $posts = MCached::get('user::forum::posts::' . $id);
    if ($posts === MCached::NO_RESULT) {
        $sql = $db->query("SELECT * FROM posts INNER JOIN users ON posts.userid = users.id WHERE users.id = " . $id);
        $posts = $sql->num_rows;
        MCached::add('user::forum::posts::' . $id, $posts, 43200);
    }
    $memberdays = max(1, round((vars::$timestamp - $row['joined']) / 86400));
    $posts_per_day = number_format(round($posts / $memberdays, 2), 2);
    print "<tr>\n<td class='header'>" . FORUM . " " . POSTS . "</td>\n<td class='lista' colspan='2'>" . $posts . " &nbsp; [" . sprintf(POSTS_PER_DAY, $posts_per_day) . "]</td></tr>\n";
}
print "</table>";
#Uploaded Torrents
block_begin(UPLOADED . " " . MNU_TORRENT);
$resuploaded = $db->query("SELECT namemap.info_hash FROM namemap INNER JOIN summary ON namemap.info_hash = summary.info_hash WHERE uploader = " . $id . " AND namemap.anonymous = 'false' ORDER BY data DESC");
$numtorrent = $resuploaded->num_rows;
if ($numtorrent > 0) {
    list($pagertop, $limit) = misc::pager($utorrents == 0 ? 15 : $utorrents, $numtorrent, security::esc_url($_SERVER["PHP_SELF"]) . "?id=" . $id . "&");
    print $pagertop;
    $resuploaded = $db->query("SELECT namemap.info_hash, namemap.filename, UNIX_TIMESTAMP(namemap.data) AS added, namemap.size, summary.seeds, summary.leechers, summary.finished FROM namemap INNER JOIN summary ON namemap.info_hash = summary.info_hash WHERE uploader = " . $id . " AND namemap.anonymous = 'false' ORDER BY data DESC " . $limit);
}
Пример #6
0
         }
     } else {
         redirect("usercp.php?uid=" . $uid);
     }
 } else {
     block_begin(WELCOME_UCP);
     print "<center><br />" . UCP_NOTE_1 . "<br />" . UCP_NOTE_2 . "<br /><br />\n";
     print "</center>";
     block_end();
     block_begin(CURRENT_DETAILS);
     $id = user::$current['uid'];
     $row = MCached::get('user::cp::' . $id);
     if ($row === MCached::NO_RESULT) {
         $res = $db->query("SELECT users.lip, users.username, users.downloaded, users.uploaded, UNIX_TIMESTAMP(users.joined) AS joined, users.flag, countries.name, countries.flagpic FROM users LEFT JOIN countries ON users.flag = countries.id WHERE users.id = " . $id);
         $row = $res->fetch_array(MYSQLI_BOTH);
         MCached::add('user::cp::' . $id, $row, 1800);
     }
     print "<table class='lista' width='100%'>\n";
     print "<tr>\n<td class='header'>" . USER_NAME . "</td>\n<td class='lista'>" . unesc(user::$current["username"]) . "</td>\n";
     if (user::$current["avatar"] && user::$current["avatar"] != "") {
         print "<td class='lista' align='center' valign='middle' rowspan='4'><img border='0' width='138' src='" . security::html_safe(user::$current["avatar"]) . "' /></td>";
     }
     print "</tr>";
     if (user::$current["edit_users"] == "yes" || user::$current["admin_access"] == "yes") {
         print "<tr>\n<td class='header'>" . EMAIL . "</td>\n<td class='lista'>" . unesc(user::$current["email"]) . "</td></tr>\n";
         print "<tr>\n<td class='header'>" . LAST_IP . "</td>\n<td class='lista'>" . long2ip($row["lip"]) . "</td></tr>\n";
         print "<tr>\n<td class='header'>" . USER_LEVEL . "</td>\n<td class='lista'>" . unesc(user::$current["level"]) . "</td></tr>\n";
         $colspan = " colspan='2'";
     } else {
         print "<tr>\n<td class='header'>" . USER_LEVEL . "</td>\n<td class='lista'>" . unesc(user::$current["level"]) . "</td></tr>\n";
         $colspan = '';
Пример #7
0
     $leechers = 0 + (int) $row["leechs"];
 } else {
     $seeds = 0;
     $leechers = 0;
 }
 if ($leechers > 0) {
     $percent = number_format($seeds / $leechers * 100, 0);
 } else {
     $percent = number_format($seeds * 100, 0);
 }
 $peers = $seeds + $leechers;
 $row = MCached::get('tracker::info::total::traffic');
 if ($row === MCached::NO_RESULT) {
     $res = $db->query("SELECT SUM(downloaded) AS dled, SUM(uploaded) AS upld FROM users");
     $row = $res->fetch_array(MYSQLI_BOTH);
     MCached::add('tracker::info::total::traffic', $row, 300);
 }
 $dled = 0 + (int) $row["dled"];
 $upld = 0 + (int) $row["upld"];
 $traffic = misc::makesize($dled + $upld);
 print "<tr><td class='blocklist' align='center'>\n";
 print "<table width='100%' cellspacing='2' cellpading='2'>\n";
 print "<tr>\n<td colspan='2' align='center'><u>" . unesc($SITENAME) . "</u></td></tr>\n";
 print "<tr><td align='left'>" . MEMBERS . ":</td><td align='right'>" . $users . "</td></tr>\n";
 print "<tr><td align='left'>" . TORRENTS . ":</td><td align='right'>" . $torrents . "</td></tr>\n";
 print "<tr><td align='left'>" . SEEDERS . ":</td><td align='right'>" . $seeds . "</td></tr>\n";
 print "<tr><td align='left'>" . LEECHERS . ":</td><td align='right'>" . $leechers . "</td></tr>\n";
 print "<tr><td align='left'>" . PEERS . ":</td><td align='right'>" . $peers . "</td></tr>\n";
 print "<tr><td align='left'>" . SEEDERS . "/" . LEECHERS . ":</td><td align='right'>" . $percent . "%</td></tr>\n";
 print "<tr><td align='left'>" . TRAFFIC . ":</td><td align='right'>" . $traffic . "</td></tr>\n";
 print "</table>\n</td></tr>";
Пример #8
0
}
?>
</tr>
<?php 
if ($count) {
    if (!isset($values[$i % 2])) {
        $writeout = '';
    } else {
        $writeout = $values[$i % 2];
    }
    while ($data = $results->fetch_array(MYSQLI_BOTH)) {
        $commentdata = MCached::get('torrent::comments::count::' . $data['hash']);
        if ($commentdata === MCached::NO_RESULT) {
            $commentres = $db->query("SELECT COUNT(*) AS comments FROM comments WHERE info_hash = '" . $db->real_escape_string($data['hash']) . "'");
            $commentdata = $commentres->fetch_assoc();
            MCached::add('torrent::comments::count::' . $data['hash'], $commentdata, 14400);
        }
        echo "<tr>\n";
        echo "\t<td align='center' class='lista'><a href='torrents.php?category=" . (int) $data['catid'] . "'>" . image_or_link($data["image"] == "" ? "" : "images/categories/" . $data["image"], "", security::html_safe($data["cname"])) . "</td>";
        echo "\t<td align='left' class='lista'><a href='details.php?id=" . $data["hash"] . "' title='" . VIEW_DETAILS . ": " . security::html_safe($data["filename"]) . "'>" . security::html_safe($data["filename"]) . "</a>" . ($data["external"] == "no" ? "" : " (<span style='color:red'>EXT</span>)") . "</td>";
        if ($commentdata) {
            if ($commentdata["comments"] > 0) {
                echo "\t<td align='center' class='lista'><a href='details.php?id=" . $data["hash"] . "#comments' title='Comments for: " . security::html_safe($data["filename"]) . "'>" . (int) $commentdata["comments"] . "</a></td>";
            } else {
                echo "\t<td align='center' class='lista'>---</td>";
            }
        } else {
            echo "\t<td align='center' class='lista'>---</td>";
        }
        // Rating
        /* Uncomment to show rating on torrents page...
Пример #9
0
function print_users()
{
    global $db, $STYLEPATH, $CURRENTPATH;
    if (!isset($_GET["searchtext"])) {
        $_GET["searchtext"] = "";
    }
    if (!isset($_GET["level"])) {
        $_GET["level"] = "";
    }
    $search = security::html_safe($_GET["searchtext"]);
    $addparams = '';
    if ($search != "") {
        $where = " AND users.username LIKE '%" . security::html_safe($db->real_escape_string($_GET["searchtext"])) . "%'";
        $addparams = "searchtext=" . $search;
    } else {
        $where = "";
    }
    $level = intval(0 + $_GET["level"]);
    if ($level > 0) {
        $where .= " AND users.id_level = " . $level;
        if ($addparams != "") {
            $addparams .= "&level=" . $level;
        } else {
            $addparams = "level=" . $level;
        }
    }
    $order_param = 3;
    // getting order
    if (isset($_GET["order"])) {
        $order_param = (int) $_GET["order"];
        switch ($order_param) {
            case 1:
                $order = "username";
                break;
            case 2:
                $order = "level";
                break;
            case 3:
                $order = "joined";
                break;
            case 4:
                $order = "lastconnect";
                break;
            case 5:
                $order = "flag";
                break;
            case 6:
                $order = "ratio";
                break;
            default:
                $order = "joined";
        }
    } else {
        $order = "joined";
    }
    if (isset($_GET["by"])) {
        $by_param = (int) $_GET["by"];
        $by = $by_param == 1 ? "ASC" : "DESC";
    } else {
        $by = "ASC";
    }
    if ($addparams != "") {
        $addparams .= "&";
    }
    $scriptname = security::html_safe($_SERVER["PHP_SELF"]);
    $count = MCached::get('users::page::total::members::count');
    if ($count === MCached::NO_RESULT) {
        $res = $db->query("SELECT COUNT(*) FROM users INNER JOIN users_level ON users.id_level = users_level.id WHERE users.id > 1 " . $where);
        $row = $res->fetch_row();
        $count = (int) $row[0];
        MCached::add('users::page::total::members::count', $count, 300);
    }
    list($pagertop, $limit) = misc::pager(20, $count, "users.php?" . $addparams . "order=" . $order_param . "&by=" . $by_param . "&");
    if ($by == "ASC") {
        $mark = "&nbsp;&#8593";
    } else {
        $mark = "&nbsp;&#8595";
    }
    ?>
        <div align='center'>
        <form action='users.php' name='ricerca' method='get'>
           <table border='0' class='lista'>
           <tr>
           <td class='block'><?php 
    echo FIND_USER;
    ?>
</td>
           <td class='block'><?php 
    echo USER_LEVEL;
    ?>
</td>
           <td class='block'>&nbsp;</td>
           </tr>
           <tr>
           <td><input type='text' name='searchtext' size='30' maxlength='50' value='<?php 
    echo $search;
    ?>
' /></td>
    <?php 
    print "<td><select name='level'>";
    print "<option value='0'" . ($level == 0 ? " selected='selected' " : "") . ">" . ALL . "</option>";
    $res = $db->query("SELECT id, level FROM users_level WHERE id_level > 1 ORDER BY id_level");
    while ($row = $res->fetch_array(MYSQLI_BOTH)) {
        $select = "<option value='" . (int) $row["id"] . "'";
        if ($level == $row["id"]) {
            $select .= "selected='selected'";
        }
        $select .= ">" . security::html_safe($row["level"]) . "</option>\n";
        print $select;
    }
    print "</select></td>";
    ?>
        </td>
        <td><input type='submit' value='<?php 
    echo SEARCH;
    ?>
' /></td>
        </tr>
    </table>
    </form>
    <?php 
    print $pagertop;
    ?>
    <table class='lista' width='95%'>
        <tr>
        <td class='header' align='center'>
	<?php 
    echo "<a href='" . $scriptname . "?" . $addparams . "" . "order=1&by=" . ($order == "username" && $by == "ASC" ? "2" : "1") . "'>" . USER_NAME . "</a>" . ($order == "username" ? $mark : "");
    ?>
	    </td>
        <td class='header' align='center'>
	<?php 
    echo "<a href='" . $scriptname . "?" . $addparams . "" . "order=2&by=" . ($order == "level" && $by == "ASC" ? "2" : "1") . "'>" . USER_LEVEL . "</a>" . ($order == "level" ? $mark : "");
    ?>
	    </td>
        <td class='header' align='center'>
	<?php 
    echo "<a href='" . $scriptname . "?" . $addparams . "" . "order=3&by=" . ($order == "joined" && $by == "ASC" ? "2" : "1") . "'>" . USER_JOINED . "</a>" . ($order == "joined" ? $mark : "");
    ?>
	    </td>
        <td class='header' align='center'>
	<?php 
    echo "<a href='" . $scriptname . "?" . $addparams . "" . "order=4&by=" . ($order == "lastconnect" && $by == "ASC" ? "2" : "1") . "'>" . USER_LASTACCESS . "</a>" . ($order == "lastconnect" ? $mark : "");
    ?>
	    </td>
        <td class='header' align='center'>
	<?php 
    echo "<a href='" . $scriptname . "?" . $addparams . "" . "order=5&by=" . ($order == "flag" && $by == "ASC" ? "2" : "1") . "'>" . PEER_COUNTRY . "</a>" . ($order == "flag" ? $mark : "");
    ?>
	    </td>
        <td class='header' align='center'>
	<?php 
    echo "<a href='" . $scriptname . "?" . $addparams . "" . "order=6&by=" . ($order == "ratio" && $by == "ASC" ? "2" : "1") . "'>" . RATIO . "</a>" . ($order == "ratio" ? $mark : "");
    ?>
	    </td>
    <?php 
    if (user::$current["uid"] > 1) {
        ?>
	    <td class='header' align='center'><?php 
        echo PM;
        ?>
</td>
	<?php 
    }
    if (user::$current["edit_users"] == "yes") {
        print "<td class='header' align='center'>" . EDIT . "</td>";
    }
    if (user::$current["delete_users"] == "yes") {
        print "<td class='header' align='center'>" . DELETE . "</td>";
    } else {
        print "</tr>";
    }
    $query = "SELECT prefixcolor, suffixcolor, users.id, downloaded, uploaded, IF(downloaded > 0, uploaded / downloaded, 0) AS ratio, username, level, UNIX_TIMESTAMP(joined) AS joined, UNIX_TIMESTAMP(lastconnect) AS lastconnect, flag, flagpic, name \n\t    FROM users INNER JOIN users_level ON users.id_level = users_level.id LEFT JOIN countries ON users.flag = countries.id \n\t\tWHERE users.id > 1 " . $where . " ORDER BY " . $order . " " . $by . " " . $limit;
    $rusers = $db->query($query);
    if ($rusers->num_rows == 0) {
        print "<tr><td class='lista' colspan='9'>" . NO_USERS_FOUND . "</td></tr>";
    } else {
        include INCL_PATH . 'offset.php';
        while ($row_user = $rusers->fetch_array(MYSQLI_BOTH)) {
            print "<tr>\n";
            print "<td class='lista'><a href='userdetails.php?id=" . (int) $row_user["id"] . "'>" . unesc($row_user["prefixcolor"]) . security::html_safe(unesc($row_user["username"])) . unesc($row_user["suffixcolor"]) . "</a></td>";
            print "<td class='lista' align='center'>" . security::html_safe($row_user["level"]) . "</td>";
            print "<td class='lista' align='center'>" . ($row_user["joined"] == 0 ? NOT_AVAILABLE : date("d/m/Y H:i:s", $row_user["joined"] - $offset)) . "</td>";
            print "<td class='lista' align='center'>" . ($row_user["lastconnect"] == 0 ? NOT_AVAILABLE : date("d/m/Y H:i:s", $row_user["lastconnect"] - $offset)) . "</td>";
            print "<td class='lista' align='center'>" . ($row_user["flag"] == 0 ? "<img src='images/flag/unknown.gif' alt='" . UNKNOWN . "' title='" . UNKNOWN . "' />" : "<img src='images/flag/" . $row_user['flagpic'] . "' alt='" . security::html_safe($row_user['name']) . "' title='" . security::html_safe($row_user['name']) . "' />") . "</td>";
            //user ratio
            if (max(0, (int) $row_user["downloaded"]) > 0) {
                $ratio = number_format((double) $row_user["uploaded"] / (double) $row_user["downloaded"], 2);
            } else {
                $ratio = "&infin;";
            }
            print "<td class='lista' align='center'>" . $ratio . "</td>";
            if (user::$current["uid"] > 1) {
                print "<td class='lista' align='center'><a href='usercp.php?do=pm&action=edit&uid=" . user::$current['uid'] . "&what=new&to=" . urlencode(security::html_safe(unesc($row_user["username"]))) . "'>" . image_or_link($STYLEPATH . "/pm.png", "", "PM") . "</a></td>";
            }
            if (user::$current["edit_users"] == "yes") {
                print "<td class='lista' align='center'><a href='account.php?act=mod&uid=" . (int) $row_user["id"] . "&returnto=" . urlencode("users.php") . "'>" . image_or_link($STYLEPATH . "/edit.png", "", EDIT) . "</a></td>";
            }
            if (user::$current["delete_users"] == "yes") {
                print "<td class='lista' align='center'><a onclick='return confirm('" . AddSlashes(DELETE_CONFIRM) . "')' href='account.php?act=del&uid=" . (int) $row_user["id"] . "&returnto=" . urlencode("users.php") . "'>" . image_or_link($STYLEPATH . "/delete.png", "", DELETE) . "</a></td>";
            }
            print "</tr>\n";
        }
    }
    print "</table>\n</div>\n<br />";
}
Пример #10
0
 public static function get_topic_forum($topicid)
 {
     global $db;
     MCached::connect();
     $key = 'forum::id::' . $topicid;
     $arr = MCached::get($key);
     if ($arr === MCached::NO_RESULT) {
         $res = $db->query("SELECT forumid FROM topics WHERE id = " . $topicid);
         if ($res->num_rows != 1) {
             return false;
         }
         $arr = $res->fetch_row();
         MCached::add($key, $arr, self::SIX_HOURS);
     }
     return (int) $arr[0];
 }
* Copyright (C) 2004-2015 Btiteam.org
*/
global $db;
if (isset(user::$current) && user::$current && user::$current['uid'] > 1 && user::$current['style'] > 1) {
    ?>
<table class='lista' cellpadding='2' cellspacing='0' width='100%'>
<tr>
<?php 
    $style = Cached::style_list();
    $langue = Cached::language_list();
    $key = 'main::user::toolbar::stats' . user::$current['uid'];
    $rowuser = MCached::get($key);
    if ($rowuser === MCached::NO_RESULT) {
        $resuser = $db->query("SELECT uploaded, downloaded FROM users WHERE id = " . user::$current['uid']);
        $rowuser = $resuser->fetch_array(MYSQLI_BOTH);
        MCached::add($key, $rowuser, 1800);
    }
    print "<td class='lista' align='center'>" . USER_LEVEL . ": " . security::html_safe(user::$current["level"]) . "</td>\n";
    print "<td class='green' align='center'>&#8593&nbsp;" . misc::makesize((double) $rowuser['uploaded']);
    print "</td><td class='red' align='center'>&#8595&nbsp;" . misc::makesize((double) $rowuser['downloaded']);
    print "</td><td class='lista' align='center'>(SR " . ((int) $rowuser['downloaded'] > 0 ? number_format((double) $rowuser['uploaded'] / (double) $rowuser['downloaded'], 2) : "&infin;") . ")</td>\n";
    if (user::$current["admin_access"] == "yes") {
        print "\n<td align='center' class='lista'><a href='admincp.php?user="******"uid"] . "&code=" . user::$current["random"] . "'>" . MNU_ADMINCP . "</a></td>\n";
    }
    print "<td class='lista' align='center'><a href='usercp.php?uid=" . user::$current["uid"] . "'>" . USER_CP . "</a></td>\n";
    $resmail = $db->query("SELECT COUNT(*) FROM messages WHERE readed = 'no' AND receiver = " . user::$current['uid']);
    if ($resmail && $resmail->num_rows > 0) {
        $mail = $resmail->fetch_row();
        if ($mail[0] > 0) {
            print "<td class='lista' align='center'><a href='usercp.php?uid=" . user::$current["uid"] . "&do=pm&action=list'>" . MAILBOX . "</a> (<font color='#FF0000'><b>" . (int) $mail[0] . "</b></font>)</td>\n";
        } else {
Пример #12
0
        stdfoot();
        exit;
    } else {
        @$db->query("INSERT INTO ratings SET infohash = '" . $id . "', userid = " . user::$current['uid'] . ", rating = " . intval($_GET["rating"]) . ", added = '" . vars::$timestamp . "'");
        redirect("details.php?id=" . $id);
    }
    exit;
}
$res = $db->query("SELECT namemap.info_hash, namemap.url, UNIX_TIMESTAMP(namemap.data) AS data, namemap.uploader, categories.name AS cat_name, summary.seeds, summary.leechers, summary.finished, summary.speed, namemap.external, namemap.announce_url, UNIX_TIMESTAMP(namemap.lastupdate) AS lastupdate, namemap.anonymous, users.username FROM namemap LEFT JOIN categories ON categories.id = namemap.category LEFT JOIN summary ON summary.info_hash = namemap.info_hash LEFT JOIN users ON users.id = namemap.uploader WHERE namemap.info_hash = '" . $id . "'");
$row = $res->fetch_array(MYSQLI_BOTH);
#Cached filename, size and description...
$cache = MCached::get('torrent::details::' . $id);
if ($cache === MCached::NO_RESULT) {
    $cached = $db->query("SELECT filename, size, comment FROM namemap WHERE info_hash = '" . $id . "'");
    $cache = $cached->fetch_assoc();
    MCached::add('torrent::details::' . $id, $cache, 43200);
}
if (!$row) {
    die("Bad ID!");
}
$spacer = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
print "<div align='center'><table class='lista' width='100%' border='0' cellspacing='1' cellpadding='5'>\n";
print "<tr><td align='right' class='header'> " . FILE_NAME;
if (user::$current["uid"] > 1 && (user::$current["uid"] == $row["uploader"] || user::$current["edit_torrents"] == "yes" || user::$current["delete_torrents"] == "yes")) {
    print "<br />&nbsp;&nbsp;";
}
// edit and delete picture/link
if (user::$current["uid"] > 1 && (user::$current["uid"] == $row["uploader"] || user::$current["edit_torrents"] == "yes")) {
    print "<a href='edit.php?info_hash=" . $row["info_hash"] . "&amp;returnto=" . urlencode("details.php?id=" . $row["info_hash"]) . "'>" . image_or_link($STYLEPATH . "/edit.gif", "", EDIT) . "</a>&nbsp;&nbsp;";
}
if (user::$current["uid"] > 1 && (user::$current["uid"] == $row["uploader"] || user::$current["delete_torrents"] == "yes")) {
Пример #13
0
 if (!isset($gueststr)) {
     $gueststr = '';
 }
 $users = '';
 $key = 'online::users';
 $users = MCached::get($key);
 if ($users === MCached::NO_RESULT) {
     $res = $db->query("SELECT username, users.id, prefixcolor, suffixcolor FROM users INNER JOIN users_level ON users.id_level = users_level.id WHERE UNIX_TIMESTAMP(lastconnect) >= " . $curtime . " AND users.id > 1");
     $print .= "\n<tr><td class='lista' align='center'>";
     if ($res) {
         while ($ruser = $res->fetch_row()) {
             $users .= ($regusers > 0 ? ", " : "") . "\n<a href='userdetails.php?id=" . (int) $ruser[1] . "'>" . StripSlashes($ruser[2] . $ruser[0] . $ruser[3]) . "</a>";
             $regusers++;
         }
     }
     MCached::add($key, $users, 300);
 }
 // guest code
 $guest_ip = explode('.', vars::$realip);
 $guest_ip = pack("C*", $guest_ip[0], $guest_ip[1], $guest_ip[2], $guest_ip[3]);
 if (!file_exists("addons/guest.dat")) {
     $handle = fopen("addons/guest.dat", "w");
     fclose($handle);
 }
 $handle = fopen("addons/guest.dat", "rb+");
 flock($handle, LOCK_EX);
 $guest_num = intval(filesize("addons/guest.dat") / 8);
 if ($guest_num > 0) {
     $data = fread($handle, $guest_num * 8);
 } else {
     $data = fread($handle, 8);
Пример #14
0
} elseif ($act == "signup") {
    block_begin(ACCOUNT_CREATE);
} elseif ($act == "del") {
    if (user::$current["delete_users"] != "yes" || $id == 1 || user::$current["uid"] == $id) {
        stderr(ERROR, ERR_NOT_AUTH);
    } else {
        block_begin(ACCOUNT_DELETE);
    }
}
print "</center>";
$numusers = MCached::get('account::total::reg::users');
if ($numusers === MCached::NO_RESULT) {
    $res = $db->query("SELECT COUNT(*) FROM users WHERE id > 1");
    $nusers = $res->fetch_row();
    $numusers = (int) $nusers[0];
    MCached::add('account::total::reg::users', $numusers, 300);
}
if ($act == "signup" && $MAX_USERS != 0 && $numusers >= $MAX_USERS) {
    err_msg(ERROR, REACHED_MAX_USERS);
    block_end();
    stdfoot();
    exit;
}
if ($act == "confirm") {
    $random = intval($_GET["confirm"]);
    $res = $db->query("UPDATE users SET id_level = 3 WHERE id_level = 2 AND random = " . $random);
    if (!$res) {
        die("ERROR: " . $db->error() . "\n");
    } else {
        block_begin(ACCOUNT_CREATE);
        print "<tr><td align='center'>" . ACCOUNT_CONGRATULATIONS . "</td></tr>";
Пример #15
0
/*
* BtiTracker v1.5.1 is a php tracker system for BitTorrent, easy to setup and configure.
* This tracker is a frontend for DeHackEd's tracker, aka phpBTTracker (now heavely modified). 
* Updated and Maintained by Yupy.
* Copyright (C) 2004-2015 Btiteam.org
*/
global $db;
if (!user::$current || user::$current["view_users"] == "no") {
    // do nothing
} else {
    //lastest member
    block_begin("Latest Member");
    $key = 'latest::member';
    $a = MCached::get($key);
    if ($a === MCached::NO_RESULT) {
        $a = @$db->query("SELECT id, username FROM users WHERE id_level <> 1 AND id_level <> 2 ORDER BY id DESC LIMIT 1");
        $a = @$a->fetch_assoc();
        MCached::add($key, $a, 9600);
    }
    if ($a) {
        if (user::$current["view_users"] == "yes") {
            $latestuser = "******" . (int) $a["id"] . "'>" . security::html_safe($a["username"]) . "</a>";
        } else {
            $latestuser = security::html_safe($a['username']);
        }
        echo "<div align='center'>Welcome to our Tracker <br /><b>" . $latestuser . "</b>!</div>\n";
    }
    block_end();
}
// end if user can view
Пример #16
0
 public static function ip_port($in, &$ip, &$port, &$type, &$addr)
 {
     MCached::connect();
     $key = 'ip::ip_port::' . sha1($in);
     $ip_port = MCached::get($key);
     if ($ip_port === MCached::NO_RESULT) {
         if (!preg_match('#^([0-9a-f:]+)$#i', $in, $matches) && !preg_match('#^\\[([0-9a-f:]+)\\](?::([0-9]{1,5}))?$#i', $in, $matches) && !preg_match('#^([0-9.]+)(?::([0-9]{1,5}))?$#', $in, $matches)) {
             return false;
         }
         $tip = $matches[1];
         $taddr = self::type($tip, $ttype);
         if (!$taddr) {
             MCached::add($key, 0, 86400);
             return false;
         }
         $taddr6 = self::ip2addr6($tip);
         $tport = 0;
         if (isset($matches[2])) {
             $tport = (int) $matches[2];
             if ($tport < 1 || $tport > 65535) {
                 MCached::add($key, 0, 86400);
                 return false;
             }
         }
         if (!self::valid_ip($tip)) {
             MCached::add($key, 0, 86400);
             return false;
         }
         $ip_port = array($tip, $tport, $ttype, $taddr, $taddr6);
         MCached::add($key, $ip_port, 86400);
     } elseif (!$ip_port) {
         return false;
     }
     list($ip, $port, $type, $addr, $addr6) = $ip_port;
     return $addr6;
 }