how to install ftp server in ubuntu 20.04

Here we will install and configure vsftpd (Very Secure File Transfer Protocol Daemon) on Ubuntu.

Install vsftpd

Update the package list and dependencies for vsftpd. Then second command download and Install vsftpd.

$ sudo apt update && sudo apt install vsftpd

Check the status of vsftpd

$ sudo service vsftpd status
● vsftpd.service – vsftpd FTP server Loaded: loaded (/lib/systemd/system/vsftpd.service; enabled; vendor preset: enabled) Active: active (running) since Mon 2020-04-27 19:35:30 IST; 13s ago Main PID: 54532 (vsftpd) Tasks: 1 (limit: 1137) Memory: 652.0K CGroup: /system.slice/vsftpd.service └─54532 /usr/sbin/vsftpd /etc/vsftpd.conf Apr 27 19:35:30 ubuntu systemd[1]: Starting vsftpd FTP server… Apr 27 19:35:30 ubuntu systemd[1]: Started vsftpd FTP server.

Configure Firewall

$ sudo ufw allow OpenSSH
$ sudo ufw allow 20/tcp
$ sudo ufw allow 21/tcp
$ sudo ufw allow 40000:50000/tcp
$ sudo ufw allow 990/tcp
$ sudo ufw enable
$ sudo ufw status
Status: active To Action From — —— —- OpenSSH ALLOW Anywhere Apache Full ALLOW Anywhere 3306 ALLOW Anywhere 20/tcp ALLOW Anywhere 21/tcp ALLOW Anywhere 40000:50000/tcp ALLOW Anywhere 990/tcp ALLOW Anywhere OpenSSH (v6) ALLOW Anywhere (v6) Apache Full (v6) ALLOW Anywhere (v6) 3306 (v6) ALLOW Anywhere (v6) 20/tcp (v6) ALLOW Anywhere (v6) 21/tcp (v6) ALLOW Anywhere (v6) 40000:50000/tcp (v6) ALLOW Anywhere (v6) 990/tcp (v6) ALLOW Anywhere (v6)

Create FTP User

$ sudo adduser ftpuser
$ sudo nano /etc/ssh/sshd_config
DenyUsers ftpuser
$ sudo service sshd restart

Directory Permissions

Upload to a Web Server

$ sudo usermod -d /var/www ftpuser
$ sudo chown ftpuser:ftpuser /var/www/html

 Upload to a Home Folder

$ sudo mkdir /home/ftpuser/ftp
$ sudo chown nobody:nogroup /home/ftpuser/ftp
$ sudo chmod a-w /home/ftpuser/ftp
$ sudo mkdir /home/ftpuser/ftp/files
$ sudo chown ftpuser:ftpuser /home/ftpuser/ftp/files

Configure vsftpd

$ sudo mv /etc/vsftpd.conf /etc/vsftpd.conf.bak
$ sudo nano /etc/vsftpd.conf
listen=NO
listen_ipv6=YES
anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
dirmessage_enable=YES
use_localtime=YES
xferlog_enable=YES
connect_from_port_20=YES
chroot_local_user=YES
secure_chroot_dir=/var/run/vsftpd/empty
pam_service_name=vsftpd
force_dot_files=YES
pasv_min_port=40000
pasv_max_port=50000
user_sub_token=$USER
local_root=/home/$USER/ftp

We are done with vsftpd.conf

$ sudo systemctl restart vsftpd

Secure FTP with TLS (Recommended)

$ sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/vsftpd.pem -out /etc/ssl/private/vsftpd.pem
$ sudo nano /etc/vsftpd.conf
ssl_enable=YES
rsa_cert_file=/etc/ssl/private/vsftpd.pem
rsa_private_key_file=/etc/ssl/private/vsftpd.pem
allow_anon_ssl=NO
force_local_data_ssl=YES
force_local_logins_ssl=YES
ssl_tlsv1=YES
ssl_sslv2=NO
ssl_sslv3=NO
require_ssl_reuse=NO
ssl_ciphers=HIGH
$ sudo systemctl restart vsftpd

Testing TLS with FileZilla

How to create static html page from dynamic php page

  • Opportunity to working on live project
  • Learn Advance topic in low cost
  • Get experience certificate
  • Learn Advance topic in limited time period
  • Get job opportunity
  • Topic cover on fast track
