Synchronize wordpress with limesurvey

In my previous post, I wrote how to use wordpress functions outside.

Suppose we want to add wordpress header and footer design in limesurvey template. Following are the steps.

1. Create copy of default template in limesurvey.
2. Activate it through survey settings.
3. Now you want to upload that php file which I defined in my previous post. But when you try to upload, it gives message of not supported file system.
4. So, we need to manually upload file in template folder which is currently created.i.e limesurvey/uploads/template/copy_of_template_directory.
5. As, limesurvey template file is .pstpl format which does not support direct inclusion of php files.
6. So, the method is to call php file through AJAX function.

<div id="demo"></div>
<script type="text/javascript" charset="utf-8">
$.ajax({
url: "{TEMPLATEURL}demo.php",
type: "POST",
success: function(result){
// Load the remote file contents into the script parent element
$("#demo").append(result);
}
});
</script>

Above code helps to append the php code in your demo division. you can define this division where ever you want to embed the php code.

Cheers!

Use WordPress theme functions externally.

If you want to call any wordpress function outside , you need to have access of its wp-load.php file which load all wordpress functions.

Suppose, you want to display header and footer of wordpress website in your web browser.

1. Create index.php

2. Copy, this code to index.php file which fetch its parts.

<?php
define('WP_USE_THEMES', false);
require('blog/wp-load.php');
get_header();
get_footer();
?>

You can call any part of wordpress like sidebar but you just need to find out its function name and call it in the required file.

Cheers!

Install Laravel in your Ubuntu 14.04

Below given are the server requirements to install laravel.

LAMP should be Installed
PHP >= 5.6.4
OpenSSL PHP Extension
PDO PHP Extension
Mbstring PHP Extension
Tokenizer PHP Extension

To upgrade php version, follow this link.

You can find out if this PHP module is installed or not by looking at the list that is produced by this command.

$ php -m

Those are not installed, install it by applying below given command.

$ sudo apt-get install php-mbstring

You can check it though phpinfo(); function

Laravel use composer to install dependencies. So, we need to install composer first.

$ sudo apt-get update
$ sudo apt-get install curl php5-cli git
$ curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer

To test installation of composer, run composer.

$ composer

However, if you want to install it in your local project directory.

$ cd /var/www/html/
$ curl -sS https://getcomposer.org/installer | php

After installation of composer, follow below given steps to install laravel.

$ cd /var/www/html
$ git clone https://github.com/laravel/laravel.git
$ cd /var/www/html/laravel
$ sudo composer install

If above given command, produce error like this.

Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

Problem 1
– phpunit/phpunit 4.8.9 requires ext-dom * -> the requested PHP extension dom is missing from your system.

Perform below given steps.

$ sudo apt-get install php-xml
$ sudo apt-get install php7.0-xml

Now set the 32 bit long random number encryption key, which used by the Illuminate encrypter service.

$ php artisan key:generate

Application key [cdfnvjfnvjkenfnkjnekjcnjkdnvknf] set successfully.

Edit config/app.php configuration file and update above generated application key as followings. Also make sure cipher is set properly.

'key' => env('APP_KEY', 'uOHTNu3Au1Kt7Uloyr2Py9blU0J5XQ75'),

‘cipher’ => ‘AES-256-CBC’,

Don’t forget to give permissions.

$ chown -R www-data.www-data /var/www/html/laravel
$ chmod -R 755 /var/www/html/laravel
$ chmod -R 777 /var/www/html/laravel/app/storage

You are done with laravel installation, to run the website, ping your browser with below given URL.

http://localhost/laravel/public

To Create apache virtual host.

Add Virtual Host in your Apache configuration file to access Laravel framework from web browser.

vim /etc/apache2/sites-available/laravel.example.com.conf

<VirtualHost *:80>

ServerName laravel.com
DocumentRoot /var/www/html/laravel/public

<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/html/laravel>
AllowOverride All
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Run the command to enable laravel website and restart apache.

$ a2ensite laravel.example.com
$ sudo service apache2 reload

