Categories
Linux

Proxmox

And the Japanese Car.

Proxmox Virtual Environment (PVE) is an open source server virtualization environment based on Debian. It allows VMs and LXCs, software-defined storage and networking, and high-availability clustering.

To backup the configuration of the server itslef use the command:

tar -zcvf /var/lib/vz/dump/srv_etc_root-$(date +"%Y_%m_%d-%H_%M_%S").tar.gz /etc /root

To disable option of removal/restoration of LXC, enable the Protection option. To allow users to make backups grant them the permission PVEDatastoreUser on the storage path and PVEVMUser on the VM path.

To limit the number of the saved backups created automatically, use the Max Backups option (Datacenter => Storage).

To use NAT within PVE create a Linux bridge with the LAN IP.

To config new storage go into Server => Storage and Datacenter => Storage.

As you probably have noticed- the word Proxmox has no meaning, it was chosen following a short catchy domain name that was available, in order to be on the safe side and not end up like the Japanese automobile manufacturer Nissan, which still struggling to achieve the nissan.com and nissan.net addresses.

Categories
Linux

ISPConfig

And the Pied Piper.

ISPConfig is an open source hosting control panel for Linux (preferably Debian). It allows multiple server management from one control panel includes web server management, mail server management, and DNS server management.

For strict privacy policy websites disable the Webstatistics program.

To create website for a client use the login as client option.

To remove a FAQ question use the phpMyAdmin panel.

To change the code configuration use the conf-custom folder.

To activate SSL for a website, first enable the SSL and than the Let’s Encrypt SSL, you may use the Rewrite HTTP to HTTPS and SEO Redirect (domain.tld => www.domain.tld, after creating automatic www subdomain) options. To clean old SSL certificates use the command (newer certificates will have higher suffix number):

certbot delete

To use ISPConfig behind NAT, enable the Skip Lets Encrypt Check option (System => Server Config => Web => SSL Settings), use the WAN IP in DNS Settings and Website Settings, and the LAN IP in Server Config and Server IP Addresses.

For better recovering process enable rescue option (Server Config tab).

As you probably have noticed- the oldest written accounts of the Pied Piper of Hamelin was created in Lüneburg, the same town the ISPConfig software is developed.

Categories
WordPress

WooCommerce

And Back to the Future.

WooCommerce is an open source E-commerce software which comes as a plugin for WordPress, it is the most popular way of creating E-commerce websites. From many clearing options, order management, shipping types to inventory settings, the plugin covers all the requirements that may arise in creating E-commerce websites.

To edit the mobile menu button text in Storefront theme:

add_filter( 'storefront_menu_toggle_text', 'condless_storefront_menu_toggle_text' );
function condless_storefront_menu_toggle_text( $text ) {
	$text = __( 'My menu' );
	return $text;
}

To edit the Update cart button text in mobile:

add_filter( 'gettext', 'condless_change_update_cart_text', 20, 3 );
function condless_change_update_cart_text( $translated, $text, $domain ) {
if ( wp_is_mobile() && is_cart() && $translated == 'Update cart' ) {
$translated = 'Text for mobile';
}
return $translated;
}

Assign Free Shipping to a single product: Create a Shipping Class “Free Shipping”, assign the new Shipping Class to your Product and set up a 0 Flat Rate based on Shipping Class.

Auto change the order status from “On hold” to “Processing”, for example, to allow a customer who pay in bank transfer (which take some time) to view the digital product download link on the “Order Received” page (must refresh the page):

add_action( 'woocommerce_thankyou', 'condless_woocommerce_auto_processing_orders' );
function condless_woocommerce_auto_processing_orders( $order_id ) {
    if ( ! $order_id )
        return;
    $order = wc_get_order( $order_id );
    if( $order->has_status( 'on-hold' ) ) {
        $order->update_status( 'processing' );
    }
}

Reordering checkout fields:

add_filter( 'woocommerce_checkout_fields', 'condless_reordering_checkout_fields' );
function condless_reordering_checkout_fields( $fields ) {
    $billing_order = array(
        'billing_first_name',
        'billing_last_name',
        'billing_email',
        'billing_phone',
        'billing_company',
        'billing_address_1',
        'billing_address_2',
        'billing_postcode',
        'billing_city',
        'billing_state',
        'billing_country'
    );
    $count = 0;
    $priority = 10;
    foreach($billing_order as $field_name){
        $count++;
        $fields['billing'][$field_name]['priority'] = $count * $priority;
    }
    $fields['billing']['billing_email']['class'] = array('form-row-first');
    $fields['billing']['billing_phone']['class'] = array('form-row-last');
    $fields['billing']['billing_postcode']['class'] = array('form-row-first');
    $fields['billing']['billing_city']['class'] = array('form-row-last');
    return $fields;
}

Hiding some variations of product:

