How to setup a Cron job ?

Scheduling a real cron job

Log into your cPanel.

Navigate to the Advanced section.

Click Cron jobs.

The Cron Email section will send an email out after the Cron has finished.

Here is a simple cron job:

example-cron-job


There are two main parts:

  1. The first part is “0,30 * * * *”. This is where we schedule the timer.
  2. The rest of the line is the command as it would run from the command line.

The command itself in this example has three parts:

  1. “php”. PHP scripts usually are not executable by themselves. Therefore we need to run it through the PHP parser.
  2. “/home directory/public_html/folder-name/admin/cron.php”. This is just the path to the script.
  3. “> /dev/null 2>&1”. This part is handling the output of the script. More on bellow.

If you do not handle the output of the cron script, it will send them as e-mails to your user account on the server.

If you put “> /dev/null 2>&1” at the end of the cron job command (or any command), the output will be discarded.

This is the first part of the cron job string, as mentioned above. It determines how often and when the cron job is going to run.

It consists of five parts:

  1. minute
  2. hour
  3. day of month
  4. month
  5. day of week

Here is an screenshot for better understanding:

cron-job-timer

Common Settings include every minute to once a year.

Enter in the desired Command and click Add New Cron Job button.

Command lines. Examples only! Bold sections must be changed.

Note:You may need to adjust /home/ to /home#/ depending on the home directory your account resides on. To view the home directory for your account simply view the stats column on the main cPanel page of your account and look for the home directory.

PHP

Command to run a PHP5 cron job:

php /home/username/public_html/cron.php

Optional flags are sometimes required for a PHP cron job:

php -q /home/username/public_html/cron.php

Command to use a specific php.ini file:

php -c /home/username/public_html/php.ini /home/username/public_html/myscript.php

Command to GET a remote file:

/usr/bin/GET http://www.example.com/file.php

Perl

Command to run a CGI cron job:

perl /home/username/public_html/cgi-bin/file.pl

SSH

Command to run a shell script cron job:

/bin/sh /home/username/public_html/file.sh

MySQL

Note: It is good practice to not type your password out in the follow commands but to simply use the -p flag alone and have the system prompt you for the password. This is way your password stays secure and is never on the server as plain text.

Command to import a database:

mysql -u mysql_user -ppassword database_name < backup.sql

Command to export a database:

mysqldump -u mysql_user -ppassword database_name > backup.sql

Custom Installations without Easy Apache 3 (VPS/Dedicated)

PHP

Command to run for a PHP5 cron job:

/usr/local/php5/bin/php5 /home/username/public_html/cron.php

Command to run for a PHP4 cron job:

/usr/bin/php /home/username/public_html/cron.php

Cron job limitations and Solution is here:

you can use ini_set to bump the memory_limit and max_execution_time (ususally infinite in command though) – that will be help you to do but I think EasyCron will be good for you so you can choose the service from here to overcome all complexity.
Enjoy your business with EasyCron without hassle 🙂

How can I make custom column with bootstrap v3 ?

It’s a easy way to make if you follow the bootstrap structure and use this code.

Here is the example of 5 columns.

HTML :

<div class="row">
    <div class="col-md-5ths col-xs-6">
        <span>This is column 1</span>
    </div>
    <div class="col-md-5ths col-xs-6">
        <span>This is column 2</span>
    </div>
    <div class="col-md-5ths col-xs-6">
        <span>This is column 3</span>
    </div>
    <div class="col-md-5ths col-xs-6">
        <span>This is column 4</span>
    </div>
    <div class="col-md-5ths col-xs-6">
        <span>This is column 5</span>
    </div>
</div>

CSS:

.col-xs-5ths,
.col-sm-5ths,
.col-md-5ths,
.col-lg-5ths {
    position: relative;
    min-height: 1px;
    padding-right: 10px;
    padding-left: 10px;
}

.col-xs-5ths {
    width: 20%;
    float: left;
}
@media (min-width: 768px) {
.col-sm-5ths {
        width: 20%;
        float: left;
    }
}
@media (min-width: 992px) {
    .col-md-5ths {
        width: 20%;
        float: left;
    }
}
@media (min-width: 1200px) {
    .col-lg-5ths {
        width: 20%;
        float: left;
    }
}

Tracking from submissions with Contact Form 7

When someone makes a submission via your contact form, Google Analytics will track it as an event with Contact Form as the Category, and Submit as the Action.

1st:
You need to add google analytic code on your site.
2nd:
Go to the option of contact from 7
contact-tab-form-7

