Mys 1.3.x Stat/SKill System

Forum
Last Post
Threads / Messages
Ok, let's take this step by step.
Try this code on a non-frozen adopt(refresh the page after clicking):
PHP:
<?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']);
		$adoptablestatname = $this->adopt->getAdoptstatname();

		if($this->settings->system != "enabled") throw new NoPermissionException("disabled");
        elseif($this->adopt->hasVoter($mysidia->user, $date)){





		    $message = "<div id='stats'>Statname: {$adoptablestatname}</div>";
$message = $message .= (($mysidia->user instanceof Member)?$mysidia->lang->already_leveled_member:$mysidia->lang->already_leveled_guest);  


			throw new LevelupException($message);		
	    }
		




		
		
		elseif($this->adopt->isFrozen() == "yes") throw new LevelupException("frozen");
        elseif($mysidia->user->getVotes() > $this->settings->number) throw new LevelupException("number");
        elseif($this->settings->owner == "disabled" and $this->adopt->getOwner() == $mysidia->user->username){
 			throw new LevelupException("owner");	           
        }
		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")));		 
			
			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_old, true);  
            imagesavealpha($img_old, true);
   
            // Lets copy the old image into the new image with  
            ImageCopyResampled($img_temp, $img_old, 0, 0, 0, 0, $width, $height, $width, $height);    
	        $textheight = $width + 2;
	        $image = $img_temp;
            $bgi = imagecreatetruecolor($newwidth, $newheight);
            $color = imagecolorallocate($bgi, 51, 51, 51);
		 
		    // Build text for siggy
            $str1 = "Name: ".$this->adopt->getName();
            $str2 = "Owner: ".$this->adopt->getOwner();
	        $str3 = "Click Here to Boost Me!";
	        $str4 = "More Pets at:";
	        $str5 = "www.".constant("DOMAIN");

            // Renger Image
	        imagestring ($image, 12, 0, $textheight,  $str1, $color);
	        imagestring ($image, 12, 0, $textheight + 13,  $str2, $color);
	        imagestring ($image, 12, 0, $textheight + 26,  $str3, $color);
	        imagestring ($image, 12, 0, $textheight + 42,  $str4, $color);
	        imagestring ($image, 12, 0, $textheight + 55,  $str5, $color);
	        $background = imagecolorallocate($image, 0, 0, 0);  
            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);
	}
}
?>
If that magically works, try this on a frozen adopt(refresh the page after clicking):
PHP:
<?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']);
		$adoptablestatname = $this->adopt->getAdoptstatname();

		if($this->settings->system != "enabled") throw new NoPermissionException("disabled");
        elseif($this->adopt->hasVoter($mysidia->user, $date)){





		    $message = "<div id='stats'>Statname: {$adoptablestatname}</div>";
$message = $message .= (($mysidia->user instanceof Member)?$mysidia->lang->already_leveled_member:$mysidia->lang->already_leveled_guest);  


			throw new LevelupException($message);		
	    }
		




		
		
		elseif($this->adopt->isFrozen() == "yes") 
		$frozenmessage = "<div id='stats'>
