\r\n not working but \r\n\r\n works - codeigniter

I am sending an email via CodeIgniter's email->send(). I have come across an anomaly that I cannot figure out.
"\r\n" is not working in a certain section of the email. However if I switch "\r\n" to "\r\n\r\n" it works. By works I mean, it adds the 2 line breaks expected.
The problem area is at the bottom.
$order = $this->ordersclass->getOrder( $order_id );
$quantity = $order['no_codes'];
$client = $this->clientclass->getClient( $order['client_id'] );
$multi_d = $this->session->userdata('multi-use-codes-d');
$multi_t = $this->session->userdata('multi-use-codes-t');
$this->load->library('email');
$to = $client['client_email'];
$subject = 'Personal Resiliency Builder Order';
$from = 'accounts#resiliencybuilder.com.au';
$message = "TAX INVOICE\r\n\r\n";
$message .= "Client Name: ". $client['client_name']."\r\n";
$message .= "Invoice Number: ".$order['order_id']."\r\n";
$message .= "Invoice Date: ".$order['order_timestamp']."\r\n\r\n";
$message .= "TOTAL AMOUNT PAYABLE: $".number_format($order['order_amount'],2)."\r\n";
$message .= "GST ON SERVICES: $".number_format(($order['order_amount']/110)*10,2)."\r\n\r\n";
$message .= "ACCOUNT PAID IN FULL VIA CREDIT CARD\r\n\r\n";
$message .= "=============================================================\r\n";
$message .= "DESCRIPTION OF SERVICES\r\n\r\n";
$message .= "Code List Name: ".$this->session->userdata('codelistname') . "\r\n";
$message .= "Quantity: ".$quantity ."\r\n";
$message .= "Single-use Developmental Reports Purchased: ".$order['no_codes_d']."\r\n";
$message .= "Single-use Thriving Reports Purchased: ".$order['no_codes_t']."\r\n";
The last 2 $message variables are the problem.
The email looks like this:
TOTAL AMOUNT PAYABLE: $1,771.00
GST ON SERVICES: $161.00
ACCOUNT PAID IN FULL VIA CREDIT CARD
=============================================================
DESCRIPTION OF SERVICES
Code List Name: fggdgfdgfd
Quantity: 12
Single-use Developmental Reports Purchased: 7 Single-use Thriving
Reports Purchased: 5
Multi-use Developmental Reports Purchased: 5
Multi-use Thriving Reports Purchased: 5
SOLVED. Now looking for the understanding behind it.
After many tests, the formula for failure is: Failure = X + Y:
Failure = X character length + spaces.
In addition, it seams this problem occurs with Microsoft outlook 20xx, but not with hotmail or gmail.
Example:
$message .= "Single-use: Developmental Reports : ddddd\r\n"; ////// fail - length 41
$message .= "Single-use: DevelopmentaldReportsd:dddddd\r\n"; /// fail - length 41
$message .= "Single-use:dDevelopmentaldReportsd:dddddd\r\n"; // pass - length 41
$message .= "Single-use:DevelopmentaldReportsd:dddddddddddddddddddddddddddddd\r\n"; // pass

NOTE: This answer is for developers using CodeIgniter version 2.1.3
This is not tested on any other PHP Framework.
Based on many tests via changing the character length, adding/removing spaces, and testing with different email services:
Outlook version 20xx
Hotmail
Gmail
It is safe to conclude that CodeIgniter version 2.1.3 parses the message in such a way that given a string length around 40 characters long + 1 space character + a newline character and sending the email to all three email serves above, that only Outlook will determine that the newline character is an "Extra" newline character and therefore remove it.
It is possible to change outlooks settings to disable Outlook from removing extra newline characters
As the link suggests: Microsoft Outlook Guide to disabling Extra Newline Removal
EASY DEVELOPER SOLUTION:
Keep your string length to a maximum 39 characters including spaces.

Related

How to filter {ITEM_TITLE} and {ITEM_DESCRIPTION} osclass keywords before using them in emails?

