Skip to content

Instantly share code, notes, and snippets.

View Zorono's full-sized avatar
😌
I may be slow to respond.

John Magdy Lotfy Kamel Zorono

😌
I may be slow to respond.
View GitHub Profile
@Zorono
Zorono / datebirth.php
Last active October 4, 2019 22:28
It calculates the Age with full detailes (Y/M/H/m/s/ms/ns/ms) in PHP by Date of Birth with the following Syntax: Year-Month-Day
<?php
$daofbi = array('year' => 2002, 'month' => 9, 'day' => 16);
$aprox_age = (date("Y") - date("Y", strtotime(join('-', $daofbi))));
$BDToday = (bool)($daofbi['year'] == date("Y") || $daofbi['month'] == date("m"));
$Username = "[BR]John_Magdy";
echo 'Age(approximate): ' .$aprox_age. '<br />';
$dabi = new DateTime(join('-', $daofbi), new DateTimeZone(date_default_timezone_get()));
$today = new DateTime("now", new DateTimeZone(date_default_timezone_get()));
echo 'Age(specifically): ' .$today->diff($dabi)->format('%y Years, %m Months, %d Days, %h Hours, %I Minutes, %s Seconds, ' . ($today->diff($dabi)->format('%s')*1000) . ' Milliseconds, ' . ($today->diff($dabi)->format('%s')*1000*1000000) . ' Nanoseconds, ' . ($today->diff($dabi)->format('%s')*1000*1000) . ' Microseconds');
echo '<br />Day of Birth: ' .$dabi->format('D');
<?php
function OpenFile($fini, $mode = 'w', $data = array('tag' => '', 'fields' => array()), $ac_on_error = False)
{
$File = array();
switch($mode)
{
case 'w': {
$File['file'] = fopen($fini, 'a') or new \Exception('[INI-Handler]: Couldn\'t open the speciefied "'. $fini .'" file!');
if((is_array($data) && is_array($data['fields'])) && (count($data) >= 1 && count($data['fields']) >= 1))
{
<?php
const OPENSSL_ENCRYPTz = 0;
const OPENSSL_DECRYPTz = 1;
function OpenSSLEndeCrypt($action = OPENSSL_ENCRYPTz, $string = '', $ende_options = OPENSSL_RAW_DATA, $encrypt_method = "AES-256-CBC")
{
$output = NULL;
$key = hash("sha256", openssl_random_pseudo_bytes(32), True);
$iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length($encrypt_method));
if ($action == OPENSSL_ENCRYPTz)
{
var $_GET = {};
if(document.location.toString().indexOf('?') !== -1)
{
var query = document.location.toString() .replace(/^.*?\?/, '').replace(/#.*$/, '').split('&');
for(var i=0, l=query.length; i<l; i++)
{
var aux = decodeURIComponent(query[i]).split('=');
$_GET[aux[0]] = aux[1];
}
}
<?php
function parse_user_agent($user_agent)
{
global $txt;
$client_data = array(
'system' => "",
'system_icon' => "unknown",
'browser' => "",
'browser_icon' => "unknown"
<?php
$timezone = new DateTime("now", new DateTimeZone(date_default_timezone_get()));
echo '#1: ' . $timezone->format('c') . '<br />';
echo '#2: ' . date("Y-m-d\TH:i:s." .round(microtime(True) * 1000). "\\" . $timezone->format('P')) . '<br />'; // the microseconds is detailed more than others...
echo '#3: ' . date("c") . '<br />';
echo '#4: ' . $timezone->format(DateTime::ISO8601); // the timezone offest doesn't contain the 's' symbol....
?>
<?php
ini_set("display_errors", 1);
ini_set("track_errors", 1);
ini_set("html_errors", 1);
ini_set('memory_limit', '250M');
set_time_limit(0);
error_reporting(E_ALL);
?>
<?php
function ReturnTimeLapse($start, $till)
{
$time = array(
'second' => $till - $start,
'minute' => 60,
'hour' => 60*60,
'day' => 60*60*24,
'month' => 60*60*24*30
);
.badge {
display:inline-block;
padding-left:8px;
padding-right:8px;
text-align:center;
border-radius:50%;
margin-left:16px;
background-color:rgba(255, 152, 0, 0.75);
color:rgb(255, 255, 255);
}
@Zorono
Zorono / image_base64_encoding.php
Last active September 9, 2018 16:29
Image Base64 Encoding...(PHP)
<?php
$img_url = (preg_match('/\%[0-9A-F]{2}|\+/', $_GET['url']) !== False ? urldecode($_GET['url']) : $_GET['url']);
if($img_content = @file_get_contents($img_url))
{
if(strlen(mime_content_type($img_url)) > 2 ? strpos(mime_content_type($img_url), 'image/') !== False : True)
{
$_finfo = new finfo();
$img_mime = $_finfo->file($img_url, FILEINFO_MIME_TYPE);
echo '<img src="data:' .(isset($img_mime) && strlen($img_mime) > 2 ? $img_mime : "image/jpeg"). ';base64,' .base64_encode($img_content). '" />';
}