View Single Post
  #1  
Old 02-15-2016, 10:27 PM
tahbikat's Avatar
tahbikat tahbikat is offline
Member
 
Join Date: Feb 2014
Location: Louisiana
Posts: 408
Gender: Female
Credits: 67,748
tahbikat is on a distinguished road
Default Need help fixing a bug?

Okay, so something weird is happening.

This is my levelup page's code. Frozen creatures of any level have certain stats that won't display because they're frozen. They also have a little comment saying "This creature's frozen"

So oddly enough, certain frozen creatures are just like, bypassing this and displaying like normal, even though they are definitely frozen.

Someone help? ;-; It was working fine before. I did make some changes to other pages and added a db column under owned_adopts. I just don't understand why some of the frozen adopts' stats are displaying correctly, and others aren't. If anything else is needed let me know!

EDIT: It seems like maybe it's something to do with newly frozen creatures... I think... All my creatures that I froze days and weeks ago are fine. The new ones are the ones that kind of just ignore the whole function.

PHP Code:
<?php

use Resource\Native\Integer;
use 
Resource\Collection\ArrayList;
use 
Resource\Utility\Curl;

class 
LevelupController extends AppController{

    const 
PARAM "aid";
    private 
$adopt;
    private 
$settings;

    public function 
__construct(){
        
parent::__construct();
        
$this->settings = new LevelSetting;
        
$mysidia Registry::get("mysidia");

        if(
$mysidia->input->action() == "click" or $mysidia->input->action() == "siggy"$this->adopt = new OwnedAdoptable($mysidia->input->get("aid"));
        if(
$mysidia->user instanceof Member){
            
$status $mysidia->user->getstatus();   
            if(
$status->canlevel == "no") throw new InvalidActionException("banned");
        }    
    }
    
    public function 
index(){
        throw new 
InvalidActionException("global_action");
    }
    
public function 
click(){
    
$mysidia Registry::get("mysidia");
    
$date = new DateTime;
    
$ip secure($_SERVER['REMOTE_ADDR']);

    
/*... First check if the system to levelup pets is enabled ...*/
    
if($this->settings->system != "enabled") { throw new NoPermissionException("disabled"); }

    
/*... Then check if the user has already visited the pet today ...*/
    
elseif($this->adopt->hasVoter($mysidia->user$date)){
        if(
$this->adopt->hasNextLevel()){
            
$nextLevel $this->adopt->getNextLevel();
            
$requiredClicks $nextLevel->getRequiredClicks();
        }

        
$gender_lookup $mysidia->db->select("owned_adoptables", array("gender"), "aid = '{$this->adopt->getAdoptID()}'")->fetchColumn();
        if (
$gender_lookup == "m") { $gender "Male"$pronoun "him"; } else { $gender "Female"$pronoun "her"; } 
        
        
$alternates_lookup $mysidia->db->select("owned_adoptables", array("usealternates"), "aid = '{$this->adopt->getAdoptID()}'")->fetchColumn();
        if (
$alternates_lookup == "yes") { $usealternates "Variant"; } else { $usealternates "Normal"; }

        if (
$mysidia->user->username == $this->adopt->getOwner()){ $manage_btn "<i><a class='btn btn-sm btn-info' href='../../myadopts/manage/{$this->adopt->getAdoptID()}'> Manage {$this->adopt->getName()}</a></i><br /><br />"; } else { $manage_btn ""; }

        if(
$this->adopt->hasNextLevel()){
            
$level $this->adopt->getNextLevel();
            
$levelupClicks $this->adopt->getLevelupClicks();
            
$toNext "(LVL ".$level->getLevel()." in ".$levelupClicks." more EXP)"
        } 
        else { 
$toNext "(MAX)"; }

        if(
$this->adopt->getTradeStatus() == "fortrade") { $tradestatus "For Trade"; } 
        else { 
$tradestatus "Not For Trade"; }

        
$message "<div class='adopt_profile'>    <h2>{$this->adopt->getName()} (#{$this->adopt->getAdoptID()})</h2>    ";
        
        
// If you've already seen the pet today:
        
if ($this->adopt->hasVoter($mysidia->user$date)){
            
$message .= "<div class='already-seen-msg'><b>Thanks!</b>  You already visited this creature today!</div>";
        }
        
// If you haven't seen the pet today:
        
if (!$this->adopt->hasVoter($mysidia->user$date)){
            
$message .= "<div style='display: inline;'><span class='button'>Play</span></div>";
        }
        if (
$this->adopt->getCurrentLevel() == 0){
        
/*if current level is less than three do this*/
            
$message .= "<div class='pet-img'>{$manage_btn}
            <img src='
{$this->adopt->getImage()}'/><br /><br />
            <img src='/picuploads/
{$this->adopt->getRarity()}.png' title='{$this->adopt->getRarity()} Species, ???' style='margin-right: -3px;' /><br /><br />
            
            <hr id='pethr'>
            <p style='text-align: left;'><b>
{$this->adopt->getName()}'s Bio:</b> Not available until hatched.</p>
            </div>
            <div class='pet-stats'>
                        <ul class='profile-list'>
                        <li class='statsFloat'><b>Owner</b>: <a href='/profile/view/
{$this->adopt->getOwner()}'>{$this->adopt->getOwner()}</a></li>
                        <li class='statsFloat'><b>Species</b>: 
{$this->adopt->getType()}</li>
                        <li class='statsFloat'><b>Obtained From</b>: 
{$this->adopt->getObtainedFrom()}</li>
                        <li class='statsFloat'><b>Total Points</b>: 
{$this->adopt->getTotalClicks()}</li>
                        <li class='statsFloat'><b>Obtained On</b>: 
{$this->adopt->getObtainedOn()}</li>
                        <li class='statsFloat'><b>Level</b>: 
{$this->adopt->getCurrentLevel()}</li>
                        <li class='statsFloat'><b>Trade Status</b>: 
{$tradestatus}</li> 

                        </ul>
                        <b>Description</b>: 
{$this->adopt->getDescription()}<br /><br />
                        </div>"
;

        throw new 
LevelupException($message);
        }
                if (
$this->adopt->getCurrentLevel() == 1){
        
/*if current level is less than three do this*/
            
$message .= "<div class='pet-img'>{$manage_btn}
            <img src='
{$this->adopt->getImage()}'/><br /><br />
            <img src='/picuploads/
{$this->adopt->getRarity()}.png' title='{$this->adopt->getRarity()} Species, ???' style='margin-right: -3px;' /><br /><br />
            
            <hr id='pethr'>
            <p style='text-align: left;'><b>
{$this->adopt->getName()}'s Bio:</b> Not available until hatched.</p>
            </div>
            <div class='pet-stats'>
                        <ul class='profile-list'>
                        <li class='statsFloat'><b>Owner</b>: <a href='/profile/view/
{$this->adopt->getOwner()}'>{$this->adopt->getOwner()}</a></li>
                        <li class='statsFloat'><b>Species</b>: 
{$this->adopt->getType()}</li>
                        <li class='statsFloat'><b>Obtained From</b>: 
{$this->adopt->getObtainedFrom()}</li>
                        <li class='statsFloat'><b>Total Points</b>: 
{$this->adopt->getTotalClicks()}</li>
                        <li class='statsFloat'><b>Obtained On</b>: 
{$this->adopt->getObtainedOn()}</li>
                        <li class='statsFloat'><b>Level</b>: 
{$this->adopt->getCurrentLevel()}</li>
                        <li class='statsFloat'><b>Trade Status</b>: 
{$tradestatus}</li> 

                        </ul>
                        <b>Description</b>: 
{$this->adopt->getDescription()} It has started to shake! It must be very close to hatching.<br /><br />
                        </div>"
;

        throw new 
LevelupException($message);
        }
         if (
$this->adopt->getCurrentLevel() == 2){
        
/*if current level is less than three do this*/ 
            
$message .= "<div class='pet-img'>{$manage_btn}
            <img src='
{$this->adopt->getImage()}'/><br /><br />
            <img src='/picuploads/
{$this->adopt->getRarity()}.png' title='{$this->adopt->getRarity()} Species, {$usealternates}' style='margin-right: -3px;' /> <img src='/picuploads/{$usealternates}.png' title='{$this->adopt->getRarity()} Species, {$usealternates}' /><br /><br />
            
            <hr id='pethr'>
            <p style='text-align: left;'><b>
{$this->adopt->getName()}'s Bio:</b> {$this->adopt->getPetBio()}</p>
            <p style='text-align: right; margin: 0; padding: 0;'><a href='' class='reportexclam'><img src='/picuploads/reportimg.png' title='Report this bio' /></a></p>
            </div>
            <div class='pet-stats'>
                        <ul class='profile-list'>
                        <li class='statsFloat'><b>Owner</b>: <a href='/profile/view/
{$this->adopt->getOwner()}'>{$this->adopt->getOwner()}</a></li>
                        <li class='statsFloat'><b>Personality</b>: 
{$this->adopt->getAdoptPersonality()}</li>
                        <li class='statsFloat'><b>Species</b>: 
{$this->adopt->getType()}</li>
                        <li class='statsFloat'><b>Magic Skill</b>: 
{$this->adopt->getMagic()}/100</li>
                        <li class='statsFloat'><b>Gender</b>: 
{$gender}</li>
                        <li class='statsFloat'><b>Obtained From</b>: 
{$this->adopt->getObtainedFrom()}</li>
                        <li class='statsFloat'><b>Total Points</b>: 
{$this->adopt->getTotalClicks()}</li>
                        <li class='statsFloat'><b>Obtained On</b>: 
{$this->adopt->getObtainedOn()}</li>
                        <li class='statsFloat'><b>Level</b>: 
{$this->adopt->getCurrentLevel()}</li>
                        <li class='statsFloat'><b>Trade Status</b>: 
{$tradestatus}</li> 

                        </ul>
                        <b>Description</b>: Oh look! Your egg has hatched into a little creature. 
{$this->adopt->getHatchyDescription()}<br /><br />
                        </div>"
;
              
        throw new 
LevelupException($message);
        }else {
/*well else it must be three or greater, so do this*/
            
$message .= "<div class='pet-img'>{$manage_btn}
            <img src='
{$this->adopt->getImage()}'/><br /><br />
            <img src='/picuploads/
{$this->adopt->getRarity()}.png' title='{$this->adopt->getRarity()} Species, {$usealternates}' style='margin-right: -3px;' /> <img src='/picuploads/{$usealternates}.png' title='{$this->adopt->getRarity()} Species, {$usealternates}' /><br /><br />
            
            <hr id='pethr'>
            <p style='text-align: left;'><b>
{$this->adopt->getName()}'s Bio:</b> {$this->adopt->getPetBio()}</p>
            <p style='text-align: right; margin: 0; padding: 0;'><a href='' class='reportexclam'><img src='/picuploads/reportimg.png' title='Report this bio' /></a></p>
            </div>
            <div class='pet-stats'>
                        <ul class='profile-list'>
                        <li class='statsFloat'><b>Owner</b>: <a href='/profile/view/
{$this->adopt->getOwner()}'>{$this->adopt->getOwner()}</a></li>
                        <li class='statsFloat'><b>Personality</b>: 
{$this->adopt->getAdoptPersonality()}</li>
                        <li class='statsFloat'><b>Species</b>: 
{$this->adopt->getType()}</li>
                        <li class='statsFloat'><b>Magic Skill</b>: 
{$this->adopt->getMagic()}/100</li>
                        <li class='statsFloat'><b>Gender</b>: 
{$gender}</li>
                        <li class='statsFloat'><b>Obtained From</b>: 
{$this->adopt->getObtainedFrom()}</li>
                        <li class='statsFloat'><b>Total Points</b>: 
{$this->adopt->getTotalClicks()}</li>
                        <li class='statsFloat'><b>Obtained On</b>: 
{$this->adopt->getObtainedOn()}</li>
                        <li class='statsFloat'><b>Level</b>: 
{$this->adopt->getCurrentLevel()}</li>
                        <li class='statsFloat'><b>Trade Status</b>: 
{$tradestatus}</li> 

                        </ul>
                        <b>Description</b>: 
{$this->adopt->getAdultDescription()}<br /><br />
                        </div>"
;
 
        throw new 
LevelupException($message); 

}  
     
}
    
/*... But do this if the pet is frozen! ...*/
    
elseif($this->adopt->isFrozen() == "yes") {  $gender_lookup $mysidia->db->select("owned_adoptables", array("gender"), "aid = '{$this->adopt->getAdoptID()}'")->fetchColumn();
        if (
$gender_lookup == "m") { $gender "Male"$pronoun "him"; } else { $gender "Female"$pronoun "her"; } 
        
        
$alternates_lookup $mysidia->db->select("owned_adoptables", array("usealternates"), "aid = '{$this->adopt->getAdoptID()}'")->fetchColumn();
        if (
$alternates_lookup == "yes") { $usealternates "Variant"; } else { $usealternates "Normal"; }
        
        if (
$mysidia->user->username == $this->adopt->getOwner()){ $manage_btn "<i><a class='btn btn-sm btn-info' href='../../myadopts/manage/{$this->adopt->getAdoptID()}'> Manage {$this->adopt->getName()}</a></i><br /><br />"; } else { $manage_btn ""; }
        
        if(
$this->adopt->getTradeStatus() == "fortrade") { $tradestatus "For Trade"; } 
        else { 
$tradestatus "Not For Trade"; }
        
        
$message "<div class='adopt_profile'>    <h2>{$this->adopt->getName()} (#{$this->adopt->getAdoptID()})</h2>    ";
        
$message .= "<div class='already-seen-msg'><img src='/picuploads/yes.png' /> This creature is frozen, your click has not been counted.</div>";
        
        
$message .= "<div class='pet-img'>{$manage_btn}
            <img src='
{$this->adopt->getImage()}'/><br /><br />
            <img src='/picuploads/
{$this->adopt->getRarity()}.png' title='{$this->adopt->getRarity()} Species, {$usealternates}' style='margin-right: -3px;' /> <img src='/picuploads/{$usealternates}.png' title='{$this->adopt->getRarity()} Species, {$usealternates}' /><br /><br />
            
            <hr id='pethr'>
            <p style='text-align: left;'><b>
{$this->adopt->getName()}'s Bio:</b> Not available when frozen.</p>
            </div>
            <div class='pet-stats'>
                        <ul class='profile-list'>
                        <li class='statsFloat'><b>Owner</b>: <a href='/profile/view/
{$this->adopt->getOwner()}'>{$this->adopt->getOwner()}</a></li>
                        <li class='statsFloat'><b>Species</b>: 
{$this->adopt->getType()}</li>
                        <li class='statsFloat'><b>Gender</b>: 
{$gender}</li>
                        <li class='statsFloat'><b>Obtained From</b>: 
{$this->adopt->getObtainedFrom()}</li>
                        <li class='statsFloat'><b>Total Points</b>: 
{$this->adopt->getTotalClicks()}</li>
                        <li class='statsFloat'><b>Obtained On</b>: 
{$this->adopt->getObtainedOn()}</li>
                        <li class='statsFloat'><b>Level</b>: 
{$this->adopt->getCurrentLevel()}</li>
                        <li class='statsFloat'><b>Trade Status</b>: 
{$tradestatus}</li> 

                        </ul>

                        </div>"
;
                        
                        throw new 
LevelupException($message);
                        }
                        

    
/*... This one, if enabled, would prevent users from visiting a pet too much a day ...*/
    # elseif($mysidia->user->getVotes() > $this->settings->number) { throw new LevelupException("number"); }

    /*... If this setting were on in the backend, it would prevent the users from visiting their own pets ...*/
    # elseif($this->settings->owner == "disabled" and $this->adopt->getOwner() == $mysidia->user->username){ throw new LevelupException("owner");}
    
    /*... If the visitor has not seen the pet today, this will be displayed and the pet will level up! ...*/
    
else{
        
$newClicks $this->adopt->getTotalClicks() + 1;
        
$this->adopt->setTotalClicks($newClicks"update");
        
$mysidia->db->insert("vote_voters", array("void" => NULL"date" => $date->format('Y-m-d'), "username" => $mysidia->user->username"ip" => $ip"adoptableid" => $mysidia->input->get("aid")));         
        
        
$ago date('Y-m-d'strtotime('-40 days'));
        
$mysidia->db->delete("vote_voters""date < '{$ago}'");    

        if(
$this->adopt->hasNextLevel()){
            
$nextLevel $this->adopt->getNextLevel();
            
$requiredClicks $nextLevel->getRequiredClicks();
            if(
$requiredClicks and $newClicks >= $requiredClicks) { $this->adopt->setCurrentLevel($nextLevel->getLevel(), "update"); }
        }
        
        
$reward $mysidia->user->clickreward($this->settings->reward);
        
$mysidia->user->changecash($reward);            
        
$this->setField("adopt"$this->adopt);
        
$this->setField("reward", new Integer($reward));            
    }
}  

    public function 
siggy(){
        
$mysidia Registry::get("mysidia");
        
// The adoptable is available, let's collect its info
        
$usingimage "no";
        
$image $this->adopt->getImage(); 
      
        
$usegd $mysidia->settings->gdimages;
        
$imageinfo = @getimagesize($image);
        
$imagemime $imageinfo["mime"]; // Mime type of the image file, should be a .gif file...

        
if(function_exists('imagegif') and $usegd == "yes" and $imagemime == "image/gif"){
            
$usingimage "yes"//Turn the template system off
            
$type $this->adopt->getType();
            list(
$width$height$type$attr) = getimagesize($image); // The size of the original adoptable image

            // Lets create the new target image, with a size big enough for the text for the adoptable
            
$newheight $height 72;
            
$newwidth = ($newwidth 250)?250:$width;
            
$img_temp imagecreatetruecolor($newwidth$newheight); 
            
$alphablending true;  
         
            
// Lets create the image and save its transparency  
            
$img_old = @imagecreatefromgif($image);  
            
imagealphablending($img_oldtrue);  
            
imagesavealpha($img_oldtrue);
   
            
// Lets copy the old image into the new image with  
            
ImageCopyResampled($img_temp$img_old0000$width$height$width$height);    
            
$textheight $width 2;
            
$image $img_temp;
            
$bgi imagecreatetruecolor($newwidth$newheight);
            
$color imagecolorallocate($bgi515151);
         
            
// Build text for siggy
            
$str1 "Name: ".$this->adopt->getName();
            
$str2 "Owner: ".$this->adopt->getOwner();
            
$str3 "Click Here to Feed Me!";
            
$str4 "More Adopts at:";
            
$str5 "www.".constant("DOMAIN");

            
// Renger Image
            
imagestring ($image120$textheight,  $str1$color);
            
imagestring ($image120$textheight 13,  $str2$color);
            
imagestring ($image120$textheight 26,  $str3$color);
            
imagestring ($image120$textheight 42,  $str4$color);
            
imagestring ($image120$textheight 55,  $str5$color);
            
$background imagecolorallocate($image000);  
            
ImageColorTransparent($image$background);  
 
            
// At the very last, let's clean up temporary files
            
header("Content-Type: image/GIF");
            
ImageGif ($image);
            
imagedestroy($image);
            
imagedestroy($img_temp);
            
imagedestroy($img_old);
            
imagedestroy($bgi);

        }
        else{      
                
// We are going to try and get this image the old fashioned way...
            
$extList = array();
            
$extList['gif'] = 'image/gif';
            
$extList['jpg'] = 'image/jpeg';
            
$extList['jpeg'] = 'image/jpeg';
            
$extList['png'] = 'image/png';

            
//Define the output file type
            
$contentType 'Content-type: '.$extList$imageinfo['extension'] ];

            if(
$imageinfo['extension'] =! "image/gif" and $imageinfo['extension'] =! "image/jpeg" and $imageinfo['extension'] =! "image/png"){             
                throw new 
InvalidIDException("The file Extension is not allowed!");
            }
            else{
                
// File type is allowed, so proceed
                
$status "";
                
header($contentType);
                
$curl = new Curl($image);
                
$curl->setHeader();
                
$curl->exec();
                
$curl->close();
            } 
        }
    }
    
    public function 
daycare(){        
        
$daycare = new Daycare;
        
$adopts $daycare->getAdopts();
        
$this->setField("daycare"$daycare);
    }
}
?>

Last edited by tahbikat; 02-15-2016 at 10:59 PM.
Reply With Quote