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 03-26-2012, 04:36 PM
SilverDragonTears's Avatar
SilverDragonTears SilverDragonTears is offline
I am your Nemesis.
 
Join Date: Jun 2011
Posts: 1,113
Gender: Female
Credits: 82,308
SilverDragonTears is on a distinguished road
Default trade not working on new version of Mys

You put in stuff and it just stays on the trade page like you simply refreshed it.

PHP Code:
<?php

include("functions/functions.php");
include(
"functions/functions_users.php");
include(
"functions/functions_adopts.php");
include(
"functions/functions_friends.php");
include(
"functions/functions_items.php");
include(
"inc/lang.php");
include(
"inc/bbcode.php");

//***************//
//  START SCRIPT //
//***************//

if($isloggedin == "yes"){

// First let's make sure we are installed...

$userstatus getuserstatus($loggedinname);
if(
$userstatus['cantrade'] == "no"){

$article_title "You do not have permission to trade";
$article_content "It appears that an admin has banned your right to trade on this site, send him/her a PM to learn the details.";

}

else{

$enab grabanysetting("enabletrades");

if(
$enab == "yes"){

// Get our post variables...

$adoptwanted $_POST["adoptwanted"];
$adoptgiven $_POST["adoptgiven"];
$itemgiven $_POST["itemgiven"];
$cashgiven $_POST["cashgiven"];
$message $_POST["message"];

$cashenabled grabanysetting("cashenabled");
$cashname grabanysetting("cost");
$tradecost grabanysetting("tradecost");
$tradeoffercost grabanysetting("tradeoffercost");
$mycash getcash($loggedinname);

// Now we are going to check if we have posted an adoptable we wish to trade...

if(is_numeric($adoptwanted)){

// Attempt to execute the trade...

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                         //
// WE ARE ATTEMPTING TO RUN A TRADE HERE...                                                             //
//                                                                                         //
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// >>> >>> >>> >>>

    // Set a flag and error message...

    
$flag 0;
    
$error "";
    
    
// First we make sure that the adoptable the user wants actually exists...

    
$num 0;

    if (!empty(
$adoptwanted)){
        
$stmt $adopts->query("SELECT * FROM {$prefix}owned_adoptables WHERE aid='$adoptwanted' and tradestatus='fortrade'");
      
$row $stmt->fetchObject();
    }

    if(!
is_object($row)){
      
$flag++;
      
$error "The adoptable that you want either does not exist or is not available for trading.";
    }
    
// Now we check that if the user entered in an adoptable to give away they actually own it and wish to trade it...

    
if (!empty($adoptgiven)){
      
$stmt $adopts->query("SELECT * FROM {$prefix}owned_adoptables WHERE aid='$adoptgiven' and owner='$loggedinname' and tradestatus='fortrade'");
      
$row $stmt->fetchObject();

      if(!
is_object($row)){
        
$flag++;
        
$error "The adoptable you selected to give the other user either does not exist, does not belong to you or is not set as available for trade.    
        As a safety precaution all adoptables must be set with the Trading Enabled setting before they can be used in trades."
;
      }
    }
    else{
      
$flag++;
      
$error "You have not selected an adoptable to give to your trade partner in exchange...";
    }
    
    if(!empty(
$itemgiven)){
      
// Check if the item offered actually belong to the owner...
      
$stmt2 $adopts->query("SELECT * FROM {$prefix}inventory WHERE iid='$itemgiven'");
      
$item $stmt2->fetchObject();

      if(!
is_object($item)){
        
// The item does not exist at all...
        
$flag++;
        
$error "The item you are offering does not seem to exist at all.";
      }
      if(
is_object($item) and $item->owner != $loggedinname){
        
// The item belongs to someone else, now we have a hacking attempt!
        
$flag++;
        
$adopts->query("UPDATE {$prefix}users SET usergroup='5' WHERE username='{$loggedinname}'");
        
$adopts->query("UPDATE {$prefix}users_status SET cantrade='no' WHERE username='{$loggedinname}'");  
        
$error "You have selected an item that belongs to someone else. You've been banned for this action, please contact an admin for further assistance.";
      }
    }
    
// Now if the user has entered in a cash amount make sure they have the money to cover the transaction with the other user...

    
if($cashenabled == "yes"){

    
$moneyleft $mycash $cashgiven;

      if(
$moneyleft 0){
        
$flag++;
        
$error "You do not have enough ".$cashname." to cover the payment amount you have selected to pay the other user.  Please either earn more ".$cashname." or decrease your payment amount.";
      }
    
    
// Now check that the user can cover the site's transaction offer fee...

    
$moneyleft $moneyleft $tradeoffercost;

    if(
$moneyleft 0){
        
$flag++;
        
$error "You do not have enough ".$cashname." to cover the cost of making this trade offer.";
    }


    }

    
// On the very last, we check if the trade partner accepts trades with friends only...
    
    
    
    // Ok, I think we are all done...

    
if($flag 0){

    
$article_title "Trade Error";
    
$article_content $error;

    }
    else{

    
// Dispatch the trade offer...
    // First we log the trade in the _trades database table...

    
$time date('Y-m-d-m-s');
    
    
$adopts->query("INSERT INTO {$prefix}trades (id, userrequestingtrade, tradetype, adoptableoffered, itemoffered, cashoffered, adoptabledesired, custommessage, offerstatus)
                                         VALUES ('', '
$loggedinname', '$time','$adoptgiven','$itemgiven','$cashgiven','$adoptwanted', '$message', 'pending')");
    
    
// Now we need to create a new PM to the user receiving the trade to let them know a trade is available for them...

    
$stmt $adopts->query("SELECT * FROM {$prefix}owned_adoptables WHERE tradestatus='fortrade' and aid='$adoptwanted'"); 
    
$adoptable $stmt->fetchObject();
    
$toname=$adoptable->owner//The person we send a PM to...


    // Now we need to fetch the ID of this trade so the user can pull it up easily...

    
$stmt $adopts->query("SELECT * FROM {$prefix}trades WHERE userrequestingtrade='$loggedinname' and adoptabledesired='$adoptwanted' and tradetype='$time'");
    
$trade $stmt->fetchObject(); 

    
// Now we send the PM to $toname...

    
$mtitle "You have received a trade request from {$loggedinname}!";
    
$mtext "You have received a trade request from {$loggedinname}!  They want to take one of your adoptables off of your hands and give you something in return.
    To see the details of this trade request and to accept or reject it, please visit the trade redemption center to check out your trade offer."
;    

    
$date date('Y-m-d');
    
$stmt $adopts->query("SELECT * FROM {$prefix}users WHERE username='$toname'");
    
$partner $stmt->fetchObject(); 
    
$loggedinid usernametouid ($loggedinname);
    
    if(
$partner->friends == ""$actionpassed "no";
    else{
      
$friendidlist explode(",",$partner->friends);
      
$actionpassed "no";
      foreach(
$friendidlist as $friend){
        if(
$friend == $loggedinid$actionpassed "yes"
      }
    }
    
    if(
$partner->tradestatus == and $actionpassed == "no"){
        
$adopts->query("DELETE FROM {$prefix}trades WHERE userrequestingtrade='$loggedinname' and adoptabledesired='$adoptwanted' and tradetype='$time'");
        
$article_title "An error has occurred...";
        
$article_content "It appears that your trade partner only accepts trade requests from his/her friends.";    
    }
    else{
    
$query "INSERT INTO {$prefix}messages (id, fromuser, touser, status, datesent, messagetitle, messagetext)
                                     VALUES ('', '
$loggedinname', '$toname','unread','$date','$mtitle', '$mtext')";
    
$adopts->query($query);

    
// Now we update the trades table with the other person's username...

    
$adopts->query("UPDATE {$prefix}trades SET tradeto='{$toname}' WHERE id='{$trade->id}' and userrequestingtrade='{$loggedinname}'");

    
// Now we are all done...
    // Let's show a thank you page to the user...

    
$article_title "Your Trade Offer Has Been Sent";
    
$article_content "Your trade offer has been sent successfully!  If you need to cancel this trade request you can do this on the My Trades page.
    You will be notified via PM when this trade is either accepted or rejected."
;    
    } 
    }

}
else{

// Show the informational page...
// Allow a custom introduction...

$pagecontent getsitecontent("tradetext");
$custom_title $pagecontent[title];
$custom_content $pagecontent[content];
$custom_content bbconvert($custom_content); // BBCODE conversion
$custom_content nl2br($custom_content);

if(
$custom_title != "" and $custom_content != ""){

$article_title $custom_title;
$article_content $custom_content;

}
else{

$article_title "The Trade Station";
$article_content "Welcome to the Trade Station.  Here you can trade one of your adoptables for an adoptable owned by someone else.  
To trade adoptables, you will need to know the ID of the adoptable you wish to receive.  You can find the adoptable ID by searching adoptables.  
Once you know the ID of the adoptable you want, simply fill out the form below to begin the trade.<br>
<b><a href='redeem.php'>Go to Redeem Center to see trade offers</a></b><br> 
<b><a href='mytrades.php'> Visit My trade page to manage trade proposals</a></b><br> 
<b><a href='search.php'> Search for an available adoptable for trade</a></b><br>"

// Custom Content IF

// Take in a param...

$gid $_GET["id"];
$gid preg_replace("/[^a-zA-Z0-9\\040.]/"""$gid);
$gid secure($gid);

// GET THE DATABASE INFO...

$adoptoffered "";
$itemoffered "";

$stmt $adopts->query("SELECT * FROM {$prefix}owned_adoptables WHERE owner='$loggedinname' and tradestatus='fortrade'");
while(
$row $stmt->fetchObject()) {

  
$aid=$row->aid//The adoptable's ID
  
$name=$row->name;
  
$adoptoffered .= "<option value='{$aid}'>{$name}</option>";
}

$stmt2 $adopts->query("SELECT * FROM {$prefix}inventory WHERE owner='$loggedinname' and status='available'");
while(
$row2 $stmt2->fetchObject()) {
  
$iid=$row2->iid//The item's ID
  
$iname=$row2->itemname;
  
$itemoffered .= "<option value='{$iid}'>{$iname}</option>";
}



// END DATABASE INFO

if($cashenabled == "yes"){

$article_content $article_content."<br><br><u>{$cashname} Based Settings:</u><br><br>
Your 
{$cashname}{$mycash}<br>
Amount of 
{$cashname} required to make a trade offer: {$tradeoffercost}<br>
Amount of 
{$cashname} required to complete a trade: {$tradecost}<br><br>
<img src='templates/icons/warning.gif' border=0> WARNING: If you do not have enough 
{$cashname} to cover the cost of this trade when the other user attempts to complete the trade the trade will fail!";

}

$article_content $article_content."<br><form name='form1' method='post' action='trade.php'>
  <p>The ID of the adoptable you wish to receive: 
    <input name='adoptwanted' type='text' id='adoptwanted' size='6' maxlength='6' value='
{$gid}'>
</p>
  <p>The adoptable you are willing to give as a part of this trade:<br> 
    <select name='adoptgiven' id='adoptgiven'>
      <option value='none' selected>No Adoptable Selected</option>
    
{$adoptoffered}
    </select>
</p>
  <p>Only the adoptables that you have set to Trading Enabled will be shown here. <a href='myadopts.php' target='_blank'>Click here</a> to manage your adoptables. </p>
  <p>The item you are willing to give as a part of this trade:<br> 
    <select name='itemgiven' id='itemgiven'>
      <option value='none' selected>No Item Selected</option>
    
{$itemoffered}
    </select></p>"
;

if(
$cashenabled == "yes"){

$article_content $article_content." <p>HINT: You can leave the above setting blank if you wish to trade only {$cashname} for your desired adoptable.</p>
  <p>The 
{$cashname} amount you wish to trade for this adoptable: 
    <input name='cashgiven' type='text' id='cashgiven' value='0' size='10' maxlength='10'>
</p>"
;

}

$article_content $article_content." <p>You can leave a short (150 character) message to the user about this trade: 
    <input name='message' type='text' id='message' maxlength='150'>
  </p>
  <p>
    <input type='submit' name='Submit' value='Submit Trade Request'> 
  </p>
</form>"
;

// Is Numeric IF

// Is Enabled IF

else{

$article_title "Trading Not Enabled";
$article_content "Trading is either not enabled or not currently available for your site.";


}

}

}

else{

$article_title "Registered Members Only";
$article_content "Only registered site members may use the trade system.  Please <a href='login.php'>Log In</a> or <a href='register.php'>Register</a> to use this feature.";

}



//***************//
//  OUTPUT PAGE  //
//***************//

echo showpage($article_title$article_content$date);

?>
__________________

Check out SilvaTales
Reply With Quote
  #2  
Old 03-26-2012, 08:45 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: 332,790
Hall of Famer is on a distinguished road
Default

Well it works perfectly fine for my demo site. Perhaps you need to change is_numeric() to !empty() again here for your site since you have id being alphanumeric instead of just numeric.
__________________


Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site.
Reply With Quote
  #3  
Old 03-26-2012, 08:49 PM
SilverDragonTears's Avatar
SilverDragonTears SilverDragonTears is offline
I am your Nemesis.
 
Join Date: Jun 2011
Posts: 1,113
Gender: Female
Credits: 82,308
SilverDragonTears is on a distinguished road
Default

*feels really stupid* I swear I thought I changed that line.
__________________

Check out SilvaTales
Reply With Quote
  #4  
Old 03-26-2012, 08:50 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: 332,790
Hall of Famer is on a distinguished road
Default

Well perhaps I should just overhaul the trade system and change everything to !empty(). Infact, I use !empty() all the time in my new script. It is BMR who loves to use is_numeric() though.
__________________


Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site.
Reply With Quote
  #5  
Old 03-26-2012, 08:51 PM
SilverDragonTears's Avatar
SilverDragonTears SilverDragonTears is offline
I am your Nemesis.
 
Join Date: Jun 2011
Posts: 1,113
Gender: Female
Credits: 82,308
SilverDragonTears is on a distinguished road
Default

Now I get "The item you are offering does not seem to exist at all." Because I didn't select an item. Do we HAVE to select items?
__________________

Check out SilvaTales
Reply With Quote
  #6  
Old 03-26-2012, 09:06 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: 332,790
Hall of Famer is on a distinguished road
Default

umm you should not, there is no need to include an item for a trade. I think there is a flaw in the code, find line 96:

PHP Code:
 if(!empty($itemgiven)){ 
change it to:

PHP Code:
 if($itemgiven != "none"){ 
This should fix your problem. Now I just regret I have not overhaul the trade system... Its weird though, this glitch should exist for the beta version already and no one had pointed it out before? o_o
__________________


Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site.
Reply With Quote
  #7  
Old 03-26-2012, 09:16 PM
SilverDragonTears's Avatar
SilverDragonTears SilverDragonTears is offline
I am your Nemesis.
 
Join Date: Jun 2011
Posts: 1,113
Gender: Female
Credits: 82,308
SilverDragonTears is on a distinguished road
Default

LoL... that worked thank you :)
__________________

Check out SilvaTales
Reply With Quote
  #8  
Old 03-26-2012, 09:18 PM
SilverDragonTears's Avatar
SilverDragonTears SilverDragonTears is offline
I am your Nemesis.
 
Join Date: Jun 2011
Posts: 1,113
Gender: Female
Credits: 82,308
SilverDragonTears is on a distinguished road
Default

Hey while I have your attention.... do you know why this...

Code:
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js"></script>
makes the tabs on the profile stop working?
__________________

Check out SilvaTales
Reply With Quote
  #9  
Old 03-26-2012, 09:26 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: 332,790
Hall of Famer is on a distinguished road
Default

Well the tabs make many things stop working, a good example is the drop down navtabs. I'd say it is either because of the css, or the javascript file of tabs.
__________________


Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site.
Reply With Quote
  #10  
Old 03-26-2012, 09:29 PM
SilverDragonTears's Avatar
SilverDragonTears SilverDragonTears is offline
I am your Nemesis.
 
Join Date: Jun 2011
Posts: 1,113
Gender: Female
Credits: 82,308
SilverDragonTears is on a distinguished road
Default

No fix then?
__________________

Check out SilvaTales
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Make pets' trade status Not For Trade by default tahbikat Questions and Supports 3 12-13-2015 10:21 PM
View Public Trade Offers not working. Pear Questions and Supports 16 03-10-2014 06:29 PM
Version 3? AlexC Feedback and Suggestions 8 09-09-2011 05:37 PM
When the new version?? SieghartZeke Suggestions and Feature Requests 4 12-02-2010 04:53 AM
Mac version? Smoggy Questions and Supports 7 08-01-2010 05:36 PM


All times are GMT -5. The time now is 12:42 AM.

Currently Active Users: 3259 (0 members and 3259 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