本文整理汇总了PHP中smf_db_insert函数的典型用法代码示例。如果您正苦于以下问题:PHP smf_db_insert函数的具体用法?PHP smf_db_insert怎么用?PHP smf_db_insert使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了smf_db_insert函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveDraft
/**
* Save a new draft, or update an existing draft.
*/
function saveDraft()
{
global $smcFunc, $topic, $board, $user_info, $options;
if (!isset($_REQUEST['draft']) || $user_info['is_guest'] || empty($options['use_drafts'])) {
return false;
}
$msgid = isset($_REQUEST['msg']) ? $_REQUEST['msg'] : 0;
// Clean up what we may or may not have
$subject = isset($_POST['subject']) ? $_POST['subject'] : '';
$message = isset($_POST['message']) ? $_POST['message'] : '';
$icon = isset($_POST['icon']) ? preg_replace('~[\\./\\\\*:"\'<>]~', '', $_POST['icon']) : 'xx';
// Sanitise what we do have
$subject = commonAPI::htmltrim(commonAPI::htmlspecialchars($subject));
$message = commonAPI::htmlspecialchars($message, ENT_QUOTES);
preparsecode($message);
if (commonAPI::htmltrim(commonAPI::htmlspecialchars($subject)) === '' && commonAPI::htmltrim(commonAPI::htmlspecialchars($_POST['message']), ENT_QUOTES) === '') {
fatal_lang_error('empty_draft', false);
}
// Hrm, so is this a new draft or not?
if (isset($_REQUEST['draft_id']) && (int) $_REQUEST['draft_id'] > 0 || $msgid) {
$_REQUEST['draft_id'] = (int) $_REQUEST['draft_id'];
$id_cond = $msgid ? ' 1=1 ' : ' id_draft = {int:draft} ';
$id_sel = $msgid ? ' AND id_msg = {int:message} ' : ' AND id_board = {int:board} AND id_topic = {int:topic} ';
// Does this draft exist?
smf_db_query('
UPDATE {db_prefix}drafts
SET subject = {string:subject},
body = {string:body},
updated = {int:post_time},
icon = {string:post_icon},
smileys = {int:smileys_enabled},
is_locked = {int:locked},
is_sticky = {int:sticky}
WHERE ' . $id_cond . '
AND id_member = {int:member}
' . $id_sel . '
LIMIT 1', array('draft' => $_REQUEST['draft_id'], 'board' => $board, 'topic' => $topic, 'message' => $msgid, 'member' => $user_info['id'], 'subject' => $subject, 'body' => $message, 'post_time' => time(), 'post_icon' => $icon, 'smileys_enabled' => !isset($_POST['ns']) ? 1 : 0, 'locked' => !empty($_POST['lock_draft']) ? 1 : 0, 'sticky' => isset($_POST['sticky']) ? 1 : 0));
if (smf_db_affected_rows() != 0) {
return $_REQUEST['draft_id'];
}
}
smf_db_insert('insert', '{db_prefix}drafts', array('id_board' => 'int', 'id_topic' => 'int', 'id_msg' => 'int', 'id_member' => 'int', 'subject' => 'string', 'body' => 'string', 'updated' => 'int', 'icon' => 'string', 'smileys' => 'int', 'is_locked' => 'int', 'is_sticky' => 'int'), array($board, $topic, $msgid, $user_info['id'], $subject, $message, time(), $icon, !isset($_POST['ns']) ? 1 : 0, !empty($_POST['lock_draft']) ? 1 : 0, isset($_POST['sticky']) ? 1 : 0), array('id_draft'));
return smf_db_insert_id('{db_prefix}drafts');
}
示例2: updateTopics
function updateTopics($topics)
{
global $context, $smcFunc;
if (empty($topics)) {
return;
}
// Get subject from database as we need it
$request = smf_db_query('
SELECT t.id_topic, mf.subject
FROM {db_prefix}topics AS t
INNER JOIN {db_prefix}messages AS mf ON (mf.id_msg = t.id_first_msg)
WHERE t.id_topic IN({array_int:topics})' . (!empty($context['rt_ignore']) ? '
AND t.id_board NOT IN({array_int:ignored})' : ''), array('topics' => $topics, 'ignored' => $context['rt_ignore']));
$rows = array();
while ($row = mysql_fetch_assoc($request)) {
$rows[] = array($row['id_topic'], $row['subject']);
}
mysql_free_result($request);
if (empty($rows)) {
return true;
}
// Insert to cache
smf_db_insert('replace', '{db_prefix}related_subjects', array('id_topic' => 'int', 'subject' => 'string-255'), $rows, array('id_topic'));
// Search for relations
$relatedRows = array();
foreach ($rows as $id_topic) {
list($id_topic, $subject) = $id_topic;
$relatedTopics = $this->__searchRelated($subject);
foreach ($relatedTopics as $id_topic_rel) {
list($id_topic_rel, $score) = $id_topic_rel;
if ($id_topic_rel == $id_topic) {
continue;
}
$relatedRows[] = array($id_topic, $id_topic_rel, $score);
}
unset($relatedTopics);
}
relatedAddRelatedTopic($relatedRows, 'fulltext');
return true;
}
示例3: EditMembergroup
//.........这里部分代码省略.........
SELECT id_member
FROM {db_prefix}members
WHERE member_name IN ({array_string:moderators}) OR real_name IN ({array_string:moderators})
LIMIT ' . count($moderators), array('moderators' => $moderators));
while ($row = mysql_fetch_assoc($request)) {
$group_moderators[] = $row['id_member'];
}
mysql_free_result($request);
}
} else {
$moderators = array();
foreach ($_POST['moderator_list'] as $moderator) {
$moderators[] = (int) $moderator;
}
$group_moderators = array();
if (!empty($moderators)) {
$request = smf_db_query('
SELECT id_member
FROM {db_prefix}members
WHERE id_member IN ({array_int:moderators})
LIMIT {int:num_moderators}', array('moderators' => $moderators, 'num_moderators' => count($moderators)));
while ($row = mysql_fetch_assoc($request)) {
$group_moderators[] = $row['id_member'];
}
mysql_free_result($request);
}
}
// Found some?
if (!empty($group_moderators)) {
$mod_insert = array();
foreach ($group_moderators as $moderator) {
$mod_insert[] = array($_REQUEST['group'], $moderator);
}
smf_db_insert('insert', '{db_prefix}group_moderators', array('id_group' => 'int', 'id_member' => 'int'), $mod_insert, array('id_group', 'id_member'));
}
}
// There might have been some post group changes.
updateStats('postgroups');
// We've definetely changed some group stuff.
updateSettings(array('settings_updated' => time()));
// Log the edit.
logAction('edited_group', array('group' => $_POST['group_name']), 'admin');
regenerateColorStyle();
redirectexit('action=admin;area=membergroups');
}
// Fetch the current group information.
$request = smf_db_query('
SELECT group_name, description, min_posts, online_color, max_messages, stars, group_type, hidden, id_parent
FROM {db_prefix}membergroups
WHERE id_group = {int:current_group}
LIMIT 1', array('current_group' => (int) $_REQUEST['group']));
if (mysql_num_rows($request) == 0) {
fatal_lang_error('membergroup_does_not_exist', false);
}
$row = mysql_fetch_assoc($request);
mysql_free_result($request);
$row['stars'] = explode('#', $row['stars']);
$context['group'] = array('id' => $_REQUEST['group'], 'name' => $row['group_name'], 'description' => htmlspecialchars($row['description']), 'editable_name' => htmlspecialchars($row['group_name']), 'color' => $row['online_color'], 'min_posts' => $row['min_posts'], 'max_messages' => $row['max_messages'], 'star_count' => (int) $row['stars'][0], 'star_image' => isset($row['stars'][1]) ? $row['stars'][1] : '', 'is_post_group' => $row['min_posts'] != -1, 'type' => $row['min_posts'] != -1 ? 0 : $row['group_type'], 'hidden' => $row['min_posts'] == -1 ? $row['hidden'] : 0, 'inherited_from' => $row['id_parent'], 'allow_post_group' => $_REQUEST['group'] == 2 || $_REQUEST['group'] > 4, 'allow_delete' => $_REQUEST['group'] == 2 || $_REQUEST['group'] > 4, 'allow_protected' => allowedTo('admin_forum'));
// Get any moderators for this group
$request = smf_db_query('
SELECT mem.id_member, mem.real_name
FROM {db_prefix}group_moderators AS mods
INNER JOIN {db_prefix}members AS mem ON (mem.id_member = mods.id_member)
WHERE mods.id_group = {int:current_group}', array('current_group' => $_REQUEST['group']));
$context['group']['moderators'] = array();
while ($row = mysql_fetch_assoc($request)) {
示例4: ModifyKarma
function ModifyKarma()
{
global $modSettings, $txt, $user_info, $topic, $smcFunc, $context;
// If the mod is disabled, show an error.
if (empty($modSettings['karmaMode'])) {
fatal_lang_error('feature_disabled', true);
}
// If you're a guest or can't do this, blow you off...
is_not_guest();
isAllowedTo('karma_edit');
checkSession('get');
// If you don't have enough posts, tough luck.
// !!! Should this be dropped in favor of post group permissions? Should this apply to the member you are smiting/applauding?
if (!$user_info['is_admin'] && $user_info['posts'] < $modSettings['karmaMinPosts']) {
fatal_lang_error('not_enough_posts_karma', true, array($modSettings['karmaMinPosts']));
}
// And you can't modify your own, punk! (use the profile if you need to.)
if (empty($_REQUEST['uid']) || (int) $_REQUEST['uid'] == $user_info['id']) {
fatal_lang_error('cant_change_own_karma', false);
}
// The user ID _must_ be a number, no matter what.
$_REQUEST['uid'] = (int) $_REQUEST['uid'];
// Applauding or smiting?
$dir = $_REQUEST['sa'] != 'applaud' ? -1 : 1;
// Delete any older items from the log. (karmaWaitTime is by hour.)
smf_db_query('
DELETE FROM {db_prefix}log_karma
WHERE {int:current_time} - log_time > {int:wait_time}', array('wait_time' => (int) ($modSettings['karmaWaitTime'] * 3600), 'current_time' => time()));
// Start off with no change in karma.
$action = 0;
// Not an administrator... or one who is restricted as well.
if (!empty($modSettings['karmaTimeRestrictAdmins']) || !allowedTo('moderate_forum')) {
// Find out if this user has done this recently...
$request = smf_db_query('
SELECT action
FROM {db_prefix}log_karma
WHERE id_target = {int:id_target}
AND id_executor = {int:current_member}
LIMIT 1', array('current_member' => $user_info['id'], 'id_target' => $_REQUEST['uid']));
if (mysql_num_rows($request) > 0) {
list($action) = mysql_fetch_row($request);
}
mysql_free_result($request);
}
// They haven't, not before now, anyhow.
if (empty($action) || empty($modSettings['karmaWaitTime'])) {
// Put it in the log.
smf_db_insert('replace', '{db_prefix}log_karma', array('action' => 'int', 'id_target' => 'int', 'id_executor' => 'int', 'log_time' => 'int'), array($dir, $_REQUEST['uid'], $user_info['id'], time()), array('id_target', 'id_executor'));
// Change by one.
updateMemberData($_REQUEST['uid'], array($dir == 1 ? 'karma_good' : 'karma_bad' => '+'));
} else {
// If you are gonna try to repeat.... don't allow it.
if ($action == $dir) {
fatal_lang_error('karma_wait_time', false, array($modSettings['karmaWaitTime'], $txt['hours']));
}
// You decided to go back on your previous choice?
smf_db_query('
UPDATE {db_prefix}log_karma
SET action = {int:action}, log_time = {int:current_time}
WHERE id_target = {int:id_target}
AND id_executor = {int:current_member}', array('current_member' => $user_info['id'], 'action' => $dir, 'current_time' => time(), 'id_target' => $_REQUEST['uid']));
// It was recently changed the OTHER way... so... reverse it!
if ($dir == 1) {
updateMemberData($_REQUEST['uid'], array('karma_good' => '+', 'karma_bad' => '-'));
} else {
updateMemberData($_REQUEST['uid'], array('karma_bad' => '+', 'karma_good' => '-'));
}
}
// Figure out where to go back to.... the topic?
if (!empty($topic)) {
redirectexit('topic=' . $topic . '.' . $_REQUEST['start'] . '#msg' . (int) $_REQUEST['m']);
} elseif (isset($_REQUEST['f'])) {
redirectexit('action=pm;f=' . $_REQUEST['f'] . ';start=' . $_REQUEST['start'] . (isset($_REQUEST['l']) ? ';l=' . (int) $_REQUEST['l'] : '') . (isset($_REQUEST['pm']) ? '#' . (int) $_REQUEST['pm'] : ''));
} else {
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"', $context['right_to_left'] ? ' dir="rtl"' : '', '>
<head>
<title>...</title>
<script type="text/javascript"><!-- // --><![CDATA[
history.go(-1);
// ]]></script>
</head>
<body>«</body>
</html>';
obExit(false);
}
}
示例5: ReduceMailQueue
//.........这里部分代码省略.........
$modSettings['mail_next_send'] = time() + $delay;
}
// If we're not overriding how many are we allow to send?
if (!$override_limit && !empty($modSettings['mail_limit'])) {
list($mt, $mn) = @explode('|', $modSettings['mail_recent']);
// Nothing worth noting...
if (empty($mn) || $mt < time() - 60) {
$mt = time();
$mn = $number;
} elseif ($mn < $modSettings['mail_limit']) {
$mn += $number;
} else {
return false;
}
// Reflect that we're about to send some, do it now to be safe.
updateSettings(array('mail_recent' => $mt . '|' . $mn));
}
// Now we know how many we're sending, let's send them.
$request = smf_db_query('
SELECT /*!40001 SQL_NO_CACHE */ id_mail, recipient, body, subject, headers, send_html
FROM {db_prefix}mail_queue
ORDER BY priority ASC, id_mail ASC
LIMIT ' . $number, array());
$ids = array();
$emails = array();
while ($row = mysql_fetch_assoc($request)) {
// We want to delete these from the database ASAP, so just get the data and go.
$ids[] = $row['id_mail'];
$emails[] = array('to' => $row['recipient'], 'body' => $row['body'], 'subject' => $row['subject'], 'headers' => $row['headers'], 'send_html' => $row['send_html']);
}
mysql_free_result($request);
// Delete, delete, delete!!!
if (!empty($ids)) {
smf_db_query('
DELETE FROM {db_prefix}mail_queue
WHERE id_mail IN ({array_int:mail_list})', array('mail_list' => $ids));
}
// Don't believe we have any left?
if (count($ids) < $number) {
// Only update the setting if no-one else has beaten us to it.
smf_db_query('
UPDATE {db_prefix}settings
SET value = {string:no_send}
WHERE variable = {string:mail_next_send}
AND value = {string:last_mail_send}', array('no_send' => '0', 'mail_next_send' => 'mail_next_send', 'last_mail_send' => $modSettings['mail_next_send']));
}
if (empty($ids)) {
return false;
}
if (!empty($modSettings['mail_type']) && $modSettings['smtp_host'] != '') {
require_once $sourcedir . '/lib/Subs-Post.php';
}
// Send each email, yea!
$failed_emails = array();
foreach ($emails as $key => $email) {
if (empty($modSettings['mail_type']) || $modSettings['smtp_host'] == '') {
$email['subject'] = strtr($email['subject'], array("\r" => '', "\n" => ''));
if (!empty($modSettings['mail_strip_carriage'])) {
$email['body'] = strtr($email['body'], array("\r" => ''));
$email['headers'] = strtr($email['headers'], array("\r" => ''));
}
// No point logging a specific error here, as we have no language. PHP error is helpful anyway...
$result = mail(strtr($email['to'], array("\r" => '', "\n" => '')), $email['subject'], $email['body'], $email['headers']);
// Try to stop a timeout, this would be bad...
@set_time_limit(300);
if (function_exists('apache_reset_timeout')) {
@apache_reset_timeout();
}
} else {
$result = smtp_mail(array($email['to']), $email['subject'], $email['body'], $email['send_html'] ? $email['headers'] : 'Mime-Version: 1.0' . "\r\n" . $email['headers']);
}
// Hopefully it sent?
if (!$result) {
$failed_emails[] = array($email['to'], $email['body'], $email['subject'], $email['headers'], $email['send_html']);
}
}
// Any emails that didn't send?
if (!empty($failed_emails)) {
// Update the failed attempts check.
smf_db_insert('replace', '{db_prefix}settings', array('variable' => 'string', 'value' => 'string'), array('mail_failed_attempts', empty($modSettings['mail_failed_attempts']) ? 1 : ++$modSettings['mail_failed_attempts']), array('variable'));
// If we have failed to many times, tell mail to wait a bit and try again.
if ($modSettings['mail_failed_attempts'] > 5) {
smf_db_query('
UPDATE {db_prefix}settings
SET value = {string:mail_next_send}
WHERE variable = {string:next_mail_send}
AND value = {string:last_send}', array('next_mail_send' => time() + 60, 'mail_next_send' => 'mail_next_send', 'last_send' => $modSettings['mail_next_send']));
}
// Add our email back to the queue, manually.
smf_db_insert('insert', '{db_prefix}mail_queue', array('recipient' => 'string', 'body' => 'string', 'subject' => 'string', 'headers' => 'string', 'send_html' => 'string'), $failed_emails, array('id_mail'));
return false;
} elseif (!empty($modSettings['mail_failed_attempts'])) {
smf_db_query('
UPDATE {db_prefix}settings
SET value = {string:zero}
WHERE variable = {string:mail_failed_attempts}', array('zero' => '0', 'mail_failed_attempts' => 'mail_failed_attempts'));
}
// Had something to send...
return true;
}
示例6: EditPoll2
//.........这里部分代码省略.........
require_once $sourcedir . '/lib/Subs-Members.php';
$allowedGroups = groupsAllowedTo('poll_vote', $board);
if (!in_array(-1, $allowedGroups['allowed'])) {
$_POST['poll_guest_vote'] = 0;
}
}
// Ensure that the number options allowed makes sense, and the expiration date is valid.
if (!$isEdit || allowedTo('moderate_board')) {
$_POST['poll_expire'] = $_POST['poll_expire'] > 9999 ? 9999 : ($_POST['poll_expire'] < 0 ? 0 : $_POST['poll_expire']);
if (empty($_POST['poll_expire']) && $_POST['poll_hide'] == 2) {
$_POST['poll_hide'] = 1;
} elseif (!$isEdit || $_POST['poll_expire'] != ceil($bcinfo['expire_time'] <= time() ? -1 : ($bcinfo['expire_time'] - time()) / (3600 * 24))) {
$_POST['poll_expire'] = empty($_POST['poll_expire']) ? '0' : time() + $_POST['poll_expire'] * 3600 * 24;
} else {
$_POST['poll_expire'] = $bcinfo['expire_time'];
}
if (empty($_POST['poll_max_votes']) || $_POST['poll_max_votes'] <= 0) {
$_POST['poll_max_votes'] = 1;
} else {
$_POST['poll_max_votes'] = (int) $_POST['poll_max_votes'];
}
}
// If we're editing, let's commit the changes.
if ($isEdit) {
smf_db_query('
UPDATE {db_prefix}polls
SET question = {string:question}, change_vote = {int:change_vote},' . (allowedTo('moderate_board') ? '
hide_results = {int:hide_results}, expire_time = {int:expire_time}, max_votes = {int:max_votes},
guest_vote = {int:guest_vote}' : '
hide_results = CASE WHEN expire_time = {int:expire_time_zero} AND {int:hide_results} = 2 THEN 1 ELSE {int:hide_results} END') . '
WHERE id_poll = {int:id_poll}', array('change_vote' => $_POST['poll_change_vote'], 'hide_results' => $_POST['poll_hide'], 'expire_time' => !empty($_POST['poll_expire']) ? $_POST['poll_expire'] : 0, 'max_votes' => !empty($_POST['poll_max_votes']) ? $_POST['poll_max_votes'] : 0, 'guest_vote' => $_POST['poll_guest_vote'], 'expire_time_zero' => 0, 'id_poll' => $bcinfo['id_poll'], 'question' => $_POST['question']));
} else {
// Create the poll.
smf_db_insert('', '{db_prefix}polls', array('question' => 'string-255', 'hide_results' => 'int', 'max_votes' => 'int', 'expire_time' => 'int', 'id_member' => 'int', 'poster_name' => 'string-255', 'change_vote' => 'int', 'guest_vote' => 'int'), array($_POST['question'], $_POST['poll_hide'], $_POST['poll_max_votes'], $_POST['poll_expire'], $user_info['id'], $user_info['username'], $_POST['poll_change_vote'], $_POST['poll_guest_vote']), array('id_poll'));
// Set the poll ID.
$bcinfo['id_poll'] = smf_db_insert_id('{db_prefix}polls', 'id_poll');
// Link the poll to the topic
smf_db_query('
UPDATE {db_prefix}topics
SET id_poll = {int:id_poll}
WHERE id_topic = {int:current_topic}', array('current_topic' => $topic, 'id_poll' => $bcinfo['id_poll']));
}
// Get all the choices. (no better way to remove all emptied and add previously non-existent ones.)
$request = smf_db_query('
SELECT id_choice
FROM {db_prefix}poll_choices
WHERE id_poll = {int:id_poll}', array('id_poll' => $bcinfo['id_poll']));
$choices = array();
while ($row = mysql_fetch_assoc($request)) {
$choices[] = $row['id_choice'];
}
mysql_free_result($request);
$delete_options = array();
foreach ($_POST['options'] as $k => $option) {
// Make sure the key is numeric for sanity's sake.
$k = (int) $k;
// They've cleared the box. Either they want it deleted, or it never existed.
if (trim($option) == '') {
// They want it deleted. Bye.
if (in_array($k, $choices)) {
$delete_options[] = $k;
}
// Skip the rest...
continue;
}
// Dress the option up for its big date with the database.
示例7: sendApprovalNotifications
function sendApprovalNotifications(&$topicData)
{
global $scripturl, $language, $user_info;
global $modSettings;
// Clean up the data...
if (!is_array($topicData) || empty($topicData)) {
return;
}
$topics = array();
$digest_insert = array();
foreach ($topicData as $topic => $msgs) {
foreach ($msgs as $msgKey => $msg) {
censorText($topicData[$topic][$msgKey]['subject']);
censorText($topicData[$topic][$msgKey]['body']);
$topicData[$topic][$msgKey]['subject'] = un_htmlspecialchars($topicData[$topic][$msgKey]['subject']);
$topicData[$topic][$msgKey]['body'] = trim(un_htmlspecialchars(strip_tags(strtr(parse_bbc($topicData[$topic][$msgKey]['body'], false), array('<br />' => "\n", '</div>' => "\n", '</li>' => "\n", '[' => '[', ']' => ']')))));
$topics[] = $msg['id'];
$digest_insert[] = array($msg['topic'], $msg['id'], 'reply', $user_info['id']);
}
}
// These need to go into the digest too...
smf_db_insert('', '{db_prefix}log_digest', array('id_topic' => 'int', 'id_msg' => 'int', 'note_type' => 'string', 'exclude' => 'int'), $digest_insert, array());
// Find everyone who needs to know about this.
$members = smf_db_query('
SELECT
mem.id_member, mem.email_address, mem.notify_regularity, mem.notify_types, mem.notify_send_body, mem.lngfile,
ln.sent, mem.id_group, mem.additional_groups, b.member_groups, mem.id_post_group, t.id_member_started,
ln.id_topic
FROM {db_prefix}log_notify AS ln
INNER JOIN {db_prefix}members AS mem ON (mem.id_member = ln.id_member)
INNER JOIN {db_prefix}topics AS t ON (t.id_topic = ln.id_topic)
INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board)
WHERE ln.id_topic IN ({array_int:topic_list})
AND mem.is_activated = {int:is_activated}
AND mem.notify_types < {int:notify_types}
AND mem.notify_regularity < {int:notify_regularity}
GROUP BY mem.id_member, ln.id_topic, mem.email_address, mem.notify_regularity, mem.notify_types, mem.notify_send_body, mem.lngfile, ln.sent, mem.id_group, mem.additional_groups, b.member_groups, mem.id_post_group, t.id_member_started
ORDER BY mem.lngfile', array('topic_list' => $topics, 'is_activated' => 1, 'notify_types' => 4, 'notify_regularity' => 2));
$sent = 0;
while ($row = mysql_fetch_assoc($members)) {
if ($row['id_group'] != 1) {
$allowed = explode(',', $row['member_groups']);
$row['additional_groups'] = explode(',', $row['additional_groups']);
$row['additional_groups'][] = $row['id_group'];
$row['additional_groups'][] = $row['id_post_group'];
if (count(array_intersect($allowed, $row['additional_groups'])) == 0) {
continue;
}
}
$needed_language = empty($row['lngfile']) || empty($modSettings['userLanguage']) ? $language : $row['lngfile'];
if (empty($current_language) || $current_language != $needed_language) {
$current_language = loadLanguage('Post', $needed_language, false);
}
$sent_this_time = false;
// Now loop through all the messages to send.
foreach ($topicData[$row['id_topic']] as $msg) {
$replacements = array('TOPICSUBJECT' => $topicData[$row['id_topic']]['subject'], 'POSTERNAME' => un_htmlspecialchars($topicData[$row['id_topic']]['name']), 'TOPICLINK' => $scripturl . '?topic=' . $row['id_topic'] . '.new;topicseen#new', 'UNSUBSCRIBELINK' => $scripturl . '?action=notify;topic=' . $row['id_topic'] . '.0');
$message_type = 'notification_reply';
// Do they want the body of the message sent too?
if (!empty($row['notify_send_body']) && empty($modSettings['disallow_sendBody'])) {
$message_type .= '_body';
$replacements['BODY'] = $topicData[$row['id_topic']]['body'];
}
if (!empty($row['notify_regularity'])) {
$message_type .= '_once';
}
// Send only if once is off or it's on and it hasn't been sent.
if (empty($row['notify_regularity']) || empty($row['sent']) && !$sent_this_time) {
$emaildata = loadEmailTemplate($message_type, $replacements, $needed_language);
sendmail($row['email_address'], $emaildata['subject'], $emaildata['body'], null, 'm' . $topicData[$row['id_topic']]['last_id']);
$sent++;
}
$sent_this_time = true;
}
}
mysql_free_result($members);
if (isset($current_language) && $current_language != $user_info['language']) {
loadLanguage('Post');
}
// Sent!
if (!empty($sent)) {
smf_db_query('
UPDATE {db_prefix}log_notify
SET sent = {int:is_sent}
WHERE id_topic IN ({array_int:topic_list})
AND id_member != {int:current_member}', array('current_member' => $user_info['id'], 'topic_list' => $topics, 'is_sent' => 1));
}
}
示例8: PackageInstall
//.........这里部分代码省略.........
require $boarddir . '/Packages/temp/' . $context['base_path'] . $action['filename'];
} elseif ($action['type'] == 'redirect' && !empty($action['redirect_url'])) {
$context['redirect_url'] = $action['redirect_url'];
$context['redirect_text'] = !empty($action['filename']) && file_exists($boarddir . '/Packages/temp/' . $context['base_path'] . $action['filename']) ? file_get_contents($boarddir . '/Packages/temp/' . $context['base_path'] . $action['filename']) : ($context['uninstalling'] ? $txt['package_uninstall_done'] : $txt['package_installed_done']);
$context['redirect_timeout'] = $action['redirect_timeout'];
// Parse out a couple of common urls.
$urls = array('$boardurl' => $boardurl, '$scripturl' => $scripturl, '$session_var' => $context['session_var'], '$session_id' => $context['session_id']);
$context['redirect_url'] = strtr($context['redirect_url'], $urls);
}
}
package_flush_cache();
// First, ensure this change doesn't get removed by putting a stake in the ground (So to speak).
package_put_contents($boarddir . '/Packages/installed.list', time());
// See if this is already installed, and change it's state as required.
$request = smf_db_query('
SELECT package_id, install_state, db_changes
FROM {db_prefix}log_packages
WHERE install_state != {int:not_installed}
AND package_id = {string:current_package}
' . ($context['install_id'] ? ' AND id_install = {int:install_id} ' : '') . '
ORDER BY time_installed DESC
LIMIT 1', array('not_installed' => 0, 'install_id' => $context['install_id'], 'current_package' => $packageInfo['id']));
$is_upgrade = false;
while ($row = mysql_fetch_assoc($request)) {
// Uninstalling?
if ($context['uninstalling']) {
smf_db_query('
UPDATE {db_prefix}log_packages
SET install_state = {int:not_installed}, member_removed = {string:member_name}, id_member_removed = {int:current_member},
time_removed = {int:current_time}
WHERE package_id = {string:package_id}', array('current_member' => $user_info['id'], 'not_installed' => 0, 'current_time' => time(), 'package_id' => $row['package_id'], 'member_name' => $user_info['name']));
} else {
$is_upgrade = true;
$old_db_changes = empty($row['db_changes']) ? array() : unserialize($row['db_changes']);
}
}
// Assuming we're not uninstalling, add the entry.
if (!$context['uninstalling']) {
// Any db changes from older version?
if (!empty($old_db_changes)) {
$db_package_log = empty($db_package_log) ? $old_db_changes : array_merge($old_db_changes, $db_package_log);
}
// If there are some database changes we might want to remove then filter them out.
if (!empty($db_package_log)) {
// We're really just checking for entries which are create table AND add columns (etc).
$tables = array();
function sort_table_first($a, $b)
{
if ($a[0] == $b[0]) {
return 0;
}
return $a[0] == 'remove_table' ? -1 : 1;
}
usort($db_package_log, 'sort_table_first');
foreach ($db_package_log as $k => $log) {
if ($log[0] == 'remove_table') {
$tables[] = $log[1];
} elseif (in_array($log[1], $tables)) {
unset($db_package_log[$k]);
}
}
$db_changes = serialize($db_package_log);
} else {
$db_changes = '';
}
// What themes did we actually install?
$themes_installed = array_unique($themes_installed);
$themes_installed = implode(',', $themes_installed);
// What failed steps?
$failed_step_insert = serialize($failed_steps);
smf_db_insert('', '{db_prefix}log_packages', array('filename' => 'string', 'name' => 'string', 'package_id' => 'string', 'version' => 'string', 'id_member_installed' => 'int', 'member_installed' => 'string', 'time_installed' => 'int', 'install_state' => 'int', 'failed_steps' => 'string', 'themes_installed' => 'string', 'member_removed' => 'int', 'db_changes' => 'string'), array($packageInfo['filename'], $packageInfo['name'], $packageInfo['id'], $packageInfo['version'], $user_info['id'], $user_info['name'], time(), $is_upgrade ? 2 : 1, $failed_step_insert, $themes_installed, 0, $db_changes), array('id_install'));
}
mysql_free_result($request);
$context['install_finished'] = true;
}
// If there's database changes - and they want them removed - let's do it last!
if (!empty($db_changes) && !empty($_POST['do_db_changes'])) {
// We're gonna be needing the package db functions!
db_extend('packages');
foreach ($db_changes as $change) {
if ($change[0] == 'remove_table' && isset($change[1])) {
smf_db_drop_table($change[1]);
} elseif ($change[0] == 'remove_column' && isset($change[2])) {
smf_db_remove_column($change[1], $change[2]);
} elseif ($change[0] == 'remove_index' && isset($change[2])) {
smf_db_remove_index($change[1], $change[2]);
}
}
}
// Clean house... get rid of the evidence ;).
if (file_exists($boarddir . '/Packages/temp')) {
deltree($boarddir . '/Packages/temp');
}
// Log what we just did.
logAction($context['uninstalling'] ? 'uninstall_package' : (!empty($is_upgrade) ? 'upgrade_package' : 'install_package'), array('package' => commonAPI::htmlspecialchars($packageInfo['name']), 'version' => commonAPI::htmlspecialchars($packageInfo['version'])), 'admin');
// Just in case, let's clear the whole cache to avoid anything going up the swanny.
clean_cache();
// Restore file permissions?
create_chmod_control(array(), array(), true);
}
示例9: aStreamAdd
/**
* add a stream activity
*
* @param int $id_member the member id who owns this activity (= who did it)
* @param int $atype activity type (numeric)
* @param $params array with parameters, mostly for formatting
* @param int $id_board the board id where it happened (if applicable)
* @param int $id_topic the topic id where it happened (if applicable)
* @param int $id_content the content id. this can be a message id but could also be a user id
* (e.g. when a member posts on the profile of another member). depends on the context
* @param int $id_owner the content owner (id_member)
* @param int $priv_level privacy level for is_private.
* @param int $dont_notify do not send the owner a notification for the activity.
*
* @return unique id (positive integer) of the inserted activity type, 0 if something went wrong.
*/
function aStreamAdd($id_member, $atype, $params, $id_board = 0, $id_topic = 0, $id_content = 0, $id_owner = 0, $priv_level = 0, $dont_notify = false)
{
global $user_info;
$act_must_notify = array(ACT_LIKE, ACT_REPLIED);
// these activity types will trigger a *mandatory*
if (0 == $id_member || 0 == $id_owner) {
// notification for $id_owner unless $dont_notify indicates otherwise
return 0;
}
if (0 == $atype) {
$_s = sprintf('Warning: tried to add atype==0 with id_member=%d, params=%s, id_board=%d, id_topic=%d', $id_member, @serialize($params), $id_board, $id_topic);
log_error($_s);
return 0;
}
// respect opt out setting
if (!empty($user_info['act_optout'])) {
if (in_array($atype, explode(',', $user_info['act_optout'])) !== false) {
return 0;
}
}
smf_db_insert('', '{db_prefix}log_activities', array('id_member' => 'int', 'id_type' => 'int', 'updated' => 'int', 'params' => 'string', 'is_private' => 'int', 'id_board' => 'int', 'id_topic' => 'int', 'id_content' => 'int', 'id_owner' => 'int'), array((int) $id_member, (int) $atype, time(), serialize($params), $priv_level, (int) $id_board, (int) $id_topic, (int) $id_content, (int) $id_owner), array('id_act'));
$id_act = smf_db_insert_id('{db_prefix}log_activities', 'id_act');
// if this activity triggers a notification for the id_owner, use the $id_act to link it
// to the notifications table.
if ($id_act && $id_owner && in_array($atype, $act_must_notify) && !$dont_notify) {
aStreamAddNotification($id_owner, $id_act, $atype);
}
$data = array('id_member' => $id_member, 'type' => $atype, 'params' => $params, 'board' => $id_board, 'topic' => $id_topic, 'content_id' => $id_content, 'id_owner' => $id_owner, 'plevel' => $priv_level, 'event_id' => $id_act);
HookAPI::callHook('astream_event_added', array(&$data));
return $id_act;
}
示例10: smf_openID_makeAssociation
function smf_openID_makeAssociation($server)
{
global $smcFunc, $modSettings, $p;
$parameters = array('openid.mode=associate');
// We'll need to get our keys for the Diffie-Hellman key exchange.
$dh_keys = smf_openID_setup_DH();
// If we don't support DH we'll have to see if the provider will accept no encryption.
if ($dh_keys === false) {
$parameters[] = 'openid.session_type=';
} else {
$parameters[] = 'openid.session_type=DH-SHA1';
$parameters[] = 'openid.dh_consumer_public=' . urlencode(base64_encode(long_to_binary($dh_keys['public'])));
$parameters[] = 'openid.assoc_type=HMAC-SHA1';
}
// The data to post to the server.
$post_data = implode('&', $parameters);
$data = fetch_web_data($server, $post_data);
// Parse the data given.
preg_match_all('~^([^:]+):(.+)$~m', $data, $matches);
$assoc_data = array();
foreach ($matches[1] as $key => $match) {
$assoc_data[$match] = $matches[2][$key];
}
if (!isset($assoc_data['assoc_type']) || empty($assoc_data['mac_key']) && empty($assoc_data['enc_mac_key'])) {
fatal_lang_error('openid_server_bad_response');
}
// Clean things up a bit.
$handle = isset($assoc_data['assoc_handle']) ? $assoc_data['assoc_handle'] : '';
$issued = time();
$expires = $issued + min((int) $assoc_data['expires_in'], 60);
$assoc_type = isset($assoc_data['assoc_type']) ? $assoc_data['assoc_type'] : '';
// !!! Is this really needed?
foreach (array('dh_server_public', 'enc_mac_key') as $key) {
if (isset($assoc_data[$key])) {
$assoc_data[$key] = str_replace(' ', '+', $assoc_data[$key]);
}
}
// Figure out the Diffie-Hellman secret.
if (!empty($assoc_data['enc_mac_key'])) {
$dh_secret = bcpowmod(binary_to_long(base64_decode($assoc_data['dh_server_public'])), $dh_keys['private'], $p);
$secret = base64_encode(binary_xor(sha1_raw(long_to_binary($dh_secret)), base64_decode($assoc_data['enc_mac_key'])));
} else {
$secret = $assoc_data['mac_key'];
}
// Store the data
smf_db_insert('replace', '{db_prefix}openid_assoc', array('server_url' => 'string', 'handle' => 'string', 'secret' => 'string', 'issued' => 'int', 'expires' => 'int', 'assoc_type' => 'string'), array($server, $handle, $secret, $issued, $expires, $assoc_type), array('server_url', 'handle'));
return array('server' => $server, 'handle' => $assoc_data['assoc_handle'], 'secret' => $secret, 'issued' => $issued, 'expires' => $expires, 'assoc_type' => $assoc_data['assoc_type']);
}
示例11: EditCustomProfiles
//.........这里部分代码省略.........
}
// Still not a unique colum name? Leave it up to the user, then.
if (!$unique) {
fatal_lang_error('custom_option_not_unique');
}
} else {
// Anything going to check or select is pointless keeping - as is anything coming from check!
if ($_POST['field_type'] == 'check' && $context['field']['type'] != 'check' || ($_POST['field_type'] == 'select' || $_POST['field_type'] == 'radio') && $context['field']['type'] != 'select' && $context['field']['type'] != 'radio' || $context['field']['type'] == 'check' && $_POST['field_type'] != 'check') {
smf_db_query('
DELETE FROM {db_prefix}themes
WHERE variable = {string:current_column}
AND id_member > {int:no_member}', array('no_member' => 0, 'current_column' => $context['field']['colname']));
} elseif ($_POST['field_type'] == 'select' || $_POST['field_type'] == 'radio') {
$optionChanges = array();
$takenKeys = array();
// Work out what's changed!
foreach ($context['field']['options'] as $k => $option) {
if (trim($option) == '') {
continue;
}
// Still exists?
if (in_array($option, $newOptions)) {
$takenKeys[] = $k;
continue;
}
}
// Finally - have we renamed it - or is it really gone?
foreach ($optionChanges as $k => $option) {
// Just been renamed?
if (!in_array($k, $takenKeys) && !empty($newOptions[$k])) {
smf_db_query('
UPDATE {db_prefix}themes
SET value = {string:new_value}
WHERE variable = {string:current_column}
AND value = {string:old_value}
AND id_member > {int:no_member}', array('no_member' => 0, 'new_value' => $newOptions[$k], 'current_column' => $context['field']['colname'], 'old_value' => $option));
}
}
}
//!!! Maybe we should adjust based on new text length limits?
}
// Do the insertion/updates.
if ($context['fid']) {
smf_db_query('
UPDATE {db_prefix}custom_fields
SET
field_name = {string:field_name}, field_desc = {string:field_desc},
field_type = {string:field_type}, field_length = {int:field_length},
field_options = {string:field_options}, show_reg = {int:show_reg},
show_display = {int:show_display}, show_profile = {string:show_profile},
private = {int:private}, active = {int:active}, default_value = {string:default_value},
can_search = {int:can_search}, bbc = {int:bbc}, mask = {string:mask},
enclose = {string:enclose}, placement = {int:placement}
WHERE id_field = {int:current_field}', array('field_length' => $field_length, 'show_reg' => $show_reg, 'show_display' => $show_display, 'private' => $private, 'active' => $active, 'can_search' => $can_search, 'bbc' => $bbc, 'current_field' => $context['fid'], 'field_name' => $_POST['field_name'], 'field_desc' => $_POST['field_desc'], 'field_type' => $_POST['field_type'], 'field_options' => $field_options, 'show_profile' => $show_profile, 'default_value' => $default, 'mask' => $mask, 'enclose' => $enclose, 'placement' => $placement));
// Just clean up any old selects - these are a pain!
if (($_POST['field_type'] == 'select' || $_POST['field_type'] == 'radio') && !empty($newOptions)) {
smf_db_query('
DELETE FROM {db_prefix}themes
WHERE variable = {string:current_column}
AND value NOT IN ({array_string:new_option_values})
AND id_member > {int:no_member}', array('no_member' => 0, 'new_option_values' => $newOptions, 'current_column' => $context['field']['colname']));
}
} else {
smf_db_insert('', '{db_prefix}custom_fields', array('col_name' => 'string', 'field_name' => 'string', 'field_desc' => 'string', 'field_type' => 'string', 'field_length' => 'string', 'field_options' => 'string', 'show_reg' => 'int', 'show_display' => 'int', 'show_profile' => 'string', 'private' => 'int', 'active' => 'int', 'default_value' => 'string', 'can_search' => 'int', 'bbc' => 'int', 'mask' => 'string', 'enclose' => 'string', 'placement' => 'int'), array($colname, $_POST['field_name'], $_POST['field_desc'], $_POST['field_type'], $field_length, $field_options, $show_reg, $show_display, $show_profile, $private, $active, $default, $can_search, $bbc, $mask, $enclose, $placement), array('id_field'));
}
// As there's currently no option to priorize certain fields over others, let's order them alphabetically.
smf_db_query('
ALTER TABLE {db_prefix}custom_fields
ORDER BY field_name', array('db_error_skip' => true));
} elseif (isset($_POST['delete']) && $context['field']['colname']) {
checkSession();
// Delete the user data first.
smf_db_query('
DELETE FROM {db_prefix}themes
WHERE variable = {string:current_column}
AND id_member > {int:no_member}', array('no_member' => 0, 'current_column' => $context['field']['colname']));
// Finally - the field itself is gone!
smf_db_query('
DELETE FROM {db_prefix}custom_fields
WHERE id_field = {int:current_field}', array('current_field' => $context['fid']));
}
// Rebuild display cache etc.
if (isset($_POST['delete']) || isset($_POST['save'])) {
checkSession();
$request = smf_db_query('
SELECT col_name, field_name, field_type, bbc, enclose, placement
FROM {db_prefix}custom_fields
WHERE show_display = {int:is_displayed}
AND active = {int:active}
AND private != {int:not_owner_only}
AND private != {int:not_admin_only}', array('is_displayed' => 1, 'active' => 1, 'not_owner_only' => 2, 'not_admin_only' => 3));
$fields = array();
while ($row = mysql_fetch_assoc($request)) {
$fields[] = array('colname' => strtr($row['col_name'], array('|' => '', ';' => '')), 'title' => strtr($row['field_name'], array('|' => '', ';' => '')), 'type' => $row['field_type'], 'bbc' => $row['bbc'] ? '1' : '0', 'placement' => !empty($row['placement']) ? $row['placement'] : '0', 'enclose' => !empty($row['enclose']) ? $row['enclose'] : '');
}
mysql_free_result($request);
updateSettings(array('displayFields' => serialize($fields)));
redirectexit('action=admin;area=featuresettings;sa=profile');
}
}
示例12: groupMembership2
//.........这里部分代码省略.........
}
}
mysql_free_result($request);
// Didn't find the target?
if (!$foundTarget) {
fatal_lang_error('no_access', false);
}
// Final security check, don't allow users to promote themselves to admin.
if ($context['can_manage_membergroups'] && !allowedTo('admin_forum')) {
$request = smf_db_query('
SELECT COUNT(permission)
FROM {db_prefix}permissions
WHERE id_group = {int:selected_group}
AND permission = {string:admin_forum}
AND add_deny = {int:not_denied}', array('selected_group' => $group_id, 'not_denied' => 1, 'admin_forum' => 'admin_forum'));
list($disallow) = mysql_fetch_row($request);
mysql_free_result($request);
if ($disallow) {
isAllowedTo('admin_forum');
}
}
// If we're requesting, add the note then return.
if ($changeType == 'request') {
$request = smf_db_query('
SELECT id_member
FROM {db_prefix}log_group_requests
WHERE id_member = {int:selected_member}
AND id_group = {int:selected_group}', array('selected_member' => $memID, 'selected_group' => $group_id));
if (mysql_num_rows($request) != 0) {
fatal_lang_error('profile_error_already_requested_group');
}
mysql_free_result($request);
// Log the request.
smf_db_insert('', '{db_prefix}log_group_requests', array('id_member' => 'int', 'id_group' => 'int', 'time_applied' => 'int', 'reason' => 'string-65534'), array($memID, $group_id, time(), $_POST['reason']), array('id_request'));
// Send an email to all group moderators etc.
require_once $sourcedir . '/lib/Subs-Post.php';
// Do we have any group moderators?
$request = smf_db_query('
SELECT id_member
FROM {db_prefix}group_moderators
WHERE id_group = {int:selected_group}', array('selected_group' => $group_id));
$moderators = array();
while ($row = mysql_fetch_assoc($request)) {
$moderators[] = $row['id_member'];
}
mysql_free_result($request);
// Otherwise this is the backup!
if (empty($moderators)) {
require_once $sourcedir . '/lib/Subs-Members.php';
$moderators = membersAllowedTo('manage_membergroups');
}
if (!empty($moderators)) {
$request = smf_db_query('
SELECT id_member, email_address, lngfile, member_name, mod_prefs
FROM {db_prefix}members
WHERE id_member IN ({array_int:moderator_list})
AND notify_types != {int:no_notifications}
ORDER BY lngfile', array('moderator_list' => $moderators, 'no_notifications' => 4));
while ($row = mysql_fetch_assoc($request)) {
// Check whether they are interested.
if (!empty($row['mod_prefs'])) {
list(, , $pref_binary) = explode('|', $row['mod_prefs']);
if (!($pref_binary & 4)) {
continue;
}
}
示例13: addSubscription
//.........这里部分代码省略.........
// If this has already expired but is active, extension means the period from now.
if ($endtime < time()) {
$endtime = time();
}
if ($starttime == 0) {
$starttime = time();
}
// Work out the new expiry date.
$endtime += $duration;
if ($forceEndTime != 0) {
$endtime = $forceEndTime;
}
// As everything else should be good, just update!
smf_db_query('
UPDATE {db_prefix}log_subscribed
SET end_time = {int:end_time}, start_time = {int:start_time}
WHERE id_sublog = {int:current_subscription_item}', array('end_time' => $endtime, 'start_time' => $starttime, 'current_subscription_item' => $id_sublog));
return;
}
mysql_free_result($request);
// If we're here, that means we don't have an active subscription - that means we need to do some work!
$request = smf_db_query('
SELECT m.id_group, m.additional_groups
FROM {db_prefix}members AS m
WHERE m.id_member = {int:current_member}', array('current_member' => $id_member));
// Just in case the member doesn't exist.
if (mysql_num_rows($request) == 0) {
return;
}
list($old_id_group, $additional_groups) = mysql_fetch_row($request);
mysql_free_result($request);
// Prepare additional groups.
$newAddGroups = explode(',', $curSub['add_groups']);
$curAddGroups = explode(',', $additional_groups);
$newAddGroups = array_merge($newAddGroups, $curAddGroups);
// Simple, simple, simple - hopefully... id_group first.
if ($curSub['prim_group'] != 0) {
$id_group = $curSub['prim_group'];
// Ensure their old privileges are maintained.
if ($old_id_group != 0) {
$newAddGroups[] = $old_id_group;
}
} else {
$id_group = $old_id_group;
}
// Yep, make sure it's unique, and no empties.
foreach ($newAddGroups as $k => $v) {
if (empty($v)) {
unset($newAddGroups[$k]);
}
}
$newAddGroups = array_unique($newAddGroups);
$newAddGroups = implode(',', $newAddGroups);
// Store the new settings.
smf_db_query('
UPDATE {db_prefix}members
SET id_group = {int:primary_group}, additional_groups = {string:additional_groups}
WHERE id_member = {int:current_member}', array('primary_group' => $id_group, 'current_member' => $id_member, 'additional_groups' => $newAddGroups));
// Now log the subscription - maybe we have a dorment subscription we can restore?
$request = smf_db_query('
SELECT id_sublog, end_time, start_time
FROM {db_prefix}log_subscribed
WHERE id_subscribe = {int:current_subscription}
AND id_member = {int:current_member}', array('current_subscription' => $id_subscribe, 'current_member' => $id_member));
//!!! Don't really need to do this twice...
if (mysql_num_rows($request) != 0) {
list($id_sublog, $endtime, $starttime) = mysql_fetch_row($request);
// If this has already expired but is active, extension means the period from now.
if ($endtime < time()) {
$endtime = time();
}
if ($starttime == 0) {
$starttime = time();
}
// Work out the new expiry date.
$endtime += $duration;
if ($forceEndTime != 0) {
$endtime = $forceEndTime;
}
// As everything else should be good, just update!
smf_db_query('
UPDATE {db_prefix}log_subscribed
SET start_time = {int:start_time}, end_time = {int:end_time}, old_id_group = {int:old_id_group}, status = {int:is_active},
reminder_sent = {int:no_reminder_sent}
WHERE id_sublog = {int:current_subscription_item}', array('start_time' => $starttime, 'end_time' => $endtime, 'old_id_group' => $old_id_group, 'is_active' => 1, 'no_reminder_sent' => 0, 'current_subscription_item' => $id_sublog));
return;
}
mysql_free_result($request);
// Otherwise a very simple insert.
$endtime = time() + $duration;
if ($forceEndTime != 0) {
$endtime = $forceEndTime;
}
if ($forceStartTime == 0) {
$starttime = time();
} else {
$starttime = $forceStartTime;
}
smf_db_insert('', '{db_prefix}log_subscribed', array('id_subscribe' => 'int', 'id_member' => 'int', 'old_id_group' => 'int', 'start_time' => 'int', 'end_time' => 'int', 'status' => 'int', 'pending_details' => 'string'), array($id_subscribe, $id_member, $old_id_group, $starttime, $endtime, 1, ''), array('id_sublog'));
}
示例14: SetJavaScript
function SetJavaScript()
{
global $settings, $user_info, $smcFunc, $options;
// Check the session id.
checkSession('get');
// This good-for-nothing pixel is being used to keep the session alive.
if (empty($_GET['var']) || !isset($_GET['val'])) {
redirectexit($settings['images_url'] . '/blank.gif');
}
// Sorry, guests can't go any further than this..
if ($user_info['is_guest'] || $user_info['id'] == 0) {
obExit(false);
}
$reservedVars = array('actual_theme_url', 'actual_images_url', 'base_theme_dir', 'base_theme_url', 'default_images_url', 'default_theme_dir', 'default_theme_url', 'default_template', 'images_url', 'number_recent_posts', 'smiley_sets_default', 'theme_dir', 'theme_id', 'theme_layers', 'theme_templates', 'theme_url', 'name');
// Can't change reserved vars.
if (in_array(strtolower($_GET['var']), $reservedVars)) {
redirectexit($settings['images_url'] . '/blank.gif');
}
// Use a specific theme?
if (isset($_GET['th']) || isset($_GET['id'])) {
// Invalidate the current themes cache too.
CacheAPI::putCache('theme_settings-' . $settings['theme_id'] . ':' . $user_info['id'], null, 60);
$settings['theme_id'] = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id'];
}
// If this is the admin preferences the passed value will just be an element of it.
if ($_GET['var'] == 'admin_preferences') {
$options['admin_preferences'] = !empty($options['admin_preferences']) ? unserialize($options['admin_preferences']) : array();
// New thingy...
if (isset($_GET['admin_key']) && strlen($_GET['admin_key']) < 5) {
$options['admin_preferences'][$_GET['admin_key']] = $_GET['val'];
}
// Change the value to be something nice,
$_GET['val'] = serialize($options['admin_preferences']);
}
// Update the option.
smf_db_insert('replace', '{db_prefix}themes', array('id_theme' => 'int', 'id_member' => 'int', 'variable' => 'string-255', 'value' => 'string-65534'), array($settings['theme_id'], $user_info['id'], $_GET['var'], is_array($_GET['val']) ? implode(',', $_GET['val']) : $_GET['val']), array('id_theme', 'id_member', 'variable'));
CacheAPI::putCache('theme_settings-' . $settings['theme_id'] . ':' . $user_info['id'], null, 60);
// Don't output anything...
redirectexit($settings['images_url'] . '/blank.gif');
}
示例15: ReportToModerator2
//.........这里部分代码省略.........
$context['post_errors'] = array();
foreach ($post_errors as $post_error) {
$context['post_errors'][] = $txt['error_' . $post_error];
}
return ReportToModerator();
}
// Get the basic topic information, and make sure they can see it.
$_POST['msg'] = (int) $_POST['msg'];
$request = smf_db_query('
SELECT m.id_topic, m.id_board, m.subject, m.body, m.id_member AS id_poster, m.poster_name, mem.real_name
FROM {db_prefix}messages AS m
LEFT JOIN {db_prefix}members AS mem ON (m.id_member = mem.id_member)
WHERE m.id_msg = {int:id_msg}
AND m.id_topic = {int:current_topic}
LIMIT 1', array('current_topic' => $topic, 'id_msg' => $_POST['msg']));
if (mysql_num_rows($request) == 0) {
fatal_lang_error('no_board', false);
}
$message = mysql_fetch_assoc($request);
mysql_free_result($request);
$poster_name = un_htmlspecialchars($message['real_name']) . ($message['real_name'] != $message['poster_name'] ? ' (' . $message['poster_name'] . ')' : '');
$reporterName = un_htmlspecialchars($user_info['name']) . ($user_info['name'] != $user_info['username'] && $user_info['username'] != '' ? ' (' . $user_info['username'] . ')' : '');
$subject = un_htmlspecialchars($message['subject']);
// Get a list of members with the moderate_board permission.
require_once $sourcedir . '/lib/Subs-Members.php';
$moderators = membersAllowedTo('moderate_board', $board);
$request = smf_db_query('
SELECT id_member, email_address, lngfile, mod_prefs
FROM {db_prefix}members
WHERE id_member IN ({array_int:moderator_list})
AND notify_types != {int:notify_types}
ORDER BY lngfile', array('moderator_list' => $moderators, 'notify_types' => 4));
// Check that moderators do exist!
if (mysql_num_rows($request) == 0) {
fatal_lang_error('no_mods', false);
}
// If we get here, I believe we should make a record of this, for historical significance, yabber.
if (empty($modSettings['disable_log_report'])) {
$request2 = smf_db_query('
SELECT id_report, ignore_all
FROM {db_prefix}log_reported
WHERE id_msg = {int:id_msg}
AND (closed = {int:not_closed} OR ignore_all = {int:ignored})
ORDER BY ignore_all DESC', array('id_msg' => $_POST['msg'], 'not_closed' => 0, 'ignored' => 1));
if (mysql_num_rows($request2) != 0) {
list($id_report, $ignore) = mysql_fetch_row($request2);
}
mysql_free_result($request2);
// If we're just going to ignore these, then who gives a monkeys...
if (!empty($ignore)) {
redirectexit('topic=' . $topic . '.msg' . $_POST['msg'] . '#msg' . $_POST['msg']);
}
// Already reported? My god, we could be dealing with a real rogue here...
if (!empty($id_report)) {
smf_db_query('
UPDATE {db_prefix}log_reported
SET num_reports = num_reports + 1, time_updated = {int:current_time}
WHERE id_report = {int:id_report}', array('current_time' => time(), 'id_report' => $id_report));
} else {
if (empty($message['real_name'])) {
$message['real_name'] = $message['poster_name'];
}
smf_db_insert('', '{db_prefix}log_reported', array('id_msg' => 'int', 'id_topic' => 'int', 'id_board' => 'int', 'id_member' => 'int', 'membername' => 'string', 'subject' => 'string', 'body' => 'string', 'time_started' => 'int', 'time_updated' => 'int', 'num_reports' => 'int', 'closed' => 'int'), array($_POST['msg'], $message['id_topic'], $message['id_board'], $message['id_poster'], $message['real_name'], $message['subject'], $message['body'], time(), time(), 1, 0), array('id_report'));
$id_report = smf_db_insert_id('{db_prefix}log_reported', 'id_report');
}
// Now just add our report...
if ($id_report) {
smf_db_insert('', '{db_prefix}log_reported_comments', array('id_report' => 'int', 'id_member' => 'int', 'membername' => 'string', 'email_address' => 'string', 'member_ip' => 'string', 'comment' => 'string', 'time_sent' => 'int'), array($id_report, $user_info['id'], $user_info['name'], $user_info['email'], $user_info['ip'], $poster_comment, time()), array('id_comment'));
}
}
// Find out who the real moderators are - for mod preferences.
$request2 = smf_db_query('
SELECT id_member
FROM {db_prefix}moderators
WHERE id_board = {int:current_board}', array('current_board' => $board));
$real_mods = array();
while ($row = mysql_fetch_assoc($request2)) {
$real_mods[] = $row['id_member'];
}
mysql_free_result($request2);
// Send every moderator an email.
while ($row = mysql_fetch_assoc($request)) {
// Maybe they don't want to know?!
if (!empty($row['mod_prefs'])) {
list(, , $pref_binary) = explode('|', $row['mod_prefs']);
if (!($pref_binary & 1) && (!($pref_binary & 2) || !in_array($row['id_member'], $real_mods))) {
continue;
}
}
$replacements = array('TOPICSUBJECT' => $subject, 'POSTERNAME' => $poster_name, 'REPORTERNAME' => $reporterName, 'TOPICLINK' => $scripturl . '?topic=' . $topic . '.msg' . $_POST['msg'] . '#msg' . $_POST['msg'], 'REPORTLINK' => !empty($id_report) ? $scripturl . '?action=moderate;area=reports;report=' . $id_report : '', 'COMMENT' => $_POST['comment']);
$emaildata = loadEmailTemplate('report_to_moderator', $replacements, empty($row['lngfile']) || empty($modSettings['userLanguage']) ? $language : $row['lngfile']);
// Send it to the moderator.
sendmail($row['email_address'], $emaildata['subject'], $emaildata['body'], $user_info['email'], null, false, 2);
}
mysql_free_result($request);
// Keep track of when the mod reports get updated, that way we know when we need to look again.
updateSettings(array('last_mod_report_action' => time()));
// Back to the post we reported!
redirectexit('reportsent;topic=' . $topic . '.msg' . $_POST['msg'] . '#msg' . $_POST['msg']);
}