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); } if ($Enabled == 2) { logout(); } // Up/Down stats $UserStats = $Cache->get_value('user_stats_' . $LoggedUser['ID']); if (!is_array($UserStats)) { $DB->query("\n\t\t\tSELECT Uploaded AS BytesUploaded, Downloaded AS BytesDownloaded, RequiredRatio\n\t\t\tFROM users_main\n\t\t\tWHERE ID = '{$LoggedUser['ID']}'"); $UserStats = $DB->next_record(MYSQLI_ASSOC); $Cache->cache_value('user_stats_' . $LoggedUser['ID'], $UserStats, 3600); } // Get info such as username $LightInfo = Users::user_info($LoggedUser['ID']); $HeavyInfo = Users::user_heavy_info($LoggedUser['ID']);
strlen($_GET['passkey']) != 32 || strlen($_GET['auth']) != 32 ) { $Feed->open_feed(); $Feed->channel('Blocked', 'RSS feed.'); $Feed->close_feed(); die(); } $User = (int)$_GET['user']; if(!$Enabled = $Cache->get_value('enabled_'.$User)){ require(SERVER_ROOT.'/classes/class_mysql.php'); $DB=NEW DB_MYSQL; //Load the database wrapper $DB->query("SELECT Enabled FROM users_main WHERE ID='$User'"); list($Enabled) = $DB->next_record(); $Cache->cache_value('enabled_'.$User, $Enabled, 0); } if (md5($User.RSS_HASH.$_GET['passkey']) != $_GET['auth'] || $Enabled != 1) { $Feed->open_feed(); $Feed->channel('Blocked', 'RSS feed.'); //</strip> /* for($i = 1; $i<50; $i++) { $Item = $Feed->item('Banned for being a douchebag x'.rand(), 'I have been banned from What.CD for being a complete jerk. In fact, you could say that I am over '.rand().' times as much of a douchebag as the next biggest douchebag on earth. That\'s a lot!', 'http://what.cd/torrents.php?id='.rand(), 'What.CD staff', 'http://what.cd?id='.rand(), 'scumoftheearth'); $Feed->populate('feed_banned', $Item); } $Feed->retrieve('feed_banned',$_GET['authkey'],$_GET['passkey']); */ //</strip>
if ((list($Size) = $Cache->get_value('ptpimg_sql_size')) === false) { $DB->query("SELECT SUM(Size) FROM uploads"); list($Size) = $DB->next_record(); $Cache->cache_value('ptpimg_sql_size', array($Size), 60); // 30 minutes } return $Size; } switch ($Action) { case 'random': // random $Count = getImageCount(); // Grab image count $Rand = rand(1, $Count); $DB->query("SELECT Code, Type, Size FROM uploads LIMIT {$Rand}, 1"); list($Code, $Type, $Size) = $DB->next_record(); echo json_encode(array(array('code' => $Code, 'type' => $Type, 'size' => $Size))); break; case 'last5': // last5 $DB->query("SELECT Code, Type, Size FROM uploads ORDER BY ID DESC LIMIT 5"); $Data = array(); while (list($Code, $Type, $Size) = $DB->next_record()) { $Data[] = array('code' => $Code, 'type' => $Type, 'size' => $Size); } echo json_encode(array($Data)); break; case 'stats': // stats $Size = getTotalSize(); $Count = getImageCount();
} 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) { $Hits = 0; } if (!$Bandwidth) { $Bandwidth = 0; } $datay[$i] = $Hits;
$_GET['act'] = "def_action"; } switch ($_GET['act']) { case 'login': case 'logout': //------------------- // LOGIN/LOGOUT //------------------- if (isset($_GET['act']) && $_GET['act'] == "logout") { logout(); } // Process the input if (!empty($_GET['tkl'])) { if (isset($_POST['username']) && preg_match('/^[a-z0-9_?]{1,20}$/iD', $_POST['username']) && strlen($_POST['password']) < 40) { $DB->query("SELECT\n\t\t\t\t\tID,\n\t\t\t\t\tPassword,\n\t\t\t\t\tSecret,\n\t\t\t\t\tEnabled\n\t\t\t\t\tFROM users WHERE Username='******'username']) . "'\n\t\t\t\t\tAND Username<>''"); list($UserID, $PassHash, $Secret, $Enabled) = $DB->next_record(); if ($UserID && $PassHash == make_hash($_POST['password'], $Secret) && $Enabled == 1) { $User->doLogin($UserID); if (empty($_POST['ref_page'])) { header("Location: index.php"); } else { $URL = base64_decode($_POST['ref_page']); if (preg_match('/^\\/[a-zA-Z0-9]+\\.php/i', $URL)) { header("Location: {$URL}"); } else { header("Location: index.php"); } } exit; } else { echo "<font color='red'><strong>BAD USERNAME/PASSWORD, try again</strong></font>";
die("404/Invalid API key"); } while ($code = randFN()) { if (!file_exists('raw/$code')) { break; } } $Data = getdata($_FILES['uploadfile']['tmp_name']); $res = $Data['res']; $ext = $Data['ext']; $hash = $Data['md5']; $size = $Data['size']; $ImageType = $Data['type']; $DB->query("SELECT Code, Extension FROM uploads WHERE NewHash='" . db_string($hash) . "'"); if ($DB->record_count() > 0) { list($Code, $Extension) = $DB->next_record(); $results[] = array("status" => 13, "code" => $Code, "ext" => $Extension); echo $Code . '.' . $Extension; die; } // Flush image contents to a temp file //$src=tempnam("/tmp", "ptpimg."); $src = "raw/{$code}"; if (!move_uploaded_file($_FILES['uploadfile']['tmp_name'], $src)) { die("error"); } $results = array(); $DB->query("INSERT INTO uploads (NewHash, UserID, Extension, Code, Resolution, Size, Type) VALUES('" . db_string($hash) . "', '" . db_string($_GET['uid']) . "', '" . db_string($ext) . "', '" . db_string($code) . "', '" . db_string($res) . "', '" . db_string($size) . "', '" . db_string($ImageType) . "')"); if ($DB->affected_rows() > 0) { // Serialized returns with status code 1 $results[] = array("status" => 1, "code" => $code, "ext" => $ext);
<? $UserStats = $Cache->get_value('user_stats_'.$UserID); if(!is_array($UserStats)) { if (!isset($DB)) { require(SERVER_ROOT.'/classes/class_mysql.php'); $DB = new DB_MYSQL; } $DB->query("SELECT Uploaded AS BytesUploaded, Downloaded AS BytesDownloaded, RequiredRatio FROM users_main WHERE ID='$UserID'"); $UserStats = $DB->next_record(MYSQLI_ASSOC); $Cache->cache_value('user_stats_'.$LoggedUser['ID'], $UserStats, 3600); } $Up = $UserStats['BytesUploaded']; $Down = $UserStats['BytesDownloaded']; $ReqRat = $UserStats['RequiredRatio']; if ($Down > 0) { $Rat = $Up/$Down; } else { $Rat = 0; } ?> <uploaded><?php echo $Up; ?> </uploaded> <downloaded><?php echo $Down; ?> </downloaded> <ratio><?php echo $Rat; ?>