Jump to content

php wont work on ssl site but will locally


marnslee

Recommended Posts

Hi all, i have a file that is used on oscommerce to write all transactions to a txt file, and i am trying to get it working on a secure site. here is the code i am using

 

include "includes/configure.php"; // this is for the user & password???
$myfile = "/myob/myob_sale" . date(m) .date(d) . date(y) . ".txt";         
$DOCUMENT_ROOT = "/home/betties/public_html/secureshop/";	
$salefile = $DOCUMENT_ROOT . $myfile ;

 

It works fine locally but on the ssl server it wont write, please help, i am not very php savvy, actually not at all! :)

the freelancers do it for you for $$$.$$    lol, sometimes cheaper.

did you do this at the top?

<?php
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
?>

 

yes i did thanks, and i cant seem to navigate to the page dont have permission can i change anything so that i can, appreciate you time.

???

were you able to navigate to the page before adding

<?php
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
?>

 

or is this a general problem with the page?

What does it say exactly when you go to the page?

Forbidden

 

You don't have permission to access /secureshop/includes/myob_sale.php on this server.

 

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

 

Apache/2.0.63 (Unix) mod_ssl/2.0.63 OpenSSL/0.9.8b mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 Server at www.betties.com.au Port 80

Quote from site:

Colour For Hair Down There

$36.25

:D  gotta love it.

 

did that error come up before or still when using error_reporting(E_ALL);?

thought you were taking a while to get back to me lol!

 

no it is still doing it i have just taken it off, could it be that instead of /home/betties/public_html/secureshop/ i should be pointing to the https://???

will sometimes take a bit to get back to people... in 15 mins I won't check back at all cuz not at computer.

/home/betties/public_html/secureshop/

is the path from the root of the server, not a HTTP protocol URL.

okay, one last probably stupid question, does that page work on that server if not SSL.

if so or if u don't know, then it may be safe to guess that that is not the problem.

btw, is that all the code on that page?

will sometimes take a bit to get back to people... in 15 mins I won't check back at all cuz not at computer.

/home/betties/public_html/secureshop/

is the path from the root of the server, not a HTTP protocol URL.

okay, one last probably stupid question, does that page work on that server if not SSL.

if so or if u don't know, then it may be safe to guess that that is not the problem.

btw, is that all the code on that page?

 

no i dont know if it works without the ssl, but i can get it working locally on my mac using mamp

 

here is all the code

 

include "includes/configure.php";

$myfile = "/myob/myob_sale" . date(m) .date(d) . date(y) . ".txt";              
$DOCUMENT_ROOT = "/home/betties/public_html/secureshop/";	
$salefile = $DOCUMENT_ROOT . $myfile ;

$terms = "";                    		// Invoice terms - check MYOB Help file for options
$memo = "Website Sale";                    	// Invoice memo - can be anything
$cleared = "";                             	// leave blank to mark transaction as cleared (printed)), X otherwise
$taxinclusive = "X";           			//leave blank if order is not tax inclusive - "";
$suppinv = "";						//this is the customer's Purchase Order number if required
$shiptaxcode = "GST";                       	// Your MYOB tax code for shipping
$printed = "";
$sfirst = "";						//salesmans first name
$slast = "ONLINE";						//salesmans last name
$referrer = "online order";				//referrer if you require it
$discp = "00.00";					//percent discount for early payment
$discp = number_format($discp, 2, '.', '');




// some info we may need
$customers_id = $customer_id;
$customers_firstname = $order->customer['firstname'];
$customers_lastname = $order->customer['lastname'];
$customers_street_address = $order->customer['street_address'];
$customers_suburb = $order->customer['suburb'];
$customers_city = $order->customer['city'];
$customers_postcode = $order->customer['postcode'];
$customers_state = $order->customer['state'];
$customers_country = $order->customer['country']['title'];
$customers_telephone = $order->customer['telephone'];
$customers_email_address = $order->customer['email_address'];
$customers_address_format_id = $order->customer['format_id'];