Statname: {$adoptablestatname}
</div><br>
We're sorry, but you cannot add clicks to this adoptable at this time because its owner has chosen to freeze it.  Frozen adoptables do not accept new clicks and do not level up.  Thanks anyway for the click though, but the owner of this adoptable wants to keep this adoptable young so it will not be counted.";
		throw new LevelupException($frozenmessage);
        elseif($mysidia->user->getVotes() > $this->settings->number) throw new LevelupException("number");
        elseif($this->settings->owner == "disabled" and $this->adopt->getOwner() == $mysidia->user->username){
 			throw new LevelupException("owner");	           
        }
		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")));		 
			
			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_old, true);  
            imagesavealpha($img_old, true);
   
            // Lets copy the old image into the new image with  
            ImageCopyResampled($img_temp, $img_old, 0, 0, 0, 0, $width, $height, $width, $height);    
	        $textheight = $width + 2;
	        $image = $img_temp;
            $bgi = imagecreatetruecolor($newwidth, $newheight);
            $color = imagecolorallocate($bgi, 51, 51, 51);
		 
		    // Build text for siggy
            $str1 = "Name: ".$this->adopt->getName();
            $str2 = "Owner: ".$this->adopt->getOwner();
	        $str3 = "Click Here to Boost Me!";
	        $str4 = "More Pets at:";
	        $str5 = "www.".constant("DOMAIN");

            // Renger Image
	        imagestring ($image, 12, 0, $textheight,  $str1, $color);
	        imagestring ($image, 12, 0, $textheight + 13,  $str2, $color);
	        imagestring ($image, 12, 0, $textheight + 26,  $str3, $color);
	        imagestring ($image, 12, 0, $textheight + 42,  $str4, $color);
	        imagestring ($image, 12, 0, $textheight + 55,  $str5, $color);
	        $background = imagecolorallocate($image, 0, 0, 0);  
            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);
	}
}
?>
And if that magically works, try this on all kinds of adopts:
PHP:
<?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']);
		$adoptablestatname = $this->adopt->getAdoptstatname();
		$adoptablename = $this->adopt->getName();

		if($this->settings->system != "enabled") throw new NoPermissionException("disabled");
        elseif($this->adopt->hasVoter($mysidia->user, $date)){





		    $message = "<div id='stats'>Statname: {$adoptablestatname}</div>";
$message = $message .= (($mysidia->user instanceof Member)?$mysidia->lang->already_leveled_member:$mysidia->lang->already_leveled_guest);  


			throw new LevelupException($message);		
	    }
		




		
		
		elseif($this->adopt->isFrozen() == "yes") 
		$frozenmessage = "<div id='stats'>
Statname: {$adoptablestatname}
</div><br>
We're sorry, but you cannot add clicks to this adoptable at this time because its owner has chosen to freeze it.  Frozen adoptables do not accept new clicks and do not level up.  Thanks anyway for the click though, but the owner of this adoptable wants to keep this adoptable young so it will not be counted.";
		throw new LevelupException($frozenmessage);
        elseif($mysidia->user->getVotes() > $this->settings->number) throw new LevelupException("number");
        elseif($this->settings->owner == "disabled" and $this->adopt->getOwner() == $mysidia->user->username){
 			throw new LevelupException("owner");	           
        }
		else{
		  $levelupmessage = "<br><text align ='center'><div id='clickpagelink'><a href='{$mysidia->path->getAbsolute()}levelup/click/{$this->adopt->getAdoptID()}'>Click here to visit {$adoptablename}</a><br></div>";
		  throw new LevelupException($levelupmessage);
		    $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")));		 
			
			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_old, true);  
            imagesavealpha($img_old, true);
   
            // Lets copy the old image into the new image with  
            ImageCopyResampled($img_temp, $img_old, 0, 0, 0, 0, $width, $height, $width, $height);    
	        $textheight = $width + 2;
	        $image = $img_temp;
            $bgi = imagecreatetruecolor($newwidth, $newheight);
            $color = imagecolorallocate($bgi, 51, 51, 51);
		 
		    // Build text for siggy
            $str1 = "Name: ".$this->adopt->getName();
            $str2 = "Owner: ".$this->adopt->getOwner();
	        $str3 = "Click Here to Boost Me!";
	        $str4 = "More Pets at:";
	        $str5 = "www.".constant("DOMAIN");

            // Renger Image
	        imagestring ($image, 12, 0, $textheight,  $str1, $color);
	        imagestring ($image, 12, 0, $textheight + 13,  $str2, $color);
	        imagestring ($image, 12, 0, $textheight + 26,  $str3, $color);
	        imagestring ($image, 12, 0, $textheight + 42,  $str4, $color);
	        imagestring ($image, 12, 0, $textheight + 55,  $str5, $color);
	        $background = imagecolorallocate($image, 0, 0, 0);  
            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);
	}
}
?>

If those don't work, I really don't know what to do from there. :L
 
Last edited:
Ok the first code on a non frozen --- I was able to level and did NOT get the white page of DOOOM.

I refreshed and got this:

An error has occurred.

Statname: 53
You already leveled this Pet today. You may only Boost a Pet once per day. Please come back tomorrow to Boost this Pet again

The *first* code works on frozen and non frozen.

The second and third codes, WHITE OUT ... so we are a lot closer :) At least one code works to some degree, not sure what the Statname 53 error is.

Was there a formatting supposed to show for this? ( the pretty layout like you have? )

.. I didn't see that, not sure if we have that coded in yet.
 
