modding etcg
eTCG is undeniably the best thing to happen to the TCG community. It was created by Bloo of Filler00 . Even though it makes all of our lives simpler, sometimes we want to find ways to simplify them even further. Below you will find information on modding eTCG and doing just that.
INDEX
Getting Started
Troubleshooting
MODS
Get Catagory
Pending
Show Needed
Show Owned
Show Pending cards in keeping
links
Danni's mods
contact
If I have made a mistake or you cannot get something to work, feel free to contact me on Discord!
Also, please note. I don't know PHP. aksldjks; ha ha haaaa lmaooooo
getting started
BACK EVERYTHING UP BEFORE MESSING WITH STUFF.
Making a mods.php file
Open your func.php file and scroll all the way to the bottom.
Before the last line, add:
include('mods.php');
Create a new file in the same directory as func.php and name it mods.php
Inside this file put the following.
<?php {
} ?>
Troubleshooting
If you have eTCG 1.0.1 your mods will use mysql.
If you have eTCG 1.1.0 your mods will use mysqli.
Make sure you do not have the same mod in your mods.php file twice.
Please double check these things if you have a problem!
My post is broken or won't load!
If your post is broken or showing a blank page, try adding the following to your header.
ini_set("display_errors", "1");error_reporting(E_ALL);
This may show us an error code that will help deduce what is wrong.
You can remove this when you are done.
mods
Below is a list of mods for eTCG. Any mod that isn't my own is displayed with permission from the original author. NOTE: I have tweaked a lot of these mods.
Get Catagory
Created by: Dite
Originally posted: here
Notes
This mod gathers a list of your catagories for use with other mods.
Instructions
Open your mods.php file and past the following between the php tags.
// GET CATAGORY MOD BY DITE
function get_category( $tcg, $category) {
$database = new Database;
$sanitize = new Sanitize;
$tcg = $sanitize->for_db($tcg);
$category = $sanitize->for_db($category);
$altname = strtolower(str_replace(' ','',$tcg));
$result = $database->get_assoc("SELECT `id` FROM `tcgs` WHERE `name`='$tcg' LIMIT 1");
$tcgid = $result['id'];
$result = $database->get_assoc("SELECT `cards` FROM `cards` WHERE `tcg`='$tcgid' AND
`category`='$category' LIMIT 1");
return $result['cards'];
}
PENDING
Created by: Dite
Originally posted: n/a
Notes
This mod gathers a list of your pending cards for use with other mods.
Instructions
Open your mods.php file and past the following between the php tags.
If you have eTCG 1.0.1 use:
// PENDING MOD BY DITE
function pending($tcg, $card){
$database = new Database;
$sanitize = new Sanitize;
$tcg = $sanitize->for_db($tcg);
$tcginfo = $database->get_assoc("SELECT * FROM `tcgs` WHERE `name`='$tcg' LIMIT 1");
$tcgid = $tcginfo['id'];
$pending = $database->num_rows("SELECT * FROM `trades` WHERE `tcg`='$tcgid' AND `receiving` LIKE '%$card%'");
return $pending;
}
If you have eTCG 1.1.0 use:
// PENDING MOD BY DITE
function pending_check($tcg, $card){
$database = new Database;
$sanitize = new Sanitize;
$tcg = $sanitize->for_db($tcg);
$tcginfo = $database->get_assoc("SELECT * FROM `tcgs` WHERE `name`='$tcg' LIMIT 1");
$tcgid = $tcginfo['id'];
$pending = $database->num_rows("SELECT * FROM `trades` WHERE `tcg`='$tcgid' AND `receiving` LIKE '%$card%'");
$pending = ($pending === 0 ? false : true);
return $pending;
}
Show Needed
Created by: Dite
Originally posted: here
Requires: get_catagory, pending
Modified by: Kriss
Notes
This mod will display a text list of all the cards you need .
This makes finding cards to ask for a lot easier.
Instructions
Make sure you have the Get Catagory and Pending mods. If not, do that first!
Open your mods.php file and past the following between the php tags.
If you have eTCG 1.0.1 use:
// SHOW NEEDED MOD BY DITE 1.0.1
function show_needed( $tcg, $category, $count,$pend = 0, $low = 0) {
$total = array();
if (strtolower($category)==='collecting'){
$database = new Database;
$sanitize = new Sanitize;
$tcg = $sanitize->for_db($tcg);
$tcginfo = $database->get_assoc("SELECT * FROM `tcgs` WHERE `name`='$tcg' LIMIT 1");
$tcgid = $tcginfo['id'];
$worth = intval($count);
$result = $database->query("SELECT * FROM `collecting` WHERE `tcg` = '$tcgid' AND `mastered` = '0' AND `worth` = '$worth' ORDER BY `sort`, `deck`");
$cards = '';
while ( $row = mysql_fetch_assoc($result) ) {$cards .= $row['cards'].', '; $total[$row['deck']] = $row['count'];}
$cards = substr($cards,0,-2);} else { $cards = get_category($tcg, $category); }
$cards = explode(', ',$cards);
$cards = array_unique($cards); array_walk($cards, 'trim_value');
$deck = array( );
//Get decks
foreach ($cards as $card) {$deck[ ] = substr($card, 0, -2);}
$group = array_combine($cards,$deck);
$deck = array_unique($deck);
//Results
foreach ($deck as $check) {
echo '<span id="needed-deck"><b>';
if(isset($total[$check])){$all = $total[$check];} else{$all = $count;}
$mine = array();
$got = array_keys($group, $check);
foreach ($got as $num) {$mine[ ] = substr($num, -2); }
$def = range(1,$all);
$default = array( );
foreach($def as $no){if($no < 10){$default[ ] = '0'.$no;} else {$default[ ] = $no;}}
$diff = array_diff($default,$mine);
foreach($diff as &$might){
$pending = pending($tcg, $check.$might);
if($pending > 0){
if($pend === 1){$might = '<u>'.$might.'</u>';}
else{ $might = '<span id="needed-pending">('.$might.')</span>';}
}
}
$diff = array_filter($diff, 'strlen');
$need = count($diff);
if($low === 0 || $need <= $low){
$diff = implode(', ',$diff);
echo $check.'</b></span> <span id="needed-cards">'.$diff.'</span><br/>';
}
}
}
If you have eTCG 1.1.0 use:
// SHOW NEEDED MOD BY DITE 1.1.0
function show_needed( $tcg, $category, $count,$pend = 0, $low = 0) {
$total = array();
if (strtolower($category)==='collecting'){
$database = new Database;
$sanitize = new Sanitize;
$tcg = $sanitize->for_db($tcg);
$tcginfo = $database->get_assoc("SELECT * FROM `tcgs` WHERE `name`='$tcg' LIMIT 1");
$tcgid = $tcginfo['id'];
$worth = intval($count);
$result = $database->query("SELECT * FROM `collecting` WHERE `tcg` = '$tcgid' AND `mastered` = '0' AND `worth` = '$worth' ORDER BY `sort`, `deck`");
$cards = '';
while ( $row = mysqli_fetch_assoc($result) ) {$cards .= $row['cards'].', '; $total[$row['deck']] = $row['count'];}
$cards = substr($cards,0,-2);} else { $cards = get_category($tcg, $category); }
$cards = explode(', ',$cards);
$cards = array_unique($cards); array_walk($cards, 'trim_value');
$deck = array( );
//Get decks
foreach ($cards as $card) {$deck[ ] = substr($card, 0, -2);}
$group = array_combine($cards,$deck);
$deck = array_unique($deck);
//Results
foreach ($deck as $check) {
echo '<span id="needed-deck"><b>';
if(isset($total[$check])){$all = $total[$check];} else{$all = $count;}
$mine = array();
$got = array_keys($group, $check);
foreach ($got as $num) {$mine[ ] = substr($num, -2); }
$def = range(1,$all);
$default = array( );
foreach($def as $no){if($no < 10){$default[ ] = '0'.$no;} else {$default[ ] = $no;}}
$diff = array_diff($default,$mine);
foreach($diff as &$might){
$pending = pending_check($tcg, $check.$might);
if($pending > 0){
if($pend === 1){$might = '<u>'.$might.'</u>';}
else{ $might = '<span id="needed-pending">'.$might.'</span>';}
}
}
$diff = array_filter($diff, 'strlen');
$need = count($diff);
if($low === 0 || $need <= $low){
$diff = implode(', ',$diff);
echo $check.'</b></span> <span id="needed-cards">'.$diff.'</span><br/>';
}
}
}
CSS Style
Paste the following into your css. This will only work if you use my version of the mod.
/************************
N E E D E D
************************/
#needed-deck {
font-weight: normal;
color: #888888;
text-align: left;
display: inline-block;
width: 31%;
margin: 0;
border-top: 1px solid #eeeeee;
vertical-align: top;
}
#needed-cards {
font-weight: normal;
color: #888888;
text-align: left;
display: inline-block;
width: 68%;
margin: 0;
border-top: 1px solid #eeeeee;
vertical-align: top;
}
#needed-trading #needed-cards {
color: white !important;
}
#needed-pending {
font-weight: normal;
color: #FFC03C;
text-shadow: 1px 1px 2px rgba(255, 192, 60, 0.5);
}
#needed {
text-align: left;
font-family: calibri;
font-size: 11px;
}
#needed b, #needed strong {
text-align: left;
font-family: calibri;
font-size: 12px;
font-weight: normal;
letter-spacing: 1px;
}
How to display it on your site
To display collecting decks, add the code below to the page you wish to display these stats.
<div id="needed"><?php show_needed( '$tcg', 'collecting', '1', '1'); ?></div>
To display all other categories, add the code below to the page you wish to display these stats.
<div id="needed"><?php show_needed( '$tcg', '$catagory', '$count', '1'); ?></div>
$tcg = The name of the TCG in eTCG.
$catagory = The name of the category you wish to display.
$count = The number of cards in the deck.
If You don't want to use my css leave out the following code.
<div id="needed"></div>
troubleshooting
Make sure this line is correct as it is different in each version.
If you have eTCG 1.0.1 use:
$pending = pending($tcg, $check.$might);
If you have eTCG 1.1.0 use:
$pending = pending_check($tcg, $check.$might);
Show Owned
Created by: Dite
Originally posted: n/a
Requires: get_catagory
Modified by: Kriss
Notes
This mod will display a text list of all the cards you have .
This makes finding cards to offer people a lot easier.
I don't beleive this works with collecting decks.
Instructions
Make sure you have the Get Catagory mod. If not, do that first!
Open your mods.php file and past the following between the php tags.
// SHOW OWNED MOD BY DITE
function show_owned( $tcg, $category, $high = 0) {
$cards = get_category($tcg, $category);
$cards = explode(', ',$cards);
$cards = array_unique($cards); array_walk($cards, 'trim_value');
$deck = array( );
//Get decks
foreach ($cards as $card) {$deck[ ] = substr($card, 0, -2);}
$group = array_combine($cards,$deck);
$deck = array_unique($deck);
//Results
foreach ($deck as $check) {
echo '<span id="needed-deck"><b>';
$mine = array();
$got = array_keys($group, $check);
foreach ($got as $num) {$mine[ ] = substr($num, -2); }
$owned = count($mine);
if($high=== 0 || $owned >= $high){
$mine = implode(', ',$mine);
echo $check.'</b></span> <span id="needed-cards">'.$mine.'</span><br/>';
}
}
}
CSS Style
Paste the following into your css. This will only work if you use my version of the mod.
/************************
N E E D E D
************************/
#needed-deck {
font-weight: normal;
color: #888888;
text-align: left;
display: inline-block;
width: 31%;
margin: 0;
border-top: 1px solid #eeeeee;
vertical-align: top;
}
#needed-cards {
font-weight: normal;
color: #888888;
text-align: left;
display: inline-block;
width: 68%;
margin: 0;
border-top: 1px solid #eeeeee;
vertical-align: top;
}
#needed-trading #needed-cards {
color: white !important;
}
#needed-pending {
font-weight: normal;
color: #FFC03C;
text-shadow: 1px 1px 2px rgba(255, 192, 60, 0.5);
}
#needed {
text-align: left;
font-family: calibri;
font-size: 11px;
}
#needed b, #needed strong {
text-align: left;
font-family: calibri;
font-size: 12px;
font-weight: normal;
letter-spacing: 1px;
}
How to display it on your site
To display categories, add the code below to the page you wish to display these stats.
<div id="needed"><?php show_owned( '$tcg', '$catagory'); ?></div>
$tcg = The name of the TCG in eTCG.
$catagory = The name of the category you wish to display.
If You don't want to use my css leave out the following code.
<div id="needed"></div>
Show Pending in Keeping
Created by: Dite
Originally posted: n/a
Requires: get_catagory
Notes
This mod will display a pending card in your keeping section.
This makes it less likely for someone to accidentally send you doubles.
Instructions
Make sure you have the Get Catagory mod. If not, do that first!
Open your mods.php file and past the following between the php tags.
If you have eTCG 1.0.1 use:
// SHOW PENDING IN KEEPING BY DITE
function show_pendcards($tcg, $category, $pendname='pending') {
$database = new Database;
$sanitize = new Sanitize;
$tcg = $sanitize->for_db($tcg);
$tcginfo = $database->get_assoc("SELECT * FROM `tcgs` WHERE `name`='$tcg' LIMIT 1");
$tcgid = $tcginfo['id'];
$cardsurl = $tcginfo['cardsurl'];
$format = $tcginfo['format'];
$cards = get_category($tcg, $category); $cards = explode(', ',$cards);
$list = get_additional($tcg, $category);
if(empty($list)){
$list = array();
foreach($cards as $card){$deck = substr($card,0,-2); $list[] = $deck;}
$list = array_unique($list);
sort($list);
} else {$list = explode(', ',$list);}
$pend = $database->query("SELECT * FROM `trades` WHERE `tcg`='$tcgid'");
$pending = array();
// Gets all pending cards
if(mysql_num_rows($pend)>0){
while($p=mysqli_fetch_assoc($pend)){
if(!empty($p['receivingcat'])){
$cats = explode(', ',$p['receivingcat']);
$divide = explode('; ', $p['receiving']);
for($i=0;$i<count($cats);$i++){
if($cats[$i]===$category){$pending = array_merge($pending, explode(', ',$divide[$i]));}
}
}test
else{
$divide = explode(', ', $p['receiving']);
foreach($divide as $pendcard){
if(in_array(substr($pendcard,0,-2),$list)){$pending[] = $pendcard;}
}
}
}
}
testarray_walk($pending,'trim_value');
//Makes a deck array with cards.
$cards = array_unique($cards);
$cards = array_combine($cards, $cards);
//Adds related pending cards to category.
foreach($pending as $check){
if(empty($cards[$check])){$cards[$check] = $pendname;}
}
if ( empty($cards) ) { echo '<p><em>There are currently no cards under this category.</em></p>'; }
else {
uksort($cards, 'strcasecmp');
foreach ( $cards as $title=>$card ) {
echo '<img src="'.$cardsurl.''.$card.'.'.$format.'" alt="" title="'.$title.'" /> ';
}
}
}
If you have eTCG 1.1.0 use:
// SHOW PENDING IN KEEPING BY DITE
function show_pendcards($tcg, $category, $pendname='pending') {
$database = new Database;
$sanitize = new Sanitize;
$tcg = $sanitize->for_db($tcg);
$tcginfo = $database->get_assoc("SELECT * FROM `tcgs` WHERE `name`='$tcg' LIMIT 1");
$tcgid = $tcginfo['id'];
$cardsurl = $tcginfo['cardsurl'];
$format = $tcginfo['format'];
$cards = get_category($tcg, $category); $cards = explode(', ',$cards);
$list = get_additional($tcg, $category);
if(empty($list)){
$list = array();
foreach($cards as $card){$deck = substr($card,0,-2); $list[] = $deck;}
$list = array_unique($list);
sort($list);
} else {$list = explode(', ',$list);}
$pend = $database->query("SELECT * FROM `trades` WHERE `tcg`='$tcgid'");
$pending = array();
// Gets all pending cards
if(mysqli_num_rows($pend)>0){
while($p=mysqli_fetch_assoc($pend)){
if(!empty($p['receivingcat'])){
$cats = explode(', ',$p['receivingcat']);
$divide = explode('; ', $p['receiving']);
for($i=0;$i<count($cats);$i++){
if($cats[$i]===$category){$pending = array_merge($pending, explode(', ',$divide[$i]));}
}
}
else{
$divide = explode(', ', $p['receiving']);
foreach($divide as $pendcard){
if(in_array(substr($pendcard,0,-2),$list)){$pending[] = $pendcard;}
}
}
}
}
array_walk($pending,'trim_value');
//Makes a deck array with cards.
$cards = array_unique($cards);
$cards = array_combine($cards, $cards);
//Adds related pending cards to category.
foreach($pending as $check){
if(empty($cards[$check])){$cards[$check] = $pendname;}
}
if ( empty($cards) ) { echo '<p><em>There are currently no cards under this category.</em></p>'; }
else {
uksort($cards, 'strcasecmp');
foreach ( $cards as $title=>$card ) {
echo '<img src="'.$cardsurl.''.$card.'.'.$format.'" alt="" title="'.$title.'" /> ';
}
}
}
How to display it on your site
For the pending cards to show up, replace the code that displays your cards with the one below.
<?php show_pendcards('$tcg','$catagory'); ?>
$tcg = The name of the TCG in eTCG.
$catagory = The name of the category you wish to display.
Troubleshooting
I had a problem where it was trying to name the pending cards 1.png .
If this happens to you, just save another pending card under that name and upload it.