Archive

Archive for November, 2009

Adding SMTP server support in CRE Loaded 6.2

November 21st, 2009 2 comments

Till version 6.2 cre loaded was only capable of sending emails using sendmail program using php mail() function. Some time it happens that our site is hosted on shared hosting where same server IP is shared between many sites. These sites may include site which send spam emails and in result the server IP get penalized by email servers and messages being sent from this IP are not delivered to recipients, or sent to junk/spam folders directly.

For a site which has to send email notifications and status update emails, this can be a nightmare. Due to this customer don’t feel confident and think the site as fake one. To avoid this situation we can use separate mail hosting services or servers which are not black list to ensure delivery to customer inbox.

Starting from cre loaded 6.3 we can tell which smtp server to be used to send emails. It is also possible to add this feature in old versions.

In this post I will guide you how to add smtp feature, but before start keep these in mind

  • None of the code is written by me so the code belongs to its respective owners
  • Backup your files and database for in case any thing goes wrong
  • The version I am using is 6.2 Pro, I think procedure will be same for simple and B2B version

What you will need

We need SMTP class library (includes/classes/class.smtp.php)available in version 6.3 and 6.4, I got it from 6.4.0 Pro, but i think it will be same for Community addition.
Copy the file includes/classes/class.smtp.php from version 6.3 or 6.4 to includes/classes/ folder. This will be used for sending emails from front end for admin area copy same file in admin/includes/classes/.
So two new files will be includes/classes/class.smtp.php and admin/includes/classes/class.smtp.php

Adding Required Configurations:
Add following configurations in your database, these will allow admins to do settings for SMTP server.

INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, last_modified, date_added, use_function, set_function) VALUES ( 'SMTP Server Host Address', 'EMAIL_SMTP_HOST_SERVER', '', 'The fully qualified host name of the SMTP server.', '12', '10', '0000-00-00 00:00:00', '2009-06-16 20:09:42', '', '');


INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, last_modified, date_added, use_function, set_function) VALUES ('SMTP Server EHLO / HELO Name', 'EMAIL_SMTP_HELO_SERVER', '', 'A name to send as part of the SMTP EHLO / HELO commands. The name is typically the hostname of the machine this web site runs on.', '12', '11', '0000-00-00 00:00:00', '2009-06-16 20:09:42', '', '');


INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, last_modified, date_added, use_function, set_function) VALUES ('SMTP Server Port Number', 'EMAIL_SMTP_PORT_SERVER', '25', 'The SMTP server port number. Port number 25 is typically used by default.', '12', '12', '0000-00-00 00:00:00', '2009-06-16 20:09:42', '', '');


INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, last_modified, date_added, use_function, set_function) VALUES ('SMTP Authentication Required', 'EMAIL_SMTP_ACTIVE_PASSWORD', 'true', 'Set to true when the SMTP Server requires password authentication.', '12', '13', '0000-00-00 00:00:00', '2009-06-16 20:09:42', '', 'tep_cfg_select_option(array(\'true\', \'false\'), ');


INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, last_modified, date_added, use_function, set_function) VALUES ('SMTP Authentication Username', 'EMAIL_SMTP_USERNAME', '', 'The e-mail username sent to the server when SMTP password authentication is required.', '12', '14', '0000-00-00 00:00:00', '2009-06-16 20:09:42', '', '');


INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, last_modified, date_added, use_function, set_function) VALUES ('SMTP Authentication Password', 'EMAIL_SMTP_PASSWORD', '', 'The e-mail password sent to the server when SMTP password authentication is required.', '12', '15', '0000-00-00 00:00:00', '2009-06-16 20:09:42', '', '');

Modifying files:
You will need to modify two files one for front and second for admin. These files will be includes/classes/email.php and admin/includes/classes/email.php

Now open includes/classes/email.php
Find