We won't be able to get to that until this levelup thing is fixed - is there a way to do this without the ERROR?! EEEEP!!!
Try this:
PHP:
<?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']);
        $adoptablestatname = $this->adopt->getAdoptstatname();

        if($this->settings->system != "enabled") throw new NoPermissionException("disabled");
        elseif($this->adopt->hasVoter($mysidia->user, $date)){





            $message = "<div id='stats'>Statname: {$adoptablestatname}</div>";
$message = $message .= (($mysidia->user instanceof Member)?$mysidia->lang->already_leveled_member:$mysidia->lang->already_leveled_guest);  


            throw new comment($message);        
        }
        




        
        
        elseif($this->adopt->isFrozen() == "yes") throw new LevelupException("frozen");
        elseif($mysidia->user->getVotes() > $this->settings->number) throw new LevelupException("number");
        elseif($this->settings->owner == "disabled" and $this->adopt->getOwner() == $mysidia->user->username){
             throw new LevelupException("owner");               
        }
        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")));         
            
            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_old, true);  
            imagesavealpha($img_old, true);
   
            // Lets copy the old image into the new image with  
            ImageCopyResampled($img_temp, $img_old, 0, 0, 0, 0, $width, $height, $width, $height);    
            $textheight = $width + 2;
            $image = $img_temp;
            $bgi = imagecreatetruecolor($newwidth, $newheight);
            $color = imagecolorallocate($bgi, 51, 51, 51);
         
            // Build text for siggy
            $str1 = "Name: ".$this->adopt->getName();
            $str2 = "Owner: ".$this->adopt->getOwner();
            $str3 = "Click Here to Boost Me!";
            $str4 = "More Pets at:";
            $str5 = "www.".constant("DOMAIN");

            // Renger Image
            imagestring ($image, 12, 0, $textheight,  $str1, $color);
            imagestring ($image, 12, 0, $textheight + 13,  $str2, $color);
            imagestring ($image, 12, 0, $textheight + 26,  $str3, $color);
            imagestring ($image, 12, 0, $textheight + 42,  $str4, $color);
            imagestring ($image, 12, 0, $textheight + 55,  $str5, $color);
            $background = imagecolorallocate($image, 0, 0, 0);  
            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);
    }
}
?>
 
Okay ...THAT code is working perfect now, no error but:

when you try to click again there is a white page. Possibly there is something we are missing in a lang file? I've noticed that often throws a white page, when that's missing or off ( something in lang )

I see what you mean and it might be the comment thing ...
 
You can go level once.

The fails before wouldn't even let you do that without white page.

If you go back to try to re level, it throws white page now with this latest code.

BUT --

The code you had JUST before that ... did work and give the 'already boosted' comment, but it gave that Statname 53 error mentioned too.
 
Ok the previous code where you posted three, and the first one works?

I just realized what that code is doing!

It's pulling the statname result and posting THAT, along with the already leveled message!



Let me see if I can fix it ...
 
^That's what I did for my site. ^.^ If html works for lang files, I may be able to fix it...
 
Okay I removed this:

$message = "<div id='stats'>Statname: {$adoptablestatname}</div>";


I've attached what I believe to be a working version of levelup for 1.3.4 and thank you so much for all your help and work !! :)
 

Attachments

  • levelup.php
    6.7 KB · Views: 2
Err, it probably would work, but I don't see how it's going to show the stats now...
Try adding this to the lang_levelup file:
$lang['already_leveled_title'] = "You already leveled this adoptable today";

