PHP Web Development Wordpress

WordPress page template to access htaccess protected pdf file

WordPress page template to access htaccess protected pdf file: <?php /* pdf file download provision */ $download_success = false; $file_found = false; if(current_user_can( ‘manage_options’ )){ $doc = esc_url($_GET[‘doc’]); echo $file = str_replace(‘https://wma.ie/’,ABSPATH ,$doc); if (file_exists($file)) { $file_found = true; ob_clean(); flush(); header(‘Content-Description: File Transfer’); header(‘Content-Type: application/octet-stream’); header(‘Content-Disposition: attachment; filename=’.basename($file)); header(‘Content-Transfer-Encoding: binary’); header(‘Expires: 0’); header(‘Cache-Control: must-revalidate’); […]

PHP Web Development

Base64 encoded image save by PHP

How to save base64 encoded image in a file using PHP <?php  /// define upload directory     define(‘UPLOAD_DIR’, ‘images/’); /// explode  on ;base64  to know image type from encoded string    $image_parts = explode(“;base64,”, $_POST[‘image’]);     $image_type_aux = explode(“image/”, $image_parts[0]);     $image_type = $image_type_aux[1];     $image_base64 = base64_decode($image_parts[1]);    /// create file path with file name     $filepath = UPLOAD_DIR .’img_’. […]

codeigniter PHP Web Development

How to remove index.php from codeigniter URL?

To remove index.php from codeigniter URL, open application/config/config.php 1. Search for $config[‘index_page’] = ‘index.php’; and replace with $config[‘index_page’] = ”;   2. Search for $config[‘uri_protocol’] = ‘AUTO’; and replace with $config[‘uri_protocol’] = ‘REQUEST_URI’;   3. Add the below code to your .htaccess file on root of your web host directory: RewriteEngine on RewriteCond $1 !^(index\.php|resources|robots\.txt) RewriteCond […]

PHP Web Development

Common security features to Website/App Admin

Below is the list of some common security tasks to be implemented on each login panel/module development: SSL installation Encryption of data Access of Website admin panel on only difined IP’s SQL Injection Prevention Broken Authentication and Session Prevention of Cross Site Scripting (XSS) Insecure Direct Object Reference Avoid Security Misconfiguration Sensitive Data Exposure Missing Function […]

Web Development Woocommerce Wordpress

How to implement category pagination in woocommerce

Update the below code in yourtheme/woocommerce/archive-product.php file to get pagination on category listing on default product page. ========================= <?php if ( ! defined( ‘ABSPATH’ ) ) { exit; // Exit if accessed directly } get_header( ‘shop’ ); ?> <?php if(is_shop()){ ?> <div class=””> <?php $base_thumb = wc_get_page_id( ‘shop’ ); $thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( $base_thumb ), “full” ); […]