azazqadir
azazqadir
Reputation Top 1%
Muhammad Azaz Qadir
11 Snippets  (75th place)
Published
1 Channel
Created
5 Channels
Following
Apr 11, 2018
Last Visit
Nov 21, 2017
Registered
265 points  (115th place)
Reputation
Junior Code Generator
Serious Code Generator
Serious Publisher
Junior Popular Coder
Serious Popular Coder
Senior Popular Coder
Junior Autobiographer
Senior Autobiographer

Recent Snippets See all snippets by azazqadir

public by azazqadir created Apr 11, 2018  659  1  5  0

Using WooCommerce Rest API for Custom Dashboard

Using WooCommerce Rest API (https://www.cloudways.com/blog/custom-dashboard-using-woocommerce-php-rest-api/ ) to create a Custom Dashboard
<div class="container">

                                  <h2 class="sub-header">Customers List</h2>

                                  <div class='table-responsive'>

                                      <table id='myTable' class='table table-striped table-bordered'>

                                          <thead>

                                              <tr>

                                                  <th>Email</th>

                                                  <th>Name</th>

                                                  <th>Billing Address</th>

                                                  <th>Total Orders</th>

                                                  <th>Total spent</th>

                                                  <th>Avatar</th>

                                                  <th>Actions</th>

                                              </tr>

                                          </thead>

                                          <tbody>

                                              <?php

                  foreach($customers as $customer){



                  echo "<tr><td>" . $customer["email"]."</td>

                            <td>" . $customer["first_name"].$customer["last_name"]."</td>

                            <td>" . $customer["billing"]["address_1"]."</td>

                            <td>" . $customer["orders_count"]."</td>

                            <td>" . $customer["total_spent"]."</td>

                            <td><img height='50px' width='50px' src='".$customer["avatar_url"]."'></td>

                             <td><a class='open-AddBookDialog btn btn-primary' data-target='#myModal' data-id=".$customer['id']." data-toggle='modal'>Update</a>

                             <a class='open-deleteDialog btn btn-danger' data-target='#myModal1' data-id=".$customer['id']." data-toggle='modal'>Delete</a></td></tr>";

                  }



                  ?>

                                          </tbody>

                                      </table>

                                  </div>

  </div>												
;

public by azazqadir created Feb 20, 2018  709  1  4  1

LEMP on Debian

Learn how to install LEMP on Debian: https://www.cloudways.com/blog/how-to-create-a-lemp-stack-on-debian-server/
php
location ~ \.php$ {

               

               fastcgi_pass unix:/var/run/php5-fpm.sock;

               fastcgi_index index.php;

               fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

               include fastcgi_params;

               

       }			
;

public by azazqadir created Jan 18, 2018  463  1  5  0

Adding Captcha in CodeIgniter

Source: https://www.cloudways.com/blog/captcha-in-codeigniter/
<?php

defined('BASEPATH') OR exit('your exit message');

class Captcha extends CI_Controller

{

   function __construct()

   {

       parent::__construct();

       $this->load->helper('captcha');

   }

   public function index()

   {

       if ($this->input->post('submit')) {

           $captcha_insert = $this->input->post('captcha');

           $contain_sess_captcha = $this->session->userdata('valuecaptchaCode');

           if ($captcha_insert === $contain_sess_captcha) {

               echo 'Success';

           } else {

               echo 'Failure';

           }

       }

       $config = array(

           'img_url' => base_url() . 'image_for_captcha/',

           'img_path' => 'image_for_captcha/',

           'img_height' => 45,

           'word_length' => 5,

           'img_width' => '45',

           'font_size' => 10

       );

       $captcha = create_captcha($config);

       $this->session->unset_userdata('valuecaptchaCode');

       $this->session->set_userdata('valuecaptchaCode', $captcha['word']);

       $data['captchaImg'] = $captcha['image'];

       $this->load->view('captcha/index', $data);

   }

   public function refresh()

   {

       $config = array(

           'img_url' => base_url() . 'image_for_captcha/',

           'img_path' => 'image_for_captcha/',

           'img_height' => 45,

           'word_length' => 5,

           'img_width' => '45',

           'font_size' => 10

       );

       $captcha = create_captcha($config);

       $this->session->unset_userdata('valuecaptchaCode');

       $this->session->set_userdata('valuecaptchaCode', $captcha['word']);

       echo $captcha['image'];

   }

}
;

public by azazqadir created Dec 15, 2017  460  1  5  -1

Installing PHP Website on Linode Server

Here is how you can easily host a PHP based website easily and quickly on Linode using Cloudways PaaS: https://www.cloudways.com/blog/host-php-on-linode/
<?php
echo rand() . "\n";
echo rand() . "\n";

echo rand(5, 15);
?>
;

public by azazqadir created Nov 21, 2017  566  0  5  1

CDN integration in Yii2 App

How to integrate CloudwaysCDN with Yii2 applications: https://www.cloudways.com/blog/cdn-in-yii2/
// ...

'components' => [

   // ...

'cdn' => [
            'class' => '\yii2cdn\Cdn',
            'baseUrl' => defined ('YII2CDN_OFFLINE')
                ? 'http://localhost/yii2/cdn'
                : '//71265-358070-raikfcquaxqncofqfm.stackpathdns.com/cdn',
            'basePath' => dirname(__DIR__, 2) . '/cdn',
            'components' => [
                'font-awesome' => [
                    'css' => [
                        [
                            // local version
                            'font-awesome.min.css',
                            // cdn version
                            '@cdn' => '//71265-358070-raikfcquaxqncofqfm.stackpathdns.com/cdn/font-awesome/css/font-awesome.min.css',
                        ]
                    ]
                ]
            ],
        ],
 // ...

],

// ...
;