function home() { global $user; $sql = 'SELECT * FROM _email WHERE email_active = ?? LIMIT ??'; if (!($email = _fieldrow(sql_filter($sql, 1, 1)))) { $this->e('No queue emails.'); } set_time_limit(0); if (!$email['email_start']) { $sql = 'UPDATE _email SET email_start = ? WHERE email_id = ?'; _sql(sql_filter($sql, time(), $email['email_id'])); } $sql = 'SELECT user_id, user_username, user_email FROM _members WHERE user_type = ? AND user_id <> ? ORDER BY user_username LIMIT ??, ??'; $members = _rowset(sql_filter($sql, 1, 1, $email['email_last'], 100)); $i = 0; foreach ($members as $row) { if (!preg_match('/^[a-z0-9\\.\\-_\\+]+@[a-z0-9\\-_]+\\.([a-z0-9\\-_]+\\.)*?[a-z]+$/is', $row['user_email'])) { continue; } if (!$i) { include XFS . 'core/emailer.php'; $emailer = new emailer(); } $emailer->use_template('mass'); $emailer->format('plain'); $emailer->from('TWC Kaulitz <*****@*****.**>'); $emailer->set_subject(entity_decode($email['email_subject'])); $emailer->email_address($row['user_email']); $emailer->assign_vars(array('USERNAME' => $row['user_username'], 'MESSAGE' => entity_decode($email['email_message']))); $emailer->send(); $emailer->reset(); sleep(2); $i++; } if ($i) { $email['email_last'] += $i; $sql = 'UPDATE _email SET email_last = ? WHERE email_id = ?'; _sql(sql_filter($sql, $email['email_last'], $email['email_id'])); } else { $sql = 'UPDATE _email SET email_active = ?, email_end = ? WHERE email_id = ?'; _sql(sql_filter($sql, 0, time(), $email['email_id'])); $this->e('Finished processing [' . $email['email_id'] . '] emails.'); } $this->e('Processed ' . $i . ' emails.'); return; }
public function _home() { global $config, $user, $cache; if (!_button()) { return false; } $username1 = request_var('username1', ''); $username2 = request_var('username2', ''); if (empty($username1) || empty($username2)) { fatal_error(); } $username_base1 = get_username_base($username1); $username_base2 = get_username_base($username2); $sql = 'SELECT * FROM _members WHERE username_base = ?'; if (!$userdata = sql_fieldrow(sql_filter($sql, $username_base1))) { _pre('El usuario no existe.', true); } $sql = 'SELECT * FROM _members WHERE username_base = ?'; if ($void = sql_fieldrow(sql_filter($sql, $username_base2))) { _pre('El usuario ya existe.', true); } // $sql = 'UPDATE _members SET username = ?, username_base = ? WHERE user_id = ?'; sql_query(sql_filter($sql, $username2, $username_base2, $userdata['user_id'])); $emailer = new emailer(); $emailer->from('info'); $emailer->use_template('username_change', $config['default_lang']); $emailer->email_address($userdata['user_email']); $emailer->assign_vars(array( 'USERNAME' => $userdata['username'], 'NEW_USERNAME' => $username2, 'U_USERNAME' => s_link('m', $username_base2)) ); $emailer->send(); $emailer->reset(); redirect(s_link('m', $username_base2)); return; }
function home() { $sql = 'SELECT * FROM _members WHERE user_type = ? AND user_birthday LIKE ? AND user_birthday_last < ? ORDER BY user_username LIMIT ??'; $birthday = _rowset(sql_filter($sql, 1, '%' . date('md'), date('Y'), 10)); if (!$birthday) { $this->e('None.'); } $process = w(); foreach ($birthday as $i => $row) { if (!$i) { @set_time_limit(0); require XFS . 'core/emailer.php'; $emailer = new emailer(); } $emailer->format('plain'); $emailer->from('TWC Kaulitz <*****@*****.**>'); $emailer->use_template('user_birthday'); $emailer->email_address($row['user_email']); $emailer->assign_vars(array('USERNAME' => $row['user_username'])); $emailer->send(); $emailer->reset(); $process[$row['user_id']] = $row['user_username']; } if (count($process)) { $sql = 'UPDATE _members SET user_birthday_last = ? WHERE user_id IN (??)'; _sql(sql_filter($sql, date('Y'), _implode(',', array_keys($process)))); } return $this->e('Done @ ' . implode(',', array_values($process))); }
function album_comment_notify($pic_id) { global $db, $config, $user, $lang, $album_config; // One row SQL for caching purpose... $sql = "SELECT ban_userid FROM " . BANLIST_TABLE . " WHERE ban_userid <> 0 ORDER BY ban_userid ASC"; $result = $db->sql_query($sql, 0, 'ban_', USERS_CACHE_FOLDER); $user_id_sql = ''; while ($row = $db->sql_fetchrow($result)) { if (isset($row['ban_userid']) && !empty($row['ban_userid'])) { $user_id_sql .= ', ' . $row['ban_userid']; } } $sql = "SELECT u.user_id, u.user_email, u.user_lang, p.pic_title\n\t\t\t\tFROM " . ALBUM_COMMENT_WATCH_TABLE . " cw, " . USERS_TABLE . " u\n\t\t\t\tLEFT JOIN " . ALBUM_TABLE . " AS p ON p.pic_id = {$pic_id}\n\t\t\t\tWHERE cw.pic_id = {$pic_id}\n\t\t\t\t\tAND cw.user_id NOT IN (" . $user->data['user_id'] . ", " . ANONYMOUS . $user_id_sql . ")\n\t\t\t\t\tAND cw.notify_status = " . COMMENT_WATCH_UN_NOTIFIED . "\n\t\t\t\t\tAND u.user_id = cw.user_id"; $result = $db->sql_query($sql); $bcc_list_ary = array(); if ($row = $db->sql_fetchrow($result)) { $pic_title = $row['pic_title']; // Sixty second limit @set_time_limit(60); do { if ($row['user_email'] != '') { $bcc_list_ary[$row['user_lang']][] = $row['user_email']; } $update_watched_sql .= $update_watched_sql != '' ? ', ' . $row['user_id'] : $row['user_id']; } while ($row = $db->sql_fetchrow($result)); // // Let's do some checking to make sure that mass mail functions // are working in win32 versions of php. // if (preg_match('/[c-z]:\\\\.*/i', getenv('PATH')) && !$config['smtp_delivery']) { $ini_val = @phpversion() >= '4.0.0' ? 'ini_get' : 'get_cfg_var'; // We are running on windows, force delivery to use our smtp functions // since php's are broken by default $config['smtp_delivery'] = 1; $config['smtp_host'] = @$ini_val('SMTP'); } if (sizeof($bcc_list_ary)) { include IP_ROOT_PATH . 'includes/emailer.' . PHP_EXT; $emailer = new emailer(); $server_url = create_server_url(); $album_showpage_url = $server_url . 'album_showpage.' . PHP_EXT; @reset($bcc_list_ary); while (list($user_lang, $bcc_list) = each($bcc_list_ary)) { $emailer->use_template('album_comment_notify', $user_lang); for ($i = 0; $i < sizeof($bcc_list); $i++) { $emailer->bcc($bcc_list[$i]); } // The Comment_notification lang string below will be used // if for some reason the mail template subject cannot be read // ... note it will not necessarily be in the posters own language! $emailer->set_subject($lang['Pic_comment_notification']); // This is a nasty kludge to remove the username var ... till translators update their templates $emailer->msg = preg_replace('#[ ]?{USERNAME}#', '', $emailer->msg); $email_sig = create_signature($config['board_email_sig']); $emailer->assign_vars(array('EMAIL_SIG' => $email_sig, 'SITENAME' => $config['sitename'], 'PIC_TITLE' => $pic_title, 'U_PIC' => $album_showpage_url . '?pic_id=' . $pic_id, 'U_STOP_WATCHING_COMMENT' => $album_showpage_url . '?pic_id=' . $pic_id . '&unwatch=comment')); $emailer->send(); $emailer->reset(); } } } $db->sql_freeresult($result); if ($update_watched_sql != '') { $sql = "UPDATE " . ALBUM_COMMENT_WATCH_TABLE . "\n\t\t\tSET notify_status = " . COMMENT_WATCH_NOTIFIED . "\n\t\t\tWHERE pic_id = {$pic_id}\n\t\t\t\tAND user_id IN ({$update_watched_sql})"; $db->sql_query($sql); } }
public function _home() { global $config, $user, $cache; $user_id = request_var('uid', 0); if (_button() || $user_id) { $username = request_var('username', ''); $user_email = request_var('user_email', ''); if ($user_id) { $sql = 'SELECT * FROM _members WHERE user_id = '; $sql = sql_filter($sql, $user_id); } else if (!empty($username)) { $username = get_username_base($username); $sql = 'SELECT * FROM _members WHERE username_base = ?'; $sql = sql_filter($sql, $username); } else { $sql = 'SELECT * FROM _members WHERE user_email = ?'; $sql = sql_filter($sql, $user_email); } if (!$userdata = sql_fieldrow($sql)) { exit; } // $user_id = $userdata['user_id']; $sql = 'UPDATE _members SET user_type = ? WHERE user_id = ?'; sql_query(sql_filter($sql, USER_NORMAL, $user_id)); $sql = 'DELETE FROM _crypt_confirm WHERE crypt_code = ? AND crypt_userid = ?'; sql_query(sql_filter($sql, $code, $user_id)); $emailer = new emailer(); $emailer->from('info'); $emailer->use_template('user_welcome_confirm'); $emailer->email_address($userdata['user_email']); $emailer->assign_vars(array( 'USERNAME' => $userdata['username']) ); $emailer->send(); $emailer->reset(); _pre('La cuenta de <strong>' . $userdata['username'] . '</strong> ha sido activada.', true); } $sql = 'SELECT * FROM _members WHERE user_type = 1 ORDER BY username'; $result = sql_rowset($sql); foreach ($result as $i => $row) { if (!$i) _style('list'); _style('list.row', array( 'LINK' => s_link($this->name, $row['user_id']), 'USERNAME' => $row['username'], 'EMAIL' => $row['user_email'], 'DATE' => $row['user_regdate'], 'IP' => $row['user_regip']) ); } return; }
} if ($to_userdata['user_notify_pm'] && !empty($to_userdata['user_email']) && $to_userdata['user_active']) { $script_name = preg_replace('/^\\/?(.*?)\\/?$/', "\\1", trim($board_config['script_path'])); $script_name = $script_name != '' ? $script_name . '/privmsg.' . $phpEx : 'privmsg.' . $phpEx; $server_name = trim($board_config['server_name']); $server_protocol = $board_config['cookie_secure'] ? 'https://' : 'http://'; $server_port = $board_config['server_port'] != 80 ? ':' . trim($board_config['server_port']) . '/' : '/'; include $phpbb_root_path . 'includes/emailer.' . $phpEx; $emailer = new emailer($board_config['smtp_delivery']); $emailer->from($board_config['board_email']); $emailer->replyto($board_config['board_email']); $emailer->use_template('privmsg_notify', $to_userdata['user_lang']); $emailer->email_address($to_userdata['user_email']); $emailer->set_subject($lang['Notification_subject']); $emailer->assign_vars(array('USERNAME' => stripslashes($to_username), 'SENDER_USERNAME' => htmlspecialchars($userdata['username']), 'PM_SUBJECT' => $privmsg_subject, 'PM_MESSAGE' => $message_text, 'SITENAME' => $board_config['sitename'], 'EMAIL_SIG' => !empty($board_config['board_email_sig']) ? str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']) : '', 'U_INBOX' => $server_protocol . $server_name . $server_port . $script_name . '?folder=inbox')); $emailer->send(); $emailer->reset(); } } /* $template->assign_vars(array( 'META' => '<meta http-equiv="refresh" content="3;url=' . append_sid("privmsg.$phpEx?folder=inbox") . '">') ); $msg = $lang['Message_sent'] . '<br /><br />' . sprintf($lang['Click_return_inbox'], '<a href="' . append_sid("privmsg.$phpEx?folder=inbox") . '">', '</a> ') . '<br /><br />' . sprintf($lang['Click_return_index'], '<a href="' . append_sid("index.$phpEx") . '">', '</a>'); message_die(GENERAL_MESSAGE, $msg); */ //-- mod : Instant Post Redirect ------------------------------------------------------------ //-- add redirect(append_sid("privmsg.{$phpEx}?folder=inbox"));
function notification($sender_id, $recipient_id, $recipient_email, $email_subject, $email_text, $use_bcc = false, $pm_subject = '', $recipient_username = '', $recipient_lang = '', $emty_email_template = false) { global $db, $config, $user, $lang; require IP_ROOT_PATH . 'includes/emailer.' . PHP_EXT; $recipient_lang = empty($recipient_lang) ? $config['default_lang'] : $recipient_lang; // Let's do some checking to make sure that mass mail functions are working in win32 versions of php. if (preg_match('/[c-z]:\\\\.*/i', getenv('PATH')) && !$config['smtp_delivery']) { // We are running on windows, force delivery to use our smtp functions since php's are broken by default $config['smtp_delivery'] = 1; $config['smtp_host'] = @ini_get('SMTP'); } $emailer = new emailer(); $emailer->headers('X-AntiAbuse: Board servername - ' . trim($config['server_name'])); $emailer->headers('X-AntiAbuse: User_id - ' . $user->data['user_id']); $emailer->headers('X-AntiAbuse: Username - ' . $user->data['username']); $emailer->headers('X-AntiAbuse: User IP - ' . $user->ip); if ($use_bcc) { $emailer->to($config['board_email']); $emailer->bcc($recipient_email); } else { $emailer->to($recipient_email); } $emailer->set_subject($email_subject); if ($emty_email_template) { $emailer->use_template('admin_send_email', $recipient_lang); $emailer->assign_vars(array('SITENAME' => $config['sitename'], 'BOARD_EMAIL' => $config['board_email'], 'MESSAGE' => $email_text)); } else { $server_url = create_server_url(); $privmsg_url = $server_url . CMS_PAGE_PRIVMSG; $recipient_username = empty($recipient_username) ? $lang['User'] : $recipient_username; $email_sig = create_signature($config['board_email_sig']); $emailer->use_template('privmsg_notify', $recipient_lang); $emailer->assign_vars(array('USERNAME' => $recipient_username, 'SITENAME' => $config['sitename'], 'EMAIL_SIG' => $email_sig, 'FROM' => $user->data['username'], 'DATE' => create_date($config['default_dateformat'], time(), $config['board_timezone']), 'SUBJECT' => $pm_subject, 'PRIV_MSG_TEXT' => $email_text, 'FROM_USERNAME' => $user->data['username'], 'U_INBOX' => $privmsg_url . '?folder=inbox')); } $emailer->send(); $emailer->reset(); return true; }
public function home() { global $core, $user; $tree = $this->valid_tree(); $v = $this->__(_array_keys(w('is_comment is_form'), 0)); // Form posting enabled and form submitted if ($v['is_form'] && _button()) { if (!is_ghost()) { _fatal(405); } if (!$tree['tree_form']) { _fatal(); } $sql_fields = 'SELECT form_alias, form_required, form_legend, form_regex, FROM _form_fields WHERE form_tree = ? ORDER BY form_order'; if (!($form = _rowset(sql_filter($sql_fields, $tree['tree_id']), 'form_alias'))) { $form = _rowset(sql_filter($sql_fields, 0), 'form_alias'); } $form['secure'] = array('form_required' => 1, 'form_regex' => '^([a-zA-Z]+)$', 'form_alias' => 'secure', 'form_type' => 'text', 'form_legend' => _lang('XCF_LEGEND')); foreach ($form as $row) { $v = array_merge($v, $this->__(array($row['form_alias']))); if (!f($v[$row['form_alias']])) { if ($row['form_required']) { $this->_error(sprintf(_lang('E_COMMENT_FIELD_EMPTY'), $row['form_legend']), false); } continue; } if (f($row['form_regex']) && !preg_match('#' . $row['form_regex'] . '#is', $v[$row['form_alias']])) { $this->_error(sprintf(_lang('E_COMMENT_FIELD_BAD'), $row['form_legend']), false); if ($row['form_alias'] == 'secure') { $v[$row['form_alias']] = ''; } } } require_once XFS . 'core/xcf.php'; $xcf = new captcha(); if ($xcf->check($v['secure']) === false) { $v['secure'] = ''; $this->_error('#E_COMMENT_INVALID_CAPTCHA'); } unset($xcf); require_once XFS . 'core/emailer.php'; $emailer = new emailer(); $emailer->set_decode(true); $emailer->format('plain'); $emailer->from($v['address']); $emailer->set_subject(_rm_acute($v['subject'])); $emailer->use_template('contact_email'); if (f($core->v('default_email'))) { $tree['tree_form_email'] .= (f($tree['tree_form_email']) ? ';' : '') . $core->v('default_email'); } $form_addresses = array_map('trim', array_unique(explode(';', $tree['tree_form_email']))); foreach ($form_addresses as $i => $address) { $row_f = !$i ? 'email_address' : 'cc'; $emailer->{$row_f}($address); } unset($v['secure']); $content = w(); foreach ($form as $row) { if (!f($v[$row['form_alias']])) { continue; } $content[] = $row['form_legend'] . ":\n" . $v[$row['form_alias']]; } $emailer->assign_vars(array('CONTENT' => implode("\n\n", $content), 'FORM_ARTICLE' => $tree['tree_subject'])); $emailer->send(); $emailer->reset(); $response = array('lang' => _lang('FORM_SUCCESS')); $this->e(json_encode($response)); } // Comment posting enabled and form submitted. if ($v['is_comment'] && _button()) { if (!$tree['tree_allow_comments']) { _fatal(); } $cv = $this->__(w('comment_username comment_address comment_website comment_message comment_security')); $comment_time = time(); if (!$user->v('is_member')) { foreach ($cv as $cv_k => $cv_v) { if (!f($cv_v)) { $this->error('E_COMMENT_FILL_FIELDS'); break; } } if (!$this->errors()) { $sql = 'SELECT comment_time FROM _comments WHERE comment_ip = ? AND comment_status = 0'; if ($row_flood = _fieldrow(sql_filter($sql, $user->ip))) { if ($comment_time - $row_flood['comment_time'] < 30) { $this->error('E_COMMENT_FLOOD_TIME'); } } } // CAPTCHA verification require_once XFS . 'core/xcf.php'; $xcf = new captcha(); if ($xcf->check($cv['comment_security']) === false) { $cv['comment_security'] = ''; $this->error('E_COMMENT_INVALID_CAPTCHA'); } unset($xcf); } if (!$this->errors()) { $approve_comments = !$user->v('is_member') ? $tree['tree_approve_comments'] : 1; $sql_insert = array('tree' => (int) $tree['tree_id'], 'uid' => (int) $user->v('user_id'), 'username' => $cv['comment_username'], 'email' => $cv['comment_address'], 'website' => $cv['comment_website'], 'ip' => $user->ip, 'status' => (int) $approve_comments, 'time' => (int) $comment_time, 'message' => $cv['comment_message']); $sql = 'INSERT INTO _comments' . _build_array('INSERT', prefix('comment', $sql_insert)); _sql($sql); if ($approve_comments) { $sql = 'UPDATE _tree SET tree_comments = tree_comments + 1 WHERE tree_id = ?'; _sql(sql_filter($sql, $tree['tree_id'])); } // Send new comment email notification for approval. if (!$approve_comments) { unset($cv['comment_security']); require_once XFS . 'core/emailer.php'; $emailer = new emailer(); $emailer->from($cv['comment_address']); $emailer->use_template('comment_approval'); if (f($tree['tree_form_email'])) { $tree['tree_form_email'] = $core->v('default_comments_email'); } foreach (explode(';', $tree['tree_form_email']) as $i => $row) { $row_f = !$i ? 'email_address' : 'cc'; $emailer->{$row_f}($row); } $input = w(); foreach ($cv as $row_k => $row_v) { if (!f($row_v)) { continue; } if ($row_k == 'comment_message') { $row_v = str_replace("\r\n", '<br />', $row_v); } $input[] = '< ' . $row_v; } $emailer->assign_vars(array('U_APPROVAL' => _link(_rewrite($tree), array('x1' => 'comments')), 'INPUT_FIELDS' => implode('<br /><br />', $input), 'FROM_USERNAME' => $cv['comment_username'])); $emailer->send(); $emailer->reset(); } redirect(_link(_rewrite($tree))); } if ($this->errors()) { if (is_ghost()) { $this->e('!'); } _style('comments_error', array('MESSAGE' => $this->get_errors())); } } // if (f($tree['tree_redirect'])) { if (preg_match('#^[a-z0-9\\-\\_]+$#is', $tree['tree_redirect'])) { $tree['tree_redirect'] = _link($tree['tree_redirect']); } redirect($tree['tree_redirect']); } // if ($tree['tree_parent']) { $sql = 'SELECT * FROM _tree WHERE tree_id = ?'; $parent = _fieldrow(sql_filter($sql, $tree['tree_parent'])); if ($tree['tree_level'] > 2) { $sql = 'SELECT * FROM _tree WHERE tree_id = ?'; $subparent = _fieldrow(sql_filter($sql, $parent['tree_parent'])); } } if ($tree['tree_node']) { $sql = 'SELECT * FROM _tree WHERE tree_id = ?'; $node = _fieldrow(sql_filter($sql, $tree['tree_node'])); } // if (@method_exists($this, 'cf_' . _rewrite($tree))) { $this->{'cf_' . _rewrite($tree)}($tree); } // $sql = 'SELECT * FROM _tree WHERE tree_parent = ? AND tree_child_hide = 0 ORDER BY ??'; $childs = _rowset(sql_filter($sql, $tree['tree_id'], $this->child_order($tree))); foreach ($childs as $i => $row) { if (!$i) { $sql = 'SELECT image_id, image_tree, image_extension FROM _images WHERE image_tree IN (??) ORDER BY RAND()'; $images_child = _rowset(sql_filter($sql, _implode(',', array_keys($childs))), 'tree_id'); _style('tree_child1', array('ORDER_URL' => _link($tree['tree_id'], array('order', 0, 0, 0, 0)))); } _style('tree_child.row', array('ITEM' => $row['tree_id'], 'URL' => _link(_rewrite($row)), 'SUBJECT' => $row['tree_subject'], 'CONTENT' => $row['tree_content'], 'EDITED' => _format_date($row['tree_edited']), 'IMAGE' => isset($images_child[$row['tree_id']]) ? $images_child[$row['tree_id']]['image_id'] . '.' . $images_child[$row['tree_id']]['image_extension'] : 'default.gif')); } // Comments if ($tree['tree_allow_comments'] && $tree['tree_comments']) { $sql = 'SELECT c.comment_id, c.comment_username, c.comment_website, c.comment_time, c.comment_message, m.user_username FROM _comments c, _members m WHERE c.comment_tree = ? AND c.comment_status = 1 AND c.comment_uid = m.user_id ORDER BY c.comment_time DESC'; $comments = _rowset(sql_filter($sql, $tree['tree_id'])); foreach ($comments as $i => $row) { if (!$i) { _style('comments'); } _style('comments.row', array('ID' => $row['comment_id'], 'SUSERNAME' => $row['user_username'], 'USERNAME' => $row['comment_username'], 'WEBSITE' => $row['comment_website'], 'TIME' => _format_date($row['comment_time']), 'MESSAGE' => str_replace("\n", '<br />', $row['comment_message']))); } } // if ($this->css_parent($tree)) { $sql = 'SELECT * FROM _tree WHERE tree_parent = ? AND tree_child_hide = 0 ORDER BY ??'; $childs_parent = _rowset(sql_filter($sql, $this->css_var($tree), $this->child_order($tree))); foreach ($childs_parent as $i => $row) { if (!$i) { $sql = 'SELECT image_id, image_tree, image_extension FROM _images WHERE image_tree IN (??) ORDER BY RAND()'; $images_child_parent = _rowset(sql_filter($sql, _implode(',', array_keys($childs_parent))), 'tree_id'); _style('tree_child', array('ORDER_URL' => _link($tree['tree_id'], array('order', 0, 0, 0, 0)))); } _style('tree_child_parent.row', array('ITEM' => $row['tree_id'], 'URL' => _link(_rewrite($row)), 'TITLE' => $row['tree_subject'], 'IMAGE' => isset($images_child_parent[$row['tree_id']]) ? $images_child_parent[$row['tree_id']]['image_id'] . '.' . $images_child_parent[$row['tree_id']]['image_extension'] : 'default.gif')); } } if ($tree['tree_downloads']) { $sql = 'SELECT * FROM _downloads WHERE download_tree = ? ORDER BY download_order'; $downloads = _rowset(sql_filter($sql, $tree['tree_id'])); foreach ($downloads as $i => $row) { if (!$i) { _style('downloads', array('ORDER_URL' => _link($tree['tree_id'], array('orderd', 0, 0, 0, 0)))); } _style('downloads.row', array('ITEM' => $row['download_id'], 'DOWNLOAD' => _link('get', $row['download_alias'] . '.' . $row['download_extension']), 'TITLE' => $row['download_title'])); } } // if ($tree['tree_form']) { $sql = 'SELECT * FROM _form_fields WHERE form_tree = ? ORDER BY form_order'; $form = _rowset(sql_filter($sql, $tree['tree_id']), 'form_alias'); if (!count($form)) { $sql = 'SELECT * FROM _form_fields WHERE form_tree = 0 ORDER BY form_order'; $form = _rowset($sql, 'form_alias'); } $form['secure'] = array('form_required' => 1, 'form_regex' => '^([a-zA-Z]+)$', 'form_alias' => 'secure', 'form_type' => 'text', 'form_legend' => 'Imagen de seguridad'); _style('form', array('URL' => _link(_rewrite($tree)))); foreach ($form as $row) { _style('form.row', array('ALIAS' => $row['form_alias'], 'REQUIRED' => $row['form_required'], 'LEGEND' => _lang($row['form_legend']), 'TYPE' => $row['form_type'], 'PAGE' => $tree['tree_alias'])); foreach ($row as $row_k => $row_v) { if (preg_match('#^form_(alias|type)$#is', $row_k)) { if ($row_k == 'form_alias') { $row_k = 'name'; } _style('form.row.attrib', array('ATTRIB' => str_replace('form_', '', $row_k), 'VALUE' => $row_v)); } } } } $s_css_page = ''; if (@file_exists('./style/css/_tree_' . _rewrite($tree) . '.css')) { $s_css_page = _rewrite($tree) . '/'; } elseif ($this->css_parent($tree)) { if (!f($tree['tree_css_var'])) { $tree['tree_css_var'] = 'parent'; } $ary_css_var = false; switch ($tree['tree_css_var']) { case 'parent': case 'subparent': case 'node': $ary_css_var = ${$tree['tree_css_var']}; break; default: if (is_numb($tree['tree_css_var'])) { $sql = 'SELECT * FROM _tree WHERE tree_id = ?'; if ($css_var_row = _fieldrow(sql_filter($sql, $tree['tree_css_var']))) { $ary_css_var = $css_var_row; } } break; } if ($ary_css_var !== false) { $s_css_page = _rewrite($ary_css_var) . '/'; } } v_style(array('S_IMAGES' => $core->v('address') . 'container/images/a_' . ($this->css_parent($tree) ? $this->css_var($tree) : $tree['tree_id']) . '/', 'V_TREE' => $tree['tree_id'], 'V_CSS' => $s_css_page, 'V_SUBJECT' => $tree['tree_subject'], 'V_CONTENT' => _message($tree['tree_content']), 'V_COMMENTS' => $tree['tree_comments'], 'V_ALLOW_COMMENTS' => $tree['tree_allow_comments'], 'V_ALLOW_FORM' => $tree['tree_form'], 'U_COMMENTS' => _link(_rewrite($tree)), 'U_XCF' => _link(_rewrite($tree) . '-xs.jpg', false, false))); $tree['tree_subject'] = strip_tags($tree['tree_subject']); // if ($tree['tree_alias'] != 'home') { if ($node['tree_id'] != $parent['tree_id']) { $this->navigation($node['tree_subject'], _rewrite($node)); } if ($tree['tree_level'] > 2) { if ($parent['tree_id'] && $node['tree_id'] && $tree['tree_level'] > 3) { $this->navigation('...'); } $this->navigation($subparent['tree_subject'], _rewrite($subparent)); } if ($parent['tree_id']) { $this->navigation($parent['tree_subject'], _rewrite($parent)); } $this->navigation($tree['tree_subject'], _rewrite($tree)); } if ($user->v('is_member')) { $tree['tree_cp'] = 1; $i = 0; $auth_tree = array('create', 'modify', 'remove'); foreach ($auth_tree as $row) { if (_auth_get('cp_' . $row)) { if (!$i) { _style('auth'); } _style('auth.row', array('U_AUTH' => _link('cp', array($row, _rewrite($tree))), 'V_NAME' => _lang('CP_AUTH_' . $row))); $i++; } } } // $this->_template('tree'); if (f($tree['tree_template']) && @file_exists('./style/custom/' . $tree['tree_template'] . '.htm')) { $this->_template('custom/' . $tree['tree_template']); } // TODO: 304 header response header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $tree['tree_edited']) . ' GMT'); return; }
function main($action) { global $db, $config, $template, $images, $user, $lang; global $pafiledb_config, $debug; $file_id = request_var('file_id', 0); if (empty($file_id)) { message_die(GENERAL_MESSAGE, $lang['File_not_exist']); } $sql = 'SELECT file_catid, file_name FROM ' . PA_FILES_TABLE . "\n\t\t\tWHERE file_id = {$file_id}"; $result = $db->sql_query($sql); if (!($file_data = $db->sql_fetchrow($result))) { message_die(GENERAL_MESSAGE, $lang['File_not_exist']); } $db->sql_freeresult($result); if (!$this->auth[$file_data['file_catid']]['auth_email']) { if (!$user->data['session_logged_in']) { redirect(append_sid(CMS_PAGE_LOGIN . '?redirect=dload.' . PHP_EXT . '&action=email&file_id=' . $file_id, true)); } $message = sprintf($lang['Sorry_auth_email'], $this->auth[$file_data['file_catid']]['auth_email_type']); message_die(GENERAL_MESSAGE, $message); } if (isset($_POST['submit'])) { // session id check $sid = request_post_var('sid', ''); if (empty($sid) || $sid != $user->data['session_id']) { message_die(GENERAL_ERROR, 'INVALID_SESSION'); } $error = false; $femail = request_var('femail', ''); if (!empty($femail) && preg_match('/^[a-z0-9\\.\\-_\\+]+@[a-z0-9\\-_]+\\.([a-z0-9\\-_]+\\.)*?[a-z]+$/is', $femail)) { $user_email = $femail; } else { $error = true; $error_msg = !empty($error_msg) ? $error_msg . '<br />' . $lang['Email_invalid'] : $lang['Email_invalid']; } $username = request_var('fname', '', true); $sender_name = request_var('sname', '', true); //if (!$user->data['session_logged_in'] || ($user->data['session_logged_in'] && ($sender_name != $user->data['username']))) if (!$user->data['session_logged_in']) { // Mighty Gorgon: is this really needed? /* include(IP_ROOT_PATH . 'includes/functions_validate.' . PHP_EXT); $result = validate_username($sender_name); if ($result['error']) { $error = true; $error_msg .= (!empty($error_msg)) ? '<br />' . $result['error_msg'] : $result['error_msg']; } */ } else { $sender_name = $user->data['username']; } if (!$user->data['session_logged_in']) { $semail = request_var('semail', ''); if (!empty($semail) && preg_match('/^[a-z0-9\\.\\-_\\+]+@[a-z0-9\\-_]+\\.([a-z0-9\\-_]+\\.)*?[a-z]+$/is', $femail)) { $sender_email = $semail; } else { $error = true; $error_msg = !empty($error_msg) ? $error_msg . '<br />' . $lang['Email_invalid'] : $lang['Email_invalid']; } } else { $sender_email = $user->data['user_email']; } $subject = request_var('subject', '', true); $subject = htmlspecialchars_decode($subject, ENT_COMPAT); if (empty($subject)) { $error = true; $error_msg = !empty($error_msg) ? $error_msg . '<br />' . $lang['Empty_subject_email'] : $lang['Empty_subject_email']; } $message = request_var('message', '', true); // We need to check if HTML emails are enabled so we can correctly escape content and linebreaks $message = !empty($config['html_email']) ? nl2br($message) : htmlspecialchars_decode($message, ENT_COMPAT); if (empty($message)) { $error = true; $error_msg = !empty($error_msg) ? $error_msg . '<br />' . $lang['Empty_message_email'] : $lang['Empty_message_email']; } if (!$error) { include IP_ROOT_PATH . 'includes/emailer.' . PHP_EXT; $emailer = new emailer(); $emailer->headers('X-AntiAbuse: Board servername - ' . trim($config['server_name'])); $emailer->headers('X-AntiAbuse: User_id - ' . $user->data['user_id']); $emailer->headers('X-AntiAbuse: Username - ' . $user->data['username']); $emailer->headers('X-AntiAbuse: User IP - ' . $user_ip); $emailer->use_template('profile_send_email', $user_lang); $emailer->to($user_email); $emailer->from($sender_email); $emailer->replyto($sender_email); $emailer->set_subject($subject); $emailer->assign_vars(array('SITENAME' => $config['sitename'], 'BOARD_EMAIL' => $config['board_email'], 'FROM_USERNAME' => $sender_name, 'TO_USERNAME' => $username, 'MESSAGE' => $message)); $emailer->send(); $emailer->reset(); $message = $lang['Econf'] . '<br /><br />' . sprintf($lang['Click_return'], '<a href="' . append_sid('dload.' . PHP_EXT . '?action=file&file_id=' . $file_id) . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_forum'], '<a href="' . append_sid(CMS_PAGE_HOME) . '">', '</a>'); message_die(GENERAL_MESSAGE, $message); } if ($error) { message_die(GENERAL_MESSAGE, $error_msg); } } $this->generate_category_nav($file_data['file_catid']); $template->assign_vars(array('USER_LOGGED' => !$user->data['session_logged_in'] ? true : false, 'L_HOME' => $lang['Home'], 'CURRENT_TIME' => sprintf($lang['Current_time'], create_date($config['default_dateformat'], time(), $config['board_timezone'])), 'S_EMAIL_ACTION' => append_sid('dload.' . PHP_EXT), 'S_HIDDEN_FIELDS' => '<input type="hidden" name="sid" value="' . $user->data['session_id'] . '" />', 'L_INDEX' => sprintf($lang['Forum_Index'], $config['sitename']), 'L_EMAIL' => $lang['Semail'], 'L_EMAIL' => $lang['Emailfile'], 'L_EMAILINFO' => $lang['Emailinfo'], 'L_YNAME' => $lang['Yname'], 'L_YEMAIL' => $lang['Yemail'], 'L_FNAME' => $lang['Fname'], 'L_FEMAIL' => $lang['Femail'], 'L_ETEXT' => $lang['Etext'], 'L_DEFAULTMAIL' => $lang['Defaultmail'], 'L_SEMAIL' => $lang['Semail'], 'L_ESUB' => $lang['Esub'], 'L_EMPTY_SUBJECT_EMAIL' => $lang['Empty_subject_email'], 'L_EMPTY_MESSAGE_EMAIL' => $lang['Empty_message_email'], 'U_INDEX_HOME' => append_sid(CMS_PAGE_HOME), 'U_DOWNLOAD_HOME' => append_sid('dload.' . PHP_EXT), 'U_FILE_NAME' => append_sid('dload.' . PHP_EXT . '?action=file&file_id=' . $file_id), 'FILE_NAME' => $file_data['file_name'], 'SNAME' => $user->data['username'], 'SEMAIL' => $user->data['user_email'], 'DOWNLOAD' => $pafiledb_config['settings_dbname'], 'FILE_URL' => create_server_url() . 'dload.' . PHP_EXT . '?action=file&file_id=' . $file_id, 'ID' => $file_id)); $this->display($lang['Download'], 'pa_email_body.tpl'); }
message_die(GENERAL_ERROR, 'Could not update private message new/read status for user', '', __LINE__, __FILE__, $sql); } if ($board_config['email_enabled'] && $to_userdata['user_notify_pm'] && !empty($to_userdata['user_email']) && $to_userdata['user_active']) { $script_name = preg_replace('/^\\/?(.*?)\\/?$/', "\\1", trim($board_config['script_path'])); $script_name = $script_name != '' ? $script_name . '/privmsg.' . $phpEx : 'privmsg.' . $phpEx; $server_name = trim($board_config['server_name']); $server_protocol = $board_config['cookie_secure'] ? 'https://' : 'http://'; $server_port = $board_config['server_port'] != 80 ? ':' . trim($board_config['server_port']) . '/' : '/'; $emailer = new emailer($board_config['smtp_delivery']); $emailer->from($board_config['board_email']); $emailer->replyto($board_config['board_email']); $emailer->use_template('privmsg_notify', $to_userdata['user_lang']); $emailer->email_address($to_userdata['user_email']); $emailer->set_subject($lang['Notification_subject']); $emailer->assign_vars(array('USERNAME' => stripslashes($to_username), 'SITENAME' => $board_config['sitename'], 'EMAIL_SIG' => !empty($board_config['board_email_sig']) ? str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']) : '', 'U_INBOX' => $server_protocol . $server_name . $server_port . $script_name . '?folder=inbox')); if (!($emailer_result = $emailer->send(1))) { message_die(GENERAL_ERROR, 'Failed sending email :: ' . $emailer_result, '', __LINE__, __FILE__); } $emailer->reset(); } $pmer = new cash_user($userdata['user_id'], $userdata); $pmer->give_pm_amount(); } } $template->assign_vars(array('META' => '<meta http-equiv="refresh" content="3;url=' . append_sid("privmsg.{$phpEx}?folder=inbox") . '">')); $msg = $lang['Message_sent'] . '<br /><br />' . sprintf($lang['Click_return_inbox'], '<a href="' . append_sid("privmsg.{$phpEx}?folder=inbox") . '">', '</a> ') . '<br /><br />' . sprintf($lang['Click_return_index'], '<a href="' . append_sid("index.{$phpEx}") . '">', '</a>'); message_die(GENERAL_MESSAGE, $msg); } else { if ($preview || $refresh || $error) { // // If we're previewing or refreshing then obtain the data
public function store_dc($mode, $to, $from, $subject, $message, $can_reply = true, $can_email = false) { global $user; if ($mode == 'reply') { $insert = array( 'parent_id' => (int) $to['parent_id'], 'privmsgs_type' => PRIVMSGS_NEW_MAIL, 'privmsgs_from_userid' => (int) $from['user_id'], 'privmsgs_to_userid' => (int) $to['user_id'], ); } else { $insert = array( 'privmsgs_type' => PRIVMSGS_NEW_MAIL, 'privmsgs_subject' => $subject, 'privmsgs_from_userid' => (int) $from['user_id'], 'privmsgs_to_userid' => (int) $to['user_id'] ); } $insert += array( 'privmsgs_date' => time(), 'msg_ip' => $user->ip, 'privmsgs_text' => $this->prepare($message), 'msg_can_reply' => (int) $can_reply ); $dc_id = sql_insert('dc', $insert); if ($mode == 'reply') { $sql = 'UPDATE _dc SET root_conv = root_conv + 1, last_msg_id = ? WHERE msg_id = ?'; sql_query(sql_filter($sql, $dc_id, $to['msg_id'])); $sql = 'UPDATE _dc SET msg_deleted = 0 WHERE parent_id = ?'; sql_query(sql_filter($sql, $to['parent_id'])); $user->delete_unread(UH_NOTE, $to['parent_id']); } else { $sql = 'UPDATE _dc SET parent_id = ?, last_msg_id = ? WHERE msg_id = ?'; sql_query(sql_filter($sql, $dc_id, $dc_id, $dc_id)); } $user->save_unread(UH_NOTE, (($mode == 'reply') ? $to['parent_id'] : $dc_id), 0, $to['user_id']); // // Notify via email if user requires it // if ($mode == 'start' && $can_email && $user->d('user_email_dc')) { $emailer = new emailer(); $emailer->from('info'); $emailer->set_subject('Rock Republik: ' . $from['username'] . ' te ha enviado un mensaje'); $emailer->use_template('dc_email'); $emailer->email_address($to['user_email']); $dc_url = s_link('my dc read', $dc_id); $emailer->assign_vars(array( 'USERNAME' => $to['username'], 'SENT_BY' => $from['username'], 'DC_URL' => $dc_url) ); $emailer->send(); $emailer->reset(); } return $dc_id; }
public function _email() { if ($this->make) { return; } if (empty($this->data['email'])) { fatal_error(); } if (!$this->auth['user']) { do_login(); } global $user, $config; $error_msg = ''; $subject = ''; $message = ''; $current_time = time(); if (_button()) { $subject = request_var('subject', ''); $message = request_var('message', '', true); if (empty($subject) || empty($message)) { $error_msg .= (($error_msg != '') ? '<br />' : '') . lang('fields_empty'); } if (empty($error_msg)) { $sql = 'UPDATE _artists SET last_email = ?, last_email_user = ? WHERE ub = ?'; sql_query(sql_filter($sql, $current_time, $user->d('user_id'), $this->data['ub'])); $emailer = new emailer($config['smtp_delivery']); $emailer->from($user->d('user_email')); $email_headers = 'X-AntiAbuse: User_id - ' . $user->d('user_id') . nr(); $email_headers .= 'X-AntiAbuse: Username - ' . $user->d('username') . nr(); $email_headers .= 'X-AntiAbuse: User IP - ' . $user->ip . nr(); $emailer->use_template('mmg_send_email', $config['default_lang']); $emailer->email_address($this->data['email']); $emailer->set_subject($subject); $emailer->extra_headers($email_headers); $emailer->assign_vars(array( 'SITENAME' => $config['sitename'], 'BOARD_EMAIL' => $config['board_email'], 'FROM_USERNAME' => $user->d('username'), 'UB_NAME' => $this->data['name'], 'MESSAGE' => $message )); $emailer->send(); $emailer->reset(); redirect(s_link('a', $this->data['subdomain'])); } } if ($error_msg != '') { _style('error'); } v_style(array( 'ERROR_MESSAGE' => $error_msg, 'SUBJECT' => $subject, 'MESSAGE' => $message) ); return; }
function adr_send_pm($dest_user, $subject, $message, $check_from_id = '') { global $db, $phpbb_root_path, $phpEx, $lang, $user_ip, $board_config, $userdata; $dest_user = intval($dest_user); $msg_time = time(); $from_id = $check_from_id === '' ? intval($userdata['user_id']) : $check_from_id; $html_on = 1; $bbcode_on = 1; $smilies_on = 1; include_once $phpbb_root_path . 'includes/functions_post.' . $phpEx; include_once $phpbb_root_path . 'includes/bbcode.' . $phpEx; $privmsg_subject = trim(strip_tags($subject)); $bbcode_uid = make_bbcode_uid(); $privmsg_message = trim(strip_tags($message)); // APM compliance if (defined('PRIVMSGA_TABLE')) { include_once $phpbb_root_path . 'includes/functions_messages.' . $phpEx; send_pm(0, '', $dest_user, $privmsg_subject, $privmsg_message, ''); } else { $sql = "SELECT user_id, user_notify_pm, user_email, user_lang, user_active\r\n\t\t\t FROM " . USERS_TABLE . "\r\n\t\t\t WHERE user_id = {$dest_user} "; if (!($result = $db->sql_query($sql))) { $error = TRUE; $error_msg = $lang['No_such_user']; } $to_userdata = $db->sql_fetchrow($result); $sql = "SELECT COUNT(privmsgs_id) AS inbox_items, MIN(privmsgs_date) AS oldest_post_time\r\n\t\t\tFROM " . PRIVMSGS_TABLE . "\r\n\t\t\tWHERE ( privmsgs_type = " . PRIVMSGS_NEW_MAIL . "\r\n\t\t\t OR privmsgs_type = " . PRIVMSGS_READ_MAIL . " \r\n\t\t\t\tOR privmsgs_type = " . PRIVMSGS_UNREAD_MAIL . " )\r\n\t\t\tAND privmsgs_to_userid = {$dest_user} "; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_MESSAGE, $lang['No_such_user']); } $sql_priority = SQL_LAYER == 'mysql' ? 'LOW_PRIORITY' : ''; if ($inbox_info = $db->sql_fetchrow($result)) { if ($inbox_info['inbox_items'] >= $board_config['max_inbox_privmsgs']) { $sql = "SELECT privmsgs_id FROM " . PRIVMSGS_TABLE . "\r\n\t\t\t\t\tWHERE ( privmsgs_type = " . PRIVMSGS_NEW_MAIL . "\r\n\t\t\t\t\tOR privmsgs_type = " . PRIVMSGS_READ_MAIL . "\r\n\t\t\t\t\tOR privmsgs_type = " . PRIVMSGS_UNREAD_MAIL . " )\r\n\t\t\t\t\tAND privmsgs_date = " . $inbox_info['oldest_post_time'] . "\r\n\t\t\t\t\tAND privmsgs_to_userid = {$dest_user} "; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Could not find oldest privmsgs (inbox)', '', __LINE__, __FILE__, $sql); } $old_privmsgs_id = $db->sql_fetchrow($result); $old_privmsgs_id = $old_privmsgs_id['privmsgs_id']; $sql = "DELETE {$sql_priority} FROM " . PRIVMSGS_TABLE . "\r\n\t\t\t\t\tWHERE privmsgs_id = {$old_privmsgs_id}"; if (!$db->sql_query($sql)) { message_die(GENERAL_ERROR, 'Could not delete oldest privmsgs (inbox)' . $sql, '', __LINE__, __FILE__, $sql); } $sql = "DELETE {$sql_priority} FROM " . PRIVMSGS_TEXT_TABLE . "\r\n\t\t\t\t\tWHERE privmsgs_text_id = {$old_privmsgs_id}"; if (!$db->sql_query($sql)) { message_die(GENERAL_ERROR, 'Could not delete oldest privmsgs text (inbox)', '', __LINE__, __FILE__, $sql); } } } $sql_info = "INSERT INTO " . PRIVMSGS_TABLE . " \r\n\t\t\t(privmsgs_type, privmsgs_subject, privmsgs_from_userid, privmsgs_to_userid, privmsgs_date, privmsgs_ip, privmsgs_enable_html, privmsgs_enable_bbcode, privmsgs_enable_smilies)\r\n\t\t\tVALUES ( 1 , '" . str_replace("\\'", "''", addslashes($privmsg_subject)) . "' , " . $from_id . ", " . $to_userdata['user_id'] . ", {$msg_time}, '{$user_ip}' , {$html_on}, {$bbcode_on}, {$smilies_on})"; if (!$db->sql_query($sql_info)) { message_die(GENERAL_ERROR, 'Could not delete oldest privmsgs text (inbox)', '', __LINE__, __FILE__, $sql_info); } $privmsg_sent_id = $db->sql_nextid(); $sql = "INSERT INTO " . PRIVMSGS_TEXT_TABLE . " (privmsgs_text_id, privmsgs_bbcode_uid, privmsgs_text)\r\n\t\t\tVALUES ({$privmsg_sent_id}, '" . $bbcode_uid . "', '" . str_replace("\\'", "''", addslashes($privmsg_message)) . "')"; if (!$db->sql_query($sql, END_TRANSACTION)) { message_die(GENERAL_ERROR, "Could not insert/update private message sent text.", "", __LINE__, __FILE__, $sql); } $sql = "UPDATE " . USERS_TABLE . "\r\n\t\t\tSET user_new_privmsg = user_new_privmsg + 1, user_last_privmsg = " . time() . " \r\n\t\t\tWHERE user_id = " . $to_userdata['user_id']; if (!($status = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Could not update private message new/read status for user', '', __LINE__, __FILE__, $sql); } if ($to_userdata['user_notify_pm'] && !empty($to_userdata['user_email']) && $to_userdata['user_active']) { // have the mail sender infos $script_name = preg_replace('/^\\/?(.*?)\\/?$/', "\\1", trim($board_config['script_path'])); $script_name = $script_name != '' ? $script_name . '/privmsg.' . $phpEx : 'privmsg.' . $phpEx; $server_name = trim($board_config['server_name']); $server_protocol = $board_config['cookie_secure'] ? 'https://' : 'http://'; $server_port = $board_config['server_port'] != 80 ? ':' . trim($board_config['server_port']) . '/' : '/'; include_once $phpbb_root_path . './includes/emailer.' . $phpEx; $emailer = new emailer($board_config['smtp_delivery']); if ($board_config['version'] == '.0.5' || $board_config['version'] == '.0.6' || $board_config['version'] == '.0.7' || $board_config['version'] == '.0.8' || $board_config['version'] == '.0.9') { $emailer->from($board_config['board_email']); $emailer->replyto($board_config['board_email']); $emailer->use_template('privmsg_notify', $to_userdata['user_lang']); } else { $email_headers = 'From: ' . $board_config['board_email'] . "\nReturn-Path: " . $board_config['board_email'] . "\n"; $emailer->use_template('privmsg_notify', $to_userdata['user_lang']); $emailer->extra_headers($email_headers); } $emailer->email_address($to_userdata['user_email']); $emailer->set_subject($lang['Notification_subject']); $emailer->assign_vars(array('USERNAME' => $to_username, 'SITENAME' => $board_config['sitename'], 'EMAIL_SIG' => !empty($board_config['board_email_sig']) ? str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']) : '', 'U_INBOX' => $server_protocol . $server_name . $server_port . $script_name . '?folder=inbox')); $emailer->send(); $emailer->reset(); } } return; }
$emailer = new emailer($board_config['smtp_delivery']); $emailer->from(EMAIL_ADMIN); $emailer->replyto(EMAIL_ADMIN); for ($i = 0; $i < count($bcc_list); $i++) { $emailer->bcc($bcc_list[$i]); } $email_headers = 'X-AntiAbuse: Board servername - Asterisk 2 billing\\n'; $email_headers .= 'X-AntiAbuse: User_id - 1\\n'; $email_headers .= 'X-AntiAbuse: Username - Areski\\n'; $email_headers .= 'X-AntiAbuse: User IP - 192.168.1.241\\n'; $emailer->use_template($message); $emailer->email_address(EMAIL_ADMIN); $emailer->set_subject($subject); $emailer->extra_headers($email_headers); $emailer->assign_vars(array('SITENAME' => 'a2billing', 'BOARD_EMAIL' => EMAIL_ADMIN, 'MESSAGE' => 'Hey it is a message, just to watch working')); $result = $emailer->send(); $emailer->reset(); } // #### HEADER SECTION $smarty->display('main.tpl'); echo $CC_help_mass_mail; if (!isset($submit)) { ?> <script language="JavaScript" src="javascript/card.js"></script> <div class="toggle_hide2show"> <center><a href="#" target="_self" class="toggle_menu"><img class="toggle_hide2show" src="<?php echo KICON_PATH; ?> /toggle_hide2show.png" onmouseover="this.style.cursor='hand';" HEIGHT="16"> <font class="fontstyle_002"><?php echo gettext("SEARCH CUSTOMERS"); ?>
function _form_home() { global $core, $user, $style; $tree = $this->valid_tree(); if (!$tree['tree_form']) { _fatal(); } if ($tree['tree_parent']) { $sql = 'SELECT * FROM _tree WHERE tree_id = ' . (int) $tree['tree_parent']; $parent = $this->_fieldrow($sql); if ($tree['tree_level'] > 2) { $sql = 'SELECT * FROM _tree WHERE tree_id = ' . (int) $parent['tree_parent']; $subparent = $this->_fieldrow($sql); } } if ($tree['tree_node']) { $sql = 'SELECT * FROM _tree WHERE tree_id = ' . (int) $tree['tree_node']; $node = $this->_fieldrow($sql); } // $sql = 'SELECT * FROM _form_fields WHERE form_tree = ' . (int) $tree['tree_id'] . ' ORDER BY form_order'; $form = $this->_rowset($sql, 'form_alias'); if (!count($form)) { $sql = 'SELECT * FROM _form_fields WHERE form_tree = 0 ORDER BY form_order'; $form = $this->_rowset($sql, 'form_alias'); } $form['ctkey'] = array('form_required' => 1, 'form_regex' => '^([a-zA-Z]+)$', 'form_alias' => 'ctkey', 'form_type' => 'text', 'form_legend' => 'Imagen de seguridad'); if (_button()) { $va = array(); foreach ($form as $row) { $va[] = $row['form_alias']; } $v = $this->__($va); foreach ($form as $row) { if (empty($v[$row['form_alias']])) { if ($row['form_required']) { $this->error(sprintf(_lang('E_COMMENT_FIELD_EMPTY'), $row['form_legend']), false); } continue; } if (!empty($row['form_regex']) && !preg_match('#' . $row['form_regex'] . '#is', $v[$row['form_alias']])) { $this->error(sprintf(_lang('E_COMMENT_FIELD_BAD'), $row['form_legend']), false); if ($row['form_alias'] == 'ctkey') { $v[$row['form_alias']] = ''; } } } if (!$this->errors()) { include XFS . 'core/xcf.php'; $xcf = new captcha(); if ($xcf->check($v['ctkey']) === false) { $v['ctkey'] = ''; $this->error('E_COMMENT_INVALID_CAPTCHA'); } unset($xcf); } if (!$this->errors()) { include XFS . 'core/emailer.php'; $emailer = new emailer(); $v['subject'] = preg_replace('#\\&([A-Za-z]+){1}(.*?)\\;#e', "substr('\\1', 0, 1)", $v['subject']); $emailer->from($v['email']); $emailer->set_subject($v['subject']); $emailer->use_template('contact_email', $core->v('default_lang')); foreach (explode(';', $tree['tree_form_email']) as $i => $address) { $row_f = !$i ? 'email_address' : 'cc'; $emailer->{$row_f}($address); } $emailer->cc($core->v('default_email')); unset($v['ctkey']); $html = array(); foreach ($form as $row) { if (empty($v[$row['form_alias']])) { continue; } if ($row['form_alias'] == 'message') { $v['message'] = str_replace("\r\n", '<br />', $v['message']); } $html[] = '<strong>' . $row['form_legend'] . ':</strong><br />' . $v[$row['form_alias']]; } $emailer->assign_vars(array('HTML_FIELDS' => implode('<br /><br />', $html), 'FROM_USERNAME' => $v['nombre'], 'FORM_ARTICLE' => $tree['tree_subject'])); $emailer->send(); $emailer->reset(); // $style->assign_block_vars('sent', array('THANKS' => _lang('CONTACT_THANKS'))); } } if (!_button() || $this->errors()) { if ($this->errors()) { $style->assign_block_vars('error', array('MESSAGE' => error_list($this->error))); } $ff = 'form_'; $fff = 'alias|type'; $style->assign_block_vars('form', array()); foreach ($form as $row) { $style->assign_block_vars('form.row', array('ALIAS' => $row[$ff . 'alias'], 'REQUIRED' => $row[$ff . 'required'], 'LEGEND' => $row[$ff . 'legend'], 'TYPE' => $row[$ff . 'type'], 'ERROR' => isset($error[$row[$ff . 'alias']]), 'VALUE' => isset($v[$row[$ff . 'alias']]) ? $v[$row[$ff . 'alias']] : '')); foreach ($row as $row_k => $row_v) { if (preg_match('#^' . $ff . '(' . $fff . ')$#is', $row_k)) { if ($row_k == 'form_alias') { $row_k = 'name'; } $style->assign_block_vars('form.row.attrib', array('ATTRIB' => str_replace($ff, '', $row_k), 'VALUE' => $row_v)); } } } } // $s_css_page = ''; if (@file_exists('./style/css/_tree_' . $this->alias_id($tree) . '.css')) { $s_css_page = $this->alias_id($tree) . '/'; } elseif ($this->css_parent($tree)) { if (empty($tree['tree_css_var'])) { $tree['tree_css_var'] = 'parent'; } $ary_css_var = false; switch ($tree['tree_css_var']) { case 'parent': case 'subparent': case 'node': $ary_css_var = ${$tree['tree_css_var']}; break; default: if (is_numeric($tree['tree_css_var'])) { $sql = 'SELECT * FROM _tree WHERE tree_id = ' . (int) $tree['tree_css_var']; if ($css_var_row = $this->_fieldrow($sql)) { $ary_css_var = $css_var_row; } } break; } if ($ary_css_var !== false) { $s_css_page = $this->alias_id($ary_css_var) . '/'; } } // $tv = array('ADI' => $core->v('address') . 'container/images/a_' . ($this->css_parent($tree) ? $this->css_var($tree) : $tree['tree_id']) . '/', 'V_TREE' => $tree['tree_id'], 'V_CSS' => $s_css_page, 'V_SUBJECT' => $tree['tree_subject']); $this->as_vars($tv); // if ($tree['tree_alias'] != 'home') { if ($node['tree_id'] != $parent['tree_id']) { $this->navigation($node['tree_subject'], $this->alias_id($node)); } if ($tree['tree_level'] > 2) { if ($parent['tree_id'] && $node['tree_id'] && $tree['tree_level'] > 3) { $this->navigation('...'); } $this->navigation($subparent['tree_subject'], $this->alias_id($subparent)); } if ($parent['tree_id']) { $this->navigation($parent['tree_subject'], $this->alias_id($parent)); } $this->navigation($tree['tree_subject'], $this->alias_id($tree)); } //$tree['tree_subject'] = strip_tags($tree['tree_subject']); // $this->template = 'default.form'; if (!empty($tree['tree_template']) && @file_exists('./style/pages/form.' . $tree['tree_template'] . '.htm')) { $this->template = 'pages/form.' . $tree['tree_template']; } return; }
public function home() { global $user; $v = $this->__(array('faddr', 'nickname', 'address', 'birthday' => array('' => 0), 'country' => 0)); foreach (w('year month day') as $name) { $v['birthday'][$name] = isset($v['birthday'][$name]) ? $v['birthday'][$name] : ''; } if (f($v['faddr'])) { $v['address'] = $v['faddr']; } if (_button()) { if (!f($v['address']) || !f($v['nickname'])) { $this->error('COMPLETE_FIELDS'); } if (f($v['address'])) { $sql = 'SELECT user_id FROM _members WHERE user_email = ?'; if (_field(sql_filter($sql, $v['address']), 'user_id', 0)) { $this->error('EMAIL_EXISTS'); } if (!preg_match('/^[a-z0-9&\'\\.\\-_\\+]+@[a-z0-9\\-]+\\.([a-z0-9\\-]+\\.)*?[a-z]+$/is', $v['address'])) { $this->error('EMAIL_BAD'); } } $sql = 'SELECT country_id FROM _countries WHERE country_id = ?'; if (!_field(sql_filter($sql, $v['country']), 'country_id', 0)) { $this->error('NO_COUNTRY'); } if (!$this->errors()) { $v['birthday'] = _zero($v['birthday']['year']) . _zero($v['birthday']['month']) . _zero($v['birthday']['day']); $sql_insert = array('type' => 1, 'active' => 0, 'username' => $v['nickname'], 'password' => '', 'registration' => time(), 'lastvisit' => '', 'lastpage' => '', 'country' => $v['country'], 'email' => $v['address'], 'birthday' => $v['birthday'], 'gender' => 0, 'dateformat' => 'd M Y H:i', 'timezone' => 0, 'dst' => 0); $sql = 'INSERT INTO _members' . _build_array('INSERT', prefix('user', $sql_insert)); _sql($sql); require XFS . 'core/emailer.php'; $emailer = new emailer(); $emailer->format('plain'); $emailer->from('TWC Kaulitz <*****@*****.**>'); $emailer->use_template('welcome'); $emailer->email_address($v['address']); $emailer->assign_vars(array('USERNAME' => $v['nickname'])); $emailer->send(); $emailer->reset(); // redirect('http://www.twckaulitz.com/', false); } } if ($this->errors()) { _style('errors', array('MSG' => $this->get_errors())); } for ($i = 1; $i < 32; $i++) { _style('days', array('DAY' => $i)); } $months = w('Enero Febrero Marzo Abril Mayo Junio Julio Agosto Septiembre Octubre Noviembre Diciembre'); foreach ($months as $i => $row) { _style('months', array('VALUE' => $i + 1, 'MONTH' => $row)); } for ($i = 2005; $i > 1899; $i--) { _style('years', array('YEAR' => $i)); } // // GeoIP // include XFS . 'core/geoip.php'; $gi = geoip_open(XFS . 'core/GeoIP.dat', GEOIP_STANDARD); $geoip_code = strtolower(geoip_country_code_by_addr($gi, $user->ip)); $sql = 'SELECT * FROM _countries ORDER BY country_name'; $countries = _rowset($sql); $codes = w(); foreach ($countries as $row) { $codes[$row['country_short']] = $row['country_id']; _style('countries', array('VALUE' => $row['country_id'], 'NAME' => $row['country_name'])); } if (!$v['country']) { $v['country'] = isset($codes[$geoip_code]) ? $codes[$geoip_code] : $codes['gt']; } v_style(array('NICKNAME' => $v['nickname'], 'ADDRESS' => $v['address'], 'COUNTRY' => $v['country'], 'BIRTHDAY_YEAR' => $v['birthday']['year'], 'BIRTHDAY_MONTH' => $v['birthday']['month'], 'BIRTHDAY_DAY' => $v['birthday']['day'])); return; }
function user_notification($mode, &$post_data, &$topic_title, &$forum_id, &$topic_id, &$post_id, &$notify_user) { global $config, $lang, $userdata, $user_ip; $current_time = time(); if ($mode == 'delete') { $delete_sql = (!$post_data['first_post'] && !$post_data['last_post']) ? sql_filter(' AND user_id = ? ', $userdata['user_id']) : ''; $sql = 'DELETE FROM _forum_topics_fav WHERE topic_id = ?' . $delete_sql; sql_query(sql_filter($sql, $topic_id)); } else { if ($mode == 'reply') { $sql = 'SELECT ban_userid FROM _banlist'; $result = sql_rowset($sql); $user_id_sql = ''; foreach ($result as $row) { if (isset($row['ban_userid']) && !empty($row['ban_userid'])) { $user_id_sql .= ', ' . $row['ban_userid']; } } $update_watched_sql = ''; $bcc_list_ary = w(); $usr_list_ary = w(); $sql = 'SELECT DISTINCT u.user_id, u.user_email, u.user_lang FROM _forum_topics_fav tw INNER JOIN _members u ON tw.user_id = u.user_id INNER JOIN _members_group ug ON tw.user_id = ug.user_id LEFT OUTER JOIN _auth_access aa ON ug.group_id = aa.group_id, _forums f WHERE tw.topic_id = ? AND tw.user_id NOT IN (??, ??, ??) AND tw.notify_status = ? AND f.forum_id = ? AND u.user_active = 1 AND ( (aa.forum_id = ? AND aa.auth_read = 1) OR f.auth_read <= ? OR (u.user_level = ? AND f.auth_read = ?) OR u.user_level = ? )'; if ($result = sql_rowset(sql_filter($sql, $topic_id, $userdata['user_id'], GUEST, $user_id_sql, TOPIC_WATCH_UN_NOTIFIED, $forum_id, $forum_id, AUTH_REG, USER_MOD, AUTH_MOD, USER_ADMIN))) { @set_time_limit(60); foreach ($result as $row) { if ($row['user_email'] != '') { $bcc_list_ary[$row['user_lang']][] = $row['user_email']; } $update_watched_sql .= ($update_watched_sql != '') ? ', ' . $row['user_id'] : $row['user_id']; } if (sizeof($bcc_list_ary)) { $emailer = new emailer(); $server_name = trim($config['server_name']); $server_protocol = ($config['cookie_secure']) ? 'https://' : 'http://'; $post_url = $server_protocol . $server_name . s_link('post', $post_id) . "#$post_id"; $emailer->from($config['board_email']); $emailer->replyto($config['board_email']); $topic_title = unprepare_message($topic_title); @reset($bcc_list_ary); while (list($user_lang, $bcc_list) = each($bcc_list_ary)) { $emailer->use_template('topic_notify', $user_lang); for ($i = 0; $i < count($bcc_list); $i++) { $emailer->bcc($bcc_list[$i]); } // The Topic_reply_notification lang string below will be used // if for some reason the mail template subject cannot be read // ... note it will not necessarily be in the posters own language! $emailer->set_subject($lang['Topic_reply_notification']); // This is a nasty kludge to remove the username var ... till (if?) // translators update their templates $emailer->msg = preg_replace('#[ ]?{USERNAME}#', '', $emailer->msg); $emailer->assign_vars(array( 'EMAIL_SIG' => '', 'SITENAME' => $config['sitename'], 'TOPIC_TITLE' => $topic_title, 'U_TOPIC' => $post_url, 'U_STOP_WATCHING_TOPIC' => $server_protocol . $server_name . $script_name . '&' . POST_TOPIC_URL . "=$topic_id&unwatch=topic") ); $emailer->send(); $emailer->reset(); } } } if ($update_watched_sql != '') { $sql = 'UPDATE _forum_topics_fav SET notify_status = ? WHERE topic_id = ? AND user_id IN (??)'; sql_query(sql_filter($sql, TOPIC_WATCH_NOTIFIED, $topic_id, $update_watched_sql)); } } $sql = 'SELECT topic_id FROM _forum_topics_fav WHERE topic_id = ? AND user_id = ?'; if ($row = sql_fieldrow(sql_filter($sql, $topic_id, $userdata['user_id']))) { if (!$notify_user && !empty($row['topic_id'])) { $sql = 'DELETE FROM _forum_topics_fav WHERE topic_id = ? AND user_id = ?'; sql_query(sql_filter($sql, $topic_id, $userdata['user_id'])); } else if ($notify_user && empty($row['topic_id'])) { $sql = "INSERT INTO _forum_topics_fav (user_id, topic_id, notify_status) VALUES (" . $userdata['user_id'] . ", $topic_id, 0)"; sql_query($sql); } } } }
function send_mail($type, $from_userdata, &$to_user_ids, &$recips, $subject, $message, $time = 0, $copy = true, $parsed_values = array()) { global $db, $board_config, $lang, $phpbb_root_path, $phpEx, $userdata; // fix some parameters $subject = trim($subject); $message = trim($message); // check we have a message and a subject if (empty($subject)) { return 'Empty_subject'; } if (empty($message)) { return 'Empty_message'; } // recipient is not an array, so make one if (!is_array($to_user_ids) && !empty($to_user_ids)) { $to_user_ids = array(intval($to_user_ids)); } // check if recipients if (empty($to_user_ids)) { return 'No_to_user'; } $s_to_user_ids = implode(', ', $to_user_ids); // censor words $orig_word = array(); $replacement_word = array(); obtain_word_list($orig_word, $replacement_word); // process some cleaning $subject = count($orig_word) ? preg_replace($orig_word, $replacement_word, unprepare_message($subject)) : unprepare_message($subject); $message = count($orig_word) ? preg_replace($orig_word, $replacement_word, unprepare_message($message)) : unprepare_message($message); // clean any bbcode_uid $subject = preg_replace('/\\:[0-9a-z\\:]+\\]/si', ']', $subject); $message = preg_replace('/\\:[0-9a-z\\:]+\\]/si', ']', $message); // clean HTML $subject = preg_replace('#(<)([\\/]?.*?)(>)#is', "<\\2>", $subject); $message = preg_replace('#(<)([\\/]?.*?)(>)#is', "<\\2>", $message); // from_user_id can be 0 for sys message (sent by the board) if (empty($from_userdata)) { $from_userdata['user_id'] = 0; $from_userdata['user_level'] = ADMIN; $from_userdata['username'] = $board_config['sitename']; } $from_user_id = intval($from_userdata['user_id']); // get the recipients $sql_where = "user_email <> '' AND user_email IS NOT NULL"; // this will require enhancement for the pcp ignore/friend list if (!$copy) { $sql_where .= " AND user_id <> " . intval($from_userdata['user_id']); } if ($userdata['user_level'] != ADMIN) { $sql_where .= " AND (user_viewemail = 1 OR user_id = " . intval($userdata['user_id']) . ")"; } // // Make sure user wánts the mail // $notify_sql = ''; $sql_notify = ''; if ($type == 'privmsg_notify') { $sql_notify = ', user_notify_pm'; $notify_sql = 'AND user_notify_pm != 0'; } // read the mail recipients $sql = "SELECT user_id, user_email, user_lang, username" . $sql_notify . "\n FROM " . USERS_TABLE . "\n WHERE user_id IN ({$s_to_user_ids})\n {$notify_sql}\n AND user_id NOT IN (0, " . ANONYMOUS . ")\n AND {$sql_where}"; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Could not read recipient mail list', '', __LINE__, __FILE__, $sql); } $count = 0; $bcc_list_ary = array(); while ($row = $db->sql_fetchrow($result)) { $count++; $bcc_list_ary[$row['user_lang']][] = array('user_id' => $row['user_id'], 'mail' => $row['user_email'], 'username' => $row['username']); } if ($count > 0) { // read the message recipients $msg_to = ''; if (!empty($recips)) { for ($i = 0; $i < count($recips); $i++) { $username = isset($recips[$i]['privmsg_to_username']) ? $recips[$i]['privmsg_to_username'] : $recips[$i]['username']; if (!empty($username)) { $msg_to .= (empty($msg_to) ? '' : ', ') . $username; } } } // // Let's do some checking to make sure that mass mail functions // are working in win32 versions of php. // if (preg_match('/[c-z]:\\\\.*/i', getenv('PATH')) && !$board_config['smtp_delivery']) { $ini_val = @phpversion() >= '4.0.0' ? 'ini_get' : 'get_cfg_var'; // We are running on windows, force delivery to use our smtp functions // since php's are broken by default $board_config['smtp_delivery'] = 1; $board_config['smtp_host'] = @$ini_val('SMTP'); } // init the mailer $emailer = new emailer($board_config['smtp_delivery']); // init server vars $server_name = trim($board_config['server_name']); $server_protocol = $board_config['cookie_secure'] ? 'https://' : 'http://'; $server_port = $board_config['server_port'] != 80 ? ':' . trim($board_config['server_port']) . '/' : '/'; // sender script $script_path = preg_replace('/^\\/?(.*?)\\/?$/', '\\1', trim($board_config['script_path'])); $script_path = !empty($script_name) ? $server_protocol . $server_name . $server_port . $script_name . '/' : $server_protocol . $server_name . $server_port; // start the emailer data $emailer->from($board_config['board_email']); $emailer->replyto($board_config['board_email']); // choose template switch ($type) { case 'privmsg_notify': $tpl = 'privmsg_notify'; $mail_subject = _lang('Notification_subject'); break; case 'save_to_mail': $tpl = 'admin_send_email'; $mail_subject = _lang('Save_to_mail_subject') . $subject; break; default: $tpl = 'admin_send_email'; $mail_subject = $subject; break; } // send message (coming partially from privmsgs.php) : one per lang @reset($bcc_list_ary); while (list($user_lang, $bcc_list) = each($bcc_list_ary)) { if ($count == 1) { $emailer->email_address($bcc_list[0]['mail']); } else { // affect users mail for ($i = 0; $i < count($bcc_list); $i++) { $emailer->bcc($bcc_list[$i]['mail']); } } // remove {USERNAME} from the template if more than one recipient if ($count > 0) { $emailer->msg = preg_replace('#[ ]?{USERNAME}#', '', $emailer->msg); } // build message $msg = _lang('Subject') . ': ' . $subject; $msg .= "\n" . _lang('From') . ': ' . $from_userdata['username']; if (!empty($msg_to)) { $msg .= "\n" . _lang('To') . ': ' . $msg_to; } if (!empty($time)) { $dformat = $board_config['default_dateformat']; $dtz = $board_config['board_timezone']; if (count($to_user_ids) == 1) { $dformat = $userdata['user_dateformat']; $dtz = $userdata['user_timezone']; } $post_date = create_date($dformat, $time, $dtz); $msg .= "\n" . _lang('Date') . ': ' . $post_date; } $msg .= "\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" . $message; // generic values $parsed_values['SITENAME'] = $board_config['sitename']; $parsed_values['EMAIL_SIG'] = !empty($board_config['board_email_sig']) ? str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']) : ''; $parsed_values['MESSAGE'] = $msg; $parsed_values['FROM'] = $userdata['username']; $emailer->use_template($tpl, $user_lang); $emailer->set_subject($mail_subject); $emailer->assign_vars($parsed_values); // send $emailer->send(); $emailer->reset(); } } }
function home() { global $core, $user, $style; $sql = 'SELECT * FROM _email WHERE email_active = 1 AND (email_schedule > ?? OR email_schedule = 0) ORDER BY email_priority, email_id LIMIT 1'; if (!$email = sql_fieldrow(sql_filter($sql, time()))) { $this->e('No queue.'); } set_time_limit(0); $sql = 'SELECT * FROM ?? WHERE address_sent = 0 ORDER BY address_id LIMIT ??'; if ($members = sql_rowset(sql_filter($sql, $email['email_data'], $email['email_batch']))) { if (!$email['email_start']) { $sql = 'UPDATE _email SET email_start = ? WHERE email_id = ?'; sql_query(sql_filter($sql, time(), $email['email_id'])); } } $i = 0; $sent_to = array(); foreach ($members as $row) { $address_account = trim($row['address_account']); if (!preg_match('/^[a-z0-9\.\-_\+]+@[a-z0-9\-_]+\.([a-z0-9\-_]+\.)*?[a-z]+$/is', $address_account)) { $sql = 'UPDATE ?? SET address_sent = ? WHERE address_id = ?'; sql_query(sql_filter($sql, $email['email_data'], 1, $row['address_id'])); continue; } if (!$i) { include(XFS . 'core/emailer.php'); $emailer = new emailer(); } $emailer->use_template('mass'); $emailer->format('html'); $emailer->from($email['email_from'] . ' <' . $email['email_from_address'] . '>'); $emailer->set_subject(entity_decode($email['email_subject'])); $emailer->email_address($address_account); $name_compose = ''; if (isset($row['address_name']) && !empty($row['address_name'])) { $row['address_name'] = preg_replace('/\s\s+/', ' ', $row['address_name']); $name_compose = ucwords(strtolower(trim($row['address_name']))); if (isset($row['address_last']) && !empty($row['address_last'])) { $row['address_last'] = preg_replace('/\s\s+/', ' ', $row['address_last']); $name_compose .= ' ' . ucwords(strtolower(trim($row['address_last']))); } if (!empty($name_compose)) { $name_gretting = ''; if (isset($row['address_gender']) && !empty($row['address_gender'])) { switch ($row['address_gender']) { case 'Femenino': $name_by = 'a'; break; case 'Masculino': $name_by = 'o'; break; default: $name_gretting = $core->config['email_gretting']; break; } } else { if (strpos($name_compose, 'Sra.') !== false || strpos($name_compose, 'Srta.') !== false) { $name_by = 'a'; } else if (strpos($name_compose, 'Sr.') !== false) { $name_by = 'o'; } else { $name_gretting = $core->config['email_gretting']; } } if (empty($email['email_gretting'])) { $name_gretting = $core->config['email_gretting']; } if (!empty($name_gretting)) { $name_compose = $name_gretting . ' ' . $name_compose; } elseif (!empty($name_by)) { if (strpos($email['email_gretting'], '*') !== false) { $name_compose = str_replace('*', $name_by, $email['email_gretting']) . ' ' . $name_compose; } } if (!empty($name_compose)) { $name_compose .= ', '; } } } $email_message = entity_decode($email['email_message']); if (strpos($email_message, '<system_image>') !== false) { $enc_email_id = encode($email['email_id']); $enc_address_id = encode($row['address_id']); $system_image_link = _link('i' . $enc_email_id . '-' . $enc_address_id . '.jpg', false, false); $email_message = str_replace('<system_image>', $system_image_link, $email_message); } $emailer->assign_vars(array( 'USERNAME' => $name_compose, 'MESSAGE' => $email_message) ); $emailer->send(); $emailer->reset(); $sql = 'UPDATE ?? SET address_sent = ? WHERE address_id = ?'; sql_query(sql_filter($sql, $email['email_data'], time(), $row['address_id'])); $i++; $sql = 'UPDATE _email SET email_last = email_last + 1 WHERE email_id = ?'; sql_query(sql_filter($sql, $email['email_id'])); $sent_to[] = $row['address_account']; sleep(1); } $sql = 'SELECT COUNT(address_id) AS total FROM ?? WHERE address_sent = 0 ORDER BY address_id'; if (!sql_field(sql_filter($sql, $email['email_data']), 'total', 0)) { $sql = 'UPDATE _email SET email_active = 0, email_end = ? WHERE email_id = ?'; sql_query(sql_filter($sql, time(), $email['email_id'])); return $this->e('Finished sending ' . $i . ' emails.'); } return $this->e('Processed ' . $i . ' emails.'); }
function sendmail($to, $from, $subject, $template = '', $vars = array()) { static $emailer; if (!$emailer) { $emailer = new emailer(); } $emailer->from = trim($from); $template_parts = explode(':', $template); if (isset($template_parts[0])) { $emailer->use_template($template_parts[0]); } if (isset($template_parts[1])) { $emailer->format = $template_parts[1]; } $emailer->assign_vars($vars); $response = $emailer->send(); $emailer->reset(); return $response; }
function notifyUser($user_id, $notify_type, $offer_id, $offer_title) { global $db, $lang, $auction_config_data, $board_config; if ($auction_config_data['auction_end_notify_email']) { // BEGIN EMAIL-NOTIFY $sql = "SELECT user_email,\r\n username\r\n FROM " . USERS_TABLE . "\r\n WHERE user_id=" . $user_id . ""; if (!($result = $db->sql_query($sql))) { } // if $user = $db->sql_fetchrow($result); $server_name = trim($board_config['server_name']); $server_protocol = $board_config['cookie_secure'] ? 'https://' : 'http://'; $server_port = $board_config['server_port'] != 80 ? ':' . trim($board_config['server_port']) . '/' : '/'; $username = $user['username']; $email = $user['user_email']; $emailer = new emailer($board_config['smtp_delivery']); $emailer->from($board_config['board_email']); $emailer->replyto($board_config['board_email']); if ($notify_type == 'WON') { $emailer->use_template('auction_won', stripslashes($user_lang)); $emailer->set_subject($lang['auction_won']); $emailer->assign_vars(array('AUCTION_WON' => $lang['auction_offer_won'], 'AUCTION_SITENAME' => $board_config['sitename'], 'AUCTION_OFFER' => prepare_message(addslashes(unprepare_message(htmlspecialchars(trim(stripslashes($offer_title))))), $board_config['allow_html'], $board_config['allow_bbcode'], $board_config['allow_smilies'], 0), 'U_AUCTION_OFFER' => $server_protocol . $server_name . $board_config['script_path'] . 'auction_offer_view.php?ao=' . $offer_id, 'AUCTION_EMAIL_SIG' => !empty($board_config['board_email_sig']) ? str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']) : '')); } if ($notify_type == 'SOLD') { $emailer->use_template('auction_sold', stripslashes($user_lang)); $emailer->set_subject($lang['auction_sold']); $emailer->assign_vars(array('AUCTION_SOLD' => $lang['auction_offer_sold'], 'AUCTION_SITENAME' => $board_config['sitename'], 'AUCTION_OFFER' => prepare_message(addslashes(unprepare_message(htmlspecialchars(trim(stripslashes($offer_title))))), $board_config['allow_html'], $board_config['allow_bbcode'], $board_config['allow_smilies'], 0), 'U_AUCTION_OFFER' => $server_protocol . $server_name . $board_config['script_path'] . 'auction_offer_view.php?ao=' . $offer_id, 'AUCTION_EMAIL_SIG' => !empty($board_config['board_email_sig']) ? str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']) : '')); } if ($notify_type == 'NOT_SOLD') { $emailer->use_template('auction_not_sold', stripslashes($user_lang)); $emailer->set_subject($lang['auction_not_sold']); $emailer->assign_vars(array('AUCTION_NOT_SOLD' => $lang['auction_offer_not_sold'], 'AUCTION_SITENAME' => $board_config['sitename'], 'AUCTION_OFFER' => prepare_message(addslashes(unprepare_message(htmlspecialchars(trim(stripslashes($offer_title))))), $board_config['allow_html'], $board_config['allow_bbcode'], $board_config['allow_smilies'], 0), 'U_AUCTION_OFFER' => $server_protocol . $server_name . $board_config['script_path'] . 'auction_offer_view.php?ao=' . $offer_id, 'AUCTION_EMAIL_SIG' => !empty($board_config['board_email_sig']) ? str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']) : '')); } $emailer->email_address($email); // Try to send email... $emailer->send(); // $emailer->reset(); } // END EMAIL-NOTIFY if ($auction_config_data['auction_end_notify_pm']) { // BEGIN PM-NOTIFY ON OUTBID if ($notify_type == 'WON') { $pm_subject = $lang['auction_won']; $pm_text = $lang['auction_won_text']; } if ($notify_type == 'SOLD') { $pm_subject = $lang['auction_sold']; $pm_text = $lang['auction_sold_text']; } if ($notify_type == 'NOT_SOLD') { $pm_subject = $lang['auction_not_sold']; $pm_text = $lang['auction_not_sold_text']; } $privmsgs_date = date("U"); $sql = "INSERT INTO " . PRIVMSGS_TABLE . "\r\n (privmsgs_type,\r\n privmsgs_subject,\r\n privmsgs_from_userid,\r\n privmsgs_to_userid,\r\n privmsgs_date,\r\n privmsgs_enable_html,\r\n privmsgs_enable_bbcode,\r\n privmsgs_enable_smilies,\r\n privmsgs_attach_sig)\r\n VALUES ('0',\r\n '" . str_replace("\\'", "''", addslashes(sprintf($pm_subject, $board_config['sitename']))) . "',\r\n '2',\r\n " . $user_id . ",\r\n " . $privmsgs_date . ",\r\n '0',\r\n '1',\r\n '1',\r\n '0')"; if (!$db->sql_query($sql)) { } // if $outbid_sent_id = $db->sql_nextid(); $sql = "INSERT INTO " . PRIVMSGS_TEXT_TABLE . "\r\n (privmsgs_text_id,\r\n privmsgs_text)\r\n VALUES (" . $outbid_sent_id . ",\r\n '" . str_replace("\\'", "''", $pm_text . "</br></br><a href=\"auction_offer_view.php?ao=" . $offer_id . "\">" . prepare_message(addslashes(unprepare_message(htmlspecialchars(trim(stripslashes($offer_title))))), $board_config['allow_html'], $board_config['allow_bbcode'], $board_config['allow_smilies'], 0) . "</a></br>" . $board_config['board_email_sig']) . "')"; if (!$db->sql_query($sql)) { } // if $sql = "UPDATE " . USERS_TABLE . "\r\n SET user_new_privmsg=user_new_privmsg+1\r\n WHERE user_id=" . $user_id; if (!$db->sql_query($sql)) { } // if } // End pm-notification }
function user_notification($mode, &$post_data, &$forum_id, &$topic_id, &$post_id, &$notify_user) { global $board_config, $lang, $db, $phpbb_root_path; global $userdata, $user_ip; $current_time = time(); if ($mode == 'delete') { $delete_sql = !$post_data['first_post'] && !$post_data['last_post'] ? " AND user_id = " . $userdata['user_id'] : ''; $sql = "DELETE FROM " . TOPICS_WATCH_TABLE . " WHERE topic_id = {$topic_id}" . $delete_sql; if (!$db->sql_query($sql)) { message_die(GENERAL_ERROR, 'Could not change topic notify data', '', __LINE__, __FILE__, $sql); } } else { if ($mode == 'reply') { $sql = "SELECT ban_userid \r\n\t\t\t\tFROM " . BANLIST_TABLE; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Could not obtain banlist', '', __LINE__, __FILE__, $sql); } $user_id_sql = ''; while ($row = $db->sql_fetchrow($result)) { if (isset($row['ban_userid'])) { $user_id_sql = ', ' . $row['ban_userid']; } } $sql = "SELECT u.user_id, u.username, u.user_email, u.user_lang, t.topic_title \r\n\t\t\t\tFROM " . TOPICS_WATCH_TABLE . " tw, " . TOPICS_TABLE . " t, " . USERS_TABLE . " u \r\n\t\t\t\tWHERE tw.topic_id = {$topic_id} \r\n\t\t\t\t\tAND tw.user_id NOT IN (" . $userdata['user_id'] . ", " . ANONYMOUS . $user_id_sql . " ) \r\n\t\t\t\t\tAND tw.notify_status = " . TOPIC_WATCH_UN_NOTIFIED . " \r\n\t\t\t\t\tAND t.topic_id = tw.topic_id \r\n\t\t\t\t\tAND u.user_id = tw.user_id"; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Could not obtain list of topic watchers', '', __LINE__, __FILE__, $sql); } $orig_word = array(); $replacement_word = array(); obtain_word_list($orig_word, $replacement_word); include $phpbb_root_path . 'includes/emailer.php'; $emailer = new emailer($board_config['smtp_delivery']); $script_name = preg_replace('/^\\/?(.*?)\\/?$/', '\\1', trim($board_config['script_path'])); $script_name = $script_name != '' ? $script_name . '/viewtopic.php' : 'viewtopic.php'; $server_name = trim($board_config['server_name']); $server_protocol = $board_config['cookie_secure'] ? 'https://' : 'http://'; $server_port = $board_config['server_port'] != 80 ? ':' . trim($board_config['server_port']) . '/' : '/'; $email_headers = 'From: ' . $board_config['board_email'] . "\nReturn-Path: " . $board_config['board_email'] . "\n"; $update_watched_sql = ''; if ($row = $db->sql_fetchrow($result)) { @set_time_limit(120); $topic_title = preg_replace($orig_word, $replacement_word, unprepare_message($row['topic_title'])); do { if ($row['user_email'] != '') { $emailer->use_template('topic_notify', $row['user_lang']); $emailer->email_address($row['user_email']); $emailer->set_subject(); $emailer->extra_headers($email_headers); $emailer->assign_vars(array('EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']), 'USERNAME' => $row['username'], 'SITENAME' => $board_config['sitename'], 'TOPIC_TITLE' => $topic_title, 'U_TOPIC' => $server_protocol . $server_name . $server_port . $script_name . '?' . POST_POST_URL . "={$post_id}#{$post_id}", 'U_STOP_WATCHING_TOPIC' => $server_protocol . $server_name . $server_port . $script_name . '?' . POST_TOPIC_URL . "={$topic_id}&unwatch=topic")); $emailer->send(); $emailer->reset(); $update_watched_sql .= $update_watched_sql != '' ? ', ' . $row['user_id'] : $row['user_id']; } } while ($row = $db->sql_fetchrow($result)); } if ($update_watched_sql != '') { $sql = "UPDATE " . TOPICS_WATCH_TABLE . "\r\n\t\t\t\t\tSET notify_status = " . TOPIC_WATCH_NOTIFIED . "\r\n\t\t\t\t\tWHERE topic_id = {$topic_id}\r\n\t\t\t\t\t\tAND user_id IN ({$update_watched_sql})"; $db->sql_query($sql); } } $sql = "SELECT topic_id \r\n\t\t\tFROM " . TOPICS_WATCH_TABLE . "\r\n\t\t\tWHERE topic_id = {$topic_id}\r\n\t\t\t\tAND user_id = " . $userdata['user_id']; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Could not obtain topic watch information', '', __LINE__, __FILE__, $sql); } $row = $db->sql_fetchrow($result); if (!$notify_user && !empty($row['topic_id'])) { $sql = "DELETE FROM " . TOPICS_WATCH_TABLE . "\r\n\t\t\t\tWHERE topic_id = {$topic_id}\r\n\t\t\t\t\tAND user_id = " . $userdata['user_id']; if (!$db->sql_query($sql)) { message_die(GENERAL_ERROR, 'Could not delete topic watch information', '', __LINE__, __FILE__, $sql); } } else { if ($notify_user && empty($row['topic_id'])) { $sql = "INSERT INTO " . TOPICS_WATCH_TABLE . " (user_id, topic_id, notify_status)\r\n\t\t\t\tVALUES (" . $userdata['user_id'] . ", {$topic_id}, 0)"; if (!$db->sql_query($sql)) { message_die(GENERAL_ERROR, 'Could not insert topic watch information', '', __LINE__, __FILE__, $sql); } } } } }
/** * Send user notifications on new topic or reply */ function send_notifications($mode, &$post_data, &$topic_title, &$forum_id, &$topic_id, &$post_id, &$notify_user) { global $config, $lang, $db, $user; global $bbcode; $current_time = time(); include_once IP_ROOT_PATH . 'includes/bbcode.' . PHP_EXT; if ($mode != 'delete') { if ($mode == 'reply') { // Look for users with notification enabled $sql = "SELECT u.user_id, u.user_email, u.user_lang, u.username, f.forum_name\n\t\t\t\t\tFROM " . USERS_TABLE . " u, " . TOPICS_WATCH_TABLE . " tw, " . FORUMS_TABLE . " f\n\t\t\t\t\tWHERE tw.topic_id = " . $topic_id . "\n\t\t\t\t\t\tAND " . $db->sql_in_set('tw.user_id', $this->exclude_users, true, true) . "\n\t\t\t\t\t\tAND tw.notify_status = " . TOPIC_WATCH_UN_NOTIFIED . "\n\t\t\t\t\t\tAND f.forum_id = " . $forum_id . "\n\t\t\t\t\t\tAND u.user_id = tw.user_id\n\t\t\t\t\t\tAND u.user_active = 1"; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { if (!in_array($row['user_id'], $this->notify_userid)) { if ($row['user_email'] != '') { $this->notify_userdata[] = array('username' => $row['username'], 'user_email' => $row['user_email'], 'user_lang' => $row['user_lang']); } $this->notify_userid[] = $row['user_id']; $this->notify_forum_name = $row['forum_name']; } } $db->sql_freeresult($result); } if ($mode == 'newtopic' || $mode == 'reply') { // Reply or New Topic forum notification $sql = "SELECT u.user_id, u.user_email, u.user_lang, f.forum_name\n\t\t\t\t\tFROM " . USERS_TABLE . " u, " . FORUMS_WATCH_TABLE . " fw, " . FORUMS_TABLE . " f\n\t\t\t\t\tWHERE fw.forum_id = " . $forum_id . "\n\t\t\t\t\t\tAND " . $db->sql_in_set('fw.user_id', array_merge($this->exclude_users, $this->notify_userid), true, true) . "\n\t\t\t\t\t\tAND fw.notify_status = " . TOPIC_WATCH_UN_NOTIFIED . "\n\t\t\t\t\t\tAND f.forum_id = " . $forum_id . "\n\t\t\t\t\t\tAND f.forum_notify = '1'\n\t\t\t\t\t\tAND u.user_id = fw.user_id\n\t\t\t\t\t\tAND u.user_active = 1"; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { if (!in_array($row['user_id'], $this->notify_userid)) { if ($row['user_email'] != '') { $this->notify_userdata[] = array('username' => $row['username'], 'user_email' => $row['user_email'], 'user_lang' => $row['user_lang']); } $this->notify_userid[] = $row['user_id']; $this->notify_forum_name = $row['forum_name']; } } $db->sql_freeresult($result); } // Users array built, so start sending notifications if (sizeof($this->notify_userdata) > 0) { include_once IP_ROOT_PATH . 'includes/emailer.' . PHP_EXT; $emailer = new emailer(); $server_url = create_server_url(); $topic_title = unprepare_message($topic_title); $topic_title = censor_text($topic_title); $post_text = unprepare_message($post_data['message']); $post_text = censor_text($post_text); if (!empty($config['html_email'])) { $bbcode->allow_bbcode = !empty($config['allow_bbcode']) ? $config['allow_bbcode'] : false; $bbcode->allow_html = !empty($config['allow_html']) ? $config['allow_html'] : false; $bbcode->allow_smilies = !empty($config['allow_smilies']) ? $config['allow_smilies'] : false; $post_text = $bbcode->parse($post_text); } else { $post_text = $bbcode->plain_message($post_text, ''); } for ($i = 0; $i < sizeof($this->notify_userdata); $i++) { $emailer->use_template('topic_notify', $this->notify_userdata[$i]['user_lang']); $emailer->bcc($this->notify_userdata[$i]['user_email']); // The Topic_reply_notification lang string below will be used // if for some reason the mail template subject cannot be read // ... note it will not necessarily be in the posters own language! $emailer->set_subject($lang['Topic_reply_notification']); // This is a nasty kludge to remove the username var ... till (if?) translators update their templates $emailer->msg = preg_replace('#[ ]?{USERNAME}#', $this->notify_userdata[$i]['username'], $emailer->msg); if ($config['url_rw'] == '1') { $topic_url = $server_url . str_replace('--', '-', make_url_friendly($topic_title) . '-vp' . $post_id . '.html#p' . $post_id); } else { $topic_url = $server_url . CMS_PAGE_VIEWTOPIC . '?' . POST_POST_URL . '=' . $post_id . '#p' . $post_id; } $email_sig = create_signature($config['board_email_sig']); $emailer->assign_vars(array('EMAIL_SIG' => $email_sig, 'SITENAME' => $config['sitename'], 'TOPIC_TITLE' => $topic_title, 'POST_TEXT' => $post_text, 'POSTERNAME' => $post_data['username'], 'FORUM_NAME' => $this->notify_forum_name, 'ROOT' => $server_url, 'U_TOPIC' => $topic_url, 'U_STOP_WATCHING_TOPIC' => $server_url . CMS_PAGE_VIEWTOPIC . '?' . POST_TOPIC_URL . '=' . $topic_id . '&unwatch=topic')); $emailer->send(); $emailer->reset(); } } // Emails sent, so set users were notified $sql = "UPDATE " . TOPICS_WATCH_TABLE . "\n\t\t\t\tSET notify_status = " . TOPIC_WATCH_NOTIFIED . "\n\t\t\t\tWHERE topic_id = " . $topic_id . "\n\t\t\t\tAND " . $db->sql_in_set('user_id', $this->notify_userid, false, true); $db->sql_query($sql); $sql = "UPDATE " . FORUMS_WATCH_TABLE . "\n\t\t\t\tSET notify_status = " . TOPIC_WATCH_NOTIFIED . "\n\t\t\t\tWHERE forum_id = " . $forum_id . "\n\t\t\t\tAND " . $db->sql_in_set('user_id', $this->notify_userid, false, true); $db->sql_query($sql); // Delete notification for poster if present, or re-activate it if requested if (!$notify_user && !empty($row['topic_id'])) { $this->delete_topic_watch($user->data['user_id'], $topic_id); } elseif ($notify_user && empty($row['topic_id'])) { $this->delete_topic_watch($user->data['user_id'], $topic_id); $this->insert_topic_watch($user->data['user_id'], $topic_id, $forum_id, TOPIC_WATCH_UN_NOTIFIED); } } }
function user_notification($mode, &$post_data, &$topic_title, &$forum_id, &$topic_id, &$notify_user) { global $bb_cfg, $lang, $userdata; if (!$bb_cfg['topic_notify_enabled']) { return; } if ($mode != 'delete') { if ($mode == 'reply') { $update_watched_sql = $user_id_sql = array(); $sql = DB()->fetch_rowset("SELECT ban_userid FROM " . BB_BANLIST . " WHERE ban_userid != 0"); foreach ($sql as $row) { $user_id_sql[] = ',' . $row['ban_userid']; } $user_id_sql = join('', $user_id_sql); $watch_list = DB()->fetch_rowset("SELECT u.username, u.user_id, u.user_email, u.user_lang\n\t\t\t\tFROM " . BB_TOPICS_WATCH . " tw, " . BB_USERS . " u\n\t\t\t\tWHERE tw.topic_id = {$topic_id}\n\t\t\t\t\tAND tw.user_id NOT IN (" . $userdata['user_id'] . ", " . EXCLUDED_USERS_CSV . $user_id_sql . ")\n\t\t\t\t\tAND tw.notify_status = " . TOPIC_WATCH_NOTIFIED . "\n\t\t\t\t\tAND u.user_id = tw.user_id\n\t\t\t\t\tAND u.user_active = 1\n\t\t\t\tORDER BY u.user_id\n\t\t\t"); if ($watch_list) { require CLASS_DIR . 'emailer.php'; $emailer = new emailer($bb_cfg['smtp_delivery']); $orig_word = $replacement_word = array(); obtain_word_list($orig_word, $replacement_word); if (count($orig_word)) { $topic_title = preg_replace($orig_word, $replacement_word, $topic_title); } $u_topic = make_url(TOPIC_URL . $topic_id . '&view=newest#newest'); $unwatch_topic = make_url(TOPIC_URL . "{$topic_id}&unwatch=topic"); foreach ($watch_list as $row) { $emailer->from($bb_cfg['sitename'] . " <{$bb_cfg['board_email']}>"); $emailer->email_address($row['username'] . " <{$row['user_email']}>"); $emailer->use_template('topic_notify', $row['user_lang']); $emailer->assign_vars(array('TOPIC_TITLE' => html_entity_decode($topic_title), 'SITENAME' => $bb_cfg['sitename'], 'USERNAME' => $row['username'], 'U_TOPIC' => $u_topic, 'U_STOP_WATCHING_TOPIC' => $unwatch_topic)); $emailer->send(); $emailer->reset(); $update_watched_sql[] = $row['user_id']; } $update_watched_sql = join(',', $update_watched_sql); } if ($update_watched_sql) { DB()->query("UPDATE " . BB_TOPICS_WATCH . "\n\t\t\t\t\tSET notify_status = " . TOPIC_WATCH_UNNOTIFIED . "\n\t\t\t\t\tWHERE topic_id = {$topic_id}\n\t\t\t\t\t\tAND user_id IN ({$update_watched_sql})\n\t\t\t\t"); } } $topic_watch = DB()->fetch_row("SELECT topic_id FROM " . BB_TOPICS_WATCH . " WHERE topic_id = {$topic_id} AND user_id = {$userdata['user_id']}", 'topic_id'); if (!$notify_user && !empty($topic_watch)) { DB()->query("DELETE FROM " . BB_TOPICS_WATCH . " WHERE topic_id = {$topic_id} AND user_id = {$userdata['user_id']}"); } else { if ($notify_user && empty($topic_watch)) { DB()->query("\n\t\t\t\tINSERT INTO " . BB_TOPICS_WATCH . " (user_id, topic_id, notify_status)\n\t\t\t\tVALUES (" . $userdata['user_id'] . ", {$topic_id}, " . TOPIC_WATCH_NOTIFIED . ")\n\t\t\t"); } } } }
'FREQUENCY' => $row['digest_type'], 'L_NEW_MESSAGES' => $lang['digest_show_only_new_messages'], 'NEW_MESSAGES' => $row['new_only'], 'L_SEND_DIGEST' => $lang['digest_send_if_no_new_messages'], 'SEND_DIGEST' => $row['send_on_no_messages'], 'L_SEND_TIME' => $lang['digest_hour_to_send_short'], 'SEND_TIME' => gmdate('g A', gmmktime($send_hour)), 'DIGEST_CONTENT' => $msg, 'DISCLAIMER' => ($html) ? $lang['digest_disclaimer_html'] : $lang['digest_disclaimer_text'], 'L_TEXT_LENGTH' => $lang['digest_message_size'], 'TEXT_LENGTH' => $row['text_length'], 'L_VERSION' => $lang['digest_version_text'], 'VERSION' => DIGEST_VERSION ) ); $emailer->send($html); $emailer->reset(); $digests_sent++; } // Normally this is run as a batch job, but it can be useful to get summary information of what was sent and to whom. if (DIGEST_SHOW_SUMMARY) { $digest_log_entry .= $lang['digest_a_digest_containing'] . ' ' . $msg_count . ' ' . $lang['digest_posts_was_sent_to'] . ' ' . $row['user_email'] . $break_type; } } $db->sql_freeresult($result); // Summary information normally not seen, but can be captured via command line to a file
protected function _ticket_home() { global $user, $core; if (!$core->v('cron_enabled')) { return $this->e('CRON_DISABLED'); } foreach (w('mail pop3 emailer htmlparser') as $row) { require_once XFS . 'core/' . $row . '.php'; } $pop3 = new pop3(); if (!$pop3->connect($core->v('mail_server'), $core->v('mail_port'))) { return $this->e('MAIL_NO_CONNECT'); } if (!($total_mail = $pop3->login('recent:' . $core->v('mail_ticket_login'), $core->v('mail_ticket_key')))) { return $this->e('MAIL_NEW_MAIL'); } // $mail = new _mail(); $emailer = new emailer(); // if (!($blacklist = $core->cache_load('ticket_blacklist'))) { $sql = 'SELECT * FROM _tickets_blacklist ORDER BY list_id'; $blacklist = $core->cache_store(_rowset($sql, 'list_address', 'list_id')); } if (!($ticket_status = $core->cache_load('ticket_status_default'))) { $sql = 'SELECT status_id FROM _tickets_status WHERE status_default = 1'; $ticket_status = $core->cache_store(_field($sql, 'status_id', 0)); } $sql = 'SELECT group_id, group_email FROM _groups ORDER BY group_email'; $groups = _rowset($sql, 'group_email', 'group_id'); $sql = 'SELECT group_email, group_name FROM _groups ORDER BY group_email'; $groups_name = _rowset($sql, 'group_email', 'group_name'); $sql = 'SELECT gg.group_email, m.user_email FROM _groups gg, _groups_members g, _members m WHERE g.member_mod = ? AND g.member_uid = m.user_id AND gg.group_id = g.member_group ORDER BY m.user_email'; $groups_mods = _rowset(sql_filter($sql, 1), 'group_email', 'user_email', true); foreach ($groups as $a_group_email => $a_group_id) { if (!isset($groups_mods[$a_group_email])) { $groups_mods[$a_group_email] = w(); } } $sql = 'SELECT s.a_assoc, s.a_value FROM _members_fields f, _members_store s WHERE s.a_field = f.field_id AND f.field_alias LIKE ? ORDER BY s.a_value'; $email_alt = _rowset(sql_filter($sql, 'email%'), 'a_value', 'a_assoc'); // Pre mail process $recv = w(); $now = time(); $line_orig = array(' '); $line_repl = array(' '); $_v = w('from from_d to ticket subject body date mod ip spam blacklist reply other'); $_c = w('normal reply other blacklist spam', 0); for ($i = 1; $i <= $total_mail; $i++) { foreach ($_v as $row) { ${'recv_' . $row} = 0; } $s_header = $mail->parse_header(split("\r\n", implode('', $pop3->top($i)))); $recv_from = $mail->parse_address($s_header['from']); if (isset($blacklist[$recv_from])) { $recv_blacklist = 1; } if ($recv_from == $core->v('mail_ticket_login')) { $recv_blacklist = 1; } _dvar($s_header['to'], ''); _dvar($s_header['cc'], ''); if (f($s_header['cc'])) { $s_header['to'] .= (f($s_header['to']) ? ', ' : '') . $s_header['cc']; } $to_part = array_map('trim', explode(strpos($s_header['to'], ',') ? ',' : ';', $s_header['to'])); foreach ($to_part as $row) { if (strpos($row, '<') !== false) { $row = preg_replace('#.*?<(.*?)>#is', '\\1', $row); } if (isset($blacklist[$row])) { $recv_blacklist = 1; } else { $recv_blacklist = 0; $row_first = array_key(explode('@', $row), 0); if (isset($groups[$row_first])) { $recv_to = $row_first; } } } if (strstr($s_header['to'], _lang('MAIL_TO_UNKNOWN')) !== false) { $recv_to = array_key(explode('@', $core->v('mail_ticket_login')), 0); } if (!$recv_to) { $recv_blacklist = 1; } if (!$recv_blacklist) { $recv_subject = htmlencode(trim($s_header['subject'])); if (preg_match('#\\[\\#(.*?)\\]#is', $recv_subject, $p_subject)) { $sql = 'SELECT ticket_id FROM _tickets WHERE ticket_code = ?'; if ($recv_subject_d = _fieldrow(sql_filter($sql, $p_subject[1]))) { $recv_ticket = $recv_subject_d['ticket_id']; $recv_reply = $p_subject[1]; $recv_subject = substr(strrchr($recv_subject, ']'), 3); } } if ($recv_to . '@' . $core->v('domain') == $recv_from && $recv_from == $core->v('mail_ticket_login') && $recv_reply) { $recv_blacklist = 1; } } if (!$recv_blacklist) { if (isset($email_alt[$recv_from])) { $sql_field = 'id'; $sql_value = $email_alt[$recv_from]; } else { $sql_field = 'username'; $sql_value = array_key(explode('@', $recv_from), 0); } $sql = 'SELECT user_id, user_username, user_firstname, user_lastname FROM _members WHERE user_?? = ?'; if ($recv_from_d = _fieldrow(sql_filter($sql, $sql_field, $sql_value))) { $recv_from_d = serialize(array_row($recv_from_d)); } else { $recv_other = 1; } $d_body = $mail->body($s_header, $pop3->fbody($i), true); $recv_date = $mail->parse_date($s_header['date']); $recv_ip = $mail->parse_ip($s_header['received']); if (isset($groups_email[$recv_to])) { $recv_mod = $groups_email[$recv_to]; } if ($recv_date > $now || $recv_date < $now - 86400) { $recv_date = $now; } if (isset($d_body['text-plain']) && f($d_body['text-plain'])) { $recv_body = trim($d_body['text-plain']); } elseif (isset($d_body['text-html']) && f($d_body['text-html'])) { $htm_text = w(); $tag_open = false; $parser = new HtmlParser($d_body['text-html']); while ($parser->parse()) { $line = trim(str_replace($line_orig, $line_repl, $parser->iNodeValue)); if ($tag_open || strpos($line, '<') !== false) { $tag_open = !$tag_open; continue; } if ($parser->iNodeName == 'Text' && f($line)) { $htm_text[] = preg_replace("/(\r\n){1}/", ' ', $line); } } $recv_body = implode("\n", $htm_text); } if (f($recv_body)) { $recv_body = htmlencode(_utf8($recv_body)); } if (!f($recv_body)) { $recv_blacklist = 1; } } $recv[$i] = w(); foreach ($_v as $row) { $recv[$i][$row] = ${'recv_' . $row}; } } foreach ($recv as $i => $row) { if ($row['spam'] || $row['blacklist']) { $pop3->delete($i); $row_key = $row['spam'] ? 'spam' : 'blacklist'; $_c[$row_key]++; continue; } // Send mail to group admin if ($row['other']) { $_c['other']++; if (count($groups_mods[$row['to']])) { foreach ($groups_mods[$row['to']] as $i => $mod_email) { $email_func = !$i ? 'email_address' : 'cc'; $emailer->{$email_func}($mod_email); } $emailer->from($row['from']); $emailer->replyto($row['from']); $emailer->set_subject(entity_decode($row['subject'])); $emailer->use_template('ticket_other'); $emailer->set_decode(true); $emailer->assign_vars(array('SUBJECT' => entity_decode($row['subject']), 'MESSAGE' => entity_decode($row['body']))); $emailer->send(); $emailer->reset(); } $pop3->delete($i); continue; } $row['code'] = $row['reply'] ? $row['reply'] : substr(md5(unique_id()), 0, 8); $row['from_d'] = unserialize($row['from_d']); $row['group_id'] = $groups[$row['to']]; $row['msubject'] = entity_decode(sprintf('%s [#%s]: %s', $groups_name[$row['to']], $row['code'], $row['subject'])); $row['mbody'] = explode("\n", $row['body']); // $body_const = w(); foreach ($row['mbody'] as $part_i => $part_row) { if (isset($row['mbody'][$part_i - 1]) && f($row['mbody'][$part_i - 1]) && f($row['mbody'][$part_i])) { $row['mbody'][$part_i] = "\n" . $part_row; } } $row['body'] = implode("\n", $row['mbody']); $v_mail = array('USERNAME' => $row['from_d']['user_username'], 'FULLNAME' => entity_decode(_fullname($row['from_d'])), 'SUBJECT' => entity_decode($row['subject']), 'MESSAGE' => entity_decode($row['body']), 'TICKET_URL' => _link('ticket', array('x1' => 'view', 'code' => $row['code']))); if (!$row['reply']) { $_c['normal']++; $sql_insert = array('parent' => 0, 'cat' => 1, 'group' => $row['group_id'], 'title' => _subject($row['subject']), 'text' => _prepare($row['body']), 'code' => $row['code'], 'contact' => $row['from_d']['user_id'], 'aby' => 0, 'status' => $ticket_status, 'start' => $row['date'], 'lastreply' => $row['date'], 'end' => 0, 'ip' => $row['ip']); $sql = 'INSERT INTO _tickets' . _build_array('INSERT', prefix('ticket', $sql_insert)); _sql($sql); // Send mail to user $emailer->email_address($row['from']); $emailer->from($row['to'] . '@' . $core->v('domain')); $emailer->set_subject($row['msubject']); $emailer->use_template('ticket_' . $row['to']); $emailer->set_decode(true); $emailer->assign_vars($v_mail); $emailer->send(); $emailer->reset(); // > Send mail to group admin if (count($groups_mods[$row['to']])) { foreach ($groups_mods[$row['to']] as $i => $mod_email) { $address_func = !$i ? 'email_address' : 'cc'; $emailer->{$address_func}($mod_email); } $emailer->from($row['to'] . '@' . $core->v('domain')); $emailer->set_subject($row['msubject']); $emailer->use_template('ticket_' . ($row['reply'] ? 'reply' : 'tech')); $emailer->set_decode(true); $emailer->assign_vars($v_mail); $emailer->send(); $emailer->reset(); } } else { $_c['reply']++; $sql_insert = array('ticket_id' => $row['ticket'], 'user_id' => $row['from_d']['user_id'], 'note_text' => htmlencode($row['body']), 'note_time' => $row['date'], 'note_cc' => 1); $sql = 'INSERT INTO _tickets_notes' . _build_array('INSERT', $sql_insert); _sql($sql); $sql = 'UPDATE _tickets SET ticket_lastreply = ? WHERE ticket_id = ?'; _sql(sql_filter($sql, $row['date'], $row['ticket'])); // Send mail to group members || user $sql = 'SELECT * FROM _tickets_assign a, _members m WHERE a.assign_ticket = ? AND a.user_id = m.user_id AND m.user_username NOT IN (?)'; $tech = _rowset(sql_filter($sql, $row['ticket'], $row['from_d']['user_username'])); if ($row['mod'] != $row['from_d']['user_username']) { $tech[] = $row['mod']; } if (count($tech)) { foreach ($tech as $tech_i => $tech_row) { $m_method = !$tech_i ? 'email_address' : 'cc'; $emailer->{$m_method}($tech_row . '@' . $core->v('domain')); } $emailer->from($row['to'] . '@' . $core->v('domain')); $emailer->use_template('ticket_reply'); $emailer->set_subject($row['msubject']); $emailer->set_decode(true); $emailer->assign_vars($v_mail); $emailer->send(); $emailer->reset(); } } // Delete mail from server $pop3->delete($i); } // Quit server $pop3->quit(); $ret = ''; foreach ($_c as $k => $v) { $ret .= "\n" . $k . ' = ' . $v . '<br />'; } return $this->e($ret); }
function user_notification($mode, &$post_data, &$topic_title, &$forum_id, &$topic_id, &$post_id, &$notify_user) { global $board_config, $lang, $db, $phpbb_root_path, $phpEx; global $userdata, $user_ip; $current_time = time(); if ($mode != 'delete') { if ($mode == 'reply') { $sql = "SELECT ban_userid \r\n\t\t\t\tFROM " . BANLIST_TABLE; if (!($result = $db->sql_query($sql, false, true))) { $db->clear_cache('posts_'); message_die(GENERAL_ERROR, 'Could not obtain banlist', '', __LINE__, __FILE__, $sql); } $user_id_sql = ''; while ($row = $db->sql_fetchrow($result)) { if (isset($row['ban_userid']) && !empty($row['ban_userid'])) { $user_id_sql .= ', ' . $row['ban_userid']; } } $sql = "SELECT u.user_id, u.user_email, u.user_lang \r\n\t\t\t\tFROM " . TOPICS_WATCH_TABLE . " tw, " . USERS_TABLE . " u \r\n\t\t\t\tWHERE tw.topic_id = {$topic_id} \r\n\t\t\t\t\tAND tw.user_id NOT IN (" . $userdata['user_id'] . ", " . ANONYMOUS . $user_id_sql . ") \r\n\t\t\t\t\tAND tw.notify_status = " . TOPIC_WATCH_UN_NOTIFIED . " \r\n\t\t\t\t\tAND u.user_id = tw.user_id"; if (!($result = $db->sql_query($sql))) { $db->clear_cache('posts_'); message_die(GENERAL_ERROR, 'Could not obtain list of topic watchers', '', __LINE__, __FILE__, $sql); } $update_watched_sql = ''; $bcc_list_ary = array(); if ($row = $db->sql_fetchrow($result)) { // Sixty second limit @set_time_limit(60); do { if ($row['user_email'] != '') { $bcc_list_ary[$row['user_lang']][] = $row['user_email']; } $update_watched_sql .= $update_watched_sql != '' ? ', ' . $row['user_id'] : $row['user_id']; } while ($row = $db->sql_fetchrow($result)); // // Let's do some checking to make sure that mass mail functions // are working in win32 versions of php. // if (preg_match('/[c-z]:\\\\.*/i', getenv('PATH')) && !$board_config['smtp_delivery']) { $ini_val = @phpversion() >= '4.0.0' ? 'ini_get' : 'get_cfg_var'; // We are running on windows, force delivery to use our smtp functions // since php's are broken by default $board_config['smtp_delivery'] = 1; $board_config['smtp_host'] = @$ini_val('SMTP'); } if (sizeof($bcc_list_ary)) { include $phpbb_root_path . 'includes/emailer.' . $phpEx; $emailer = new emailer($board_config['smtp_delivery']); $script_name = preg_replace('/^\\/?(.*?)\\/?$/', '\\1', trim($board_config['script_path'])); $script_name = $script_name != '' ? $script_name . '/viewtopic.' . $phpEx : 'viewtopic.' . $phpEx; $server_name = trim($board_config['server_name']); $server_protocol = $board_config['cookie_secure'] ? 'https://' : 'http://'; $server_port = $board_config['server_port'] != 80 ? ':' . trim($board_config['server_port']) . '/' : '/'; $orig_word = array(); $replacement_word = array(); obtain_word_list($orig_word, $replacement_word); $emailer->from($board_config['board_email']); $emailer->replyto($board_config['board_email']); $topic_title = count($orig_word) ? preg_replace($orig_word, $replacement_word, unprepare_message($topic_title)) : unprepare_message($topic_title); @reset($bcc_list_ary); while (list($user_lang, $bcc_list) = each($bcc_list_ary)) { $emailer->use_template('topic_notify', $user_lang); for ($i = 0; $i < count($bcc_list); $i++) { $emailer->bcc($bcc_list[$i]); } // The Topic_reply_notification lang string below will be used // if for some reason the mail template subject cannot be read // ... note it will not necessarily be in the posters own language! $emailer->set_subject($lang['Topic_reply_notification']); // This is a nasty kludge to remove the username var ... till (if?) // translators update their templates $emailer->msg = preg_replace('#[ ]?{USERNAME}#', '', $emailer->msg); $emailer->assign_vars(array('EMAIL_SIG' => !empty($board_config['board_email_sig']) ? str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']) : '', 'SITENAME' => $board_config['sitename'], 'TOPIC_TITLE' => $topic_title, 'U_TOPIC' => $server_protocol . $server_name . $server_port . $script_name . '?' . POST_POST_URL . "={$post_id}#{$post_id}", 'U_STOP_WATCHING_TOPIC' => $server_protocol . $server_name . $server_port . $script_name . '?' . POST_TOPIC_URL . "={$topic_id}&unwatch=topic")); $emailer->send(); $emailer->reset(); } } } $db->sql_freeresult($result); if ($update_watched_sql != '') { $sql = "UPDATE " . TOPICS_WATCH_TABLE . "\r\n\t\t\t\t\tSET notify_status = " . TOPIC_WATCH_NOTIFIED . "\r\n\t\t\t\t\tWHERE topic_id = {$topic_id}\r\n\t\t\t\t\t\tAND user_id IN ({$update_watched_sql})"; $db->sql_query($sql); } } $sql = "SELECT topic_id \r\n\t\t\tFROM " . TOPICS_WATCH_TABLE . "\r\n\t\t\tWHERE topic_id = {$topic_id}\r\n\t\t\t\tAND user_id = " . $userdata['user_id']; if (!($result = $db->sql_query($sql))) { $db->clear_cache('posts_'); message_die(GENERAL_ERROR, 'Could not obtain topic watch information', '', __LINE__, __FILE__, $sql); } $row = $db->sql_fetchrow($result); if (!$notify_user && !empty($row['topic_id'])) { $sql = "DELETE FROM " . TOPICS_WATCH_TABLE . "\r\n\t\t\t\tWHERE topic_id = {$topic_id}\r\n\t\t\t\t\tAND user_id = " . $userdata['user_id']; if (!$db->sql_query($sql)) { $db->clear_cache('posts_'); message_die(GENERAL_ERROR, 'Could not delete topic watch information', '', __LINE__, __FILE__, $sql); } } else { if ($notify_user && empty($row['topic_id'])) { $sql = "INSERT INTO " . TOPICS_WATCH_TABLE . " (user_id, topic_id, notify_status)\r\n\t\t\t\tVALUES (" . $userdata['user_id'] . ", {$topic_id}, 0)"; if (!$db->sql_query($sql)) { $db->clear_cache('posts_'); message_die(GENERAL_ERROR, 'Could not insert topic watch information', '', __LINE__, __FILE__, $sql); } } } } $db->clear_cache('posts_'); }
function chaser_email($sender_email, $recip_email, $subject, $message) { global $board_config, $phpEx, $phpbb_root_path; global $email_headers, $user_lang; include_once $phpbb_root_path . 'includes/emailer.' . $phpEx; // Left in for debugging //echo '===============================<br>'; //echo '$sender_email=',$sender_email,'<br>'; //echo '$recip_email=',$recip_email,'<br>'; //echo '$subject=',$subject,'<br>'; //echo '$message=',$message,'<br>'; $emailer = new emailer($board_config['smtp_delivery']); $emailer->from($sender_email); $emailer->replyto($sender_email); $emailer->use_template('admin_send_email', $user_lang); $emailer->email_address($recip_email); $emailer->set_subject($subject); $emailer->extra_headers($email_headers); $emailer->assign_vars(array('SITENAME' => $board_config['sitename'], 'BOARD_EMAIL' => $board_config['board_email'], 'MESSAGE' => $message)); $emailer->send(); $emailer->reset(); }
protected function _tech_add() { global $user, $core; gfatal(); if (!_auth_get('ticket_assign_tech') && !_auth_get('ticket_auto_assign')) { _fatal(); } $v = $this->__(array('ticket' => 0, 'tech')); if (_auth_get('ticket_auto_assign') && !$user->v('is_founder') && $user->v('user_username') != $v['tech']) { $this->_error('NO_ASSIGN_OTHER'); } $sql = 'SELECT * FROM _tickets t, _groups g WHERE t.ticket_id = ? AND t.ticket_group = g.group_id'; if (!($tdata = _fieldrow(sql_filter($sql, $v['ticket'])))) { $this->_error('NOT_MEMBER_2'); } $sql = 'SELECT user_id FROM _members WHERE user_username = ?'; $v['tech'] = _field(sql_filter($sql, $v['tech']), 'user_id', 0); $sql = 'SELECT * FROM _members WHERE user_id = ?'; if (!($techdata = _fieldrow(sql_filter($sql, $v['tech'])))) { $this->_error('NOT_MEMBER'); } $sql = 'SELECT ticket_id FROM _tickets WHERE ticket_contact = ? AND ticket_id = ?'; if ($row1 = _field(sql_filter($sql, $v['tech'], $v['ticket']), 'ticket_id', 0)) { $this->_error('CANT_ASSIGN'); } $sql = 'SELECT * FROM _tickets_assign WHERE user_id = ? AND assign_ticket = ?'; if ($row2 = _fieldrow(sql_filter($sql, $v['tech'], $v['ticket']))) { $this->_error('ALREADY_ASSIGN'); } $sql = 'SELECT * FROM _members WHERE user_id = ?'; if (!($cdata = _fieldrow(sql_filter($sql, $tdata['ticket_contact'])))) { $this->_error('NOT_MEMBER_3'); } $sql_insert = array('assign_ticket' => $v['ticket'], 'user_id' => $v['tech'], 'assign_status' => $tdata['ticket_status'], 'assign_end' => 0); $sql = 'INSERT INTO _tickets_assign' . _build_array('INSERT', $sql_insert); _sql($sql); // Send notification require_once XFS . 'core/emailer.php'; $emailer = new emailer(); $ticket_subject = entity_decode($tdata['group_name'] . ' [#' . $tdata['ticket_code'] . ']: ' . $tdata['ticket_title']); $ticket_message = entity_decode($tdata['ticket_text']); $emailer->from($tdata['group_email'] . '@' . $core->v('domain')); $emailer->email_address($techdata['user_email']); $emailer->use_template('ticket_tech'); $emailer->set_subject($ticket_subject); $emailer->assign_vars(array('USERNAME' => $techdata['user_username'], 'FULLNAME' => entity_decode(_fullname($cdata)), 'SUBJECT' => entity_decode($tdata['ticket_title']), 'MESSAGE' => $ticket_message, 'TICKET_URL' => _link($this->m(), array('x1' => 'view', 'code' => $tdata['ticket_code'])))); $emailer->send(); $emailer->reset(); return $this->e(_fullname($cdata)); }
function cash_pm(&$targetdata, $privmsg_subject, &$message) { global $db, $board_config, $lang, $userdata, $phpbb_root_path, $phpEx, $html_entities_match, $html_entities_replace; // // It looks like we're sending a PM! // NOTE: most of the following code is shamelessly "reproduced" from privmsg.php // include $phpbb_root_path . 'includes/bbcode.' . $phpEx; include $phpbb_root_path . 'includes/functions_post.' . $phpEx; // // Toggles // if (!$board_config['allow_html']) { $html_on = 0; } else { $html_on = $userdata['user_allowhtml']; } $bbcode_on = TRUE; if (!$board_config['allow_smilies']) { $smilies_on = 0; } else { $smilies_on = $userdata['user_allowsmile']; } $attach_sig = $userdata['user_attachsig']; // // Flood control // $sql = "SELECT MAX(privmsgs_date) AS last_post_time\n\t\tFROM " . PRIVMSGS_TABLE . "\n\t\tWHERE privmsgs_from_userid = " . $userdata['user_id']; if ($result = $db->sql_query($sql)) { $db_row = $db->sql_fetchrow($result); $last_post_time = $db_row['last_post_time']; $current_time = time(); if ($current_time - $last_post_time < $board_config['flood_interval']) { message_die(GENERAL_MESSAGE, $lang['Flood_Error']); } } // // End Flood control // $msg_time = time(); $bbcode_uid = make_bbcode_uid(); $privmsg_message = prepare_message($message, $html_on, $bbcode_on, $smilies_on, $bbcode_uid); // // See if recipient is at their inbox limit // $sql = "SELECT COUNT(privmsgs_id) AS inbox_items, MIN(privmsgs_date) AS oldest_post_time \n\t\tFROM " . PRIVMSGS_TABLE . " \n\t\tWHERE ( privmsgs_type = " . PRIVMSGS_NEW_MAIL . " \n\t\t\t\tOR privmsgs_type = " . PRIVMSGS_READ_MAIL . " \n\t\t\t\tOR privmsgs_type = " . PRIVMSGS_UNREAD_MAIL . " ) \n\t\t\tAND privmsgs_to_userid = " . $targetdata['user_id']; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_MESSAGE, $lang['No_such_user']); } $sql_priority = SQL_LAYER == 'mysql' ? 'LOW_PRIORITY' : ''; if ($inbox_info = $db->sql_fetchrow($result)) { if ($inbox_info['inbox_items'] >= $board_config['max_inbox_privmsgs']) { $sql = "SELECT privmsgs_id FROM " . PRIVMSGS_TABLE . " \n\t\t\t\tWHERE ( privmsgs_type = " . PRIVMSGS_NEW_MAIL . " \n\t\t\t\t\t\tOR privmsgs_type = " . PRIVMSGS_READ_MAIL . " \n\t\t\t\t\t\tOR privmsgs_type = " . PRIVMSGS_UNREAD_MAIL . " ) \n\t\t\t\t\tAND privmsgs_date = " . $inbox_info['oldest_post_time'] . " \n\t\t\t\t\tAND privmsgs_to_userid = " . $targetdata['user_id']; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Could not find oldest privmsgs (inbox)', '', __LINE__, __FILE__, $sql); } $old_privmsgs_id = $db->sql_fetchrow($result); $old_privmsgs_id = $old_privmsgs_id['privmsgs_id']; $sql = "DELETE {$sql_priority} FROM " . PRIVMSGS_TABLE . " \n\t\t\t\tWHERE privmsgs_id = {$old_privmsgs_id}"; if (!$db->sql_query($sql)) { message_die(GENERAL_ERROR, 'Could not delete oldest privmsgs (inbox)' . $sql, '', __LINE__, __FILE__, $sql); } $sql = "DELETE {$sql_priority} FROM " . PRIVMSGS_TEXT_TABLE . " \n\t\t\t\tWHERE privmsgs_text_id = {$old_privmsgs_id}"; if (!$db->sql_query($sql)) { message_die(GENERAL_ERROR, 'Could not delete oldest privmsgs text (inbox)', '', __LINE__, __FILE__, $sql); } } } $sql_info = "INSERT INTO " . PRIVMSGS_TABLE . " (privmsgs_type, privmsgs_subject, privmsgs_from_userid, privmsgs_to_userid, privmsgs_date, privmsgs_ip, privmsgs_enable_html, privmsgs_enable_bbcode, privmsgs_enable_smilies, privmsgs_attach_sig)\n\t\tVALUES (" . PRIVMSGS_NEW_MAIL . ", '" . str_replace("\\'", "''", $privmsg_subject) . "', " . $userdata['user_id'] . ", " . $targetdata['user_id'] . ", {$msg_time}, '{$user_ip}', {$html_on}, {$bbcode_on}, {$smilies_on}, {$attach_sig})"; if (!($result = $db->sql_query($sql_info, BEGIN_TRANSACTION))) { message_die(GENERAL_ERROR, "Could not insert/update private message sent info.", "", __LINE__, __FILE__, $sql_info); } $privmsg_sent_id = $db->sql_nextid(); $sql = "INSERT INTO " . PRIVMSGS_TEXT_TABLE . " (privmsgs_text_id, privmsgs_bbcode_uid, privmsgs_text)\n\t\tVALUES ({$privmsg_sent_id}, '" . $bbcode_uid . "', '" . str_replace("\\'", "''", $privmsg_message) . "')"; if (!$db->sql_query($sql, END_TRANSACTION)) { message_die(GENERAL_ERROR, "Could not insert/update private message sent text.", "", __LINE__, __FILE__, $sql_info); } // // Add to the users new pm counter // $sql = "UPDATE " . USERS_TABLE . "\n\t\tSET user_new_privmsg = user_new_privmsg + 1, user_last_privmsg = " . time() . " \n\t\tWHERE user_id = " . $targetdata['user_id']; if (!($status = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Could not update private message new/read status for user', '', __LINE__, __FILE__, $sql); } if ($targetdata['user_notify_pm'] && !empty($targetdata['user_email']) && $targetdata['user_active']) { $script_name = preg_replace('/^\\/?(.*?)\\/?$/', "\\1", trim($board_config['script_path'])); $script_name = $script_name != '' ? $script_name . '/privmsg.' . $phpEx : 'privmsg.' . $phpEx; $server_name = trim($board_config['server_name']); $server_protocol = $board_config['cookie_secure'] ? 'https://' : 'http://'; $server_port = $board_config['server_port'] != 80 ? ':' . trim($board_config['server_port']) . '/' : '/'; include $phpbb_root_path . 'includes/emailer.' . $phpEx; $emailer = new emailer($board_config['smtp_delivery']); $emailer->from($board_config['board_email']); $emailer->replyto($board_config['board_email']); $emailer->use_template('privmsg_notify', $targetdata['user_lang']); $emailer->email_address($targetdata['user_email']); $emailer->set_subject($lang['Notification_subject']); $emailer->assign_vars(array('USERNAME' => $to_username, 'SITENAME' => $board_config['sitename'], 'EMAIL_SIG' => !empty($board_config['board_email_sig']) ? str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']) : '', 'U_INBOX' => $server_protocol . $server_name . $server_port . $script_name . '?folder=inbox')); $emailer->send(); $emailer->reset(); } }