$delivery_name = $order->delivery['firstname'] . ' ' . $order->delivery['lastname'];
$delivery_street_address = $order->delivery['street_address'];
$delivery_suburb = $order->delivery['suburb'];
$delivery_city = $order->delivery['city'];
$delivery_postcode = $order->delivery['postcode'];
$delivery_state = $order->delivery['state'];
$delivery_country = $order->delivery['country']['title'];
$delivery_address_format_id = $order->delivery['format_id'];

$payment_method = $order->info['payment_method'];
$cc_type = $order->info['cc_type'];
$cc_owner = $order->info['cc_owner'];
$cc_number = $order->info['cc_number'];
$cc_expires = $order->info['cc_expires'];
$date_purchased = 'now()';
$orders_status = DEFAULT_ORDERS_STATUS_ID;
$comments = $order->info['comments'];
$currency = $order->info['currency'];
$currency_value = $order->info['currency_value'];



// First we setup the format of our transaction header, 
// These can be changed to suit your requirements, but
// read the MYOB docs for more info.



$transaction_header ="LASTNAME\tFIRSTNAME\tADDR1\tADDR2\tADDR3\tADDR4\tTAXINC\tINVNUM\tINVDATE\t";  
$transaction_header.="SHIPVIA\tITEMNO\tQTY\tDESC\tPRICE\tINCTAX\t";
$transaction_header.="TOTAL\tInc-Tax Price\tJNLMEMO\tSHIPDATE\tREF\tTAXCODE\t";
$transaction_header.="NOGSTAMT\tGSTAMT\tFreight Amount\tInc-Tax Freight Amount\tFreight Tax Code\tFreight Non-GST Amount\tFreight GST Amount\t";
$transaction_header.="STATUS\tTERMS\tDISCDYS\tDUEDAYS\tAMTPD\tPMTMETH\t$CardID\n";


$end_order ="\n"; //adds a blank line between orders so MYOB knows when one order stops and a new one starts


// Now we setup some of the info that we need to send to the file

$order_date = date('d/m/y');
$ordernum = $insert_id;  							//this will be the order number
$sale_name = $order->customer['firstname'] . ', ' . $order->customer['lastname']; //matches the format in myob_cust.php
$customers_firstname = $order->customer['firstname'];
$customers_lastname = $order->customer['lastname'];
$shipping = $order->info['shipping_cost'];
$frtgst = ($shipping / 11);								// Freight GST amount
$frtnogst = ($frtgst * 10);								// Shipping cost minus GST
$frtgst = number_format($frtgst, 2, '.', '');
$nongstc = number_format($nongstc, 2, '.', '');
$nongst = number_format($nongst, 2, '.', '');
$frtnogst = number_format($frtnogst, 2, '.', '');
$inctxprc = number_format($inctxprc, 2, '.', '');
// Convert transaction amounts from TEP to QB currency, if needed.

if (CONVERT_MYOB_CURRENCY==1) 
{  
$shipping = ($shipping * EXCHANGE_RATE);  
$shipping_cost = ($shipping_cost * EXCHANGE_RATE);  
$total_tax = ($total_tax * EXCHANGE_RATE);  
$total_cost = ($total_cost * EXCHANGE_RATE);}

// more info for the TXT file.
$shipping = number_format($shipping, 2, '.', '');
$shipping_cost = number_format($shipping_cost, 2, '.', '');
$total_cost = number_format($total_cost, 2, '.', '');
$transtotal = $cart->show_total() + $shipping;

// setup our ship via for MYOB. Change these to match your own needs

/* if ($HTTP_POST_VARS['shipping_method'] == "Flat Rate") 
{  
$shipvia="Courier";} 
elseif 
(
$HTTP_POST_VARS['shipping_method'] == "Shipping") 
{  
$shipvia="Pickup";} 
else 
{  
$shipvia = "Australia Post";} */ 

$shipvia = "Courier";	// Above ship via "function" not tested, so we use only one option

// Check if the transaction import file exists;
$oldfile = file_exists ($salefile);

// Open transaction import file for appending, create it if necessary. 1 line for each product.
$fp = fopen($salefile,"a");

if (!$oldfile) 
{  
fputs($fp,$transaction_header);

}    

