本文整理汇总了PHP中removeAttachments函数的典型用法代码示例。如果您正苦于以下问题:PHP removeAttachments函数的具体用法?PHP removeAttachments怎么用?PHP removeAttachments使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了removeAttachments函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: downloadAvatar
/**
* downloads a file from a url and stores it locally for avatar use by id_member.
* - supports GIF, JPG, PNG, BMP and WBMP formats.
* - detects if GD2 is available.
* - uses resizeImageFile() to resize to max_width by max_height, and saves the result to a file.
* - updates the database info for the member's avatar.
* - returns whether the download and resize was successful.
*
* @param string $temporary_path, the full path to the temporary file
* @param int $memID, member ID
* @param int $max_width
* @param int $max_height
* @return bool, whether the download and resize was successful.
*
*/
function downloadAvatar($url, $memID, $max_width, $max_height)
{
global $modSettings, $sourcedir, $smcFunc;
$ext = !empty($modSettings['avatar_download_png']) ? 'png' : 'jpeg';
$destName = 'avatar_' . $memID . '_' . time() . '.' . $ext;
// Just making sure there is a non-zero member.
if (empty($memID)) {
return false;
}
require_once $sourcedir . '/ManageAttachments.php';
removeAttachments(array('id_member' => $memID));
$id_folder = !empty($modSettings['currentAttachmentUploadDir']) ? $modSettings['currentAttachmentUploadDir'] : 1;
$avatar_hash = empty($modSettings['custom_avatar_enabled']) ? getAttachmentFilename($destName, false, null, true) : '';
$smcFunc['db_insert']('', '{db_prefix}attachments', array('id_member' => 'int', 'attachment_type' => 'int', 'filename' => 'string-255', 'file_hash' => 'string-255', 'fileext' => 'string-8', 'size' => 'int', 'id_folder' => 'int'), array($memID, empty($modSettings['custom_avatar_enabled']) ? 0 : 1, $destName, $avatar_hash, $ext, 1, $id_folder), array('id_attach'));
$attachID = $smcFunc['db_insert_id']('{db_prefix}attachments', 'id_attach');
// Retain this globally in case the script wants it.
$modSettings['new_avatar_data'] = array('id' => $attachID, 'filename' => $destName, 'type' => empty($modSettings['custom_avatar_enabled']) ? 0 : 1);
$destName = (empty($modSettings['custom_avatar_enabled']) ? is_array($modSettings['attachmentUploadDir']) ? $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']] : $modSettings['attachmentUploadDir'] : $modSettings['custom_avatar_dir']) . '/' . $destName . '.tmp';
// Resize it.
if (!empty($modSettings['avatar_download_png'])) {
$success = resizeImageFile($url, $destName, $max_width, $max_height, 3);
} else {
$success = resizeImageFile($url, $destName, $max_width, $max_height);
}
// Remove the .tmp extension.
$destName = substr($destName, 0, -4);
if ($success) {
// Walk the right path.
if (!empty($modSettings['currentAttachmentUploadDir'])) {
if (!is_array($modSettings['attachmentUploadDir'])) {
$modSettings['attachmentUploadDir'] = unserialize($modSettings['attachmentUploadDir']);
}
$path = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']];
} else {
$path = $modSettings['attachmentUploadDir'];
}
// Remove the .tmp extension from the attachment.
if (rename($destName . '.tmp', empty($avatar_hash) ? $destName : $path . '/' . $attachID . '_' . $avatar_hash)) {
$destName = empty($avatar_hash) ? $destName : $path . '/' . $attachID . '_' . $avatar_hash;
list($width, $height) = getimagesize($destName);
$mime_type = 'image/' . $ext;
// Write filesize in the database.
$smcFunc['db_query']('', '
UPDATE {db_prefix}attachments
SET size = {int:filesize}, width = {int:width}, height = {int:height},
mime_type = {string:mime_type}
WHERE id_attach = {int:current_attachment}', array('filesize' => filesize($destName), 'width' => (int) $width, 'height' => (int) $height, 'current_attachment' => $attachID, 'mime_type' => $mime_type));
return true;
} else {
return false;
}
} else {
$smcFunc['db_query']('', '
DELETE FROM {db_prefix}attachments
WHERE id_attach = {int:current_attachment}', array('current_attachment' => $attachID));
@unlink($destName . '.tmp');
return false;
}
}
示例2: action_attachapprove
/**
* Called from a mouse click,
* works out what we want to do with attachments and actions it.
* Accessed by ?action=attachapprove
*/
public function action_attachapprove()
{
global $user_info;
// Security is our primary concern...
checkSession('get');
// If it approve or delete?
$is_approve = !isset($_GET['sa']) || $_GET['sa'] != 'reject' ? true : false;
$attachments = array();
require_once SUBSDIR . '/ManageAttachments.subs.php';
// If we are approving all ID's in a message , get the ID's.
if ($_GET['sa'] == 'all' && !empty($_GET['mid'])) {
$id_msg = (int) $_GET['mid'];
$attachments = attachmentsOfMessage($id_msg);
} elseif (!empty($_GET['aid'])) {
$attachments[] = (int) $_GET['aid'];
}
if (empty($attachments)) {
fatal_lang_error('no_access', false);
}
// @todo nb: this requires permission to approve posts, not manage attachments
// Now we have some ID's cleaned and ready to approve, but first - let's check we have permission!
$allowed_boards = !empty($user_info['mod_cache']['ap']) ? $user_info['mod_cache']['ap'] : boardsAllowedTo('approve_posts');
if ($allowed_boards == array(0)) {
$approve_query = '';
} elseif (!empty($allowed_boards)) {
$approve_query = ' AND m.id_board IN (' . implode(',', $allowed_boards) . ')';
} else {
$approve_query = ' AND 0';
}
// Validate the attachments exist and have the right approval state.
$attachments = validateAttachments($attachments, $approve_query);
// Set up a return link based off one of the attachments for this message
$attach_home = attachmentBelongsTo($attachments[0]);
$redirect = 'topic=' . $attach_home['id_topic'] . '.msg' . $attach_home['id_msg'] . '#msg' . $attach_home['id_msg'];
if (empty($attachments)) {
fatal_lang_error('no_access', false);
}
// Finally, we are there. Follow through!
if ($is_approve) {
// Checked and deemed worthy.
approveAttachments($attachments);
} else {
removeAttachments(array('id_attach' => $attachments, 'do_logging' => true));
}
// We approved or removed, either way we reset those numbers
cache_put_data('num_menu_errors', null, 900);
// Return to the topic....
redirectexit($redirect);
}
示例3: action_unapproved_attachments
/**
* View all unapproved attachments.
*/
public function action_unapproved_attachments()
{
global $txt, $scripturl, $context, $user_info, $modSettings;
$context['page_title'] = $txt['mc_unapproved_attachments'];
// Once again, permissions are king!
$approve_boards = !empty($user_info['mod_cache']['ap']) ? $user_info['mod_cache']['ap'] : boardsAllowedTo('approve_posts');
if ($approve_boards == array(0)) {
$approve_query = '';
} elseif (!empty($approve_boards)) {
$approve_query = ' AND m.id_board IN (' . implode(',', $approve_boards) . ')';
} else {
$approve_query = ' AND 0';
}
// Get together the array of things to act on, if any.
$attachments = array();
if (isset($_GET['approve'])) {
$attachments[] = (int) $_GET['approve'];
} elseif (isset($_GET['delete'])) {
$attachments[] = (int) $_GET['delete'];
} elseif (isset($_POST['item'])) {
foreach ($_POST['item'] as $item) {
$attachments[] = (int) $item;
}
}
// Are we approving or deleting?
if (isset($_GET['approve']) || isset($_POST['do']) && $_POST['do'] == 'approve') {
$curAction = 'approve';
} elseif (isset($_GET['delete']) || isset($_POST['do']) && $_POST['do'] == 'delete') {
$curAction = 'delete';
}
// Something to do, let's do it!
if (!empty($attachments) && isset($curAction)) {
checkSession('request');
// This will be handy.
require_once SUBSDIR . '/ManageAttachments.subs.php';
// Confirm the attachments are eligible for changing!
$attachments = validateAttachments($attachments, $approve_query);
// Assuming it wasn't all like, proper illegal, we can do the approving.
if (!empty($attachments)) {
if ($curAction == 'approve') {
approveAttachments($attachments);
} else {
removeAttachments(array('id_attach' => $attachments, 'do_logging' => true));
}
cache_put_data('num_menu_errors', null, 900);
}
}
require_once SUBSDIR . '/GenericList.class.php';
require_once SUBSDIR . '/ManageAttachments.subs.php';
$listOptions = array('id' => 'mc_unapproved_attach', 'width' => '100%', 'items_per_page' => $modSettings['defaultMaxMessages'], 'no_items_label' => $txt['mc_unapproved_attachments_none_found'], 'base_href' => $scripturl . '?action=moderate;area=attachmod;sa=attachments', 'default_sort_col' => 'attach_name', 'get_items' => array('function' => 'list_getUnapprovedAttachments', 'params' => array($approve_query)), 'get_count' => array('function' => 'list_getNumUnapprovedAttachments', 'params' => array($approve_query)), 'columns' => array('attach_name' => array('header' => array('value' => $txt['mc_unapproved_attach_name']), 'data' => array('db' => 'filename'), 'sort' => array('default' => 'a.filename', 'reverse' => 'a.filename DESC')), 'attach_size' => array('header' => array('value' => $txt['mc_unapproved_attach_size']), 'data' => array('db' => 'size'), 'sort' => array('default' => 'a.size', 'reverse' => 'a.size DESC')), 'attach_poster' => array('header' => array('value' => $txt['mc_unapproved_attach_poster']), 'data' => array('function' => create_function('$data', '
return $data[\'poster\'][\'link\'];')), 'sort' => array('default' => 'm.id_member', 'reverse' => 'm.id_member DESC')), 'date' => array('header' => array('value' => $txt['date'], 'style' => 'width: 18%;'), 'data' => array('db' => 'time', 'class' => 'smalltext', 'style' => 'white-space:nowrap;'), 'sort' => array('default' => 'm.poster_time', 'reverse' => 'm.poster_time DESC')), 'message' => array('header' => array('value' => $txt['post']), 'data' => array('function' => create_function('$data', '
global $modSettings;
return \'<a href="\' . $data[\'message\'][\'href\'] . \'">\' . Util::shorten_text($data[\'message\'][\'subject\'], !empty($modSettings[\'subject_length\']) ? $modSettings[\'subject_length\'] : 24) . \'</a>\';'), 'class' => 'smalltext', 'style' => 'width:15em;'), 'sort' => array('default' => 'm.subject', 'reverse' => 'm.subject DESC')), 'action' => array('header' => array('value' => '<input type="checkbox" class="input_check" onclick="invertAll(this, this.form);" />', 'style' => 'width: 4%'), 'data' => array('sprintf' => array('format' => '<input type="checkbox" name="item[]" value="%1$d" class="input_check" />', 'params' => array('id' => false))))), 'form' => array('href' => $scripturl . '?action=moderate;area=attachmod;sa=attachments', 'include_sort' => true, 'include_start' => true, 'hidden_fields' => array($context['session_var'] => $context['session_id']), 'token' => 'mod-ap'), 'additional_rows' => array(array('position' => 'bottom_of_list', 'value' => '
<select name="do" onchange="if (this.value != 0 && confirm(\'' . $txt['mc_unapproved_sure'] . '\')) submit();">
<option value="0">' . $txt['with_selected'] . ':</option>
<option value="0" disabled="disabled">' . str_repeat('—', strlen($txt['approve'])) . '</option>
<option value="approve">' . (isBrowser('ie8') ? '»' : '➤') . ' ' . $txt['approve'] . '</option>
<option value="delete">' . (isBrowser('ie8') ? '»' : '➤') . ' ' . $txt['delete'] . '</option>
</select>
<noscript><input type="submit" name="ml_go" value="' . $txt['go'] . '" class="right_submit" /></noscript>', 'class' => 'floatright')));
// Create the request list.
createToken('mod-ap');
createList($listOptions);
$context['sub_template'] = 'show_list';
$context['default_list'] = 'mc_unapproved_attach';
$context[$context['moderation_menu_name']]['tab_data'] = array('title' => $txt['mc_unapproved_attachments'], 'help' => '', 'description' => $txt['mc_unapproved_attachments_desc']);
}
示例4: deleteMembers
//.........这里部分代码省略.........
// Delete the member.
smf_db_query('
DELETE FROM {db_prefix}members
WHERE id_member IN ({array_int:users})', array('users' => $users));
// Delete the logs...
smf_db_query('
DELETE FROM {db_prefix}log_actions
WHERE id_log = {int:log_type}
AND id_member IN ({array_int:users})', array('log_type' => 2, 'users' => $users));
smf_db_query('
DELETE FROM {db_prefix}log_boards
WHERE id_member IN ({array_int:users})', array('users' => $users));
smf_db_query('
DELETE FROM {db_prefix}log_comments
WHERE id_recipient IN ({array_int:users})
AND comment_type = {string:warntpl}', array('users' => $users, 'warntpl' => 'warntpl'));
smf_db_query('
DELETE FROM {db_prefix}log_group_requests
WHERE id_member IN ({array_int:users})', array('users' => $users));
smf_db_query('
DELETE FROM {db_prefix}log_karma
WHERE id_target IN ({array_int:users})
OR id_executor IN ({array_int:users})', array('users' => $users));
smf_db_query('
DELETE FROM {db_prefix}log_mark_read
WHERE id_member IN ({array_int:users})', array('users' => $users));
smf_db_query('
DELETE FROM {db_prefix}log_notify
WHERE id_member IN ({array_int:users})', array('users' => $users));
smf_db_query('
DELETE FROM {db_prefix}log_online
WHERE id_member IN ({array_int:users})', array('users' => $users));
smf_db_query('
DELETE FROM {db_prefix}log_subscribed
WHERE id_member IN ({array_int:users})', array('users' => $users));
smf_db_query('
DELETE FROM {db_prefix}log_topics
WHERE id_member IN ({array_int:users})', array('users' => $users));
smf_db_query('
DELETE FROM {db_prefix}collapsed_categories
WHERE id_member IN ({array_int:users})', array('users' => $users));
// delete activities and corresponding notifications
smf_db_query('
DELETE a.*, n.* FROM {db_prefix}log_activities AS a LEFT JOIN {db_prefix}log_notifications AS n ON (n.id_act = a.id_act)
WHERE a.id_member IN ({array_int:users})', array('users' => $users));
// Make their votes appear as guest votes - at least it keeps the totals right.
//!!! Consider adding back in cookie protection.
smf_db_query('
UPDATE {db_prefix}log_polls
SET id_member = {int:guest_id}
WHERE id_member IN ({array_int:users})', array('guest_id' => 0, 'users' => $users));
// Delete personal messages.
require_once $sourcedir . '/PersonalMessage.php';
deleteMessages(null, null, $users);
smf_db_query('
UPDATE {db_prefix}personal_messages
SET id_member_from = {int:guest_id}
WHERE id_member_from IN ({array_int:users})', array('guest_id' => 0, 'users' => $users));
// They no longer exist, so we don't know who it was sent to.
smf_db_query('
DELETE FROM {db_prefix}pm_recipients
WHERE id_member IN ({array_int:users})', array('users' => $users));
smf_db_query('
DELETE FROM {db_prefix}drafts WHERE id_member IN ({array_int:members})', array('members' => $users));
// Delete avatar.
require_once $sourcedir . '/lib/Subs-ManageAttachments.php';
removeAttachments(array('id_member' => $users));
// It's over, no more moderation for you.
smf_db_query('
DELETE FROM {db_prefix}moderators
WHERE id_member IN ({array_int:users})', array('users' => $users));
smf_db_query('
DELETE FROM {db_prefix}group_moderators
WHERE id_member IN ({array_int:users})', array('users' => $users));
// If you don't exist we can't ban you.
smf_db_query('
DELETE FROM {db_prefix}ban_items
WHERE id_member IN ({array_int:users})', array('users' => $users));
// Remove individual theme settings.
smf_db_query('
DELETE FROM {db_prefix}themes
WHERE id_member IN ({array_int:users})', array('users' => $users));
// These users are nobody's buddy nomore.
$request = smf_db_query('
SELECT id_member, pm_ignore_list, buddy_list
FROM {db_prefix}members
WHERE FIND_IN_SET({raw:pm_ignore_list}, pm_ignore_list) != 0 OR FIND_IN_SET({raw:buddy_list}, buddy_list) != 0', array('pm_ignore_list' => implode(', pm_ignore_list) != 0 OR FIND_IN_SET(', $users), 'buddy_list' => implode(', buddy_list) != 0 OR FIND_IN_SET(', $users)));
while ($row = mysql_fetch_assoc($request)) {
smf_db_query('
UPDATE {db_prefix}members
SET
pm_ignore_list = {string:pm_ignore_list},
buddy_list = {string:buddy_list}
WHERE id_member = {int:id_member}', array('id_member' => $row['id_member'], 'pm_ignore_list' => implode(',', array_diff(explode(',', $row['pm_ignore_list']), $users)), 'buddy_list' => implode(',', array_diff(explode(',', $row['buddy_list']), $users))));
}
mysql_free_result($request);
// Make sure no member's birthday is still sticking in the calendar...
updateSettings(array('calendar_updated' => time()));
updateStats('member');
}
示例5: Post2
//.........这里部分代码省略.........
} else {
$_POST['poll_hide'] = (int) $_POST['poll_hide'];
}
$_POST['poll_change_vote'] = isset($_POST['poll_change_vote']) ? 1 : 0;
$_POST['poll_guest_vote'] = isset($_POST['poll_guest_vote']) ? 1 : 0;
// Make sure guests are actually allowed to vote generally.
if ($_POST['poll_guest_vote']) {
require_once $sourcedir . '/Subs-Members.php';
$allowedVoteGroups = groupsAllowedTo('poll_vote', $board);
if (!in_array(-1, $allowedVoteGroups['allowed'])) {
$_POST['poll_guest_vote'] = 0;
}
}
// If the user tries to set the poll too far in advance, don't let them.
if (!empty($_POST['poll_expire']) && $_POST['poll_expire'] < 1) {
fatal_lang_error('poll_range_error', false);
} elseif (empty($_POST['poll_expire']) && $_POST['poll_hide'] == 2) {
$_POST['poll_hide'] = 1;
}
// Clean up the question and answers.
$_POST['question'] = htmlspecialchars($_POST['question']);
$_POST['question'] = $smcFunc['truncate']($_POST['question'], 255);
$_POST['question'] = preg_replace('~&#(\\d{4,5}|[2-9]\\d{2,4}|1[2-9]\\d);~', '&#$1;', $_POST['question']);
$_POST['options'] = htmlspecialchars__recursive($_POST['options']);
}
// Check if they are trying to delete any current attachments....
if (isset($_REQUEST['msg'], $_POST['attach_del']) && (allowedTo('post_attachment') || $modSettings['postmod_active'] && allowedTo('post_unapproved_attachments'))) {
$del_temp = array();
foreach ($_POST['attach_del'] as $i => $dummy) {
$del_temp[$i] = (int) $dummy;
}
require_once $sourcedir . '/ManageAttachments.php';
$attachmentQuery = array('attachment_type' => 0, 'id_msg' => (int) $_REQUEST['msg'], 'not_id_attach' => $del_temp);
removeAttachments($attachmentQuery);
}
// ...or attach a new file...
if (isset($_FILES['attachment']['name']) || !empty($_SESSION['temp_attachments']) && empty($_POST['from_qr'])) {
// Verify they can post them!
if (!$modSettings['postmod_active'] || !allowedTo('post_unapproved_attachments')) {
isAllowedTo('post_attachment');
}
// Make sure we're uploading to the right place.
if (!empty($modSettings['currentAttachmentUploadDir'])) {
if (!is_array($modSettings['attachmentUploadDir'])) {
$modSettings['attachmentUploadDir'] = unserialize($modSettings['attachmentUploadDir']);
}
// The current directory, of course!
$current_attach_dir = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']];
} else {
$current_attach_dir = $modSettings['attachmentUploadDir'];
}
// If this isn't a new post, check the current attachments.
if (isset($_REQUEST['msg'])) {
$request = $smcFunc['db_query']('', '
SELECT COUNT(*), SUM(size)
FROM {db_prefix}attachments
WHERE id_msg = {int:id_msg}
AND attachment_type = {int:attachment_type}', array('id_msg' => (int) $_REQUEST['msg'], 'attachment_type' => 0));
list($quantity, $total_size) = $smcFunc['db_fetch_row']($request);
$smcFunc['db_free_result']($request);
} else {
$quantity = 0;
$total_size = 0;
}
if (!empty($_SESSION['temp_attachments'])) {
foreach ($_SESSION['temp_attachments'] as $attachID => $name) {
示例6: removeMessage
//.........这里部分代码省略.........
$topicID = empty($id_recycle_topic) ? $smcFunc['db_insert_id']('{db_prefix}topics', 'id_topic') : $id_recycle_topic;
// If the topic creation went successful, move the message.
if ($topicID > 0) {
$smcFunc['db_query']('', '
UPDATE {db_prefix}messages
SET
id_topic = {int:id_topic},
id_board = {int:recycle_board},
icon = {string:recycled},
approved = {int:is_approved}
WHERE id_msg = {int:id_msg}', array('id_topic' => $topicID, 'recycle_board' => $modSettings['recycle_board'], 'id_msg' => $message, 'recycled' => 'recycled', 'is_approved' => 1));
// Take any reported posts with us...
$smcFunc['db_query']('', '
UPDATE {db_prefix}log_reported
SET
id_topic = {int:id_topic},
id_board = {int:recycle_board}
WHERE id_msg = {int:id_msg}', array('id_topic' => $topicID, 'recycle_board' => $modSettings['recycle_board'], 'id_msg' => $message));
// Mark recycled topic as read.
if (!$user_info['is_guest']) {
$smcFunc['db_insert']('replace', '{db_prefix}log_topics', array('id_topic' => 'int', 'id_member' => 'int', 'id_msg' => 'int'), array($topicID, $user_info['id'], $modSettings['maxMsgID']), array('id_topic', 'id_member'));
}
// Mark recycle board as seen, if it was marked as seen before.
if (!empty($isRead) && !$user_info['is_guest']) {
$smcFunc['db_insert']('replace', '{db_prefix}log_boards', array('id_board' => 'int', 'id_member' => 'int', 'id_msg' => 'int'), array($modSettings['recycle_board'], $user_info['id'], $modSettings['maxMsgID']), array('id_board', 'id_member'));
}
// Add one topic and post to the recycle bin board.
$smcFunc['db_query']('', '
UPDATE {db_prefix}boards
SET
num_topics = num_topics + {int:num_topics_inc},
num_posts = num_posts + 1' . ($message > $last_board_msg ? ', id_last_msg = {int:id_merged_msg}' : '') . '
WHERE id_board = {int:recycle_board}', array('num_topics_inc' => empty($id_recycle_topic) ? 1 : 0, 'recycle_board' => $modSettings['recycle_board'], 'id_merged_msg' => $message));
// Lets increase the num_replies, and the first/last message ID as appropriate.
if (!empty($id_recycle_topic)) {
$smcFunc['db_query']('', '
UPDATE {db_prefix}topics
SET num_replies = num_replies + 1' . ($message > $last_topic_msg ? ', id_last_msg = {int:id_merged_msg}' : '') . ($message < $first_topic_msg ? ', id_first_msg = {int:id_merged_msg}' : '') . '
WHERE id_topic = {int:id_recycle_topic}', array('id_recycle_topic' => $id_recycle_topic, 'id_merged_msg' => $message));
}
// Make sure this message isn't getting deleted later on.
$recycle = true;
// Make sure we update the search subject index.
updateStats('subject', $topicID, $row['subject']);
}
// If it wasn't approved don't keep it in the queue.
if (!$row['approved']) {
$smcFunc['db_query']('', '
DELETE FROM {db_prefix}approval_queue
WHERE id_msg = {int:id_msg}
AND id_attach = {int:id_attach}', array('id_msg' => $message, 'id_attach' => 0));
}
}
$smcFunc['db_query']('', '
UPDATE {db_prefix}boards
SET ' . ($row['approved'] ? '
num_posts = CASE WHEN num_posts = {int:no_posts} THEN 0 ELSE num_posts - 1 END' : '
unapproved_posts = CASE WHEN unapproved_posts = {int:no_unapproved} THEN 0 ELSE unapproved_posts - 1 END') . '
WHERE id_board = {int:id_board}', array('no_posts' => 0, 'no_unapproved' => 0, 'id_board' => $row['id_board']));
// If the poster was registered and the board this message was on incremented
// the member's posts when it was posted, decrease his or her post count.
if (!empty($row['id_member']) && $decreasePostCount && empty($row['count_posts']) && $row['approved']) {
updateMemberData($row['id_member'], array('posts' => '-'));
}
// Only remove posts if they're not recycled.
if (!$recycle) {
// Remove the message!
$smcFunc['db_query']('', '
DELETE FROM {db_prefix}messages
WHERE id_msg = {int:id_msg}', array('id_msg' => $message));
if (!empty($modSettings['search_custom_index_config'])) {
$customIndexSettings = unserialize($modSettings['search_custom_index_config']);
$words = text2words($row['body'], $customIndexSettings['bytes_per_word'], true);
if (!empty($words)) {
$smcFunc['db_query']('', '
DELETE FROM {db_prefix}log_search_words
WHERE id_word IN ({array_int:word_list})
AND id_msg = {int:id_msg}', array('word_list' => $words, 'id_msg' => $message));
}
}
// Delete attachment(s) if they exist.
require_once $sourcedir . '/ManageAttachments.php';
$attachmentQuery = array('attachment_type' => 0, 'id_msg' => $message);
removeAttachments($attachmentQuery);
// Allow mods to remove message related data of their own (likes, maybe?)
call_integration_hook('integrate_remove_message', array($message));
}
// Update the pesky statistics.
updateStats('message');
updateStats('topic');
updateSettings(array('calendar_updated' => time()));
// And now to update the last message of each board we messed with.
require_once $sourcedir . '/Subs-Post.php';
if ($recycle) {
updateLastMessages(array($row['id_board'], $modSettings['recycle_board']));
} else {
updateLastMessages($row['id_board']);
}
return false;
}
示例7: ApproveAttach
function ApproveAttach()
{
global $smcFunc;
// Security is our primary concern...
checkSession('get');
// If it approve or delete?
$is_approve = !isset($_GET['sa']) || $_GET['sa'] != 'reject' ? true : false;
$attachments = array();
// If we are approving all ID's in a message , get the ID's.
if ($_GET['sa'] == 'all' && !empty($_GET['mid'])) {
$id_msg = (int) $_GET['mid'];
$request = $smcFunc['db_query']('', '
SELECT id_attach
FROM {db_prefix}attachments
WHERE id_msg = {int:id_msg}
AND approved = {int:is_approved}
AND attachment_type = {int:attachment_type}', array('id_msg' => $id_msg, 'is_approved' => 0, 'attachment_type' => 0));
while ($row = $smcFunc['db_fetch_assoc']($request)) {
$attachments[] = $row['id_attach'];
}
$smcFunc['db_free_result']($request);
} elseif (!empty($_GET['aid'])) {
$attachments[] = (int) $_GET['aid'];
}
if (empty($attachments)) {
fatal_lang_error('no_access', false);
}
// Now we have some ID's cleaned and ready to approve, but first - let's check we have permission!
$allowed_boards = boardsAllowedTo('approve_posts');
// Validate the attachments exist and are the right approval state.
$request = $smcFunc['db_query']('', '
SELECT a.id_attach, m.id_board, m.id_msg, m.id_topic
FROM {db_prefix}attachments AS a
INNER JOIN {db_prefix}messages AS m ON (m.id_msg = a.id_msg)
WHERE a.id_attach IN ({array_int:attachments})
AND a.attachment_type = {int:attachment_type}
AND a.approved = {int:is_approved}', array('attachments' => $attachments, 'attachment_type' => 0, 'is_approved' => 0));
$attachments = array();
while ($row = $smcFunc['db_fetch_assoc']($request)) {
// We can only add it if we can approve in this board!
if ($allowed_boards = array(0) || in_array($row['id_board'], $allowed_boards)) {
$attachments[] = $row['id_attach'];
// Also come up witht he redirection URL.
$redirect = 'topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'];
}
}
$smcFunc['db_free_result']($request);
if (empty($attachments)) {
fatal_lang_error('no_access', false);
}
// Finally, we are there. Follow through!
if ($is_approve) {
ApproveAttachments($attachments);
} else {
removeAttachments(array('id_attach' => $attachments));
}
// Return to the topic....
redirectexit($redirect);
}
示例8: makeAvatarChanges
function makeAvatarChanges($memID, &$post_errors)
{
global $modSettings, $sourcedir, $db_prefix;
if (!isset($_POST['avatar_choice']) || empty($memID)) {
return;
}
require_once $sourcedir . '/ManageAttachments.php';
$uploadDir = empty($modSettings['custom_avatar_enabled']) ? $modSettings['attachmentUploadDir'] : $modSettings['custom_avatar_dir'];
$downloadedExternalAvatar = false;
if ($_POST['avatar_choice'] == 'external' && allowedTo('profile_remote_avatar') && strtolower(substr($_POST['userpicpersonal'], 0, 7)) == 'http://' && strlen($_POST['userpicpersonal']) > 7 && !empty($modSettings['avatar_download_external'])) {
if (!is_writable($uploadDir)) {
fatal_lang_error('attachments_no_write');
}
require_once $sourcedir . '/Subs-Package.php';
$url = parse_url($_POST['userpicpersonal']);
$contents = fetch_web_data('http://' . $url['host'] . (empty($url['port']) ? '' : ':' . $url['port']) . $url['path']);
if ($contents != false && ($tmpAvatar = fopen($uploadDir . '/avatar_tmp_' . $memID, 'wb'))) {
fwrite($tmpAvatar, $contents);
fclose($tmpAvatar);
$downloadedExternalAvatar = true;
$_FILES['attachment']['tmp_name'] = $uploadDir . '/avatar_tmp_' . $memID;
}
}
if ($_POST['avatar_choice'] == 'server_stored' && allowedTo('profile_server_avatar')) {
$_POST['avatar'] = strtr(empty($_POST['file']) ? empty($_POST['cat']) ? '' : $_POST['cat'] : $_POST['file'], array('&' => '&'));
$_POST['avatar'] = preg_match('~^([\\w _!@%*=\\-#()\\[\\]&.,]+/)?[\\w _!@%*=\\-#()\\[\\]&.,]+$~', $_POST['avatar']) != 0 && preg_match('/\\.\\./', $_POST['avatar']) == 0 && file_exists($modSettings['avatar_directory'] . '/' . $_POST['avatar']) ? $_POST['avatar'] == 'blank.gif' ? '' : $_POST['avatar'] : '';
// Get rid of their old avatar. (if uploaded.)
removeAttachments('a.ID_MEMBER = ' . $memID);
} elseif ($_POST['avatar_choice'] == 'external' && allowedTo('profile_remote_avatar') && strtolower(substr($_POST['userpicpersonal'], 0, 7)) == 'http://' && empty($modSettings['avatar_download_external'])) {
// Remove any attached avatar...
removeAttachments('a.ID_MEMBER = ' . $memID);
$_POST['avatar'] = preg_replace('~action(=|%3d)(?!dlattach)~i', 'action-', $_POST['userpicpersonal']);
if ($_POST['avatar'] == 'http://' || $_POST['avatar'] == 'http:///') {
$_POST['avatar'] = '';
} elseif (substr($_POST['avatar'], 0, 7) != 'http://') {
$post_errors[] = 'bad_avatar';
} elseif (!empty($modSettings['avatar_max_height_external']) || !empty($modSettings['avatar_max_width_external'])) {
// Now let's validate the avatar.
$sizes = url_image_size($_POST['avatar']);
if (is_array($sizes) && ($sizes[0] > $modSettings['avatar_max_width_external'] && !empty($modSettings['avatar_max_width_external']) || $sizes[1] > $modSettings['avatar_max_height_external'] && !empty($modSettings['avatar_max_height_external']))) {
// Houston, we have a problem. The avatar is too large!!
if ($modSettings['avatar_action_too_large'] == 'option_refuse') {
$post_errors[] = 'bad_avatar';
} elseif ($modSettings['avatar_action_too_large'] == 'option_download_and_resize') {
require_once $sourcedir . '/Subs-Graphics.php';
if (downloadAvatar($_POST['avatar'], $memID, $modSettings['avatar_max_width_external'], $modSettings['avatar_max_height_external'])) {
$_POST['avatar'] = '';
} else {
$post_errors[] = 'bad_avatar';
}
}
}
}
} elseif ($_POST['avatar_choice'] == 'upload' && allowedTo('profile_upload_avatar') || $downloadedExternalAvatar) {
if (isset($_FILES['attachment']['name']) && $_FILES['attachment']['name'] != '' || $downloadedExternalAvatar) {
// Get the dimensions of the image.
if (!$downloadedExternalAvatar) {
if (!is_writable($uploadDir)) {
fatal_lang_error('attachments_no_write');
}
if (!move_uploaded_file($_FILES['attachment']['tmp_name'], $uploadDir . '/avatar_tmp_' . $memID)) {
fatal_lang_error('smf124');
}
$_FILES['attachment']['tmp_name'] = $uploadDir . '/avatar_tmp_' . $memID;
}
$sizes = @getimagesize($_FILES['attachment']['tmp_name']);
// No size, then it's probably not a valid pic.
if ($sizes === false) {
$post_errors[] = 'bad_avatar';
} elseif (!empty($modSettings['avatar_max_width_upload']) && $sizes[0] > $modSettings['avatar_max_width_upload'] || !empty($modSettings['avatar_max_height_upload']) && $sizes[1] > $modSettings['avatar_max_height_upload']) {
if (!empty($modSettings['avatar_resize_upload'])) {
// Attempt to chmod it.
@chmod($uploadDir . '/avatar_tmp_' . $memID, 0644);
require_once $sourcedir . '/Subs-Graphics.php';
downloadAvatar($uploadDir . '/avatar_tmp_' . $memID, $memID, $modSettings['avatar_max_width_upload'], $modSettings['avatar_max_height_upload']);
} else {
$post_errors[] = 'bad_avatar';
}
} elseif (is_array($sizes)) {
// Though not an exhaustive list, better safe than sorry.
$fp = fopen($_FILES['attachment']['tmp_name'], 'rb');
if (!$fp) {
fatal_lang_error('smf124');
}
// Now try to find an infection.
while (!feof($fp)) {
if (preg_match('~(iframe|\\<\\?php|\\<\\?[\\s=]|\\<%[\\s=]|html|eval|body|script\\W)~', fgets($fp, 4096)) === 1) {
if (file_exists($uploadDir . '/avatar_tmp_' . $memID)) {
@unlink($uploadDir . '/avatar_tmp_' . $memID);
}
fatal_lang_error('smf124');
}
}
fclose($fp);
$extensions = array('1' => '.gif', '2' => '.jpg', '3' => '.png', '6' => '.bmp');
$extension = isset($extensions[$sizes[2]]) ? $extensions[$sizes[2]] : '.bmp';
$destName = 'avatar_' . $memID . $extension;
list($width, $height) = getimagesize($_FILES['attachment']['tmp_name']);
// Remove previous attachments this member might have had.
removeAttachments('a.ID_MEMBER = ' . $memID);
//.........这里部分代码省略.........
示例9: profileSaveAvatarData
function profileSaveAvatarData(&$value)
{
global $modSettings, $sourcedir, $smcFunc, $profile_vars, $cur_profile, $context;
$memID = $context['id_member'];
if (empty($memID) && !empty($context['password_auth_failed'])) {
return false;
}
require_once $sourcedir . '/ManageAttachments.php';
// We need to know where we're going to be putting it..
if (!empty($modSettings['custom_avatar_enabled'])) {
$uploadDir = $modSettings['custom_avatar_dir'];
$id_folder = 1;
} elseif (!empty($modSettings['currentAttachmentUploadDir'])) {
if (!is_array($modSettings['attachmentUploadDir'])) {
$modSettings['attachmentUploadDir'] = unserialize($modSettings['attachmentUploadDir']);
}
// Just use the current path for temp files.
$uploadDir = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']];
$id_folder = $modSettings['currentAttachmentUploadDir'];
} else {
$uploadDir = $modSettings['attachmentUploadDir'];
$id_folder = 1;
}
$downloadedExternalAvatar = false;
if ($value == 'external' && allowedTo('profile_remote_avatar') && strtolower(substr($_POST['userpicpersonal'], 0, 7)) == 'http://' && strlen($_POST['userpicpersonal']) > 7 && !empty($modSettings['avatar_download_external'])) {
if (!is_writable($uploadDir)) {
fatal_lang_error('attachments_no_write', 'critical');
}
require_once $sourcedir . '/Subs-Package.php';
$url = parse_url($_POST['userpicpersonal']);
$contents = fetch_web_data('http://' . $url['host'] . (empty($url['port']) ? '' : ':' . $url['port']) . str_replace(' ', '%20', trim($url['path'])));
if ($contents != false && ($tmpAvatar = fopen($uploadDir . '/avatar_tmp_' . $memID, 'wb'))) {
fwrite($tmpAvatar, $contents);
fclose($tmpAvatar);
$downloadedExternalAvatar = true;
$_FILES['attachment']['tmp_name'] = $uploadDir . '/avatar_tmp_' . $memID;
}
}
if ($value == 'none') {
$profile_vars['avatar'] = '';
// Reset the attach ID.
$cur_profile['id_attach'] = 0;
$cur_profile['attachment_type'] = 0;
$cur_profile['filename'] = '';
removeAttachments(array('id_member' => $memID));
} elseif ($value == 'server_stored' && allowedTo('profile_server_avatar')) {
$profile_vars['avatar'] = strtr(empty($_POST['file']) ? empty($_POST['cat']) ? '' : $_POST['cat'] : $_POST['file'], array('&' => '&'));
$profile_vars['avatar'] = preg_match('~^([\\w _!@%*=\\-#()\\[\\]&.,]+/)?[\\w _!@%*=\\-#()\\[\\]&.,]+$~', $profile_vars['avatar']) != 0 && preg_match('/\\.\\./', $profile_vars['avatar']) == 0 && file_exists($modSettings['avatar_directory'] . '/' . $profile_vars['avatar']) ? $profile_vars['avatar'] == 'blank.gif' ? '' : $profile_vars['avatar'] : '';
// Clear current profile...
$cur_profile['id_attach'] = 0;
$cur_profile['attachment_type'] = 0;
$cur_profile['filename'] = '';
// Get rid of their old avatar. (if uploaded.)
removeAttachments(array('id_member' => $memID));
} elseif ($value == 'external' && allowedTo('profile_remote_avatar') && strtolower(substr($_POST['userpicpersonal'], 0, 7)) == 'http://' && empty($modSettings['avatar_download_external'])) {
// We need these clean...
$cur_profile['id_attach'] = 0;
$cur_profile['attachment_type'] = 0;
$cur_profile['filename'] = '';
// Remove any attached avatar...
removeAttachments(array('id_member' => $memID));
$profile_vars['avatar'] = str_replace('%20', '', preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $_POST['userpicpersonal']));
if ($profile_vars['avatar'] == 'http://' || $profile_vars['avatar'] == 'http:///') {
$profile_vars['avatar'] = '';
} elseif (substr($profile_vars['avatar'], 0, 7) != 'http://') {
return 'bad_avatar';
} elseif (!empty($modSettings['avatar_max_height_external']) || !empty($modSettings['avatar_max_width_external'])) {
// Now let's validate the avatar.
$sizes = url_image_size($profile_vars['avatar']);
if (is_array($sizes) && ($sizes[0] > $modSettings['avatar_max_width_external'] && !empty($modSettings['avatar_max_width_external']) || $sizes[1] > $modSettings['avatar_max_height_external'] && !empty($modSettings['avatar_max_height_external']))) {
// Houston, we have a problem. The avatar is too large!!
if ($modSettings['avatar_action_too_large'] == 'option_refuse') {
return 'bad_avatar';
} elseif ($modSettings['avatar_action_too_large'] == 'option_download_and_resize') {
require_once $sourcedir . '/Subs-Graphics.php';
if (downloadAvatar($profile_vars['avatar'], $memID, $modSettings['avatar_max_width_external'], $modSettings['avatar_max_height_external'])) {
$profile_vars['avatar'] = '';
$cur_profile['id_attach'] = $modSettings['new_avatar_data']['id'];
$cur_profile['filename'] = $modSettings['new_avatar_data']['filename'];
$cur_profile['attachment_type'] = $modSettings['new_avatar_data']['type'];
} else {
return 'bad_avatar';
}
}
}
}
} elseif ($value == 'upload' && allowedTo('profile_upload_avatar') || $downloadedExternalAvatar) {
if (isset($_FILES['attachment']['name']) && $_FILES['attachment']['name'] != '' || $downloadedExternalAvatar) {
// Get the dimensions of the image.
if (!$downloadedExternalAvatar) {
if (!is_writable($uploadDir)) {
fatal_lang_error('attachments_no_write', 'critical');
}
if (!move_uploaded_file($_FILES['attachment']['tmp_name'], $uploadDir . '/avatar_tmp_' . $memID)) {
fatal_lang_error('attach_timeout', 'critical');
}
$_FILES['attachment']['tmp_name'] = $uploadDir . '/avatar_tmp_' . $memID;
}
$sizes = @getimagesize($_FILES['attachment']['tmp_name']);
// No size, then it's probably not a valid pic.
//.........这里部分代码省略.........
示例10: updateAttachmentThumbnail
/**
* Update an attachment's thumbnail
*
* @package Attachments
* @param string $filename
* @param int $id_attach
* @param int $id_msg
* @param int $old_id_thumb = 0
* @return array The updated information
*/
function updateAttachmentThumbnail($filename, $id_attach, $id_msg, $old_id_thumb = 0)
{
global $modSettings;
$attachment = array('id_attach' => $id_attach);
require_once SUBSDIR . '/Graphics.subs.php';
if (createThumbnail($filename, $modSettings['attachmentThumbWidth'], $modSettings['attachmentThumbHeight'])) {
// So what folder are we putting this image in?
$id_folder_thumb = getAttachmentPathID();
// Calculate the size of the created thumbnail.
$size = @getimagesize($filename . '_thumb');
list($attachment['thumb_width'], $attachment['thumb_height']) = $size;
$thumb_size = filesize($filename . '_thumb');
// These are the only valid image types.
$validImageTypes = array(1 => 'gif', 2 => 'jpeg', 3 => 'png', 5 => 'psd', 6 => 'bmp', 7 => 'tiff', 8 => 'tiff', 9 => 'jpeg', 14 => 'iff');
// What about the extension?
$thumb_ext = isset($validImageTypes[$size[2]]) ? $validImageTypes[$size[2]] : '';
// Figure out the mime type.
if (!empty($size['mime'])) {
$thumb_mime = $size['mime'];
} else {
$thumb_mime = 'image/' . $thumb_ext;
}
$thumb_filename = $filename . '_thumb';
$thumb_hash = getAttachmentFilename($thumb_filename, 0, null, true);
$db = database();
// Add this beauty to the database.
$db->insert('', '{db_prefix}attachments', array('id_folder' => 'int', 'id_msg' => 'int', 'attachment_type' => 'int', 'filename' => 'string', 'file_hash' => 'string', 'size' => 'int', 'width' => 'int', 'height' => 'int', 'fileext' => 'string', 'mime_type' => 'string'), array($id_folder_thumb, $id_msg, 3, $thumb_filename, $thumb_hash, (int) $thumb_size, (int) $attachment['thumb_width'], (int) $attachment['thumb_height'], $thumb_ext, $thumb_mime), array('id_attach'));
$attachment['id_thumb'] = $db->insert_id('{db_prefix}attachments', 'id_attach');
if (!empty($attachment['id_thumb'])) {
$db->query('', '
UPDATE {db_prefix}attachments
SET id_thumb = {int:id_thumb}
WHERE id_attach = {int:id_attach}', array('id_thumb' => $attachment['id_thumb'], 'id_attach' => $attachment['id_attach']));
$thumb_realname = getAttachmentFilename($thumb_filename, $attachment['id_thumb'], $id_folder_thumb, false, $thumb_hash);
rename($filename . '_thumb', $thumb_realname);
// Do we need to remove an old thumbnail?
if (!empty($old_id_thumb)) {
require_once SUBSDIR . '/ManageAttachments.subs.php';
removeAttachments(array('id_attach' => $old_id_thumb), '', false, false);
}
}
}
return $attachment;
}
示例11: UnapprovedAttachments
/**
* View all unapproved attachments.
*/
function UnapprovedAttachments()
{
global $txt, $scripturl, $context, $user_info, $sourcedir, $smcFunc, $modSettings;
$context['page_title'] = $txt['mc_unapproved_attachments'];
// Once again, permissions are king!
$approve_boards = boardsAllowedTo('approve_posts');
if ($approve_boards == array(0)) {
$approve_query = '';
} elseif (!empty($approve_boards)) {
$approve_query = ' AND m.id_board IN (' . implode(',', $approve_boards) . ')';
} else {
$approve_query = ' AND 0';
}
// Get together the array of things to act on, if any.
$attachments = array();
if (isset($_GET['approve'])) {
$attachments[] = (int) $_GET['approve'];
} elseif (isset($_GET['delete'])) {
$attachments[] = (int) $_GET['delete'];
} elseif (isset($_POST['item'])) {
foreach ($_POST['item'] as $item) {
$attachments[] = (int) $item;
}
}
// Are we approving or deleting?
if (isset($_GET['approve']) || isset($_POST['do']) && $_POST['do'] == 'approve') {
$curAction = 'approve';
} elseif (isset($_GET['delete']) || isset($_POST['do']) && $_POST['do'] == 'delete') {
$curAction = 'delete';
}
// Something to do, let's do it!
if (!empty($attachments) && isset($curAction)) {
checkSession('request');
// This will be handy.
require_once $sourcedir . '/ManageAttachments.php';
// Confirm the attachments are eligible for changing!
$request = $smcFunc['db_query']('', '
SELECT a.id_attach
FROM {db_prefix}attachments AS a
INNER JOIN {db_prefix}messages AS m ON (m.id_msg = a.id_msg)
LEFT JOIN {db_prefix}boards AS b ON (m.id_board = b.id_board)
WHERE a.id_attach IN ({array_int:attachments})
AND a.approved = {int:not_approved}
AND a.attachment_type = {int:attachment_type}
AND {query_see_board}
' . $approve_query, array('attachments' => $attachments, 'not_approved' => 0, 'attachment_type' => 0));
$attachments = array();
while ($row = $smcFunc['db_fetch_assoc']($request)) {
$attachments[] = $row['id_attach'];
}
$smcFunc['db_free_result']($request);
// Assuming it wasn't all like, proper illegal, we can do the approving.
if (!empty($attachments)) {
if ($curAction == 'approve') {
ApproveAttachments($attachments);
} else {
removeAttachments(array('id_attach' => $attachments, 'do_logging' => true));
}
}
}
require_once $sourcedir . '/Subs-List.php';
$listOptions = array('id' => 'mc_unapproved_attach', 'width' => '100%', 'items_per_page' => $modSettings['defaultMaxMessages'], 'no_items_label' => $txt['mc_unapproved_attachments_none_found'], 'base_href' => $scripturl . '?action=moderate;area=attachmod;sa=attachments', 'default_sort_col' => 'attach_name', 'get_items' => array('function' => 'list_getUnapprovedAttachments', 'params' => array($approve_query)), 'get_count' => array('function' => 'list_getNumUnapprovedAttachments', 'params' => array($approve_query)), 'columns' => array('attach_name' => array('header' => array('value' => $txt['mc_unapproved_attach_name']), 'data' => array('db' => 'filename'), 'sort' => array('default' => 'a.filename', 'reverse' => 'a.filename DESC')), 'attach_size' => array('header' => array('value' => $txt['mc_unapproved_attach_size']), 'data' => array('db' => 'size'), 'sort' => array('default' => 'a.size', 'reverse' => 'a.size DESC')), 'attach_poster' => array('header' => array('value' => $txt['mc_unapproved_attach_poster']), 'data' => array('function' => create_function('$data', '
return $data[\'poster\'][\'link\'];')), 'sort' => array('default' => 'm.id_member', 'reverse' => 'm.id_member DESC')), 'date' => array('header' => array('value' => $txt['date'], 'style' => 'width: 18%;'), 'data' => array('db' => 'time', 'class' => 'smalltext', 'style' => 'white-space:nowrap;'), 'sort' => array('default' => 'm.poster_time', 'reverse' => 'm.poster_time DESC')), 'message' => array('header' => array('value' => $txt['post']), 'data' => array('function' => create_function('$data', '
return \'<a href="\' . $data[\'message\'][\'href\'] . \'">\' . shorten_subject($data[\'message\'][\'subject\'], 20) . \'</a>\';'), 'class' => 'smalltext', 'style' => 'width:15em;'), 'sort' => array('default' => 'm.subject', 'reverse' => 'm.subject DESC')), 'action' => array('header' => array('value' => '<input type="checkbox" class="input_check" onclick="invertAll(this, this.form);" checked="checked" />', 'style' => 'width: 4%;'), 'data' => array('sprintf' => array('format' => '<input type="checkbox" name="item[]" value="%1$d" checked="checked" class="input_check" />', 'params' => array('id' => false)), 'style' => 'text-align: center;'))), 'form' => array('href' => $scripturl . '?action=moderate;area=attachmod;sa=attachments', 'include_sort' => true, 'include_start' => true, 'hidden_fields' => array($context['session_var'] => $context['session_id']), 'token' => 'mod-ap'), 'additional_rows' => array(array('position' => 'bottom_of_list', 'value' => '
<select name="do" onchange="if (this.value != 0 && confirm(\'' . $txt['mc_unapproved_sure'] . '\')) submit();">
<option value="0">' . $txt['with_selected'] . ':</option>
<option value="0">-------------------</option>
<option value="approve"> -- ' . $txt['approve'] . '</option>
<option value="delete"> -- ' . $txt['delete'] . '</option>
</select>
<noscript><input type="submit" name="ml_go" value="' . $txt['go'] . '" class="button_submit" /></noscript>', 'align' => 'right')));
// Create the request list.
createToken('mod-ap');
createList($listOptions);
$context['sub_template'] = 'unapproved_attachments';
}
示例12: shd_attach_delete
function shd_attach_delete()
{
global $smcFunc, $user_info, $context, $sourcedir;
if (empty($context['ticket_id']) || empty($_GET['attach']) || (int) $_GET['attach'] == 0) {
fatal_lang_error('no_access', false);
}
$_GET['attach'] = (int) $_GET['attach'];
// Well, we have a ticket id. Let's figure out what department we're in so we can check permissions.
$query = shd_db_query('', '
SELECT hdt.id_dept, a.filename, hda.id_msg, hdt.subject
FROM {db_prefix}attachments AS a
INNER JOIN {db_prefix}helpdesk_attachments AS hda ON (hda.id_attach = a.id_attach)
INNER JOIN {db_prefix}helpdesk_tickets AS hdt ON (hda.id_ticket = hdt.id_ticket)
WHERE {query_see_ticket}
AND hda.id_ticket = {int:ticket}
AND hda.id_attach = {int:attach}
AND a.attachment_type = 0', array('attach' => $_GET['attach'], 'ticket' => $context['ticket_id']));
if ($smcFunc['db_num_rows']($query) == 0) {
$smcFunc['db_free_result']($query);
fatal_lang_error('no_access');
}
list($dept, $filename, $id_msg, $subject) = $smcFunc['db_fetch_row']($query);
$smcFunc['db_free_result']($query);
shd_is_allowed_to('shd_delete_attachment', $dept);
// So, we can delete the attachment. We already know it exists, we know we have permission.
$log_params = array('subject' => $subject, 'ticket' => $context['ticket_id'], 'msg' => $id_msg, 'att_removed' => array(htmlspecialchars($filename)));
shd_log_action('editticket', $log_params);
// Now you can delete
require_once $sourcedir . '/ManageAttachments.php';
$attachmentQuery = array('attachment_type' => 0, 'id_msg' => 0, 'id_attach' => array($_GET['attach']));
removeAttachments($attachmentQuery);
redirectexit('action=helpdesk;sa=ticket;ticket=' . $context['ticket_id']);
}
示例13: action_post2
/**
* Posts or saves the message composed with Post().
*
* requires various permissions depending on the action.
* handles attachment, post, and calendar saving.
* sends off notifications, and allows for announcements and moderation.
* accessed from ?action=post2.
*/
public function action_post2()
{
global $board, $topic, $txt, $modSettings, $context, $user_settings;
global $user_info, $board_info, $options, $ignore_temp;
// Sneaking off, are we?
if (empty($_POST) && empty($topic)) {
if (empty($_SERVER['CONTENT_LENGTH'])) {
redirectexit('action=post;board=' . $board . '.0');
} else {
fatal_lang_error('post_upload_error', false);
}
} elseif (empty($_POST) && !empty($topic)) {
redirectexit('action=post;topic=' . $topic . '.0');
}
// No need!
$context['robot_no_index'] = true;
// We are now in post2 action
$context['current_action'] = 'post2';
require_once SOURCEDIR . '/AttachmentErrorContext.class.php';
// No errors as yet.
$post_errors = Error_Context::context('post', 1);
$attach_errors = Attachment_Error_Context::context();
// If the session has timed out, let the user re-submit their form.
if (checkSession('post', '', false) != '') {
$post_errors->addError('session_timeout');
// Disable the preview so that any potentially malicious code is not executed
$_REQUEST['preview'] = false;
return $this->action_post();
}
// Wrong verification code?
if (!$user_info['is_admin'] && !$user_info['is_mod'] && !empty($modSettings['posts_require_captcha']) && ($user_info['posts'] < $modSettings['posts_require_captcha'] || $user_info['is_guest'] && $modSettings['posts_require_captcha'] == -1)) {
require_once SUBSDIR . '/VerificationControls.class.php';
$verificationOptions = array('id' => 'post');
$context['require_verification'] = create_control_verification($verificationOptions, true);
if (is_array($context['require_verification'])) {
foreach ($context['require_verification'] as $verification_error) {
$post_errors->addError($verification_error);
}
}
}
require_once SUBSDIR . '/Boards.subs.php';
require_once SUBSDIR . '/Post.subs.php';
loadLanguage('Post');
// Drafts enabled and needed?
if (!empty($modSettings['drafts_enabled']) && (isset($_POST['save_draft']) || isset($_POST['id_draft']))) {
require_once SUBSDIR . '/Drafts.subs.php';
}
// First check to see if they are trying to delete any current attachments.
if (isset($_POST['attach_del'])) {
$keep_temp = array();
$keep_ids = array();
foreach ($_POST['attach_del'] as $dummy) {
if (strpos($dummy, 'post_tmp_' . $user_info['id']) !== false) {
$keep_temp[] = $dummy;
} else {
$keep_ids[] = (int) $dummy;
}
}
if (isset($_SESSION['temp_attachments'])) {
foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) {
if (isset($_SESSION['temp_attachments']['post']['files'], $attachment['name']) && in_array($attachment['name'], $_SESSION['temp_attachments']['post']['files']) || in_array($attachID, $keep_temp) || strpos($attachID, 'post_tmp_' . $user_info['id']) === false) {
continue;
}
unset($_SESSION['temp_attachments'][$attachID]);
@unlink($attachment['tmp_name']);
}
}
if (!empty($_REQUEST['msg'])) {
require_once SUBSDIR . '/ManageAttachments.subs.php';
$attachmentQuery = array('attachment_type' => 0, 'id_msg' => (int) $_REQUEST['msg'], 'not_id_attach' => $keep_ids);
removeAttachments($attachmentQuery);
}
}
// Then try to upload any attachments.
$context['attachments']['can']['post'] = !empty($modSettings['attachmentEnable']) && $modSettings['attachmentEnable'] == 1 && (allowedTo('post_attachment') || $modSettings['postmod_active'] && allowedTo('post_unapproved_attachments'));
if ($context['attachments']['can']['post'] && empty($_POST['from_qr'])) {
require_once SUBSDIR . '/Attachments.subs.php';
if (isset($_REQUEST['msg'])) {
processAttachments((int) $_REQUEST['msg']);
} else {
processAttachments();
}
}
// Previewing? Go back to start.
if (isset($_REQUEST['preview'])) {
return $this->action_post();
}
// Prevent double submission of this form.
checkSubmitOnce('check');
// If this isn't a new topic load the topic info that we need.
if (!empty($topic)) {
require_once SUBSDIR . '/Topic.subs.php';
//.........这里部分代码省略.........
示例14: shd_attachment_remove
/**
* If we are deleting an attachment, check if we should handle this.
*
* @since 2.1
* @param array &$listOptions The listOptions of attachments page.
* @param array &$titles All the sections we have.
* @param array &$list_title List title.
*/
function shd_attachment_remove(&$filesRemoved, $attachments)
{
if (in_array($_REQUEST['type'], array('shd_attach', 'shd_thumb')) && !empty($attachments)) {
$messages = removeAttachments(array('id_attach' => $attachments), '', true);
}
}
示例15: deleteMembers
function deleteMembers($users)
{
global $db_prefix, $sourcedir, $modSettings, $ID_MEMBER;
// If it's not an array, make it so!
if (!is_array($users)) {
$users = array($users);
} else {
$users = array_unique($users);
}
// Make sure there's no void user in here.
$users = array_diff($users, array(0));
// How many are they deleting?
if (empty($users)) {
return;
} elseif (count($users) == 1) {
list($user) = $users;
$condition = '= ' . $user;
if ($user == $ID_MEMBER) {
isAllowedTo('profile_remove_own');
} else {
isAllowedTo('profile_remove_any');
}
} else {
foreach ($users as $k => $v) {
$users[$k] = (int) $v;
}
$condition = 'IN (' . implode(', ', $users) . ')';
// Deleting more than one? You can't have more than one account...
isAllowedTo('profile_remove_any');
}
// Make sure they aren't trying to delete administrators if they aren't one. But don't bother checking if it's just themself.
if (!allowedTo('admin_forum') && (count($users) != 1 || $users[0] != $ID_MEMBER)) {
$request = db_query("\n\t\t\tSELECT ID_MEMBER\n\t\t\tFROM {$db_prefix}members\n\t\t\tWHERE ID_MEMBER IN (" . implode(', ', $users) . ")\n\t\t\t\tAND (ID_GROUP = 1 OR FIND_IN_SET(1, additionalGroups) != 0)\n\t\t\tLIMIT " . count($users), __FILE__, __LINE__);
$admins = array();
while ($row = mysql_fetch_assoc($request)) {
$admins[] = $row['ID_MEMBER'];
}
mysql_free_result($request);
if (!empty($admins)) {
$users = array_diff($users, $admins);
}
}
if (empty($users)) {
return;
}
// Log the action - regardless of who is deleting it.
foreach ($users as $user) {
// Integration rocks!
if (isset($modSettings['integrate_delete_member']) && function_exists($modSettings['integrate_delete_member'])) {
call_user_func($modSettings['integrate_delete_member'], $user);
}
logAction('delete_member', array('member' => $user));
}
// Make these peoples' posts guest posts.
db_query("\n\t\tUPDATE {$db_prefix}messages\n\t\tSET ID_MEMBER = 0" . (!empty($modSettings['allow_hideEmail']) ? ", posterEmail = ''" : '') . "\n\t\tWHERE ID_MEMBER {$condition}", __FILE__, __LINE__);
db_query("\n\t\tUPDATE {$db_prefix}polls\n\t\tSET ID_MEMBER = 0\n\t\tWHERE ID_MEMBER {$condition}", __FILE__, __LINE__);
// Make these peoples' posts guest first posts and last posts.
db_query("\n\t\tUPDATE {$db_prefix}topics\n\t\tSET ID_MEMBER_STARTED = 0\n\t\tWHERE ID_MEMBER_STARTED {$condition}", __FILE__, __LINE__);
db_query("\n\t\tUPDATE {$db_prefix}topics\n\t\tSET ID_MEMBER_UPDATED = 0\n\t\tWHERE ID_MEMBER_UPDATED {$condition}", __FILE__, __LINE__);
db_query("\n\t\tUPDATE {$db_prefix}log_actions\n\t\tSET ID_MEMBER = 0\n\t\tWHERE ID_MEMBER {$condition}", __FILE__, __LINE__);
db_query("\n\t\tUPDATE {$db_prefix}log_banned\n\t\tSET ID_MEMBER = 0\n\t\tWHERE ID_MEMBER {$condition}", __FILE__, __LINE__);
db_query("\n\t\tUPDATE {$db_prefix}log_errors\n\t\tSET ID_MEMBER = 0\n\t\tWHERE ID_MEMBER {$condition}", __FILE__, __LINE__);
// Delete the member.
db_query("\n\t\tDELETE FROM {$db_prefix}members\n\t\tWHERE ID_MEMBER {$condition}\n\t\tLIMIT " . count($users), __FILE__, __LINE__);
// Delete the logs...
db_query("\n\t\tDELETE FROM {$db_prefix}log_boards\n\t\tWHERE ID_MEMBER {$condition}", __FILE__, __LINE__);
db_query("\n\t\tDELETE FROM {$db_prefix}log_karma\n\t\tWHERE ID_TARGET {$condition}\n\t\t\tOR ID_EXECUTOR {$condition}", __FILE__, __LINE__);
db_query("\n\t\tDELETE FROM {$db_prefix}log_mark_read\n\t\tWHERE ID_MEMBER {$condition}", __FILE__, __LINE__);
db_query("\n\t\tDELETE FROM {$db_prefix}log_notify\n\t\tWHERE ID_MEMBER {$condition}", __FILE__, __LINE__);
db_query("\n\t\tDELETE FROM {$db_prefix}log_online\n\t\tWHERE ID_MEMBER {$condition}", __FILE__, __LINE__);
db_query("\n\t\tDELETE FROM {$db_prefix}log_polls\n\t\tWHERE ID_MEMBER {$condition}", __FILE__, __LINE__);
db_query("\n\t\tDELETE FROM {$db_prefix}log_topics\n\t\tWHERE ID_MEMBER {$condition}", __FILE__, __LINE__);
db_query("\n\t\tDELETE FROM {$db_prefix}collapsed_categories\n\t\tWHERE ID_MEMBER {$condition}", __FILE__, __LINE__);
// Delete personal messages.
require_once $sourcedir . '/PersonalMessage.php';
deleteMessages(null, null, $users);
db_query("\n\t\tUPDATE {$db_prefix}personal_messages\n\t\tSET ID_MEMBER_FROM = 0\n\t\tWHERE ID_MEMBER_FROM {$condition}", __FILE__, __LINE__);
// Delete avatar.
require_once $sourcedir . '/ManageAttachments.php';
removeAttachments('a.ID_MEMBER ' . $condition);
// It's over, no more moderation for you.
db_query("\n\t\tDELETE FROM {$db_prefix}moderators\n\t\tWHERE ID_MEMBER {$condition}", __FILE__, __LINE__);
// If you don't exist we can't ban you.
db_query("\n\t\tDELETE FROM {$db_prefix}ban_items\n\t\tWHERE ID_MEMBER {$condition}", __FILE__, __LINE__);
// Remove individual theme settings.
db_query("\n\t\tDELETE FROM {$db_prefix}themes\n\t\tWHERE ID_MEMBER {$condition}", __FILE__, __LINE__);
// These users are nobody's buddy nomore.
$request = db_query("\n\t\tSELECT ID_MEMBER, pm_ignore_list, buddy_list\n\t\tFROM {$db_prefix}members\n\t\tWHERE FIND_IN_SET(" . implode(', pm_ignore_list) OR FIND_IN_SET(', $users) . ', pm_ignore_list) OR FIND_IN_SET(' . implode(', buddy_list) OR FIND_IN_SET(', $users) . ', buddy_list)', __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($request)) {
db_query("\n\t\t\tUPDATE {$db_prefix}members\n\t\t\tSET\n\t\t\t\tpm_ignore_list = '" . implode(',', array_diff(explode(',', $row['pm_ignore_list']), $users)) . "',\n\t\t\t\tbuddy_list = '" . implode(',', array_diff(explode(',', $row['buddy_list']), $users)) . "'\n\t\t\tWHERE ID_MEMBER = {$row['ID_MEMBER']}\n\t\t\tLIMIT 1", __FILE__, __LINE__);
}
mysql_free_result($request);
// Make sure no member's birthday is still sticking in the calendar...
updateStats('calendar');
updateStats('member');
}