How to filter {ITEM_TITLE} and {ITEM_DESCRIPTION} osclass keywords before using them in emails?
I want to apply a function on the item_title and item_description before using them in emails.
Ex.
Title: Sell bmw_ x5__
To become
Sell bmw x5
without changing the database values
I have the function
removeunderline(argument) that works, I only need to know from where to call it or where to use it.
(Osclass forums are blocked for new users, that's why I ask here)
/oc-includes/osclass/emails.php
Put removeunderline() at {ITEM_TITLE} and {ITEM_DESCRIPTION} values.
Example:
$words = array();
$words[] = array(
'{ITEM_DESCRIPTION_ALL_LANGUAGES}',
'{ITEM_DESCRIPTION}',
'{ITEM_COUNTRY}',
'{ITEM_PRICE}',
'{ITEM_REGION}',
'{ITEM_CITY}',
'{ITEM_ID}',
'{USER_NAME}',
'{USER_EMAIL}',
'{ITEM_TITLE}',
'{ITEM_URL}',
'{ITEM_LINK}',
'{VALIDATION_LINK}',
'{VALIDATION_URL}',
'{EDIT_LINK}',
'{EDIT_URL}',
'{DELETE_LINK}',
'{DELETE_URL}'
);
$words[] = array(
$all,
removeunderline($item['s_description']), // here
$item['s_country'],
osc_format_price($item['i_price']),
$item['s_region'],
$item['s_city'],
$item['pk_i_id'],
$item['s_contact_name'],
$item['s_contact_email'],
removeunderline($item['s_title']), // here
$item_url,
$item_link,
'<a href="' . $validation_url . '" >' . $validation_url . '</a>',
$validation_url,
'' . $edit_url . '',
$edit_url,
'' . $delete_url . '',
$delete_url
);
Do the same for all {ITEM_TITLE} in this file (10 replacements).
Do the same for all {ITEM_DESCRIPTION} in this file (3 replacements).

Commission Junction Simple Pixel Magento

Let me start by saying I am NOT a programmer. I'm a retail web manager that knows enough about HTML5 to understand what is going on. Ok now on to my issue. We recently upgraded our eCommerce platform from 3DCart to Magento. It's a completely different monster and I'm fairly lost. I'm trying to integrate Magento's simple pixel (just returns the total not the individual items) into our confirmation page but all of our tests are failing. I've tried bits and pieces of other codes that I've found around the web but I'm still missing the "amount" parameter. Can anyone help me? Below is what we have on our site now (please note this is part of the copy/paste code I've found):
//-------------------------------------------
// START CJ CONVERSION TRACKING PIXEL
//-------------------------------------------
$cjmerchID = '1521251';
$cjaid = '382643';
$cjorder = Mage::getModel('sales/order')->loadByIncrementId(Mage::getSingleton('checkout/session')->getLastRealOrderId());
$cjitems = $cjorder->getAllItems();
$cjorderID = $cjorder->getIncrementId();
//$cjsubtotal = round($cjorder->getSubtotal(), 2);
$i = 1;
foreach ($cjitems as $itemId => $item)
{
$unitPrice = round($item->getPrice(), 2);
$sku = $item->getSku();
$qty = $item->getQtyToInvoice();
//echo $qty . '<br>';
$itemsStr .= '&ITEM;' . $i . '=' . $sku . '&AMT;' . $i . '=' . $unitPrice . '&QTY;' . $i . '=' . $qty . '';
$i++;
}
?>
?<img src="https://www.emjcd.com/u?CID=<?php echo $cjmerchID; ?>&OID;=<?php echo $cjorderID; ?>&TYPE;=<?php echo $cjaid; ?><?php echo $itemsStr; ?>&CURRENCY;=USD&METHOD;=IMG" height="1" width="20">
<?php
//-------------------------------------------
// END CJ CONVERSION TRACKING PIXEL
//-------------------------------------------
According to CJ this is what I'm doing wrong:
Thank you for providing the results of your test. I am seeing the pixel calls on our server. However, both tests failed as the incorrect Action ID is being used and the 'AMOUNT' parameter has no associated value and is being passed back blank. I've attached the integration instructions for your convenience.
The Action ID for the simple action that should be integrated to replace the existing pixel is 382643.
Integration Test
Advertiser: 3448671
Ad: 12313358
Action Id: 346589
Action Type: item_sale
Query String: AMOUNT=&OID=100056687&CID=1521251&CURRENCY=USD&METHOD=IMG&TYPE=346589
Sid: TrackingTest
Surfer: 476602316150531682:VJXkXAhFHzU2 Click Ref:
Action Status: active
img src="https://www.emjcd.com/u?AMOUNT=&CID=1521251&OID=100056687&TYPE=346589&CURRENCY=USD&METHOD=IMG" height="1" width="20"
Please update the pixel to pull in the subtotal (pre-taxed amount of purchase) and to have 'TYPE' populated with 382643.
Any help you can give would me most appreciated!
Diana
See if this code works. what i did is get the subtotal of total checkout order and append a new parameter in img href with AMOUNT. Let me know how the results work out
//-------------------------------------------
// START CJ CONVERSION TRACKING PIXEL
//-------------------------------------------
$cjmerchID = '1521251';
$cjaid = '382643';
$cjorder = Mage::getModel('sales/order')->loadByIncrementId(Mage::getSingleton('checkout/session')->getLastRealOrderId());
$cjitems = $cjorder->getAllItems();
$cjorderID = $cjorder->getIncrementId();
//New Codee
$totals = Mage::getSingleton('checkout/cart')->getQuote()->getTotals();
$subtotal = $totals["subtotal"]->getValue();
//$cjsubtotal = round($cjorder->getSubtotal(), 2);
$i = 1;
foreach ($cjitems as $itemId => $item)
{
$unitPrice = round($item->getPrice(), 2);
$sku = $item->getSku();
$qty = $item->getQtyToInvoice();
//echo $qty . '<br>';
$itemsStr .= '&ITEM;' . $i . '=' . $sku . '&AMT;' . $i . '=' . $unitPrice . '&QTY;' . $i . '=' . $qty . '';
$i++;
}
?>
?<img src="https://www.emjcd.com/u?CID=<?php echo $cjmerchID; ?>&OID;=<?php echo $cjorderID; ?>&TYPE;=<?php echo $cjaid; ?>&AMOUNT;=<?php echo $subtotal; ?><?php echo $itemsStr; ?>&CURRENCY;=USD&METHOD;=IMG" height="1" width="20">
<?php
//-------------------------------------------
// END CJ CONVERSION TRACKING PIXEL
//-------------------------------------------

Barclays epdq pspid integration error : Invalid ItemName field length

I have integrated barclay card payment into my website and when i do a cardpayment i get the following error message
Invalid ItemName field length: "Product name --- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxburgandy" (54 MIN : 0 MAX : 40)
in the page https://payments.epdq.co.uk/ncol/prod/orderstandard.asp
REASON for the error : The error is being caused by the Product name / sku being too long. The parameter is limited to a maximum of 40 characters (including spaces).
In order to resolve this issue, you need to pass an item name that is less than 40 characters long.
SOLUTION:
Before submitting the form to https://payments.epdq.co.uk/ncol/prod/orderstandard.asp just delimit the itemname and id as shown below
//Fix for only 40 characters of length for itemname ITEMNAME*XX*
$ordername = substr($ordername, 0, 40);
$sku = substr($sku, 0, 15);
//Fix - End
$html .= '<input type="hidden" name="ITEMID'.$counter.'" value="'.$sku.'">';
$html .= '<input type="hidden" name="ITEMNAME'.$counter.'" value="'.$ordername.'">';

grocery CRUD list thumbnail size

Is there a way to adjust the size of gorcery CRUD's list thumbnails?
The way it is now it's just silly big, and breaks the table flow.
If possible, it would be nice to have a PHP solution or grocery CRUD setting for this; if not - a CSS rule would be ok, I guess.
Same issue I came across, I'm sure it's a quick-and-dirty solution but it worked for me.
Open your application/library/Grocery_CRUD.php
Download timthumb from here
Place timthumb.php in Root directory (in same directory
level cache folder should be there)
Find function change_list_value
Find around line number 333 in Grocery_CRUD.php
$file_url_anchor .= 'class="image-thumbnail">';
Replace with... following
$file_url_anchor .= ' class="image-thumbnail"><img src="' . base_url('timthumb.php') . '?src=' . $file_url . '&w=100&h=100&zc=3' .'" height="50px">';
Again Find function get_upload_file_input
Find around line number 2545 in Grocery_CRUD.php
$input .= $is_image ? " $image_class'>" : "' target='_blank'>$value";
Replace with following
$input .= $is_image ? " $image_class'><img src='".base_url('timthumb.php') . '?src=' . $file_url . '&w=100&h=100&zc=3'."' height='50px'>" : "' target='_blank'>$value";
Hope this would help you to get rid of ugly size in your list as well as add/edit forms

preg_match issue: Delimiter must not be alphanumeric or backslash

I know this issue has been discussed in different questions but the answers people have given don't seem to work on my end. I'm dealing with the following problem:
if ( (preg_match($suspect, $lowmsg) )
|| (preg_match($suspect, strtolower($_POST['name'])))
|| (preg_match($suspect, strtolower($_POST['email']))))
Now, people have been saying that if I put "/" in front and behind quotes like so '/email/' that this would solve the problem. I tried putting the / for email and name but it still brought me back to the same delimiter error.
I also get a final error of: Warning: Cannot modify header information - headers already sent by (my website's send.php:43) on line 61. Does this have anything to do with it or is this just an error as a result of the earlier error?
Here's the entire code for interested parties:
<?php
if(($_POST['email']=="")||($_POST['name']=="")||($_POST['message']==""))
{
echo "<html><body><p>The following fields are <strong>required</strong>.</p><ul>";
if($_POST['name'] == ""){ echo "<li>Name</li>"; }
if($_POST['email'] == ""){ echo "<li>Email</li>"; }
if($_POST['message'] == ""){ echo "<li>Message</li>"; }
echo "</ul><p>Please use your browser's back button to complete the form.</p></body></html>";
}
else
{
$message = "";
$message .= "Name: " . htmlspecialchars($_POST['name'], ENT_QUOTES) . "<br>\n";
$message .= "Email: " . htmlspecialchars($_POST['email'], ENT_QUOTES) . "<br>\n";
$message .= "Message: " . htmlspecialchars($_POST['message'], ENT_QUOTES) . "<br>\n";
$subject = htmlspecialchars($_POST['subject'], ENT_QUOTES);
$pagelink = htmlspecialchars($_POST['pagelink'], ENT_QUOTES);
$repemail = htmlspecialchars($_POST['repemail'], ENT_QUOTES);
$injection_strings = array ( "content-type:","charset=","mime-version:","multipart/mixed","bcc:","cc:");
foreach($injection_strings as $suspect)
{
if((preg_match($suspect, $lowmsg)) || (preg_match($suspect, strtolower($_POST['/name/']))) || (preg_match($suspect, strtolower($_POST['/email/']))))
{
die ( 'Illegal Input. Go back and try again. Your message has not been sent.' );
}
}
$headers = "MIME-Version: 1.0\r\nContent-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: \"" . $_POST['/name/'] . "\" <" . $_POST['/email/'] . ">\r\n";
$headers .= "Reply-To: " . $_POST['/email/'] . "\r\n\r\n";
mail($repemail, $subject, $message, $headers);
header("Location: " . $pagelink . "");
}
?>
You can try other delimiters, such as / # ~
see regexp.reference.delimiters
Hope that helps.
EDIT: you do not need to do backslash inside $_POST
Use $_POST['name'] instead of $_POST['/name/']
EDIT: try
preg_match("/".$suspect."/i", strtolower($_POST['name']);
However, I dont think you would find any of your $injection_strings inside post name. You may need to rethink how you are searching. "content_type" is not going to match "text/html" with your current statement. You'd need to try other regex like
preg_match("/".$suspect."(.*)/i", strtolower($_POST['name'], $output);
So that it would $output[0], your "suspect" variable. I'm not sure if thats what you are looking for, but maybe sending you to the right track.
EDIT: Here.
If you want to look at say "cc:" and find what email it is, use this.
preg_match("/cc:(.*)/i",'cc:'.$_POST['email'],$output);
$output[0]; would equal your email.
To be compatible with your foreach loop, you may want to change it too,
switch this below code within your "if statements"
preg_match("/".$suspect."(.*)/i",$suspect.$_POST['email'])

Resources