Donations Bug

Forum
Last Post
Threads / Messages

pachoofoosh

Artist
Member
Joined
Dec 10, 2012
Messages
99
Points
6
Location
New York
Mysidian Dollar
10,255
(Sorry if this is posted in the wrong place! ^^;)

I've noticed a small bug when editing my site.

On the donate.php page, if you enter your own username and a cash amount (for instance, 1,000 of the site currency), it will give you that cash amount without first subtracting it from your total amount. So, for example, if the user has 1,000 cash, they could enter their own username and 'donate' 500 cash to themselves. Instead of still having 1,000 cash, they now have 1,500 cash.
 
umm interesting, I never checked this but it could be true. Are you sure this is affecting Mys v1.3.3 and the earlier versions?
 
I just tested it, running 1.3.3 and tried donating 200 currencies to myself. I had 435 currencies before 'donating' and ended up with 635 afterwards, so it is affecting 1.3.3!
 
I see, so this has been confirmed to be a glitch. I am terribly sorry about it, will post a fix for the problem in 1-2 days. Shouldnt be difficult though.
 
Here is a simple fix, try it if you are interested. Just copy/paste whatever is inside the code block to your donate.php file, make sure to overwrite the old contents:

PHP:
<?php

class DonateController extends AppController{

    private $view;
    private $subController;

    public function __construct(){
        parent::__construct("member");
    }
    
    public function index(){
        $mysidia = Registry::get("mysidia");
        $document = $mysidia->frame->getDocument();
        $document->setTitle($mysidia->lang->title);
        
        if($mysidia->input->post("recipient") and is_numeric($mysidia->input->post("amount"))){
            $recipient = preg_replace("/[^a-zA-Z0-9\\040]/", "", $mysidia->input->post("recipient"));
            $amount = preg_replace("/[^0-9]/", "", $mysidia->input->post("amount"));
            $recipient = new Member($recipient);
            
             if($amount < 0){
                $document->setTitle($mysidia->lang->fail);
                $document->addLangvar($mysidia->lang->negative);
            }
            elseif($mysidia->user->money < $amount){
                $document->setTitle($mysidia->lang->fail);
                $document->addLangvar($mysidia->lang->funds);
            }
            elseif($recipient->username == $mysidia->user->username){
                $document->setTitle($mysidia->lang->fail);
                $document->addLangvar("Cannot donate to yourself!");
           } 
            else{
                $mysidia->user->donate($recipient, $amount);
                $document->setTitle($mysidia->lang->success);
                $document->add(new Comment("You've just donated {$amount} of {$mysidia->settings->cost} to <a href='profile/{$recipient->username}'>{$recipient->username}</a>. "));
                $document->add(new Comment("You'll be redirected back to the donation page within 3 seconds. Click "));
                $document->add(new Link("donate", "here "));
                $document->add(new Comment("if your browser does not automatically redirect you."));
                header("Refresh:3; URL='donate'");
            }
            return;
        }

        $document->add(new Comment("This page will allows you to donate your money to other users. "));
        $document->add(new Comment("You currently have {$mysidia->user->getcash()} {$mysidia->settings->cost} left."));
        $document->add(new Paragraph(new Comment("")));

        $donateForm = new FormBuilder("donateform", "donate", "post");
        $donateForm->buildComment("Donate to: ", FALSE)
                   ->buildTextField("recipient")
                   ->buildComment("Amount to donate: ", FALSE)
                   ->buildTextField("amount")
                   ->buildButton("Donate", "submit", "submit");
        $document->add($donateForm);    
    }
}
?>
 
Tested it HoF, and it's working as it ought to be now, thank you!

Hope you're doing well, by the way.
 
Um, is that fix for the newest coding? Because its not working on mine at all lol... And the coding looks different. Is there any chance of a fix for Mysidia Adoptables v1.3.2? ^_^' Or shall I just disable it?
 
Glad it works for you Pachoofoosh. And Ruinily, this simple fix above was for Mys v1.3.3. Are you saying that this glitch is also present for Mys v1.3.2? Or are you talking about another issue irrelevant to this topic?
 
Yeh I thought it was for Mys v1.3.3 And yes I just tested it and I got an extra 100 added to my own account. Is there any chance theres a simple fix for 1.3.2 too? ^_^'
 
Thanks, sorry for being a pest. ^_^'

And I hope you're feeling better!
 
Last edited:

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