Empty commit

This commit is contained in:
Git 2012-07-16 08:00:07 +00:00
parent 55300ee9e9
commit a7298a44cd
10 changed files with 125 additions and 4 deletions

View File

@ -5,7 +5,7 @@
"sfv","md5","accurip","ffp","pdf");
$ebooks_extensions = array("pdf", "nfo", "sfv", "mobi", "epub", "txt", "htm", "html", "lit",
"chm", "rtf", "doc", "jpg","jpeg","png","gif");
"chm", "rtf", "doc", "djv", "djvu", "jpg","jpeg","png","gif");
$comics_extensions = array("cbr", "cbz", "pdf", "jpg","jpeg","png","gif");

View File

@ -13,7 +13,7 @@ function check_imagehost($url) {
global $blacklist;
foreach ($blacklist as &$value) {
if(contains(strtolower($url), $value)) {
if(strpos(strtolower($url), $value)) {
$parsed_url = parse_url($url);
error($parsed_url['host'] . " is not an allowed imagehost. Please use a different imagehost.");
break;

View File

@ -1127,11 +1127,27 @@ function display_array($Array, $Escape = array()) {
function sanitize_tag($str) {
$str = strtolower($str);
$str = preg_replace('/[^a-z0-9.]/', '', $str);
$str = preg_replace('/(^[.,]*)|([.,]*$)/','',$str);
$str = htmlspecialchars($str);
$str = db_string(trim($str));
return $str;
}
/**
* Gets the alias of the tag, if there is no alias silently returns the original tag.
* @return the tag
*/
function get_alias_tag($str) {
global $DB;
$DB->query("SELECT AliasTag FROM tag_aliases WHERE BadTag = '". $str ."' LIMIT 1");
if($DB->record_count() > 0) {
list($AliasTag) = $DB->next_record();
return $AliasTag;
}
return $str;
}
// Generate a random string
function make_secret($Length = 32) {
$Secret = '';

View File

@ -801,6 +801,21 @@ CREATE TABLE `stylesheets` (
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
CREATE TABLE `subscribed_users` (
`UserID` int(10) NOT NULL,
`SubscriberID` int(10) NOT NULL,
PRIMARY KEY (`UserID`,`SubscriberID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
CREATE TABLE `tag_aliases` (
`ID` int(10) NOT NULL AUTO_INCREMENT,
`BadTag` varchar(22) COLLATE utf8_bin NOT NULL,
`AliasTag` varchar(22) COLLATE utf8_bin NOT NULL,
PRIMARY KEY (`ID`),
KEY `BadTag` (`BadTag`),
KEY `AliasTag` (`AliasTag`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
CREATE TABLE `tags` (
`ID` int(10) NOT NULL AUTO_INCREMENT,
`Name` varchar(100) COLLATE utf8_bin DEFAULT NULL,

View File

@ -90,7 +90,7 @@
if(empty($_POST['image'])) {
$Image = "";
} else {
check_imagehost($Image);
check_imagehost($_POST['image']);
if(preg_match("/".IMAGE_REGEX."/", trim($_POST['image'])) > 0) {
$Image = trim($_POST['image']);
} else {

View File

@ -158,7 +158,10 @@
include('managers/official_tags.php');
break;
case 'permissions':
case 'tag_aliases':
include('managers/tag_aliases.php');
break;
case 'permissions':
if (!check_perms('admin_manage_permissions')) { error(403); }
if (!empty($_REQUEST['id'])) {

View File

@ -0,0 +1,82 @@
<?php
if (!check_perms('users_mod')) { error(403);
}
show_header('Tag Aliases');
$orderby = ($_GET['order']) == "badtags" ? "BadTag" : "AliasTag";
if (isset($_POST['newalias'])) {
$badtag = mysql_escape_string($_POST['badtag']);
$aliastag = mysql_escape_string($_POST['aliastag']);
$DB -> query("INSERT INTO tag_aliases (BadTag, AliasTag) VALUES ('$badtag', '$aliastag')");
}
if (isset($_POST['changealias'])) {
$aliasid = $_POST['aliasid'];
$badtag = mysql_escape_string($_POST['badtag']);
$aliastag = mysql_escape_string($_POST['aliastag']);
if ($_POST['save']) {
$DB -> query("UPDATE tag_aliases SET BadTag = '$badtag', AliasTag = '$aliastag' WHERE ID = '$aliasid' ");
}
if ($_POST['delete']) {
$DB -> query("DELETE FROM tag_aliases WHERE ID = '$aliasid'");
}
}
?>
<div class="linkbox">
[<a href="tools.php?action=tag_aliases&order=goodtags">Sort by Good Tags</a>]
[<a href="tools.php?action=tag_aliases&order=badtags">Sort by Bad Tags</a>]
</div>
<h2>Tag Aliases</h2>
<table width="100%">
<tr class="colhead">
<td>Tag</td>
<td>Renamed From</td>
<td>Submit</td>
</tr>
<tr/>
<tr>
<form method="post">
<input type="hidden" name="newalias" value="1" />
<td>
<input type="text" name="aliastag"/>
</td>
<td>
<input type="text" name="badtag"/>
</td>
<td>
<input type="submit" value="Add Alias"/>
</td>
</form>
</tr>
<?
$DB->query("SELECT ID,BadTag,AliasTag FROM tag_aliases ORDER BY " . $orderby);
while (list($ID, $BadTag, $AliasTag) = $DB -> next_record()) {
?>
<tr>
<form method="post">
<input type="hidden" name="changealias" value="1" />
<input type="hidden" name="aliasid" value="<?=$ID?>" />
<td>
<input type="text" name="aliastag" value="<?=$AliasTag?>"/>
</td>
<td>
<input type="text" name="badtag" value="<?=$BadTag?>"/>
</td>
<td>
<input type="submit" name="save" value="Save Alias"/>
<input type="submit" name="delete" value="Delete Alias"/>
</td>
</form>
</tr>
<? }?>
</table>
<?
show_footer();
?>

View File

@ -29,6 +29,8 @@
<tr><td><a href="tools.php?action=email_blacklist">Email Blacklist</a></td></tr>
<tr><td><a href="tools.php?action=tokens">Manage freeleech tokens</a></td></tr>
<tr><td><a href="tools.php?action=official_tags">Official Tags Manager</a></td></tr>
<tr><td><a href="tools.php?action=tag_aliases">Tag Aliases</a></td></tr>
<? } ?>
</table>

View File

@ -11,7 +11,9 @@
$Tags = explode(',', $_POST['tagname']);
foreach($Tags as $TagName) {
$TagName = sanitize_tag($TagName);
if(!empty($TagName)) {
$TagName = get_alias_tag($TagName);
// Check DB for tag matching name
$DB->query("SELECT t.ID FROM tags AS t WHERE t.Name LIKE '".$TagName."'");
list($TagID) = $DB->next_record();

View File

@ -599,6 +599,7 @@
foreach($Tags as $Tag) {
$Tag = sanitize_tag($Tag);
if(!empty($Tag)) {
$Tag = get_alias_tag($Tag);
$DB->query("INSERT INTO tags
(Name, UserID) VALUES
('".$Tag."', $LoggedUser[ID])