Mysidia Adoptables Support Forum  

Home Community Mys-Script Creative Off-Topic
Go Back   Mysidia Adoptables Support Forum > Mysidia Adoptables > Questions and Supports

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 02-15-2016, 07:23 PM
tahbikat's Avatar
tahbikat tahbikat is offline
Member
 
Join Date: Feb 2014
Location: Louisiana
Posts: 408
Gender: Female
Credits: 49,633
tahbikat is on a distinguished road
Default New Report Function help

I'm wondering if it would be possible to make a new report function to report, say, an adopt's name or bio field on its public profile (which would be located at levelup.php)

I ask because I've made a bio field for pets on my site. Members can write their own bios for the pet and have it display publicly on the profile (levelup.php). It's working great, but I'm having trouble figuring out how to make a report function for it. :c Essentially a user would just be reporting a specific adopt's value in its "petbio" column in the db.

Any help? I'd love to make a tutorial out of this so other Mysidia game owners can utilize this feature too. If anyone needs me to post any code I'm using for this in order to help with the report function, let me know!
Reply With Quote
  #2  
Old 02-15-2016, 08:53 PM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 88,319
Kyttias is on a distinguished road
Default

I was considering making a pet bio field, too, but I hadn't considered that it would need a report button! There are always bad eggs that spoil the bunch, isn't there? Do you want the report PM'd to the Admin?
__________________
Please do not contact me directly outside of Mysidia.
I also cannot troubleshoot code more than two years old - I legit don't remember it.
Reply With Quote
  #3  
Old 02-15-2016, 09:35 PM
tahbikat's Avatar
tahbikat tahbikat is offline
Member
 
Join Date: Feb 2014
Location: Louisiana
Posts: 408
Gender: Female
Credits: 49,633
tahbikat is on a distinguished road
Default

