Enhanced e-mail SPAM protection in ISPConfig 3


How to enchance e-mail SPAM protection in ISPConfig 3. In the end we will be able to

    Reject sender hostnames with invalid syntax
    Reject sender hostnames that are no fully qualified domains (e.g. reject “server1” but allow server1.domain.tld)
    Reject sender domains that have no DNS records
    Check sender IP addresses against realtime blacklists

Always ensure that you make a copy of your configuration file. In this case its at /etc/postfix/main.cf on Debian.

sudo cp -pf /etc/postfix/main.cf /etc/postfix/main.cf.bak

Then execute this command as sudo

sudo postconf -e 'smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_invalid_hostname, reject_non_fqdn_hostname, reject_unknown_recipient_domain, reject_non_fqdn_recipient, reject_unauth_destination, reject_non_fqdn_sender, reject_unknown_sender_domain, reject_unknown_recipient_domain, reject_rbl_client cbl.abuseat.org,reject_rbl_client dul.dnsbl.sorbs.net,reject_rbl_client ix.dnsbl.manitu.net, check_recipient_access mysql:/etc/postfix/mysql-virtual_recipient.cf, reject_unauth_destination'

Then restart postfix so that your changes will take effect immediately.

sudo /etc/init.d/postfix restart

Advertisements

Enable image caching in apache for better Google Page Speed results


High page speed and short page load times of your website are essential for good search engine rankings. To enable Image caching and http requests in apache, you need to enable the expires module on Ubunto or Debian. This module allows the apache web server to set HTTP headers. It sets the modification header for static assets like image and CSS files that do not change often.


a2enmod headers expires

Add the following directives inside the vhost file of the web site or at the end of the file /etc/apache2/apache2.conf to enable it globally.

Header set Cache-Control "max-age=3024000, public"
</FilesMatch

On ISPConfig 3 servers, this can be added in the “Apache Directives” field of the website instead. There is no apache reload required as ISPConfig takes care about that

Porteus Linux – Fast and versatile USB Linux


I was a searching for a Linux for installing into USB and also backing up files from windows. There is also several benefits of having a Linux USB.

  • Backup your files from Windows and GNU/Linux Operating System. That includes saving files across many file systems like Fat32, Ext3 and Ext4. You could also sync it with cloud services like Google drive, Dropbox etc.
  • Have your personalized Operating system load on any PC which could a public computer, friends’ laptop or a Browsing center (internet cafe).
  • Test drive a new Linux OS without having to mess with your operating system on the Desktop
  • Install Programming Language like Python and Ruby without the fear that you will mess with the system packages.
  • Browse anonymously and securely in a public unsafe networked environment.
  • Seamlessly encrypt and decrypt your data so that it does not get misused if lost or stolen.
  • Boot very fast and quickly complete the task because you are always in a hurry when you are working outside your home and office.
  • Able to boot from a dual partition pen drive (USB). This way if for some reason one is not able to boot from another PC, at least we should be able to use it as a windows recognizable drive.

Porteus surprised me by fulfilling many of expectations. I could install it within no time. the installation was radically different from many Ubuntu based distro and other modern GNU/Linux operating system. I could just mount the ISO file as a virtual CD and then copy the boot folder into the target thumb drive. Then its just a matter of running a bash script provided by Porteus.

If you have used Slitaz or Slax you would know the concept of package modules.  Changes to the Operating System could be stored and thus you could persist your session. There are several ways to store data, customize and even magic folder which are always in sync with each other.

Prior to installation I have partitioned the USB drive into two files systems. A Fat32 in the beginning and Ext4 in the end.

 

 

 

 

 

 

Things to do after Magento 1.9.4.4 install


Replace Magento logo with your Brand Name

  • If you followed my other post for installation in a shared hosting environment, then you would want to do the following things.
  • Replace the Magento Logo with your store Brand. For this upload the logo to the following directory

