block attempts to set the baseurl to an ip address if it was previously a dns name

This commit is contained in:
friendica 2013-08-29 16:46:22 -07:00
parent b4bd518e40
commit 70c0beb857
4 changed files with 25 additions and 12 deletions

View File

@ -1164,10 +1164,22 @@ function check_config(&$a) {
set_config('system','urlverify',bin2hex(z_root()));
if(($saved) && ($saved != bin2hex(z_root()))) {
// our URL changed. Do something.
$oldurl = hex2bin($saved);
$oldhost = substr($oldurl,strpos($oldurl,'//')+2);
$host = substr(z_root(),strpos(z_root(),'//')+2);
$is_ip_addr = ((preg_match("/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/",$host)) ? true : false);
$was_ip_addr = ((preg_match("/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/",$oldhost)) ? true : false);
// only change the url to an ip address if it was already an ip and not a dns name
if((! $is_ip_addr) || ($is_ip_addr && $was_ip_addr)) {
fix_system_urls($oldurl,z_root());
set_config('system','urlverify',bin2hex(z_root()));
}
else
logger('Attempt to change baseurl from a DNS name to an IP address was refused.');
}
// This will actually set the url to the one stored in .htconfig, and ignore what
// we're passing - unless we are installing and it has never been set.

View File

@ -6,6 +6,7 @@ require_once('include/page_widgets.php');
function page_init(&$a) {
// We need this to make sure the channel theme is always loaded.
$which = argv(1);
$profile = 0;
$channel = $a->get_channel();

View File

@ -997,7 +997,7 @@ function settings_content(&$a) {
$stpl = get_markup_template('settings.tpl');
$celeb = ((($a->user['page-flags'] == PAGE_SOAPBOX) || ($a->user['page-flags'] == PAGE_COMMUNITY)) ? true : false);
$celeb = false;
$expire_arr = array(
'days' => array('expire', t("Automatically expire posts after this many days:"), $expire, t('If empty, posts will not expire. Expired posts will be deleted')),

View File

@ -1 +1 @@
2013-08-28.419
2013-08-29.420