Pretty much, yes! I'm actually using your modified version of the PM report function, and it works great. Basically the same thing I want for the pet's bio report function. (:

To make the pet bios, I simply modified the rename functions and classes. :P Working like a charm so far.
Reply With Quote
  #4  
Old 02-15-2016, 11:27 PM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 88,319
Kyttias is on a distinguished road
Default

Ah, so you don't even need help anymore?
__________________
Please do not contact me directly outside of Mysidia.
I also cannot troubleshoot code more than two years old - I legit don't remember it.
Reply With Quote
  #5  
Old 02-16-2016, 12:13 AM
tahbikat's Avatar
tahbikat tahbikat is offline
Member
 
Join Date: Feb 2014
Location: Louisiana
Posts: 408
Gender: Female
Credits: 49,633
tahbikat is on a distinguished road
Default

Oh no, I do LOL. I don't know how to make the report function work with the pet bio, is what I meant. xc

So yea I have the actual bios done. Only thing left is the reporting part. I'm clueless about it. I tried to copy and modify the original report function, but tis hard. :<
Reply With Quote
  #6  
Old 02-17-2016, 01:14 AM
tahbikat's Avatar
tahbikat tahbikat is offline
Member
 
Join Date: Feb 2014
Location: Louisiana
Posts: 408
Gender: Female
Credits: 49,633
tahbikat is on a distinguished road
Default

Update: Also noticed slashes are butchering bios when apostrophe's are used. :L I tried my best to remedy it but can't figure it out. The 'stripslashes($message);' string I have only works if I echo it, but then it displays above the whole layout of the site and not where it's supposed to.

I'm not sure how to make stripslashes work with 'throw new LevelupException($message);'
Reply With Quote
  #7  
Old 02-17-2016, 08:54 AM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 88,319
Kyttias is on a distinguished road
Default

I know how to fix that. I've got another site project (not Mysidia-related, something custom coded) where I had to create fields for users to post bio data and I've got a whole function on hand ready to check for slashes and that will allow for some safe levels of html while stripping out anything potentially harmful. I haven't gotten around to upgrading the profile bio area in Mysidia, but of course we'd want it the same as the pet one.

Like, at minimum this one should solve the slashes(probably):
PHP Code:
public function validate($data){
        
$data trim($data);
        
$data stripslashes($data);
        
$data htmlspecialchars($data);
        return 
$data;    

But also these (to allow for some, but not all html... and I made some exceptions that will still allow for some faces to render... and <3 is replaced with ♥ so the bracket is accounted for:
PHP Code:
public function removeStyles($data){
    
$list = array('cursor''position','font','z-index','font-family','font-size','border','border-left','border-right','border-top','border-bottom','border-radius');
    
$patterns = array();
    foreach (
$list as $v){
        
$patterns[]= '/'.$v.'\s*:\s*[^;"]*;?/';
    }
    return 
preg_replace($patterns,''$data);

(I have no idea why the syntax highlighting is borked on this one.)
PHP Code:
public function purify($data){
    $data = removeStyles($data);
    
    $data = html_entity_decode($data);

    $data = str_ireplace('<3','&#x2665;',$data);
    $data = str_ireplace('_<','_&lt;',$data); 
    $data = str_replace('D<','D&lt;',$data);
    $data = str_replace('D:<','D:&lt;',$data);    
    $data = str_replace('u<','u&lt;',$data);
    $data = str_replace('w<','w&lt;',$data);
    $data = str_replace('o<','o&lt;',$data);
    $data = str_replace('U<','U&lt;',$data);
    $data = str_replace('W<','W&lt;',$data);
    $data = str_replace('O<','O&lt;',$data);
    $data = str_ireplace('&lt;/','</',$data);

    $data = str_ireplace('<a href="j','<a href="## ',$data);
    $data = str_ireplace('onclick=',' ',$data);
    $data = str_ireplace('<a ','<a target="_BLANK" ',$data);
    $data = str_ireplace('<strike>','<s>',$data); $data = str_ireplace('</strike>','</s>',$data);
    $data = preg_replace('/(<br>){1,}$/', '', $data);   

    $doc = new DOMDocument();
    $doc->loadHTML('<?xml encoding="UTF-8">' . $data);
    $data = $doc->saveHTML();
    
    $data = strip_tags($data,'
<a><pre><code><b><i><center><u><s><em><sub><sup><strong><br><span><small>'); 

    $data = trim($data);  

    /* BEGIN URL PARSE*/
    $pattern = '
/((http|www\.)+(s)?:\/\/[^"\s]+)(?![^<]*>)/';
    preg_match_all(
$pattern$data$output);
    foreach (
$output[0] as $values){ $urls[] = $values; }
    foreach(
$urls as $url) {
        
$parser = '<a class="chatlink" target="_blank" href="'.$url.'">'.$url."</a>";
        
$data = str_ireplace($url$parser$data);
    }
    /* END URL PARSE */
}
Run the bio through each of these functions in that order (that's my recommendation, anyway).








Anyway, as far as the Report feature, I've got some free time so I'll put some thought into over the next couple days.
__________________
Please do not contact me directly outside of Mysidia.
I also cannot troubleshoot code more than two years old - I legit don't remember it.

Last edited by Kyttias; 02-17-2016 at 09:02 AM.
Reply With Quote
  #8  
Old 02-17-2016, 05:03 PM
tahbikat's Avatar
tahbikat tahbikat is offline
Member
 
Join Date: Feb 2014
Location: Louisiana
Posts: 408
Gender: Female
Credits: 49,633
tahbikat is on a distinguished road
Default

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_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-17-2016 at 05:12 PM.
Reply With Quote
  #9  
Old 02-17-2016, 11:00 PM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 88,319
Kyttias is on a distinguished road
Default

*shrug* I haven't built a pet bio field myself. I mean... you could do it all without functions, if you wanted...? You want to filter the bio variable immediately before storing it in the database, so whatever file you're doing that in.
__________________
Please do not contact me directly outside of Mysidia.
I also cannot troubleshoot code more than two years old - I legit don't remember it.
Reply With Quote
  #10  
Old 02-17-2016, 11:33 PM
tahbikat's Avatar
tahbikat tahbikat is offline
Member
 
Join Date: Feb 2014
Location: Louisiana
Posts: 408
Gender: Female
Credits: 49,633
tahbikat is on a distinguished road
Default

Ooohhh, I see what you mean. I think I understand now. Gonna try adding it soon and report back. c:
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 05:57 AM.

Currently Active Users: 9828 (0 members and 9828 guests)
Threads: 4,080, Posts: 32,024, Members: 2,016
Welcome to our newest members, jolob.
BETA





What's New?

What's Hot?

What's Popular?


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
vBCommerce I v2.0.0 Gold ©2010, PixelFX Studios
vBCredits I v2.0.0 Gold ©2010, PixelFX Studios
Emoticons by darkmoon3636