diff --git a/.gitattributes b/.gitattributes index be1b039..02c94b5 100644 --- a/.gitattributes +++ b/.gitattributes @@ -22,6 +22,7 @@ # Server config files. *.admins text *.cfg text +*.cnf text *.conf text *.htaccess text *.htaccess-apache text @@ -31,8 +32,14 @@ # CSS/JavaScript files. *.css text *.js text +*.css.map text +*.js.map text *.json text +# Applescript files. +*.applescript text +*.scpt binary + # PHP scripts/files. *.inc text *.php text @@ -140,4 +147,4 @@ *.dll binary *.exe binary *.sh text -*.so binary \ No newline at end of file +*.so binary diff --git a/.gitignore b/.gitignore index 2b70c04..12e3bd4 100644 --- a/.gitignore +++ b/.gitignore @@ -8,9 +8,15 @@ *~ *.bak +# Node +node_modules/ +npm-debug.log + +# SASS +.sass-cache/ + # IntelliJ .idea/ -*.iml *.ipr *.iws @@ -49,10 +55,13 @@ Icon? # Amazon Web Services .elasticbeanstalk/ -# For shell glob patterns. This includes GIT files too. We simply maintain this list together with `.gitignore`. -# .~*;*~;*.bak;.idea;*.iml;*.ipr;*.iws;*.sublime-workspace;*.sublime-project;.git;.gitignore;.gitattributes;CVS;.cvsignore;.svn;_svn;.bzr;.bzrignore;.hg;.hgignore;SCCS;RCS;$RECYCLE.BIN;Desktop.ini;Thumbs.db;ehthumbs.db;.Spotlight-V100;.AppleDouble;.LSOverride;.DS_Store;.Trashes;.elasticbeanstalk +# Vagrant +.vagrant/ + +# For shell glob patterns. This includes Git files too. We simply maintain this list together with `.gitignore`. +# .~*;*~;*.bak;node_modules;npm-debug.log;.idea;*.ipr;*.iws;*.sublime-workspace;*.sublime-project;.git;.gitignore;.gitattributes;CVS;.cvsignore;.svn;_svn;.bzr;.bzrignore;.hg;.hgignore;SCCS;RCS;$RECYCLE.BIN;Desktop.ini;Thumbs.db;ehthumbs.db;.Spotlight-V100;.AppleDouble;.LSOverride;.DS_Store;.Trashes;._*;.elasticbeanstalk;.vagrant # This list is for IntelliJ IDEA / PhpStorm `File Types` configuration. Some files we actually WANT to work with as part of a project. -# .idea;*.iml;*.ipr;*.iws;*.sublime-workspace;*.sublime-project;.git;CVS;.svn;_svn;.bzr;.hg;SCCS;RCS;$RECYCLE.BIN;Desktop.ini;Thumbs.db;ehthumbs.db;.Spotlight-V100;.AppleDouble;.LSOverride;.DS_Store;.Trashes;._* +# .sass-cache;.idea;*.ipr;*.iws;*.sublime-workspace;*.sublime-project;.git;CVS;.svn;_svn;.bzr;.hg;SCCS;RCS;$RECYCLE.BIN;Desktop.ini;Thumbs.db;ehthumbs.db;.Spotlight-V100;.AppleDouble;.LSOverride;.DS_Store;.Trashes;._*;.vagrant -# We also need to update the WebSharks™ Core `dirs_files::ignore()` method if this changes. \ No newline at end of file +# We also need to update the WebSharks™ Core `dirs_files::ignore()` method if this changes. diff --git a/zencache/includes/share.php b/zencache/includes/share.php index cb9e343..e48399f 100644 --- a/zencache/includes/share.php +++ b/zencache/includes/share.php @@ -989,6 +989,7 @@ public function has_a_cacheable_status() * @return string Real IP address, else `unknown` on failure. * * @note This supports both IPv4 and IPv6 addresses. + * @note See my tests against this here: http://3v4l.org/fVWUp */ public function current_ip() { @@ -998,11 +999,9 @@ public function current_ip() static::$static[__FUNCTION__] = ''; // Initialize. $ip = &static::$static[__FUNCTION__]; - $_s = $_SERVER; // Copy of current `$_SERVER` vars. - - if($this->apply_filters(__METHOD__.'_prioritize_remote_addr', FALSE)) - if(($REMOTE_ADDR = $this->valid_public_ip($_s['REMOTE_ADDR']))) - return ($ip = $REMOTE_ADDR); + if(!empty($_SERVER['REMOTE_ADDR']) && $this->apply_filters(__METHOD__.'_prioritize_remote_addr', FALSE)) + if(($_valid_public_ip = $this->valid_public_ip($_SERVER['REMOTE_ADDR']))) + return ($ip = $_valid_public_ip); $sources = array( 'HTTP_CF_CONNECTING_IP', @@ -1018,12 +1017,15 @@ public function current_ip() $sources = $this->apply_filters(__METHOD__.'_sources', $sources); foreach($sources as $_source) // Try each of these; in order. - if(!isset($$_source) && ($$_source = $this->valid_public_ip($_s[$_source]))) - return ($ip = $$_source); // A valid, public IPv4 or IPv6 address. - unset($_source); // Housekeeping. + { + if(!empty($_SERVER[$_source])) // Does the source key exist at all? + if(($_valid_public_ip = $this->valid_public_ip($_SERVER[$_source]))) + return ($ip = $_valid_public_ip); // A valid public IPv4 or IPv6 address. + } + unset($_source, $_valid_public_ip); // Housekeeping. - if(!empty($_s['REMOTE_ADDR']) && is_string($_s['REMOTE_ADDR'])) - return ($ip = strtolower($_s['REMOTE_ADDR'])); + if(!empty($_SERVER['REMOTE_ADDR']) && is_string($_SERVER['REMOTE_ADDR'])) + return ($ip = strtolower($_SERVER['REMOTE_ADDR'])); return ($ip = 'unknown'); // Not possible. } @@ -1031,23 +1033,25 @@ public function current_ip() /** * Gets a valid/public IP address. * - * @param string $possible_ips A single IP, or a possible comma-delimited list of IPs. - * Pass by reference to avoid PHP notices while checking multiple sources. + * @param string $list_of_possible_ips A single IP, or a comma-delimited list of IPs. * * @return string A valid/public IP address (if one is found), else an empty string. * * @note This supports both IPv4 and IPv6 addresses. * @note See my tests against this here: http://3v4l.org/fVWUp */ - public function valid_public_ip(&$possible_ips) + public function valid_public_ip($list_of_possible_ips) { - if(!$possible_ips || !is_string($possible_ips)) + if(!$list_of_possible_ips || !is_string($list_of_possible_ips)) return ''; // Empty or invalid data. - foreach(preg_split('/[\s;,]+/', trim($possible_ips), NULL, PREG_SPLIT_NO_EMPTY) as $_possible_ip) - if(($_possible_ip = filter_var(strtolower($_possible_ip), FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE))) - return $_possible_ip; // A valid, public IPv4 or IPv6 address. - unset($_possible_ip); // Housekeeping. + if(!($list_of_possible_ips = trim($list_of_possible_ips))) + return ''; // Not possible; i.e., empty string. + + foreach(preg_split('/[\s;,]+/', $list_of_possible_ips, NULL, PREG_SPLIT_NO_EMPTY) as $_possible_ip) + if(($_valid_public_ip = filter_var(strtolower($_possible_ip), FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE))) + return $_valid_public_ip; // A valid public IPv4 or IPv6 address. + unset($_possible_ip, $_valid_public_ip); // Housekeeping. return ''; // Default return value. }