diff --git a/classes/class_file_checker.php b/classes/class_file_checker.php index 67829c5b..3cd50547 100644 --- a/classes/class_file_checker.php +++ b/classes/class_file_checker.php @@ -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"); diff --git a/classes/class_image_tools.php b/classes/class_image_tools.php index e8eb8b32..ec22e932 100644 --- a/classes/class_image_tools.php +++ b/classes/class_image_tools.php @@ -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; diff --git a/classes/script_start.php b/classes/script_start.php index a95004a9..8bedeaec 100644 --- a/classes/script_start.php +++ b/classes/script_start.php @@ -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 = ''; diff --git a/gazelle.sql b/gazelle.sql index 10c1239e..e423af8b 100644 --- a/gazelle.sql +++ b/gazelle.sql @@ -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, diff --git a/sections/requests/takenew_edit.php b/sections/requests/takenew_edit.php index 6cdadcf9..fe871bd7 100644 --- a/sections/requests/takenew_edit.php +++ b/sections/requests/takenew_edit.php @@ -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 { diff --git a/sections/tools/index.php b/sections/tools/index.php index a1a0d102..b3a92ecd 100644 --- a/sections/tools/index.php +++ b/sections/tools/index.php @@ -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'])) { diff --git a/sections/tools/managers/tag_aliases.php b/sections/tools/managers/tag_aliases.php new file mode 100644 index 00000000..24f317a7 --- /dev/null +++ b/sections/tools/managers/tag_aliases.php @@ -0,0 +1,82 @@ + 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'"); + } +} +?> + + + +

Tag Aliases

+ + + + + + + + + + + + + + + + query("SELECT ID,BadTag,AliasTag FROM tag_aliases ORDER BY " . $orderby); +while (list($ID, $BadTag, $AliasTag) = $DB -> next_record()) { + ?> + + + + + + + + + + +
TagRenamed FromSubmit
+ + + + + +
+ + + + + + +
+ diff --git a/sections/tools/tools.php b/sections/tools/tools.php index 89d1023d..50461f41 100644 --- a/sections/tools/tools.php +++ b/sections/tools/tools.php @@ -29,6 +29,8 @@ Email Blacklist Manage freeleech tokens Official Tags Manager + Tag Aliases + diff --git a/sections/torrents/add_tag.php b/sections/torrents/add_tag.php index 7b10da70..03b91459 100644 --- a/sections/torrents/add_tag.php +++ b/sections/torrents/add_tag.php @@ -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(); diff --git a/sections/upload/upload_handle.php b/sections/upload/upload_handle.php index 370e24c0..f2256a46 100644 --- a/sections/upload/upload_handle.php +++ b/sections/upload/upload_handle.php @@ -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])