eTCG Mods
These mods has been tested on my TCG collection and is compatible with PHP8. There aren't much explanations as to how to use/install them aside from copy-pasting them to your mods.php
file.
If these doesn't work on your end, feel free to report them to me! Although I can't guarantee that I will be able to attend to your reports as quickly as possible.
Last updated on July 16, 2023
Add this function on your
To display the count on your TCG page, use this code:
mods.php
file.// Show total count of unique masteries by Aki
function unique_mastery($tcg)
{
$database = new Database;
$sanitize = new Sanitize;
$tcg = $sanitize->for_db($tcg);
$tcginfo = $database->get_assoc("SELECT * FROM `tcgs` WHERE `name`='$tcg' LIMIT 1");
$result = $database->query("SELECT * FROM `collecting` WHERE `tcg`='".$tcginfo['id']."' AND `mastered`='1'");
if( mysqli_num_rows( $result ) == 0 )
{
echo "0";
}
else
{
while( $row = mysqli_fetch_assoc( $result ) )
{
$decks[] = $row['deck'];
}
return count(array_unique($decks));
}
}
To display the count on your TCG page, use this code:
<?php echo unique_mastery('TCG NAME'); ?>
Last updated on July 17, 2023
This mod will display your remastered decks as list, with count of how many of them has been remastered, and the total count of your remasteries. Add this function on your
To display the list on your TCG masterted page or wherever you prefer, use this code:
mods.php
file.// Show remasteries list and count each deck by Aki
// Type is list and count
function remastery($tcg, $type)
{
$txt = null;
$database = new Database;
$sanitize = new Sanitize;
$tcg = $sanitize->for_db($tcg);
$type = $sanitize->for_db($type);
$tcginfo = $database->get_assoc("SELECT * FROM `tcgs` WHERE `name`='$tcg' LIMIT 1");
$result = $database->query("SELECT * FROM `collecting` WHERE `tcg`='".$tcginfo['id']."' AND `mastered`='1'");
if( mysqli_num_rows( $result ) == 0 )
{
echo "0";
}
else
{
while( $row = mysqli_fetch_assoc( $result ) )
{
$decks[] = $row['deck'];
}
$counted = array_count_values($decks);
$total_remasteries = 0;
foreach( $counted as $key => $count )
{
if( $count <= 1 )
{
unset($counted[$key]);
}
else
{
$minus = $count - 1;
$total_remasteries += $minus;
}
}
if( $type == 'list' )
{
if( $total_remasteries >= 2 ) { $rem = 'remasteries'; }
else { $rem = 'remastery'; }
echo '<p>You have a total of '.$total_remasteries.' '.$rem.'.</p>';
ksort($counted);
foreach( $counted as $key => $count )
{
$minus = $count - 1;
if( $count >= 2 ) { $mast = 'masteries'; }
else { $mast = 'mastery'; }
if( $minus >= 2 ) { $rem = 'remasteries'; }
else { $rem = 'remastery'; }
echo '<li>'.$key.': '.$count.' total '.$mast.' ('.$minus.' '.$rem.')</li>';
}
}
elseif( $type == 'count' )
{
echo $total_remasteries;
}
}
}
To display the list on your TCG masterted page or wherever you prefer, use this code:
<?php echo remastery('TCG NAME', 'TYPE'); ?>Select remastery type: list or count.
Last updated on July 17, 2023
This mod will show the full deck of your mastered decks including the date you mastered it. First, add the customized
or
To display the linked mastery badges according to its link type, use this code:
Moving forward, follow the steps below to setup your mastered page. Make sure to add these codes after
- include(func.php);
- include(header.php);
- include(NAVLINK); if you have a separate set of links for a specific TCG
- custom codes
Add the code below at the top of your page (e.g. in between your callback of func.php and main content)
Then copy the suitable code for you depending on your link type.
show_mastered()
on your mods.php
file./*************************************************Depending on how you set up your mastered deck page, you must define this by selecting any of the following link types:
* Custom function to show full deck of mastered deck.
* $tcg = the name of the TCG as defined in the database
* $worth = card worth
* $deckname = name of a mastered deck
* $link = the type of link you have for this (static, querystring or variable)
*************************************************/
function custom_mastered($tcg, $link, $worth = '', $deckname = '')
{
$database = new Database;
$sanitize = new Sanitize;
$tcg = $sanitize->for_db($tcg);
$tcginfo = $database->get_assoc("SELECT * FROM `tcgs` WHERE `name`='$tcg' LIMIT 1");
if( $worth !== '' ) { $worth = intval($worth); }
if( $deckname !== '' ) { $deckname = $sanitize->for_db($deckname); }
if( $worth !== '' ) { $result = $database->query("SELECT * FROM `collecting` WHERE `tcg` = '".$tcginfo['id']."' AND `mastered` = '1' AND `worth` = '$worth' ORDER BY `mastereddate`"); }
else if( $deckname !== '' ) { $result = $database->query("SELECT * FROM `collecting` WHERE `tcg` = '".$tcginfo['id']."' AND `mastered` = '1' AND `deck` = '$deckname' ORDER BY `mastereddate`"); }
else { $result = $database->query("SELECT * FROM `collecting` WHERE `tcg` = '".$tcginfo['id']."' AND `mastered` = '1' ORDER BY `mastereddate`"); }
while( $row = mysqli_fetch_assoc( $result ) )
{
$tcgname = strtolower($tcg);
$mastered = date('F d, Y', strtotime($row['mastereddate']));
if( $row['badge'] !== '' )
{
// Check link type
if( $link == 'static' )
{
echo '<a href="'.$tcgname.'-mastered.php?deck='.$row['deck'].'"><img src="'.$tcginfo['cardsurl'].''.$row['badge'].'" alt="" title="Mastered '.$mastered.'" /></a> ';
}
else if( $link == 'querystring' )
{
echo '<a href="'.$tcgname.'.php?mastered&deck='.$row['deck'].'"><img src="'.$tcginfo['cardsurl'].''.$row['badge'].'" alt="" title="Mastered '.$mastered.'" /></a> ';
}
else if( $link == 'variable' )
{
echo '<a href="'.$tcgname.'.php?page=mastered&deck='.$row['deck'].'"><img src="'.$tcginfo['cardsurl'].''.$row['badge'].'" alt="" title="Mastered '.$mastered.'" /></a> ';
}
}
else
{
echo ''.$row['deck'].' ';
}
}
}
static
(e.g. gleam-mastered.php?deck=DECKNAME)querystring
(e.g. gleam.php?mastered=DECKNAME)variable
(e.g. gleam.php?page=mastered&deck=DECKNAME) - make sure to change ?page= to your own variables (e.g ?id= or ?sub=)To display the linked mastery badges according to its link type, use this code:
<?php custom_mastered('TCG NAME', 'LINK TYPE'); ?>
Moving forward, follow the steps below to setup your mastered page. Make sure to add these codes after
include(func.php);
or header.php
include if you have it after func.php include. As to make it more clearer, refer to the hierarchy below:- include(func.php);
- include(header.php);
- include(NAVLINK); if you have a separate set of links for a specific TCG
- custom codes
<?php
$deck = isset($_GET['deck']) ? $_GET['deck'] : '';
$page = isset($_GET['page']) ? $_GET['page'] : ''; // applicable only to variable link type
?>
if( empty( $deck ) )
{
echo '<h1>Mastered Decks</h1>';
echo '<center>';
custom_mastered('TCG NAME', 'LINK TYPE');
echo '</center>';
}
else
{
echo '<h1>Mastered : '.$deck.'</h1>';
$database = new Database;
$tcginfo = $database->get_assoc("SELECT * FROM `tcgs` WHERE `name`='TCG NAME' LIMIT 1");
$result = $database->query("SELECT * FROM `collecting` WHERE `tcg` = '".$tcginfo['id']."' AND `mastered` = '1' AND `deck` = '$deck' ORDER BY `sort`, `worth`");
while( $row = mysqli_fetch_assoc( $result ) )
{
echo '<center>
<img src="'.$tcginfo['cardsurl'].''.$row['badge'].'"><br /><b>Mastered on:</b> '.date('F d, Y', strtotime($row['mastereddate'])).'<br /><br />';
$cards = explode(',',$row['cards']);
for( $i = 1; $i <= $row['count']; $i++ )
{
$number = $i;
if ( $number < 10 ) { $number = '0'.$number; }
$card = $row['deck'].''.$number;
echo '<img src="'.$tcginfo['cardsurl'].''.$card.'.'.$tcginfo['format'].'" alt="" title="'.$card.'" />';
if ( $row['break'] !== '0' && $i % $row['break'] == 0 ) { echo '<br />'; }
}
echo '</center><br /><br />';
}
}
else if( $_SERVER['QUERY_STRING'] == "mastered" && $_GET['mastered'] == '' )
{
echo '<h1>Mastered</h1>';
echo '<center>';
custom_mastered('TCG NAME', 'LINK TYPE');
echo '<center>';
} // end list of mastered decks badges
else if( isset($_GET['mastered']) && $_GET['mastered'] !== '' )
{
$deck = $_GET['mastered'];
$database = new Database;
$tcginfo = $database->get_assoc("SELECT * FROM `tcgs` WHERE `name`='TCG NAME' LIMIT 1");
echo '<h1>Mastered : '.$deck.'</h1>';
$result = $database->query("SELECT * FROM `collecting` WHERE `tcg` = '".$tcginfo['id']."' AND `mastered` = '1' AND `deck` = '$deck' ORDER BY `sort`, `worth`");
while ( $row = mysqli_fetch_assoc($result) )
{
echo '<center>
<img src="'.$tcginfo['cardsurl'].''.$row['badge'].'"><br /><b>Mastered on:</b> '.date('F d, Y', strtotime($row['mastereddate'])).'<br /><br />';
$cards = explode(',',$row['cards']);
for( $i = 1; $i <= $row['count']; $i++ )
{
$number = $i;
if ( $number < 10 ) { $number = '0'.$number; }
$card = $row['deck'].''.$number;
echo '<img src="'.$tcginfo['cardsurl'].''.$card.'.'.$tcginfo['format'].'" alt="" title="'.$card.'" />';
if ( $row['break'] !== '0' && $i % $row['break'] == 0 ) { echo '<br />'; }
}
echo '</center><br /><br />';
}
} // end display of full mastered deck
else if( $page == "mastered" )
{
if( empty( $deck ) )
{
echo '<h1>Mastered Decks</h1>';
echo '<center>';
custom_mastered('TCG NAME', 'LINK TYPE');
echo '</center>';
}
else
{
echo '<h1>Mastered : '.$deck.'</h1>';
$database = new Database;
$tcginfo = $database->get_assoc("SELECT * FROM `tcgs` WHERE `name`='TCG NAME' LIMIT 1");
$result = mysqli_query($connect, "SELECT * FROM `collecting` WHERE `tcg` = '$tcgid' AND `mastered` = '1' AND `deck` = '$deck' ORDER BY `sort`, `worth`");
while ( $row = mysqli_fetch_assoc($result) )
{
echo '<center>
<img src="'.$tcginfo['cardsurl'].''.$row['badge'].'"><br /><b>Mastered on:</b> '.date('F d, Y', strtotime($row['mastereddate'])).'<br /><br />';
$cards = explode(',',$row['cards']);
for( $i = 1; $i <= $row['count']; $i++ )
{
$number = $i;
if ( $number < 10 ) { $number = '0'.$number; }
$card = $row['deck'].''.$number;
echo '<img src="'.$tcginfo['cardsurl'].''.$card.'.'.$tcginfo['format'].'" alt="" title="'.$card.'" />';
if ( $row['break'] !== '0' && $i % $row['break'] == 0 ) { echo '<br />'; }
}
echo '</center><br /><br />';
}
}
}
Last updated on July 29, 2023
Use the custom code below by adding it to your
To display the sections, use this code:
mods.php
file to section your trading and doubles pile to 0-m or n-z.// Show custom trading section by Aki
// Section: 0-m, n-z
function show_trading( $tcg, $category, $section, $unique = 0 )
{
$database = new Database;
$sanitize = new Sanitize;
$tcg = $sanitize->for_db($tcg);
$category = $sanitize->for_db($category);
$section = $sanitize->for_db($section);
$altname = strtolower(str_replace(' ','',$tcg));
$tcginfo = $database->get_assoc("SELECT * FROM `tcgs` WHERE `name`='$tcg' LIMIT 1");
$tcgid = $tcginfo['id'];
$cardsurl = $tcginfo['cardsurl'];
$format = $tcginfo['format'];
$cards = $database->get_assoc("SELECT `cards`, `format` FROM `cards` WHERE `tcg`='$tcgid' AND `category`='$category' LIMIT 1");
if ( $cards['format'] != 'default' ) { $format = $cards['format']; }
if ( $cards['cards'] === '' ) { echo '<p><em>There are currently no cards under this section.</em></p>'; }
else
br /> $cards = explode(',',$cards['cards']);
$cards = array_map('trim', $cards);
if ( $unique == 1 ) { $cards = array_unique($cards); }
foreach( $cards as $card )
{
$card = trim($card);
if( preg_match('/['.$section.']/', $card[0]) )
{
echo '<div class="cardList"><img src="'.$cardsurl.''.$card.'.'.$format.'" alt="" title="'.$card.'" /><br /><span class="text">'.$card.'</span></div>';
}
}
}
}
To display the sections, use this code:
<?php echo show_trading('TCG NAME', 'CATEGORY', 'SECTION'); ?>Select trading section: 0-m, n-z
Last updated on July 16, 2023
If you are a player of Gleam TCG, you may need this mod to sort your merchandise according to their prefix. So even if you put them all in one eTCG category, you will still be able to display them per merchandise type. All you have to do is add this function on your
To display the merchandise according to their type or prefix, use this code:
mods.php
file.// Show list of Gleam merchandise per prefix (e.g. cd, dvd, pt, le, ws)
// Example code: <?php echo gleam_merch('Gleam', 'merchandise', 'pt-'); ?>
function gleam_merch( $tcg, $category, $prefix )
{
$database = new Database;
$sanitize = new Sanitize;
$tcg = $sanitize->for_db($tcg);
$category = $sanitize->for_db($category);
$prefix = $sanitize->for_db($prefix);
$altname = strtolower(str_replace(' ','',$tcg));
$tcginfo = $database->get_assoc("SELECT * FROM `tcgs` WHERE `name`='$tcg' LIMIT 1");
$tcgid = $tcginfo['id'];
$cardsurl = $tcginfo['cardsurl'];
$format = $tcginfo['format'];
$cards = $database->get_assoc("SELECT `cards`, `format` FROM `cards` WHERE `tcg`='$tcgid' AND `category`='$category' LIMIT 1");
if( $cards['format'] != 'default' ) { $format = $cards['format']; }
if( $cards['cards'] === '' )
{
echo '<p><em>There are currently no merchandise under this category.</em></p>';
}
else
{
$cards = explode(',',$cards['cards']);
$cards = array_map('trim', $cards);
if ( $prefix == "ws-" ) { $format = 'gif'; }
foreach( $cards as $card )
{
$card = trim($card);
if ( str_starts_with( $card, $prefix ) === TRUE )
{
echo '<img src="'.$cardsurl.''.$card.'.'.$format.'" alt="" title="'.$card.'" /> ';
}
else { echo ''; }
}
}
}
To display the merchandise according to their type or prefix, use this code:
<?php echo gleam_merch('TCG NAME', 'CATEGORY', 'PREFIX'); ?>Select merchandise prefix: cd-, dvd-, pt-, le-, ws-.