function update_fail($update_id, $error_message) { //send the administrators an e-mail $admin_mail_list = "'" . implode("','", array_map(dbesc, explode(",", str_replace(" ", "", $a->config['admin_email'])))) . "'"; $adminlist = q("SELECT uid, language, email FROM user WHERE email IN (%s)", $admin_mail_list); // every admin could had different language foreach ($adminlist as $admin) { $lang = $admin['language'] ? $admin['language'] : 'en'; push_lang($lang); $preamble = deindent(t("\n\t\t\tThe friendica developers released update %s recently,\n\t\t\tbut when I tried to install it, something went terribly wrong.\n\t\t\tThis needs to be fixed soon and I can't do it alone. Please contact a\n\t\t\tfriendica developer if you can not help me on your own. My database might be invalid.")); $body = t("The error message is\n[pre]%s[/pre]"); $preamble = sprintf($preamble, $update_id); $body = sprintf($body, $error_message); notification(array('type' => "SYSTEM_EMAIL", 'to_email' => $admin['email'], 'preamble' => $preamble, 'body' => $body, 'language' => $lang)); } /* $email_tpl = get_intltext_template("update_fail_eml.tpl"); $email_msg = replace_macros($email_tpl, array( '$sitename' => $a->config['sitename'], '$siteurl' => $a->get_baseurl(), '$update' => DB_UPDATE_VERSION, '$error' => sprintf(t('Update %s failed. See error logs.'), DB_UPDATE_VERSION) )); $subject=sprintf(t('Update Error at %s'), $a->get_baseurl()); require_once('include/email.php'); $subject = email_header_encode($subject,'UTF-8'); mail($a->config['admin_email'], $subject, $email_msg, 'From: ' . 'Administrator' . '@' . $_SERVER['SERVER_NAME']."\n" .'Content-type: text/plain; charset=UTF-8'."\n" .'Content-transfer-encoding: 8bit'); */ //try the logger logger("CRITICAL: Database structure update failed: " . $retval); break; }
/** * Users admin page * * @param App $a */ function admin_page_users_post(&$a) { $pending = x($_POST, 'pending') ? $_POST['pending'] : array(); $users = x($_POST, 'user') ? $_POST['user'] : array(); $nu_name = x($_POST, 'new_user_name') ? $_POST['new_user_name'] : ''; $nu_nickname = x($_POST, 'new_user_nickname') ? $_POST['new_user_nickname'] : ''; $nu_email = x($_POST, 'new_user_email') ? $_POST['new_user_email'] : ''; check_form_security_token_redirectOnErr('/admin/users', 'admin_users'); if (!($nu_name === "") && !($nu_email === "") && !($nu_nickname === "")) { require_once 'include/user.php'; $result = create_user(array('username' => $nu_name, 'email' => $nu_email, 'nickname' => $nu_nickname, 'verified' => 1)); if (!$result['success']) { notice($result['message']); return; } $nu = $result['user']; $preamble = deindent(t(' Dear %1$s, the administrator of %2$s has set up an account for you.')); $body = deindent(t(' The login details are as follows: Site Location: %1$s Login Name: %2$s Password: %3$s You may change your password from your account "Settings" page after logging in. Please take a few moments to review the other account settings on that page. You may also wish to add some basic information to your default profile (on the "Profiles" page) so that other people can easily find you. We recommend setting your full name, adding a profile photo, adding some profile "keywords" (very useful in making new friends) - and perhaps what country you live in; if you do not wish to be more specific than that. We fully respect your right to privacy, and none of these items are necessary. If you are new and do not know anybody here, they may help you to make some new and interesting friends. Thank you and welcome to %4$s.')); $preamble = sprintf($preamble, $nu['username'], $a->config['sitename']); $body = sprintf($body, $a->get_baseurl(), $nu['email'], $result['password'], $a->config['sitename']); notification(array('type' => "SYSTEM_EMAIL", 'to_email' => $nu['email'], 'subject' => sprintf(t('Registration details for %s'), $a->config['sitename']), 'preamble' => $preamble, 'body' => $body)); } if (x($_POST, 'page_users_block')) { foreach ($users as $uid) { q("UPDATE `user` SET `blocked`=1-`blocked` WHERE `uid`=%s", intval($uid)); } notice(sprintf(tt("%s user blocked/unblocked", "%s users blocked/unblocked", count($users)), count($users))); } if (x($_POST, 'page_users_delete')) { require_once "include/Contact.php"; foreach ($users as $uid) { user_remove($uid); } notice(sprintf(tt("%s user deleted", "%s users deleted", count($users)), count($users))); } if (x($_POST, 'page_users_approve')) { require_once "mod/regmod.php"; foreach ($pending as $hash) { user_allow($hash); } } if (x($_POST, 'page_users_deny')) { require_once "mod/regmod.php"; foreach ($pending as $hash) { user_deny($hash); } } goaway($a->get_baseurl(true) . '/admin/users'); return; // NOTREACHED }
function send_register_open_eml($email, $sitename, $siteurl, $username, $password) { $preamble = deindent(t(' Dear %1$s, Thank you for registering at %2$s. Your account has been created. ')); $body = deindent(t(' The login details are as follows: Site Location: %3$s Login Name: %1$s Password: %5$s You may change your password from your account "Settings" page after logging in. Please take a few moments to review the other account settings on that page. You may also wish to add some basic information to your default profile (on the "Profiles" page) so that other people can easily find you. We recommend setting your full name, adding a profile photo, adding some profile "keywords" (very useful in making new friends) - and perhaps what country you live in; if you do not wish to be more specific than that. We fully respect your right to privacy, and none of these items are necessary. If you are new and do not know anybody here, they may help you to make some new and interesting friends. Thank you and welcome to %2$s.')); $preamble = sprintf($preamble, $username, $sitename); $body = sprintf($body, $email, $sitename, $siteurl, $username, $password); return notification(array('type' => "SYSTEM_EMAIL", 'to_email' => $email, 'subject' => sprintf(t('Registration details for %s'), $sitename), 'preamble' => $preamble, 'body' => $body)); }
function lostpass_content(&$a) { if (x($_GET, 'verify')) { $verify = $_GET['verify']; $hash = hash('whirlpool', $verify); $r = q("SELECT * FROM `user` WHERE `pwdreset` = '%s' LIMIT 1", dbesc($hash)); if (!count($r)) { $o = t("Request could not be verified. (You may have previously submitted it.) Password reset failed."); return $o; } $uid = $r[0]['uid']; $username = $r[0]['username']; $email = $r[0]['email']; $new_password = autoname(6) . mt_rand(100, 9999); $new_password_encoded = hash('whirlpool', $new_password); $r = q("UPDATE `user` SET `password` = '%s', `pwdreset` = '' WHERE `uid` = %d", dbesc($new_password_encoded), intval($uid)); if ($r) { $tpl = get_markup_template('pwdreset.tpl'); $o .= replace_macros($tpl, array('$lbl1' => t('Password Reset'), '$lbl2' => t('Your password has been reset as requested.'), '$lbl3' => t('Your new password is'), '$lbl4' => t('Save or copy your new password - and then'), '$lbl5' => '<a href="' . $a->get_baseurl() . '">' . t('click here to login') . '</a>.', '$lbl6' => t('Your password may be changed from the <em>Settings</em> page after successful login.'), '$newpass' => $new_password, '$baseurl' => $a->get_baseurl())); info("Your password has been reset." . EOL); $sitename = $a->config['sitename']; $siteurl = $a->get_baseurl(); // $username, $email, $new_password $preamble = deindent(t(' Dear %1$s, Your password has been changed as requested. Please retain this information for your records (or change your password immediately to something that you will remember). ')); $body = deindent(t(' Your login details are as follows: Site Location: %1$s Login Name: %2$s Password: %3$s You may change that password from your account settings page after logging in. ')); $preamble = sprintf($preamble, $username); $body = sprintf($body, $siteurl, $email, $new_password); notification(array('type' => "SYSTEM_EMAIL", 'to_email' => $email, 'subject' => sprintf(t('Your password has been changed at %s'), $sitename), 'preamble' => $preamble, 'body' => $body)); return $o; } } else { $tpl = get_markup_template('lostpass.tpl'); $o .= replace_macros($tpl, array('$title' => t('Forgot your Password?'), '$desc' => t('Enter your email address and submit to have your password reset. Then check your email for further instructions.'), '$name' => t('Nickname or Email: '), '$submit' => t('Reset'))); return $o; } }