CSS : .my-icon .date { background:#fff url(https://cdn1.iconfinder.com/data/icons/cc_mono_icon_set/blacks/16×16/calendar_2.png) 93% 50% no-repeat ; } HTML : <div class="my-icon" form-group style="padding-left:0px ;margin-bottom:15px;"> <label>From: </label> <input type="text" name="fromdt" id="fromdt" class="form-control date" value="<?= isset($_POST[‘fromdt’]) ? $_POST[‘fromdt’] : "" ?>" readonly> </div> JS : $(“#fromdt”).datepicker( { dateFormat: ‘yy-mm-dd’, maxDate: ‘+0D’, changeYear: true, changeMonth: true, yearRange: “-100:+0” } );
Bash read txt file into array
declare -a DIRS readarray -t DIRS < /var/www/html/.logPaths.txt let i=0 while (( ${#DIRS[@]} > i )); do #Do Your Stuff done
Check Filesize & Extension before upload (Javascript)
Input <input type=”file” onchange=”ValidateFile(this);” id=”uploaded_file”> Function for checking upon on change for uploaded file function ValidateFile(file){ var FileSize = file.files[0].size / 1024 / 1024; //In MB var filePath = file.files[0].name; var extension = filePath.substr((filePath.lastIndexOf(‘.’) +1)); var allowed_extension = [“jpg”,”png”,”jpeg”]; if (FileSize > 2) { […]
Prevent Direct Calling for PHP scripts, Only Allow Ajax Calling
The Code below is useful to prevent direct calling. #Only Allow Ajax Call if(!($_SERVER[‘HTTP_X_REQUESTED_WITH’] == ‘XMLHttpRequest’ && $_SERVER[‘HTTP_X_REQUESTED_WITH’])) { echo “Access Denied”; exit(); }
SSH Trick
How To SSH run command without key-in password again echo < password > | ssh username@host ‘sudo -S < command >’ Running Two SSH Command line for sqldump ssh -t username@host ‘mysqldump -u {DB_USER} -p”{DB_PASS}” {DB_NAME}’ > dump.sql | ssh -t username@host ‘cat dump.sql’ > local.sql
Building your own SMTP server
https://www.linode.com/docs/email/postfix/email-with-postfix-dovecot-and-mysql/#dovecot
PHP Code Injection Prevention
Hi, this would be great if you place @ the very first line of your script. if(isset($_GET)){ foreach ($_GET as $key => $value) { $_GET[$key] = cleanInput(strip_tags(rawurldecode(rawurldecode($value)))); } } if(isset($_POST)){ foreach ($_POST as $key => $value) { $_POST[$key] = cleanInput(strip_tags(rawurldecode(rawurldecode($value)))); } } function cleanInput($input) { $search = array( ‘@@si’, ‘@@si’, ‘@@siU’, ‘@@’ ); $output = […]
Nmap Scan ( Port Scanning )
nmap is aport scanning tool that is useful to detect which port is up and its usage. #$ nmap -O -p1-65535 thedomain Explaination: -O: Enable OS detection -p : Only scan specified ports
How to install laravel & php 7.2
There are few things we need for this tutorial. PHP 7.2+ REF : https://www.chris-shaw.com/blog/installing-php-7.2-on-debian-8-jessie-and-debian-9-stretch Composer REF : https://getcomposer.org/doc/00-intro.md#downloading-the-composer-executable laravel Okay , so we will start intall for php 7.2 ++ and below are the steps :- #Adding Repo $ sudo apt-get install apt-transport-https lsb-release ca-certificates $ sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg $ echo “deb https://packages.sury.org/php/ […]
Codeigniter Rewrite for nginx & apache
Rewrite Rules for nginx must be added into each domain’s configuration. location /path/to/project{ try_files $uri $uri/ /path/to/project/index.php?/$request_uri; } Rewrite Rules for apache can be added in the project’s .htaccess. RewriteEngine on RewriteCond $1 !^(index\.php|assets|images|js|css|uploads|favicon.png) RewriteCond %(REQUEST_FILENAME) !-f RewriteCond %(REQUEST_FILENAME) !-d RewriteRule ^(.*)$ ./index.php/$1 [L]