Show Mastered Cards | v1.0 | etcgfm v1.0.1 | up 10.16.13

  1. 4 years ago

    Bloo

    16 Oct 2013 Administrator kablooey.net

    The first chunk of code may need tweaking, depending on how your existing mastered decks page is set up. I do not recommend attempting to install this mod unless you are familiar with PHP.

    Add the following code to your mastered decks page. Replace TCG NAME.

    <?php if ( isset($_GET['mastered']) && $_GET['mastered'] !== '' ) { $deckid = intval($_GET['mastered']);
    
        $tcginfo = $database->get_assoc("SELECT * FROM `tcgs` WHERE `name`='TCG NAME' LIMIT 1");
    
        if ( $database->num_rows("SELECT * FROM `collecting` WHERE `id`='$deckid' AND `tcg`='".$tcginfo['id']."' LIMIT 1") > 0 ) {
    
            $deckinfo = $database->get_assoc("SELECT * FROM `collecting` WHERE `id`='$deckid' AND `tcg`='".$tcginfo['id']."' LIMIT 1");
            $cards = explode(',',$deckinfo['cards']); 
            array_walk($cards, 'trim_value');
    
            $count = count($cards);    
    
            echo '<h1>mastered</h1>';
            echo '<p align="center">';
            echo '<strong>'.$deckinfo['deck'].'</strong> - <em>'.date('F d, Y',strtotime($deckinfo['mastereddate'])).'</em><br />';
    
            for ( $i = 1; $i <= $deckinfo['count']; $i++ ) {
                $number = $i;
    
                if ( $number < 10 ) { $number = "0$number"; }
                $card = "".$deckinfo['deck']."$number";
                $pending = $database->num_rows("SELECT * FROM `trades` WHERE `tcg`='$id' AND `receiving` LIKE '%$card%'");
    
                if ( in_array($card, $cards) ) echo '<img src="'.$tcginfo['cardsurl'].''.$card.'.'.$tcginfo['format'].'" alt="" />';
                else if ( $pending > 0 ) { echo '<img src="'.$tcginfo['cardsurl'].''.$deckinfo['pending'].'.'.$tcginfo['format'].'" alt="" />'; }
                else { echo '<img src="'.$tcginfo['cardsurl'].''.$deckinfo['filler'].'.'.$tcginfo['format'].'" alt="" />'; }
    
                if ( $deckinfo['puzzle'] == 0 ) { echo ' '; }
                if ( $deckinfo['break'] !== '0' && $i % $deckinfo['break'] == 0 ) { echo '<br />'; }
    
            }
    
            echo '</p>';
    
        }
        
    }
    
    ?>

    Replace the following line of code in func.php (should be on or around line 305):

    if ( $row['badge'] !== '' ) { echo '<img src="'.$tcginfo['cardsurl'].''.$row['badge'].'" alt="" title="Mastered '.$mastered.'" /> '; }

    With this:

    if ( $row['badge'] !== '' ) { echo '<a href="?mastered='.$row['id'].'"><img src="'.$tcginfo['cardsurl'].''.$row['badge'].'" alt="" title="Mastered '.$mastered.'" /></a> '; }
  2. effy

    4 Nov 2013 http://twig.slothly.org

    Is there a fix for this for when it turns up blank? For example: http://tcg.slothly.org/trade/elements.php?mastered=1

  3. Bloo

    4 Nov 2013 Administrator kablooey.net

    Yup. But it's highly dependent on how your existing page is set up, so there isn't a &quot;plug-and-play&quot; solution.

    Send me your 'elements.php' or post it here, and I will make it work. |3

  4. effy

    5 Nov 2013 http://twig.slothly.org

    http://pastebin.com/9Kz9d07S :)

  5. Bloo

    5 Nov 2013 Administrator kablooey.net

    Try this:

    <?php
    include 'header.php';
    define('VALID_INC', TRUE); include 'func.php';
    include 'navi.php';
    if (!$_SERVER['QUERY_STRING']) { ?>
    <h1>Elements</h1>
    <table width="100%"><tr><td width="33%" valign="middle" align="center">
    <a href="http://elements.neo-romance.net/" target="_blank"><img src="http://elements.neo-romance.net/images/badges/<?php echo get_additional('Elements','level'); ?>.png" alt="" /></a></td>
    <td width="33%" valign="middle" align="center">
    <strong>Card Count:</strong> <?php echo cardcount('Elements'); ?><br>
    <strong>Card Worth:</strong> <?php echo cardcount('Elements','worth'); ?><br>
    <strong>Last Updated:</strong> <?php $database = new Database;
    		$tcginfo = $database->get_assoc("SELECT * FROM `tcgs` WHERE `name`='Elements'");
    		echo date('j M y', strtotime($tcginfo['lastupdated'])); ?><br>
    <strong># Trades:</strong> <?php echo get_additional('Elements','trades'); ?>
    </td>
    <td width="33%" valign="middle" align="center"><a href="?alog">activity log</a><br>
    <a href="?tlog">trade log</a><br>
    <a href="alogs/elements_alog.txt">activity archive</a><br>
    <a href="alogs/elements_tlog.txt">trade archive</a></td></tr></table>
     
    <h2>Misc. Items</h2>
    <table width="100%">
    <tr><td width="20%" valign="middle" style="text-align: center">
    <h3>Berries</h3>
    <center><img src="http://elements.neo-romance.net/images/pixels/blackberry.gif" alt="" /> x <?php echo get_additional('Elements','blackberry'); ?> &nbsp;<img src="http://elements.neo-romance.net/images/pixels/raspberry.gif" alt="" /> x <?php echo get_additional('Elements','raspberry'); ?></center></td>
     
    <td width="20%" valign="middle" style="text-align: center"><h3>Stars</h3>
    <center><img src="http://elements.neo-romance.net/images/pixels/star1.png" alt="" /> x <?php echo get_additional('Elements','largestar'); ?> <img src="http://elements.neo-romance.net/images/pixels/star2.png" alt="" /> x <?php echo get_additional('Elements','mediumstar'); ?> <img src="http://elements.neo-romance.net/images/pixels/star3.png" alt="" /> x <?php echo get_additional('Elements','smallstar'); ?></center></td>
     
    <td width="25%" valign="middle" style="text-align: center">
    <h3><?php echo get_additional('Elements','choice'); ?> Coupons</h3>
    <center><img src="http://elements.neo-romance.net/images/coupon.gif" alt="" /></center></td>
    </tr></table>
     
    <h3>Orbs</h3>
    <p class="center"><?php show_cards('Elements','orbs'); ?></p>
     
    <h3>Star Charts</h3>
    <p class="center"><?php show_cards('Elements','charts'); ?></p>
     
    <h3>Milestones</h3>
    <p class="center"><?php show_cards('Elements','milestones'); ?></p>
     
    <?php } elseif ($_SERVER['QUERY_STRING'] == "alog") { ?>
    <h1>Activity Log</h1>
    <?php echo str_replace("\n","<br />",get_logs('Elements','activitylog')); ?>
    <?php } elseif ($_SERVER['QUERY_STRING'] == "tlog") { ?>
    <h1>Trade Log</h1>
    <?php echo str_replace("\n","<br />",get_logs('Elements','tradelog')); ?>
    <?php } elseif ($_SERVER['QUERY_STRING'] == "collecting") { ?>
    <center><form action onSubmit="return false;">
    		<input name="search" id="search" />
    		<input value="Search" type="submit" onClick="highlightImage();"/>
    		<input value="Clear" type="submit" onClick="clearHighlight();"/>
    </form>
    <div id="cardlist"></div></center>
     
    <h1>Collecting</h1>
    <h2><?php echo cardcount('Elements','','member'); ?> Member Cards</h2>
    <p class="center"><?php show_cards('Elements','member'); ?></p>
     
    <?php show_collecting('Elements'); ?>
     
    <?php } elseif ($_SERVER['QUERY_STRING'] == "future") { ?>
    <center><form action onSubmit="return false;">
    		<input name="search" id="search" />
    		<input value="Search" type="submit" onClick="highlightImage();"/>
    		<input value="Clear" type="submit" onClick="clearHighlight();"/>
    </form>
    <div id="cardlist"></div></center>
    <h1>Future Decks (<?php echo cardcount('Elements','','future'); ?>)</h1>
    <p class="center"><?php show_cards('Elements','future'); ?></p>
     
    <?php } elseif ($_SERVER['QUERY_STRING'] == "trading") { ?>
    <center><form action onSubmit="return false;">
    		<input name="search" id="search" />
    		<input value="Search" type="submit" onClick="highlightImage();"/>
    		<input value="Clear" type="submit" onClick="clearHighlight();"/>
    </form>
    <div id="cardlist"></div></center>
     
    <h1>Trading (<?php echo cardcount('Elements','','trading'); ?>)</h1>
    <p class="center"><?php show_cards('Elements','trading'); ?></p>
     
    <?php } elseif ($_SERVER['QUERY_STRING'] == "pending") { ?>
    <h1>Pending Trades</h1>
    <?php show_pending('Elements'); ?>
    <?php } elseif ($_SERVER['QUERY_STRING'] == "mastered") { ?>
    <h1>Mastered Decks</h1>
    <?php show_mastered('Elements'); ?>
    <?php } else if ( isset($_GET['mastered']) && $_GET['mastered'] !== '' ) { $deckid = intval($_GET['mastered']);
     
    	$tcginfo = $database->get_assoc("SELECT * FROM `tcgs` WHERE `name`='Elements' LIMIT 1");
     
    	if ( $database->num_rows("SELECT * FROM `collecting` WHERE `id`='$deckid' AND `tcg`='".$tcginfo['id']."' LIMIT 1") > 0 ) {
     
    		$deckinfo = $database->get_assoc("SELECT * FROM `collecting` WHERE `id`='$deckid' AND `tcg`='".$tcginfo['id']."' LIMIT 1");
    		$cards = explode(',',$deckinfo['cards']);
    		array_walk($cards, 'trim_value');
     
    		$count = count($cards);    
     
    		echo '<h1>mastered</h1>';
    		echo '<p align="center">';
    		echo '<strong>'.$deckinfo['deck'].'</strong> - <em>'.date('F d, Y',strtotime($deckinfo['mastereddate'])).'</em><br />';
     
    		for ( $i = 1; $i <= $deckinfo['count']; $i++ ) {
    			$number = $i;
     
    			if ( $number < 10 ) { $number = "0$number"; }
    			$card = "".$deckinfo['deck']."$number";
    			$pending = $database->num_rows("SELECT * FROM `trades` WHERE `tcg`='$id' AND `receiving` LIKE '%$card%'");
     
    			if ( in_array($card, $cards) ) echo '<img src="'.$tcginfo['cardsurl'].''.$card.'.'.$tcginfo['format'].'" alt="" />';
    			else if ( $pending > 0 ) { echo '<img src="'.$tcginfo['cardsurl'].''.$deckinfo['pending'].'.'.$tcginfo['format'].'" alt="" />'; }
    			else { echo '<img src="'.$tcginfo['cardsurl'].''.$deckinfo['filler'].'.'.$tcginfo['format'].'" alt="" />'; }
     
    			if ( $deckinfo['puzzle'] == 0 ) { echo ' '; }
    			if ( $deckinfo['break'] !== '0' && $i % $deckinfo['break'] == 0 ) { echo '<br />'; }
     
    		}
     
    		echo '</p>';
     
    	}
       
    }
     
    ?>
     
    <?php   
    include 'footer.php'; ?>
  6. Would it be best to completely start from scratch with the mastered page and use the snippets that you posted? I have the same problem with my mastered cards.

  7. Bloo

    5 Nov 2013 Administrator kablooey.net

    Not sure what you mean by start from scratch. :0a

    But if you've already got a working mastered decks page and just need the mod applied, you can attach/paste the page source code here (or email if you prefer: bloo@filler00.com) and I can probably get it working for you without having to make an entirely new page. ^^

  8. Oh, sorry! I totally forgot about this :P

    What I meant was, start a brand new "mastered.php" page using the code snippets that you provided above. I've done a bunch of tweaking to my mastered page trying to get it working, but with no avail.

  9. Bloo

    30 Jan 2014 Administrator kablooey.net

    If you wanted to just post the code here for me to fix it, you can just post whatever you currently have - I can figure it out either way. C:

    But if you wanted to give it another shot on your own, a fresh start might be best.

  10. I'll give it a try on my own and see if I can make it work. I'll just start from scratch with a new test directory. If I have any issues, I'll let you know :)

  11. Phyx

    19 Apr 2014 http://phantasmic.7pz.me

    Hello I'm having a problem, I just got myself back into TCGs and I'm remodelling my Tradepost and I noticed that when I click on my badge for a mastered deck I get this error:

    Fatal error: Call to a member function get_assoc() on a non-object in /home/-----------/public_html/1up/mastered.php on line 13.

    I don't understand what happened because I haven't changed any coding except what's related to the styling, and it was working before.

    This is the line of code

     $tcginfo = $database->get_assoc("SELECT * FROM `tcgs` WHERE `name`='1up' LIMIT 1");

    Thanks for your help

    ~Phyx

  12. Bloo

    20 Apr 2014 Administrator kablooey.net

    Could you please send or attach your entire 'mastered.php' file, as well as your 'func.php'? Thanks! <3

  13. Phyx

    21 Apr 2014 http://phantasmic.7pz.me

    Here they are.
    Again, thank you for your help.

  14. Bloo

    25 Apr 2014 Administrator kablooey.net

    Sorry for the delay getting back to this. Your code actually looks fine to me - not sure why it suddenly stopped working. :/ Did you change hosts by any chance? Also, do you know which version of PHP you are running? It's possible that your host changed something in the PHP or server configuration - most likely what happened if it was working previously and you really haven't changed anything yourself.

    You can give this 'mastered.php' a try - not sure it will help, but let me know what it does in any case.

  15. I had the exact same error as what Phyx had, and I tried using the 'mastered.php' attached above, but the same error still happened. I actually posted here a moment ago for help, then my friend sent me her working copy of her mastered page for me to see what I had done wrong and I realised there was just one little difference in her code, in which I tried adding it in, and that made mine work.

    This is the first line from the above attached 'mastered.php'.

    <?php if ( isset($_GET['mastered']) && $_GET['mastered'] !== '' ) { $deckid = intval($_GET['mastered']);

    This is the first line from my friend's working code.

    <?php if ( isset($_GET['mastered']) && $_GET['mastered'] !== '' ) {$database = new Database; $deckid = intval($_GET['mastered']);

    Also, I had to add this at the top with the include header code

    <?php include '/home/messejji/hyunseong/func.php' ?>[/code] in order for mine to work, if not I will get some error that states "[b]Fatal error: Call to undefined function show_mastered() in /home/messejji/hyunseong/dillydallymastered.php on line 46[/b]" in which the code on line 46 was [code]<?php show_mastered('dillydally'); ?>

    I hope this helps!! :)

  16. Phyx

    26 Apr 2014 http://phantasmic.7pz.me

    The new mastered.php gave me the same error, but the code from messejji's friend worked. Thanks for both of you all's help. :D

  17. I've tried all codes given here but since I seem to have a different error, it was probably natural that none of the above worked... orz

    It used to work perfectly well, and I hadn't changed anything in the php coding other than styling or html.
    Here is my error message:
    Fatal error: Cannot redeclare get_logs() (previously declared in /home/saita/public_html/func.php:122) in /home/-----/public_html/func.php on line 136

    I have attached my func.php and copied the code from my mastered page
    The forum won't let me upload the latter because it was identified as a possible attack vector :c

    Here is the code in my mastered page:

    <?php } elseif ( isset($_GET['mastered']) && $_GET['mastered'] !== '' ) {
    	define('VALID_INC', TRUE); include '/home/saita/public_html/func.php';
    
    	$database = new Database;
    	$deckid = intval($_GET['mastered']); 
    	
        $tcginfo = $database->get_assoc("SELECT * FROM `tcgs` WHERE `name`='himitsu' LIMIT 1"); 
    
        if ( $database->num_rows("SELECT * FROM `collecting` WHERE `id`='$deckid' AND `tcg`='".$tcginfo['id']."' LIMIT 1") > 0 ) { 
    
            $deckinfo = $database->get_assoc("SELECT * FROM `collecting` WHERE `id`='$deckid' AND `tcg`='".$tcginfo['id']."' LIMIT 1"); 
            $cards = explode(',',$deckinfo['cards']);  
            array_walk($cards, 'trim_value'); 
    
            $count = count($cards);     
    
            echo '<h1>mastered</h1>'; 
            echo '<p align="center">'; 
            echo '<strong>'.$deckinfo['deck'].'</strong> - <em>'.date('F d, Y',strtotime($deckinfo['mastereddate'])).'</em><br />'; 
    
            for ( $i = 1; $i <= $deckinfo['count']; $i++ ) { 
                $number = $i; 
    
                if ( $number < 10 ) { $number = "0$number"; } 
                $card = "".$deckinfo['deck']."$number"; 
                $pending = $database->num_rows("SELECT * FROM `trades` WHERE `tcg`='$id' AND `receiving` LIKE '%$card%'");
    
                if ( in_array($card, $cards) ) echo '<img src="'.$tcginfo['cardsurl'].''.$card.'.'.$tcginfo['format'].'" alt="" />';
                else if ( $pending > 0 ) { echo '<img src="'.$tcginfo['cardsurl'].''.$deckinfo['pending'].'.'.$tcginfo['format'].'" alt="" />'; }
                else { echo '<img src="'.$tcginfo['cardsurl'].''.$deckinfo['filler'].'.'.$tcginfo['format'].'" alt="" />'; }
    
                if ( $deckinfo['puzzle'] == 0 ) { echo ' '; } 
                if ( $deckinfo['break'] !== '0' && $i % $deckinfo['break'] == 0 ) { echo '<br />'; } 
    
            } 
    
            echo '</p>'; 
    
        }
    
    ?>

    :Oa
    thank you for all the help! I appreciate it a lot uwu

  18. Is that all of the code for your master page? (I'm wondering about the first "}" in the first line)
    If there's more code than that, make sure you're not including func.php twice in the file.

  19. <?php include('header.php'); ?>
    
    <?php if (!$_SERVER['QUERY_STRING']) { ?>
    
    <?php } elseif ($_SERVER['QUERY_STRING'] == "mastered" && $_GET['mastered'] == '' ) { ?>
    
    <p>
    <h1>Mastered Decks</h1>
    <small>mastered decks !!!</small>
    <br>
     <br>
      <br>
    <center>
    <?php show_mastered('himitsu'); ?>
    
    </center>
    
    <?php } elseif ( isset($_GET['mastered']) && $_GET['mastered'] !== '' ) {
    	define('VALID_INC', TRUE); include '/home/saita/public_html/func.php';
    
    	$database = new Database;
    	$deckid = intval($_GET['mastered']); 
    	
        $tcginfo = $database->get_assoc("SELECT * FROM `tcgs` WHERE `name`='himitsu' LIMIT 1"); 
    
        if ( $database->num_rows("SELECT * FROM `collecting` WHERE `id`='$deckid' AND `tcg`='".$tcginfo['id']."' LIMIT 1") > 0 ) { 
    
            $deckinfo = $database->get_assoc("SELECT * FROM `collecting` WHERE `id`='$deckid' AND `tcg`='".$tcginfo['id']."' LIMIT 1"); 
            $cards = explode(',',$deckinfo['cards']);  
            array_walk($cards, 'trim_value'); 
    
            $count = count($cards);     
    
            echo '<h1>mastered</h1>'; 
            echo '<p align="center">'; 
            echo '<strong>'.$deckinfo['deck'].'</strong> - <em>'.date('F d, Y',strtotime($deckinfo['mastereddate'])).'</em><br />'; 
    
            for ( $i = 1; $i <= $deckinfo['count']; $i++ ) { 
                $number = $i; 
    
                if ( $number < 10 ) { $number = "0$number"; } 
                $card = "".$deckinfo['deck']."$number"; 
                $pending = $database->num_rows("SELECT * FROM `trades` WHERE `tcg`='$id' AND `receiving` LIKE '%$card%'");
    
                if ( in_array($card, $cards) ) echo '<img src="'.$tcginfo['cardsurl'].''.$card.'.'.$tcginfo['format'].'" alt="" />';
                else if ( $pending > 0 ) { echo '<img src="'.$tcginfo['cardsurl'].''.$deckinfo['pending'].'.'.$tcginfo['format'].'" alt="" />'; }
                else { echo '<img src="'.$tcginfo['cardsurl'].''.$deckinfo['filler'].'.'.$tcginfo['format'].'" alt="" />'; }
    
                if ( $deckinfo['puzzle'] == 0 ) { echo ' '; } 
                if ( $deckinfo['break'] !== '0' && $i % $deckinfo['break'] == 0 ) { echo '<br />'; } 
    
            } 
    
            echo '</p>'; 
    
        }
    
    ?>
    <?php } ?>
    
    <?php include('footer.php'); ?>

    ugh i thought I had included the top and bottom of the code oups...orz
    thanks for any help!!

  20. Looking at the show_mastered got me wondering: do you include func.php inside your header.php? If so, You don't need to include it again. Your header is before your if statement, so it'll always show up, which means func.php is already added to the file.
    Func.php is a file that declares a lot of functions, so when it's included twice, they get "redeclared", causing the error. It only says "get_logs()' because that's the first function declared in func.php, so that's where it finds the error and stops.

  21. Newer ›

or Sign Up to reply!