May 27, 2022 in Php, Tips and Tricks
JavaScript array
JavaScript Simple Array
const nouns= ["Aditya", "Amit", "Ajay"];
JavaScript indexed Array
const cars = [];
cars[0]= "Saab";
cars[1]= "Volvo";
cars[2]= "BMW";
May 27, 2022 in Php, Tips and Tricks
JavaScript Simple Array
const nouns= ["Aditya", "Amit", "Ajay"];
JavaScript indexed Array
const cars = [];
cars[0]= "Saab";
cars[1]= "Volvo";
cars[2]= "BMW";
May 26, 2022 in Tips and Tricks
Add .modal-dialog-centered to .modal-dialog to vertically center the modal.
<!-- Button trigger modal -->
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModalCenter">
Launch demo modal
</button>
<!-- Modal -->
<div class="modal fade" id="exampleModalCenter" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLongTitle">Modal title</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
May 12, 2022 in Php, Tips and Tricks
Phone number validation using regular expression
$user_phone = $_POST['user_phone'];
if(!preg_match('/^([0-9]+)$/', $user_phone))
{
$_SESSION['info']="Please enter valid phone number";
header('location:/register');
}
Phone number validation using is_numeric function
$user_phone = $_POST['user_phone'];
if(!is_numeric($user_phone))
{
$_SESSION['info']="Please enter valid phone number";
header('location:/register');
}
if (filter_var($user_email, FILTER_VALIDATE_EMAIL) == false){
$_SESSION['info']="Please enter valid email";
header('location:/register');
}
is_integer()
for this function these values are are not valid: “0010”, “123”
is_numeric()
for this function these values are valid: 1.3, +1234e44 and 0x539
filter_var()
for this function a value as “00123” is not valid
CONSLUSION
it seems that only regex and ctype_digit work always fine.
May 11, 2022 in Tips and Tricks, Ubuntu
canonical-livepatch disable as rootsnap remove canonical-livepatch as root (optional. Try it first without doing this)rm /etc/machine-id as root to remove your current machine ID (if it says the file or directory doesn’t exist, you can safely ignore it)systemd-machine-id-setup as root to regenerate the IDsnap install canonical-livepatch as root (if you removed it earlier)check ubuntu version
lsb_release -a
Upgrade Ubuntu
sudo apt upgrade
May 10, 2022 in Php, Tips and Tricks
Unable to upload large file in php website, here is setting for htaccess file, after this you can upload 500 mb file size, and also change this value.
php_value upload_max_filesize 5000M
php_value post_max_size 5000M
php_value memory_limit 256M
php_value max_execution_time 300
php_value max_input_time 300
April 29, 2022 in Php, Tips and Tricks
if( !function_exists('redirect_404_to_homepage') ){
add_action( 'template_redirect', 'redirect_404_to_homepage' );
function redirect_404_to_homepage(){
if(is_404()):
wp_safe_redirect( home_url('/') );
exit;
endif;
}
}
April 25, 2022 in Php, Technology, Tips and Tricks
# compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
#BEGIN EXPIRES HEADERS
<IfModule mod_expires.c>
# Enable expirations
ExpiresActive On
# Default expiration: 1 hour after request
ExpiresDefault "now plus 1 hour"
# CSS and JS expiration: 1 week after request
ExpiresByType text/css "now plus 1 week"
ExpiresByType application/javascript "now plus 1 week"
ExpiresByType application/x-javascript "now plus 1 week"
# Image files expiration: 1 month after request
ExpiresByType image/bmp "now plus 1 month"
ExpiresByType image/gif "now plus 1 month"
ExpiresByType image/jpeg "now plus 1 month"
ExpiresByType image/jp2 "now plus 1 month"
ExpiresByType image/pipeg "now plus 1 month"
ExpiresByType image/png "now plus 1 month"
ExpiresByType image/svg+xml "now plus 1 month"
ExpiresByType image/tiff "now plus 1 month"
ExpiresByType image/vnd.microsoft.icon "now plus 1 month"
ExpiresByType image/x-icon "now plus 1 month"
ExpiresByType image/ico "now plus 1 month"
ExpiresByType image/icon "now plus 1 month"
ExpiresByType text/ico "now plus 1 month"
ExpiresByType application/ico "now plus 1 month"
# Webfonts
ExpiresByType font/truetype "access plus 1 month"
ExpiresByType font/opentype "access plus 1 month"
ExpiresByType application/x-font-woff "access plus 1 month"
ExpiresByType image/svg+xml "access plus 1 month"
ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
</IfModule>
#END EXPIRES HEADERS
# BEGIN Cache-Control Headers
<ifModule mod_headers.c>
<filesMatch "\.(ico|jpe?g|png|gif|swf)$">
Header set Cache-Control "max-age=2592000, public"
</filesMatch>
<filesMatch "\.(css)$">
Header set Cache-Control "max-age=604800, public"
</filesMatch>
<filesMatch "\.(js)$">
Header set Cache-Control "max-age=216000, private"
</filesMatch>
<filesMatch "\.(x?html?|php)$">
Header set Cache-Control "max-age=600, private, must-revalidate"
</filesMatch>
</ifModule>
# END Cache-Control Headers
# ENABLE LITESPEED CACHE START
<IfModule LiteSpeed>
CacheEnable public
RewriteEngine On
RewriteCond %{REQUEST_METHOD} ^GET|HEAD$
RewriteCond %{HTTP_HOST} ^sample.com|sample.net|sample.org [NC]
RewriteCond %{REQUEST_URI} !login|admin|register|post|cron
RewriteCond %{QUERY_STRING} !nocache
RewriteRule .* - [E=Cache-Control:max-age=300]
</IfModule>
# ENABLE LITESPEED CACHE END
# START ENABLE KEEP ALIVE
<ifModule mod_headers.c>
Header set Connection keep-alive
</ifModule>
# END ENABLE KEEP ALIVE
<IfModule pagespeed_module>
ModPagespeed on
ModPagespeedEnableFilters rewrite_css,combine_css
ModPagespeedEnableFilters recompress_images
ModPagespeedEnableFilters convert_png_to_jpeg,convert_jpeg_to_webp
ModPagespeedEnableFilters collapse_whitespace,remove_comments
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>
April 22, 2022 in Technology, Tips and Tricks
Step by step overview guide for setup business WhatsApp API with Facebook business account
What is the criteria to check my business Facebook is active for WhatsApp api
after that your WhatsApp api is fully activated.
*Step by step overview guide for setup business WhatsApp API
*What is business WhatsApp API
*How to implement WhatsApp API