This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?PHP | |
// Generate a random key of N size | |
$keySize = 256; | |
$key = bin2hex(openssl_random_pseudo_bytes($keySize/2)); | |
echo 'Generating Key of size: '.$keySize; | |
echo '<br />Key: '.$key; | |
echo '<br />Length: '.strlen($key); | |
die(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class PHPCache { | |
protected $path = null; | |
protected $durationInSeconds = null; | |
protected $filenamePrefix = null; | |
protected $disableCacheForAdmin = false; | |
function __construct ( $path, $filenamePrefix='phpcache-', $durationInSeconds = 60) { | |
$this->path = $path; | |
$this->filenamePrefix = $filenamePrefix; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?PHP | |
function truncate($text, $suffix="...",$maxLength=false,$maxWords=false){ | |
$text = trim($text); | |
$text = preg_replace("/[\s]+/", " ", $text); // convert all consecuritve spaces to single spaces | |
if($maxLength!==false){ | |
if(strlen($text)>$maxLength){ | |
$text = substr($text, 0, $maxLength).$suffix; | |
} | |
} | |
if($maxWords!==false){ |