当前位置: 首页>>代码示例>>PHP>>正文


PHP Misc::sanitize_tag方法代码示例

本文整理汇总了PHP中Misc::sanitize_tag方法的典型用法代码示例。如果您正苦于以下问题:PHP Misc::sanitize_tag方法的具体用法?PHP Misc::sanitize_tag怎么用?PHP Misc::sanitize_tag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Misc的用法示例。


在下文中一共展示了Misc::sanitize_tag方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: list

        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}");
开发者ID:Kufirc,项目名称:Gazelle,代码行数:31,代码来源:new_handle.php

示例2: authorize

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;
开发者ID:Kufirc,项目名称:Gazelle,代码行数:31,代码来源:add_tag.php

示例3: list

			</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
开发者ID:Kufirc,项目名称:Gazelle,代码行数:31,代码来源:tags.php

示例4: list

        $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');
开发者ID:Kufirc,项目名称:Gazelle,代码行数:31,代码来源:upload_handle.php

示例5: db_string

    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']])) {
开发者ID:Kufirc,项目名称:Gazelle,代码行数:31,代码来源:browse.php

示例6: error

    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">
开发者ID:Kufirc,项目名称:Gazelle,代码行数:31,代码来源:official_tags.php


注:本文中的Misc::sanitize_tag方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。