// | modify it under the terms of the GNU General Public License | // | as published by the Free Software Foundation; either version 2 | // | of the License, or (at your option) any later version. | // | | // | This program is distributed in the hope that it will be useful, | // | but WITHOUT ANY WARRANTY; without even the implied warranty of | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | // | GNU General Public License for more details. | // | | // | You should have received a copy of the GNU General Public License | // | along with this program; if not, write to the Free Software Foundation, | // | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | // | | // +--------------------------------------------------------------------------+ require_once 'lib-common.php'; USES_lib_user(); USES_lib_social(); if (!isset($_SYSTEM['verification_token_ttl'])) { $_SYSTEM['verification_token_ttl'] = 86400; } /** * Shows a profile for a user * * This grabs the user profile for a given user and displays it * * @return string HTML for user profile page * */ function userprofile() { global $_CONF, $_TABLES, $_USER, $LANG01, $LANG04, $LANG09, $LANG28, $LANG_LOGIN;
/** * This function actually sends the messages to the specified group * * @param array $vars Same as $_POST, holds all the email info * @return string HTML with success or error message * */ function MAIL_sendMessages($vars) { global $_CONF, $_TABLES, $LANG31; USES_lib_user(); $retval = ''; $html = 0; $message = $vars['message']; if ($vars['postmode'] == 'html') { $html = true; } $usermode = (int) $vars['to_uid'] > 0 && (int) $vars['to_group'] == 0 ? true : false; if (empty($vars['fra']) or empty($vars['fraepost']) or empty($vars['subject']) or empty($message) or empty($vars['to_group']) && empty($vars['to_uid'])) { $retval .= COM_showMessageText($LANG31[26], $LANG31[1], true); $msg = htmlspecialchars($vars['message'], ENT_COMPAT, COM_getEncodingt()); $subject = htmlspecialchars($vars['subject'], ENT_COMPAT, COM_getEncodingt()); $fra = htmlspecialchars($vars['fra'], ENT_COMPAT, COM_getEncodingt()); $fraepost = htmlspecialchars($vars['fraepost'], ENT_COMPAT, COM_getEncodingt()); $retval .= MAIL_displayForm($vars['to_uid'], $vars['to_group'], $fra, $fraepost, $subject, $msg); return $retval; } // Urgent message! if (isset($vars['priority'])) { $priority = 1; } else { $priority = 0; } $toUsers = array(); if ($usermode) { $result = DB_query("SELECT email,username FROM {$_TABLES['users']} WHERE uid=" . (int) COM_applyFilter($vars['to_uid'], true)); if (DB_numRows($result) > 0) { list($email, $username) = DB_fetchArray($result); $toUsers[] = COM_formatEmailAddress($username, $email); } } else { $groupList = implode(',', USER_getChildGroups((int) COM_applyFilter($vars['to_group'], true))); // and now mail it if (isset($vars['overstyr'])) { $sql = "SELECT DISTINCT username,fullname,email FROM {$_TABLES['users']},{$_TABLES['group_assignments']} WHERE uid > 1"; $sql .= " AND {$_TABLES['users']}.status = 3 AND ((email is not null) and (email != ''))"; $sql .= " AND {$_TABLES['users']}.uid = ug_uid AND ug_main_grp_id IN ({$groupList})"; } else { $sql = "SELECT DISTINCT username,fullname,email,emailfromadmin FROM {$_TABLES['users']},{$_TABLES['userprefs']},{$_TABLES['group_assignments']} WHERE {$_TABLES['users']}.uid > 1"; $sql .= " AND {$_TABLES['users']}.status = 3 AND ((email is not null) and (email != ''))"; $sql .= " AND {$_TABLES['users']}.uid = {$_TABLES['userprefs']}.uid AND emailfromadmin = 1"; $sql .= " AND ug_uid = {$_TABLES['users']}.uid AND ug_main_grp_id IN ({$groupList})"; } $result = DB_query($sql); $nrows = DB_numRows($result); for ($i = 0; $i < $nrows; $i++) { $A = DB_fetchArray($result); if (empty($A['fullname'])) { $toUsers[] = COM_formatEmailAddress($A['username'], $A['email']); } else { $toUsers[] = COM_formatEmailAddress($A['fullname'], $A['email']); } } } $from = array(); $from = COM_formatEmailAddress($vars['fra'], $vars['fraepost']); $subject = $vars['subject']; // Loop through and send the messages! $successes = array(); $failures = array(); foreach ($toUsers as $to) { if (defined('DEMO_MODE')) { $successes[] = htmlspecialchars($to[0]); } else { if (!COM_mail($to, $subject, $message, $from, $html, $priority)) { $failures[] = htmlspecialchars($to[0]); } else { $successes[] = htmlspecialchars($to[0]); } } } $retval .= COM_startBlock($LANG31[1]); $failcount = count($failures); $successcount = count($successes); $mailresult = str_replace('<successcount>', $successcount, $LANG31[20]); $retval .= str_replace('<failcount>', $failcount, $mailresult); $retval .= '<h2>' . $LANG31[21] . '</h2>'; for ($i = 0; $i < count($failures); $i++) { $retval .= current($failures) . '<br/>'; next($failures); } if (count($failures) == 0) { $retval .= $LANG31[23]; } $retval .= '<h2>' . $LANG31[22] . '</h2>'; for ($i = 0; $i < count($successes); $i++) { $retval .= current($successes) . '<br/>'; next($successes); } if (count($successes) == 0) { $retval .= $LANG31[24]; } $retval .= COM_endBlock(); return $retval; }