<?php
include ("include/conn.php");
error_reporting(E_ALL);
ini_set('display_errors', '1');
$cmdm="select * from satta_cms";
 $resultm=mysqli_query($link,$cmdm); 
 if($rowm=mysqli_fetch_array($resultm)){ 
	 $srno=$rowm['srno']; 
	 $message1=nl2br($rowm['message1']); 
	 $message2=nl2br($rowm['message2']); 
	 $message3=nl2br($rowm['message3']); } 
date_default_timezone_set('Asia/Kolkata');
$cmd1="select * from record"; $result1=mysqli_query($link,$cmd1);
 while($row1=mysqli_fetch_array($result1)){
	  $recno=$row1['recno'];
	 $tablename=$row1['tablename'];
			
 $cmd="select * from $tablename";
$result=mysqli_query($link,$cmd);
while($row=mysqli_fetch_array($result)){
	$recname=$row['recname'];
	$recdate=$row['recdate'];
	$rec=$row['new'];
	$recdispdate=date('d-M-Y',strtotime($recdate)); 
	ob_start();
?>
 
<!DOCTYPE html>
<html lang="en">
<head>
  <?php include('common/head.php'); ?>
 <style>
 h1.text-center {
    background-color: #000000;
    color: white !important;
    padding: 15px;
    text-align: center;
}
 </style>
  </head>
  <body>
<?php include('common/nav.php'); ?>


<div class="container">
<div class="row">
<?php include('common/advertise1.php'); ?>
<div class="col-lg-12"><h1 class="text-center"><?php echo date('d-M-Y',strtotime($recdate)); ?></h1></div>
<div class="live text-center">
    <h1><img src="satta-king.gif" width="70px"></h1>
 <div id="recbadge"> <h4 id="rectime"><?php echo $rec;?></h4><h2 id="recname" class="text-uppercase"><?php echo $recname;?></div>
 </div>

</div>
<hr>

</div>


<div class="container">
<div class="row">
<div class="col-lg-12">
<?php include('common/advertise0.php'); ?>
<?php include('common/message1.php'); ?>
<?php include('common/message2.php'); ?>
<?php include('common/message3.php'); ?>
    <?php include('common/advertise.php'); ?>
<?php //$cmd="select * from record order by rectime"; include('common/record-display.php');
?>
</div>
</div>
</div>
<?php
include('common/script.php');
 ?>

  </body>
</html>
<?php


$MainDir="satta-king-result";
 if(!is_dir($MainDir))
{
	mkdir($MainDir,0777);
}
$fileName=str_ireplace(' ','-',$recname).'-'.$recdispdate;

//
//$fp=fopen($MainDir.$QuestionId.".html","w");
$fp=fopen($MainDir."/".$fileName.".html","w");
$html = ob_get_contents();
fputs($fp,$html);


  } } ?>

How to Generate sitemap.xml file when new post added into WordPress website

Automatically Generate sitemap.xml file when new post added into WordPress website

  1. Login into WordPress admin
  2. Choose Appearance
  3. Choose theme editor
  4. Select your theme
  5. Open functions.php file into editor
  6. Add below code at the end of file
/**
 * start page for webaccess
 * redirect the user to the supported page type by the users webbrowser (js available or not)
 *
 * PHP version 5
 *
 * @category  PHP
 * @package   aditya
 * @author   Aditya Kumar <adityaypi@yahoo.com>
 * @link      http://adityakumarsingh.co.in
************************************
*HTML Sitemap   in WordPress   
************************************/

