IP Detection

This little snippet tries to get the IP-Address of the user: private function _detectIP(){ //Mage::log(‘_detectIP’, null, __CLASS__.’.log’, true); if (getenv(‘HTTP_CLIENT_IP’)) { $this->_ip = getenv(‘HTTP_CLIENT_IP’); Mage::log(‘Detected IP (getenv(\’HTTP_CLIENT_IP\’)):’, null, __CLASS__.’.log’, true); Mage::log($this->_ip, null, __CLASS__.’.log’, true); } elseif (getenv(‘HTTP_X_FORWARDED_FOR’)) { $ips = explode(‘,’, getenv(‘HTTP_X_FORWARDED_FOR’)); $this->_ip = (string)trim($ips[0]); } elseif (getenv(‘HTTP_X_FORWARDED’)) { $ips = explode(‘,’, getenv(‘HTTP_X_FORWARDED’)); $this->_ip = […]

Xdebug

Manual Install The following Instructions based on http://xdebug.org/wizard.php help you to install it manually: Download the latest version (xdebug-x.x.x.tgz) from  http://xdebug.org/download.php Unpack the downloaded file with: $> tar -xvzf xdebug-x.x.x.tgz On shell run: $> cd xdebug-2.2.3 $> phpize #(See the FAQ if you don’t have phpize. Result should be: Configuring for: … Zend Module Api […]

Run PHP script with parameters within another PHP script

Recently I had to call a PHP script within another script with some arguments. Normally you pass these parameters by GET or POST. But how to do it within another script? Here is how to run PHP script with parameters within another PHP script: //set arguments $_SERVER[‘argv’][1] = ‘-action’; $_SERVER[‘argv’][2] = ‘unsetMaintenanceMode’; $_SERVER[‘argv’][3] = ‘-initRedis’; $_SERVER[‘argv’][4] […]