/** * checks the validity of input parameters, fills $page['errors'] and * $page['infos'] and send an email with confirmation link * * @return bool (true if email was sent, false otherwise) */ function process_password_request() { global $page, $conf; if (empty($_POST['username_or_email'])) { $page['errors'][] = l10n('Invalid username or email'); return false; } $user_id = get_userid_by_email($_POST['username_or_email']); if (!is_numeric($user_id)) { $user_id = get_userid($_POST['username_or_email']); } if (!is_numeric($user_id)) { $page['errors'][] = l10n('Invalid username or email'); return false; } $userdata = getuserdata($user_id, false); // password request is not possible for guest/generic users $status = $userdata['status']; if (is_a_guest($status) or is_generic($status)) { $page['errors'][] = l10n('Password reset is not allowed for this user'); return false; } if (empty($userdata['email'])) { $page['errors'][] = l10n('User "%s" has no email address, password reset is not possible', $userdata['username']); return false; } $activation_key = generate_key(20); list($expire) = pwg_db_fetch_row(pwg_query('SELECT ADDDATE(NOW(), INTERVAL 1 HOUR)')); single_update(USER_INFOS_TABLE, array('activation_key' => pwg_password_hash($activation_key), 'activation_key_expire' => $expire), array('user_id' => $user_id)); $userdata['activation_key'] = $activation_key; set_make_full_url(); $message = l10n('Someone requested that the password be reset for the following user account:') . "\r\n\r\n"; $message .= l10n('Username "%s" on gallery %s', $userdata['username'], get_gallery_home_url()); $message .= "\r\n\r\n"; $message .= l10n('To reset your password, visit the following address:') . "\r\n"; $message .= get_gallery_home_url() . '/password.php?key=' . $activation_key . '-' . urlencode($userdata['email']); $message .= "\r\n\r\n"; $message .= l10n('If this was a mistake, just ignore this email and nothing will happen.') . "\r\n"; unset_make_full_url(); $message = trigger_change('render_lost_password_mail_content', $message); $email_params = array('subject' => '[' . $conf['gallery_title'] . '] ' . l10n('Password Reset'), 'content' => $message, 'email_format' => 'text/plain'); if (pwg_mail($userdata['email'], $email_params)) { $page['infos'][] = l10n('Check your email for the confirmation link'); return true; } else { $page['errors'][] = l10n('Error sending email'); return false; } }
if (isset($error_copy)) { $errors[] = $error_copy; } else { session_set_save_handler('pwg_session_open', 'pwg_session_close', 'pwg_session_read', 'pwg_session_write', 'pwg_session_destroy', 'pwg_session_gc'); if (function_exists('ini_set')) { ini_set('session.use_cookies', $conf['session_use_cookies']); ini_set('session.use_only_cookies', $conf['session_use_only_cookies']); ini_set('session.use_trans_sid', intval($conf['session_use_trans_sid'])); ini_set('session.cookie_httponly', 1); } session_name($conf['session_name']); session_set_cookie_params(0, cookie_path()); register_shutdown_function('session_write_close'); $user = build_user(1, true); log_user($user['id'], false); // email notification if (isset($_POST['send_password_by_mail'])) { include_once PHPWG_ROOT_PATH . 'include/functions_mail.inc.php'; $keyargs_content = array(get_l10n_args('Hello %s,', $admin_name), get_l10n_args('Welcome to your new installation of Piwigo!', ''), get_l10n_args('', ''), get_l10n_args('Here are your connection settings', ''), get_l10n_args('', ''), get_l10n_args('Link: %s', get_absolute_root_url()), get_l10n_args('Username: %s', $admin_name), get_l10n_args('Password: %s', $admin_pass1), get_l10n_args('Email: %s', $admin_mail), get_l10n_args('', ''), get_l10n_args('Don\'t hesitate to consult our forums for any help: %s', PHPWG_URL)); pwg_mail($admin_mail, array('subject' => l10n('Just another Piwigo gallery'), 'content' => l10n_args($keyargs_content), 'content_format' => 'text/plain')); } } } if (count($errors) != 0) { $template->assign('errors', $errors); } if (count($infos) != 0) { $template->assign('infos', $infos); } //----------------------------------------------------------- html code display $template->pparse('install');
/** * Creates a new user. * * @param string $login * @param string $password * @param string $mail_adress * @param bool $notify_admin * @param array &$errors populated with error messages * @param bool $notify_user * @return int|false user id or false */ function register_user($login, $password, $mail_address, $notify_admin = true, &$errors = array(), $notify_user = false) { global $conf; if ($login == '') { $errors[] = l10n('Please, enter a login'); } if (preg_match('/^.* $/', $login)) { $errors[] = l10n('login mustn\'t end with a space character'); } if (preg_match('/^ .*$/', $login)) { $errors[] = l10n('login mustn\'t start with a space character'); } if (get_userid($login)) { $errors[] = l10n('this login is already used'); } if ($login != strip_tags($login)) { $errors[] = l10n('html tags are not allowed in login'); } $mail_error = validate_mail_address(null, $mail_address); if ('' != $mail_error) { $errors[] = $mail_error; } if ($conf['insensitive_case_logon'] == true) { $login_error = validate_login_case($login); if ($login_error != '') { $errors[] = $login_error; } } $errors = trigger_change('register_user_check', $errors, array('username' => $login, 'password' => $password, 'email' => $mail_address)); // if no error until here, registration of the user if (count($errors) == 0) { $insert = array($conf['user_fields']['username'] => pwg_db_real_escape_string($login), $conf['user_fields']['password'] => $conf['password_hash']($password), $conf['user_fields']['email'] => $mail_address); single_insert(USERS_TABLE, $insert); $user_id = pwg_db_insert_id(); // Assign by default groups $query = ' SELECT id FROM ' . GROUPS_TABLE . ' WHERE is_default = \'' . boolean_to_string(true) . '\' ORDER BY id ASC ;'; $result = pwg_query($query); $inserts = array(); while ($row = pwg_db_fetch_assoc($result)) { $inserts[] = array('user_id' => $user_id, 'group_id' => $row['id']); } if (count($inserts) != 0) { mass_inserts(USER_GROUP_TABLE, array('user_id', 'group_id'), $inserts); } $override = array(); if ($language = get_browser_language()) { $override['language'] = $language; } create_user_infos($user_id, $override); if ($notify_admin and $conf['email_admin_on_new_user']) { include_once PHPWG_ROOT_PATH . 'include/functions_mail.inc.php'; $admin_url = get_absolute_root_url() . 'admin.php?page=user_list&username='******'User: %s', stripslashes($login)), get_l10n_args('Email: %s', $mail_address), get_l10n_args(''), get_l10n_args('Admin: %s', $admin_url)); pwg_mail_notification_admins(get_l10n_args('Registration of %s', stripslashes($login)), $keyargs_content); } if ($notify_user and email_check_format($mail_address)) { include_once PHPWG_ROOT_PATH . 'include/functions_mail.inc.php'; $keyargs_content = array(get_l10n_args('Hello %s,', stripslashes($login)), get_l10n_args('Thank you for registering at %s!', $conf['gallery_title']), get_l10n_args('', ''), get_l10n_args('Here are your connection settings', ''), get_l10n_args('', ''), get_l10n_args('Link: %s', get_absolute_root_url()), get_l10n_args('Username: %s', stripslashes($login)), get_l10n_args('Password: %s', stripslashes($password)), get_l10n_args('Email: %s', $mail_address), get_l10n_args('', ''), get_l10n_args('If you think you\'ve received this email in error, please contact us at %s', get_webmaster_mail_address())); pwg_mail($mail_address, array('subject' => '[' . $conf['gallery_title'] . '] ' . l10n('Registration'), 'content' => l10n_args($keyargs_content), 'content_format' => 'text/plain')); } trigger_notify('register_user', array('id' => $user_id, 'username' => $login, 'email' => $mail_address)); return $user_id; } else { return false; } }
function save_profile_from_post($userdata, &$errors) { global $conf, $page; $errors = array(); if (!isset($_POST['validate'])) { return false; } $special_user = in_array($userdata['id'], array($conf['guest_id'], $conf['default_user_id'])); if ($special_user) { unset($_POST['username'], $_POST['mail_address'], $_POST['password'], $_POST['use_new_pwd'], $_POST['passwordConf'], $_POST['theme'], $_POST['language']); $_POST['theme'] = get_default_theme(); $_POST['language'] = get_default_language(); } if (!defined('IN_ADMIN')) { unset($_POST['username']); } if ($conf['allow_user_customization'] or defined('IN_ADMIN')) { $int_pattern = '/^\\d+$/'; if (empty($_POST['nb_image_page']) or !preg_match($int_pattern, $_POST['nb_image_page'])) { $errors[] = l10n('The number of photos per page must be a not null scalar'); } // periods must be integer values, they represents number of days if (!preg_match($int_pattern, $_POST['recent_period']) or $_POST['recent_period'] < 0) { $errors[] = l10n('Recent period must be a positive integer value'); } if (!in_array($_POST['language'], array_keys(get_languages()))) { die('Hacking attempt, incorrect language value'); } if (!in_array($_POST['theme'], array_keys(get_pwg_themes()))) { die('Hacking attempt, incorrect theme value'); } } if (isset($_POST['mail_address'])) { // if $_POST and $userdata have are same email // validate_mail_address allows, however, to check email $mail_error = validate_mail_address($userdata['id'], $_POST['mail_address']); if (!empty($mail_error)) { $errors[] = $mail_error; } } if (!empty($_POST['use_new_pwd'])) { // password must be the same as its confirmation if ($_POST['use_new_pwd'] != $_POST['passwordConf']) { $errors[] = l10n('The passwords do not match'); } if (!defined('IN_ADMIN')) { // changing password requires old password $query = ' SELECT ' . $conf['user_fields']['password'] . ' AS password FROM ' . USERS_TABLE . ' WHERE ' . $conf['user_fields']['id'] . ' = \'' . $userdata['id'] . '\' ;'; list($current_password) = pwg_db_fetch_row(pwg_query($query)); if (!$conf['password_verify']($_POST['password'], $current_password)) { $errors[] = l10n('Current password is wrong'); } } } if (count($errors) == 0) { // mass_updates function include_once PHPWG_ROOT_PATH . 'admin/include/functions.php'; if (isset($_POST['mail_address'])) { // update common user informations $fields = array($conf['user_fields']['email']); $data = array(); $data[$conf['user_fields']['id']] = $userdata['id']; $data[$conf['user_fields']['email']] = $_POST['mail_address']; // password is updated only if filled if (!empty($_POST['use_new_pwd'])) { $fields[] = $conf['user_fields']['password']; // password is hashed with function $conf['password_hash'] $data[$conf['user_fields']['password']] = $conf['password_hash']($_POST['use_new_pwd']); } // username is updated only if allowed if (!empty($_POST['username'])) { if ($_POST['username'] != $userdata['username'] and get_userid($_POST['username'])) { $page['errors'][] = l10n('this login is already used'); unset($_POST['redirect']); } else { $fields[] = $conf['user_fields']['username']; $data[$conf['user_fields']['username']] = $_POST['username']; // send email to the user if ($_POST['username'] != $userdata['username']) { include_once PHPWG_ROOT_PATH . 'include/functions_mail.inc.php'; switch_lang_to($userdata['language']); $keyargs_content = array(get_l10n_args('Hello', ''), get_l10n_args('Your username has been successfully changed to : %s', $_POST['username'])); pwg_mail($_POST['mail_address'], array('subject' => '[' . $conf['gallery_title'] . '] ' . l10n('Username modification'), 'content' => l10n_args($keyargs_content), 'content_format' => 'text/plain')); switch_lang_back(); } } } mass_updates(USERS_TABLE, array('primary' => array($conf['user_fields']['id']), 'update' => $fields), array($data)); } if ($conf['allow_user_customization'] or defined('IN_ADMIN')) { // update user "additional" informations (specific to Piwigo) $fields = array('nb_image_page', 'language', 'expand', 'show_nb_hits', 'recent_period', 'theme'); if ($conf['activate_comments']) { $fields[] = 'show_nb_comments'; } $data = array(); $data['user_id'] = $userdata['id']; foreach ($fields as $field) { if (isset($_POST[$field])) { $data[$field] = $_POST[$field]; } } mass_updates(USER_INFOS_TABLE, array('primary' => array('user_id'), 'update' => $fields), array($data)); } trigger_notify('save_profile_from_post', $userdata['id']); if (!empty($_POST['redirect'])) { redirect($_POST['redirect']); } } return true; }
/** * @deprecated 2.6 */ function pwg_send_mail($result, $to, $subject, $content, $headers) { if (is_admin()) { trigger_error('pwg_send_mail function is deprecated', E_USER_NOTICE); } if (!$result) { return pwg_mail($to, array('content' => $content, 'subject' => $subject)); } else { return $result; } }
function do_subscribe_unsubscribe_notification_by_mail($is_admin_request, $is_subscribe = false, $check_key_list = array()) { global $conf, $page, $env_nbm, $conf; set_make_full_url(); $check_key_treated = array(); $updated_data_count = 0; $error_on_updated_data_count = 0; if ($is_subscribe) { $msg_info = l10n('User %s [%s] was added to the subscription list.'); $msg_error = l10n('User %s [%s] was not added to the subscription list.'); } else { $msg_info = l10n('User %s [%s] was removed from the subscription list.'); $msg_error = l10n('User %s [%s] was not removed from the subscription list.'); } if (count($check_key_list) != 0) { $updates = array(); $enabled_value = boolean_to_string($is_subscribe); $data_users = get_user_notifications('subscribe', $check_key_list, !$is_subscribe); // Prepare message after change language $msg_break_timeout = l10n('Time to send mail is limited. Others mails are skipped.'); // Begin nbm users environment begin_users_env_nbm(true); foreach ($data_users as $nbm_user) { if (check_sendmail_timeout()) { // Stop fill list on 'send', if the quota is override $page['errors'][] = $msg_break_timeout; break; } // Fill return list $check_key_treated[] = $nbm_user['check_key']; $do_update = true; if ($nbm_user['mail_address'] != '') { // set env nbm user set_user_on_env_nbm($nbm_user, true); $subject = '[' . $conf['gallery_title'] . '] ' . ($is_subscribe ? l10n('Subscribe to notification by mail') : l10n('Unsubscribe from notification by mail')); // Assign current var for nbm mail assign_vars_nbm_mail_content($nbm_user); $section_action_by = $is_subscribe ? 'subscribe_by_' : 'unsubscribe_by_'; $section_action_by .= $is_admin_request ? 'admin' : 'himself'; $env_nbm['mail_template']->assign(array($section_action_by => true, 'GOTO_GALLERY_TITLE' => $conf['gallery_title'], 'GOTO_GALLERY_URL' => get_gallery_home_url())); $ret = pwg_mail(array('name' => stripslashes($nbm_user['username']), 'email' => $nbm_user['mail_address']), array('from' => $env_nbm['send_as_mail_formated'], 'subject' => $subject, 'email_format' => $env_nbm['email_format'], 'content' => $env_nbm['mail_template']->parse('notification_by_mail', true), 'content_format' => $env_nbm['email_format'])); if ($ret) { inc_mail_sent_success($nbm_user); } else { inc_mail_sent_failed($nbm_user); $do_update = false; } // unset env nbm user unset_user_on_env_nbm(); } if ($do_update) { $updates[] = array('check_key' => $nbm_user['check_key'], 'enabled' => $enabled_value); $updated_data_count += 1; $page['infos'][] = sprintf($msg_info, stripslashes($nbm_user['username']), $nbm_user['mail_address']); } else { $error_on_updated_data_count += 1; $page['errors'][] = sprintf($msg_error, stripslashes($nbm_user['username']), $nbm_user['mail_address']); } } // Restore nbm environment end_users_env_nbm(); display_counter_info(); mass_updates(USER_MAIL_NOTIFICATION_TABLE, array('primary' => array('check_key'), 'update' => array('enabled')), $updates); } $page['infos'][] = l10n_dec('%d user was updated.', '%d users were updated.', $updated_data_count); if ($error_on_updated_data_count != 0) { $page['errors'][] = l10n_dec('%d user was not updated.', '%d users were not updated.', $error_on_updated_data_count); } unset_make_full_url(); return $check_key_treated; }
foreach ($users as $u) { $usernames[] = $u['username']; $authkey = create_user_auth_key($u['user_id'], $u['status']); $user_tpl = $tpl; if ($authkey !== false) { $user_tpl['assign']['LINK'] = add_url_params($tpl['assign']['LINK'], array('auth' => $authkey['auth_key'])); if (isset($user_tpl['assign']['IMG']['link'])) { $user_tpl['assign']['IMG']['link'] = add_url_params($user_tpl['assign']['IMG']['link'], array('auth' => $authkey['auth_key'])); } } $user_args = $args; if (isset($authkey)) { $user_args['auth_key'] = $authkey['auth_key']; } switch_lang_to($u['language']); pwg_mail($u['email'], $user_args, $user_tpl); switch_lang_back(); } $message = l10n_dec('%d mail was sent.', '%d mails were sent.', count($users)); $message .= ' (' . implode(', ', $usernames) . ')'; $page['infos'][] = $message; } elseif ('group' == $_POST['who'] and !empty($_POST['group'])) { check_input_parameter('group', $_POST, false, PATTERN_ID); pwg_mail_group($_POST['group'], $args, $tpl); $query = ' SELECT name FROM ' . GROUPS_TABLE . ' WHERE id = ' . $_POST['group'] . ' ;'; list($group_name) = pwg_db_fetch_row(pwg_query($query));
function do_action_send_mail_notification($action = 'list_to_send', $check_key_list = array(), $customize_mail_content = '') { global $conf, $page, $user, $lang_info, $lang, $env_nbm; $return_list = array(); if (in_array($action, array('list_to_send', 'send'))) { list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();')); $is_action_send = $action == 'send'; // disabled and null mail_address are not selected in the list $data_users = get_user_notifications('send', $check_key_list); // List all if it's define on options or on timeout $is_list_all_without_test = ($env_nbm['is_sendmail_timeout'] or $conf['nbm_list_all_enabled_users_to_send']); // Check if exist news to list user or send mails if (!$is_list_all_without_test or $is_action_send) { if (count($data_users) > 0) { $datas = array(); if (!isset($customize_mail_content)) { $customize_mail_content = $conf['nbm_complementary_mail_content']; } $customize_mail_content = trigger_change('nbm_render_global_customize_mail_content', $customize_mail_content); // Prepare message after change language if ($is_action_send) { $msg_break_timeout = l10n('Time to send mail is limited. Others mails are skipped.'); } else { $msg_break_timeout = l10n('Prepared time for list of users to send mail is limited. Others users are not listed.'); } // Begin nbm users environment begin_users_env_nbm($is_action_send); foreach ($data_users as $nbm_user) { if (!$is_action_send and check_sendmail_timeout()) { // Stop fill list on 'list_to_send', if the quota is override $page['infos'][] = $msg_break_timeout; break; } if ($is_action_send and check_sendmail_timeout()) { // Stop fill list on 'send', if the quota is override $page['errors'][] = $msg_break_timeout; break; } // set env nbm user set_user_on_env_nbm($nbm_user, $is_action_send); if ($is_action_send) { $auth = null; $add_url_params = array(); $auth_key = create_user_auth_key($nbm_user['user_id'], $nbm_user['status']); if ($auth_key !== false) { $auth = $auth_key['auth_key']; $add_url_params['auth'] = $auth; } set_make_full_url(); // Fill return list of "treated" check_key for 'send' $return_list[] = $nbm_user['check_key']; if ($conf['nbm_send_detailed_content']) { $news = news($nbm_user['last_send'], $dbnow, false, $conf['nbm_send_html_mail'], $auth); $exist_data = count($news) > 0; } else { $exist_data = news_exists($nbm_user['last_send'], $dbnow); } if ($exist_data) { $subject = '[' . $conf['gallery_title'] . '] ' . l10n('New photos added'); // Assign current var for nbm mail assign_vars_nbm_mail_content($nbm_user); if (!is_null($nbm_user['last_send'])) { $env_nbm['mail_template']->assign('content_new_elements_between', array('DATE_BETWEEN_1' => $nbm_user['last_send'], 'DATE_BETWEEN_2' => $dbnow)); } else { $env_nbm['mail_template']->assign('content_new_elements_single', array('DATE_SINGLE' => $dbnow)); } if ($conf['nbm_send_detailed_content']) { $env_nbm['mail_template']->assign('global_new_lines', $news); } $nbm_user_customize_mail_content = trigger_change('nbm_render_user_customize_mail_content', $customize_mail_content, $nbm_user); if (!empty($nbm_user_customize_mail_content)) { $env_nbm['mail_template']->assign('custom_mail_content', $nbm_user_customize_mail_content); } if ($conf['nbm_send_html_mail'] and $conf['nbm_send_recent_post_dates']) { $recent_post_dates = get_recent_post_dates_array($conf['recent_post_dates']['NBM']); foreach ($recent_post_dates as $date_detail) { $env_nbm['mail_template']->append('recent_posts', array('TITLE' => get_title_recent_post_date($date_detail), 'HTML_DATA' => get_html_description_recent_post_date($date_detail, $auth))); } } $env_nbm['mail_template']->assign(array('GOTO_GALLERY_TITLE' => $conf['gallery_title'], 'GOTO_GALLERY_URL' => add_url_params(get_gallery_home_url(), $add_url_params), 'SEND_AS_NAME' => $env_nbm['send_as_name'])); $ret = pwg_mail(array('name' => stripslashes($nbm_user['username']), 'email' => $nbm_user['mail_address']), array('from' => $env_nbm['send_as_mail_formated'], 'subject' => $subject, 'email_format' => $env_nbm['email_format'], 'content' => $env_nbm['mail_template']->parse('notification_by_mail', true), 'content_format' => $env_nbm['email_format'], 'auth_key' => $auth)); if ($ret) { inc_mail_sent_success($nbm_user); $datas[] = array('user_id' => $nbm_user['user_id'], 'last_send' => $dbnow); } else { inc_mail_sent_failed($nbm_user); } unset_make_full_url(); } } else { if (news_exists($nbm_user['last_send'], $dbnow)) { // Fill return list of "selected" users for 'list_to_send' $return_list[] = $nbm_user; } } // unset env nbm user unset_user_on_env_nbm(); } // Restore nbm environment end_users_env_nbm(); if ($is_action_send) { mass_updates(USER_MAIL_NOTIFICATION_TABLE, array('primary' => array('user_id'), 'update' => array('last_send')), $datas); display_counter_info(); } } else { if ($is_action_send) { $page['errors'][] = l10n('No user to send notifications by mail.'); } } } else { // Quick List, don't check news // Fill return list of "selected" users for 'list_to_send' $return_list = $data_users; } } // Return list of "selected" users for 'list_to_send' // Return list of "treated" check_key for 'send' return $return_list; }
function ws_pshare_share_create($params, &$service) { global $conf, $user; if (!pshare_is_active()) { return new PwgError(401, "permission denied"); } $query = ' SELECT * FROM ' . IMAGES_TABLE . ' WHERE id = ' . $params['image_id'] . ' ;'; $images = query2array($query); if (count($images) == 0) { return new PwgError(404, "image not found"); } $image = $images[0]; if (!pshare_is_photo_visible($params['image_id'])) { return new PwgError(401, "permissions denied"); } if (!email_check_format($params['email'])) { return new PwgError(WS_ERR_INVALID_PARAM, l10n('Invalid email address')); } // TODO check the expires_in is in the defined list $query = ' SELECT NOW(), ADDDATE(NOW(), INTERVAL ' . $params['expires_in'] . ' DAY) ;'; list($now, $expire) = pwg_db_fetch_row(pwg_query($query)); $key_uuid = pshare_get_key(); single_insert(PSHARE_KEYS_TABLE, array('uuid' => $key_uuid, 'user_id' => $user['id'], 'image_id' => $params['image_id'], 'sent_to' => $params['email'], 'created_on' => $now, 'duration' => $params['expires_in'], 'expire_on' => $expire)); $query = ' SELECT * FROM ' . PSHARE_KEYS_TABLE . ' WHERE uuid = \'' . $key_uuid . '\' ;'; $shares = query2array($query); if (count($shares) == 0) { return new PwgError(500, "share not created"); } $share = $shares[0]; // // Send the email // include_once PHPWG_ROOT_PATH . 'include/functions_mail.inc.php'; // force $conf['derivative_url_style'] to 2 (script) to make sure we // will use i.php?/upload and not _data/i/upload because you don't // know when the cache will be flushed $previous_derivative_url_style = $conf['derivative_url_style']; $conf['derivative_url_style'] = 2; $thumb_url = DerivativeImage::thumb_url(array('id' => $image['id'], 'path' => $image['path'])); // restore configuration setting $conf['derivative_url_style'] = $previous_derivative_url_style; $link = get_absolute_root_url() . 'index.php?/pshare/' . $share['uuid']; $content = '<p style="text-align:center">'; $content .= l10n('%s has shared a photo with you', $user['username']); $content .= '<br><br><a href="' . $link . '"><img src="' . $thumb_url . '"></a>'; $content .= '<br><br><a href="' . $link . '">' . l10n('clic to view') . '</a>'; $content .= '</p>'; $subject = l10n('Photo shared'); pwg_mail($params['email'], array('subject' => '[' . $conf['gallery_title'] . '] ' . $subject, 'mail_title' => $conf['gallery_title'], 'mail_subtitle' => $subject, 'content' => $content, 'content_format' => 'text/html')); return array('message' => l10n('Email sent to %s', $share['sent_to'])); }
/** * Function called from UAM_admin.php to send notification email when user registration have been manually validated by admin * * @param : user id * */ function validation_mail($id) { global $conf; $conf_UAM = unserialize($conf['UserAdvManager']); include_once PHPWG_ROOT_PATH . 'include/functions_mail.inc.php'; $custom_txt = ""; $subject = ""; // We have to get the user's language in database // ---------------------------------------------- $query = ' SELECT user_id, language FROM ' . USER_INFOS_TABLE . ' WHERE user_id = ' . $id . ' ;'; $data = pwg_db_fetch_assoc(pwg_query($query)); // Check if user is already registered (profile changing) - If not (new registration), language is set to current gallery language // ------------------------------------------------------------------------------------------------------------------------------- if (empty($data)) { // And switch gallery to this language before using personalized and multilangual contents // --------------------------------------------------------------------------------------- $language = pwg_get_session_var('lang_switch', $user['language']); switch_lang_to($language); } else { // And switch gallery to this language before using personalized and multilangual contents // --------------------------------------------------------------------------------------- $language = $data['language']; // Usefull for debugging switch_lang_to($data['language']); load_language('plugin.lang', UAM_PATH); } // Retreive users email and user name from id // ------------------------------------------ $query = ' SELECT id, username, mail_address FROM ' . USERS_TABLE . ' WHERE id = ' . $id . ' ;'; $result = pwg_db_fetch_assoc(pwg_query($query)); if (isset($conf_UAM['ADMINVALIDATIONMAIL_SUBJECT']) and !empty($conf_UAM['ADMINVALIDATIONMAIL_SUBJECT'])) { // Management of Extension flags ([username], [mygallery]) // ------------------------------------------------------- $patterns[] = '#\\[username\\]#i'; $replacements[] = stripslashes($result['username']); $patterns[] = '#\\[mygallery\\]#i'; $replacements[] = $conf['gallery_title']; if (function_exists('get_user_language_desc')) { $subject = get_user_language_desc(preg_replace($patterns, $replacements, $conf_UAM['ADMINVALIDATIONMAIL_SUBJECT'])) . "\n\n"; } else { $subject = l10n(preg_replace($patterns, $replacements, $conf_UAM['ADMINVALIDATIONMAIL_SUBJECT'])) . "\n\n"; } } if (isset($conf_UAM['ADMINVALIDATIONMAIL']) and !empty($conf_UAM['ADMINVALIDATIONMAIL'])) { // Management of Extension flags ([username], [mygallery], [myurl]) // ---------------------------------------------------------------- $patterns[] = '#\\[username\\]#i'; $replacements[] = stripslashes($result['username']); $patterns[] = '#\\[mygallery\\]#i'; $replacements[] = $conf['gallery_title']; $patterns[] = '#\\[myurl\\]#i'; $replacements[] = get_gallery_home_url(); if (function_exists('get_user_language_desc')) { $custom_txt = get_user_language_desc(preg_replace($patterns, $replacements, $conf_UAM['ADMINVALIDATIONMAIL'])) . "\n\n"; } else { $custom_txt = l10n(preg_replace($patterns, $replacements, $conf_UAM['ADMINVALIDATIONMAIL'])) . "\n\n"; } } $infos = array(get_l10n_args('UAM_User: %s', stripslashes($result['username'])), get_l10n_args('Email: %s', $result['mail_address']), get_l10n_args('', '')); // Sending the email with subject and contents // ------------------------------------------- // Adding gallery URL at the end of the email if (isset($conf_UAM['ADD_GALLERY_URL_TO_EMAILS']) and $conf_UAM['ADD_GALLERY_URL_TO_EMAILS'] == 'true') { $content = l10n_args($infos) . "\n\n" . $custom_txt . get_absolute_root_url(); pwg_mail(array('name' => stripslashes($result['username']), 'email' => $result['mail_address']), array('content' => $content, 'content_format' => 'text/plain', 'subject' => $subject)); // Send a copy to admins if (isset($conf_UAM['EMAILS_COPY_TO_ADMINS']) and $conf_UAM['EMAILS_COPY_TO_ADMINS'] == 'true') { UAM_Copy2Admins($subject, $content); } } elseif (isset($conf_UAM['ADD_GALLERY_URL_TO_EMAILS']) and $conf_UAM['ADD_GALLERY_URL_TO_EMAILS'] == 'false') { $content = l10n_args($infos) . "\n\n" . $custom_txt; pwg_mail(array('name' => stripslashes($result['username']), 'email' => $result['mail_address']), array('content' => $content, 'content_format' => 'text/plain', 'subject' => $subject)); // Send a copy to admins if (isset($conf_UAM['EMAILS_COPY_TO_ADMINS']) and $conf_UAM['EMAILS_COPY_TO_ADMINS'] == 'true') { UAM_Copy2Admins($subject, $content); } } else { $content = l10n_args($infos) . "\n\n" . $custom_txt; pwg_mail(array('name' => stripslashes($result['username']), 'email' => $result['mail_address']), array('content' => $content, 'content_format' => 'text/plain', 'subject' => $subject)); // Send a copy to admins if (isset($conf_UAM['EMAILS_COPY_TO_ADMINS']) and $conf_UAM['EMAILS_COPY_TO_ADMINS'] == 'true') { UAM_Copy2Admins($subject, $content); } } // Switching back to default language // ---------------------------------- switch_lang_back(); }
/** * Add new registered user in Piwigo users table from audit/synch action * To solve password synch problem, passwords are reset to NULL to force users to get a new password on their profile page * * Based on user_mass_register plugin (thx to plg!) * * @return : $errors */ function Synch_Piwigo_Adduser($fluxbb_id, $username, $password, $email) { global $conf; load_language('plugin.lang', REGFLUXBB_PATH); $errors = register_user($username, $password, $email, false); if (empty($errors)) { include_once PHPWG_ROOT_PATH . 'include/functions_mail.inc.php'; $keyargs_content = array(get_l10n_args('Hello %s,', $username), get_l10n_args('To synchronize your forum access with the gallery you have been registered at %s!', $conf['gallery_title']), get_l10n_args('', ''), get_l10n_args('Here are your connection settings', ''), get_l10n_args('Username: %s', $username), get_l10n_args('Password: %s', $password), get_l10n_args('Email: %s', $email), get_l10n_args('', ''), get_l10n_args('Please change your password at your first connexion on the gallery', ''), get_l10n_args('', ''), get_l10n_args('If you think you\'ve received this email in error, please contact us at %s', get_webmaster_mail_address())); pwg_mail($email, array('subject' => '[' . $conf['gallery_title'] . '] ' . l10n('Registration'), 'content' => l10n_args($keyargs_content), 'content_format' => 'text/plain')); $pwg_id = get_userid($username); FluxBB_Linkuser($pwg_id, $fluxbb_id, "NOK"); } return $errors; }