Try this code:
PHP:
<?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']);
        $document = $mysidia->frame->getDocument();
        $adoptablestatname = $this->adopt->getAdoptstatname();

        if($this->settings->system != "enabled") throw new NoPermissionException("disabled");
        elseif($this->adopt->hasVoter($mysidia->user, $date)){





            $message = "<div id='stats'>Statname: {$adoptablestatname}</div>";
$message = $message .= (($mysidia->user instanceof Member)?$mysidia->lang->already_leveled_member:$mysidia->lang->already_leveled_guest);
$document->addLangvar($message);
$document->setTitle($mysidia->lang->already_leveled_title);        
        }
        




        
        
        elseif($this->adopt->isFrozen() == "yes") throw new LevelupException("frozen");
        elseif($mysidia->user->getVotes() > $this->settings->number) throw new LevelupException("number");
        elseif($this->settings->owner == "disabled" and $this->adopt->getOwner() == $mysidia->user->username){
             throw new LevelupException("owner");               
        }
        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")));         
            
            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_old, true);  
            imagesavealpha($img_old, true);
   
            // Lets copy the old image into the new image with  
            ImageCopyResampled($img_temp, $img_old, 0, 0, 0, 0, $width, $height, $width, $height);    
            $textheight = $width + 2;
            $image = $img_temp;
            $bgi = imagecreatetruecolor($newwidth, $newheight);
            $color = imagecolorallocate($bgi, 51, 51, 51);
         
            // Build text for siggy
            $str1 = "Name: ".$this->adopt->getName();
            $str2 = "Owner: ".$this->adopt->getOwner();
            $str3 = "Click Here to Boost Me!";
            $str4 = "More Pets at:";
            $str5 = "www.".constant("DOMAIN");

            // Renger Image
            imagestring ($image, 12, 0, $textheight,  $str1, $color);
            imagestring ($image, 12, 0, $textheight + 13,  $str2, $color);
            imagestring ($image, 12, 0, $textheight + 26,  $str3, $color);
            imagestring ($image, 12, 0, $textheight + 42,  $str4, $color);
            imagestring ($image, 12, 0, $textheight + 55,  $str5, $color);
            $background = imagecolorallocate($image, 0, 0, 0);  
            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);
    }
}
?>
 
Nope :(

White page immediately on attempt.

No go ..and I really do suspect something with the lang file setting.
 
Try this:
PHP:
<?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']);
        $document = $mysidia->frame->getDocument();
        $adoptablestatname = $this->adopt->getAdoptstatname();

        if($this->settings->system != "enabled") throw new NoPermissionException("disabled");
        elseif($this->adopt->hasVoter($mysidia->user, $date)){





            $message = "<div id='stats'>Statname: {$adoptablestatname}</div>";
$message = $message .= (($mysidia->user instanceof Member)?$mysidia->lang->already_leveled_member:$mysidia->lang->already_leveled_guest);
$document->add(new Comment($message));      
        }
        




        
        
        elseif($this->adopt->isFrozen() == "yes") throw new LevelupException("frozen");
        elseif($mysidia->user->getVotes() > $this->settings->number) throw new LevelupException("number");
        elseif($this->settings->owner == "disabled" and $this->adopt->getOwner() == $mysidia->user->username){
             throw new LevelupException("owner");               
        }
        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")));         
            
            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_old, true);  
            imagesavealpha($img_old, true);
   
            // Lets copy the old image into the new image with  
            ImageCopyResampled($img_temp, $img_old, 0, 0, 0, 0, $width, $height, $width, $height);    
            $textheight = $width + 2;
            $image = $img_temp;
            $bgi = imagecreatetruecolor($newwidth, $newheight);
            $color = imagecolorallocate($bgi, 51, 51, 51);
         
            // Build text for siggy
            $str1 = "Name: ".$this->adopt->getName();
            $str2 = "Owner: ".$this->adopt->getOwner();
            $str3 = "Click Here to Boost Me!";
            $str4 = "More Pets at:";
            $str5 = "www.".constant("DOMAIN");

            // Renger Image
            imagestring ($image, 12, 0, $textheight,  $str1, $color);
            imagestring ($image, 12, 0, $textheight + 13,  $str2, $color);
            imagestring ($image, 12, 0, $textheight + 26,  $str3, $color);
            imagestring ($image, 12, 0, $textheight + 42,  $str4, $color);
            imagestring ($image, 12, 0, $textheight + 55,  $str5, $color);
            $background = imagecolorallocate($image, 0, 0, 0);  
            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);
    }
}
?>
 
Still white page... we really need HOF to help on this possibly.
 
It might be this?

$message = $message .= (restOfCode)

Try just

$message .= (restOfCode)

or

$message = $message . (restOfCode)
 
Good call but it didn't change it white paging ....good eye though!
 
^Actually, can you link me to the levelup page where it showed as an error... I want to check something. :3
 
^Would you mind putting the error code back real quick for me(the one that shows the stats)
 
http://sim-life.com/simpets/stats

from there clicking gives the white page too. I have the error still happening ( as in white page ) for attempting to Boost any of them.

You can view the stats themselves in myadopts but you cannot Boost ( levelup )
 

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,277
Messages
33,118
Members
1,602
Latest member
BerrieMilk
BETA

Latest Threads

Top