[ Index ] |
PHP Cross Reference of MyBB |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * MyBB 1.6 4 * Copyright 2010 MyBB Group, All Rights Reserved 5 * 6 * Website: http://mybb.com 7 * License: http://mybb.com/about/license 8 * 9 * $Id$ 10 */ 11 12 define("IN_MYBB", 1); 13 define('THIS_SCRIPT', 'sendthread.php'); 14 15 $templatelist = "sendthread,forumdisplay_password_wrongpass,forumdisplay_password"; 16 17 require_once "./global.php"; 18 require_once MYBB_ROOT."inc/functions_post.php"; 19 require_once MYBB_ROOT."inc/class_parser.php"; 20 $parser = new postParser; 21 22 // Load global language phrases 23 $lang->load("sendthread"); 24 25 // Get thread info 26 $tid = intval($mybb->input['tid']); 27 $thread = get_thread($tid); 28 29 // Get thread prefix 30 $breadcrumbprefix = ''; 31 if($thread['prefix']) 32 { 33 $threadprefix = build_prefixes($thread['prefix']); 34 if(isset($threadprefix['displaystyle'])) 35 { 36 $breadcrumbprefix = $threadprefix['displaystyle'].' '; 37 } 38 } 39 40 $thread['subject'] = htmlspecialchars_uni($parser->parse_badwords($thread['subject'])); 41 42 // Invalid thread 43 if(!$thread['tid']) 44 { 45 error($lang->error_invalidthread); 46 } 47 48 // Guests cannot use this feature 49 if(!$mybb->user['uid']) 50 { 51 error_no_permission(); 52 } 53 $fid = $thread['fid']; 54 55 56 // Make navigation 57 build_forum_breadcrumb($thread['fid']); 58 add_breadcrumb($breadcrumbprefix.$thread['subject'], get_thread_link($thread['tid'])); 59 add_breadcrumb($lang->nav_sendthread); 60 61 // Get forum info 62 $forum = get_forum($thread['fid']); 63 $forumpermissions = forum_permissions($forum['fid']); 64 65 // Invalid forum? 66 if(!$forum['fid'] || $forum['type'] != "f") 67 { 68 error($lang->error_invalidforum); 69 } 70 71 // This user can't view this forum or this thread 72 if($forumpermissions['canview'] == 0 || $forumpermissions['canviewthreads'] == 0 || ($forumpermissions['canonlyviewownthreads'] != 0 && $thread['uid'] != $mybb->user['uid'])) 73 { 74 error_no_permission(); 75 } 76 77 // Check if this forum is password protected and we have a valid password 78 check_forum_password($forum['fid']); 79 80 if($mybb->usergroup['cansendemail'] == 0) 81 { 82 error_no_permission(); 83 } 84 85 // Check group limits 86 if($mybb->usergroup['maxemails'] > 0) 87 { 88 $query = $db->simple_select("maillogs", "COUNT(*) AS sent_count", "fromuid='{$mybb->user['uid']}' AND dateline >= '".(TIME_NOW - (60*60*24))."'"); 89 $sent_count = $db->fetch_field($query, "sent_count"); 90 if($sent_count >= $mybb->usergroup['maxemails']) 91 { 92 $lang->error_max_emails_day = $lang->sprintf($lang->error_max_emails_day, $mybb->usergroup['maxemails']); 93 error($lang->error_max_emails_day); 94 } 95 } 96 97 if($mybb->input['action'] == "do_sendtofriend" && $mybb->request_method == "post") 98 { 99 // Verify incoming POST request 100 verify_post_check($mybb->input['my_post_key']); 101 102 $plugins->run_hooks("sendthread_do_sendtofriend_start"); 103 104 if(!validate_email_format($mybb->input['email'])) 105 { 106 $errors[] = $lang->error_invalidemail; 107 } 108 109 if(empty($mybb->input['subject'])) 110 { 111 $errors[] = $lang->error_nosubject; 112 } 113 114 if(empty($mybb->input['message'])) 115 { 116 $errors[] = $lang->error_nomessage; 117 } 118 119 // No errors detected 120 if(count($errors) == 0) 121 { 122 if($mybb->settings['mail_handler'] == 'smtp') 123 { 124 $from = $mybb->user['email']; 125 } 126 else 127 { 128 $from = "{$mybb->user['username']} <{$mybb->user['email']}>"; 129 } 130 131 $threadlink = get_thread_link($thread['tid']); 132 133 $message = $lang->sprintf($lang->email_sendtofriend, $mybb->user['username'], $mybb->settings['bbname'], $mybb->settings['bburl']."/".$threadlink, $mybb->input['message']); 134 135 // Send the actual message 136 my_mail($mybb->input['email'], $mybb->input['subject'], $message, $from, "", "", false, "text", "", $mybb->user['email']); 137 138 if($mybb->settings['mail_logging'] > 0) 139 { 140 // Log the message 141 $log_entry = array( 142 "subject" => $db->escape_string($mybb->input['subject']), 143 "message" => $db->escape_string($message), 144 "dateline" => TIME_NOW, 145 "fromuid" => $mybb->user['uid'], 146 "fromemail" => $db->escape_string($mybb->user['email']), 147 "touid" => 0, 148 "toemail" => $db->escape_string($mybb->input['email']), 149 "tid" => $thread['tid'], 150 "ipaddress" => $db->escape_string($session->ipaddress) 151 ); 152 $db->insert_query("maillogs", $log_entry); 153 } 154 155 $plugins->run_hooks("sendthread_do_sendtofriend_end"); 156 redirect(get_thread_link($thread['tid']), $lang->redirect_emailsent); 157 } 158 else 159 { 160 $mybb->input['action'] = ''; 161 } 162 } 163 164 if(!$mybb->input['action']) 165 { 166 $plugins->run_hooks("sendthread_start"); 167 168 // Do we have some errors? 169 if(count($errors) >= 1) 170 { 171 $errors = inline_error($errors); 172 $email = htmlspecialchars_uni($mybb->input['email']); 173 $subject = htmlspecialchars_uni($mybb->input['subject']); 174 $message = htmlspecialchars_uni($mybb->input['message']); 175 } 176 else 177 { 178 $errors = ''; 179 $email = ''; 180 $subject = $lang->sprintf($lang->emailsubject_sendtofriend, $mybb->settings['bbname']); 181 $message = ''; 182 } 183 184 $plugins->run_hooks("sendthread_end"); 185 186 eval("\$sendtofriend = \"".$templates->get("sendthread")."\";"); 187 output_page($sendtofriend); 188 } 189 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Tue Oct 8 19:19:50 2013 | Cross-referenced by PHPXref 0.7.1 |