1 | <?php |
---|
2 | require_once('common/includes/class.parser.php'); |
---|
3 | require_once('common/includes/class.phpmailer.php'); |
---|
4 | require_once('common/includes/class.kill.php'); |
---|
5 | |
---|
6 | $page = new Page('Post killmail'); |
---|
7 | $kb = new Killboard(KB_SITE); |
---|
8 | |
---|
9 | if (isset($_POST['killmail'])) |
---|
10 | { |
---|
11 | if ($_POST['password'] == config::get('post_password') || $page->isAdmin()) |
---|
12 | { |
---|
13 | $parser = new Parser($_POST['killmail']); |
---|
14 | |
---|
15 | // Filtering |
---|
16 | if (config::get('filter_apply')) |
---|
17 | { |
---|
18 | $filterdate = config::get('filter_date'); |
---|
19 | $year = substr($_POST['killmail'], 0, 4); |
---|
20 | $month = substr($_POST['killmail'], 5, 2); |
---|
21 | $day = substr($_POST['killmail'], 8, 2); |
---|
22 | $killstamp = mktime(0, 0, 0, $month, $day, $year); |
---|
23 | if ($killstamp < $filterdate) |
---|
24 | { |
---|
25 | $killid = -3; |
---|
26 | } |
---|
27 | else |
---|
28 | { |
---|
29 | $killid = $parser->parse(true); |
---|
30 | } |
---|
31 | } |
---|
32 | else |
---|
33 | { |
---|
34 | $killid = $parser->parse(true); |
---|
35 | } |
---|
36 | |
---|
37 | if ($killid == 0 || $killid == -1 || $killid == -2 || $killid == -3) |
---|
38 | { |
---|
39 | if ($killid == 0) |
---|
40 | { |
---|
41 | $html = "Killmail is malformed.<br/>"; |
---|
42 | if ($errors = $parser->getError()) |
---|
43 | { |
---|
44 | foreach ($errors as $error) |
---|
45 | { |
---|
46 | $html .= 'Error: '.$error[0]; |
---|
47 | if ($error[1]) |
---|
48 | { |
---|
49 | $html .= ' The text lead to this error was: "'.$error[1].'"'; |
---|
50 | } |
---|
51 | $html .= '<br/>'; |
---|
52 | } |
---|
53 | } |
---|
54 | } |
---|
55 | elseif ($killid == -1) |
---|
56 | { |
---|
57 | $html = "That killmail has already been posted <a href=\"?a=kill_detail&kll_id=".$parser->dupeid_."\">here</a>."; |
---|
58 | } |
---|
59 | elseif ($killid == -2) |
---|
60 | { |
---|
61 | $html = "You are not authorized to post this killmail."; |
---|
62 | } |
---|
63 | elseif ($killid == -3) |
---|
64 | { |
---|
65 | $filterdate = kbdate("j F Y", config::get("filter_date")); |
---|
66 | $html = "You are not allowed to post killmails older than $filterdate."; |
---|
67 | } |
---|
68 | } |
---|
69 | else |
---|
70 | { |
---|
71 | if (config::get('post_mailto') != "") |
---|
72 | { |
---|
73 | $mailer = new PHPMailer(); |
---|
74 | $kill = new Kill($killid); |
---|
75 | |
---|
76 | if (!$server = config::get('post_mailserver')) |
---|
77 | { |
---|
78 | $server = 'localhost'; |
---|
79 | } |
---|
80 | $mailer->From = "mailer@".config::get('post_mailhost'); |
---|
81 | $mailer->FromName = config::get('post_mailhost'); |
---|
82 | $mailer->Subject = "Killmail #" . $killid; |
---|
83 | $mailer->Host = $server; |
---|
84 | $mailer->Port = 25; |
---|
85 | $mailer->Helo = $server; |
---|
86 | $mailer->Mailer = "smtp"; |
---|
87 | $mailer->AddReplyTo("no_reply@".config::get('post_mailhost'), "No-Reply"); |
---|
88 | $mailer->Sender = "mailer@".config::get('post_mailhost'); |
---|
89 | $mailer->Body = $_POST['killmail']; |
---|
90 | $mailer->AddAddress(config::get('post_mailhost')); |
---|
91 | $mailer->Send(); |
---|
92 | } |
---|
93 | |
---|
94 | $qry = new DBQuery(); |
---|
95 | $qry->execute("insert into kb3_log (log_kll_id, log_site, log_ip_address, log_timestamp) values(". |
---|
96 | $killid.",'".KB_SITE."','".$_SERVER['REMOTE_ADDR']."', now())"); |
---|
97 | |
---|
98 | header("Location: ?a=kill_detail&kll_id=".$killid); |
---|
99 | exit; |
---|
100 | } |
---|
101 | } |
---|
102 | else |
---|
103 | { |
---|
104 | $html = "Invalid password."; |
---|
105 | } |
---|
106 | } |
---|
107 | elseif (!config::get('post_forbid') && !config::get('post_oog_forbid')) |
---|
108 | { |
---|
109 | $html .= "Paste the killmail from your EVEMail inbox into the box below. Make sure you post the <b>ENTIRE</b> mail.<br>Posting fake or otherwise edited mails is not allowed. All posts are logged."; |
---|
110 | $html .= "<br><br>Remember to post your losses as well.<br><br>"; |
---|
111 | $html .= "<b>Killmail:</b><br>"; |
---|
112 | $html .= "<form id=postform name=postform class=f_killmail method=post action=\"?a=post\">"; |
---|
113 | $html .= "<textarea name=killmail id=killmail class=f_killmail cols=\"70\" rows=\"24\"></textarea>"; |
---|
114 | if (!$page->isAdmin()) |
---|
115 | { |
---|
116 | $html .= "<br><br><b>Password:</b><br><input id=password name=password type=password></input>"; |
---|
117 | } |
---|
118 | $html .= " <input id=submit name=submit type=submit value=\"Process !\"></input>"; |
---|
119 | $html .= "</form>"; |
---|
120 | } |
---|
121 | else |
---|
122 | { |
---|
123 | if (config::get('post_oog_forbid')) |
---|
124 | { |
---|
125 | $html .= 'Out of game posting is disabled, please use the ingame browser.<br/>'; |
---|
126 | } |
---|
127 | else |
---|
128 | { |
---|
129 | $html .= 'Posting killmails is disabled<br/>'; |
---|
130 | } |
---|
131 | } |
---|
132 | |
---|
133 | $page->setContent($html); |
---|
134 | $page->generate(); |
---|
135 | ?> |
---|