Okay, sorry, I'm a little confused as to where/how to add this lol. ;-;
Do I add it to the class where I call the bio, or in the levelup.php where it's displayed? Or where the actual set bio function itself is? I'll go ahead and post the whole code for the bio. :P
Here's my codes:
class_ownedadopt pet bio section
PHP Code:
<?php
class OwnedAdoptable extends Adoptable{
protected $aid; protected $name; protected $owner; protected $currentlevel; protected $totalclicks; protected $code; protected $imageurl; protected $usealternates; protected $tradestatus; protected $isfrozen; protected $gender; protected $offsprings; protected $lastbred; protected $nextlevel; protected $voters; protected $adoptablepersonality; protected $obtainedfrom; protected $obtainedon; protected $magic; protected $petbio; public function __construct($aid, $owner = ""){ $mysidia = Registry::get("mysidia"); $whereClause = "aid ='{$aid}'"; if(!empty($owner)) $whereClause .= " and owner = '{$owner}'"; $row = $mysidia->db->select("owned_adoptables", array(), $whereClause)->fetchObject(); if(!is_object($row)) throw new AdoptNotfoundException("Adoptable ID {$aid} does not exist or does not belong to the owner specified..."); parent::__construct($row->type); foreach($row as $key => $val){ $this->$key = $val; } }
public function getAdoptID(){ return $this->aid; }
public function getName(){ return $this->name; } public function getPetBio(){ return $this->petbio; } public function setName($name, $assignMode = ""){ if($assignMode == Model::UPDATE) $this->save("name", $name); $this->name = $name; } public function setPetBio($petbio, $assignMode = ""){ if($assignMode == Model::UPDATE) $this->save("petbio", $petbio); $this->petbio = $petbio; } } ?>
myadopts.php pet bio part haven't cleaned this up yet lol
PHP Code:
public function petbio(){ $mysidia = Registry::get("mysidia"); if($mysidia->input->post("submit")){ $poundsettings = getpoundsettings(); $poundpet = $mysidia->db->select("pounds", array(), "aid='{$this->adopt->getAdoptID()}'")->fetchObject(); if($poundpet and $poundsettings->rename->active == "yes"){ if(!empty($poundpet->firstowner) and $mysidia->user->username != $poundpet->firstowner){ $this->setFlags("petbio_error", "petbio_owner"); return; } } $this->adopt->setPetBio($mysidia->input->post("petbio"), "update"); } $this->setField("adopt", $this->adopt); $this->setField("image", $this->image); }
myadoptsview.php
PHP Code:
public function petbio(){ $mysidia = Registry::get("mysidia"); $adopt = $this->getField("adopt"); $image = $this->getField("image"); $document = $this->document; if($mysidia->input->post("submit")){ $document->setTitle($this->lang->petbio_success_title); $document->add($image); $message = "<br>{$this->lang->petbio_success}{$adopt->getName()}. You can now manage {$adopt->getName()} on the"; $document->addLangvar($message); $document->add(new Link("myadopts/manage/{$adopt->getAdoptID()}", "My Creatures Page")); return; } $document->setTitle($this->lang->petbio.$adopt->getName()); $document->add($image); $document->addLangvar("<br />{$this->lang->petbio_default}{$adopt->getName()}{$this->lang->petbio_details}<br />"); $petbioForm = new FormBuilder("petbioform", "", "post"); $petbioForm->buildTextArea("petbio")->buildButton("Submit Bio", "submit", "submit"); $document->add($petbioForm); }
levelup.php
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_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 Feed Me!"; $str4 = "More Adopts 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); } } ?>
Last edited by tahbikat; 02-17-2016 at 06:12 PM.
|