3rd:
You need to add the code on your “Additional Settings” area.
additional-setting-contact-from-7

Ref Site: http://contactform7.com/tracking-form-submissions-with-google-analytics/

That all
🙂

How to Share a Social Button to your Website Pages

Please change the URL as your site link.

<!-- Facebook -->
<a href="http://www.facebook.com/sharer.php?u=https://www.deshisoft.com" target="_blank"><img src="https://www.deshisoft.com/images/somacro/facebook.png" alt="Facebook" /></a>

<!-- Twitter -->
<a href="http://twitter.com/share?url=https://www.deshisoft.com&text=Simple Share Buttons" target="_blank"><img src="https://www.deshisoft.com/images/somacro/twitter.png" alt="Twitter" /></a>

<!-- Google+ -->
<a href="https://plus.google.com/share?url=https://www.deshisoft.com" target="_blank"><img src="https://www.deshisoft.com/images/somacro/google.png" alt="Google" /></a>

<!-- Digg -->
<a href="http://www.digg.com/submit?url=https://www.deshisoft.com" target="_blank"><img src="https://www.deshisoft.com/images/somacro/diggit.png" alt="Digg" /></a>

<!-- Reddit -->
<a href="http://reddit.com/submit?url=https://www.deshisoft.com&title=Simple Share Buttons" target="_blank"><img src="https://www.deshisoft.com/images/somacro/reddit.png" alt="Reddit" /></a>

<!-- LinkedIn -->
<a href="http://www.linkedin.com/shareArticle?mini=true&url=https://www.deshisoft.com" target="_blank"><img src="https://www.deshisoft.com/images/somacro/linkedin.png" alt="LinkedIn" /></a>

<!-- Pinterest -->
<a href="javascript:void((function()%7Bvar%20e=document.createElement('script');e.setAttribute('type','text/javascript');e.setAttribute('charset','UTF-8');e.setAttribute('src','http://assets.pinterest.com/js/pinmarklet.js?r='+Math.random()*99999999);document.body.appendChild(e)%7D)());"><img src="https://www.deshisoft.com/images/somacro/pinterest.png" alt="Pinterest" /></a>

<!-- StumbleUpon-->
<a href="https://www.deshisoft.com/submit?url=https://www.deshisoft.com&title=Simple Share Buttons" target="_blank"><img src="https://www.deshisoft.com/images/somacro/stumbleupon.png" alt="StumbleUpon" /></a>

<!-- Email -->
<a href="mailto:?Subject=Simple Share Buttons&Body=I%20saw%20this%20and%20thought%20of%20you!%20 https://www.deshisoft.com"><img src="https://www.deshisoft.com/images/somacro/email.png" alt="Email" /></a>

If you want to pop-up window after click the share button (You can use it for dynamic site likes wordpress for different page link):

<a class="tv-sharer-facebook facebook" href="#" 
              onclick="
                window.open(
                  'https://www.facebook.com/sharer/sharer.php?u='+encodeURIComponent(location.href), 
                  'facebook-share-dialog', 
                  'width=626,height=436'); 
                return false;">
              Share on Facebook
</a>
<a class="tv-sharer-twitter twitter" href="#" 
              onclick="
                window.open(
                  'http://twitter.com/share?url='+encodeURIComponent(location.href), 
                  'twitter-share-dialog', 
                  'width=626,height=436'); 
                return false;">
              Tweet it
</a>
<a class="tv-sharer-email email" href="#" 
              onclick="
                window.open(
                  'mailto:?subject=check+out+this+video+on+deshisoft.com%21&body='+encodeURIComponent(location.href), 
                  'email-share-dialog', 
                  'width=626,height=436'); 
                return false;">
              Tweet it
</a>

Malware:SPAM:SEO – (MODx Evolution: removing spam links)

MODx Evolution based website has been detected hacked. Every page of his website showing “infected” with invisible links to viagra webshops. The code of those links was as follows:

<div style="position:absolute;left:-2311px;top:-2794px;"><a href="LINK">... viagra ...</a></div>

After quick investigation I figured out the malicious code (which generated those links) had been planted into the MySQL table “modx_site_plugins“.  In our case it was inside “Quick ManagerManager” plugin code:

