예제 #1
0
	function make_tree(){
		$UserID = $this->UserID;
		global $DB;
?>
		<div class="invitetree pad">
<?
		$DB->query("SELECT 
			t1.TreePosition, 
			t1.TreeID, 
			t1.TreeLevel, 
			(SELECT 
				t2.TreePosition FROM invite_tree AS t2 
				WHERE TreeID=t1.TreeID AND TreeLevel=t1.TreeLevel AND t2.TreePosition>t1.TreePosition 
				ORDER BY TreePosition LIMIT 1
			) AS MaxPosition
			FROM invite_tree AS t1
			WHERE t1.UserID=$UserID");
		
		list($TreePosition, $TreeID, $TreeLevel, $MaxPosition) = $DB->next_record();
		if(!$MaxPosition){ $MaxPosition = 1000000; } // $MaxPermission is null if the user is the last one in that tree on that level
		if(!$TreeID){ return; }
		$DB->query("
			SELECT 
			it.UserID, 
			Username,
			Donor,
			Warned,
			Enabled,
			PermissionID,
			Uploaded,
			Downloaded,
			Paranoia,
			TreePosition,
			TreeLevel
			FROM invite_tree AS it
			JOIN users_main AS um ON um.ID=it.UserID
			JOIN users_info AS ui ON ui.UserID=it.UserID
			WHERE TreeID=$TreeID
			AND TreePosition>$TreePosition
			AND TreePosition<$MaxPosition
			AND TreeLevel>$TreeLevel
			ORDER BY TreePosition");
		
		$PreviousTreeLevel = $TreeLevel;
		
		// Stats for the summary
		$MaxTreeLevel = $TreeLevel; // The deepest level (this changes)
		$OriginalTreeLevel = $TreeLevel; // The level of the user we're viewing
		$BaseTreeLevel = $TreeLevel + 1; // The level of users invited by our user
		$Count = 0;
		$Branches = 0;
		$DisabledCount = 0;
		$DonorCount = 0;
		$ParanoidCount = 0;
		$TotalUpload = 0;
		$TotalDownload = 0;
		$TopLevelUpload = 0;
		$TopLevelDownload = 0;
		
		$ClassSummary = array();
		global $Classes;
		foreach ($Classes as $ClassID => $Val) {
			$ClassSummary[$ClassID] = 0;
		}
		
		// We store this in an output buffer, so we can show the summary at the top without having to loop through twice
		ob_start();
		while(list($ID, $Username, $Donor, $Warned, $Enabled, $Class, $Uploaded, $Downloaded, $Paranoia, $TreePosition, $TreeLevel) = $DB->next_record()){ 
			
			// Do stats
			$Count++;
			
			if($TreeLevel > $MaxTreeLevel){
				$MaxTreeLevel = $TreeLevel;
			}
			
			if($TreeLevel == $BaseTreeLevel){
				$Branches++;
				$TopLevelUpload += $Uploaded;
				$TopLevelDownload += $Downloaded;
			}
			
			$ClassSummary[$Class]++;
			if($Enabled == 2){
				$DisabledCount++;
			}
			if($Donor){
				$DonorCount++;
			}
			
			// Manage tree depth
			if($TreeLevel > $PreviousTreeLevel){
				for($i = 0; $i<$TreeLevel-$PreviousTreeLevel; $i++){ echo "<ul class=\"invitetree\">\n"; }
			} elseif($TreeLevel < $PreviousTreeLevel){
				for($i = 0; $i<$PreviousTreeLevel-$TreeLevel; $i++){ echo "</ul>\n"; }
			}
?>
			<li>
				<strong><?php 
echo format_username($ID, $Username, $Donor, $Warned, $Enabled == 2 ? false : true, $Class);
?>
</strong>
<?
			if ($Paranoia < 4 || check_perms('users_mod')) {
				$TotalUpload += $Uploaded;
				$TotalDownload += $Downloaded;
?>
				&nbsp;Uploaded: <strong><?php 
echo get_size($Uploaded);
?>
</strong>
				&nbsp;Downloaded: <strong><?php 
echo get_size($Downloaded);
?>
</strong>
				&nbsp;Ratio: <strong><?php 
echo ratio($Uploaded, $Downloaded);
?>
</strong>
<?
			} else {
				$ParanoidCount++;
?>
				&nbsp;Paranoia: <strong><?php 
echo number_format($Paranoia);
?>
</strong>
<?
			}
?>			
			</li>
<?			$PreviousTreeLevel = $TreeLevel;
		} 
		$Tree = ob_get_clean();
		if($Count){
		
?> 		<p style="font-weight: bold;">
			This tree has <?php 
echo $Count;
?>
 entries, <?php 
echo $Branches;
?>
 branches, and a depth of <?php 
echo $MaxTreeLevel - $OriginalTreeLevel;
?>
.
			It has
<?
			$ClassStrings = array();
			foreach ($ClassSummary as $ClassID => $ClassCount) {
				if($ClassCount == 0) { continue; }
				$LastClass = make_class_string($ClassID);
				if($ClassCount>1) { 
					if($LastClass == "Torrent Celebrity") {
						 $LastClass = 'Torrent Celebrities';
					} else {
						$LastClass.='s'; 
					}
				}
				$LastClass= $ClassCount.' '.$LastClass.' (' . number_format(($ClassCount/$Count)*100) . '%)';
				
				$ClassStrings []= $LastClass;
			}
			if(count($ClassStrings)>1){
				array_pop($ClassStrings);
				echo implode(', ', $ClassStrings);
				echo ' and '.$LastClass;
			} else {
				echo $LastClass;
			}
			echo '. ';
			echo $DisabledCount;
			echo ($DisabledCount==1)?' user is':' users are';
			echo ' disabled (';
			if($DisabledCount == 0) { echo '0%)'; }
			else { echo number_format(($DisabledCount/$Count)*100) . '%)';}
			echo ', and ';
			echo $DonorCount;
			echo ($DonorCount==1)?' user has':' users have';
			echo ' donated (';
			if($DonorCount == 0) { echo '0%)'; }
			else { echo number_format(($DonorCount/$Count)*100) . '%)';}
			echo '. </p>';
			
			echo '<p style="font-weight: bold;">';
			echo 'The total amount uploaded by the entire tree was '.get_size($TotalUpload);
			echo ', the total amount downloaded was '.get_size($TotalDownload);
			echo ', and the total ratio is '.ratio($TotalUpload, $TotalDownload).'. ';
			echo '</p>';
			
			echo '<p style="font-weight: bold;">';
			echo 'The total amount uploaded by direct invitees (the top level) was '.get_size($TopLevelUpload);
			echo ', the total amount downloaded was '.get_size($TopLevelDownload);
			echo ', and the total ratio is '.ratio($TopLevelUpload, $TopLevelDownload).'. ';
			
			
			echo 'These numbers include the stats of paranoid users, and will be factored in to the invitation giving script.</p>';
			
			
			if($ParanoidCount){
				echo '<p style="font-weight: bold;">';
				echo $ParanoidCount;
				echo ($ParanoidCount==1)?' user (':' users (';
				echo number_format(($ParanoidCount/$Count)*100);
				echo '%) ';
				echo ($ParanoidCount==1)?'  is':' are';
				echo ' too paranoid to have their stats shown here, and ';
				echo ($ParanoidCount==1)?'  was':' were';
				echo ' not factored into the stats for the total tree.';
				echo '</p>';
			}
		}
		
?>
		<br />
		<?php 
echo $Tree;
?>
		</div>
<?
	}
예제 #2
0
파일: search.php 프로젝트: morilo/ptpimg
		<table style="width:400px;margin:0px auto;">
			<tr class="colhead">
				<td width="50%">Username</td>
				<td>Class</td>
			</tr>
<?php 
foreach ($Results as $Result) {
    list($UserID, $Username, $Enabled, $PermissionID, $Donor, $Warned) = $Result;
    ?>
			<tr>
				<td><?php 
    echo format_username($UserID, $Username, $Donor, $Warned, $Enabled == 2 ? false : true);
    ?>
</td>
				<td><?php 
    echo make_class_string($PermissionID);
    ?>
</td>
			</tr>
<?php 
}
?>
		</table>
	</div>
	<div class="linkbox">
	<?php 
echo $Pages;
?>
	</div>
</div>
예제 #3
0
function format_username($UserID, $Username, $IsDonor = false, $IsWarned = '0000-00-00 00:00:00', $IsEnabled = true, $Class = false, $Title = false) {
	if($UserID == 0) {
		return 'System';
	} elseif($Username == '') {
		return "Unknown [$UserID]";
	}
	$str='<a href="user.php?id='.$UserID.'">'.$Username.'</a>';
	$str.=($IsDonor) ? '<a href="donate.php"><img src="'.STATIC_SERVER.'common/symbols/donor.png" alt="Donor" title="Donor" /></a>' : '';
	$str.=($IsWarned!='0000-00-00 00:00:00') ? '<img src="'.STATIC_SERVER.'common/symbols/warned.png" alt="Warned" title="Warned" />' : '';
	$str.=(!$IsEnabled) ? '<img src="'.STATIC_SERVER.'common/symbols/disabled.png" alt="Banned" title="Be good, and you won\'t end up like this user" />' : '';
	$str.=($Class) ? ' ('.make_class_string($Class).')' : '';
	$str.=($Title) ? ' ('.$Title.')' : '';
	return $str;
}
예제 #4
0
        if ($Logs095 === 100) {
            $Details = "";
        } else {
            $Results[] = "The original uploader has chosen to allow this log to be deducted one point for using EAC v0.95., -1 point [1]";
            $Details = db_string(serialize($Results));
        }
        $DB->query("UPDATE torrents SET LogScore = " . $Logs095 . " WHERE ID = " . $TorrentID);
        $DB->query("UPDATE torrents_logs_new SET Score = " . $Logs095 . ", Details = '" . $Details . "' WHERE TorrentID = " . $TorrentID);
        $DB->set_query_id($Logs);
    }
    $EditSummary[] = 'EAC v0.95 logs rescored to ' . $Logs095;
}
// Start building SQL query and edit summary
if ($Classes[$Class]['Level'] != $Cur['Class'] && ($Classes[$Class]['Level'] < $LoggedUser['Class'] && check_perms('users_promote_below', $Cur['Class']) || $Classes[$Class]['Level'] <= $LoggedUser['Class'] && check_perms('users_promote_to', $Cur['Class'] - 1))) {
    $UpdateSet[] = "PermissionID='{$Class}'";
    $EditSummary[] = "class changed to " . make_class_string($Class);
    $LightUpdates['PermissionID'] = $Class;
    $DB->query("SELECT DISTINCT DisplayStaff FROM permissions WHERE ID = {$Class} OR ID = " . $ClassLevels[$Cur['Class']]['ID']);
    if ($DB->record_count() == 2) {
        if ($Classes[$Class]['Level'] < $Cur['Class']) {
            $SupportFor = '';
        }
        $ClearStaffIDCache = true;
    }
}
if ($Username != $Cur['Username'] && check_perms('users_edit_usernames', $Cur['Class'] - 1)) {
    $DB->query("SELECT ID FROM users_main WHERE Username = '******'");
    if ($DB->next_record() > 0) {
        list($UsedUsernameID) = $DB->next_record();
        error("Username already in use by <a href='user.php?id=" . $UsedUsernameID . "'>" . $Username . "</a>");
        header("Location: user.php?id=" . $UserID);
예제 #5
0
            }
            $i++;
            $Errors = array();
            if ($LoggedUser['BytesUploaded'] < $Data['MinUpload']) {
                $Errors['Uploaded'] = "(" . get_size($Data['MinUpload'] - $LoggedUser['BytesUploaded']) . " left)";
            }
            if ($Uploads < $Data['MinUploads']) {
                $Errors['Uploads'] = "(" . number_format($Data['MinUploads'] - $Uploads) . " left)";
            }
            if ($LoggedUser['JoinDate'] > $Data['MaxTime']) {
                $Errors['Time'] = "(" . time_df($Data['MaxTime'], $LoggedUser['JoinDate']) . " left)";
            }
            ?>
						<tr>
							<td><h3><?php 
            echo make_class_string($Data['To']);
            ?>
</h3></td>
							<td><?php 
            echo number_format($Data['PointReq']);
            ?>
</td>
							<td>Uploaded: <span class="<?php 
            echo $Errors['Uploaded'] ? 'v2_red' : 'v2_green';
            ?>
"><?php 
            echo get_size($Data['MinUpload']);
            echo $Errors['Uploaded'] ? ' ' . $Errors['Uploaded'] : '';
            ?>
</span><br />
							<?php 
예제 #6
0
파일: sandbox2.php 프로젝트: morilo/ptpimg
              $Cache->commit_transaction(0);*/
            $Cache->delete_value('user_info_' . $UserID);
            $Cache->delete_value('user_info_heavy_' . $UserID);
            $Cache->delete_value('user_stats_' . $UserID);
            $Cache->delete_value('enabled_' . $UserID);
            $DB->query("UPDATE users_info SET AdminComment = CONCAT('" . sqltime() . " - Class changed to " . make_class_string($L['To']) . " by System\n\n', AdminComment) WHERE UserID = " . $UserID);
        }
        $DB->query("UPDATE users_main SET PermissionID=" . $L['To'] . " WHERE ID IN(" . implode(',', $UserIDs) . ")");
    }
    $Query = "SELECT ID FROM users_main JOIN users_info ON users_main.ID = users_info.UserID\n                        WHERE PermissionID='{$L['To']}'\n                        AND ( Uploaded<'{$L['MinUpload']}'\n                        OR (SELECT COUNT(ID) FROM torrents WHERE UserID=users_main.ID)<'{$L['MinUploads']}'";
    if (!empty($L['Extra'])) {
        $Query .= " OR NOT " . $L['Extra'];
    }
    $Query .= ")\n                        AND Enabled='1'\n                        AND ID NOT IN (213461)";
    $DB->query($Query);
    $UserIDs = $DB->collect('ID');
    if (count($UserIDs) > 0) {
        foreach ($UserIDs as $UserID) {
            /*$Cache->begin_transaction('user_info_'.$UserID);
              $Cache->update_row(false, array('PermissionID'=>$L['From']));
              $Cache->commit_transaction(0);*/
            $Cache->delete_value('user_info_' . $UserID);
            $Cache->delete_value('user_info_heavy_' . $UserID);
            $Cache->delete_value('user_stats_' . $UserID);
            $Cache->delete_value('enabled_' . $UserID);
            $DB->query("UPDATE users_info SET AdminComment = CONCAT('" . sqltime() . " - Class changed to " . make_class_string($L['From']) . " by System\n\n', AdminComment) WHERE UserID = " . $UserID);
        }
        $DB->query("UPDATE users_main SET PermissionID=" . $L['From'] . " WHERE ID IN(" . implode(',', $UserIDs) . ")");
    }
}
show_footer();
예제 #7
0
<?php

