// Session data - Information about the specific session // Enabled - if the user's enabled or not // Permissions if (isset($_COOKIE['session'])) { $LoginCookie=$Enc->decrypt($_COOKIE['session']); } if(isset($LoginCookie)) { list($SessionID, $LoggedUser['ID'])=explode("|~|",$Enc->decrypt($LoginCookie)); $LoggedUser['ID'] = (int)$LoggedUser['ID']; $UserID=$LoggedUser['ID']; //TODO: UserID should not be LoggedUser if (!$LoggedUser['ID'] || !$SessionID) { logout(); } $UserSessions = $Cache->get_value('users_sessions_'.$UserID); if(!is_array($UserSessions)) { $DB->query("SELECT SessionID, Browser, OperatingSystem, IP, LastUpdate FROM users_sessions WHERE UserID='$UserID' ORDER BY LastUpdate DESC"); $UserSessions = $DB->to_array('SessionID',MYSQLI_ASSOC); $Cache->cache_value('users_sessions_'.$UserID, $UserSessions, 0); } if (!array_key_exists($SessionID,$UserSessions)) {
// Stats - Uploaded and downloaded - can be updated by a script if you want super speed // Session data - Information about the specific session // Enabled - if the user's enabled or not // Permissions if (isset($_COOKIE['session'])) { $LoginCookie = $Enc->decrypt($_COOKIE['session']); } if (isset($LoginCookie)) { list($SessionID, $LoggedUser['ID']) = explode('|~|', $Enc->decrypt($LoginCookie)); $LoggedUser['ID'] = (int) $LoggedUser['ID']; $UserID = $LoggedUser['ID']; //TODO: UserID should not be LoggedUser if (!$LoggedUser['ID'] || !$SessionID) { logout(); } $UserSessions = $Cache->get_value("users_sessions_{$UserID}"); if (!is_array($UserSessions)) { $DB->query("\n\t\t\tSELECT\n\t\t\t\tSessionID,\n\t\t\t\tBrowser,\n\t\t\t\tOperatingSystem,\n\t\t\t\tIP,\n\t\t\t\tLastUpdate\n\t\t\tFROM users_sessions\n\t\t\tWHERE UserID = '{$UserID}'\n\t\t\t\tAND Active = 1\n\t\t\tORDER BY LastUpdate DESC"); $UserSessions = $DB->to_array('SessionID', MYSQLI_ASSOC); $Cache->cache_value("users_sessions_{$UserID}", $UserSessions, 0); } if (!array_key_exists($SessionID, $UserSessions)) { logout(); } // Check if user is enabled $Enabled = $Cache->get_value('enabled_' . $LoggedUser['ID']); if ($Enabled === false) { $DB->query("\n\t\t\tSELECT Enabled\n\t\t\tFROM users_main\n\t\t\tWHERE ID = '{$LoggedUser['ID']}'"); list($Enabled) = $DB->next_record(); $Cache->cache_value('enabled_' . $LoggedUser['ID'], $Enabled, 0); }
require('classes/config.php'); //The config contains all site wide configuration information as well as memcached rules if (!extension_loaded('gd')) { error('nogd'); } require(SERVER_ROOT.'/classes/class_cache.php'); //Require the caching class require(SERVER_ROOT.'/classes/class_encrypt.php'); //Require the encryption class $Cache = NEW CACHE; //Load the caching class $Enc = NEW CRYPT; //Load the encryption class if (isset($_COOKIE['session'])) { $LoginCookie=$Enc->decrypt($_COOKIE['session']); } if(isset($LoginCookie)) { list($SessionID, $UserID)=explode("|~|",$Enc->decrypt($LoginCookie)); $UserID = (int)$UserID; $UserInfo = $Cache->get_value('user_info_'.$UserID); $Permissions = $Cache->get_value('perm_'.$UserInfo['PermissionID']); } function check_perms($PermissionName) { global $Permissions; return (isset($Permissions['Permissions'][$PermissionName])) ? true : false; } function error($Type) { header('Content-type: image/gif'); die(file_get_contents(SERVER_ROOT.'/sections/image/'.$Type.'.gif')); } function invisible($Image) { $Count = imagecolorstotal($Image);
<?php require "cache.php"; require "misc.class.php"; $Cache = new CACHE(); if (($lasthpm = $Cache->get_value('ptpimg_hpm_last')) === false) { $lasthpm = $Cache->get_value('ptpimg_hpm'); $Cache->cache_value('ptpimg_hpm_last', $lasthpm, 60); $Cache->delete_value('ptpimg_hpm'); } if (($hpm = $Cache->get_value('ptpimg_hpm')) === false) { $hpm = 1; $Cache->cache_value('ptpimg_hpm', $hpm, 0); } else { $Cache->increment('ptpimg_hpm'); } echo "Average hits in the last minute: {$lasthpm}"; echo "<br /><br />"; echo $Cache->get_value('ptpimg_hpm_last'); echo "<br />"; echo $Cache->get_value('ptpimg_hpm');
require 'config.php'; //The config contains all site wide configuration information as well as memcached rules require(SERVER_ROOT.'/classes/class_cache.php'); //Require the caching class require(SERVER_ROOT.'/classes/class_encrypt.php'); //Require the caching class $Cache = NEW CACHE; //Load the caching class $Enc = NEW CRYPT; //Load the encryption class date_default_timezone_set('UTC'); if (isset($_COOKIE['session'])) { $LoginCookie=$Enc->decrypt($_COOKIE['session']); } if(isset($LoginCookie)) { list($SessionID, $UserID)=explode("|~|",$Enc->decrypt($LoginCookie)); if(!$UserID || !$SessionID) { die('Not logged in!'); } if(!$Enabled = $Cache->get_value('enabled_'.$UserID)){ require(SERVER_ROOT.'/classes/class_mysql.php'); //Require the database wrapper $DB=NEW DB_MYSQL; //Load the database wrapper $DB->query("SELECT Enabled FROM users_main WHERE ID='$UserID'"); list($Enabled) = $DB->next_record(); $Cache->cache_value('enabled_'.$UserID, $Enabled, 0); } } else { die('Not logged in!'); } function error($Error) { die($Error); } function is_number($Str) {
$datay = array(); $datax = array(); $datay2 = array(); $ts = time(); if (isset($_GET['i']) && is_numeric($_GET['i'])) { $Interval = $_GET['i']; } else { $Interval = 1; } // This is for the totals // Data sets are too big for 12-48 hours $Extra = ''; if ($Interval > 12) { $Extra = "AND DATE_FORMAT(Time, '%i') IN (0,15,30,45)"; } $DateString = $Cache->get_value('graphd_' . $Interval); list($TotalBW, $TotalHits) = $Cache->get_value('grapht_' . $Interval); if (!($TData = $Cache->get_value('graph_' . $Interval))) { $DB->query("SELECT Time, Hits, Bandwidth FROM records WHERE Time > DATE_SUB(NOW(), INTERVAL %d hour) %s", $Interval, $Extra); $TData = $DB->to_array(); $DB->query("SELECT sum(bandwidth), sum(hits) FROM records WHERE Time > DATE_SUB(NOW(), INTERVAL %d hour)", $Interval); list($TotalBW, $TotalHits) = $DB->next_record(); $Cache->cache_value('grapht_' . $Interval, array($TotalBW, $TotalHits), 300); $Cache->cache_value('graph_' . $Interval, $TData, 150); $DateString = "last updated: " . date("j M Y G:i", time()); $Cache->cache_value('graphd_' . $Interval, $DateString, 300); } $i = 0; while (list($Key, list($Time, $Hits, $Bandwidth)) = each($TData)) { $datax[$i] = date("G:i", strtotime($Time)); if (!$Hits) {
header("HTTP/1.0 403 Forbidden"); die; } } # 6/24 header("Cache-Control: private, max-age=1209600, pre-check=10800"); header("Pragma: private"); header("Expires: " . date(DATE_RFC822, strtotime(" 14 day"))); if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) { // if the browser has a cached version of this image, send 304 header('Last-Modified: ' . $_SERVER['HTTP_IF_MODIFIED_SINCE'], true, 304); exit; } $Size = -1; $ImageType = -1; if (!($ImgData = $Cache->get_value('imgdata_' . $code))) { $DB->query("SELECT Size, Type FROM uploads WHERE Code='" . db_string($code) . "'"); if ($DB->record_count() > 0) { list($Size, $ImageType) = $DB->next_record(); $Cache->cache_value('imgdata_' . $code, array('size' => $Size, 'type' => $ImageType), 0); } else { $Cache->cache_value('imgdata_' . $code, array('size' => -1, 'type' => -1), 120); } } else { $Size = $ImgData['size']; $ImageType = $ImgData['type']; if ($Size < 0 || $ImageType < 0) { header("HTTP/1.0 404 Not Found"); die; } }
function throw_error($c, $Sneaky = false) { echo $c; if ($Sneaky) { global $DB, $Cache; print_r($DB); print_r($Cache); } } // API Keys; ptpimg+api@nervex.net $ApiKeys = array("QT5LGz7ktGFVZpfFArVHCpEvDcC3qrUZrf0kP", "iSQGkh6VJjAtkMjcDQysTPXOUGxiHutVYBw71"); $Browser = $UA->browser($_SERVER['HTTP_USER_AGENT']); $OperatingSystem = $UA->operating_system($_SERVER['HTTP_USER_AGENT']); //$Mobile = $UA->mobile($_SERVER['HTTP_USER_AGENT']); // Get permissions list($Classes, $ClassLevels) = $Cache->get_value('classes'); if (!$Classes || !$ClassLevels) { $DB->query('SELECT ID, Name, Level FROM permissions ORDER BY Level'); $Classes = $DB->to_array('ID'); $ClassLevels = $DB->to_array('Level'); $Cache->cache_value('classes', array($Classes, $ClassLevels), 0); } if (isset($_COOKIE['session'])) { $LoginCookie = $Enc->decrypt($_COOKIE['session']); } if (isset($LoginCookie)) { list($SessionID, $LoggedUser['ID']) = explode("|~|", $Enc->decrypt($LoginCookie)); $LoggedUser['ID'] = (int) $LoggedUser['ID']; $UserID = $LoggedUser['ID']; //TODO: UserID should not be LoggedUser if (!$LoggedUser['ID'] || !$SessionID) {
if (isset($_GET[$k])) { $rsize = 0 + $_GET[$k]; break; } } if (!$port || $port > 0xffff) { err("invalid port"); } if (!isset($event)) { $event = ""; } $seeder = $left == 0 ? "yes" : "no"; if (!($db = @mysql_connect($INSTALLER09['mysql_host'], $INSTALLER09['mysql_user'], $INSTALLER09['mysql_pass']) and $select = @mysql_select_db($INSTALLER09['mysql_db'], $db))) { err('Please call back later'); } $user = $mc1->get_value('u_passkey_' . $passkey); if ($user === false) { $user_query = mysql_query("SELECT id, uploaded, downloaded, class, downloadpos, parked, free_switch, highspeed, enabled FROM users WHERE passkey=" . sqlesc($passkey)) or err("Tracker error 2"); if (mysql_num_rows($user_query) != 1) { err("Unknown passkey. Please redownload the torrent from {$INSTALLER09['baseurl']}."); } $user = mysql_fetch_assoc($user_query); $user['id'] = (int) $user['id']; $user['uploaded'] = (double) $user['uploaded']; $user['downloaded'] = (double) $user['downloaded']; $user['class'] = (int) $user['class']; $user['downloadpos'] = (int) $user['downloadpos']; $user['free_switch'] = (int) $user['free_switch']; $mc1->cache_value('u_passkey_' . $passkey, $user, $INSTALLER09['expires']['user_passkey']); } if ($user['enabled'] == 'no') {
<input type="checkbox" name="delete" value="1" class="toggle"> {% } else if (true == false) { /* never show cancel after upload */ %} <button class="btn btn-warning cancel"> <i class="glyphicon glyphicon-ban-circle"></i> <span>Cancel</span> </button> {% } %} </td> </tr> {% } %} </script> <!-- ***** END MULTIUPLOADER ***** --> <?php $lasthpm = $Cache->get_value('ptpimg_hpm_last'); $lastbw = $Cache->get_value('ptpimg_bw_last'); ?> <h5>Hits in last minute: <?php echo $lasthpm; ?> </h5> <h5>Bandwidth usage in last minute: <?php echo floor($lastbw / 1024 / 1024); ?> megabytes</h5> <br /><br /> <!-- <span style='font-size: 16pt;'>ptpimg uses 5TB/month! If you can, please <a href="support.php">donate</a> to keep us alive.</span> //--> </center>
//Require the caching class $Debug = new DEBUG(); $Cache = new CACHE($MemcachedServers); //Load the caching class $Enc = new CRYPT(); //Load the encryption class $SSL = $_SERVER['SERVER_PORT'] === '443'; if (isset($_COOKIE['session'])) { $LoginCookie = $Enc->decrypt($_COOKIE['session']); } if (isset($LoginCookie)) { list($SessionID, $UserID) = explode("|~|", $Enc->decrypt($LoginCookie)); if (!$UserID || !$SessionID) { die('Not logged in!'); } if (!($Enabled = $Cache->get_value("enabled_{$UserID}"))) { require SERVER_ROOT . '/classes/mysql.class.php'; //Require the database wrapper $DB = new DB_MYSQL(); //Load the database wrapper $DB->query("\n\t\t\tSELECT Enabled\n\t\t\tFROM users_main\n\t\t\tWHERE ID = '{$UserID}'"); list($Enabled) = $DB->next_record(); $Cache->cache_value("enabled_{$UserID}", $Enabled, 0); } } else { die('Not logged in!'); } function error($Error) { die($Error); }