Exemplo n.º 1
0
 /**
  * Create a service
  * @link     https://apidocs.serverdensity.com/?python#creating-a-service
  * @param    array  $service with all it's attributes.
  * @return   an array that is the device.
  */
 public function create($service, array $tagNames = array())
 {
     if (!empty($tagNames)) {
         $tagEndpoint = new Tags($this->client);
         $tags = $tagEndpoint->findAll($tagNames);
         if (!empty($tags['notFound'])) {
             foreach ($tags['notFound'] as $name) {
                 $tags['tags'][] = $tagEndpoint->create($name);
             }
         }
         $formattedTags = $tagEndpoint->format($tags['tags'], 'other');
         $service['tags'] = $formattedTags['tags'];
     }
     $service = $this->makeJsonReady($service);
     return $this->post('inventory/services/', $service);
 }
Exemplo n.º 2
0
 /**
  * Create a user
  * @link     https://apidocs.serverdensity.com/#creating-a-user
  * @param    array $user
  * @return   an array with the user that got created
  */
 public function create(array $user, array $tagNames = array())
 {
     if (!empty($tagNames)) {
         $tagEndpoint = new Tags($this->client);
         $tags = $tagEndpoint->findAll($tagNames);
         if (!empty($tags['notFound'])) {
             foreach ($tags['notFound'] as $name) {
                 $tags['tags'][] = $tagEndpoint->create($name);
             }
         }
         $formattedTags = $tagEndpoint->format($tags['tags'], 'user');
         // don't overwrite permission array if user creates his own.
         if (!empty($user['permissions'])) {
             $user['permissions'] = array_merge($user['permissions'], $formattedTags);
         } else {
             $user['permissions'] = $formattedTags;
         }
     }
     $user = $this->makeJsonReady($user);
     return $this->post('users/users/', $user);
 }
Exemplo n.º 3
0
            ?>
					<span class="add_bookmark float_right">
						<a style="float: right;" href="#" id="bookmarklink_torrent_<?php 
            echo $GroupID;
            ?>
" class="add_bookmark brackets" onclick="Bookmark('torrent', <?php 
            echo $GroupID;
            ?>
, 'Remove bookmark'); return false;">Bookmark</a>
					</span>
<?php 
        }
        Votes::vote_link($GroupID, $UserVote);
        ?>
					<div class="tags"><?php 
        echo $TorrentTags->format();
        ?>
</div>
				</td>
			</tr>
