diff -r 5e1f1e916419 -r 98bbc533541c punbb/misc.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/punbb/misc.php Sun Apr 06 00:28:50 2008 -0400 @@ -0,0 +1,490 @@ + $_ ) +{ + $$key =& $GLOBALS[$key]; +} + +($hook = get_hook('mi_start')) ? eval($hook) : null; + +// Load the misc.php language file +require PUN_ROOT.'lang/'.$pun_user['language'].'/misc.php'; + + +$action = isset($_GET['action']) ? $_GET['action'] : null; + + +// Show the forum rules? +if ($action == 'rules') +{ + if ($pun_config['o_rules'] == '0') + message($lang_common['Bad request']); + + // Setup breadcrumbs + $pun_page['crumbs'] = array( + array($pun_config['o_board_title'], pun_link($pun_url['index'])), + $lang_common['Rules'] + ); + + ($hook = get_hook('mi_rules_pre_header_load')) ? eval($hook) : null; + + define('PUN_PAGE', 'rules'); + require PUN_ROOT.'header.php'; + +?> +
+ +

+ +
+

+
+ +
+
+ +
+
+ +
+ 'users', + 'SET' => 'last_visit='.$pun_user['logged'], + 'WHERE' => 'id='.$pun_user['id'] + ); + + ($hook = get_hook('mi_qr_update_last_visit')) ? eval($hook) : null; + $pun_db->query_build($query) or error(__FILE__, __LINE__); + + // Reset tracked topics + set_tracked_topics(null); + + pun_redirect($pun_user['prev_url'], $lang_misc['Mark read redirect']); +} + + +// Mark the topics/posts in a forum as read? +else if ($action == 'markforumread') +{ + if ($pun_user['is_guest']) + message($lang_common['No permission']); + + ($hook = get_hook('mi_markforumread_selected')) ? eval($hook) : null; + + $tracked_topics = get_tracked_topics(); + $tracked_topics['forums'][intval($_GET['fid'])] = time(); + set_tracked_topics($tracked_topics); + + pun_redirect($pun_user['prev_url'], $lang_misc['Mark forum read redirect']); +} + + +// Send form e-mail? +else if (isset($_GET['email'])) +{ + if ($pun_user['is_guest']) + message($lang_common['No permission']); + + ($hook = get_hook('mi_email_selected')) ? eval($hook) : null; + + // User pressed the cancel button + if (isset($_POST['cancel'])) + pun_redirect(htmlspecialchars($_POST['redirect_url']), $lang_common['Cancel']); + + $recipient_id = intval($_GET['email']); + if ($recipient_id < 2) + message($lang_common['Bad request']); + + $query = array( + 'SELECT' => 'u.username, u.email, u.email_setting', + 'FROM' => 'users AS u', + 'WHERE' => 'u.id='.$recipient_id + ); + + ($hook = get_hook('mi_qr_get_form_email_data')) ? eval($hook) : null; + $result = $pun_db->query_build($query) or error(__FILE__, __LINE__); + if (!$pun_db->num_rows($result)) + message($lang_common['Bad request']); + + list($recipient, $recipient_email, $email_setting) = $pun_db->fetch_row($result); + + if ($email_setting == 2 && !$pun_user['is_admmod']) + message($lang_misc['Form e-mail disabled']); + + + if (isset($_POST['form_sent'])) + { + ($hook = get_hook('mi_email_form_submitted')) ? eval($hook) : null; + + // Clean up message and subject from POST + $subject = trim($_POST['req_subject']); + $message = trim($_POST['req_message']); + + if ($subject == '') + message($lang_misc['No e-mail subject']); + else if ($message == '') + message($lang_misc['No e-mail message']); + else if (strlen($message) > 65535) + message($lang_misc['Too long e-mail message']); + + // Load the "form e-mail" template + $mail_tpl = trim(file_get_contents(PUN_ROOT.'lang/'.$pun_user['language'].'/mail_templates/form_email.tpl')); + + // The first row contains the subject + $first_crlf = strpos($mail_tpl, "\n"); + $mail_subject = trim(substr($mail_tpl, 8, $first_crlf-8)); + $mail_message = trim(substr($mail_tpl, $first_crlf)); + + $mail_subject = str_replace('', $subject, $mail_subject); + $mail_message = str_replace('', $pun_user['username'], $mail_message); + $mail_message = str_replace('', $pun_config['o_board_title'], $mail_message); + $mail_message = str_replace('', $message, $mail_message); + $mail_message = str_replace('', sprintf($lang_common['Forum mailer'], $pun_config['o_board_title']), $mail_message); + + require_once PUN_ROOT.'include/email.php'; + + pun_mail($recipient_email, $mail_subject, $mail_message, '"'.str_replace('"', '', $pun_user['username']).'" <'.$pun_user['email'].'>'); + + pun_redirect(htmlspecialchars($_POST['redirect_url']), $lang_misc['E-mail sent redirect']); + } + + // Setup form + $pun_page['set_count'] = $pun_page['fld_count'] = 0; + $pun_page['form_action'] = pun_link($pun_url['email'], $recipient_id); + + $pun_page['hidden_fields'] = array( + '', + '' + ); + if ($pun_user['is_admmod']) + $pun_page['hidden_fields'][] = ''; + + // Setup main heading + $pun_page['main_head'] = sprintf($lang_misc['Send forum e-mail'], htmlspecialchars($recipient)); + + // Setup breadcrumbs + $pun_page['crumbs'] = array( + array($pun_config['o_board_title'], pun_link($pun_url['index'])), + $lang_common['Send forum e-mail'] + ); + + ($hook = get_hook('mi_email_pre_header_load')) ? eval($hook) : null; + + define('PUN_PAGE', 'formemail'); + require PUN_ROOT.'header.php'; + +?> +
+ +

