Thread: Donations Bug
View Single Post
  #6  
Old 07-01-2013, 01:55 PM
Hall of Famer's Avatar
Hall of Famer Hall of Famer is offline
Administrator, Lead Coder
 
Join Date: Dec 2008
Location: South Brunswick
Posts: 4,448
Gender: Male
Credits: 339,457
Hall of Famer is on a distinguished road
Default

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


Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site.
Reply With Quote