<?php 
        $LastRemasterYear = '-';
        $LastRemasterTitle = '';
        $LastRemasterRecordLabel = '';
        $LastRemasterCatalogueNumber = '';
        $LastMedia = '';
        $EditionID = 0;
        unset($FirstUnknown);
        foreach ($Torrents as $TorrentID => $Torrent) {
            if ($Torrent['Remastered'] && !$Torrent['RemasterYear']) {
                $FirstUnknown = !isset($FirstUnknown);
Exemplo n.º 4
0
                    ?>
					<div class="group_image float_left clear">
						<?php 
                    ImageTools::cover_thumb($WikiImage, $GroupCategoryID);
                    ?>
					</div>
<?php 
                }
                ?>
					<div class="group_info clear">
						<strong><?php 
                echo $DisplayName;
                ?>
</strong>
						<div class="tags"><?php 
                echo $TorrentTags->format();
                ?>
</tags>
					</div>
				</td>
			</tr>
<?php 
                $LastRemasterYear = '-';
                $LastRemasterTitle = '';
                $LastRemasterRecordLabel = '';
                $LastRemasterCatalogueNumber = '';
                $LastMedia = '';
                $EditionID = 0;
                unset($FirstUnknown);
                foreach ($Torrents as $TorrentID => $Torrent) {
                    if ($Torrent['Remastered'] && !$Torrent['RemasterYear']) {
Exemplo n.º 5
0
, 'Bookmark'); return false;">Remove bookmark</a>
				</span>
<?	} else { ?>
				<span class="add_bookmark float_right">
					<a href="#" id="bookmarklink_torrent_<?php 
echo $GroupID;
?>
" class="brackets" onclick="Bookmark('torrent', <?php 
echo $GroupID;
?>
, 'Remove bookmark'); return false;">Bookmark</a>
				</span>
<?	} ?>
				<br />
				<div class="tags"><?php 
echo $TorrentTags->format('torrents.php?' . $Action . '&amp;taglist=');
?>
</div>
			</div>
		</td>
		<td class="nobr"><?php 
echo time_diff($GroupTime, 1);
?>
</td>
		<td class="number_column nobr"><?php 
echo Format::get_size($MaxSize);
?>
 (Max)</td>
		<td class="number_column"><?php 
echo number_format($TotalSnatched);
?>
Exemplo n.º 6
0
            echo $LoggedUser['AuthKey'];
            ?>
&amp;torrent_pass=<?php 
            echo $LoggedUser['torrent_pass'];
            ?>
" title="Download" class="brackets tooltip">DL</a>
				</span>
				<?php 
            echo $DisplayName;
            ?>
				<div class="torrent_info"><?php 
            echo $Edition['EditionName'];
            ?>
</div>
				<div class="tags"><?php 
            echo $TorrentTags->format('better.php?action=transcode&tags=');
            ?>
</div>
			</td>
			<td><?php 
            echo isset($Edition['MP3s']['V2 (VBR)']) ? '<strong class="important_text_alt">YES</strong>' : '<strong class="important_text">NO</strong>';
            ?>
</td>
			<td><?php 
            echo isset($Edition['MP3s']['V0 (VBR)']) ? '<strong class="important_text_alt">YES</strong>' : '<strong class="important_text">NO</strong>';
            ?>
</td>
			<td><?php 
            echo isset($Edition['MP3s']['320']) ? '<strong class="important_text_alt">YES</strong>' : '<strong class="important_text">NO</strong>';
            ?>
</td>
Exemplo n.º 7
0
        ?>
&amp;torrent_pass=<?php 
        echo $LoggedUser['torrent_pass'];
        ?>
" class="tooltip" title="Download">DL</a>
						| <a href="reportsv2.php?action=report&amp;id=<?php 
        echo $TorrentID;
        ?>
" class="tooltip" title="Report">RP</a> ]
					</span>
					<?php 
        echo "{$DisplayName}\n";
        Votes::vote_link($GroupID, isset($UserVotes[$GroupID]) ? $UserVotes[$GroupID]['Type'] : '');
        ?>
					<div class="tags"><?php 
        echo $TorrentTags->format('torrents.php?type=' . $Action . '&amp;userid=' . $UserID . '&amp;tags=');
        ?>
</div>
				</div>
			</td>
			<td class="nobr"><?php 
        echo time_diff($Time, 1);
        ?>
</td>
			<td class="number_column nobr"><?php 
        echo Format::get_size($Torrent['Size']);
        ?>
</td>
			<td class="number_column"><?php 
        echo number_format($Torrent['Snatched']);
        ?>
Exemplo n.º 8
0
function generate_torrent_table($Caption, $Tag, $Details, $Limit)
{
    global $LoggedUser, $Categories, $ReleaseTypes, $GroupBy;
    ?>
		<h3>Top <?php 
    echo "{$Limit} {$Caption}";
    if (empty($_GET['advanced'])) {
        ?>
		<small class="top10_quantity_links">
<?php 
        switch ($Limit) {
            case 100:
                ?>
				- <a href="top10.php?details=<?php 
                echo $Tag;
                ?>
" class="brackets">Top 10</a>
				- <span class="brackets">Top 100</span>
				- <a href="top10.php?type=torrents&amp;limit=250&amp;details=<?php 
                echo $Tag;
                ?>
" class="brackets">Top 250</a>
<?php 
                break;
            case 250:
                ?>
				- <a href="top10.php?details=<?php 
                echo $Tag;
                ?>
" class="brackets">Top 10</a>
				- <a href="top10.php?type=torrents&amp;limit=100&amp;details=<?php 
                echo $Tag;
                ?>
" class="brackets">Top 100</a>
				- <span class="brackets">Top 250</span>
<?php 
                break;
            default:
                ?>
				- <span class="brackets">Top 10</span>
				- <a href="top10.php?type=torrents&amp;limit=100&amp;details=<?php 
                echo $Tag;
                ?>
" class="brackets">Top 100</a>
				- <a href="top10.php?type=torrents&amp;limit=250&amp;details=<?php 
                echo $Tag;
                ?>
" class="brackets">Top 250</a>
<?php 
        }
        ?>
		</small>
<?php 
    }
    ?>
		</h3>
	<table class="torrent_table cats numbering border">
	<tr class="colhead">
		<td class="center" style="width: 15px;"></td>
		<td class="cats_col"></td>
		<td>Name</td>
		<td style="text-align: right;">Size</td>
		<td style="text-align: right;">Data</td>
		<td style="text-align: right;" class="sign snatches"><img src="static/styles/<?php 
    echo $LoggedUser['StyleName'];
    ?>
/images/snatched.png" alt="Snatches" title="Snatches" class="tooltip" /></td>
		<td style="text-align: right;" class="sign seeders"><img src="static/styles/<?php 
    echo $LoggedUser['StyleName'];
    ?>
/images/seeders.png" alt="Seeders" title="Seeders" class="tooltip" /></td>
		<td style="text-align: right;" class="sign leechers"><img src="static/styles/<?php 
    echo $LoggedUser['StyleName'];
    ?>
/images/leechers.png" alt="Leechers" title="Leechers" class="tooltip" /></td>
		<td style="text-align: right;">Peers</td>
	</tr>
<?php 
    // Server is already processing a top10 query. Starting another one will make things slow
    if ($Details === false) {
        ?>
		<tr class="rowb">
			<td colspan="9" class="center">
				Server is busy processing another top list request. Please try again in a minute.
			</td>
		</tr>
		</table><br />
<?php 
        return;
    }
    // in the unlikely event that query finds 0 rows...
    if (empty($Details)) {
        ?>
		<tr class="rowb">
			<td colspan="9" class="center">
				Found no torrents matching the criteria.
			</td>
		</tr>
		</table><br />
<?php 
        return;
    }
    $Rank = 0;
    foreach ($Details as $Detail) {
        $GroupIDs[] = $Detail[1];
    }
    $Artists = Artists::get_artists($GroupIDs);
    foreach ($Details as $Detail) {
        list($TorrentID, $GroupID, $GroupName, $GroupCategoryID, $WikiImage, $TagsList, $Format, $Encoding, $Media, $Scene, $HasLog, $HasCue, $LogScore, $Year, $GroupYear, $RemasterTitle, $Snatched, $Seeders, $Leechers, $Data, $ReleaseType, $Size) = $Detail;
        $IsBookmarked = Bookmarks::has_bookmarked('torrent', $GroupID);
        $IsSnatched = Torrents::has_snatched($TorrentID);
        // highlight every other row
        $Rank++;
        $Highlight = $Rank % 2 ? 'a' : 'b';
        // generate torrent's title
        $DisplayName = '';
        if (!empty($Artists[$GroupID])) {
            $DisplayName = Artists::display_artists($Artists[$GroupID], true, true);
        }
        $DisplayName .= "<a href=\"torrents.php?id={$GroupID}&amp;torrentid={$TorrentID}\" class=\"tooltip\" title=\"View torrent\" dir=\"ltr\">{$GroupName}</a>";
        if ($GroupCategoryID == 1 && $GroupYear > 0) {
            $DisplayName .= " [{$GroupYear}]";
        }
        if ($GroupCategoryID == 1 && $ReleaseType > 0) {
            $DisplayName .= ' [' . $ReleaseTypes[$ReleaseType] . ']';
        }
        // append extra info to torrent title
        $ExtraInfo = '';
        $AddExtra = '';
        if (empty($GroupBy)) {
            if ($Format) {
                $ExtraInfo .= $Format;
                $AddExtra = ' / ';
            }
            if ($Encoding) {
                $ExtraInfo .= $AddExtra . $Encoding;
                $AddExtra = ' / ';
            }
            // "FLAC / Lossless / Log (100%) / Cue / CD";
            if ($HasLog) {
                $ExtraInfo .= $AddExtra . 'Log (' . $LogScore . '%)';
                $AddExtra = ' / ';
            }
            if ($HasCue) {
                $ExtraInfo .= $AddExtra . 'Cue';
                $AddExtra = ' / ';
            }
            if ($Media) {
                $ExtraInfo .= $AddExtra . $Media;
                $AddExtra = ' / ';
            }
            if ($Scene) {
                $ExtraInfo .= $AddExtra . 'Scene';
                $AddExtra = ' / ';
            }
            if ($Year > 0) {
                $ExtraInfo .= $AddExtra . $Year;
                $AddExtra = ' ';
            }
            if ($RemasterTitle) {
                $ExtraInfo .= $AddExtra . $RemasterTitle;
            }
            if ($IsSnatched) {
                if ($GroupCategoryID == 1) {
                    $ExtraInfo .= ' / ';
                }
                $ExtraInfo .= Format::torrent_label('Snatched!');
            }
            if ($ExtraInfo != '') {
                $ExtraInfo = "- [{$ExtraInfo}]";
            }
        }
        $TorrentTags = new Tags($TagsList);
        //Get report info, use the cache if available, if not, add to it.
        $Reported = false;
        $Reports = Torrents::get_reports($TorrentID);
        if (count($Reports) > 0) {
            $Reported = true;
        }
        // print row
        ?>
	<tr class="torrent row<?php 
        echo $Highlight . ($IsBookmarked ? ' bookmarked' : '') . ($IsSnatched ? ' snatched_torrent' : '');
        ?>
">
		<td style="padding: 8px; text-align: center;"><strong><?php 
        echo $Rank;
        ?>
</strong></td>
		<td class="center cats_col"><div title="<?php 
        echo $TorrentTags->title();
        ?>
" class="tooltip <?php 
        echo Format::css_category($GroupCategoryID);
        ?>
 <?php 
        echo $TorrentTags->css_name();
        ?>
"></div></td>
		<td class="big_info">
<?php 
        if ($LoggedUser['CoverArt']) {
            ?>
			<div class="group_image float_left clear">
				<?php 
            ImageTools::cover_thumb($WikiImage, $GroupCategoryID);
            ?>
			</div>
<?php 
        }
        ?>
			<div class="group_info clear">

				<span><a href="torrents.php?action=download&amp;id=<?php 
        echo $TorrentID;
        ?>
&amp;authkey=<?php 
        echo $LoggedUser['AuthKey'];
        ?>
&amp;torrent_pass=<?php 
        echo $LoggedUser['torrent_pass'];
        ?>
" title="Download" class="brackets tooltip">DL</a></span>

				<strong><?php 
        echo $DisplayName;
        ?>
</strong> <?php 
        echo $ExtraInfo;
        if ($Reported) {
            ?>
 - <strong class="torrent_label tl_reported">Reported</strong><?php 
        }
        if ($IsBookmarked) {
            ?>
				<span class="remove_bookmark float_right">
					<a href="#" id="bookmarklink_torrent_<?php 
            echo $GroupID;
            ?>
" class="bookmarklink_torrent_<?php 
            echo $GroupID;
            ?>
 brackets" onclick="Unbookmark('torrent', <?php 
            echo $GroupID;
            ?>
, 'Bookmark'); return false;">Remove bookmark</a>
				</span>
<?php 
        } else {
            ?>
				<span class="add_bookmark float_right">
					<a href="#" id="bookmarklink_torrent_<?php 
            echo $GroupID;
            ?>
" class="bookmarklink_torrent_<?php 
            echo $GroupID;
            ?>
 brackets" onclick="Bookmark('torrent', <?php 
            echo $GroupID;
            ?>
, 'Remove bookmark'); return false;">Bookmark</a>
				</span>
<?php 
        }
        ?>
				<div class="tags"><?php 
        echo $TorrentTags->format();
        ?>
</div>
			</div>
		</td>
		<td class="number_column nobr"><?php 
        echo Format::get_size($Size);
        ?>
</td>
		<td class="number_column nobr"><?php 
        echo Format::get_size($Data);
        ?>
</td>
		<td class="number_column"><?php 
        echo number_format((double) $Snatched);
        ?>
</td>
		<td class="number_column"><?php 
        echo number_format((double) $Seeders);
        ?>
</td>
		<td class="number_column"><?php 
        echo number_format((double) $Leechers);
        ?>
</td>
		<td class="number_column"><?php 
        echo number_format($Seeders + $Leechers);
        ?>
</td>
	</tr>
<?php 
    }
    //foreach ($Details as $Detail)
    ?>
	</table><br />
<?php 
}
Exemplo n.º 9
0
						<span class="add_bookmark float_right">
							<a style="float: right;" href="#" id="bookmarklink_torrent_<?php 
        echo $GroupID;
        ?>
" class="brackets" onclick="Bookmark('torrent', <?php 
        echo $GroupID;
        ?>
, 'Remove bookmark'); return false;">Bookmark</a>
						</span>
<?php 
    }
    $VoteType = isset($UserVotes[$GroupID]['Type']) ? $UserVotes[$GroupID]['Type'] : '';
    Votes::vote_link($GroupID, $VoteType);
    ?>
						<div class="tags"><?php 
    echo $TorrentTags->format('torrents.php?taglist=', $Name);
    ?>
</div>
					</div>
				</td>
			</tr>
<?php 
    $LastRemasterYear = '-';
    $LastRemasterTitle = '';
    $LastRemasterRecordLabel = '';
    $LastRemasterCatalogueNumber = '';
    $LastMedia = '';
    $EditionID = 0;
    unset($FirstUnknown);
    foreach ($Torrents as $TorrentID => $Torrent) {
        if ($Torrent['Remastered'] && !$Torrent['RemasterYear']) {
Exemplo n.º 10
0
    ?>
</a>
<?php 
    if ($BookmarkView) {
        ?>
			<span style="float: right;">
				<a href="#" onclick="Unbookmark('collage', <?php 
        echo $ID;
        ?>
, ''); return false;" class="brackets">Remove bookmark</a>
			</span>
<?php 
    }
    ?>
			<div class="tags"><?php 
    echo $TorrentTags->format('collages.php?action=search&amp;tags=');
    ?>
</div>
		</td>
		<td class="number_column"><?php 
    echo number_format((int) $NumTorrents);
    ?>
</td>
		<td class="number_column"><?php 
    echo number_format((int) $Subscribers);
    ?>
</td>
		<td class="nobr"><?php 
    echo time_diff($Updated);
    ?>
</td>