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
#!/usr/bin/env bash | |
# Before executing it, you must download UnQLite source code (http://www.unqlite.org/downloads.html) | |
# unzip all the files and execute this script inside the unzipped folder. For example: | |
# mkdir /tmp/unqlite; cd /tmp/unqlite; unzip ~/Downloads/unqlite-db-116.zip | |
gcc -Wall -fPIC -c *.c | |
gcc -shared -Wl,-soname,libunqlite.so.1 -o libunqlite.so.1.0 *.o | |
sudo cp `pwd`/libunqlite.so.1.0 /usr/local/lib/ | |
sudo cp `pwd`/unqlite.h /usr/local/include/ | |
sudo ln -sf /usr/local/lib/libunqlite.so.1.0 /usr/local/lib/libunqlite.so.1 |
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 | |
// To the extent possible under law, I (Stephan Sokolow) waive all copyright and related or | |
// neighbouring rights to this code snippet. (Though it'd still be nice if you mention me) | |
// If we're running under `php -S` with PHP 5.4.0+ | |
if (php_sapi_name() == 'cli-server') { | |
// Replicate the effects of basic "index.php"-hiding mod_rewrite rules | |
// Tested working under FatFreeFramework 2.0.6 through 2.0.12. | |
$_SERVER['SCRIPT_NAME'] = str_replace(__DIR__, '', __FILE__); |
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 get_ip_address() { | |
$ip_keys = array('HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR'); | |
foreach ($ip_keys as $key) { | |
if (array_key_exists($key, $_SERVER) === true) { | |
foreach (explode(',', $_SERVER[$key]) as $ip) { | |
// trim for safety measures | |
$ip = trim($ip); | |
// attempt to validate IP | |
if (validate_ip($ip)) { |