Ejemplo n.º 1
0
        list($ID, $Deleted) = $DB->next_record();
        if ($Deleted) {
            $Err = 'That collection already exists but needs to be recovered; please <a href="staffpm.php">contact</a> the staff team!';
        } else {
            $Err = "That collection already exists: <a href=\"/collages.php?id={$ID}\">{$ID}</a>.";
        }
    }
}
if (!$Err) {
    if (empty($CollageCats[$P['category']])) {
        $Err = 'Please select a category';
    }
}
if ($Err) {
    $Name = $_POST['name'];
    $Category = $_POST['category'];
    $Tags = $_POST['tags'];
    $Description = $_POST['description'];
    include SERVER_ROOT . '/sections/collages/new.php';
    die;
}
$TagList = explode(',', $_POST['tags']);
foreach ($TagList as $ID => $Tag) {
    $TagList[$ID] = Misc::sanitize_tag($Tag);
}
$TagList = implode(' ', $TagList);
$DB->query("\n\tINSERT INTO collages\n\t\t(Name, Description, UserID, TagList, CategoryID)\n\tVALUES\n\t\t('{$P['name']}', '{$P['description']}', {$LoggedUser['ID']}, '{$TagList}', '{$P['category']}')");
$CollageID = $DB->inserted_id();
$Cache->delete_value("collage_{$CollageID}");
Misc::write_log("Collage {$CollageID} (" . $_POST['name'] . ') was created by ' . $LoggedUser['Username']);
header("Location: collages.php?id={$CollageID}");
Ejemplo n.º 2
0
authorize();
if (!empty($LoggedUser['DisableTagging'])) {
    error(403);
}
$UserID = $LoggedUser['ID'];
$GroupID = $_POST['groupid'];
if (!is_number($GroupID) || !$GroupID) {
    error(0);
}
//Delete cached tag used for undos
if (isset($_POST['undo'])) {
    $Cache->delete_value("deleted_tags_{$GroupID}" . '_' . $LoggedUser['ID']);
}
$Tags = explode(',', $_POST['tagname']);
foreach ($Tags as $TagName) {
    $TagName = Misc::sanitize_tag($TagName);
    if (!empty($TagName)) {
        $TagName = Misc::get_alias_tag($TagName);
        // Check DB for tag matching name
        $DB->query("\n\t\t\tSELECT ID\n\t\t\tFROM tags\n\t\t\tWHERE Name LIKE '{$TagName}'");
        list($TagID) = $DB->next_record();
        if (!$TagID) {
            // Tag doesn't exist yet - create tag
            $DB->query("\n\t\t\t\tINSERT INTO tags (Name, UserID)\n\t\t\t\tVALUES ('{$TagName}', {$UserID})");
            $TagID = $DB->inserted_id();
        } else {
            $DB->query("\n\t\t\t\tSELECT TagID\n\t\t\t\tFROM torrents_tags_votes\n\t\t\t\tWHERE GroupID = '{$GroupID}'\n\t\t\t\t\tAND TagID = '{$TagID}'\n\t\t\t\t\tAND UserID = '{$UserID}'");
            if ($DB->has_results()) {
                // User has already voted on this tag, and is trying hax to make the rating go up
                header('Location: ' . $_SERVER['HTTP_REFERER']);
                die;
Ejemplo n.º 3
0
			</tr>
		</table>
	</form>
<br />
<?php 
if (isset($_GET['tag']) || isset($_GET['replace'])) {
    // validate input
    $Err = $Val->ValidateForm($_GET);
    if ($Err) {
        echo '
			<div class="box pad center">
				<strong>Error:</strong> ' . $Err . '
			</div>';
    } else {
        $Tag = Misc::sanitize_tag($_GET['tag']);
        $Replacement = Misc::sanitize_tag($_GET['replace']);
        // trying to merge tag with itself would create big problems
        if ($Tag == $Replacement) {
            echo "\n\t\t\t\t<div class=\"box pad center\">\n\t\t\t\t\t<strong>Error:</strong> Cannot merge tag {$Tag} with itself!\n\t\t\t\t</div>\n\t\t\t</div>";
            View::show_footer();
            exit;
        }
        // 1) make sure tag exists
        $DB->query("\n\t\t\tSELECT ID\n\t\t\tFROM tags\n\t\t\tWHERE Name = '{$Tag}'\n\t\t\tLIMIT 1;");
        if (!$DB->has_results()) {
            echo "\n\t\t\t\t<div class=\"box pad center\">\n\t\t\t\t\t<strong>Error:</strong> No such tag found: {$Tag}\n\t\t\t\t</div>\n\t\t\t</div>";
            View::show_footer();
            exit;
        }
        list($TagID) = $DB->next_record();
        // 2) check if replacement exists
Ejemplo n.º 4
0
        $DB->query("\n\t\t\tSELECT ReleaseType\n\t\t\tFROM torrents_group\n\t\t\tWHERE ID = '{$GroupID}'");
        list($Properties['ReleaseType']) = $DB->next_record();
    }
}
// Description
if (!$NoRevision) {
    $DB->query("\n\t\tINSERT INTO wiki_torrents\n\t\t\t(PageID, Body, UserID, Summary, Time, Image)\n\t\tVALUES\n\t\t\t({$GroupID}, {$T['GroupDescription']}, {$LoggedUser['ID']}, 'Uploaded new torrent', '" . sqltime() . "', {$T['Image']})");
    $RevisionID = $DB->inserted_id();
    // Revision ID
    $DB->query("\n\t\tUPDATE torrents_group\n\t\tSET RevisionID = '{$RevisionID}'\n\t\tWHERE ID = {$GroupID}");
}
// Tags
$Tags = explode(',', $Properties['TagList']);
if (!$Properties['GroupID']) {
    foreach ($Tags as $Tag) {
        $Tag = Misc::sanitize_tag($Tag);
        if (!empty($Tag)) {
            $Tag = Misc::get_alias_tag($Tag);
            $DB->query("\n\t\t\t\tINSERT INTO tags\n\t\t\t\t\t(Name, UserID)\n\t\t\t\tVALUES\n\t\t\t\t\t('{$Tag}', {$LoggedUser['ID']})\n\t\t\t\tON DUPLICATE KEY UPDATE\n\t\t\t\t\tUses = Uses + 1;\n\t\t\t");
            $TagID = $DB->inserted_id();
            $DB->query("\n\t\t\t\tINSERT INTO torrents_tags\n\t\t\t\t\t(TagID, GroupID, UserID, PositiveVotes)\n\t\t\t\tVALUES\n\t\t\t\t\t({$TagID}, {$GroupID}, {$LoggedUser['ID']}, 10)\n\t\t\t\tON DUPLICATE KEY UPDATE\n\t\t\t\t\tPositiveVotes = PositiveVotes + 1;\n\t\t\t");
        }
    }
}
// Use this section to control freeleeches
$T['FreeLeech'] = 0;
$T['FreeLeechType'] = 0;
$LogScore = $HasLog == 1 ? $LogScoreAverage : 0;
// Torrent
$DB->query("\n\tINSERT INTO torrents\n\t\t(GroupID, UserID, Media, Format, Encoding,\n\t\tRemastered, RemasterYear, RemasterTitle, RemasterRecordLabel, RemasterCatalogueNumber,\n\t\tScene, HasLog, HasCue, info_hash, FileCount, FileList, FilePath,\n\t\tSize, Time, Description, LogScore, FreeTorrent, FreeLeechType)\n\tVALUES\n\t\t({$GroupID}, {$LoggedUser['ID']}, {$T['Media']}, {$T['Format']}, {$T['Encoding']},\n\t\t{$T['Remastered']}, {$T['RemasterYear']}, {$T['RemasterTitle']}, {$T['RemasterRecordLabel']}, {$T['RemasterCatalogueNumber']},\n\t\t{$T['Scene']}, '{$HasLog}', '{$HasCue}', '" . db_string($InfoHash) . "', {$NumFiles}, '{$FileString}', '{$FilePath}',\n\t\t{$TotalSize}, '" . sqltime() . "', {$T['TorrentDescription']}, {$LogScore}, '{$T['FreeLeech']}', '{$T['FreeLeechType']}')");
$Cache->increment('stats_torrent_count');
Ejemplo n.º 5
0
    if (!in_array($Type, array('c.name', 'description'))) {
        $Type = 'c.name';
    }
} else {
    $Type = 'c.name';
}
if (!empty($_GET['search'])) {
    // What are we looking for? Let's make sure it isn't dangerous.
    $Search = db_string(trim($_GET['search']));
    // Break search string down into individual words
    $Words = explode(' ', $Search);
}
if (!empty($_GET['tags'])) {
    $Tags = explode(',', db_string(trim($_GET['tags'])));
    foreach ($Tags as $ID => $Tag) {
        $Tags[$ID] = Misc::sanitize_tag($Tag);
    }
}
if (!empty($_GET['cats'])) {
    $Categories = $_GET['cats'];
    foreach ($Categories as $Cat => $Accept) {
        if (empty($CollageCats[$Cat]) || !$Accept) {
            unset($Categories[$Cat]);
        }
    }
    $Categories = array_keys($Categories);
} else {
    $Categories = array(1, 2, 3, 4, 5, 6, 7);
}
// Ordering
if (!empty($_GET['order_by']) && !empty($OrderTable[$_GET['order_by']])) {
Ejemplo n.º 6
0
    error(403);
}
if (isset($_POST['doit'])) {
    authorize();
    if (isset($_POST['oldtags'])) {
        $OldTagIDs = $_POST['oldtags'];
        foreach ($OldTagIDs as $OldTagID) {
            if (!is_number($OldTagID)) {
                error(403);
            }
        }
        $OldTagIDs = implode(', ', $OldTagIDs);
        $DB->query("\n\t\t\tUPDATE tags\n\t\t\tSET TagType = 'other'\n\t\t\tWHERE ID IN ({$OldTagIDs})");
    }
    if ($_POST['newtag']) {
        $TagName = Misc::sanitize_tag($_POST['newtag']);
        $DB->query("\n\t\t\tSELECT ID\n\t\t\tFROM tags\n\t\t\tWHERE Name LIKE '{$TagName}'");
        list($TagID) = $DB->next_record();
        if ($TagID) {
            $DB->query("\n\t\t\t\tUPDATE tags\n\t\t\t\tSET TagType = 'genre'\n\t\t\t\tWHERE ID = {$TagID}");
        } else {
            // Tag doesn't exist yet - create tag
            $DB->query("\n\t\t\t\tINSERT INTO tags\n\t\t\t\t\t(Name, UserID, TagType, Uses)\n\t\t\t\tVALUES\n\t\t\t\t\t('{$TagName}', " . $LoggedUser['ID'] . ", 'genre', 0)");
            $TagID = $DB->inserted_id();
        }
    }
    $Cache->delete_value('genre_tags');
}
View::show_header('Official Tags Manager');
?>
<div class="header">