PDA

View Full Version : Donations Bug


pachoofoosh
06-26-2013, 06:34 PM
(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.

Hall of Famer
06-27-2013, 01:55 PM
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?

Abronsyth
06-27-2013, 03:05 PM
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!

Infernette
06-28-2013, 08:42 PM
That is a big problem! I guess I should wait until the new update after all so this will be fixed :)

Hall of Famer
06-29-2013, 01:35 PM
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.

Hall of Famer
07-01-2013, 01:55 PM
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

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);
}
}
?>

Abronsyth
07-01-2013, 03:35 PM
Tested it HoF, and it's working as it ought to be now, thank you!

Hope you're doing well, by the way.

Hall of Famer
07-02-2013, 12:08 PM
You are very welcome, glad it worked. I am a bit sick lately, but will get better soon. ^^

Ruinily
07-02-2013, 02:27 PM
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?

pachoofoosh
07-02-2013, 05:05 PM
I replaced my donate.php with that and it worked perfectly. Thanks a bunch! :D

Hall of Famer
07-03-2013, 02:20 PM
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?

Ruinily
07-03-2013, 04:49 PM
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? ^_^'

Hall of Famer
07-03-2013, 11:28 PM
I think so yes, I will take a look into how to fix it for Mys v1.3.2 later.

Ruinily
07-04-2013, 12:33 AM
Thanks, sorry for being a pest. ^_^'

And I hope you're feeling better!