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 similar of MVC sistem | |
function view ( $file , $data = null){ | |
// IF data different of null and diferrent than array | |
if($data!= NULL && !is_array($data)){ | |
// Erro, expection. | |
throw new Exception('Data view isn\'t valid!'); | |
return false; | |
} |
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 | |
// Exists functions gmp_gcd ? | |
if(!function_exists('gmp_gcd')){ | |
// No, so create | |
// find greatest common divisor | |
function gmp_gcd($a, $b) { | |
while ($b != 0) | |
$remainder = $a % $b; | |
$a = $b; |
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
(c) Copyright 2012 Jonathan Fontes. | |
Licensed under the MIT license: | |
http://www.opensource.org/licenses/mit-license.php | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
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 | |
require 'site_url.php'; | |
echo site_url(array('blog','como-criar-url')); | |
// output: http://www.jonathanfontes.pt/blog/como-criar-url | |
echo site_url('blog/como-criar-url'); | |
// output: http://www.jonathanfontes.pt/blog/como-criar-url |
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 generatePassword ($length = 8) { | |
$password = ""; | |
$possible = "2346789bcdfghjkmnpqrtvwxyzBCDFGHJKLMNPQRTVWXYZ"; | |
$maxlength = strlen($possible); | |
// check for length overflow and truncate if necessary | |
if ($length > $maxlength) { | |
$length = $maxlength; |
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 | |
interface IException | |
{ | |
/* Protected methods inherited from Exception class */ | |
public function getMessage(); // Exception message | |
public function getCode(); // User-defined Exception code | |
public function getFile(); // Source filename | |
public function getLine(); // Source line | |
public function getTrace(); // An array of the backtrace() | |
public function getTraceAsString(); // Formated string of trace |
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 cleanForShortURL($toClean) { | |
$charactersToRemove = array( | |
'Š'=>'S', 'š'=>'s', 'Ð'=>'Dj','Ž'=>'Z', 'ž'=>'z', 'À'=>'A', 'Á'=>'A', 'Â'=>'A', 'Ã'=>'A', 'Ä'=>'A', | |
'Å'=>'A', 'Æ'=>'A', 'Ç'=>'C', 'È'=>'E', 'É'=>'E', 'Ê'=>'E', 'Ë'=>'E', 'Ì'=>'I', 'Í'=>'I', 'Î'=>'I', | |
'Ï'=>'I', 'Ñ'=>'N', 'Ò'=>'O', 'Ó'=>'O', 'Ô'=>'O', 'Õ'=>'O', 'Ö'=>'O', 'Ø'=>'O', 'Ù'=>'U', 'Ú'=>'U', | |
'Û'=>'U', 'Ü'=>'U', 'Ý'=>'Y', 'Þ'=>'B', 'ß'=>'Ss','à'=>'a', 'á'=>'a', 'â'=>'a', 'ã'=>'a', 'ä'=>'a', | |
'å'=>'a', 'æ'=>'a', 'ç'=>'c', 'è'=>'e', 'é'=>'e', 'ê'=>'e', 'ë'=>'e', 'ì'=>'i', 'í'=>'i', 'î'=>'i', |
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 | |
/* ---------------------------------------------------------- */ | |
/* minibots.class.php Ver.1.9g */ | |
/* ---------------------------------------------------------- */ | |
/* Mini Bots class is a small php class that allows you to */ | |
/* use some free web seriveces online to retrive usefull data */ | |
/* and infos. This version includes: */ | |
/* smtp validation, check spelling, meteo, exchange rates, */ | |
/* shorten urls, and geo referencing with IP address and more */ | |
/* Feel free to use in your applications, but link my blog: */ |
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
function emptySet(x) { | |
return false; | |
} | |
function insert(elem, set) { | |
return function(x) { | |
if (x === elem) { // insert smarter comparison here if needed | |
return true; | |
} | |
return function() { return contains(x, set); }; |
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 output ( $str, $tabs = 0, $date = TRUE, $silent = FALSE ) | |
{ | |
// Silent echo's | |
if( !empty($silent)) | |
{ | |
return FALSE; | |
} | |
if( is_array($str)) |
OlderNewer