Saturday, May 14, 2022

Copy files and folders from current directory to another in CentOS

 Using rsync:

First install rsync (if not installed) : yum install rsync

rsync -a /source_directory /destination_directory


Friday, May 6, 2022

Tuesday, April 19, 2022

Decrease product price by 10% using SQL command in Woocommernce from Phpmyadmin

 Query-1:

UPDATE

   wp_wc_product_meta_lookup

SET

    min_price =(min_price - min_price * .13)

WHERE 1;

Query-2;

 UPDATE

   wp_wc_product_meta_lookup

SET

    max_price =(max_price - max_price * .13)

WHERE 1;

Saturday, April 16, 2022

Mark all products as draft Woocommerce using SQL query

 UPDATE `wp_posts` SET `post_status` = 'draft' WHERE `post_type` = 'product' AND `post_status` = 'publish'

Saturday, April 9, 2022

Print Product Group in WHMCS Invoice Item Description

PRODUCTNAME - Domain (Start Date - End Date)

e.g. Standard - abc.com (04/10/2010 - 03/10/2012)

Need to change it to the following:

PRODUCTNAME - Domain (Start Date - End Date)

PRODUCT DESCRIPTION

e.g. Shared Hosting - Standard - abc.com (04/10/2010 - 03/10/2012)

Method -1: 

Place the following script at the top of your /templates/<templatename>/viewinvoice.tpl:


{php}

foreach ($this->_tpl_vars['invoiceitems'] as $key => $value)

{

$result = mysql_query("SELECT (SELECT name FROM tblproductgroups WHERE gid = tblproducts.id) AS groupname FROM tblproducts WHERE name = '".sanitize(substr($value['description'], 0, strpos($value['description']." - ", " - ")))."'");

$data = mysql_fetch_array($result);

if(mysql_num_rows($result) == 1)

$this->_tpl_vars['invoiceitems'][$key]['description'] = $data['groupname']." - ".$value['description'];

}

{/php}

Now place the following script at the top of your /templates/<templatename>/invoicepdf.tpl:
foreach ($invoiceitems as $key => $value)
{
   $result    = mysql_query("SELECT (SELECT name FROM tblproductgroups WHERE gid = tblproducts.id) AS groupname FROM tblproducts WHERE name = '".sanitize(substr($value['description'], 0, strpos($value['description']." - ", " - ")))."'");
   $data     = mysql_fetch_array($result);

   if(mysql_num_rows($result) == 1)
       $invoiceitems[$key]['description'] = $data['groupname']." - ".$value['description'];
}

Method -2: 
Create a new .php file called invoices_productgroup.php in your action hooks directory (/includes/hooks/), and place the following code in it:

<?php
add_hook("InvoiceCreationPreEmail", 1, "invoice_productgroup");

function invoice_productgroup($vars)
{
   $result = select_query("tblinvoiceitems","id,description",array("invoiceid" => $vars['invoiceid']));

   while($data = mysql_fetch_array ($result))
   {
       $result2 = full_query("SELECT (SELECT name FROM tblproductgroups WHERE gid = tblproducts.id) AS groupname FROM tblproducts WHERE name = '".sanitize(substr($data['description'], 0, strpos($data['description']." - ", " - ")))."'");
       $data2   = mysql_fetch_array($result2);

       if(mysql_num_rows($result2) == 1)
           update_query("tblinvoiceitems", array("description" => $data2['groupname']." - ".$data['description']), array("id" => $data['id']));
   }
}
?>
This will add the product group (if applicable) in front of the description from a new invoice.

Tuesday, March 15, 2022

How to restore a Large cPanel Backup file from Google Drive

 wget --load-cookies /tmp/cookies.txt "https://docs.google.com/uc?export=download&confirm=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate 'https://docs.google.com/uc?export=download&id=FILEID' -O- | sed -rn 's/.confirm=([0-9A-Za-z_]+)./\1\n/p')&id=FILEID" -O FILENAME && rm -rf /tmp/cookies.txt





Download Large File from Google Drive to Linux Directory using command

First install yum if not installed before : sudo yum install wget

Before the file to be downloaded it is needed to be share publicly.

Steps:

  1. Select a file that is need to be downloaded and do right click.
  2. Click Share. A dialog box will appear.
  3. Click Advance in the right bottom corner.
  4. Click on the Change.. under who has access.
  5. Make it On- Public on the web.
  6. Click Save button.
  7. Copy the link for sharing…like…https://drive.google.com/file/d/1UibyVC_C2hoT_XEw15gPEwPW4yFyJFeOEA/view?usp=sharing
  8. Extrac FILEID part like….from above….1UibyVC_C2hoT_XEw15gPEwPW4yFyJFeOEA



For small file run following command on your terminal:

wget --no-check-certificate 'https://docs.google.com/uc?export=download&id=FILEID' -O FILENAME

In the above command change the FILEID by above id extracted and rename FILENAME for your own simple use.

Large files

For large file run the following command with necessary changes in FILEID and FILENAME:

wget --load-cookies /tmp/cookies.txt "https://docs.google.com/uc?export=download&confirm=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate 'https://docs.google.com/uc?export=download&id=FILEID' -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')&id=FILEID" -O FILENAME && rm -rf /tmp/cookies.txt

Office 2021 Activation using command

  @echo off title Activate Microsoft Office 2021 (ALL versions) for FREE - office.com&cls&echo =====================================...