+ +
+

+
+ +
+
+

+
+
+

'.$lang_common['Required'].'') ?>

+
+
+ + +
+ +
+ +
+ +
+ +
+
+ +
+ + +
+
+
+ +
+ 't.id, t.subject, t.forum_id', + 'FROM' => 'posts AS p', + 'JOINS' => array( + array( + 'INNER JOIN' => 'topics AS t', + 'ON' => 't.id=p.topic_id' + ) + ), + 'WHERE' => 'p.id='.$post_id + ); + + ($hook = get_hook('mi_qr_get_report_topic_data')) ? eval($hook) : null; + $result = $pun_db->query_build($query) or error(__FILE__, __LINE__); + if (!$pun_db->num_rows($result)) + message($lang_common['Bad request']); + + list($topic_id, $subject, $forum_id) = $pun_db->fetch_row($result); + + ($hook = get_hook('mi_report_pre_reports_sent')) ? eval($hook) : null; + + // Should we use the internal report handling? + if ($pun_config['o_report_method'] == 0 || $pun_config['o_report_method'] == 2) + { + $query = array( + 'INSERT' => 'post_id, topic_id, forum_id, reported_by, created, message', + 'INTO' => 'reports', + 'VALUES' => $post_id.', '.$topic_id.', '.$forum_id.', '.$pun_user['id'].', '.time().', \''.$pun_db->escape($reason).'\'' + ); + + ($hook = get_hook('mi_add_report')) ? eval($hook) : null; + $pun_db->query_build($query) or error(__FILE__, __LINE__); + } + + // Should we e-mail the report? + if ($pun_config['o_report_method'] == 1 || $pun_config['o_report_method'] == 2) + { + // We send it to the complete mailing-list in one swoop + if ($pun_config['o_mailing_list'] != '') + { + $mail_subject = 'Report('.$forum_id.') - \''.$subject.'\''; + $mail_message = 'User \''.$pun_user['username'].'\' has reported the following message:'."\n".pun_link($pun_url['post'], $post_id)."\n\n".'Reason:'."\n".$reason; + + require PUN_ROOT.'include/email.php'; + + pun_mail($pun_config['o_mailing_list'], $mail_subject, $mail_message); + } + } + + pun_redirect(pun_link($pun_url['post'], $post_id), $lang_misc['Report redirect']); + } + + // Setup form + $pun_page['set_count'] = $pun_page['fld_count'] = 0; + $pun_page['form_action'] = pun_link($pun_url['report'], $post_id); + + $pun_page['hidden_fields'][] = ''; + if ($pun_user['is_admmod']) + $pun_page['hidden_fields'][] = ''; + + // Setup breadcrumbs + $pun_page['crumbs'] = array( + array($pun_config['o_board_title'], pun_link($pun_url['index'])), + $lang_misc['Report post'] + ); + + ($hook = get_hook('mi_report_pre_header_load')) ? eval($hook) : null; + + define('PUN_PAGE', 'report'); + require PUN_ROOT.'header.php'; + +?> +
+ +

+ +
+

+
+ +
+
+

'.$lang_common['Required'].'') ?>

+
+
+ + +
+ +
+ +
+
+ +
+ + +
+
+
+ +
+ '1', + 'FROM' => 'subscriptions AS s', + 'WHERE' => 'user_id='.$pun_user['id'].' AND topic_id='.$topic_id + ); + + ($hook = get_hook('mi_qr_check_subscribed')) ? eval($hook) : null; + $result = $pun_db->query_build($query) or error(__FILE__, __LINE__); + if ($pun_db->num_rows($result)) + message($lang_misc['Already subscribed']); + + $query = array( + 'INSERT' => 'user_id, topic_id', + 'INTO' => 'subscriptions', + 'VALUES' => $pun_user['id'].' ,'.$topic_id + ); + + ($hook = get_hook('mi_add_subscription')) ? eval($hook) : null; + $pun_db->query_build($query) or error(__FILE__, __LINE__); + + pun_redirect(pun_link($pun_url['topic'], $topic_id), $lang_misc['Subscribe redirect']); +} + + +// Unsubscribe from a topic? +else if (isset($_GET['unsubscribe'])) +{ + if ($pun_user['is_guest'] || $pun_config['o_subscriptions'] != '1') + message($lang_common['No permission']); + + ($hook = get_hook('mi_unsubscribe_selected')) ? eval($hook) : null; + + $topic_id = intval($_GET['unsubscribe']); + if ($topic_id < 1) + message($lang_common['Bad request']); + + $query = array( + 'SELECT' => '1', + 'FROM' => 'subscriptions AS s', + 'WHERE' => 'user_id='.$pun_user['id'].' AND topic_id='.$topic_id + ); + + ($hook = get_hook('mi_qr_check_subscribed2')) ? eval($hook) : null; + $result = $pun_db->query_build($query) or error(__FILE__, __LINE__); + if (!$pun_db->num_rows($result)) + message($lang_misc['Not subscribed']); + + $query = array( + 'DELETE' => 'subscriptions', + 'WHERE' => 'user_id='.$pun_user['id'].' AND topic_id='.$topic_id + ); + + ($hook = get_hook('mi_qr_delete_subscription')) ? eval($hook) : null; + $result = $pun_db->query_build($query) or error(__FILE__, __LINE__); + + pun_redirect(pun_link($pun_url['topic'], $topic_id), $lang_misc['Unsubscribe redirect']); +} + + +($hook = get_hook('mi_new_action')) ? eval($hook) : null; + +message($lang_common['Bad request']);