function sitemap() {
    $sitemap = '';
    $sitemap .= '<h4>Articles </h4>';
    $sitemap .= '<ul class="sitemapul">';
    $posts_array = get_posts();
    foreach ($posts_array as $spost):
        $sitemap .='<div class="blockArticle">
            <h3><a href="' . $spost->guid . '" rel="bookmark" class="linktag">' . $spost->post_title . '</a> </h3>
        </div>';
    endforeach;
    $sitemap .= '</ul>';
    $sitemap .= '<h4>Category</h4>';
    $sitemap .= '<ul class="sitemapul">';
    $args = array(
        'offset' => 0,
        'category' => '',
        'category_name' => '',
        'orderby' => 'date',
        'order' => 'DESC',
        'include' => '',
        'exclude' => '',
        'meta_key' => '',
        'meta_value' => '',
        'post_type' => 'post',
        'post_mime_type' => '',
        'post_parent' => '',
        'author' => '',
        'post_status' => 'publish',
        'suppress_filters' => true
    );
    $cats = get_categories($args);
    foreach ($cats as $cat) :
        $sitemap .= '<li class="pages-list"><a href="' . get_category_link($cat->term_id) . '">' . $cat->cat_name . '</a></li>';
    endforeach;
    $sitemap .= '</ul>';
    $pages_args = array(
        'exclude' => '', /* ID of pages to be excluded, separated by comma */
        'post_type' => 'page',
        'post_status' => 'publish'
    );
    $sitemap .= '<h3>Pages</h3>';
    $sitemap .= '<ul>';
    $pages = get_pages($pages_args);
    foreach ($pages as $page) :
        $sitemap .= '<li class="pages-list"><a href="' . get_page_link($page->ID) . '" rel="bookmark">' . $page->post_title . '</a></li>';
    endforeach;
    $sitemap .= '</ul>';
    $sitemap .= '<h4>Tags</h4>';
    $sitemap .= '<ul class="sitemapul">';
    $tags = get_tags();
    foreach ($tags as $tag) {
        $tag_link = get_tag_link($tag->term_id);
        $sitemap .= "<li class='pages-list'><a href='{$tag_link}' title='{$tag->name} Tag' class='{$tag->slug}'>";
        $sitemap .= $tag->name . '</a></li>';
    }
    return$sitemap;
}
add_shortcode('sitemap', 'sitemap');


/****************************************************
* XML Sitemap in WordPress
*****************************************************/

function xml_sitemap() {
  $postsForSitemap = get_posts(array(
    'numberposts' => -1,
    'orderby' => 'modified',
    'post_type'  => array('post','page'),
    'order'    => 'DESC'
  ));

  $sitemap = '<?xml version="1.0" encoding="UTF-8"?>';
  $sitemap .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';

  foreach($postsForSitemap as $post) {
    setup_postdata($post);

    $postdate = explode(" ", $post->post_modified);

    $sitemap .= '<url>'.
      '<loc>'. get_permalink($post->ID) .'</loc>'.
      '<lastmod>'. $postdate[0] .'</lastmod>'.
      '<changefreq>monthly</changefreq>'.
    '</url>';
  }

  $sitemap .= '</urlset>';

  $fp = fopen(ABSPATH . "sitemap.xml", 'w');
  fwrite($fp, $sitemap);
  fclose($fp);
}

add_action("publish_post", "xml_sitemap");
add_action("publish_page", "xml_sitemap");

how to change limit value 15 25 in opencart of category page

Change default 15 products per page on Category view

Goto Extensions in Extensions in opencart, Choose the extension type Theme

Click on edit button and change below listed value

For views change value from category.php from controller directory

	$data['limits'] = array();

			$limits = array_unique(array($this->config->get('theme_' . $this->config->get('config_theme') . '_product_limit'), 25, 50, 75, 100));

			sort($limits);

change pagination style in opencart

how to change design of pagination in opencart

Change or Add new class in pagination.php file stored in /home/ubuntu/public_html/shopping/system/library

<?php
/**
 * @package		OpenCart
 * @author		Daniel Kerr
 * @copyright	Copyright (c) 2005 - 2017, OpenCart, Ltd. (https://www.opencart.com/)
 * @license		https://opensource.org/licenses/GPL-3.0
 * @link		https://www.opencart.com
*/

/**
* Pagination class
*/
class Pagination {
	public $total = 0;
	public $page = 1;
	public $limit = 20;
	public $num_links = 8;
	public $url = '';
	public $text_first = '|&lt;';
	public $text_last = '&gt;|';
	public $text_next = '&gt;';
	public $text_prev = '&lt;';

