function approveAllData() { global $smcFunc, $sourcedir; // Start with messages and topics. $request = $smcFunc['db_query']('', ' SELECT id_msg FROM {db_prefix}messages WHERE approved = {int:not_approved}', array('not_approved' => 0)); $msgs = array(); while ($row = $smcFunc['db_fetch_row']($request)) { $msgs[] = $row[0]; } $smcFunc['db_free_result']($request); if (!empty($msgs)) { require_once $sourcedir . '/Subs-Post.php'; approvePosts($msgs); } // Now do attachments $request = $smcFunc['db_query']('', ' SELECT id_attach FROM {db_prefix}attachments WHERE approved = {int:not_approved}', array('not_approved' => 0)); $attaches = array(); while ($row = $smcFunc['db_fetch_row']($request)) { $attaches[] = $row[0]; } $smcFunc['db_free_result']($request); if (!empty($attaches)) { require_once $sourcedir . '/ManageAttachments.php'; ApproveAttachments($attaches); } }
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); }
function approveAllData() { global $sourcedir, $backend_subdir; // Start with messages and topics. $request = smf_db_query(' SELECT id_msg FROM {db_prefix}messages WHERE approved = {int:not_approved}', array('not_approved' => 0)); $msgs = array(); while ($row = mysql_fetch_row($request)) { $msgs[] = $row[0]; } mysql_free_result($request); if (!empty($msgs)) { require_once $sourcedir . '/lib/Subs-Post.php'; approvePosts($msgs); } // Now do attachments $request = smf_db_query(' SELECT id_attach FROM {db_prefix}attachments WHERE approved = {int:not_approved}', array('not_approved' => 0)); $attaches = array(); while ($row = mysql_fetch_row($request)) { $attaches[] = $row[0]; } mysql_free_result($request); if (!empty($attaches)) { require_once $sourcedir . '/lib/Subs-ManageAttachments.php'; ApproveAttachments($attaches); } }