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
/** | |
* Retrieves the best guess of the client's actual IP address. | |
* Takes into account numerous HTTP proxy headers due to variations | |
* in how different ISPs handle IP addresses in headers between hops. | |
*/ | |
function get_ip_address() { | |
// check for shared internet/ISP IP | |
if (!empty($_SERVER['HTTP_CLIENT_IP']) && validate_ip($_SERVER['HTTP_CLIENT_IP'])) { | |
return $_SERVER['HTTP_CLIENT_IP']; | |
} |
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
#!/bin/bash | |
#setup build essentials | |
yum install gcc gdbm-devel readline-devel ncurses-devel zlib-devel bzip2-devel sqlite-devel db4-devel openssl-devel tk-devel bluez-libs-devel | |
wget http://www.python.org/ftp/python/2.7.5/Python-2.7.5.tgz | |
tar zxvf Python-2.7.5.tgz | |
cd Python-2.7.5 | |
./configure --prefix=/usr/local/python27 --enable-shared | |
make altinstall | |
echo "/usr/local/python27/lib" >> /etc/ld.so.conf.d/usr-python27.conf |
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 | |
/* | |
* .htaccess | |
* <IfModule mod_rewrite.c> | |
* RewriteEngine on | |
* RewriteCond %{REQUEST_FILENAME} !-d | |
* RewriteCond %{REQUEST_FILENAME} !-f | |
* RewriteRule ^(.*)\.(.+)\.(css|js)$ $1.$3 [L] # Strip out the version number | |
* </IfModule> |
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
/** | |
* Generate a random UUID | |
* | |
* @see http://www.ietf.org/rfc/rfc4122.txt | |
* @return RFC 4122 UUID | |
*/ | |
function uuid() { | |
$node = $_SERVER['SERVER_ADDR']; | |
if (strpos($node, ':') !== false) { |
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
//Set mobile check to true | |
$mobile_check = true; | |
if (preg_match('/bot|ipad|xoom|sch-i800|playbook|tablet|kindle/i',$_SERVER['HTTP_USER_AGENT'])) { | |
$mobile_check = false; | |
} | |
if ( isset($_GET['desktop']) && !empty($_GET['desktop']) ) { | |
$mobile_check = false; | |
setcookie('desktop', 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
#!/bin/sh | |
# Only publish the last 2 digits of an IP address, do not expose the complete network range | |
# place this script post testing some were like /etc/rc.local, were issues like dynamic address, or cloned machines in cloud env will have an updated IP address in http header | |
# This script should run before http starts, experiment to get it right. | |
# Configuration section | |
network_id='192.168' # first 2 digits of the IP address identifying the network, usually would be an private ip address reange. | |
partial_ip_address=`ifconfig | grep 'inet addr:' | grep $network_id | awk -F: '{print $2}' | awk '{print $1}' | awk -F. '{print $3"."$4}'` | |
apache_conf_file='/etc/apache2/conf.d/X-fry' # RHEL/CentOS could be /etc/http/conf.d/X-fry |
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/php5 | |
<?php | |
/* | |
Apache2 Log format in Json | |
LogFormat "{ \"@timestamp\": \"%{%Y-%m-%dT%H:%M:%S%z}t\", \"@fields\": { \"client\": \"%a\", \"duration_usec\": %D, \"status\": %s, \"request\": \"%U%q\", \"method\": \"%m\", \"referrer\": \"%{Referer}i\" } }" log_json | |
CustomLog "|/var/www/mongolog.php" log_json | |
*/ |
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
$cdnHosts = array( //declared in an global config | |
'h1.hostname.com', | |
'h2.hostname.com', | |
'h3.hostname.com', | |
'h4.hostname.com' | |
); | |
/** | |
* | |
* cdnHostNames |