add_filter( 'woocommerce_dropdown_variation_attribute_options_args', 'condless_hide_dropdown_variation_args', );
function condless_hide_dropdown_variation_args( $args ) {
    $args['show_option_none'] = false;
    foreach( $args['options'] as $key => $option ){
        if( $option === "2,5 kg" ) {
            unset($args['options'][$key]);
        }
    }
    return $args;
}

Add fields validation in the checkout page. for example, to allow ASCII chars only (as well as disallow non-English letters):

add_action( 'woocommerce_after_checkout_validation', 'condless_ascii_validate_checkout', 10, 2 );
function condless_ascii_validate_checkout( $fields, $errors ){
if ( preg_match( '/[^[:ascii:]]/', $fields[ 'billing_first_name' ] ) )
$errors->add( 'validation', '<strong>Billing First name</strong> contains non-English letters.' );
if ( preg_match( '/[^[:ascii:]]/', $fields[ 'billing_last_name' ] ) )
$errors->add( 'validation', '<strong>Billing Last name</strong> contains non-English letters.' );
if ( preg_match( '/[^[:ascii:]]/', $fields[ 'billing_company' ] ) )
$errors->add( 'validation', '<strong>Billing Company</strong> contains non-English letters.' );
if ( preg_match( '/[^[:ascii:]]/', $fields[ 'billing_address_1' ] ) )
$errors->add( 'validation', '<strong>Billing Address</strong> contains non-English letters.' );
if ( preg_match( '/[^[:ascii:]]/', $fields[ 'billing_address_2' ] ) )
$errors->add( 'validation', '<strong>Billing Address details</strong> contains non-English letters.' );
if ( preg_match( '/[^[:ascii:]]/', $fields[ 'billing_city' ] ) )
$errors->add( 'validation', '<strong>Billing City</strong> contains non-English letters.' );
if ( preg_match( '/[^[:ascii:]]/', $fields[ 'shipping_first_name' ] ) )
$errors->add( 'validation', '<strong>Shipping First name</strong> contains non-English letters.' );
if ( preg_match( '/[^[:ascii:]]/', $fields[ 'shipping_last_name' ] ) )
$errors->add( 'validation', '<strong>Shipping Last name</strong> contains non-English letters.' );
if ( preg_match( '/[^[:ascii:]]/', $fields[ 'shipping_company' ] ) )
$errors->add( 'validation', '<strong>Shipping Company</strong> contains non-English letters.' );
if ( preg_match( '/[^[:ascii:]]/', $fields[ 'shipping_address_1' ] ) )
$errors->add( 'validation', '<strong>Shipping Address</strong> contains non-English letters.' );
if ( preg_match( '/[^[:ascii:]]/', $fields[ 'shipping_address_2' ] ) )
$errors->add( 'validation', '<strong>Shipping Address details</strong> contains non-English letters.' );
if ( preg_match( '/[^[:ascii:]]/', $fields[ 'shipping_city' ] ) )
$errors->add( 'validation', '<strong>Shipping City</strong> contains non-English letters.' );
}

Manipulate the product price display, for example, to display the discount on sale products:

add_filter( 'woocommerce_get_price_html', 'condless_simple_product_price_format', 10, 2 );
function condless_simple_product_price_format( $price, $product ) {
   if ( $product->is_on_sale() && $product->is_type('simple') ) {
      $price = sprintf( __( '<div class="was-now-save"><div class="was">WAS %1$s</div><div class="now">NOW %2$s</div><div class="save">SAVE %3$s</div></div>', 'woocommerce' ), wc_price ( $product->get_regular_price() ), wc_price( $product->get_sale_price() ), wc_price( $product->get_regular_price() - $product->get_sale_price() )  );      
   }
   return $price;
}

Display the TAX/VAT amount and the product price with/without it:

add_filter( 'woocommerce_get_price_suffix', 'condless_price_vat_suffix', 10, 4 );
function condless_price_vat_suffix( $html, $instance, $price, $qty ) {
if ( is_product() ) {
        $html .=  ' + ' . wc_price(wc_get_price_including_tax($instance) - wc_get_price_excluding_tax($instance)) . ' VAT =  ' . wc_price(wc_get_price_including_tax($instance)); }
return $html;
}

Remove the product added/removed messages:

add_filter( 'wc_add_to_cart_message_html', '__return_null' );
add_filter( 'woocommerce_cart_item_removed_notice_type', '__return_null' );

Display product only in built-in WordPress search:

function condless_search_wc( $query ) {
if ( $query->is_search ) {
$query->set( 'post_type', 'product' );
}
return $query;
}
add_filter('pre_get_posts','condless_search_wc');

Booking and Appointments.

Wholesale.

Products personalization.

Recover abandoned carts.

Free shipping settings.

Apply coupons automatically.

