├── liftoff.php └── README.markdown /liftoff.php: -------------------------------------------------------------------------------- 1 | VirtualHostX Liftoff. 6 | Author: Tyler Hall 7 | Version: 1.0 8 | Author URI: http://clickontyler.com/ 9 | */ 10 | 11 | if(!class_exists('VHXLiftOff')) 12 | { 13 | class VHXLiftOff 14 | { 15 | protected static $instance; 16 | 17 | public function __construct() 18 | { 19 | if(isset($_COOKIE['VHXOriginalHost'])) 20 | { 21 | add_filter('option_home', array(&$this, 'filterDomain'), 20); 22 | add_filter('option_siteurl', array(&$this, 'filterDomain'), 20); 23 | add_filter('theme_root_uri', array(&$this, 'filterDomain'), 20); 24 | } 25 | } 26 | 27 | public function filterDomain($url) 28 | { 29 | $parts = parse_url($url); 30 | $user_pass = $port = $query = $fragment = null; 31 | 32 | if($parts['user']) 33 | { 34 | $user_pass = $parts['user']; 35 | if($parts['pass']) 36 | $user_pass .= ':' . $parts['pass']; 37 | 38 | $user_pass .= '@'; 39 | } 40 | 41 | if($parts['port']) 42 | $port = ':' . $parts['port']; 43 | 44 | if($parts['query']) 45 | $query = '?' . $parts['query']; 46 | 47 | if($parts['fragment']) 48 | $query = '#' . $parts['fragment']; 49 | 50 | return sprintf('%s://%s%s%s%s%s%s', $parts['scheme'], $user_pass, $_COOKIE['VHXOriginalHost'], $port, $parts['path'], $query, $fragment); 51 | } 52 | } 53 | } 54 | 55 | if(class_exists('VHXLiftOff')) 56 | { 57 | $vhxliftoff = new VHXLiftOff(); 58 | } 59 | -------------------------------------------------------------------------------- /README.markdown: -------------------------------------------------------------------------------- 1 | VHX-Liftoff-Wordpress-Plugin 2 | ========= 3 | 4 | A WordPress plugin that enables your website to work with [VirtualHostX Lift Off](http://clickontyler.com/virtualhostx/liftoff/). 5 | 6 | INSTALL 7 | ------- 8 | 9 | The Lift Off plugin installs like any other WordPress plugin. 10 | 11 | * Copy `liftoff.php` into your blog's `wp-content/plugins/` directory. 12 | * Navigate to your blog's Admin Dashboard, click on "Plugins" and activate "VirtualHostX Liftoff". 13 | 14 | You're done! 15 | 16 | TECHNICAL DESCRIPTION 17 | --------------------- 18 | 19 | The Lift Off service inserts a `VHXOriginalHost` cookie into each HTTP request it proxies. This 20 | plugin looks for that cookie and, if detected, alters your blog's URL on the fly to match the 21 | original Lift Off hostname. It does this by inserting filters for 22 | 23 | * option_home 24 | * option_siteurl 25 | * theme_root_uri 26 | 27 | An earlier version of Lift Off inserted a special HTTP header instead of relying on a cookie, but we 28 | found certain security hardened versions of PHP stripped out the header. Cookies, however, made it 29 | through. 30 | 31 | LICENSE 32 | ------- 33 | 34 | The MIT License 35 | 36 | Copyright (c) 2011 Tyler Hall 37 | 38 | Permission is hereby granted, free of charge, to any person obtaining a copy 39 | of this software and associated documentation files (the "Software"), to deal 40 | in the Software without restriction, including without limitation the rights 41 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 42 | copies of the Software, and to permit persons to whom the Software is 43 | furnished to do so, subject to the following conditions: 44 | 45 | The above copyright notice and this permission notice shall be included in 46 | all copies or substantial portions of the Software. 47 | 48 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 49 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 50 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 51 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 52 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 53 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 54 | THE SOFTWARE. 55 | --------------------------------------------------------------------------------