function get_not_default_language() { $default_language = get_default_language(); $available_languages = explode(',', Config::get('AVAILABLE_LANGUAGES')); // Find other language different from the default one $other_language = ''; foreach ($available_languages as $al) { if ($al != $default_language) { $other_language = $al; } } return $other_language; }
/** * includes a language file or returns the content of a language file * * tries to load in descending order: * param language, user language, default language * * @param string $filename * @param string $dirname * @param mixed options can contain * @option string language - language to load * @option bool return - if true the file content is returned * @option bool no_fallback - if true do not load default language * @option bool|string force_fallback - force pre-loading of another language * default language if *true* or specified language * @option bool local - if true load file from local directory * @return boolean|string */ function load_language($filename, $dirname = '', $options = array()) { global $user, $language_files; // keep trace of plugins loaded files for switch_lang_to() function if (!empty($dirname) && !empty($filename) && !@$options['return'] && !isset($language_files[$dirname][$filename])) { $language_files[$dirname][$filename] = $options; } if (!@$options['return']) { $filename .= '.php'; } if (empty($dirname)) { $dirname = PHPWG_ROOT_PATH; } $dirname .= 'language/'; $default_language = defined('PHPWG_INSTALLED') and !defined('UPGRADES_PATH') ? get_default_language() : PHPWG_DEFAULT_LANGUAGE; // construct list of potential languages $languages = array(); if (!empty($options['language'])) { // explicit language $languages[] = $options['language']; } if (!empty($user['language'])) { // use language $languages[] = $user['language']; } if (($parent = get_parent_language()) != null) { // parent language // this is only for when the "child" language is missing $languages[] = $parent; } if (isset($options['force_fallback'])) { // fallback language // this is only for when the main language is missing if ($options['force_fallback'] === true) { $options['force_fallback'] = $default_language; } $languages[] = $options['force_fallback']; } if (!@$options['no_fallback']) { // default language $languages[] = $default_language; } $languages = array_unique($languages); // find first existing $source_file = ''; $selected_language = ''; foreach ($languages as $language) { $f = @$options['local'] ? $dirname . $language . '.' . $filename : $dirname . $language . '/' . $filename; if (file_exists($f)) { $selected_language = $language; $source_file = $f; break; } } if (!empty($source_file)) { if (!@$options['return']) { // load forced fallback if (isset($options['force_fallback']) && $options['force_fallback'] != $selected_language) { @(include str_replace($selected_language, $options['force_fallback'], $source_file)); } // load language content @(include $source_file); $load_lang = @$lang; $load_lang_info = @$lang_info; // access already existing values global $lang, $lang_info; if (!isset($lang)) { $lang = array(); } if (!isset($lang_info)) { $lang_info = array(); } // load parent language content directly in global if (!empty($load_lang_info['parent'])) { $parent_language = $load_lang_info['parent']; } else { if (!empty($lang_info['parent'])) { $parent_language = $lang_info['parent']; } else { $parent_language = null; } } if (!empty($parent_language) && $parent_language != $selected_language) { @(include str_replace($selected_language, $parent_language, $source_file)); } // merge contents $lang = array_merge($lang, (array) $load_lang); $lang_info = array_merge($lang_info, (array) $load_lang_info); return true; } else { $content = @file_get_contents($source_file); //Note: target charset is always utf-8 $content = convert_charset($content, 'utf-8', $target_charset); return $content; } } return false; }
$user_ids[] = $row['id']; } $template->assign(array('users' => $users, 'all_users' => join(',', $user_ids), 'ACTIVATE_COMMENTS' => $conf['activate_comments'], 'Double_Password' => $conf['double_password_type_in_admin'])); $default_user = get_default_user_info(true); $protected_users = array($user['id'], $conf['guest_id'], $conf['default_user_id'], $conf['webmaster_id']); // an admin can't delete other admin/webmaster if ('admin' == $user['status']) { $query = ' SELECT user_id FROM ' . USER_INFOS_TABLE . ' WHERE status IN (\'webmaster\', \'admin\') ;'; $protected_users = array_merge($protected_users, query2array($query, null, 'user_id')); } $template->assign(array('PWG_TOKEN' => get_pwg_token(), 'NB_IMAGE_PAGE' => $default_user['nb_image_page'], 'RECENT_PERIOD' => $default_user['recent_period'], 'theme_options' => get_pwg_themes(), 'theme_selected' => get_default_theme(), 'language_options' => get_languages(), 'language_selected' => get_default_language(), 'association_options' => $groups, 'protected_users' => implode(',', array_unique($protected_users)), 'guest_user' => $conf['guest_id'])); // Status options foreach (get_enums(USER_INFOS_TABLE, 'status') as $status) { $label_of_status[$status] = l10n('user_status_' . $status); } $pref_status_options = $label_of_status; // a simple "admin" can set/remove statuses webmaster/admin if ('admin' == $user['status']) { unset($pref_status_options['webmaster']); unset($pref_status_options['admin']); } $template->assign('label_of_status', $label_of_status); $template->assign('pref_status_options', $pref_status_options); $template->assign('pref_status_selected', 'normal'); // user level options foreach ($conf['available_permission_levels'] as $level) {
/** * @see get_quick_search_results but without result caching */ function get_quick_search_results_no_cache($q, $options) { global $conf; $q = trim(stripslashes($q)); $search_results = array('items' => array(), 'qs' => array('q' => $q)); $q = trigger_change('qsearch_pre', $q); $scopes = array(); $scopes[] = new QSearchScope('tag', array('tags')); $scopes[] = new QSearchScope('photo', array('photos')); $scopes[] = new QSearchScope('file', array('filename')); $scopes[] = new QSearchScope('author', array(), true); $scopes[] = new QNumericRangeScope('width', array()); $scopes[] = new QNumericRangeScope('height', array()); $scopes[] = new QNumericRangeScope('ratio', array(), false, 0.001); $scopes[] = new QNumericRangeScope('size', array()); $scopes[] = new QNumericRangeScope('filesize', array()); $scopes[] = new QNumericRangeScope('hits', array('hit', 'visit', 'visits')); $scopes[] = new QNumericRangeScope('score', array('rating'), true); $scopes[] = new QNumericRangeScope('id', array()); $createdDateAliases = array('taken', 'shot'); $postedDateAliases = array('added'); if ($conf['calendar_datefield'] == 'date_creation') { $createdDateAliases[] = 'date'; } else { $postedDateAliases[] = 'date'; } $scopes[] = new QDateRangeScope('created', $createdDateAliases, true); $scopes[] = new QDateRangeScope('posted', $postedDateAliases); // allow plugins to add their own scopes $scopes = trigger_change('qsearch_get_scopes', $scopes); $expression = new QExpression($q, $scopes); // get inflections for terms $inflector = null; $lang_code = substr(get_default_language(), 0, 2); @(include_once PHPWG_ROOT_PATH . 'include/inflectors/' . $lang_code . '.php'); $class_name = 'Inflector_' . $lang_code; if (class_exists($class_name)) { $inflector = new $class_name(); foreach ($expression->stokens as $token) { if (isset($token->scope) && !$token->scope->is_text) { continue; } if (strlen($token->term) > 2 && ($token->modifier & (QST_QUOTED | QST_WILDCARD)) == 0 && strcspn($token->term, '\'0123456789') == strlen($token->term)) { $token->variants = array_unique(array_diff($inflector->get_variants($token->term), array($token->term))); } } } trigger_notify('qsearch_expression_parsed', $expression); //var_export($expression); if (count($expression->stokens) == 0) { return $search_results; } $qsr = new QResults(); qsearch_get_tags($expression, $qsr); qsearch_get_images($expression, $qsr); // allow plugins to evaluate their own scopes trigger_notify('qsearch_before_eval', $expression, $qsr); $ids = qsearch_eval($expression, $qsr, $tmp, $search_results['qs']['unmatched_terms']); $debug[] = "<!--\nparsed: " . $expression; $debug[] = count($expression->stokens) . ' tokens'; for ($i = 0; $i < count($expression->stokens); $i++) { $debug[] = $expression->stokens[$i] . ': ' . count($qsr->tag_ids[$i]) . ' tags, ' . count($qsr->tag_iids[$i]) . ' tiids, ' . count($qsr->images_iids[$i]) . ' iiids, ' . count($qsr->iids[$i]) . ' iids' . ' modifier:' . dechex($expression->stoken_modifiers[$i]) . (!empty($expression->stokens[$i]->variants) ? ' variants: ' . implode(', ', $expression->stokens[$i]->variants) : ''); } $debug[] = 'before perms ' . count($ids); $search_results['qs']['matching_tags'] = $qsr->all_tags; $search_results = trigger_change('qsearch_results', $search_results, $expression, $qsr); global $template; if (empty($ids)) { $debug[] = '-->'; $template->append('footer_elements', implode("\n", $debug)); return $search_results; } $permissions = !isset($options['permissions']) ? true : $options['permissions']; $where_clauses = array(); $where_clauses[] = 'i.id IN (' . implode(',', $ids) . ')'; if (!empty($options['images_where'])) { $where_clauses[] = '(' . $options['images_where'] . ')'; } if ($permissions) { $where_clauses[] = get_sql_condition_FandF(array('forbidden_categories' => 'category_id', 'forbidden_images' => 'i.id'), null, true); } $query = ' SELECT DISTINCT(id) FROM ' . IMAGES_TABLE . ' i'; if ($permissions) { $query .= ' INNER JOIN ' . IMAGE_CATEGORY_TABLE . ' AS ic ON id = ic.image_id'; } $query .= ' WHERE ' . implode("\n AND ", $where_clauses) . "\n" . $conf['order_by']; $ids = query2array($query, null, 'id'); $debug[] = count($ids) . ' final photo count -->'; $template->append('footer_elements', implode("\n", $debug)); $search_results['items'] = $ids; return $search_results; }
} } else { $language['state'] = 'inactive'; } if ($language_id == $default_language) { $language['is_default'] = true; array_unshift($tpl_languages, $language); } else { $language['is_default'] = false; $tpl_languages[] = $language; } } $template->assign(array('languages' => $tpl_languages)); $template->append('language_states', 'active'); $template->append('language_states', 'inactive'); $missing_language_ids = array_diff(array_keys($languages->db_languages), array_keys($languages->fs_languages)); foreach ($missing_language_ids as $language_id) { $query = ' UPDATE ' . USER_INFOS_TABLE . ' SET language = \'' . get_default_language() . '\' WHERE language = \'' . $language_id . '\' ;'; pwg_query($query); $query = ' DELETE FROM ' . LANGUAGES_TABLE . ' WHERE id= \'' . $language_id . '\' ;'; pwg_query($query); } $template->assign_var_from_handle('ADMIN_CONTENT', 'languages');
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; }
/** * Send a email to all administrators. * current user (if admin) is excluded * @see pwg_mail() * @since 2.6 * * @param array $args - as in pwg_mail() * @param array $tpl - as in pwg_mail() * @return boolean */ function pwg_mail_admins($args = array(), $tpl = array()) { if (empty($args['content']) and empty($tpl)) { return false; } global $conf, $user; $return = true; // get admins (except ourself) $query = ' SELECT u.' . $conf['user_fields']['username'] . ' AS name, u.' . $conf['user_fields']['email'] . ' AS email FROM ' . USERS_TABLE . ' AS u JOIN ' . USER_INFOS_TABLE . ' AS i ON i.user_id = u.' . $conf['user_fields']['id'] . ' WHERE i.status in (\'webmaster\', \'admin\') AND u.' . $conf['user_fields']['email'] . ' IS NOT NULL AND i.user_id <> ' . $user['id'] . ' ORDER BY name ;'; $admins = array_from_query($query); if (empty($admins)) { return $return; } switch_lang_to(get_default_language()); $return = pwg_mail($admins, $args, $tpl); switch_lang_back(); return $return; }
/** * Perform requested actions * @param string - action * @param string - language id * @param array - errors */ function perform_action($action, $language_id) { global $conf; if (isset($this->db_languages[$language_id])) { $crt_db_language = $this->db_languages[$language_id]; } $errors = array(); switch ($action) { case 'activate': if (isset($crt_db_language)) { $errors[] = 'CANNOT ACTIVATE - LANGUAGE IS ALREADY ACTIVATED'; break; } $query = ' INSERT INTO ' . LANGUAGES_TABLE . ' (id, version, name) VALUES(\'' . $language_id . '\', \'' . $this->fs_languages[$language_id]['version'] . '\', \'' . $this->fs_languages[$language_id]['name'] . '\') ;'; pwg_query($query); break; case 'deactivate': if (!isset($crt_db_language)) { $errors[] = 'CANNOT DEACTIVATE - LANGUAGE IS ALREADY DEACTIVATED'; break; } if ($language_id == get_default_language()) { $errors[] = 'CANNOT DEACTIVATE - LANGUAGE IS DEFAULT LANGUAGE'; break; } $query = ' DELETE FROM ' . LANGUAGES_TABLE . ' WHERE id= \'' . $language_id . '\' ;'; pwg_query($query); break; case 'delete': if (!empty($crt_db_language)) { $errors[] = 'CANNOT DELETE - LANGUAGE IS ACTIVATED'; break; } if (!isset($this->fs_languages[$language_id])) { $errors[] = 'CANNOT DELETE - LANGUAGE DOES NOT EXIST'; break; } // Set default language to user who are using this language $query = ' UPDATE ' . USER_INFOS_TABLE . ' SET language = \'' . get_default_language() . '\' WHERE language = \'' . $language_id . '\' ;'; pwg_query($query); deltree(PHPWG_ROOT_PATH . 'language/' . $language_id, PHPWG_ROOT_PATH . 'language/trash'); break; case 'set_default': $query = ' UPDATE ' . USER_INFOS_TABLE . ' SET language = \'' . $language_id . '\' WHERE user_id IN (' . $conf['default_user_id'] . ', ' . $conf['guest_id'] . ') ;'; pwg_query($query); break; } return $errors; }
<?php if (!defined('PHPWG_ROOT_PATH')) { die('Hacking attempt!'); } $languages = get_languages(); if (isset($_POST['edit'])) { $_POST['language'] = $_POST['language_select']; } if (isset($_POST['language'])) { $page['language'] = $_POST['language']; } if (!isset($page['language']) or !in_array($page['language'], array_keys($languages))) { $page['language'] = get_default_language(); } $template->assign('language', $page['language']); $edited_file = PHPWG_ROOT_PATH . PWG_LOCAL_DIR . 'language/' . $page['language'] . '.lang.php'; if (file_exists($edited_file)) { $content_file = file_get_contents($edited_file); } else { $content_file = "<?php\n\n/* " . l10n('locfiledit_newfile') . " */\n\n\n\n\n?>"; } $selected = 0; foreach (get_languages() as $language_code => $language_name) { $file = PHPWG_ROOT_PATH . PWG_LOCAL_DIR . 'language/' . $language_code . '.lang.php'; $options[$language_code] = (file_exists($file) ? '✔' : '✘') . ' ' . $language_name; if ($page['language'] == $language_code) { $selected = $language_code; $template->assign('show_default', array(array('URL' => LOCALEDIT_PATH . 'show_default.php?file=language/' . $language_code . '/common.lang.php', 'FILE' => 'common.lang.php'), array('URL' => LOCALEDIT_PATH . 'show_default.php?file=language/' . $language_code . '/admin.lang.php', 'FILE' => 'admin.lang.php'))); } }
/** * Function called from main.inc.php to send validation email * * @param : Type of email, user id, username, email address, confirmation (optional) * */ function SendMail2User($typemail, $id, $username, $password, $email, $confirm) { global $conf; $conf_UAM = unserialize($conf['UserAdvManager']); $conf_UAM_ConfirmMail = unserialize($conf['UserAdvManager_ConfirmMail']); include_once PHPWG_ROOT_PATH . 'include/functions_mail.inc.php'; $infos1_perso = ""; $infos2_perso = ""; $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); } switch ($typemail) { case 1: // Confirmation email on user registration - Without information email (already managed by Piwigo) if (isset($conf_UAM['CONFIRMMAIL_SUBJECT']) and !empty($conf_UAM['CONFIRMMAIL_SUBJECT'])) { // Management of Extension flags ([username], [mygallery]) // ------------------------------------------------------- $patterns[] = '#\\[username\\]#i'; $replacements[] = $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['CONFIRMMAIL_SUBJECT'])) . "\n\n"; } else { $subject = l10n(preg_replace($patterns, $replacements, $conf_UAM['CONFIRMMAIL_SUBJECT'])) . "\n\n"; } } break; case 2: // Confirmation email on user profile update - Information email if modification done in user profile if (isset($conf_UAM['INFOMAIL_SUBJECT']) and !empty($conf_UAM['INFOMAIL_SUBJECT'])) { // Management of Extension flags ([username], [mygallery]) // ------------------------------------------------------- $patterns[] = '#\\[username\\]#i'; $replacements[] = $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['INFOMAIL_SUBJECT'])) . "\n\n"; } else { $subject = l10n(preg_replace($patterns, $replacements, $conf_UAM['INFOMAIL_SUBJECT'])) . "\n\n"; } } $password = !empty($password) ? $password : l10n('UAM_no_update_pwd'); if (isset($conf_UAM['MAILINFO_TEXT']) and !empty($conf_UAM['MAILINFO_TEXT'])) { // Management of Extension flags ([username], [mygallery], [myurl]) // ---------------------------------------------------------------- $patterns[] = '#\\[username\\]#i'; $replacements[] = $username; $patterns[] = '#\\[mygallery\\]#i'; $replacements[] = $conf['gallery_title']; $patterns[] = '#\\[myurl\\]#i'; $replacements[] = get_gallery_home_url(); if (function_exists('get_user_language_desc')) { $infos1_perso = get_user_language_desc(preg_replace($patterns, $replacements, $conf_UAM['MAILINFO_TEXT'])) . "\n\n"; } else { $infos1_perso = l10n(preg_replace($patterns, $replacements, $conf_UAM['MAILINFO_TEXT'])) . "\n\n"; } } if (isset($conf_UAM['MAIL_INFO']) and $conf_UAM['MAIL_INFO'] == 'true') { if (isset($conf_UAM['HIDEPASSW']) and $conf_UAM['HIDEPASSW'] == 'true') { $infos1 = array(get_l10n_args('UAM_infos_mail %s', stripslashes($username)), get_l10n_args('UAM_User: %s', stripslashes($username)), get_l10n_args('UAM_Password: %s', $password), get_l10n_args('Email: %s', $email), get_l10n_args('', '')); } else { $infos1 = array(get_l10n_args('UAM_infos_mail %s', stripslashes($username)), get_l10n_args('UAM_User: %s', stripslashes($username)), get_l10n_args('Email: %s', $email), get_l10n_args('', '')); } } break; } if (isset($conf_UAM['CONFIRM_MAIL']) and $conf_UAM['CONFIRM_MAIL'] == 'true' and $confirm) { $infos2 = array(get_l10n_args('UAM_Link: %s', AddConfirmMail($id, $email)), get_l10n_args('', '')); if (isset($conf_UAM['CONFIRMMAIL_TEXT']) and !empty($conf_UAM['CONFIRMMAIL_TEXT'])) { // Management of Extension flags ([username], [mygallery], [myurl], [Kdays]) // ------------------------------------------------------------------------- $patterns[] = '#\\[username\\]#i'; $replacements[] = $username; $patterns[] = '#\\[mygallery\\]#i'; $replacements[] = $conf['gallery_title']; $patterns[] = '#\\[myurl\\]#i'; $replacements[] = get_gallery_home_url(); if (isset($conf_UAM_ConfirmMail['CONFIRMMAIL_TIMEOUT']) and $conf_UAM_ConfirmMail['CONFIRMMAIL_TIMEOUT'] == 'true') { $patterns[] = '#\\[Kdays\\]#i'; $replacements[] = $conf_UAM_ConfirmMail['CONFIRMMAIL_DELAY']; } if (function_exists('get_user_language_desc')) { $infos2_perso = get_user_language_desc(preg_replace($patterns, $replacements, $conf_UAM['CONFIRMMAIL_TEXT'])) . "\n\n"; } else { $infos2_perso = l10n(preg_replace($patterns, $replacements, $conf_UAM['CONFIRMMAIL_TEXT'])) . "\n\n"; } } } // $converted_res = ($confirm) ? 'true' : 'false'; // UAMLog($typemail,$converted_res,$conf_UAM['CONFIRM_MAIL'],$subject); // Sending the email with subject and contents // ------------------------------------------- if (isset($conf_UAM['CONFIRM_MAIL']) and $conf_UAM['CONFIRM_MAIL'] == 'local' and $confirm) { switch_lang_to(get_default_language()); load_language('plugin.lang', UAM_PATH); $subject_admin = get_l10n_args('UAM_Subject admin validation for %s', $username); $content_admin = array(get_l10n_args('UAM_Manual_validation_needed_for %s', stripslashes($username)), get_l10n_args('', ''), get_l10n_args('UAM_Link: %s', AddConfirmMail($id, $email))); pwg_mail_notification_admins($subject_admin, $content_admin, true); } if (isset($conf_UAM['CONFIRM_MAIL']) and $conf_UAM['CONFIRM_MAIL'] == 'true' and $confirm) { // 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_confirmation = (isset($infos1) ? $infos1_perso . l10n_args($infos1) . "\n\n" : "") . (isset($infos2) ? $infos2_perso . l10n_args($infos2) . "\n\n" : "") . get_absolute_root_url(); pwg_mail(array('name' => stripslashes($username), 'email' => $email), array('content' => $content_confirmation, '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_confirmation); } } elseif (isset($conf_UAM['ADD_GALLERY_URL_TO_EMAILS']) and $conf_UAM['ADD_GALLERY_URL_TO_EMAILS'] == 'false') { $content_confirmation = (isset($infos1) ? $infos1_perso . l10n_args($infos1) . "\n\n" : "") . (isset($infos2) ? $infos2_perso . l10n_args($infos2) . "\n\n" : ""); pwg_mail(array('name' => stripslashes($username), 'email' => $email), array('content' => $content_confirmation, '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_confirmation); } } else { $content_confirmation = (isset($infos1) ? $infos1_perso . l10n_args($infos1) . "\n\n" : "") . (isset($infos2) ? $infos2_perso . l10n_args($infos2) . "\n\n" : ""); pwg_mail(array('name' => stripslashes($username), 'email' => $email), array('content' => $content_confirmation, '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_confirmation); } } } if (isset($conf_UAM['MAIL_INFO']) and $conf_UAM['MAIL_INFO'] == 'true' and $typemail != 1) { // 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_info = (isset($infos1) ? $infos1_perso . l10n_args($infos1) . "\n\n" : "") . (isset($infos2) ? $infos2_perso . l10n_args($infos2) . "\n\n" : "") . get_absolute_root_url(); pwg_mail(array('name' => stripslashes($username), 'email' => $email), array('content' => $content_info, '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_info); } } elseif (isset($conf_UAM['ADD_GALLERY_URL_TO_EMAILS']) and $conf_UAM['ADD_GALLERY_URL_TO_EMAILS'] == 'false') { $content_info = (isset($infos1) ? $infos1_perso . l10n_args($infos1) . "\n\n" : "") . (isset($infos2) ? $infos2_perso . l10n_args($infos2) . "\n\n" : ""); pwg_mail(array('name' => stripslashes($username), 'email' => $email), array('content' => $content_info, '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_info); } } else { $content_info = (isset($infos1) ? $infos1_perso . l10n_args($infos1) . "\n\n" : "") . (isset($infos2) ? $infos2_perso . l10n_args($infos2) . "\n\n" : ""); pwg_mail(array('name' => stripslashes($username), 'email' => $email), array('content' => $content_info, '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_info); } } } // Switching back to default language // ---------------------------------- switch_lang_back(); }