/**********************************************************************
 *>>>>>>>>>>>>>>>>>>>>>>>>>>> User search <<<<<<<<<<<<<<<<<<<<<<<<<<<<*
 **********************************************************************/
authorize(true);
if (!empty($_GET['search'])) {
    $_GET['username'] = $_GET['search'];
}
define('USERS_PER_PAGE', 30);
if (isset($_GET['username'])) {
    $_GET['username'] = trim($_GET['username']);
    list($Page, $Limit) = page_limit(USERS_PER_PAGE);
    $DB->query("SELECT SQL_CALC_FOUND_ROWS\n\t\tID,\n\t\tUsername,\n\t\tEnabled,\n\t\tPermissionID,\n\t\tDonor,\n\t\tWarned\n\t\tFROM users_main AS um\n\t\tJOIN users_info AS ui ON ui.UserID=um.ID\n\t\tWHERE Username LIKE '%" . db_string($_GET['username']) . "%'\n\t\tORDER BY Username\n\t\tLIMIT {$Limit}");
    $Results = $DB->to_array();
    $DB->query('SELECT FOUND_ROWS();');
    list($NumResults) = $DB->next_record();
}
$JsonUsers = array();
foreach ($Results as $Result) {
    list($UserID, $Username, $Enabled, $PermissionID, $Donor, $Warned) = $Result;
    $JsonUsers[] = array('userId' => $UserID, 'username' => $Username, 'donor' => $Donor, 'warned' => $Warned, 'enabled' => $Enabled == 2 ? false : true, 'class' => make_class_string($PermissionID));
}
print json_encode(array('status' => 'success', 'response' => array('currentPage' => $Page, 'pages' => ceil($NumResults / USERS_PER_PAGE), 'results' => $JsonUsers)));