X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fregmod.php;h=a772a78ce77e6b4ccdf9f2cc09317572b0defcbc;hb=3f85ee3ef8348dd2200c7bb05be6701689a649d5;hp=21f41eb01ccc3c854443f22e3465ba50cc3797fa;hpb=43d5876e8b35d53a0bef5248c5d63e5bc209dbbf;p=friendica.git diff --git a/mod/regmod.php b/mod/regmod.php index 21f41eb01c..a772a78ce7 100644 --- a/mod/regmod.php +++ b/mod/regmod.php @@ -1,135 +1,109 @@ false, 'verified' => true], ['uid' => $register['uid']]); - $r = q("UPDATE `user` SET `blocked` = 0, `verified` = 1 WHERE `uid` = %d LIMIT 1", - intval($register[0]['uid']) - ); - - $r = q("SELECT * FROM `profile` WHERE `uid` = %d AND `is-default` = 1", - intval($user[0]['uid']) - ); - if(count($r) && $r[0]['net-publish']) { - $url = $a->get_baseurl() . '/profile/' . $user[0]['nickname']; - if($url && strlen(get_config('system','directory_submit_url'))) - proc_run('php',"include/directory.php","$url"); - } + $profile = DBA::selectFirst('profile', ['net-publish'], ['uid' => $register['uid'], 'is-default' => true]); - push_lang($register[0]['language']); + if (DBA::isResult($profile) && $profile['net-publish'] && Config::get('system', 'directory')) { + $url = System::baseUrl() . '/profile/' . $user['nickname']; + Worker::add(PRIORITY_LOW, "Directory", $url); + } - $email_tpl = get_intltext_template("register_open_eml.tpl"); - $email_tpl = replace_macros($email_tpl, array( - '$sitename' => $a->config['sitename'], - '$siteurl' => $a->get_baseurl(), - '$username' => $user[0]['username'], - '$email' => $user[0]['email'], - '$password' => $register[0]['password'], - '$uid' => $user[0]['uid'] - )); + L10n::pushLang($register['language']); - $res = mail($user[0]['email'], sprintf(t('Registration details for %s'), $a->config['sitename']), - $email_tpl, - 'From: ' . t('Administrator') . '@' . $_SERVER['SERVER_NAME'] . "\n" - . 'Content-type: text/plain; charset=UTF-8' . "\n" - . 'Content-transfer-encoding: 8bit' ); + $res = User::sendRegisterOpenEmail( + $user, + Config::get('config', 'sitename'), + $a->getBaseUrl(), + defaults($register, 'password', 'Sent in a previous email') + ); - pop_lang(); + L10n::popLang(); - if($res) { - info( t('Account approved.') . EOL ); + if ($res) { + info(L10n::t('Account approved.') . EOL); return true; - } - + } } - // This does not have to go through user_remove() and save the nickname // permanently against re-registration, as the person was not yet // allowed to have friends on this system +function user_deny($hash) +{ + $register = Register::getByHash($hash); + if (!DBA::isResult($register)) { + return false; + } -function user_deny($hash) { + $user = User::getById($register['uid']); + if (!DBA::isResult($user)) { + exit(); + } - $register = q("SELECT * FROM `register` WHERE `hash` = '%s' LIMIT 1", - dbesc($hash) - ); + DBA::delete('user', ['uid' => $register['uid']]); - if(! count($register)) - return false; + Register::deleteByHash($register['hash']); - $user = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1", - intval($register[0]['uid']) - ); - - $r = q("DELETE FROM `user` WHERE `uid` = %d LIMIT 1", - intval($register[0]['uid']) - ); - $r = q("DELETE FROM `contact` WHERE `uid` = %d LIMIT 1", - intval($register[0]['uid']) - ); - $r = q("DELETE FROM `profile` WHERE `uid` = %d LIMIT 1", - intval($register[0]['uid']) - ); - - $r = q("DELETE FROM `register` WHERE `hash` = '%s' LIMIT 1", - dbesc($register[0]['hash']) - ); - notice( sprintf(t('Registration revoked for %s'), $user[0]['username']) . EOL); + notice(L10n::t('Registration revoked for %s', $user['username']) . EOL); return true; - } -function regmod_content(&$a) { - - global $lang; - - $_SESSION['return_url'] = $a->cmd; - - if(! local_user()) { - info( t('Please login.') . EOL); - $o .= '

' . login(($a->config['register_policy'] == REGISTER_CLOSED) ? 0 : 1); - return $o; +function regmod_content(App $a) +{ + if (!local_user()) { + info(L10n::t('Please login.') . EOL); + return Login::form($a->query_string, intval(Config::get('config', 'register_policy')) === REGISTER_CLOSED ? 0 : 1); } - if((!is_site_admin()) || (x($_SESSION,'submanage') && intval($_SESSION['submanage']))) { - notice( t('Permission denied.') . EOL); + if (!is_site_admin() || !empty($_SESSION['submanage'])) { + notice(L10n::t('Permission denied.') . EOL); return ''; } - if($a->argc != 3) - killme(); + if ($a->argc != 3) { + exit(); + } - $cmd = $a->argv[1]; + $cmd = $a->argv[1]; $hash = $a->argv[2]; - - - if($cmd === 'deny') { - if (!user_deny($hash)) killme(); + if ($cmd === 'deny') { + user_deny($hash); + $a->internalRedirect('admin/users/'); } - if($cmd === 'allow') { - if (!user_allow($hash)) killme(); + if ($cmd === 'allow') { + user_allow($hash); + $a->internalRedirect('admin/users/'); } }