Skip to content

Instantly share code, notes, and snippets.

@daif
daif / iban.php
Created February 21, 2019 13:54
Check IBAN number
<?php
/**
* Value should be an IBAN number
*
*
* @param string
* @return bool
*/
function iban($str)
{
<?php
// set your database path
$firebase = 'https://myrealtimedb.firebaseio.com/';
// Update or Save to fireBase
$data = FireBaseJson('PUT','MyContentPath', 'MyContentData');
print_r($data);
// Get from fireBase
$data = FireBaseJson('GET', 'MyContentPath');
@daif
daif / imagehash.php
Last active December 29, 2024 06:26
a simple image hashing algorithm
<?php
function imageHash($image_file) {
// check if the file is existed and is readable
if(file_exists($image_file) && is_readable($image_file)) {
return false;
}
// get image dimensions
list($width, $height) = getimagesize($image_file);
@daif
daif / file_search.php
Last active December 29, 2024 06:27
search in text file
<?php
// script startup time and memory usage
$mem_usage = memory_get_usage();
$time_usage = microtime(true);
$return = 'FALSE';
$password = '070162';
// get password list file from https://github.com/danielmiessler/SecLists/tree/master/Passwords
/* don't touch the above lines */
/* ------------------------------------------------------------------- */
@daif
daif / file_cache_contents.php
Created January 4, 2017 16:50
Tiny Cache system
<?php
//Tiny Cache system
function file_cache_contents($url, $cache_time=360000) { // 60*60*5
$cache_dir = __DIR__.'/cache/';
$cache_file = $cache_dir.md5($url).'.cache';
@mkdir($cache_dir, 0775, true);
// return data from cached file if file exists and not expired
if(file_exists($cache_file) && filemtime($cache_file)+$cache_time >= time()) {
return(unserialize(file_get_contents($cache_file)));
}