Login
Username: Password:
Remember me

[Sign Up] / [Recover Password]

Theme / Language

Popular
New Torrents
new name
Size: 18.40 MB
Most active
new name
S: 74 L: 3
New Posters
SuperTag [TTv3]
Controls ·  Search New posts · Mark unread

You are in: Forum / Forum / Torrent Trader / v3 Mods in Progress

2019-04-27 10:30:02
[color=rgb(251, 160, 38)]WARNING !!! Do not install on live site (for testing only)[/color]

Mod still has 3 issues torrent_tag table needs work, when click search brings white page & click torrent upload shows white page ( maybe both to do with table)

[color=rgb(251, 160, 38)]SQL[/color]
-
-- Table structure for table `tags`
--

CREATE TABLE `tags` (
 `id` int(10) UNSIGNED NOT NULL,
 `url` varchar(255) NOT NULL,
 `tag_id` int(20) UNSIGNED NOT NULL,
 `tag_name` varchar(60) NOT NULL DEFAULT '',
 `added_by` int(10) UNSIGNED NOT NULL DEFAULT '0',
 `banned_by` int(10) UNSIGNED NOT NULL,
 `tag_banned` enum('yes','no') NOT NULL DEFAULT 'no',
 `banned_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
 `banned_reason` varchar(255) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tags`
--

INSERT INTO `tags` (`id`, `url`, `tag_id`, `tag_name`, `added_by`, `banned_by`, `tag_banned`, `banned_date`, `banned_reason`) VALUES
(0, '', 2, 'test', 1, 0, 'no', '0000-00-00 00:00:00', ''),
(0, '', 3, 'slammin', 1, 0, 'no', '0000-00-00 00:00:00', '');

-- --------------------------------------------------------

--
-- Table structure for table `torrent_tags`
--

CREATE TABLE `torrent_tags` (
 `t.tag_banned` int(20) UNSIGNED NOT NULL,
 `tt.torrent_id` varchar(255) NOT NULL,
 `torrent_id` int(20) UNSIGNED NOT NULL,
 `added_by` varchar(255) NOT NULL,
 `tag_id` int(20) UNSIGNED NOT NULL,
 `tt.tag_id` int(20) UNSIGNED NOT NULL,
 `t.tag_name` varchar(255) NOT NULL,
 `t.tag_id` int(20) UNSIGNED NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

ALTER TABLE groups ADD `can_add_tags` enum('yes','no') NOT NULL DEFAULT 'no';

--
-- Indexes for table `tags`
--
ALTER TABLE `tags`
 ADD PRIMARY KEY (`tag_id`),
 ADD KEY `tag_name` (`tag_name`);


--
-- AUTO_INCREMENT for table `tags`
--
ALTER TABLE `tags`
 MODIFY `tag_id` int(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
COMMIT;


[color=rgb(251, 160, 38)]Backend/functions.php find[/color]
    print("<center><b>" . $message . "</b></center>\n");
   end_frame();


replace with
    if(is_array($message)){
       foreach($message as $m){
           print("<center><b>" . $m . "</b></center><br />");
       }
   } else {
       print("<center><b>" . $message . "</b></center>\n");
   }
   end_frame();


find
 
 SQL_Query_exec("DELETE FROM torrents WHERE id = $id");
   SQL_Query_exec("DELETE FROM reports WHERE votedfor = $id AND type = 'torrent'");


after add
 
  SQL_Query_exec("DELETE FROM torrent_tags WHERE torrent_id = " . $id);  


find
      return is_numeric($id) && ($id > 0) && (floor($id) == $id);
}


after add

       function get_tags(){
   return SQL_Query_exec("SELECT tag_id, tag_name from tags");
}
function get_tags_for_torrent($torrentId){
   return SQL_Query_exec(" SELECT tt.tag_id, t.tag_name FROM torrent_tags tt
                       LEFT JOIN tags t ON tt.tag_id = t.tag_id
                       WHERE tt.torrent_id = " . intval($torrentId) . "
                       AND t.tag_banned != 'Y'");
}

function is_valid_tag_name($tag){

   $res = mysqli_fetch_assoc(SQL_Query_exec("SELECT COUNT(tag_id) AS tc from tags WHERE tag_name = '" . mysqli_real_escape_string($GLOBALS["DBconnector"],$tag) . "'"));
   if ($res['tc'] != 0)
       return true;
   else
       return false;
}

function get_tag_id_from_name($tagName){
   $res = mysql_fetchi_assoc(SQL_Query_exec("SELECT tag_id, tag_banned from tags WHERE tag_name = '" . mysqli_real_escape_string($GLOBALS["DBconnector"],$tagName) . "'"));
   if ($res['tag_banned'] == 'Y'){
       return "banned";
   } else if ($res['tag_id']) {
       return $res['tag_id'];
   }
}

function add_new_tag($tagName){
   global $CURUSER;
   $tagName = strtolower(trim(preg_replace("/--+/", '-', preg_replace('/[^A-Za-z0-9\-]+/', '-', $tagName)), "-"));
   SQL_Query_exec("INSERT INTO tags
                           (tag_name, added_by)
                           VALUES
                           ('" . $tagName . "', '" . $CURUSER['id'] . "')");
   return mysqli_insert_id();
}

function add_tag_id_to_torrent($tagId, $torrentId){
   global $CURUSER;
   SQL_Query_exec("INSERT INTO torrent_tags (torrent_id, tag_id, added_by)
                           VALUES (" . intval($torrentId) . ", " . intval($tagId) . ", " . intval($CURUSER['id']) . ")");
}

function print_torrent_tags_js($placeholder, $initialTags=""){
   global $site_config;

   if($initialTags){
       $initialTags = implode('","', explode(",", htmlspecialchars($initialTags)));
   }

   // Grab tag names
   $tags = get_tags();
   while ($row = mysqli_fetch_array($tags)) {
       $autotags[] = $row['tag_name'];
   }

   ?>

   <script type="text/javascript">

       $('#tags').tagEditor({
           autocomplete: {
               delay: 0, // show suggestions immediately
               position: { collision: "flip" }, // automatic menu position up/down
               source: ["<?php echo implode('","',$autotags); ?>"]
           },
           forceLowercase: true,
           delimiter: ", ", /* space and comma */
           initialTags: [<?php echo '"' . $initialTags . '"'; ?>],
           placeholder: "<?php echo $placeholder; ?>",
           maxTags: <?php echo intval($site_config['max_torrent_tags']); ?>,
           removeDuplicates: true
       });

   </script>

   <?php
}


find
              print("<td class='ttable_col$x' nowrap='nowrap'>".(count($expandrows)?"<a href=\"javascript: klappe_torrent('t".$row['id']."')\"><img border=\"0\" src=\"".$site_config["SITEURL"]."/images/plus.gif\" id=\"pict".$row['id']."\" alt=\"Show/Hide\" class=\"showthecross\" /></a>":"")."&nbsp;<a title=\"".$row["name"]."\" href=\"torrents-details.php?id=$id&amp;hit=1\">$dispname</a></td>"); 


add after
                   
                $tags = get_tags_for_torrent($id);
               while ($row = mysqli_fetch_array($tags)) {
                   $tagHtml[] = "<a href='./torrents.php?tags=" . $row['tag_id'] . "'>" . $row['tag_name'] . "</a>";
               }
               //print_r($tagHtml);
               print($tagHtml ? "<br />&nbsp;<span class='tags'>" . implode(", ", $tagHtml) . "</span>" : "");
               print("</td>");
               unset($tagHtml);


[color=rgb(251, 160, 38)]admincp add link[/color]
<td align="center"><a href="admincp.php?action=tags"><img src="images/admin/hashtag.png" border="0" width="118" height="80" alt="" /><br />Tags<br /></a></td>


add at bottom before ?
#======================================================================#
#  TAGS by Mjay
#======================================================================#

if ($action == "tags") {
   stdhead("tags Manager");
   navmenu();

   if ($do == "del") {
       if (!@count($_POST["ids"])) show_error_msg("Error", "select nothing.", 1);
       $ids = array_map("intval", $_POST["ids"]);
       $ids = implode(", ", $ids);
       
       SQL_Query_exec("DELETE FROM `tags` WHERE `tag_id` IN ($ids)");
       autolink("admincp.php?action=tags", "Deleted Entries");
   }

   if ($do == "add") {
       $tag_name = trim($_POST["tag_name"]);
       if (empty($tag_name))
           show_error_msg(T_("ERROR"), T_("MISSING_FORM_DATA").". Go back and try again", 1);

       if (!is_valid_tag_name($tag_name)){
           add_new_tag($tag_name);
           switch (mysqli_errno($GLOBALS["DBconnector"])) {
               case 0:
                   show_error_msg(T_("SUCCESS"), "Tag added.", 0);
               break;
               default:
                   show_error_msg(T_("ERROR"), T_("THEME_DATEBASE_ERROR")." ".htmlspecialchars(mysqli_error($GLOBALS["DBconnector"])), 0);
           }
       } else {
           show_error_msg(T_("ERROR"), T_("TAG_EXISTS"), 0);
       }
   }

   if ($do == "ban") {
       foreach ($_POST['banned'] as $tagid => $banstatus){
           SQL_Query_exec("UPDATE tags
                           SET tag_banned = '" . ($banstatus=='Y' ? 'Y' : 'N') . "',
                           banned_by = '" . ($banstatus=='Y' ? $CURUSER['id'] : 0) . "',
                           banned_date = " . ($banstatus=='Y' ? 'NOW()' : '0') . ",
                           banned_reason = " . ($banstatus=='Y' ? sqlesc($_POST['bannedReason'][$tagid]) : '"-"') . "
                           WHERE tag_id = '" . intval($tagid) . "'");
       }
       show_error_msg(T_("SUCCESS"), "Tag(s) ban status updated.", 0);
   }

   begin_frame("Management of Tags");
   echo "<p align=\"justify\">This page allows you to add, delete and ban tags.</p><br />";



   $count = get_row_count("tags");
   if ($count == 0)
   print("<b>No Tags Found</b><br />\n");
   else {
   list($pagertop, $pagerbottom, $limit) = pager(25, $count, 'admincp.php?action=tags&amp;');
                                                                                                                                                                                                                                                               

   echo "<form id='tags' method='post' action='admincp.php?action=tags'>
   <input type='hidden' name='do' value='del' />
   <table border='0' cellpadding='3' cellspacing='0' width='100%' align='center' class='table_table'>
   <tr>
           <th class='table_head'>Tag</th>
           <th class='table_head'>Added By</th>
           <th class='table_head'>Date Added</th>
           <th class='table_head'>Banned</th>
           <th class='table_head'>Banned By</th>
           <th class='table_head'>Date Banned</th>
           <th class='table_head'>Banned Reason</th>
       <th class='table_head'><input type='checkbox' name='checkall' onclick='checkAll(this.form.id);' /></th>
   </tr>";

   $res2 = SQL_Query_exec("SELECT tags.*, tag_id, ua.username as addedby, ub.username as bannedby FROM tags
                               LEFT JOIN users ua ON tags.added_by = ua.id
                               LEFT JOIN users ub ON tags.banned_by = ub.id
                               ORDER BY tag_name ASC $limit");
   while ($arr = mysqli_fetch_assoc($res2)) {
       echo "<tr>
       
           <td align='center' class='table_col2'>" . htmlspecialchars($arr['tag_name']) . "</td>
           <td align='center' class='table_col2'><a href='account-details.php?id=" . intval($arr['added_by']) . "'>" . htmlspecialchars($arr['addedby']) . "</a></td>
           <td align='center' class='table_col2'>".date('d/m/Y H:i:s', utc_to_tz_time($arr["added_date"]))."</td>
           <td align='center' class='table_col2'><input type='radio' name='banned[" . $arr['tag_id'] . "]' value='Y' " . ($arr['tag_banned']=='Y' ? "checked" : "") . "> Yes&nbsp;&nbsp; <input type='radio' name='banned[" . $arr['tag_id'] . "]' value='N' " . ($arr['tag_banned']!='Y' ? "checked" : "") . "> No<br></td>
           <td align='center' class='table_col2'>" . ($arr['banned_by'] ? "<a href='account-details.php?id=" . intval($arr['banned_by']) . "'>" . htmlspecialchars($arr['bannedby']) . "</a>" : "-") . "</td>
           <td align='center' class='table_col2'>".($arr["banned_date"]!=0 ? date('d/m/Y H:i:s', utc_to_tz_time($arr["banned_date"])) : "-")."</td>
           <td align='center' class='table_col2'><input type='text' name='bannedReason[" . $arr['tag_id'] . "]' value='".($arr["banned_reason"] ? htmlspecialchars($arr["banned_reason"]) : "-")."'></td>
           <td class='table_col1' align='center'><input type='checkbox' name='ids[]' value=" . $arr['tag_id'] . " /></td>
       </tr>";
   }
   echo '</table><br />';    
   echo "<center><input type='submit' value='Update' />&nbsp;&nbsp;<input type='submit' value='Delete' /></center></form><br />";
   if ($count > 25) echo $pagerbottom;
   }
   echo "<br />";
   print("<form method='post' action='admincp.php?action=tags&amp;do=add'>\n");
   print("<table cellspacing='0' cellpadding='5' align='center' class='table_table' width='98%'>\n");
   print("<tr><th class='table_head' align='center'>Add Tag</th></tr>\n");
   print("<tr><td class='table_col1' align='center'>Tag: <input type='text' name='tag_name' size='40' /></td></tr>\n");
   print("<tr><td class='table_head' align='center'><input type='submit' value='Okay' /></td></tr>\n");
   print("</table></form><br />\n");

   end_frame();
   stdfoot();
}
     // END Mjays Tags


[color=rgb(251, 160, 38)]header.php add css & js[/color]
<script src="https://code.jquery.com/jquery-3.3.1.min.js" type="text/javascript"></script>
<script src="https://code.jquery.com/jquery-migrate-3.0.1.min.js" type="text/javascript"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js" type="text/javascript"></script>
<script src="./js/jquery.tag-editor.min.js" type="text/javascript"></script>
<script src="./js/jquery.caret.min.js" type="text/javascript"></script>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="./css/jquery.tag-editor.css">


[color=rgb(251, 160, 38)]theme.css[/color]

input, select {

change to
input, select, .tag-editor {


input[type=text] {

change to
input[type=text], .tag-editor {


[color=rgb(251, 160, 38)]torrents.php find[/color]
$category = (int) $_GET["cat"];

add after
// supertag mod
if($_GET['tagNames']){
   $tagNames = explode(",", mysqli_real_escape_string($GLOBALS["DBconnector"],$_GET['tagNames']));
   foreach($tagNames as $tagName){
       if($tagId = get_tag_id_from_name($tagName)){
           $tagNameIdArray[] = $tagId;
       }
   }
}

if ($_GET["tags"] || isset($tagNameIdArray)){
   if(isset($_GET["tags"])){
       $tagArray = explode(',', mysqli_real_escape_string($GLOBALS["DBconnector"],$_GET["tags"]));
   }
   if(isset($tagNameIdArray)){
       isset($tagArray) ? $tagArray = array_merge($tagArray, $tagNameIdArray) : $tagArray = $tagNameIdArray;
   }
   $addparam .= "tags=" . urlencode($_GET["tags"]) . "&amp;";
   $thisurl .= "tags=".urlencode($_GET["tags"])."&amp;";
   $wherea[] = "torrents.id IN (SELECT torrent_id FROM torrent_tags WHERE tag_id IN ('" . implode("', '", $tagArray) . "'))";
}


[color=rgb(251, 160, 38)]torrent-details.php[/color]
//DECIDE IF TORRENT EXISTS


before add
// Get all tags
$tags = get_tags_for_torrent($id);


find
if (empty($row["lang_name"])) $row["lang_name"] = "Unknown/NA";


before add
while ($row = mysqli_fetch_array($tags)) {
   $tagHtml[] = "<a href='./torrents.php?tags=" . $row['tag_id'] . "'>" . $row['tag_name'] . "</a>";
}

print("<tr><td align='left'><b>Tags:</b></td><td>" . ($tagHtml ? implode(", ", $tagHtml) : "none") . "</td></tr>\n");


[color=rgb(251, 160, 38)]torrent-upload.php[/color]
        $message = T_("UPLOAD_NO_ID");
       show_error_msg(T_("UPLOAD_FAILED"), $message, 1);
   }


replace with
            $message[] = T_("UPLOAD_NO_ID");
       show_error_msg(T_("UPLOAD_FAILED"), $message[], 1);
   } else {
       // Check the tags - not required for a valid upload
       if ($torrentTags = array_unique(explode(",", mysql_real_escape_string($GLOBALS["DBconnector"],$_POST["tags"])))){
           if(count($torrentTags) > 10){
               $torrentTags = array_splice($torrentTags, 10);
               $message[] = "You can only add up to " . intval($site_config['max_torrent_tags']) . " tags, the first " . intval($site_config['max_torrent_tags']) . " have been selected";
           }
           if($CURUSER['can_add_tags']) {
               foreach ($torrentTags as $torrentTag) {
                   // Check if the tag exists
                   if ($tagId = get_tag_id_from_name($torrentTag)) {
                       if ($tagId == 'banned') {
                           $message[] = "Tag '" . htmlspecialchars($torrentTag) . "' has been banned by staff";
                       } else {
                           // It exists and isnt banned - add it for this torrent
                           add_tag_id_to_torrent($tagId, $id);
                       }
                   } else {
                       // Add new tag
                       $newTagId = add_new_tag($torrentTag);
                       add_tag_id_to_torrent($newTagId, $id);
                   }
               }
           } else {
               $message[] = "Your userlevel is not allowed to add tags";
           }
       }
   }


find
begin_frame(T_("UPLOAD"));


add before
    // Grab tag names
$tags = get_tags();
while ($row = mysqli_fetch_array($GLOBALS["DBconnector"],$tags)) {
   $autotags[] = $row['tag_name'];
}


find
print ("<tr><td align='right'>" .T_("NFO"). ": </td><td align='left'> <input type='file' name='nfo' size='50' value='" . $_FILES['nfo']['name'] . "' /><br />\n</td></tr>");


add after
print ("<tr><td align='right'>Tags: </td><td align='left'><input id='tags' class='ui-autocomplete-input' type='text' name='tags' size='60' value='" . $_POST['tags'] . "' /><br />Tags can be selected from the drop down. " . ($CURUSER['can_add_tags'] ? "You can also add you own custom tags by typing one that doesnt exist" : "Your userlevel does not allow adding custom tags so they will be ignored if added") . "</td></tr>");
print_torrent_tags_js("Start typing ...");


[color=rgb(251, 160, 38)]torrent-search.php[/color]
    <?php echo  $catdropdown ?>
   </select>


add after
    <br /><br />
       <?php print(T_("TAGS")); ?>
   <input id="tags" class="ui-autocomplete-input" type="text" name="tagNames" size="40" />

   <?php print_torrent_tags_js("Search tags ...", $_GET['tagNames']); ?>


find
$parent_cat = $_GET["parent_cat"];


add after
if($_GET['tagNames']){
   $tagNames = explode(",", mysqli_real_escape_string($GLOBALS["DBconnector"],$_GET['tagNames']));
   foreach($tagNames as $tagName){
       if($tagId = get_tag_id_from_name($tagName)){
           $tagNameIdArray[] = $tagId;
       }
   }
}

if ($_GET["tags"] || isset($tagNameIdArray)){
   if(isset($_GET["tags"])){
       $tagArray = explode(',', mysqli_real_escape_string($GLOBALS["DBconnector"],$_GET["tags"]));
   }
   if(isset($tagNameIdArray)){
       isset($tagArray) ? $tagArray = array_merge($tagArray, $tagNameIdArray) : $tagArray = $tagNameIdArray;
   }
   $addparam .= "tags=" . urlencode($_GET["tags"]) . "&amp;";
   $thisurl .= "tags=".urlencode($_GET["tags"])."&amp;";
   $wherea[] = "torrents.id IN (SELECT torrent_id FROM torrent_tags WHERE tag_id IN ('" . implode("', '", $tagArray) . "'))";
}


add files to root





tags.zip
Download
2020-01-26 12:04:05
thank you I expect it to be functional
2020-01-26 23:46:06
This is super bloated for a basic function. Very little code added to torrents-edit.php, torrents-upload.php, a sql query for the new table, and even code to show on torrents-details.php. I’ll post it later tonight.

Good work though!
2020-02-07 02:01:39
that is great for SEO
2020-02-22 14:56:55
"STorrents2020, post: 67793, member: 20382":

This is super bloated for a basic function. Very little code added to torrents-edit.php, torrents-upload.php, a sql query for the new table, and even code to show on torrents-details.php. I’ll post it later tonight.

Good work though!


Would love to see your version of this tag mod!
If It Ain't Dutch, It Ain't Much!!
2020-04-26 23:56:15
whene will be ready
tell us
many thanks
Users online

No users online

Search



Statistics

    Torrents

  • Tracking: 3
  • Todays torrents: 0
  • Seeders: 0
  • Leechers: 0
  • Peers: 0
  • Downloaded: 89.96 GB
  • Uploaded: 9.86 GB

  • Members

  • We have: 838
  • New today: 0
  • Guest today: 9

  • Online

  • Total online: 9
  • Members: 0
  • Guests online: 9
  • Comments: 3
  • Messages: 1,728