Now you can browse your laravel from this URL(http://laravel.example.com)

Cheers!

Upgrade PHP version in Ubuntu 14.04 LTS

To run new applications, like laravel, we need to upgrade our system. so, to update php version, follow below given steps.

  • sudo apt-get dist-upgrade
  • sudo LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php
  • sudo apt-get update
  • sudo apt-get install php7.0 #for php 7
  • sudo apt-get install php5.6 #for php 5.6
  • sudo apt-get install php-xdebug php-apcu
  • php -v (to see the new version installed in your system)

Thanks.

How To Live Your Presence On Web

If you want to live your website on web, you need few tools which is defined as below.

1. Server: Basically, Server is a computer which has assigned a static IP to access while sitting anywhere in the world. Various companies which provide server hosting like Bluehost, digital ocean and many more. These companies provide you space according to your requirement and charge you for that.

2. Domain Name: It is word which defines or identifies your website from entire world. Well, domain name is also used because its difficult to memorize IP addresses. Companies like dynadot from where you can buy your own domain like navdeepbagga.com, facebook.com.

Now when you have domain name and server, you can make your website up witin few minutes.

I assume you got services from Digital Ocean and Dynadot and I explain further according to that. I hope you enjoy this lesson and excited for your web presence. Let’s start.

1. If you have register with Digital Ocean(hosting service provider), just login with your given credentials, now you able to see the droplet(your space dashboard). From the very first screen, IP address has been written. Just copy that IP address.

2. Login to your dynadot account. From the main menu DOMAINS go to MANAGE. Click on given name server it is like(Dynadot DNS: 012.345.678.900). After clicking, you reach to domain record page where you need to set your record type and IP address.

3. Now remember, the IP address which you have copied in first step that is need to be copied under IP address or target host.
Just choose record type A and put IP address on the same side. Click on Save DNS.

4. Now you just mapped your DNS with IP address. It takes few hours to mapping but when it is done, you can access your server with its domain name.

5. I assume that you have basic knowledge about server login, some hosting companies provide cpanel to access your server data like bluehost. But if not you must have knowledge about ssh client.

6. Login your server with your given credentials. Place your files there and you are ready to access that files from your web browser.

So, It is just a basic lesson. For advance learning like handle NGINX Server, create subdomains, keep reading upcoming blogs.

Thanks!

Audio conversion with ffmpeg

Hi Guys!

Do you ever stuck with DVD’s or CD’s player while playing your favourite audio’s?
If yes, you are in right place. I will told you how to convert your audio formats with this simple trick in one go.

So, first you all need to know about ffmpeg.
ffmpeg : It is a free software which helps you to convert your audio formats.

To use this, you have to compile it on your system. Follow this below given link.
https://trac.ffmpeg.org/wiki/CompilationGuide

After compilation, you can convert any type of audio and video according to your requirement.

Basic command to run ffmpeg is

ffmpeg -i inputfilename..mp3 outputfilename.m4a

Here -i means input file.

So simple, isn’t it.

Well if you want to play with ffmpeg, like setting its bit rate, channel and frequency.
You need to compile ffmpeg with libfdk_aac library for high quality output.

I will tell you by giving some examples.

To convert .wav to .aac

ffmpeg -i song003.wav -c:a libfdk_aac -ar 44100 -ab 128000 -ac 2 wav.aac

ar to set frequency
ab to set bitrate
ac to channel like stereo or mono.

To convert .m4a to .aac

ffmpeg MediaCoder.m4a -c:a libfdk_aac -vbr 4 m4a.aac

vbr stands for variable bit rate. It may vary from 1 to 5. For further detail you can check this link. https://trac.ffmpeg.org/wiki/Encode/AAC

To convert .wma to .aac

ffmpeg -i Kronke.wma -c:a libfdk_aac -vbr 4 wma.aac

Above given commands convert your audio file specifications to Stream #0:0: Audio: aac (LC), 44100 Hz, stereo, fltp, 128 kb/s.

Thanks!

Install Laravel on Ubuntu

Introduction

Laravel is a free, open source PHP web application framework, designed for the development of MVC web applications.

Requirements

1. Latest version of PHP,MySQL and Apache Web Server must be installed on your system.

2. You need to ensure that you have mod_rewrite enabled on your web server.

$ sudo a2enmod rewrite

3. Install the PHP JSON extension.

$ sudo apt-get install php5-json.

Steps:-

1. Download the latest version of laravel framework and extract its contents into a directory on your server. Don’t forget to give permissions to it.
2. Laravel utilizes Composer to manage its dependencies,we need to install Composer (again, this means downloading it into your project)

$ curl -sS https://getcomposer.org/installer | php

Note: If the above fails for some reason, you can download the installer with php instead.

$ php -r "readfile('https://getcomposer.org/installer');" | php

4. Next, run below given command to install all of the framework’s dependencies and the framework dependencies as mentioned in composer.json file.

$ php composer.phar install

Note : Run this command from the root of your application.

5. Lastly, we’ll need to setup a virtual host for Laravel. Add the domain, laravelapp.com, to our hosts files i.e /etc/hosts

127.0.0.1 laravelapp.com

Note: we are not buying an actual .com domain, but just making one at local installation.

This will inform our machine that the domain laravelapp.com will resolve to 127.0.0.1, which is the local computer.

6. In the Laravel files you should see a directory, called public, which is where all publically accessible files should go. In addition to that, we need to make sure that our domain, http://laravelapp.com only points to the public folder and nowhere else. Edit /etc/apache2/sites-available. Add following lines to it.
(i) Copy deafult file as a new file.

$ cp default laravel

(ii) Edit /etc/apache2/sites-available/laravel. Add below given lines to it.

<VirtualHost *:80>
ServerName laravelapp.com
DocumentRoot "/var/www/laravel-master/public"
<Directory "/var/www/laravel-master/public">
</Directory>

(iii) Run below given command after it.

$ sudo a2ensite laravel

7. Reload apache Server.

$ sudo service apache2 reload

8. Run http://laravelapp.com/ on your browser. It display “You have arrived”. That’s all.

Thanks.

Typography

I have recently listen presentation on Typography delivered by Inderpreet Singh. He delivered in such a way that he enforced audience to think upon every minute while reading or writting any material.

Typography is how to present written material in well manner. It is not about designing or decorating, it is about problem solving. Typograpghy is justfont, which change mood of readers. Every font say something, and every font has special meaning, just to recognize it which font where needed.
Most of the webpages filled with content in bad typography, that makes reader uncomfortable.

Typography change the look of material in such a way that reader kept on reading with interest. It is the heart of articles, blogs and webpages.

Before listening to this presenatation I have never think about Typography.
Now I came to know, how much Typograpghy matters.
Need to think how we can read books continuosly, specially novels.
Need to think that how small things made change from good to excellence.
Without typograpghy is just like forget to put maggie masala into maggie.