European countries list in php array

$eu_counries = array( 'AL' => 'Albania', 'AD' => 'Andorra', 'AM' => 'Armenia', 'AT' => 'Austria ', 'BY' => 'Belarus', 'BE' => 'Belgium', 'BA' => 'Bosnia and Herzegovina', 'BG' => 'Bulgaria', 'CH' => 'Switzerland', 'CY' => 'Cyprus', 'CZ' => 'Czech Republic', 'DE' => 'Germany', 'DK' => 'Denmark', 'EE' => 'Estonia', 'ES' => 'Spain', 'FO' => 'Faeroe Islands', 'FI' => 'Finland', 'FR' => 'France', 'GB' => 'United Kingdom', 'GE' => 'Georgia', 'GI' => 'Gibraltar', 'GR' => 'Greece', 'HU' => 'Hungary', 'HR' => 'Croatia', 'IE' => 'Ireland', 'IS' => 'Iceland', 'IT' => 'Italy', 'LI' => 'Liechtenstein', 'LT' => 'Lithuania', 'LU' => 'Luxembourg', 'LV' => 'Latvia', 'MC' => 'Monaco', 'MK' => 'Macedonia', 'MT' => 'Malta', 'NO' => 'Norway', 'NL' => 'Netherlands', 'PL' => 'Poland', 'PT' => 'Portugal', 'RO' => 'Romania', 'RU' => 'Russian Federation', 'SE' => 'Sweden', 'SI' => 'Slovenia', 'SK' => 'Slovakia', 'SM' => 'San Marino', 'TR' => 'Turkey', 'UA' => 'Ukraine', 'VA' => 'Vatican City State');

Password protecting your site using .htaccess / .htpasswd

1. Update .htaccess file to the root of your site with the following content:

AuthName "Authorisation Required"
AuthUserFile "/path/to/.htpasswd"
AuthType Basic
require valid-user
ErrorDocument 401 "Authorisation Required"
2. Create & upload the .htpasswd file to ‘AuthUserFile’ path with the following content:
foo:$testing$f#$ffgJHFjhfRGV.
3. generate about line using username & password uaing this site http://www.htaccesstools.com/htpasswd-generator/

Check date expired or not using PHP code

Please check below code:-

$todays_date = date(“Y/m/d”);
$today = strtotime($todays_date);
$exp_date = ‘2018/06/06’;
$expiration_date = strtotime($exp_date);

if($expiration_date >= $today) {
echo ‘Not expired’;
}else{
echo ‘Expired’;
}

Split large SQL file into small files using PHP code

Please find below code to Split large SQL file into small files

$file_handle = fopen(‘sql/file.sql’,’r’); //open big file with fopen
$f = 1; //new file number
while(!feof($file_handle))
{
$newfile = fopen(‘sql/splitfile-‘ . $f . ‘.sql’,’w’); //create new file to write to with file number
for($i = 1; $i <= 3000; $i++) //for 3000 lines
{
$import = fgets($file_handle);
fwrite($newfile,$import);
if(feof($file_handle))
{break;} //If file ends, break loop
}
fclose($newfile);
//MySQL newfile insertion stuff goes here
$f++;
}
fclose($file_handle);

MailChimp integration with PHP CURL API

$memberHash = md5($email);
$api_key = ‘XXXXXXXXXXXXXX-us19’;  //API KEY
$server = ‘us19.’;
$list_id = “XXXXXXX”; // LIST ID
$auth = base64_encode( ‘user:’.$api_key );
$data = array(
‘apikey’ => $api_key,
’email_address’ => $email,
‘status’ => ‘subscribed’,
‘merge_fields’ => array(
‘NAME’ => $name,
),
);
$json_data = json_encode($data);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, ‘https://\’.$server.’api.mailchimp.com/3.0/lists/’.$list_id.’/members/’.$memberHash);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(‘Content-Type: application/json’,
‘Authorization: Basic ‘.$auth));
curl_setopt($ch, CURLOPT_USERAGENT, ‘PHP-MCAPI/2.0’);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, “PUT”);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, $json_data);
$result = curl_exec($ch);
$result_obj = json_decode($result);
echo $result_obj->status;