$lines=$ordernum;
$lines++;
for ($i=0; $i<sizeof($order->products); $i++) {  
$product_name = $order->products[$i]['name'];  
$product_price = $order->products[$i]['price'];  
//$inctxprc = ($product_price * $qty);    
$product_number = $order->products[$i]['model'];  
$class = $order->products[$i]['class'];  
$desc = $order->products[$i]['name'];  
//$vendor = $order->products[$i]['vendor'];  
$qty = $order->products[$i]['qty'];  
$product_id = $order->products[$i]['model'];
//$qty = $qty - ($qty * 2);  // MUST BE NEGATIVE NUMBER, SO 'FLIP' IT  
$total_product_price = ($product_price + $cart->attributes_price($order->products[$i]['id']));
//  $product_tax = tep_get_tax_rate($delivery_values['zone_id'], $order->products[$i]['tax_class_id']);  
$attributes_exist = '0';  
if ($order->products[$i]['attributes']) {    
$attributes_exist = '1';    
reset($order->products[$i]['attributes']);    
while (list($option, $value) = each($order->products[$i]['attributes'])) {      
$attributes = tep_db_query("select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix from products_options popt, products_options_values poval, products_attributes pa where pa.products_id = '" . $order->products[$i]['id'] . "' and pa.options_id = '" . $option . "' and pa.options_id = popt.products_options_id and pa.options_values_id = '" . $value . "' and pa.options_values_id = poval.products_options_values_id");      $attributes_values = tep_db_fetch_array($attributes);      
// If there are attributes, we'll simply append the values to the item description      
// on the invoice line      
$memo.= ' ';      
$memo.= $attributes_values['products_options_values_name'];      
$product_price += $attributes_values['options_values_price'];    
}  
}  
if (CONVERT_MYOB_CURRENCY==1) {    
$product_price = ($product_price * EXCHANGE_RATE);    
$total_product_price = ($total_product_price * EXCHANGE_RATE);  
}  
$product_price = number_format($product_price, 2, '.', '');  
$total_product_price = number_format($total_product_price, 2, '.', '');  
$account = $order->products[$i]['accnt'];
$total_product_price = $order->products[$i]['final_price'];  
$ItemCost = $total_product_price * $qty;

/*  
// CHANGE THESE TO SUIT YOUR MYOB TAX CODES  
if ($product_tax == "0.0000") {    $taxcode = "E";  } 
elseif ($product_tax == "7.0000") {    
$taxcode = "G";  } 
else {    $taxcode = "E";  }*/    
$taxcode = "GST";	//Australia has only one tax code

  
$total = $order->info['total'];
$gst = ($product_price / 10);	//product_price is price with no gst added yet
$gst = number_format($gst, 2, '.', '');

// Let's work out how much GST is paid on the items total (no shipping)
$nongsta = ($total - $shipping);
$nongstc = ($nongsta / 11);
$nongst = ($nongstc * 10);

// Let's work out the GST inclusive product total
$inctxtot1 = $product_price *$qty;
$inctxtot2 = ($inctxtot1 / 10);
$inctxtot = ($inctxtot2 * 11);
$inctxprc1 = ($product_price / 10);
$inctxprc = ($inctxprc1 * 11);


// Let's work out how much GST is paid on the shipping
$fgst = ($shipping / 11);

// Create order lines & write them to file  




$line ="$customers_lastname\t$customers_firstname\t$delivery_name\t$delivery_street_address\t$delivery_suburb\t$delivery_postcode\t$taxinclusive\t$ordernum\t$order_date\t";  
$line.="$shipvia\t$product_id\t$qty\t$desc\t$product_price\t$inctxprc\t";  
$line.="$inctxtot1\t$inctxtot\t$memo\t$order_date\t$referrer\t$taxcode\t";  
$line.="$sfirst\t$gst\t$frtnogst\t$shipping\t$shiptaxcode\t\t$fgst\t";  
$line.="$orders_status\t5\t1\t30\t$total\t$payment_method\t$cc_type\n";  


fputs($fp,$line);  
$lines++;}



// write an end of order line
fputs($fp,$end_order);

fclose($fp);
?>

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.