Pages

Wednesday, January 16, 2019

How to Make your Website PCI DSS Compliant

Web application that need to take payment online, then it has to follow the PCI DSS compliance (Payment Card Industry Data Security Standards). Ensuring that website is secure for taking payment and its not stolen the card data and password by anyone.

There are few point need to implement in application to follow PCI DSS compliance
a). Secure Hosting (Use SSL)
b). Use Latest TLS version of web server
c). Protect Card Data : Use Hosted payment form for any gateway (Not use website payment form)
d). CSRF token use for every request
e). Do not store card data in database : If need to reuse user card information then use token instead of storing card details
f). For reference if storing card data then store in masked format and store only last 4 digit of card number
g). Password Expiration policy
h). Always use strong password encryption algorithm for storing password in DB
i). Prevent XSS in application

Monday, July 16, 2018

How to Fix the Leverage Browser Caching?

What is Browser caching?
  • Browser stores web page files on a local computer when a user browses any web page.
  • "Leveraging" browser caching: When a webmaster has instructed browsers how their resources should be handled like what its expiration and what's the age of web page resources like css and js or any other media.

For resolve leverage browser caching error we need simple put below code into .htaccess file.

## EXPIRES HEADER CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType image/svg "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType application/javascript "access 1 month"
ExpiresByType application/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 2 days"
</IfModule>
## EXPIRES HEADER CACHING ##

Monday, July 2, 2018

MYSQL Comma Seperated Rows | Concatenate multiple MySQL rows into one field

Tips Trick to Concatenate comma separated rows Value:

Suppose you want to show comma separate row value using mysql query and want output like below:

Mysql query to get favorite subject of Person :

SELECT subjects FROM user_subject_table WHERE user_id = 5; 

It will Give below output:

subjects
Computer
History
English
Chemistry

But you want to show comma separate in single row with user id then use below query:

SELECT user_id, GROUP_CONCAT(subjects SEPARATOR ', ') as fav_subject
FROM user_subject_table GROUP BY user_id

Output:

user_id          fav_subject
2                     English, Computer
5                     Computer, History, English, Chemistry

Advance Usage : 
1. Show Distinct subjects

SELECT user_id, GROUP_CONCAT(DISTINCT subjects  SEPARATOR ', ') as fav_subject

FROM user_subject_table GROUP BY user_id

2.  Show Subject Order by (ASC or DESC)

SELECT user_id , GROUP_CONCAT(subjects  ORDER BY subjects  ASC SEPARATOR ', ') as fav_subject FROM user_subject_table GROUP BY user_id






Saturday, June 30, 2018

How to Check Version of Codeigniter Framework Using

Method 1:
Follow this path : root_folder of CI
Navigate to system -> Core -> Codeigniter.php
Here you can see the version of CI under CI_VERSION constant.
define('CI_VERSION', '3.0.0');

Method 2:
Easy and simple way:
Just write below line in any controller or any view

for example Welcome.php or Index.php (Controller)
In any function or constructor put this:

echo CI_VERSION;

This will give you the version of the CI currently you are using.

Codeigniter | How to Insert Batch Records

When you want to insert batch data into database table then you not need to insert using loop just use insert_batch function provided by Codeigniter.
Example :

$data = array(
   array(
      'title' => 'Title 1' ,
      'name' => 'Name 1' ,
      'date' => 'date('Y-m-d H:i:s)'
   ),
   array(
      'title' => 'Title 2' ,
      'name' => 'Name 2' ,
      'date' => 'date('Y-m-d H:i:s)'
   )
);

$this->db->insert_batch('your_table_name', $data);

This will reduce memory and execution time.