magentodir/skin/frontend/rwd/default/images/yourbrand.png

  • then in your admin panel select configuration and then with your current configuration scope as Default Config
  • select Design from the left panel
  • make sure that your package name is rwd in the right side pane. if not replace rwd with the package name in the above path.
  • now scroll down to the Header section in the right pane and enter the name of the image you uploaded without changing the images/ prefix so it looks like images/yourbrand.png

Add products to your Magento webpage

  • From you admin panel CMS menu select pages
  • Then click on your existing homepage to edit the page.
  • Then click on the content tab.
  • In the HTML editor toolbar, look for the insert widget icon   and click it.
  • In the appearing panel window select catalog new products list for widget type
  • For display type, If you select new products, After populating the rest of the fields in the widget window, simply click the insert widget button to add the widget to your page.
  • If you want to get rid of the ugly bullets from the product, go to the custom design pane and paste the following code

<reference name="head">
<action method="addCss">
<stylesheet>css/custom.css</stylesheet>
</action>
</reference>

  • now upload the custom.css to the following magento installation sub directory.

magentodir/skin/frontend/rwd/default/css

Change the button text to your Locale

  • We, Indians speak English that is most similar to British and not U.S. So I selected British (English) as my Locale at the time of Magento Installation.  So the button names like Add to Cart, Proceed to Checkout etc. is good enough for most of the installation. However my client wanted to use Magento for sending Quotation instead of doing E-Commerce. So I had to change many of the buttons and hyperlinks. Lets see how to do this.
  • There are three different ways to change the Locale we will use the csv technique for making the changes.
  • Upload a CSV file like this one under the directory /magentodir/app/design/frontend/rwd/default/locale/en_GB
  • If no directory exists inside your theme/default then you can create it.

Change the new order email template

  • If you have made magento to bypass cron and send mail immediately after placing the order, then next step you want to take is change the emails text.
  • For this you need to edit the file located under folder magentodir/app/locale/en_us/template/email/sales

Magento 1.9.4.4 step by step installation on a Shared Hosting


  •  Download the zip archive from Magento website. Do not use the downloader version because its more complicated.
  • create a subfolder under public_html.
  • Set folder permission 755 to the public_html/subfolder
  • Unzip the contents of Magento archive into it.
  • Set correct file permission 644 to the subfolder/index.php
  • replace the contents of .htaccess file with this code. please substitute subfolder with your actual magneto installation foldername

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /subfolder/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /subfolder/index.php [L]
</IfModule>
<IfModule mod_security.c>
SecFilterEngine Off
SecFilterScanPOST Off
</IfModule>

  • make following changes to file public_html/app/code/core/Mage/Sales/Model/Order.php at around line 325. This is not necessary but if you want Magento to send mail immediately without relying on Cron, you may do like this.


// $mailer->setQueue($emailQueue)->send();
$mailer->send();

Sending email screen shots from Enlightenment Linux


I read somewhere that its possible to take unattended screen shots (scrot) and mail it (heirloom-mailx) every one hour (/etc/cron.hourly). It was not easy particularly the mailing part because configuring any mail program to send mail from terminal to the outside world seemed a herculean task. The steps ..

$ sudo apt-get install scrot

$ sudo apt-get install heirloom-mailx

#  to install certutil in enlightenement

$ sudo apt-get install libss3-tools

# Create a certificate directory
$ mkdir .certs
 
# Create a new database in the certs dir
$ certutil -N -d .certs 
 
# Fetch the certificate from Gmail, saving in the text file GMAILCERT
echo -n | openssl s_client -connect smtp.gmail.com:465 | sed -ne ‘/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p’ > GMAILCERT
 
# Import the new cert file into the new database in the new dir. enter password when prompted
$ certutil -A -n “Google Internet Authority” -t “C,,” -d .certs -i GMAILCERT 
 
# Double Check
$ certutil -L -d .certs

Certificate Nickname                                         Trust Attributes
                                                             SSL,S/MIME,JAR/XPI
 
Google Internet Authority                                    C,,  
edit ~/..mailrc file
 account gmail {
 set smtp-use-starttls
 set ssl-verify=ignore
 set nss-config-dir=~/.certs
 set smtp=smtp://smtp.gmail.com:587
 set smtp-auth=yourusername@gmail.com
 set smtp-auth-user=you@gmail.com
 set smtp-auth-password=your_gmail_passwsord
 set from=”you@gmail.com
 }

Testing mail Config

 echo “Test Email” | mailx  -v -A gmail -s “test” testing@example.com

 

 

 

YII webapp customising from ground up


A)) config/main.php

1. name your webapp

‘name’=’my webapp’

2.  enable gii

‘gii’=>array(
‘class’=>’system.gii.GiiModule’,
‘password’=>’password’,
// If removed, Gii defaults to localhost only. Edit carefully to taste.
‘ipFilters’=>array(‘127.0.0.1′,’::1′),
),

),

3. create your database scheme

4.  beautify url

‘urlManager’=>array(
‘urlFormat’=>’path’,
‘rules’=>array(
‘<controller:\w+>/<id:\d+>’=>'<controller>/view’,
‘<controller:\w+>/<action:\w+>/<id:\d+>’=>'<controller>/<action>’,
‘<controller:\w+>/<action:\w+>’=>'<controller>/<action>’,
),
),

5. enable mysql or point to sqldatabase

‘db’=>array(
‘connectionString’ => ‘mysql:host=localhost;dbname=mywebapp’,
’emulatePrepare’ => true,
‘username’ => ‘root’,
‘password’ => ‘password’,
‘charset’ => ‘utf8’,
),

6. set admin email

‘params’=>array(
// this is used in contact page
‘adminEmail’=>’xxxxx@gmail.com’,
),

 

7. show log messages in the webpage

/ uncomment the following to show log messages on web pages
//
array(
‘class’=>’CWebLogRoute’,
),

componenets/UserIdentity.php

7.  change default passwords

public function authenticate()
{
$users=array(
// username => password
‘demo’=>’demo’,
‘admin’=>’admin’,
);

BB) Download mbmenu plugi

views/layouts/main.php

1. change menus

<?php $this->widget(‘application.extensions.mbmenu.MbMenu’,array(
‘items’=>array(
array(‘label’=>’Home’, ‘url’=>array(‘/site/index’)),
array(‘label’=>’Menu 1’, ‘url’=>array(‘/menu1l’),
‘items’=>array(
array(‘label’=>’sub menu 1’, ‘url’=>array(‘/item11’)),
array(‘label’=>’sub menu 2’, ‘url’=>array(‘/item12)),
),
),

2. change footer

<div id=”footer”>
Copyright &copy; <?php echo date(‘Y’); ?> by my company – All Rights Reserved.<br/>
</div><!– footer –>

CC)  YII-booster plugin

config/main.php

Yii::setPathOfAlias(‘booster’, dirname(__FILE__) . DIRECTORY_SEPARATOR . ‘../extensions/yii-booster’);

// preloading ‘log’ component
‘preload’=>array(‘log’,’booster’),

‘components’=>array(

…………………..

‘booster’=> array(
‘class’ =>’booster.components.Booster’,
‘responsiveCss’=>true,
),

………………………….

Handling related models in YII forms


Many AWBs can be carried in one Trip. One AWB can be carried across Many Trips. We will use MySQL for the database. Below is the schema. tbl_tripAWB is the junction table.

CREATE TABLE tbl_trip(

id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,

truckId TINYINT UNSIGNED NOT NULL,

departureDate DATETIME NOT NULL,

tripOrigin MEDIUMINT UNSIGNED NOT NULL,

tripDestination MEDIUMINT UNSIGNED NOT NULL,

arrivalDate DATETIME NOT NULL,

tripFor BOOLEAN NOT NULL DEFAULT 0,

tripStatus VARCHAR(125),

trip TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,

INDEX (truckId),

INDEX (tripOrigin),

INDEX (tripDestination)

) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE tbl_awb(

id INTEGER UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,

awbPrefix VARCHAR(3) NOT NULL,

awbNumber VARCHAR(8) NOT NULL,

awbAirport MEDIUMINT UNSIGNED NOT NULL,

awbCarrier TINYINT UNSIGNED NOT NULL,

awbPieces TINYINT UNSIGNED NOT NULL,

awbWeight MEDIUMINT UNSIGNED NOT NULL,

awb TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,

INDEX (awbAirport),

INDEX (awbCarrier)

) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE tbl_tripAwb(

id INTEGER UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,

trip INTEGER UNSIGNED NOT NULL,

awb INTEGER UNSIGNED NOT NULL

) ENGINE=InnoDB DEFAULT CHARSET=utf8;

ALTER TABLE tbl_tripAwb

ADD CONSTRAINT FOREIGN KEY (trip) REFERENCES tbl_trip (id) ON UPDATE CASCADE,

ADD CONSTRAINT FOREIGN KEY (awb) REFERENCES tbl_awb (id) ON UPDATE CASCADE;

Update Trip form to display the list box with multi select containing AWBs.

labelEx($model,’tripAwbs’); ?>
dropDownList($model, ‘tripAwbs’, CHtml::listData(Awb::model()->findAll(), ‘id’, ‘awbNumber’, ‘awbPrefix’),array(‘multiple’=>’multiple’, ‘size’=>5)
); ?>
error($model,’tripAwbs’); ?>

Yii automatically created the below relationship


'tripAwbs' => array(self::HAS_MANY, 'TripAwb', 'trip'),

In order for the creation of a new Trip to work, you’ll need to update the Controller to handle the tripAwbs. Within the actionCreate() method (of TripController), after the Trip has been saved, loop through each AWB and add that record to tbl_tripAwb. The beginning of actionCreate() would look like:

if(isset($_POST['Trip']))
{
$model->attributes=$_POST['Trip'];
if($model->save()) {
foreach ($_POST['Trip']['tripAwbs'] as $awb) {
$tripAwb = new TripAwb;
$tripAwb->trip = $model->id;
$tripAwb->awb = $awb;
if (!$tripAwb->save()) print_r($tripAwb->errors);
// $this->redirect(array('view','id'=>$model->id));
}}
}

The form has already been created and populated, but to get it to indicate existing selections, we need to pass along the tbl_tripAwb values. You might think that you can just fetch all the tbl_tripAwb records where id equals the Model’s id (in other words, perform a with(‘tripAwb’)-> retrieval), but you can’t. For the drop-down menu in the form to preselect the right values, the form needs to access an array of values, not an array of objects. To achieve that, add some code to the loadModel() method of the TripController. This method is called for the update, delete, and view actions and just returns a single Model. The Model is loaded using:


public function loadModel($id)
{

$model=Trip::model()->findByPk($id);

// added for update by karthick
$criteria=new CDbCriteria;
$criteria->condition=’trip=:trip’;
$criteria->select = ‘awb’;
$criteria->params=array(‘:trip’=>$_GET[‘id’]);
$tripAwbs = TripAwb::model()->findAll($criteria);

$Awbs = array();
foreach ($tripAwbs as $awb) {
$Awbs[] = $awb->awb;
}

$model->tripAwbs = $Awbs;

if($model===null)
throw new CHttpException(404,’The requested page does not exist.’);
return $model;
}

Then update the tbl_tripAwb when the form is submitted (and the post is updated). The easiest way to handle all possibilities is to clear out the existing values (for this trip) in tbl_tripAWb, and then add them new. To do that, in actionUpdate() of the TripController, you would have:


if(isset($_POST['Trip']))
{
$model->attributes=$_POST['Trip'];
if($model->save()) {
$criteria=new CDbCriteria;
$criteria->condition='trip=:trip';
$criteria->params=array(':trip'=>$model->id);
tripAwb::model()->deleteAll($criteria);

// repeat of for each loop found in actionCreate()

foreach ($_POST[‘Trip’][‘tripAwbs’] as $awb) {
$tripAwb = new TripAwb;
$tripAwb->trip = $model->id;
$tripAwb->awb = $awb;
if (!$tripAwb->save()) print_r($tripAwb->errors);
}

$this->redirect(array(‘view’,’id’=>$model->id));
}

}

Nokia N900


My Nokia N900 suddenly started losing battery charge fast. I have updated the latest beta repositories and installed as much as new (useful) applications I can. The situation became so bad, that I cannot use my phone for even few calls. I was charging my phone more rather than using it. So, I decided to do something about it.

I then flashed my phone from one of the US kernels, i downloaded before. It was successful but I was not getting any network at all and hence could not make any calls. After pulling my hair for several days and going through abundant resources from the net, I downloaded the latest US kernel and did the flashing once again. This time I was successful.

Guess, what was the problem. Never downgrade from the previous version of kernel or whatever on the N900. The same kernel worked for me before, now it didn’t because. I have updated to the latest kernel after installing it and hence applying the old kernel do not work 🙂

Customizing Gedit as Web Developer’s IDE


These tips I followed from Micah Carrick’s blog

1. get the tag for gedit
wget http://www.micahcarrick.com/files/gedit_webdev_tags-0.1.tar.gz
tar -xzf gedit_webdev_tags-0.1.tar.gz
sudo mkdir /usr/share/gedit-2/plugins/taglist
sudo cp *.tags /usr/share/gedit-2/plugins/taglist/
rm -rf *.gz *.tags

2. get current version of PHP_Beautifier and other useful stuffs

sudo apt-get install csstidy linkchecker
sudo pear install PHP_Beautifier-0.1.14

3. use external tools plugin
for beautifying PHP (add command)

php_beautifier -s4 -l “ArrayNested() IndentStyles(style=bsd) NewLines(before=if:switch:while:for:foreach:function:T_CLASS:return:break,after=T_COMMENT)”

check PHP code for parse error (add command)
php -l

PHP function look up in browser firefox (add command)
xargs -I '{}' firefox \
'http://www.php.net/search.php?lang=en&show=quickref&pattern={}'

“Not working for me in Jaunty Jackalope”

4. get ftp support
run gconf-editor add ftp to the list at
/apps/gedit-2/preferences/editor/save/writable_vfs_schemes/

“Already updated in Jaunty Jackalope”

5.get symbol browser plugin

cd ~/.gnome2/gedit/
wget http://sourceforge.net/projects/symbol-browser/files/symbol-browser-bin/gedit-symbol-browser-plugin-bin-ubuntu-i386-0.1/gedit-symbol-browser-plugin-bin-ubuntu-i386-0.1.tar.gz
tar -xzf gedit-symbol-browser-plugin-bin-ubuntu-i386-0.1.tar.gz
rm -rf *.gz
sudo apt-get install libgnomeprintui2.2-0 ctags

Now enable from menu Edit->Preferences-Plugins

6. get tidy plugin
cd plugins
wget http://www.eng.tau.ac.il/~atavory/gedit-plugins/html-tidy/html-tidy-gedit-plugin.tar.gz
tar -xzf html-tidy-gedit-plugin.tar.gz
sudo apt-get install tidy

7. get PHP autocomplete
wget http://downloads.sourceforge.net/project/gedit-autocomp/gedit-autocomp/gedit-autocomplete-0.9.6/gedit-autocomplete-0.9.6.tar.gz
tar -xzf gedit-autocomplete-0.9.6.tar.gz
cd gedit-autocomplete-0.9.6
mv *.* ../.
cd ..
rm -rf gedit-autocomplete
*

8. get python plugin for posting code into snipplr.com remotely.


wget http://geditsnipplr.googlecode.com/files/snipplrpy-0.4.tar.gz
tar -xzf snipplrpy-0.4.tar.gz
cd snipplrpy-0.4/
sudo python setup.py install
cd ..
wget http://geditsnipplr.googlecode.com/files/gedit_snipplr_plugin-1.0.tar.gz
tar -xzf gedit_snipplr_plugin-1.0.tar.gz
cd plugin
mv snipplr* ../.
cd ..
rm -rf plugin

if you have not signed up already, sign up with snipplr.com and get the api key from the site.

9. cleanup
rm -rf *.gz

Continue reading “Customizing Gedit as Web Developer’s IDE”