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 | |
| public static function DB($query = null) | |
| { | |
| static $db = array(); | |
| static $result = array(); | |
| if (isset($db[self::$id], $query) === true) | |
| { | |
| if (empty($result[self::$id][$hash = md5($query)]) === true) |
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 | |
| public static function Dump() | |
| { | |
| foreach (func_get_args() as $argument) | |
| { | |
| switch (gettype($argument)) | |
| { | |
| case 'array': | |
| case 'object': |
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 | |
| public static function Typography($string, $quotes = true) | |
| { | |
| if ($quotes === true) | |
| { | |
| $string = preg_replace(array("~'([^']+)'~", '~"([^"]+)"~'), array('‘$1’', '“$1”'), $string); | |
| } | |
| return preg_replace(array('~[.]{2,}~', '~--~', '~-~', '~(?<=\d)(st|nd|rd|th)\b~i'), array('…', '—', '–', '<sup>$1</sup>'), $string); |
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 | |
| /** | |
| * The MIT License | |
| * http://creativecommons.org/licenses/MIT/ | |
| * | |
| * Copyright (c) Alix Axel <alix.axel@gmail.com> | |
| **/ | |
| class phunction_HTML_Form extends phunction_HTML |
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 isVATIN($vatin) | |
| { | |
| if (preg_match('~^[125689][0-9]{8}$~', $vatin) > 0) | |
| { | |
| $vatin = str_split($vatin); | |
| foreach (array_slice($vatin, 0, -1) as $key => $value) | |
| { |
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 | |
| /** plugin_DatabaseHide.php | |
| * @author Alix Axel | |
| * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0 | |
| */ | |
| class AdminerDatabaseHide { | |
| protected $disabled; | |
| function AdminerDatabaseHide($disabled) { |
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 | |
| /** | |
| * Download a large distant file to a local destination. | |
| * | |
| * This method is very memory efficient :-) | |
| * The file can be huge, PHP doesn't load it in memory. | |
| * | |
| * /!\ Warning, the return value is always true, you must use === to test the response type too. | |
| * | |
| * @author dalexandre |
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
| These weights are often combined into a tf-idf value, simply by multiplying them together. The best scoring words under tf-idf are uncommon ones which are repeated many times in the text, which lead early web search engines to be vulnerable to pages being stuffed with repeated terms to trick the search engines into ranking them highly for those keywords. For that reason, more complex weighting schemes are generally used, but tf-idf is still a good first step, especially for systems where no one is trying to game the system. | |
| There are a lot of variations on the basic tf-idf idea, but a straightforward implementation might look like: | |
| <?php | |
| $tfidf = $term_frequency * // tf | |
| log( $total_document_count / $documents_with_term, 2); // idf | |
| ?> | |
| It's worth repeating that the IDF is the total document count over the count of the ones containing the term. So, if there were 50 documents in the collection, and two of them contained the term in question, the IDF would be 50/2 = 25. To be accurate, we s |
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 | |
| /** | |
| * This function computes a hash of an integer. This can be used to not expose values to a customer, such as | |
| * not giving them the id value for passing them to URLs. This algorithm is a bidirectional encryption (Feistel cipher) that maps | |
| * the integer space onto itself. | |
| * | |
| * @link http://wiki.postgresql.org/wiki/Pseudo_encrypt Algorithm used | |
| * @link http://en.wikipedia.org/wiki/Feistel_cipher Wikipedia page about Feistel ciphers | |
| * @param int $value | |
| * @return int |
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 | |
| /* | |
| * What about asking PHP to figure out the relation path!???? AWESOME! | |
| */ | |
| // url.user_id -> belongs_to -> users.id | |
| $start = 'vote'; // We have a vote | |
| $end = 'user'; // We have a user |