if (EMAIL_TRANSPORT == 'smtp') {
return mail($to_addr, $subject, $this->output, 'From: ' . $from . $this->lf . 'To: ' . $to . $this->lf . implode($this->lf, $this->headers) . $this->lf . implode($this->lf, $xtra_headers));

Replace line

return mail($to_addr, $subject, $this->output, 'From: ' . $from . $this->lf . 'To: ' . $to . $this->lf . implode($this->lf, $this->headers) . $this->lf . implode($this->lf, $xtra_headers));

With this code

include_once(DIR_WS_CLASSES . ‘class.smtp.php’);

// Build up the SMTP connection parameter list
$params['host'] = EMAIL_SMTP_HOST_SERVER; // The smtp server host/ip
$params['port'] = EMAIL_SMTP_PORT_SERVER; // The smtp server port
$params['helo'] = EMAIL_SMTP_HELO_SERVER; // helo/ehlo command string; typically your domain/hostname
$params['auth'] = EMAIL_SMTP_ACTIVE_PASSWORD; // Whether to use basic authentication or not
$params['user'] = EMAIL_SMTP_USERNAME; // Username for authentication
$params['pass'] = EMAIL_SMTP_PASSWORD; // Password for authentication

// Prepare the recipient names; there can be multiple recipients in the to_addr seperated by a comma.
// Create an array of the recipients and then strip off everything and just leave the internet style
// email address behind. For example: “MyCuteName <me@mydomain.com>” => “me@mydomain.com”
$recipients = explode(‘,’, $to_addr);
for ($i = 0; $i < count($recipients); $i++) {
$recipients[$i] = trim(preg_replace( ‘/(.*)<(.*)>(.*)/’, ‘$2′, $recipients[$i]));
}
$send_params['recipients'] = $recipients;

// Timestamp the message
$date = date(‘r’);

$send_params['headers'] = array_merge($this->headers, array(“From: $from”, “To: $to”, “Subject: $subject”, “Date: $date”));

// This is used as in the MAIL FROM: cmd
// It should end up as the Return-Path: header
$send_params['from'] = $from_addr;

// The body of the email message
$send_params['body'] = $this->output;

//Send the email via SMTP
return (is_object($smtp = smtp::connect($params)) AND $smtp->send($send_params));

For file admin/includes/classes/email.php do the same as above and after that
Find:

case (($text == true) && ($attachments == false) && ($html == false)):

Replace with

case (($text == true) && ($attachments == false)):

and thats it now go to admin area and update smtp settings in Configuration > Email Options. I am using this code in one of my sites so it should work if every thing is done as described.

Categories: CRE Loaded Tags:

Protecting WordPress blogs from spam

November 16th, 2009 1 comment

It is very exciting to have your blog appearing in search results. Commonly the traffic received, includes a good number of visitors which promote spam. They commonly add comments on posts to get back links and may be visitors.

Percentage of spam comments can be very high. For example comments posted on this blog include 95% spam. Blogs hosted on WordPress.com get some protection by default, but blogs hosted else where using WordPress software are open for such spam by default.

It is really a headache to filter and remove such comments. Luckly following two WordPress plugins can make your life a lot easier.

  1. Akismet
  2. reCAPTCHA
  1. Akismet:

    In latest versions of WordPress this is installed by default. The plugin protects the blog against spam comments and deletes the obvious spam ones based on spam keywords and content. It significantly reduces the number of comments moderator have to filter. The plugin requires API key which can be attained simply by creating an account on WordPress.com. The API key is shown on edit profile page in admin area.

  2. reCAPTCHA:

    Spam comment posting is mostly done by automated software called “Bots” or “Robots”. They find specific fields on pages and fill them with predefined data. reCAPTCHA wordpress plugin provides protection against these bots this reducing  the number of spam comments. The plugin requires two keys called Public and Private key. These can be obtained by creating free account at recaptcha.net.

Categories: Uncategorized Tags:

Google Caffeine is coming

November 16th, 2009 No comments

Google’s search based on new technology will be rolled out in early 2010. Google caffeine will be first rolled out on one data center. Developer preview of caffeine is now removed so you can’t perform any testing on it anymore. According to google caffeine is technology to improve indexing infrastructure and performance.

Categories: SEO Tags:

Compress your web pages

November 15th, 2009 2 comments

When optimizing web performance, most consideration is given to reduce number and file size of images, CSS and JS etc., and less consideration is given to size of HTML being sent to browser, called “document size”. Optimizing document size can be very beneficial.

There are two ways you can reduce the document size

  1. Reduce HTML
  2. Compress HTML sent
  1. Reducing HTML: Well its not easy for developers, but its good to consider during writing html. A good way to do it is to use DIVs instead of tables. If used correctly divs reduces the code to text ratio in document. Secondly avoid using inline css styles and java script. You can use external css and js files for this purpose.
  2. Compressing HTML: The best way to reduce the document size is to send html in compressed form. Today most of the browser capable of receiving html in compressed format, un compress it on client side and display it correctly. This reduces the time spent and bandwidth usage between browser and server significantly. If you are working with PHP and apache it is really easy to compress HTML before sending to client. Most of the PHP installations have built in gzip library. You only have to use it. If you have static files or don’t want to use PHP or have static html files you can use apache module mod_deflate to compress html. Both of above methods use gzip compression.

How gzip Works
gzip compression works by finding identical strings within a html, and replacing those temporarily to make the overall size smaller. Its compression algorithm makes is very suitable to be used with html, css as they have repetitive tags and definitions. For example if our html has tag <div> 100 times it will replace this tag during compression thus reducing the size significantly.

Categories: Web Performance Optimization Tags:

Home of SPHINX search is down

November 12th, 2009 2 comments

Home of great SPHINX search http://www.sphinxsearch.com is down. Complete site including Forums, Downloads are unavailable. It is now almost 12 hours since we realized that the site is down.

One reason behind this might be that this site is NOT powered by SPHINX, yes its true forums searching is not implemented on SPHINX.

Hope to have it back soon.

Categories: SPHINX Tags:

Categories Breadcrumb not working, CRE Loaded Pro

November 1st, 2009 3 comments

I was amazed to see that Categories breadcrumb is not working http://demos.creloaded.com/creloaded_pro/index.php?cPath=3_10 on category pages. You can see proper cPath in url still the breadcrumb is missing. This happens on in CRE Loaded 6.4 PRO. Breadcrumb is not only important for visitors, it is also important for SEO aspect.

The issue is due to bug in “runtime override” code. The code is using $cPath_array variable which is not declared global in function. To fix this open file includes/runoverride/applicationtop/CDSlogic_applicationtop_breadcrumb.php and find line global $breadcrumb, $languages_id after the $languages_id variable add, $cPath_array. This will make cPath_array global and the breadcrumb will start working.

Categories: CRE Loaded Tags:

Why specify image dimensions

November 1st, 2009 No comments

Some times for connivance webmasters don’t specify dimensions of images (using height and with attributes). If thumbnails of user uploaded image are created proportionally it become difficult to specify a fixed size of an image as one dimension may be smaller then other. See in example page here image dimensions in listing are not specified as images are of different sizes.

Not specifying image sizes causes “Browser reFlow”. Browser reflow means that browser have to adjust height and width of image once its downloaded. After browser determines the image dimensions it has to adjust height and width of all parent elements. For example if an image is located inside a TD, the browser will adjust height/width of TR, table and then page body.

All these operations consume client CPU so the page renders slower, thus giving impression of slow loading to client. So it is good idea to specify dimensions for all images. I recently fixed this issue on one of my CRE Loaded based project.

Categories: Web Performance Optimization Tags:

what Google search parameters do?

November 1st, 2009 No comments

Some one forwarded an worth sharing post, explaining different parameters used in google search. Here what parameters are being used in Google search and what they do.

Parameter Description (Value)
Search modifiers
q / as_q the search query
as_epq matches exact phrase, same as searchphrase surrounded by quotes in searchbox
as_oq with at least one of the search terms, same as searchterms combined with OR in searchbox
as_eq without these searchterms, same as searchterm prefixed with – in the searchbox
qdr / as_qdr Date restriction, show results up to either 3 months old, 6 months old, or 1 year old
as_occt (3m | 6m | y)
as_filetype query term occurs in (any | title | body | url | links)
as_ft specify filetype (pdf | ps | dwf | kml | kmz | xls | ppt | doc | rtf | swf)
sitesearch exclude or include solely files with filetype given in as_filetype (e | i)
as_sitesearch the same as site: (URL with or without http://)
as_dt same as sitesearch, but shows site:URL in the search box, can be used together with as_dt
as_rq (URL with or without http://)
as_lq together with as_sitesearch shows you results from URL, or from all except that URL (i (only
hl this URL)| e (except this URL))
lr find sites related to URL, same as related: in the search box (URL)
ie find sites linking to URL, same as link: in the search box (URL)
oe specifies the interface language
safe language restrict (<langcode>)
filter input encoding
Result modifiers output encoding (<documentation>)
num safe search filtering (active (default)| off)
newwindow 0
pws number of results (<0..100>)
adtest open results in new window (1)
Buttons disable personalized web search (0)
btnG allows testing of ads without registering an impression, url’s are not clickable (on)
btnI normal search from webinterface
Localization (taken from: bluetent.typepad.com) I’m feeling lucky search (I%27m+Feeling+Lucky)
gl country, for instance “US” (<countrycode>)
gll latitude&longitude, (<latitude>,<longitude>)
gr region, for instance GB-ENG (<region>)
gcs city, to use this gr must be set to the same value (<city>)
gpc postal code, only works if gl is set to “US” (<postalcode>)
gm US designated metropolitan areas (<GM>)
Categories: SEO Tags:

Installing “Output Queries Debug” in CRE Loaded 6.4 PCI

November 1st, 2009 No comments

Output Queries Debug is very useful contribution for osCommerce. This contribution captures each query used to construct a page and can be output if desired. This information can be very useful for developers working on CRE Loaded performance optimization. To see more details about the contribution please refer to this page.

In this post we will be installing on CRE Loaded PCI 6.4 PRO. We will be using Runtime Code Inclusion (RCI) feature for installing the contribution. For details about RCI please refer to CRE loaded forums or any where ever you can find.

It is always a good idea to backup your files before making any changes. Unless you feel comfortable do not make the changes on live site.

Step One: Changing tep_db_query function
Open file includes/functions/database.php and

Find:

if (defined('STORE_DB_TRANSACTIONS') && (STORE_DB_TRANSACTIONS == 'true')) {
$page_name = $_SERVER['SCRIPT_FILENAME'];
$page_name = str_replace('\', '/', $page_name);
$page_name = str_replace('//', '/', $page_name);
$i = strrpos($page_name, '/');
$page_name = substr($page_name, $i+1);
error_log('QUERY - ' . $page_name . ':'. "\n" . $query . "\n", 3, DIR_FS_CATALOG . STORE_PAGE_PARSE_TIME_LOG);
$sql_start = microtime(true);
}

After above code Add following

// queries_debug-v1.7
$query_start = microtime();

After:

$result = mysql_query($query, $$link) or tep_db_error($query, mysql_errno(), mysql_error());

Add:

// start queries_debug-v1.7
global $debug;
if ((DISPLAY_QUERIES == 'true') || (DISPLAY_PAGE_PARSE_TIME == 'true')){
$_start = explode(' ', $query_start);
$_end = explode(' ', microtime());
$_time = number_format(($_end[1] + $_end[0]) - ($_start[1] + $_start[0]), 6);

$debug['QUERIES'][] = $query;
$debug['TIME'][] = $_time;
}
// end queries_debug-v1.7

Step Two:
Create a new php file debug_applicationbottom_bottom.php in /includes/runtime/applicationbottom/ and put following code in the created file

<?php
global $debug;
if (DISPLAY_PAGE_PARSE_TIME == ‘true’) {
$time_start = explode(‘ ‘, PAGE_PARSE_START_TIME);
$time_end = explode(‘ ‘, microtime());
$parse_time = number_format(($time_end[1] + $time_end[0] – ($time_start[1] + $time_start[0])), 3);
echo ‘<div align=”center”><span>’ . $parse_time . ‘ – ‘ . sizeof($debug['QUERIES']) . ‘</span></div>’;
if (DISPLAY_QUERIES == ‘true’) {
echo ‘<b>QUERY DEBUG:</b><pre>’;
print_r($debug);
echo ‘</pre><hr>’;
echo ‘<b>SESSION:</b><pre>’;
print_r($_SESSION);
echo ‘</pre><hr>’;
echo ‘<b>COOKIE:</b><pre>’;
print_r($_COOKIE);
echo ‘</pre><b>POST:</b><pre>’;
print_r($_POST);
echo ‘</pre><hr>’;
echo ‘<b>GET:</b><pre>’;
print_r($_GET);
echo ‘</pre>’;
} # END if request
}
unset($debug);
?>

Step Three: adding configuration
Run following sql statement on your database through phpmyadmin, command line or any MySQL other interface. This statement will allow you to turn on or off the queries through the admin panel:

INSERT INTO configuration ( configuration_id , configuration_title , configuration_key ,
configuration_value , configuration_description , configuration_group_id , sort_order ,
last_modified , date_added , use_function , set_function )
VALUES ( '', 'Display Database Queries', 'DISPLAY_QUERIES', 'true',
'Display COOKIE, SESSION, POST, and GET data in the footer', '10', '6', NOW( ) , NOW( ) ,
NULL , 'tep_cfg_select_option(array(''true'', ''false''),' );

And that’s it we are done with the installation. Browse to home page of your CRE Loaded installation to see if its working. You can turn on/off the queries information displayed at bottom of the page from admin » Logging » Display Database Queries menu.

Categories: CRE Loaded Tags:

SEO URLs addon for CRE Loaded

November 1st, 2009 2 comments

SEO url is a commercial addon for converting links to SEO Friendly format. Almost every cre loaded site requests to have seo friendly urls. In CRE loaded 6.4 pro the addon has become built in feature.

Over the time using this addons I realized a major issue regarding SEO. As you may know issue of duplicate content is major concern for every seo expert. The seo urls addon helps generating duplicate content :) , yes its true.

Consider a product posted in two or more categories, there will two different SEO friendly URLs which will be pointing to same content. For example

http://**/Main-cat-one-subcat-one/c1_21/p1/my-product/product_info.html
http://**/Other-main-cat-other-sub-cat/c2_30/p1/my-product/product_info.html

the two above urls point to same product same content. These links are generated from listing pages.

Even if there are no product listed in multiple categories still different pages like “specials” page can generate duplicate link for same product.

Due to this addon more urls are generated from “Buy Now” links which are like http://**/Main-cat-one-subcat-one/c1_21/p1/my-product/index.html?action=buy_now. These duplicate links are just killing for seo as search engine consider them separate links and expect different content.

How to fix: These issues and some more are fixable and have been fixed for many sites. If you like to get them fixed for your site then contact or post a commit.

Categories: CRE Loaded, SEO Tags: