How to Increase import file size limit in phpMyAdmin

The default file import/upload size in phpMyAdmin is 2MB, For increasing file import size You need to make some changes in php.ini file and restart apache server. After changing following parameter you’ll able to import big .sql file easily.

 

Here i am going to take example of  XAMPP server ,

step 1. open xampp control panel

step 2. click on  apache config then one drop down open where you find php(php.ini) file  click on it then open it on any text editor.

step 3. find below value and increased it as per your requirement

post_max_size = 500M 
upload_max_filesize = 500M 
max_execution_time = 5000 
max_input_time = 5000 
memory_limit = 1000M

Note: don’t forget to allocate larger value to memory_limit then post_max_size.

step 4. save file and restart XAMPP  server

To invite all your Facebook friends to like a page you run, follow these instructions from a computer.

STEP 1: While logged in on your personal profile, Facebook and click on “Build Audience” on the top right side of the Facebook page you admin and the click “Invite Friends” button.

NOTE: you need to be logged in as your personal profile while accessing the page. If you don’t see the option to “Invite Friends”, from your personal FB acount type your page’s URL directly into the browser URL bar and go straight to it. That should make it possible to get to step 2.

STEP 2: Scroll down till it loads every single friend you have on your list. you have to keep scrolling down until it stops loading more.

NOTE: If you want to only invite specific people, you can chose from the filters that are available here before scrolling.

STEP 3: (In chrome), open the JavaScript console [CTRL + Shift + J] and paste the following EXACTLY AS IS,INCLUDING THE CURLY BRACKET AT THE END:

javascript:var inputs = document.getElementsByClassName(‘uiButton _1sm’); for(var i=0; i<inputs.length;i++) { inputs[i].click(); }

STEP 4: Press enter, and wait for it to send invites to everyone. 1,000 people, took about 30 seconds on my computer. It might take more or less time on yours.

Basic PHP File Handling — Create, Open, Read, Write, Append, Close, and Delete

Create a File

$my_file = 'filename.txt';
$handle = fopen($my_file, 'w') or die('Cannot open file:  '.$my_file); //implicitly creates file

Open a File

$my_file = 'filename.txt';
$handle = fopen($my_file, 'w') or die('Cannot open file:  '.$my_file); //open file for writing ('w','r','a')...

Read a File

$my_file = 'filename.txt';
$handle = fopen($my_file, 'r');
$data = fread($handle,filesize($my_file));

Write to a File

$my_file = 'filename.txt';
$handle = fopen($my_file, 'w') or die('Cannot open file:  '.$my_file);
$data = 'This is the data';
fwrite($handle, $data);

Append to a File

$my_file = 'filename.txt';
$handle = fopen($my_file, 'a') or die('Cannot open file:  '.$my_file);
$data = 'New data line 1';
fwrite($handle, $data);
$new_data = "\n".'New data line 2';
fwrite($handle, $new_data);

Close a File

$my_file = 'filename.txt';
$handle = fopen($my_file, 'w') or die('Cannot open file:  '.$my_file);
//write some data here
fclose($handle);

Delete a File

$my_file = 'filename.txt';
unlink($my_file);

Check Null In PHP

<?php
/**
 * 
 * @param $value the value that need to be checked
 * @return TRUE if value is not null/empty else FALSE
 */
function check_for_null($value) {
    if (is_array($value)) {
        if (count($value) > 0) {
            return TRUE;
        } else {
            return FALSE;
        }
    } else {
        if (($value != '') && ($value !== NULL) && (strlen(trim($value)) > 0)) {
            return TRUE;
        } else {
            return FALSE;
        }
    }
}

echo check_for_null(NULL); // return false
echo check_for_null(array()); // return false
echo check_for_null(10); // return true
echo check_for_null($apple); // return false

if ( check_for_null(10) ) {
    // not null do, something here
} else {
    // yes it is null, do something here
}

?>

Generate random string

<?php

/**

 * 

 * @param $size is an integer value ( length ) of string to be generated

 * @return string if a positive integer value is passed 

 * or NULL if a negative or non-integer number is given

 */

function get_random_string($size) {

    $size = intval($size);

    if ($size == 0) {

        // if an integer value is not given return NULL 

        return NULL;

    }

   

    // you can add more characters to this variable

    $charSet = "ABCHEFGHJKMNPQRSTUVWXYZ0123456789abchefghjkmnpqrstuvwxyz!@#%^&*()";

    $len = strlen($charSet);

    $str = '';

    $i = 0;

    while (strlen($str) < $size) {

        $num = rand(0, ($len-1));

        $tmp = substr($charSet, $num, 1);

        $str = $str . $tmp;

        $i++;

    }

    return $str;

}

 

// how to use this function

echo get_random_string(10);  // return hHA%y!bc)f (can be different)

echo get_random_string(5);  // return ajHm) (can be different)

?>

How detect robots and spiders with PHP

How-detect-robots-and-spiders-with-PHP

Here is the simple function for detecting spiders and robots. It will return true or false.

function is_bot(){
    $bots = array(
        'Googlebot',
        'Baiduspider',
        'ia_archiver',
        'R6_FeedFetcher',
        'NetcraftSurveyAgent',
        'Sogou web spider',
        'bingbot',
        'Yahoo! Slurp',
        'facebookexternalhit',
        'PrintfulBot',
        'msnbot',
        'Twitterbot',
        'UnwindFetchor',
        'urlresolver',
        'Butterfly',
        'TweetmemeBot');
   foreach($bots as $b){
      if( stripos( $_SERVER['HTTP_USER_AGENT'], $b ) !== false ) return true;
   }
   return false;
}