This file contains 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 | |
session_start(); | |
date_default_timezone_set ('America/Sao_Paulo'); | |
define ('DS', DIRECTORY_SEPARATOR); | |
define ('URL', "http://".$_SERVER['SERVER_NAME']); | |
define ('ENVIRONMENT' , 'DEV'); | |
spl_autoload_register('autoload'); |
This file contains 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 | |
$uriPath = parse_url ($_SERVER['REQUEST_URI'], PHP_URL_PATH); | |
$uriPath = explode('/', trim($uriPath, '/') ); | |
$page = reset($uriPath); | |
require $page . '.php'; |
This file contains 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
RewriteEngine On | |
RewriteBase / | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteRule !(css|js|jpg|png) ./index.php |
This file contains 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 strRand($qtd) | |
{ | |
$chars = implode(array_merge(range(0, 9),range('A', 'Z'),range('a', 'z'))); | |
return substr(str_shuffle($chars), 0, $qtd); | |
} | |
$str = strRand(5); | |
echo "look: " . $str; |
This file contains 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 copyDir($source,$destination) | |
{ | |
if(!is_dir($destination)) | |
mkdir($destination, 0777); | |
chmod($destination, 0777); | |
$it = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($source), | |
\RecursiveIteratorIterator::SELF_FIRST); |
This file contains 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 listEncodingPath($path) | |
{ | |
$finfo = new finfo(FILEINFO_MIME_ENCODING, "/usr/share/misc/magic"); | |
foreach(new DirectoryIterator($path) as $file) | |
if(!$file->isDot() && !$file->isDir()) | |
$return[$file->getBasename()] = $finfo->file($file->getPathname()); | |
return $return; | |
} |
This file contains 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 //Run as command line. Input file as first argument. | |
const G_FOO = 'aeiou'; //Googlon special letters | |
const G_INV = 'z'; //Preposition invalidator | |
const G_PREP = 3; //Preposition size | |
const G_VERB = 8; //Verb size | |
const G_ORDER = 'qnbczxjtklmvhrwfsdgp'; //Letter ordering | |
const G_NUM_MOD = 4; //Pretty number divisor | |
const G_NUM_MAX = 526593; //Pretty number minimum | |
$textB = explode(' ', file_get_contents($argv[1])); |
This file contains 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 A { | |
public static function who() { | |
echo get_called_class(); | |
} | |
public static function whoParent() { | |
echo get_parent_class(get_called_class()); | |
} |
This file contains 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 | |
// encontrada nesse link | |
// http://www.php.net/manual/en/function.htmlentities.php | |
function ascii2entities($string){ | |
for($i=128;$i<=255;$i++){ | |
$entity = htmlentities(chr($i), ENT_QUOTES, 'cp1252'); | |
$temp = substr($entity, 0, 1); | |
$temp .= substr($entity, -1, 1); |
This file contains 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 deleteDir($source) | |
{ | |
if(!is_dir($source)) | |
return false; | |
$it = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($source), | |
\RecursiveIteratorIterator::SELF_FIRST); | |
$it->next(); |
OlderNewer