Basically, look for: @eval(@gzuncompress(@str_rot13(@base64_decode(

After removing the code I’ve also replaced the entire assets/cache/ folder with one from the MODx distributive.

Malware checking link: http://sitecheck.sucuri.net

How can I add a new module position for opencart?

Create a file name content_footer.php and past the code from here

class ControllerCommonContentFooter extends Controller {
    public function index() {
        $this->load->model('design/layout');
        $this->load->model('catalog/category');
        $this->load->model('catalog/product');
        $this->load->model('catalog/information');

        if (isset($this->request->get['route'])) {
            $route = (string)$this->request->get['route'];
        } else {
            $route = 'common/home';
        }

        $layout_id = 0;

        if ($route == 'product/category' && isset($this->request->get['path'])) {
            $path = explode('_', (string)$this->request->get['path']);

            $layout_id = $this->model_catalog_category->getCategoryLayoutId(end($path));
        }

        if ($route == 'product/product' && isset($this->request->get['product_id'])) {
            $layout_id = $this->model_catalog_product->getProductLayoutId($this->request->get['product_id']);
        }

        if ($route == 'information/information' && isset($this->request->get['information_id'])) {
            $layout_id = $this->model_catalog_information->getInformationLayoutId($this->request->get['information_id']);
        }

        if (!$layout_id) {
            $layout_id = $this->model_design_layout->getLayout($route);
        }

        if (!$layout_id) {
            $layout_id = $this->config->get('config_layout_id');
        }

        $module_data = array();

        $this->load->model('setting/extension');

        $extensions = $this->model_setting_extension->getExtensions('module');

        foreach ($extensions as $extension) {
            $modules = $this->config->get($extension['code'] . '_module');

            if ($modules) {
                foreach ($modules as $module) {
                    if ($module['layout_id'] == $layout_id && $module['position'] == 'content_footer' && $module['status']) {
                        $module_data[] = array(
                            'code'       => $extension['code'],
                            'setting'    => $module,
                            'sort_order' => $module['sort_order']
                        );
                    }
                }
            }
        }

        $sort_order = array();

        foreach ($module_data as $key => $value) {
            $sort_order[$key] = $value['sort_order'];
        }

        array_multisort($sort_order, SORT_ASC, $module_data);

        $this->data['modules'] = array();

        foreach ($module_data as $module) {
            $module = $this->getChild('module/' . $module['code'], $module['setting']);

            if ($module) {
                $this->data['modules'][] = $module;
            }
        }

        if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/common/content_footer.tpl')) {
            $this->template = $this->config->get('config_template') . '/template/common/content_footer.tpl';
        } else {
            $this->template = 'default/template/common/content_footer.tpl';
        }

        $this->render();
    }
}
?>

Step#1: Go to catalog/controller/common/ paste the file content_footer.php

Step#2: We will need to create a template file for this new module position. Create a file name content_footer.tpl. Go to catalog/view/theme/default/template/common/ paste the file content_footer.tpl

<?php foreach ($modules as $module) { ?>
   <?php echo $module; ?>
<?php } ?>

Step#3: Edit for link up catalog/controller/common/footer.php and find

$this->render();

Before it, add

$this->children = array(
   'common/content_footer'
);

Step#4: Edit catalog/view/theme/default/template/common/footer.tpl and find

<div id="powered"><?php echo $powered; ?></div>

Before it, add

<?php echo $content_footer; ?>

Assigning Positions To Modules

Open up the template files of any modules that you would like to display at the new position. Let’s say I would like to display the Featured Module at Content Footer, I will open up admin/view/template/module/featured.tpl and find

<?php if ($module['position'] == 'content_top') { ?>
   <option value="content_top" selected="selected"><?php echo $text_content_top; ?></option>
<?php } else { ?>
   <option value="content_top"><?php echo $text_content_top; ?></option>
<?php } ?>

Before it, add

<?php if ($module['position'] == 'content_footer') { ?>
   <option value="content_footer" selected="selected">Content Footer</option>
<?php } else { ?>
   <option value="content_footer">Content Footer</option>
<?php } ?>

Now, find

html += '      <option value="content_top"><?php echo $text_content_top; ?></option>';

and before it add

html += '      <option value="content_footer">Content Footer</option>';

By adding those codes, you have a new position ‘Content Footer’ for the Featured module.

Enjoy it 🙂

Download Source Code: 1st you need to backup your all source code then apply with this.

Module Position Downlaod
Opencart Module Position

Newsletter – default Subscribe for opencart

Tested for version 1.5.x
Edit: catalog/view/theme/default/template/account/register.tpl

Find the code

<td><?php if ($newsletter == 1) { ?>
<input type="radio" name="newsletter" value="1" checked="checked" />
<?php echo $text_yes; ?>
<input type="radio" name="newsletter" value="0" />
<?php echo $text_no; ?>
<?php } else { ?>
<input type="radio" name="newsletter" value="1" />
<?php echo $text_yes; ?>
<input type="radio" name="newsletter" value="0" checked="checked" />
<?php echo $text_no; ?>
<?php } ?></td>

Replace by

<td><?php if ($newsletter == 0) { ?>
<input type="radio" name="newsletter" value="1" />
<?php echo $text_yes; ?>
<input type="radio" name="newsletter" value="0" checked="checked" />
<?php echo $text_no; ?>
<?php } else { ?>
<input type="radio" name="newsletter" value="1" checked="checked" />
<?php echo $text_yes; ?>
<input type="radio" name="newsletter" value="0" />
<?php echo $text_no; ?>
<?php } ?></td>

Edit: catalog/view/theme/default/template/checkout/register.tpl

Find the code

<input type="checkbox" name="newsletter" value="1" id="newsletter" />

Replace by

<input type="checkbox" name="newsletter" value="1" id="newsletter" checked="checked" />

How to add watermark to image for opencart?

These instructions are valid for Opencart 1.4.x and 1.5.x

Step#1. Create PNG watermark, name it as watermark.png and copy it to image/ folder of your Opencart installation (yes, it works fine with PNG files).
Step#2. Now edit 2 PHP files
Step#3. The first file: system/library/image.php

Go to lines 93-121 and you will see the following code:

public function watermark($file, $position = 'bottomright') {
        $watermark = $this->create($file);

        $watermark_width = imagesx($watermark);
        $watermark_height = imagesy($watermark);

        switch($position) {
            case 'topleft':
                $watermark_pos_x = 0;
                $watermark_pos_y = 0;
                break;
            case 'topright':
                $watermark_pos_x = $this->info['width'] - $watermark_width;
                $watermark_pos_y = 0;
                break;
            case 'bottomleft':
                $watermark_pos_x = 0;
                $watermark_pos_y = $this->info['height'] - $watermark_height;
                break;
            case 'bottomright':
                $watermark_pos_x = $this->info['width'] - $watermark_width;
                $watermark_pos_y = $this->info['height'] - $watermark_height;
                break;
        }

        imagecopy($this->image, $watermark, $watermark_pos_x, $watermark_pos_y, 0, 0, 120, 40);

        imagedestroy($watermark);
    }

You have to replace this code with the code below :

public function watermark($file, $position = 'bottomright') {

   //Pb ! you don't work on the true object => you must modify the "create" method ($mime = $this->info['mime']; it's work only if we have the same image format !
        //$watermark = $this->create($file);

        //Prefer PNG files => it's not optimized but it's work
   $watermark = imagecreatefrompng($file);

        $watermark_width  = imagesx($watermark);
        $watermark_height = imagesy($watermark);

        switch($position) {
            case 'topleft':
                $watermark_pos_x = 0;
                $watermark_pos_y = 0;
                break;
            case 'topright':
                $watermark_pos_x = $this->info['width'] - $watermark_width;
                $watermark_pos_y = 0;
                break;
            case 'bottomleft':
                $watermark_pos_x = 0;
                $watermark_pos_y = $this->info['height'] - $watermark_height;
                break;
            case 'bottomright':
                $watermark_pos_x = $this->info['width'] - $watermark_width;
                $watermark_pos_y = $this->info['height'] - $watermark_height;
                break;
         case 'center':
            $watermark_pos_x = ($this->info['width']- $watermark_width)/2;
            $watermark_pos_y = ($this->info['height']- $watermark_height)/2;
            break;
        }

        imagecopy($this->image, $watermark, $watermark_pos_x, $watermark_pos_y, 0, 0, $watermark_width, $watermark_height);

        imagedestroy($watermark);
    }

Step#4. Second file to edit is catalog/model/tool/image.php
Go to line 27 and you will see the follwing line:

$image = new Image(DIR_IMAGE . $old_image);

Right after this line add the following code:

if ($width > 400 || $height > 300) {   
   $image->watermark(DIR_IMAGE . 'watermark.png', 'center');
}

In the code above you can define desired position of the watermark (topleft, topright, bottomleft, bottomright or center).
You can also define minimum width or height of your image to which the watermark will be added (if you want watermarks appear even on thumbnails, put 0)

5. Final step: delete all data in folder image/cache/data in order to have the images recreated with watermarks.
That’s it!

Download File is here, you can view it after click any social button.