It's easy to get Magento get base url. Just use below code to retrieve base url.
Mage::getBaseUrl('type_of_link', 'secure_or_unsecure');
For example:
Mage::getBaseUrl(); // returns http://dltr.org/ Mage::getBaseUrl('web'); // returns url defined in system/config/web/(un)secure/base url // http://dltr.org/ Mage::getBaseUrl('link'); // returns url defined in system/config/web/(un)secure/base link url // http://dltr.org/ Mage::getBaseUrl('direct_link'); // same as 'link'; // http://dltr.org/ Mage::getBaseUrl('skin'); // returns url set on system/config/web/(un)secure/base skin url // http://dltr.org/skin/ Mage::getBaseUrl('js'); // returns url set on system/config/web/(un)secure/base javascript url // http://dltr.org/js/ Mage::getBaseUrl('media'); // returns url set on system/config/web/(un)secure/base media url // http://dltr.org/media/
Hope that helps.
Source: Mage.php and app\code\core\Mage\Core\Model\Store.php