Shipment tracking.

Payment methods for payment apps which don’t have API.

Fees and discounts by payment method.

Payment method by product.

Add payment option of “request for quote“.

Advanced pricing.

Products filter.

Crowdfunding.

Bulk edit for variable products.

Multi vendor.

Selling courses. If the video files are not on the site create a post for each course with the embedded video, create a virtual product for each video course with a link to the video file (if the video files on the site) / post (if the video is embedded), define in each video file (if the files The video on the site) / post (if the video is embedded) that only those who purchased the compatible product on the WooCommerce may view it.

As you probably have noticed- Jigowatt ltd, the developers of Jigoshop on which WooCommerce code is based, was named after the pronunciation mistake of the word Gigawatt in the movie Back to the Future.

Categories
WordPress

WordPress

And the Jazz Artists.

WordPress is an open source content management system. This system is the most popular CMS due to the great flexibility it provides and the option to manage a site even without extensive programming knowledge.

A significant option in WordPress is to create a Multisite network, ie multiple sites based on the same code, making it easier to manage and maintain them.

To improve system security at the WordPress level: Update frequently, install few plugins as possible, remove unused templates, install SSL certificate, and set up Two-Factor Authentication.

To improve system security at the server level: Update frequently, report any suspicious activity in your account to your hosting provider, verify that there is a firewall, and config the Intrusion Prevention System (enable mod_remoteip if used with reverse proxy), hide software versions, and disable the XML-RPC function and the directory browsing option by adding the commands to the .htacess file:

<Files "xmlrpc.php">
Order Allow,Deny
Deny from all
</Files>

Options -Indexes

To detect malwares, look for suspicious code lines and files in the WordPress folder and database (Japanese Keyword Hack guide, Mobile Spam Popup guide) and check the recently modified files:

find ./ -type f -mtime -15

To run WordPress website with SSL in reverse proxy, it is required to edit the commands in the wp-config.php file to appear at this order:

$_SERVER['HTTPS'] = 'on';
require_once(ABSPATH . 'wp-settings.php');

To improve the SEO for the WordPress: use responsive template, config permalink by post name, set the URL slugs in English, and speed up the WordPress.

To optimize the WordPress Speed: Turn off Trackbacks & Pingbacks, use few plugins as possible, delete unused media, decrease media size before upload, run frequently a Database Cleaner, and limit autosaves and revisions by adding the commands to the wp-config.php file:

define('AUTOSAVE_INTERVAL', 300 );
define('WP_POST_REVISIONS', false );

To control the file storage and upload size limit, the available space on the server, the size of the hosting plan, the hosting panel settings, the WordPress site and multisite settings, and the files: .htaccess, php.ini, .user.ini, wp-config.php, functions.php, must be taken into account.

To change theme files in WordPress, create child theme. To change WordPress functionality, use built-in hooks (which are seperated to actions and filters), add the hooks into the functions.php file in the child theme. To change WordPress styles, use the Dashboard => Appearance => Customize => Additional CSS, and in order the change the styles of the Dashboard itself:

add_action( 'admin_head', 'condless_admin_custom_css' );
function condless_admin_custom_css() { echo '<style>your_custom_css</style>'; }

To customize the Twenty Twenty theme header, make use of the CSS:

.cover-header-inner-wrapper { min-height: 60vh !importent; }
.home .entry-header { display: none; }

To limit the length of the code block, make use of the CSS:

pre.wp-block-code { max-height: 30vh; }

Enable use of session variables:

add_action( 'init', 'condless_activate_session', 1 );
function condless_activate_session() {
    if( ! session_id() ) {
        session_start();
    }
}

E-commerce.

Tags for effective social media sharing.

Contact forms. For custom design, make use of the CSS:

.wpcf7-form {
	background: #dcc8a5;
	padding: 10px 20px;
	border: 2px solid #f6efdf;
	border-radius: 7px;
	max-width: 300px;
}
 
.wpcf7-form p {
	color: #4f2a0f;
	margin-bottom: 5px;
}
 
.wpcf7-form input,
.wpcf7-form textarea {
	background: #f6efdf;
	padding: 5px 7px;
	margin: 4px 0 8px 0;
	border: 3px solid #ccb58c;
	color: #4f4f4f;
	border-radius: 7px;
}
 
.wpcf7-form .wpcf7-submit {
	background: #4f2a0f;
	padding: 5px 15px;
	color: #fff;
	min-width: 100px;
}
 
.wpcf7-form input[type="submit"]:hover {
 	background: #000;
}

Multi language.

Forums with moderation options.

Social network with private area.

Ads board.

Database search and replace.

Slider. To create full width video, make use of the CSS:

