Пример #1
0
 public static function init()
 {
     MCached::connect();
     $key = 'ord::chars::bin';
     $chars = MCached::get($key);
     if (!is_array($chars)) {
         $chrs = $ords = array();
         for ($i = 0; $i <= 0xff; $i++) {
             $char = chr($i);
             $bin = sprintf('%08b', $i);
             $chrs[$i] = $char;
             $ords[$char] = $i;
             $b2cs[$bin] = $char;
             $c2bs[$char] = $bin;
         }
         $chars = array($chrs, $ords, $b2cs, $c2bs);
         MCached::set($key, $chars, 86400);
     }
     self::$chr = $chars[0];
     self::$ord = $chars[1];
     self::$b2c = $chars[2];
     self::$c2b = $chars[3];
 }
Пример #2
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;
 }
Пример #3
0
        $ris = $db->query("SELECT info_hash, filename, url FROM namemap WHERE info_hash = '" . $hash . "'");
        if ($ris->num_rows == 0) {
            err_msg("Sorry!", "Torrent " . $hash . " not found.");
            exit;
        } else {
            list($torhash, $torname, $torurl) = $ris->fetch_array(MYSQLI_BOTH);
        }
        write_log("Deleted torrent " . $torname . " (" . $torhash . ")", "delete");
        @$db->query("DELETE FROM summary WHERE info_hash = '" . $hash . "'");
        @$db->query("DELETE FROM namemap WHERE info_hash = '" . $hash . "'");
        @$db->query("DELETE FROM timestamps WHERE info_hash = '" . $hash . "'");
        @$db->query("DELETE FROM comments WHERE info_hash = '" . $hash . "'");
        @$db->query("DELETE FROM ratings WHERE infohash = '" . $hash . "'");
        @$db->query("DELETE FROM peers WHERE infohash = '" . $hash . "'");
        @$db->query("DELETE FROM history WHERE infohash = '" . $hash . "'");
        MCached::del('torrent::details::' . $hash);
        unlink($TORRENTSDIR . "/" . $hash . ".btf");
        print "<script language='javascript'>window.location.href='" . $link . "'</script>";
        exit;
    } else {
        print "<script language='javascript'>window.location.href='" . $link . "'</script>";
        exit;
    }
}
block_begin(DELETE_TORRENT);
print "<table width='100%' class='lista' border='0' cellspacing='5' cellpadding='5'>\n";
print "<tr><td align='right' class='header'>" . FILE_NAME . ":</td><td class='lista'>" . security::html_safe($row["filename"]) . "</td></tr>";
print "<tr><td align='right' class='header'>" . INFO_HASH . ":</td><td class='lista'>" . security::html_safe($row["info_hash"]) . "</td></tr>";
if (!empty($row["comment"])) {
    print "<tr><td align='right' class='header'>" . DESCRIPTION . ":</td><td align='left' class='lista'>" . format_comment(unesc($row["comment"])) . "</td></tr>";
}
Пример #4
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>";
Пример #5
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...
Пример #6
0
     print "</td></tr>\n";
     print "</table>\n</form>\n";
     block_end();
 } elseif ($do == "banip" && $action == "write") {
     if ($_POST['firstip'] == "" || $_POST['lastip'] == "") {
         err_msg(ERROR, NO_IP_WRITE);
     } else {
         //ban the ip for real
         $firstip = $db->real_escape_string($_POST["firstip"]);
         $lastip = $db->real_escape_string($_POST["lastip"]);
         $comment = $db->real_escape_string($_POST["comment"]);
         $firstip = sprintf("%u", ip2long($firstip));
         $lastip = sprintf("%u", ip2long($lastip));
         for ($i = $firstip; $i <= $lastip; $i++) {
             $ip = long2ip($i);
             MCached::del('banned::' . $ip);
         }
         if ($firstip == -1 || $lastip == -1) {
             err_msg(ERROR, IP_ERROR);
         } else {
             $comment = sqlesc($comment);
             $added = sqlesc(vars::$timestamp);
             $db->query("INSERT INTO bannedip (added, addedby, first, last, comment) VALUES(" . $added . ", " . user::$current['uid'] . ", " . $firstip . ", " . $lastip . ", " . $comment . ")");
             redirect("admincp.php?user="******"uid"] . "&code=" . user::$current["random"] . "&do=banip&action=read");
         }
     }
 } elseif ($do == "banip" && $action == "delete") {
     if ($_GET['ip'] == "") {
         err_msg(ERROR, INVALID_ID);
     }
     //delete the ip from db
Пример #7
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
Пример #8
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);
    }
}
    public function display()
    {
        global $currentIndex;
        $warnings = array();
        if (!extension_loaded('memcache')) {
            $warnings[] = $this->l('To use Memcached, you must to install the Memcache PECL extension on your server.') . ' <a href="http://www.php.net/manual/en/memcache.installation.php">http://www.php.net/manual/en/memcache.installation.php</a>';
        }
        if (!is_writable(_PS_CACHEFS_DIRECTORY_)) {
            $warnings[] = $this->l('To use CacheFS the directory') . ' ' . realpath(_PS_CACHEFS_DIRECTORY_) . ' ' . $this->l('must be writable');
        }
        if ($warnings) {
            $this->displayWarning($warnings);
        }
        echo '<script type="text/javascript">
						$(document).ready(function() {
							showMemcached();
							$(\'#caching_system\').change(function() {
								showMemcached();
							});
							function showMemcached()
							{
								if ($(\'#caching_system option:selected\').val() == \'MCached\')
								{
									$(\'#memcachedServers\').show();
									$(\'#directory_depth\').hide();
								}
								else
								{
									$(\'#memcachedServers\').hide();
									$(\'#directory_depth\').show();
								}
							}
							$(\'#addMemcachedServer\').click(function() {
								$(\'#formMemcachedServer\').show();
								return false;
							});
						});
		</script>
		';
        echo '
		<form action="' . $currentIndex . '&token=' . Tools::getValue('token') . '" method="post" style="margin-top:10px;">
			<fieldset>
				<legend><img src="../img/admin/prefs.gif" /> ' . $this->l('Smarty') . '</legend>
				
				<label>' . $this->l('Force compile:') . '</label>
				<div class="margin-form">
					<input type="radio" name="smarty_force_compile" id="smarty_force_compile_1" value="1" ' . (Configuration::get('PS_SMARTY_FORCE_COMPILE') ? 'checked="checked"' : '') . ' /> <label class="t"><img src="../img/admin/enabled.gif" alt="" /> ' . $this->l('Yes') . '</label>
					<input type="radio" name="smarty_force_compile" id="smarty_force_compile_0" value="0" ' . (!Configuration::get('PS_SMARTY_FORCE_COMPILE') ? 'checked="checked"' : '') . ' /> <label class="t"><img src="../img/admin/disabled.gif" alt="" /> ' . $this->l('No') . '</label>
					<p>' . $this->l('This forces Smarty to (re)compile templates on every invocation. This is handy for development and debugging. It should never be used in a production environment.') . '</p>
				</div>
				<label>' . $this->l('Cache:') . '</label>
				<div class="margin-form">
					<input type="radio" name="smarty_cache" id="smarty_cache_1" value="1" ' . (Configuration::get('PS_SMARTY_CACHE') ? 'checked="checked"' : '') . ' /> <label class="t"><img src="../img/admin/enabled.gif" alt="" /> ' . $this->l('Yes') . '</label>
					<input type="radio" name="smarty_cache" id="smarty_cache_0" value="0" ' . (!Configuration::get('PS_SMARTY_CACHE') ? 'checked="checked"' : '') . ' /> <label class="t"><img src="../img/admin/disabled.gif" alt="" /> ' . $this->l('No') . '</label>
					<p>' . $this->l('Should be enabled except for debugging.') . '</p>
				</div>

				<div class="margin-form">
					<input type="submit" value="' . $this->l('   Save   ') . '" name="submitSmartyConfig" class="button" />
				</div>
			</fieldset>
		</form>';
        echo '
		<form action="' . $currentIndex . '&token=' . Tools::getValue('token') . '" method="post" style="margin-top:10px;">
			<fieldset>
				<legend><img src="../img/admin/arrow_in.png" /> ' . $this->l('CCC (Combine, Compress and Cache)') . '</legend>
				<p>' . $this->l('CCC allows you to reduce the loading time of your page. With these settings you will gain performance without even touching the code of your theme. Make sure, however, that your theme is compatible with PrestaShop 1.4+. Otherwise, CCC will cause problems.') . '</p>
				<label>' . $this->l('Smart cache for CSS') . ' </label>
				<div class="margin-form">
					<input type="radio" value="1" name="PS_CSS_THEME_CACHE" id="PS_CSS_THEME_CACHE_1" ' . (Configuration::get('PS_CSS_THEME_CACHE') ? 'checked="checked"' : '') . ' />
					<label class="t" for="PS_CSS_THEME_CACHE_1">' . $this->l('Use CCC for CSS.') . '</label>
					<br />
					<input type="radio" value="0" name="PS_CSS_THEME_CACHE" id="PS_CSS_THEME_CACHE_0" ' . (Configuration::get('PS_CSS_THEME_CACHE') ? '' : 'checked="checked"') . ' />
					<label class="t" for="PS_CSS_THEME_CACHE_0">' . $this->l('Keep CSS as original') . '</label>
				</div>
				
				<label>' . $this->l('Smart cache for JavaScript') . ' </label>
				<div class="margin-form">
					<input type="radio" value="1" name="PS_JS_THEME_CACHE" id="PS_JS_THEME_CACHE_1" ' . (Configuration::get('PS_JS_THEME_CACHE') ? 'checked="checked"' : '') . ' />
					<label class="t" for="PS_JS_THEME_CACHE_1">' . $this->l('Use CCC for JavaScript.') . '</label>
					<br />
					<input type="radio" value="0" name="PS_JS_THEME_CACHE" id="PS_JS_THEME_CACHE_0" ' . (Configuration::get('PS_JS_THEME_CACHE') ? '' : 'checked="checked"') . ' />
					<label class="t" for="PS_JS_THEME_CACHE_0">' . $this->l('Keep JavaScript as original') . '</label>
				</div>
				
				<label>' . $this->l('Minify HTML') . ' </label>
				<div class="margin-form">
					<input type="radio" value="1" name="PS_HTML_THEME_COMPRESSION" id="PS_HTML_THEME_COMPRESSION_1" ' . (Configuration::get('PS_HTML_THEME_COMPRESSION') ? 'checked="checked"' : '') . ' />
					<label class="t" for="PS_HTML_THEME_COMPRESSION_1">' . $this->l('Minify HTML after "smarty compile" execution.') . '</label>
					<br />
					<input type="radio" value="0" name="PS_HTML_THEME_COMPRESSION" id="PS_HTML_THEME_COMPRESSION_0" ' . (Configuration::get('PS_HTML_THEME_COMPRESSION') ? '' : 'checked="checked"') . ' />
					<label class="t" for="PS_HTML_THEME_COMPRESSION_0">' . $this->l('Keep HTML as original') . '</label>
				</div>
				
				<label>' . $this->l('Compress inline JavaScript in HTML') . ' </label>
				<div class="margin-form">
					<input type="radio" value="1" name="PS_JS_HTML_THEME_COMPRESSION" id="PS_JS_HTML_THEME_COMPRESSION_1" ' . (Configuration::get('PS_JS_HTML_THEME_COMPRESSION') ? 'checked="checked"' : '') . ' />
					<label class="t" for="PS_JS_HTML_THEME_COMPRESSION_1">' . $this->l('Compress inline JavaScript in HTML after "smarty compile" execution') . '</label>
					<br />
					<input type="radio" value="0" name="PS_JS_HTML_THEME_COMPRESSION" id="PS_JS_HTML_THEME_COMPRESSION_0" ' . (Configuration::get('PS_JS_HTML_THEME_COMPRESSION') ? '' : 'checked="checked"') . ' />
					<label class="t" for="PS_JS_HTML_THEME_COMPRESSION_0">' . $this->l('Keep inline JavaScript in HTML as original') . '</label>
				</div>
				
				<label>' . $this->l('High risk HTML compression') . ' </label>
				<div class="margin-form">
					<input type="radio" value="1" name="PS_HIGH_HTML_THEME_COMPRESSION" id="PS_HIGH_HTML_THEME_COMPRESSION_1" ' . (Configuration::get('PS_HIGH_HTML_THEME_COMPRESSION') ? 'checked="checked"' : '') . ' />
					<label class="t" for="PS_HIGH_HTML_THEME_COMPRESSION_1">' . $this->l('HTML is compressed but cancels the W3C validation (only when "Minify HTML" is enabled)') . '</label>
					<br />
					<input type="radio" value="0" name="PS_HIGH_HTML_THEME_COMPRESSION" id="PS_HIGH_HTML_THEME_COMPRESSION_0" ' . (Configuration::get('PS_HIGH_HTML_THEME_COMPRESSION') ? '' : 'checked="checked"') . ' />
					<label class="t" for="PS_HIGH_HTML_THEME_COMPRESSION_0">' . $this->l('Keep W3C validation') . '</label>
				</div>
				
				<div class="margin-form">
					<input type="submit" value="' . $this->l('   Save   ') . '" name="submitCCC" class="button" />
				</div>
			</fieldset>
		</form>';
        echo '<form action="' . $currentIndex . '&token=' . Tools::getValue('token') . '" method="post" style="margin-top:10px;">
			<fieldset>
				<legend><img src="../img/admin/subdomain.gif" /> ' . $this->l('Media servers (used only with CCC)') . '</legend>
				<p>' . $this->l('You must enter another domain or subdomain in order to use cookieless static content.') . '</p>
				<label for="_MEDIA_SERVER_1_">' . $this->l('Media server #1') . '</label>
				<div class="margin-form">
					<input type="text" name="_MEDIA_SERVER_1_" id="_MEDIA_SERVER_1_" value="' . htmlentities(Tools::getValue('_MEDIA_SERVER_1_', _MEDIA_SERVER_1_), ENT_QUOTES, 'UTF-8') . '" size="30" />
					<p>' . $this->l('Name of the second domain of your shop, (e.g., myshop-media-server-1.com). If you do not have another domain, leave this field blank') . '</p>
				</div>
				<label for="_MEDIA_SERVER_2_">' . $this->l('Media server #2') . '</label>
				<div class="margin-form">
					<input type="text" name="_MEDIA_SERVER_2_" id="_MEDIA_SERVER_2_" value="' . htmlentities(Tools::getValue('_MEDIA_SERVER_2_', _MEDIA_SERVER_2_), ENT_QUOTES, 'UTF-8') . '" size="30" />
					<p>' . $this->l('Name of the third domain of your shop, (e.g., myshop-media-server-2.com). If you do not have another domain, leave this field blank') . '</p>
				</div>
				<label for="_MEDIA_SERVER_3_">' . $this->l('Media server #3') . '</label>
				<div class="margin-form">
					<input type="text" name="_MEDIA_SERVER_3_" id="_MEDIA_SERVER_3_" value="' . htmlentities(Tools::getValue('_MEDIA_SERVER_3_', _MEDIA_SERVER_3_), ENT_QUOTES, 'UTF-8') . '" size="30" />
					<p>' . $this->l('Name of the fourth domain of your shop, (e.g., myshop-media-server-3.com). If you do not have another domain, leave this field blank') . '</p>
				</div>
				<div class="margin-form">
					<input type="submit" value="' . $this->l('   Save   ') . '" name="submitMediaServers" class="button" />
				</div>
			</fieldset>
		</form>';
        echo '
		<fieldset style="margin-top:10px;">
			<legend><img src="../img/admin/computer_key.png" /> ' . $this->l('Ciphering') . '</legend>
			<form action="' . $currentIndex . '&token=' . Tools::getValue('token') . '" method="post">
				<p>' . $this->l('Mcrypt is faster than our custom BlowFish class, but requires the PHP extension "mcrypt". If you change this configuration, all cookies will be reset.') . '</p>
				<label>' . $this->l('Algorithm') . ' </label>
				<div class="margin-form">
					<input type="radio" value="1" name="PS_CIPHER_ALGORITHM" id="PS_CIPHER_ALGORITHM_1" ' . (Configuration::get('PS_CIPHER_ALGORITHM') ? 'checked="checked"' : '') . ' />
					<label class="t" for="PS_CIPHER_ALGORITHM_1">' . $this->l('Use Rijndael with mcrypt lib.') . '</label>
					<br />
					<input type="radio" value="0" name="PS_CIPHER_ALGORITHM" id="PS_CIPHER_ALGORITHM_0" ' . (Configuration::get('PS_CIPHER_ALGORITHM') ? '' : 'checked="checked"') . ' />
					<label class="t" for="PS_CIPHER_ALGORITHM_0">' . $this->l('Keep the custom BlowFish class.') . '</label>
				</div>
				<div class="margin-form">
					<input type="submit" value="' . $this->l('   Save   ') . '" name="submitCiphering" class="button" />
				</div>
			</form>
		</fieldset>
		';
        $depth = Configuration::get('PS_CACHEFS_DIRECTORY_DEPTH');
        echo '<fieldset style="margin-top: 10px;">
				<legend><img src="../img/admin/computer_key.png" /> ' . $this->l('Caching') . '</legend>
				<form action="' . $currentIndex . '&token=' . Tools::getValue('token') . '"  method="post">
					<label>' . $this->l('Use cache:') . ' </label>
					<div class="margin-form">
						<input type="radio" name="active" id="active_on" value="1" ' . (_PS_CACHE_ENABLED_ ? 'checked="checked" ' : '') . '/>
						<label class="t" for="active_on"> <img src="../img/admin/enabled.gif" alt="' . $this->l('Enabled') . '" title="' . $this->l('Enabled') . '" /></label>
						<input type="radio" name="active" id="active_off" value="0" ' . (!_PS_CACHE_ENABLED_ ? 'checked="checked" ' : '') . '/>
						<label class="t" for="active_off"> <img src="../img/admin/disabled.gif" alt="' . $this->l('Disabled') . '" title="' . $this->l('Disabled') . '" /></label>
						<p>' . $this->l('Enable or disable caching system') . '</p>
					</div>
					<label>' . $this->l('Caching system:') . ' </label>
					<div class="margin-form">
						<select name="caching_system" id="caching_system">
							<option value="MCached" ' . (_PS_CACHING_SYSTEM_ == 'MCached' ? 'selected="selected"' : '') . '>' . $this->l('Memcached') . '</option>
							<option value="CacheFS" ' . (_PS_CACHING_SYSTEM_ == 'CacheFS' ? 'selected="selected"' : '') . '>' . $this->l('File System') . '</option>
						</select>
					</div>
					<div id="directory_depth">
						<label>' . $this->l('Directory depth:') . ' </label>
						<div class="margin-form">
							<input type="text" name="ps_cache_fs_directory_depth" value="' . ($depth ? $depth : 1) . '" />
						</div>
					</div>
					<div class="margin-form">
						<input type="submit" value="' . $this->l('   Save   ') . '" name="submitCaching" class="button" />
					</div>
				</form>
				<div id="memcachedServers">
					<div class="margin-form">
						<a id="addMemcachedServer" href="#" ><img src="../img/admin/add.gif" />' . $this->l('Add server') . '</a>
					</div>
					<div id="formMemcachedServer" style="margin-top: 10px; display:none;">
						<form action="' . $currentIndex . '&token=' . Tools::getValue('token') . '" method="post">
							<label>' . $this->l('IP Address:') . ' </label>
							<div class="margin-form">
								<input type="text" name="memcachedIp" />
							</div>
							<label>' . $this->l('Port:') . ' </label>
							<div class="margin-form">
								<input type="text" name="memcachedPort" value="11211" />
							</div>
							<label>' . $this->l('Weight:') . ' </label>
							<div class="margin-form">
								<input type="text" name="memcachedWeight" value="1" />
							</div>
							<div class="margin-form">
								<input type="submit" value="' . $this->l('   Add Server   ') . '" name="submitAddServer" class="button" />
							</div>
						</form>
					</div>';
        $servers = MCached::getMemcachedServers();
        if ($servers) {
            echo '<div class="margin-form">
					<table style="width: 320px;" cellspacing="0" cellpadding="0" class="table">
					<tr>
						<th style="width: 20px; text-align: center">' . $this->l('Id') . '</th>
						<th style="width: 200px; text-align: center">' . $this->l('Ip') . '</th>
						<th style="width: 50px; text-align: center">' . $this->l('Port') . '</th>
						<th style="width: 30px; text-align: right; font-weight: bold;">' . $this->l('Weight') . '</th>
						<th style="width: 20px; text-align: right;">&nbsp;</th>
					</tr>';
            foreach ($servers as $server) {
                echo '<tr>
							<td>' . $server['id_memcached_server'] . '</td>
							<td>' . $server['ip'] . '</td>
							<td>' . $server['port'] . '</td>
							<td>' . $server['weight'] . '</td>
							<td>
								<a href="' . $currentIndex . '&token=' . Tools::getValue('token') . '&deleteMemcachedServer=' . (int) $server['id_memcached_server'] . '" ><img src="../img/admin/delete.gif" /></a>
							</td>
						</tr>';
            }
            echo '
					</table>
				</div>';
        }
        echo '
				</div>
			</fieldset>';
    }
* 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 {
Пример #11
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")) {
Пример #12
0
 private static function set_error($method, $key = '')
 {
     self::$errno = self::$link->getResultCode();
     if (self::$errno) {
         self::$error = self::$link->getResultMessage();
         switch (self::$errno) {
             case Memcached::RES_NOTFOUND:
             case Memcached::RES_NOTSTORED:
                 break;
             default:
                 trigger_error('Error in ' . $method . ($key ? ' KEY ' . var_export($key, true) : '') . ' [' . self::$errno . ']: ' . self::$error, E_USER_WARNING);
                 break;
         }
     } else {
         self::$error = '';
     }
 }
Пример #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
function aggiungiutente()
{
    global $SITENAME, $SITEEMAIL, $db, $BASEURL, $VALIDATION, $USERLANG, $USE_IMAGECODE;
    $utente = $db->real_escape_string($_POST["user"]);
    $pwd = $db->real_escape_string($_POST["pwd"]);
    $pwd1 = $db->real_escape_string($_POST["pwd1"]);
    $email = $db->real_escape_string($_POST["email"]);
    $idlangue = intval($_POST["language"]);
    $idstyle = intval($_POST["style"]);
    $idflag = intval($_POST["flag"]);
    $timezone = intval($_POST["timezone"]);
    if (utf8::strtoupper($utente) == utf8::strtoupper("Guest")) {
        print ERROR . " " . ERR_GUEST_EXISTS . "<br />\n";
        print "<a href='account.php'>" . BACK . "</a>";
        block_end();
        stdfoot();
        exit;
    }
    if ($pwd != $pwd1) {
        print ERROR . " " . DIF_PASSWORDS . "<br />\n";
        print "<a href='account.php'>" . BACK . "</a>";
        block_end();
        stdfoot();
        exit;
    }
    if ($VALIDATION == "none") {
        $idlevel = 3;
    } else {
        $idlevel = 2;
    }
    # Create Random number
    $floor = 100000;
    $ceiling = 999999;
    srand((double) microtime() * 1000000);
    $random = mt_rand($floor, $ceiling);
    if ($utente == "" || $pwd == "" || $email == "") {
        return -1;
        exit;
    }
    $res = $db->query("SELECT email FROM users WHERE email = '" . $email . "'");
    if ($res->num_rows > 0) {
        return -2;
        exit;
    }
    if (!security::valid_email($email)) {
        return -3;
        exit;
    }
    // duplicate username
    $res = $db->query("SELECT username FROM users WHERE username = '******'");
    if ($res->num_rows > 0) {
        return -4;
        exit;
    }
    // duplicate username
    if (strpos($db->real_escape_string($utente), " ") == true) {
        return -7;
        exit;
    }
    if ($USE_IMAGECODE) {
        if (extension_loaded('gd')) {
            $arr = gd_info();
            if ($arr['FreeType Support'] == 1) {
                $public = $_POST['public_key'];
                $private = $_POST['private_key'];
                $p = new ocr_captcha();
                if ($p->check_captcha($public, $private) != true) {
                    err_msg(ERROR, ERR_IMAGE_CODE);
                    block_end();
                    stdfoot();
                    exit;
                }
            }
        }
    }
    $bannedchar = array("\\", "/", ":", "*", "?", "\"", "@", "\$", "'", "`", ",", ";", ".", "<", ">", "!", "£", "%", "^", "&", "(", ")", "+", "=", "#", "~");
    if (straipos($db->real_escape_string($utente), $bannedchar) == true) {
        return -8;
        exit;
    }
    if (utf8::strlen($db->real_escape_string($pwd)) < 4) {
        return -9;
        exit;
    }
    @$db->query("INSERT INTO users (username, password, random, id_level, email, style, language, flag, joined, lastconnect, pid, time_offset) VALUES ('" . $utente . "', '" . md5($pwd) . "', " . $random . ", " . $idlevel . ", '" . $email . "', " . $idstyle . ", " . $idlangue . ", " . $idflag . ", NOW(), NOW(), '" . md5(uniqid(mt_rand(), true)) . "', '" . $timezone . "')");
    MCached::del('latest::member');
    if ($VALIDATION == "user") {
        ini_set("sendmail_from", "");
        if ($db->errno == 0) {
            mail($email, ACCOUNT_CONFIRM, ACCOUNT_MSG . "\n\n" . $BASEURL . "/account.php?act=confirm&confirm=" . $random . "&language=" . $idlangue . "", "From: " . $SITENAME . " <" . $SITEEMAIL . ">");
            write_log("Signup new User " . $utente . " (" . $email . ")", "add");
        } else {
            die($db->error);
        }
    }
    return $db->errno;
}
Пример #15
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 = '';
Пример #16
0
    if (user::$current["admin_access"] == "yes" && $_GET["action"] == "delete") {
        @$db->query("DELETE FROM comments WHERE id = " . $cid);
        MCached::del('torrent::comments::count::' . $_POST['info_hash']);
        redirect("details.php?id=" . $id . "#comments");
        exit;
    }
}
if (isset($_POST["info_hash"])) {
    if ($_POST["confirm"] == FRM_CONFIRM) {
        $comment = $db->real_escape_string(addslashes($_POST["comment"]));
        $user = AddSlashes(user::$current["username"]);
        if ($user == '') {
            $user = "******";
        }
        @$db->query("INSERT INTO comments (added, text, ori_text, user, info_hash) VALUES (NOW(), '" . $comment . "', '" . $comment . "', '" . $user . "', '" . $db->real_escape_string(StripSlashes($_POST["info_hash"])) . "')");
        MCached::del('torrent::comments::count::' . $_POST['info_hash']);
        redirect("details.php?id=" . StripSlashes($_POST["info_hash"]) . "#comments");
    }
    # Comment preview by miskotes
    #############################
    if ($_POST["confirm"] == FRM_PREVIEW) {
        block_begin(COMMENT_PREVIEW);
        $comment = str_replace('\\r\\n', "\n", $comment);
        print "<table width='100%' align='center' class='lista'><tr><td class='lista' align='center'>" . format_comment(unesc($comment)) . "</td></tr>\n";
        print "</table>";
        block_end();
        comment_form();
        stdfoot();
        #####################
        # Comment preview end
    } else {
Пример #17
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);
}
Пример #18
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];
 }
Пример #19
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();
}
Пример #20
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 />";
}
        $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 
Пример #22
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;
 }