PHP code example of azecdev90 / seclibrary

1. Go to this page and download the library: Download azecdev90/seclibrary library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

azecdev90 / seclibrary example snippets

 
 xssCleaner($stringfromdatabase); 


if(csrfCompareTokens($_POST['token'])) {
   // tokens are equals and request is valid
} else {
  // refuse request, because it is potentially type of CSRF attack
}


hashPassword($plainpassword);


// $plainpass – usually from form
// $hashedpass – usually from database
checkPassword($plainpass, $hashedpass) { 
// Password from form and database are equals
}


// $file to check extension
// $allowedextensions = [‘jpg’,’png’]
If(imgCheckExtension($file, $allowedextensions)) {
// extension of this file is in allowed list 
}


// $file to check mime type
// $allowedmime = ['image/jpg', 'image/png']
If(imgCheckMimeType($file, $allowedmime)) {
// file have right mime-type
}


$newname = imgRandomName();


// $page = $_GET['page']
// $allowedlist = ['forum.php','about.php','history.php'];
If(checkInclusion($page, $allowedlist) {
// Page is in allowed list, safe 


validateEmail($emailfrominput);


validateNumber($numberfrominput);
html
<input type="hidden" name="token" value=" echo csrfGenerateToken();