.wp-video, video.wp-video-shortcode, .mejs-container, .mejs-overlay.load {
	width: 100% !important;
	height: 100% !important;
}
.mejs-container {
	padding-top: 56.25%;
}
.wp-video, video.wp-video-shortcode {
	max-width: 100% !important;
}
video.wp-video-shortcode {
	position: relative;
}
.mejs-mediaelement {
	position: absolute;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
}
.mejs-controls {
	display: none;
}
.mejs-overlay-play {
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	width: auto !important;
	height: auto !important;
}

Image hover effects.

As you probably have noticed- Pastorius, Carter, Valdés, and all other WordPress Version names, are names of popular jazz artists, inspired by WordPress core developers, who share a love of jazz music.

Categories
Security

Two-Factor Authentication

And Kim Dotcom.

TOTP-based Two-Factor Authentication makes it difficult for unauthorized access to your account, becuase that besides your password, it will required to obtain the code generated in your app in real time and log in immediately (the code changes every short time) or to locate your secret.

In this verification process, a one-time code is created using an algorithm that uses your secret code and the current time, so that each code is set to change over time.

Two-Factor Authentication is part of the information security system required in every business. Most of the services provided by Condless enable Two-Factor Authentication.

To config TOTP as a second factor to WordPress:

  • Install and activate the plugin (built-in in Condless hosting)
  • Scan the QR code through your OTP app
  • Click Update profile

To config TOTP as a second factor to the VPS Control Panel:

  • Press the TFA button in the user list
  • Randomize the secret key (optional)
  • Set the Issuer Name (optional)
  • Scan the QR code using your OTP app
  • Enter your password
  • Enter the TOTP Value that your app generated
  • Press Apply

To config TOTP as a second factor to the VPS.

To config TOTP as a second factor to the webmail.

To config TOTP as a second factor to the phpMyAdmin.

As you probably have noticed- Kim Dotcom threatened to sue all the major web services offering this kind of authentication, bases on its patent from 2000. Currently the European Patent Office revoked his patent in light of an earlier 1998 US patent held by AT&T.

Categories
Linux

Debian

And Toy Story.

Debian is a very popular Linux distribution for servers and is considered to be the most stable. Its social contract highlights values of transparency, community contribution, and adherence to the principles of Free software.

Debian “buster” 10 released, and Condless of course lets you experiment the new release with a ready-to-use VPS, so what are you waiting for?

To improve the successfull mail delivery rate from the server set up for the domain names: SPF, DKIM, DMARC, and make sure the server hostname appear at the A record, rDNS, server control panel, MTA (includes mailname), and content filter configuration values.

To config relay host in Postfix, use the commands:

apt-get install libsasl2-modules
postconf -e 'relayhost = $relay_host_ip'
postconf -e 'smtp_sasl_auth_enable = yes'
postconf -e 'smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd'
postconf -e 'smtp_sasl_security_options ='
echo "$relay_host_ip   yourEmail:yourPassword" > /etc/postfix/sasl_passwd
chown root:root /etc/postfix/sasl_passwd
chmod 600 /etc/postfix/sasl_passwd
postmap /etc/postfix/sasl_passwd
/etc/init.d/postfix restart

To control the SSH authentication methods, the sshd_config file should be edited. In order to define which logs will be saved and where, the rsyslog.conf file should be edited according to the instructions.

To config the intrusion prevention system Fail2ban, create a jail.local file and use the commands, for example to enable the ssh protection:

[sshd]
enabled = true

And to unban IP:

fail2ban-client set sshd unbanip $IP

To config NAT and port forwarding with iptables use:

post-up echo 1 > /proc/sys/net/ipv4/ip_forward
post-up iptables -t nat -A POSTROUTING -s '$LAN-IP-SUBNET' -o eno1 -j MASQUERADE
post-down iptables -t nat -D POSTROUTING -s '$LAN-IP-SUBNET' -o eno1 -j MASQUERADE
post-up iptables -t nat -A PREROUTING -i eno1 -p tcp -m multiport --dports $PORTS -j DNAT --to $DESTINATION-LAN-IP
post-down iptables -t nat -D PREROUTING -i eno1 -p tcp -m multiport --dports $PORTS -j DNAT --to $DESTINATION-LAN-IP

To config a reverse proxy in Apache server, which keeps the original reciever address and don’t pass the SSL certificates requests use those directives:

ProxyPreserveHost On
ProxyPass /.well-known/acme-challenge !
ProxyPass /$PATH http://$LAN-IP:$PORT/$PATH
ProxyPassReverse /$PATH http://$LAN-IP:$PORT/$PATH
ProxyPass / http://$LAN-IP:$PORT/
ProxyPassReverse / http://$LAN-IP:$PORT/ 

As you probably have noticed- Buster, Strech, Jessie, and all other Debian distribution code names, are names of characters from the Toy Story movie, inspired by Bruce Ferns who worked at Pixar besides his tenure as the Debian project leader.