Jump to content

Something's wrong with this, but I don't know what....


pmoore

Recommended Posts

I'm sorry but I don't know php or mysql, but I know there's something wrong around line 177 in the following code:

 

<?php
/**
* write.php
*
* writes and edits ads,
* uploads and deletes images
*
* @package com_marketplace
* @subpackage frontend
*
* @copyright 2005-2008 Codingfish Limited
* @author Achim Fischer
*
* This file is part of Codingfish Marketplace.
*
* Marketplace is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* Marketplace is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Marketplace; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/

// Dont allow direct linking
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
?>

<link rel="stylesheet" href="components/com_marketplace/marketplace.css" type="text/css" />

<?php
global $database;

$mode         = strval( mosGetParam( $_REQUEST, 'mode', '' ) );

$payment			= intval( mosGetParam( $_REQUEST, 'payment', '0' ) );

$ad_level			=intval(mosGetParam($_REQUEST,'ad_level','0'));


// set page title

    $mainframe->SetPageTitle( JOO_TITLE." - " .JOO_AD_PAYMENT );

// get marketplace configuration data
$database->setQuery("SELECT * FROM #__marketplace_config LIMIT 1");
$config = $database->loadObjectList();
$ad_default                       	= (int)$config[0]->ad_default;
$use_top                      		= (int)$config[0]->use_top;
$use_featured                      	= (int)$config[0]->use_featured;
$use_commercial                     = (int)$config[0]->use_commercial;
$use_surname                      	= (int)$config[0]->use_surname;
$use_street                       	= (int)$config[0]->use_street;
$use_zip                          	= (int)$config[0]->use_zip;
$use_city                         	= (int)$config[0]->use_city;
$use_state                        	= (int)$config[0]->use_state;
$use_country                      	= (int)$config[0]->use_country;
$use_web                          	= (int)$config[0]->use_web;
$use_phone1                       	= (int)$config[0]->use_phone1;
$use_phone2                       	= (int)$config[0]->use_phone2;
$use_condition                    	= (int)$config[0]->use_condition;
$use_price                        	= (int)$config[0]->use_price;
$rss_syndication                  	= (int)$config[0]->rss_syndication;
$emailFrom                        	= (string)$config[0]->email_from;
$emailFromName                    	= (string)$config[0]->email_from_name;
$use_admin_email_notification     	= (int)$config[0]->use_admin_email_notification;
$use_moderator_email_notification 	= (int)$config[0]->use_moderator_email_notification;
$notification_email_subject       	= (string)$config[0]->notification_email_subject;
$notification_email_text          	= (string)$config[0]->notification_email_text;
$use_paid_ads                    	= (int)$config[0]->use_paid_ads;
$paid_ads_currency          		= (string)$config[0]->paid_ads_currency;
//$paid_ads_price_basic          		= (string)$config[0]->paid_ads_price_basic;
//$paid_ads_price_top          		= (string)$config[0]->paid_ads_price_top;
//$paid_ads_price_featured          	= (string)$config[0]->paid_ads_price_featured;
//$paid_ads_price_commercial          = (string)$config[0]->paid_ads_price_commercial;
$use_paypal_testmode          		= (int)$config[0]->use_paypal_testmode;
$use_offline_payment          		= (int)$config[0]->use_offline_payment;
$offline_payment_text          		= (string)$config[0]->offline_payment_text;
$paypal_businessid          		= (string)$config[0]->paypal_businessid;
$use_paypal_payment          		= (int)$config[0]->use_paypal_payment;

$basic_no_ad          				= (string)$config[0]->basic_no_ad;
$basic_price          				= (string)$config[0]->basic_price;
$basic_price_top          			= (string)$config[0]->basic_price_top;
$basic_price_featured          		= (string)$config[0]->basic_price_featured;
$basic_price_commercial        		= (string)$config[0]->basic_price_commercial;

$dealer1_no_ad          			= (string)$config[0]->dealer1_no_ad;
$dealer1_price          			= (string)$config[0]->dealer1_price;
$dealer1_price_top          		= (string)$config[0]->dealer1_price_top;
$dealer1_price_featured          	= (string)$config[0]->dealer1_price_featured;
$dealer1_price_commercial         	= (string)$config[0]->dealer1_price_commercial;

$dealer2_no_ad          			= (string)$config[0]->dealer2_no_ad;
$dealer2_price          			= (string)$config[0]->dealer2_price;
$dealer2_price_top          		= (string)$config[0]->dealer2_price_top;
$dealer2_price_featured          	= (string)$config[0]->dealer2_price_featured;
$dealer2_price_commercial         	= (string)$config[0]->dealer2_price_commercial;



// get marketplace user data
$dateToday = date("Y-m-d");
$database->setQuery("SELECT * FROM #__marketplace_users WHERE userid = '$my->id' AND published = '1' AND date_begin <= curdate() AND date_end >= curdate() ORDER BY date_begin ASC, date_end ASC ");
$marketplace_users = $database->loadObjectList();
$marketplace_users_entry_count = count( $marketplace_users);

$marketplace_users_isAdmin          = (int)$marketplace_users[0]->isAdmin;
$marketplace_users_isModerator      = (int)$marketplace_users[0]->isModerator;
$marketplace_users_categories       = (string)$marketplace_users[0]->categories;
$marketplace_users_isBlocked        = (int)$marketplace_users[0]->isBlocked;
$marketplace_users_flagTop          = (int)$marketplace_users[0]->flag_top;
$marketplace_users_flagFeatured     = (int)$marketplace_users[0]->flag_featured;
$marketplace_users_flagCommercial   = (int)$marketplace_users[0]->flag_commercial;

// Paypal settings
$notify_url 						= sefRelToAbs( "index.php?option=com_marketplace&page=ipn");
$return_url							= sefRelToAbs( "index.php?option=com_marketplace&page=ipn");
$cancel_url							= sefRelToAbs( "index.php?option=com_marketplace");

echo "<table width='100%'>";
echo "<tr>";
echo "<td align='left'>";

include($mosConfig_absolute_path.'/components/com_marketplace/topmenu.php');
// -------------------------------------------------------------------------------

$username=$my->username;
$userid=$my->id;

$afNameClass 		= "marketplace_required";
$afEmailClass 		= "marketplace_required";
$afHeadlineClass 	= "marketplace_required";
$afTextClass 		= "marketplace_required";


if ($userid == "0") {
    echo "<br>";
    echo "<br>";

    echo "<table cellspacing=\"10\" cellpadding=\"5\">";
    echo "<tr>";
    echo "<td width=\"20\">";
    echo " ";
    echo "</td>";
    //echo "<td>";
    //echo "<img src=\"".$mosConfig_live_site."/components/com_marketplace/images/system/warning.gif\" border=\"0\" align=\"center\">";
    //echo "</td>";
    echo "<td>";
    echo JOO_ADD_NOTALLOWED;
    echo "</td>";
    echo "</tr>";
    echo "</table>";
    echo "<br>";
    echo "<br>";
    echo "<br>";
    echo "<br>";
}else {  // user is logged in

$sql = "Select user_id from #__marketplace_user_paid where user_id =".$userid;
$database->setQuery($sql);
$paided_user = $database->loadResult();

	if ( $payment == 0) { // no payment set
	    if ( $marketplace_users_entry_count > 0 && $marketplace_users_isBlocked == 1) {
	            echo JOO_ACCOUNT_IS_BLOCKED;
	    }
	    else {  // user has no entry in users table or has one and is not blocked

	    if( $mode == "db") {
	    		if( !$paided_user){
	    			$sql = "insert into #__marketplace_user_paid (user_id,ad_level,no_of_ad,date_buy) values ($my->id,";
	    			if($ad_level ==0){
	    				$sql .= "'Basic package',".$basic_no_ad;
	    			}elseif ($ad_level == 1){
	    				$sql .= "'Dealer package 1',".$dealer1_no_ad;
	    			}else{
	    				$sql .= "'Dealer package 2',".$dealer2_no_ad;
	    			}
	    			$sql .=",CURRENT_DATE())";

	    		}
	    		
	    		$database->setQuery($sql);
	    			
    			 if ($database->getErrorNum()) {
			    	echo $database->stderr();
			    } else {
			        $database->query();
			    }
	            	// calculate costs for ad
	            	echo "<table><tr>";
	                	echo "<td>";
	                    	echo " ";
	                	echo "</td>";
	                	echo "<td colspan='2'>";

	                        echo "<table border='0'>";
	                        	echo "<tr>";
	                        		echo "<td colspan='2'>";
	                        			echo JOO_COMPLETE_PAYMENT;
	                        		echo "</td>";
	                        	echo "</tr>";

	                        	echo "<tr>";
	                        		echo "<td colspan='2'>";
	                					echo " ";
	                        		echo "</td>";
	                        	echo "</tr>";

	                        	echo "<tr>";
	                        		echo "<td colspan='2'>";
	                					if($ad_level == 0){
	                        				echo JOO_INFO_BASIC_TEXT;
	                        			}elseif ($ad_level == 1){
	                        				echo JOO_INFO_DEALER1_TEXT;
	                        			}else{
	                        				echo JOO_INFO_DEALER2_TEXT;
	                        			}
	                        		echo "</td>";
	                        	echo "</tr>";

	                        	echo "<tr>";
	                        		echo "<td colspan='2'>";
	                					echo " ";
	                        		echo "</td>";
	                        	echo "</tr>";

	                        	echo "<tr>";
	                        		echo "<td width='30%' colspan='1'>";
	                        			if($ad_level == 0){
	                        				echo JOO_PRICE_BASIC_TEXT;
	                        			}elseif ($ad_level == 1){
	                        				echo JOO_PRICE_DEALER1_TEXT;
	                        			}else{
	                        				echo JOO_PRICE_DEALER2_TEXT;
	                        			}

	                        		echo "</td>";
	                        		echo "<td width='70%' colspan='1'>";
	                        			if($ad_level == 0){
	                        				echo number_format( $basic_price,2)." ".$paid_ads_currency;
											$paid_ads_price_total = $basic_price; // at least basic price
	                        			}elseif ($ad_level == 1){
	                        				echo number_format( $dealer1_price,2)." ".$paid_ads_currency;
											$paid_ads_price_total = $dealer1_price; // at least basic price
	                        			}else{
	                        				echo number_format( $dealer2_price,2)." ".$paid_ads_currency;
											$paid_ads_price_total = $dealer2_price; // at least basic price
	                        			}

	                        		echo "</td>";
	                        	echo "</tr>";

	                        	if ( $ad_flag_top == 1) { // top set
	                        		echo "<tr>";
	                        			echo "<td colspan='1'>";
											echo JOO_PRICE_TOP_TEXT;
	                        			echo "</td>";
	                        			echo "<td colspan='1'>";
	                        			
		                        			if($ad_level == 0){
		                        				echo number_format( $basic_price_top,2)." ".$paid_ads_currency;
												$paid_ads_price_total += $basic_price_top; // at least basic price
		                        			}elseif ($ad_level == 1){
		                        				echo number_format( $dealer1_price_top,2)." ".$paid_ads_currency;
												$paid_ads_price_total += $dealer1_price_top; // at least basic price
		                        			}else{
		                        				echo number_format( $dealer2_price_top,2)." ".$paid_ads_currency;
												$paid_ads_price_total += $dealer2_price_top; // at least basic price
		                        			}

	                        			echo "</td>";
	                        		echo "</tr>";
	                        	}

	                        	if ( $ad_flag_featured == 1) { // featured set
	                        		echo "<tr>";
	                        			echo "<td colspan='1'>";
											echo JOO_PRICE_FEATURED_TEXT;
	                        			echo "</td>";
	                        			echo "<td colspan='1'>";
											if($ad_level == 0){
		                        				echo number_format( $basic_price_featured,2)." ".$paid_ads_currency;
												$paid_ads_price_total += $basic_price_featured; // at least basic price
		                        			}elseif ($ad_level == 1){
		                        				echo number_format( $dealer1_price_featured,2)." ".$paid_ads_currency;
												$paid_ads_price_total += $dealer1_price_featured; // at least basic price
		                        			}else{
		                        				echo number_format( $dealer2_price_top,2)." ".$paid_ads_currency;
												$paid_ads_price_total += $dealer2_price_featured; // at least basic price
		                        			}
	                        			echo "</td>";
	                        		echo "</tr>";
	                        	}

	                        	if ( $ad_flag_commercial == 1) { // commercial set
	                        		echo "<tr>";
	                        			echo "<td colspan='1'>";
	                        				echo JOO_PRICE_COMMERCIAL_TEXT;
	                        			echo "</td>";
	                        			echo "<td colspan='1'>";
											if($ad_level == 0){
		                        				echo number_format( $basic_price_commercial,2)." ".$paid_ads_currency;
												$paid_ads_price_total += $basic_price_commercial; // at least basic price
		                        			}elseif ($ad_level == 1){
		                        				echo number_format( $dealer1_price_commercial,2)." ".$paid_ads_currency;
												$paid_ads_price_total += $dealer1_price_commercial; // at least basic price
		                        			}else{
		                        				echo number_format( $dealer2_price_commercial,2)." ".$paid_ads_currency;
												$paid_ads_price_total += $dealer2_price_commercial; // at least basic price
		                        			}
	                        			echo "</td>";
	                        		echo "</tr>";
	                        	}

	                        	echo "<tr>";
	                        		echo "<td colspan='2'>";
	                					echo " ";
	                        		echo "</td>";
	                        	echo "</tr>";

	                        	echo "<tr>";
	                        		echo "<td colspan='1'>";
	                        			echo JOO_PRICE_TOTAL_TEXT;
	                        		echo "</td>";
	                        		echo "<td colspan='1'>";
										echo "<b>".number_format($paid_ads_price_total,2)." ".$paid_ads_currency." ";
	                        		echo "</td>";
	                        	echo "</tr>";

	                        	echo "<tr>";
	                        		echo "<td colspan='2'>";
	                					echo " ";
	                        		echo "</td>";
	                        	echo "</tr>";

	                        	echo "</table>";


	                	echo "</td>";
	            	echo "</tr>";


	            	if ( $use_offline_payment == 1) { // offline / bank transfer
	            		echo "<tr>";
	                		echo "<td>";
	                    		echo " ";
	                		echo "</td>";
	                		echo "<td>";
	       						?>

								<form action="#" method="post">
	   								<input type="hidden" name="payment" value="1">
	   								<input type="hidden" name="adid" value="<?php echo $adid; ?>">
									<input class="button" type="submit" name="submit" value="<?php echo JOO_FORM_SUBMIT_OFFLINE_TEXT; ?>">
								</form>

	  							<?php
	                		echo "</td>";
	                		echo "<td>";
	                    		echo "You will be asked to pay the ad via Bank Transfer. The new ad will stay in a 'pending' status until the money is transfered. Then the new ad is being published.";
	                		echo "</td>";
	            		echo "</tr>";
	            	}


	            	if ( $use_paypal_payment == 1) { // PayPal
	            		echo "<tr>";
	                		echo "<td>";
	                    		echo " ";
	                		echo "</td>";
	                		echo "<td>";

	                			if ( $use_paypal_testmode == 1) { // use PayPal Sandbox
	       							?>
									<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
	  								<?php
	                			}
	  							else {
	  								?>
									<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
									<?php
	  							}
								?>

	   									<input type="hidden" name="cmd" value="_xclick">
	   									<input type="hidden" name="business" value="<?php echo $paypal_businessid; ?>">
	   									<input type="hidden" name="return" value="<?php echo $return_url; ?>">
	   									<input type="hidden" name="cancel" value="<?php echo $cancel_url; ?>">
	   									<input type="hidden" name="item_name" value="Your payment for <?php if($ad_level==0){ echo "Basic Package";}elseif($ad_level==1){echo "Dealer Package 1";}else{echo "Dealer Package 2";} ?> "/>
	   									<input type="hidden" name="item_number" value="<?php echo $ad_level ?> "/>
	   									<input type="hidden" name="amount" value="<?php echo $paid_ads_price_total; ?>">
	   									<input type="hidden" name="no_shipping" value="1">
	   									<input type="hidden" name="no_note" value="1">
	   									<input type="hidden" name="rm" value="2">
	   									<input type="hidden" name="currency_code" value="<?php echo $paid_ads_currency; ?>">
	   									<input type="hidden" name="bn" value="toolkit-php">
	   									<input type="hidden" name="cbt" value="Return To TOMPAds.com">
	   									<input type="hidden" name="notify_url" value="<?php echo $notify_url; ?>">
										<input class="button" type="submit" name="submit" value="<?php echo JOO_FORM_SUBMIT_PAYPAL_TEXT; ?>">
									</form>
									<?php
	                		echo "</td>";
	                		echo "</tr>";
	                		echo "<tr>";
	                	//	echo "<td>";
	                    		echo "<b>*IMPORTANT*  You will be directed to PayPal's secure checkout page where you can pay with a credit card or your PayPal account. After making your payment click on the orange 'Continue' button to return and start writing your ad(s).</b>";
	                		//echo "</td>";
	            		echo "</tr>";
	            	}

	        echo "</table>";

	    } // mode db && bInputfields==0
	    else {

	        echo "<br>";
	        echo "<br>";
	       
			 ?>

	    <!-- form -->
	    <form class="marketplace" action="<?php echo $mosConfig_live_site;?>/index.php?option=com_marketplace&page=pay_ad" method="post" name="pay_ad" enctype="multipart/form-data">
	    		<?php
	    			echo JOO_PAYMENT_INTRO."<br/>";
	    			echo JOO_PAYMENT_BASIC_INTRO."<br/>";
	    			echo JOO_PAYMENT_DEALER1_INTRO."<br/>";
	    			echo JOO_PAYMENT_DEALER2_INTRO."<br/>";
	    		?>
				<br />
				<label class="marketplace" for="ad_level"><?php echo JOO_FLAG_AD_LEVEL; ?></label>
				<?php
                	echo "<select class='marketplace' id='ad_level' name='ad_level'>";
                    		echo "<option value='0' selected>Basic Package</option>";
                        	echo "<option value='1'>Dealer Package 1</option>";
                        	echo "<option value='2'>Dealer Package 2</option>";
	        	echo "</select>";
	        	?>
				<label class="marketplace_left" for="ad_level"><?php echo JOO_FLAG_AD_LEVEL_TEXT; ?></label>
				<?php
	        	echo "<br />";
	        	echo "<br />";
				?>


				<!-- buttons -->
				<label class="marketplace" for="ad_dummy"> </label>
				<input type="hidden" name="gflag" value="0">
				<?php
				echo "<input type='hidden' name='userid' value='$userid'>";
				echo "<input type='hidden' name='username' value='$username'>";
				echo "<input type='hidden' name='mode' value='db'>";

				?>
					<input class="button" type="submit" name="submit" value="<?php echo JOO_FORM_SUBMIT_PAYMENT_TEXT; ?>">


			  </form>
			  <!-- form -->

			  <br />
			  <br />


			<?php

		}
	}

}else{ // Bank Transfer screen

		echo "<table cellspacing='10' cellpadding='5' border='0'>";
	   		echo "<tr>";
	        	echo "<td width='20'>";
	            	echo " ";
	            echo "</td>";

	         	echo "<td>";
					echo JOO_BANK_TRANSFER_TEXT1;
					echo $offline_payment_text;
					echo JOO_BANK_TRANSFER_TEXT2;
	            echo "</td>";
	        echo "</tr>";
	    echo "</table>";

}
}  // user is logged in
//	}else{

//	}
echo "<br />";
echo "<br />";
echo "<br />";


// -------------------------------------------------------------------------------
echo "</td>";
echo "</tr>";


// set news feed icon if rss syndication is enabled



echo "<tr>";
echo "<td class='small' align='center'>";
include($mosConfig_absolute_path.'/components/com_marketplace/footer.php');
echo "</td>";
echo "</tr>";


echo "</table>";

?>

 

It's for a classifieds component - the problem is that when checking out at paypal with a credit card the user returns without getting the ad package they bought.  Money is received in the account though, and the strangest thing is that it works with using a paypal account, just not a credit card.

 

Any help for an extreme noob is greatly appreciated!

Sorry, it's this bit here....

 

    if( $mode == "db") {
	    		if( !$paided_user){
	    			$sql = "insert into #__marketplace_user_paid (user_id,ad_level,no_of_ad,date_buy) values ($my->id,";
	    			if($ad_level ==0){
	    				$sql .= "'Basic package',".$basic_no_ad;
	    			}elseif ($ad_level == 1){
	    				$sql .= "'Dealer package 1',".$dealer1_no_ad;
	    			}else{
	    				$sql .= "'Dealer package 2',".$dealer2_no_ad;
	    			}
	    			$sql .=",CURRENT_DATE())";

	    		}
	    		
	    		$database->setQuery($sql);
	    			
    			 if ($database->getErrorNum()) {
			    	echo $database->stderr();
			    } else {
			        $database->query();
			    }

Thanks for the reply...

 

It's actually not an error, just not making the user 'paid' in the database, and I was just on my way over here because I got it worked out with some help.

 

This ended up being the culprit in another file:

 

if (strcmp ($payer_status, "verified") == 0) {

the table _marketplace_log_paypal was getting filled,  _user_paid field 'paided' (which says the user is a paid customer) was set to 0 instead of 1, even though it was hard coded to set to 1 if it returned 'verified' from paypal (and the money was being deposited).  It was only happening with credit cards, not paypal accounts.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.