X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fsettings.php;h=bd779ad4e50fe906baf0420a28f0a10d6442d77f;hb=a93f5627c1cb05f2f2c14cc390d38799eaf461e8;hp=1abb60fccb1405e7229c56dc959cbb4eeee109e4;hpb=a26f4eeff6edcb49ad2e7607512853ddd24374cc;p=friendica.git diff --git a/mod/settings.php b/mod/settings.php index 1abb60fccb..bd779ad4e5 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -3,20 +3,20 @@ function settings_init(&$a) { - if((! x($_SESSION,'authenticated')) && (x($_SESSION,'uid'))) { - $_SESSION['sysmsg'] .= "Permission denied." . EOL; + if(! local_user()) { + notice("Permission denied." . EOL); $a->error = 404; return; } require_once("mod/profile.php"); - profile_load($a,$_SESSION['uid']); + profile_load($a,$a->user['nickname']); } function settings_post(&$a) { - if((! x($_SESSION['authenticated'])) && (! (x($_SESSION,'uid')))) { - $_SESSION['sysmsg'] .= "Permission denied." . EOL; + if(! local_user()) { + notice( "Permission denied." . EOL); return; } if(count($a->user) && x($a->user,'uid') && $a->user['uid'] != $_SESSION['uid']) { @@ -53,13 +53,10 @@ function settings_post(&$a) { $username = notags(trim($_POST['username'])); $email = notags(trim($_POST['email'])); - if(x($_POST,'nick')) - $nick = notags(trim($_POST['nick'])); $timezone = notags(trim($_POST['timezone'])); $username_changed = false; $email_changed = false; - $nick_changed = false; $zone_changed = false; $err = ''; @@ -81,19 +78,6 @@ function settings_post(&$a) { if($r !== NULL && count($r)) $err .= " This email address is already registered." . EOL; } - if((x($nick)) && ($nick != $a->user['nickname'])) { - $nick_changed = true; - if(! preg_match("/^[a-zA-Z][a-zA-Z0-9\-\_]*$/",$nick)) - $err .= " Nickname must start with a letter and contain only contain letters, numbers, dashes, and underscore."; - $r = q("SELECT `uid` FROM `user` - WHERE `nickname` = '%s' LIMIT 1", - dbesc($nick) - ); - if($r !== NULL && count($r)) - $err .= " Nickname is already registered. Try another." . EOL; - } - else - $nick = $a->user['nickname']; if(strlen($err)) { $_SESSION['sysmsg'] .= $err . EOL; @@ -104,11 +88,10 @@ function settings_post(&$a) { if(strlen($timezone)) date_default_timezone_set($timezone); } - if($email_changed || $username_changed || $nick_changed || $zone_changed ) { - $r = q("UPDATE `user` SET `username` = '%s', `email` = '%s', `nickname` = '%s', `timezone` = '%s' WHERE `uid` = %d LIMIT 1", + if($email_changed || $username_changed || $zone_changed ) { + $r = q("UPDATE `user` SET `username` = '%s', `email` = '%s', `timezone` = '%s' WHERE `uid` = %d LIMIT 1", dbesc($username), dbesc($email), - dbesc($nick), dbesc($timezone), intval($_SESSION['uid'])); if($r) @@ -119,17 +102,6 @@ function settings_post(&$a) { // FIXME - set to un-verified, blocked and redirect to logout } - if($nick_changed) { - $r = q ("UPDATE `profile` SET `url` = '%s', `request` = '%s', `notify` = '%s', `poll` = '%s', `confirm` = '%s' - WHERE `uid` = %d AND `self` = 1 LIMIT 1", - dbesc( $a->get_baseurl() . '/profile/' . $nick ), - dbesc( $a->get_baseurl() . '/dfrn_request/' . $nick ), - dbesc( $a->get_baseurl() . '/dfrn_notify/' . $nick ), - dbesc( $a->get_baseurl() . '/dfrn_poll/' . $nick ), - dbesc( $a->get_baseurl() . '/dfrn_confirm/' . $nick ), - intval($_SESSION['uid']) - ); - } // Refresh the content display with new data @@ -156,15 +128,26 @@ function settings_content(&$a) { $timezone = $a->user['timezone']; - if(x($nickname)) - $nickname_block = file_get_contents("view/settings_nick_set.tpl"); - else - $nickname_block = file_get_contents("view/settings_nick_unset.tpl"); + + $nickname_block = file_get_contents("view/settings_nick_set.tpl"); + + + $nickname_subdir = ''; + if(strlen($a->get_path())) { + $subdir_tpl = file_get_contents('view/settings_nick_subdir.tpl'); + $nickname_subdir = replace_macros($subdir_tpl, array( + '$baseurl' => $a->get_baseurl(), + '$nickname' => $nickname, + '$hostname' => $a->get_hostname() + )); + } + $nickname_block = replace_macros($nickname_block,array( '$nickname' => $nickname, '$uid' => $_SESSION['uid'], - '$basepath' => substr($a->get_baseurl(),strpos($a->get_baseurl(),'://') + 3), + '$subdir' => $nickname_subdir, + '$basepath' => $a->get_hostname(), '$baseurl' => $a->get_baseurl())); $o = file_get_contents('view/settings.tpl');