Add Authorization to your Website using .htaccess file

You have to create 2 files first is .htaccess file and another is .htpasswd file
code of .htaccess file :

#deny from all
allow from all
AuthUserFile path-of-your-.htpasswd-file e.g. /usr/home/aftab/public_html/store/.htpasswd
AuthType Basic
AuthName "Authorization Required"
Require valid-user

and code of .htpasswd file :

//admin is the username
// and password is encrypted by MD5


JQuery Code Snippet to “Translate your website in many languages”

You just need to add the script in your HTML which is given below:

<!-- If you already have jQuery embeded in your page, remove the following line: -->
<script src=""></script>
<!-- Start Translate This button  -->
<script src=""></script>
<div class="translate_this notranslate" style="margin-top:20px;">
<a class="translate_this_drop translate_this_tc_icon" title="Translate" href="">translation services</a>
<a class="translate_this_drop translate_this_translate_text" title="Translate" href="">Translate</a>
<span class="translate_this_separator"> | </span>
<a class="translate_this_no_drop" title="English" href="" rel="en">English translation</a>
<a class="translate_this_no_drop" title="Spanish" href="" rel="es">Spanish</a>
<a class="translate_this_no_drop" title="German" href="" rel="de">German</a>
<a class="translate_this_no_drop" title="Chinese" href="" rel="zh-CHS">translate Chinese</a>
</div> <!-- End Translate This button -->

Create PDF file of any URL

Now it is very easy to create a PDF file of any page or any reports etc.
Simply, you need to create the html page for which you need to create PDF.

For eg: If I want to create PDF of than I will simply put url of as shown in below example:

$url = "";
$file = phptopdf_url($url, 'pdf_examples/', "GOOGLE_HOMEPAGE.pdf");
// First Param : specifies the URL whose PDF to generate
// Second Param : specifies the storage location
// Third Param : defines the PDF filename 

I had created a function called "phptopdf_url()" to make it more clear
and structured. The function is follows: function phptopdf_url($source_url,$save_directory,$save_filename) { $API_KEY = 'd6s73mtjk85di7hm3'; $url = ''.$API_KEY.'&url='.urlencode($source_url); $resultsXml = file_get_contents(($url)); file_put_contents($save_directory.$save_filename,$resultsXml); return $save_directory.$save_filename; }

By executing above given code you can generate PDF. That’s it. ­čÖé

Create Tiny URL from PHP

To create tiny url from PHP code we can use following:

//gets the data from a URL
function get_tiny_url($url) {
$ch = curl_init();
$timeout = 5;
$data = curl_exec($ch);
return $data;

//test it out!
$new_url = get_tiny_url('


echo $new_url

Thats It…!! Enjoy

Creating Thumbnail Images From Video

To Create thumbnail image for the video which is uploaded then you can use a library┬ácalled “ffmpeg”
This library is used to manipulate videos.

Steps for creating thumbnail from video:

1). Download the ffmpeg library into the system, or you can add ffmpeg-php extension.

2). To see that ffmpeg is installed you can check it by viewing phpinfo() function.

$tmpfile = $_FILES['video']["tmp_name"];
$file = $_FILES['video']["name"];
$abc = date("dmyHis");
$insertVideo = $abc . $file;
move_uploaded_file($tmpfile, $sub_dir . $insertVideo);
$image_name = $abc . "_image.jpg";
$file_thumb = create_movie_thumb($sub_dir . $insertVideo,$sub_dir,$image_name);

Below is the actual function to create thumbnail

function create_movie_thumb($src_file,$fullpath,$image_name)
global $CONFIG, $ERROR;
if ($_SERVER['HTTP_HOST'] == '') {
$CONFIG['ffmpeg_path'] = 'c:/ffmpeg/bin/'; // path of your ffmpeg bin folder this is for windows
$CONFIG['ffmpeg_path'] = '/usr/local/bin/'; // this path is for linux
$CONFIG['fullpath'] = $fullpath;
$CONFIG['debug_mode'] = 1;

$src_file = $src_file;
$imgname = $image_name;
$dest_file = $CONFIG['fullpath'].$imgname;

$cmd = "\"".str_replace("\\","/", $CONFIG['ffmpeg_path'])."ffmpeg\" -i ".str_replace("\\","/" ,$src_file )." -an -ss 00:00:03 -r 1 -vframes 1 -y ".str_replace("\\","/" ,$dest_file);
echo $cmd;