	/**
     * 
     *
     * @return	text
     */
	public function render() {
		$total = $this->total;

		if ($this->page < 1) {
			$page = 1;
		} else {
			$page = $this->page;
		}

		if (!(int)$this->limit) {
			$limit = 10;
		} else {
			$limit = $this->limit;
		}

		$num_links = $this->num_links;
		$num_pages = ceil($total / $limit);

		$this->url = str_replace('%7Bpage%7D', '{page}', $this->url);

		$output = '<ul class="pagination">';

		if ($page > 1) {
			$output .= '<li class="page-item"><a class="page-link" href="' . str_replace(array('&amp;page={page}', '?page={page}', '&page={page}'), '', $this->url) . '">' . $this->text_first . '</a></li>';
			
			if ($page - 1 === 1) {
				$output .= '<li class="page-item"><a class="page-link" href="' . str_replace(array('&amp;page={page}', '?page={page}', '&page={page}'), '', $this->url) . '">' . $this->text_prev . '</a></li>';
			} else {
				$output .= '<li class="page-item"><a class="page-link" href="' . str_replace('{page}', $page - 1, $this->url) . '">' . $this->text_prev . '</a></li>';
			}
		}

		if ($num_pages > 1) {
			if ($num_pages <= $num_links) {
				$start = 1;
				$end = $num_pages;
			} else {
				$start = $page - floor($num_links / 2);
				$end = $page + floor($num_links / 2);

				if ($start < 1) {
					$end += abs($start) + 1;
					$start = 1;
				}

				if ($end > $num_pages) {
					$start -= ($end - $num_pages);
					$end = $num_pages;
				}
			}

			for ($i = $start; $i <= $end; $i++) {
				if ($page == $i) {
					$output .= '<li class="page-item active"><a href="#" class="page-link">' . $i . '</a></li>';
				} else {
					if ($i === 1) {
						$output .= '<li class="page-item" ><a class="page-link" href="' . str_replace(array('&amp;page={page}', '?page={page}', '&page={page}'), '', $this->url) . '">' . $i . '</a></li>';
					} else {
						$output .= '<li class="page-item"><a class="page-link" href="' . str_replace('{page}', $i, $this->url) . '">' . $i . '</a></li>';
					}
				}
			}
		}

		if ($page < $num_pages) {
			$output .= '<li class="page-item"><a class="page-link" href="' . str_replace('{page}', $page + 1, $this->url) . '">' . $this->text_next . '</a></li>';
			$output .= '<li class="page-item"><a class="page-link" href="' . str_replace('{page}', $num_pages, $this->url) . '">' . $this->text_last . '</a></li>';
		}

		$output .= '</ul>';

		if ($num_pages > 1) {
			return $output;
		} else {
			return '';
		}
	}
}

Developer Setup: High Availability & Multiconnect

Developer Setup: High Availability & Multiconnect

This document shows you how to set up a High Availability cluster on a developer machine. It also provides guidance on how to enable Multiconnect on top of that as well as the changes required for a highly available Multiconnect cluster. For a production setup, follow the relevant instructions listed in Production Setups.

Before you start any of these set ups, check our list of requirements.

To set up a High Availability cluster follow these steps:

  1. Create a biz Directory for the setup scripts
  2. Get the WhatsApp Business API Client configuration files
  3. Set the WA_API_VERSION environment variable
  4. Start the WhatsApp Business API Client with High Availability
  5. Verify containers are running
  6. Perform a health check
  7. Register the WhatsApp Business API Client
  8. Perform a second health check

To set up a Multiconnect cluster follow these steps:

  1. Set up two shards
  2. Perform a health check
  3. Start a third coreapp to maintain High Availability
  4. Perform a second health check

Developer Setup: Single Instance

Developer Setup: Single Instance

This document shows you how to set up a single instance of the WhatsApp Business API client on a developer machine for testing purposes. For a production setup, follow the relevant instructions listed in Production Setups.

To initially set up a single instance, check our list of requirements, and follow these steps:

  1. Create a biz directory for the setup scripts
  2. Get the WhatsApp Business API Client configuration files
  3. Set the WA_API_VERSION environment variable
  4. Start the WhatsApp Business API Client
  5. Verify containers are running
  6. Perform a health check
  7. Register the WhatsApp Business API Client
  8. Perform a second health check

WhatsApp Business API Installation for Production setup

Production Setups

Demonstrates how to set up a WhatsApp Business API client in a production environment and covers best practices. Please use this documentation as reference and make necessary changes according to your business needs.

The WhatsApp Business API client can be installed as a developer setup for testing using either Docker Compose or Minikube. You can also use Amazon Web Services (AWS) on production systems. You can migrate from a developer setup to a production setup when ready to send messages to customers.

Make sure you have approval for your business’s phone number and have a certificate before attempting installation.

WhatsApp Business API Installation for Developer setup

Developer Setups

Demonstrates how to set up a WhatsApp Business API client on your developer machine with the purpose of getting familiar with the setup process. This should not be used for a production environment. It is highly recommended that you try out one of the developer setup processes below before attempting a production setup.

The WhatsApp Business API client can be installed as a developer setup for testing using either Docker Compose or Minikube. You can also use Amazon Web Services (AWS) on production systems. You can migrate from a developer setup to a production setup when ready to send messages to customers.

Make sure you have approval for your business’s phone number and have a certificate before attempting installation.