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 | $page = new Page('Post killmail'); |
---|
6 | $kb = new Killboard(KB_SITE); |
---|
7 | |
---|
8 | if (isset($_POST['killmail'])) |
---|
9 | { |
---|
10 | |
---|
11 | if (($_POST['password'] == config::get('post_password') && !config::get('apiuser_killmail')) |
---|
12 | || (config::get('apiuser_killmail') && ((user::role('post_killmail')) || user::role('admin') ) ) |
---|
13 | || $page->isAdmin() |
---|
14 | ) |
---|
15 | { |
---|
16 | $parser = new Parser($_POST['killmail']); |
---|
17 | |
---|
18 | // Filtering |
---|
19 | if (config::get('filter_apply')) |
---|
20 | { |
---|
21 | $filterdate = config::get('filter_date'); |
---|
22 | $year = substr($_POST['killmail'], 0, 4); |
---|
23 | $month = substr($_POST['killmail'], 5, 2); |
---|
24 | $day = substr($_POST['killmail'], 8, 2); |
---|
25 | $killstamp = mktime(0, 0, 0, $month, $day, $year); |
---|
26 | if ($killstamp < $filterdate) |
---|
27 | { |
---|
28 | $killid = -3; |
---|
29 | } |
---|
30 | else |
---|
31 | { |
---|
32 | $killid = $parser->parse(true); |
---|
33 | } |
---|
34 | } |
---|
35 | else |
---|
36 | { |
---|
37 | $killid = $parser->parse(true); |
---|
38 | } |
---|
39 | |
---|
40 | if ($killid == 0 || $killid == -1 || $killid == -2 || $killid == -3) |
---|
41 | { |
---|
42 | if ($killid == 0) |
---|
43 | { |
---|
44 | $html = "Killmail is malformed.<br/>"; |
---|
45 | if ($errors = $parser->getError()) |
---|
46 | { |
---|
47 | foreach ($errors as $error) |
---|
48 | { |
---|
49 | $html .= 'Error: '.$error[0]; |
---|
50 | if ($error[1]) |
---|
51 | { |
---|
52 | $html .= ' The text lead to this error was: "'.$error[1].'"'; |
---|
53 | } |
---|
54 | $html .= '<br/>'; |
---|
55 | } |
---|
56 | } |
---|
57 | } |
---|
58 | elseif ($killid == -1) |
---|
59 | { |
---|
60 | $html = "That killmail has already been posted <a href=\"?a=kill_detail&kll_id=".$parser->dupeid_."\">here</a>."; |
---|
61 | } |
---|
62 | elseif ($killid == -2) |
---|
63 | { |
---|
64 | $html = "You are not authorized to post this killmail."; |
---|
65 | } |
---|
66 | elseif ($killid == -3) |
---|
67 | { |
---|
68 | $filterdate = kbdate("j F Y", config::get("filter_date")); |
---|
69 | $html = "You are not allowed to post killmails older than $filterdate."; |
---|
70 | } |
---|
71 | } |
---|
72 | else |
---|
73 | { |
---|
74 | if (config::get('post_mailto') != "") |
---|
75 | { |
---|
76 | $mailer = new PHPMailer(); |
---|
77 | $kill = new Kill($killid); |
---|
78 | |
---|
79 | if (!$server = config::get('post_mailserver')) |
---|
80 | { |
---|
81 | $server = 'localhost'; |
---|
82 | } |
---|
83 | $mailer->From = "mailer@".config::get('post_mailhost'); |
---|
84 | $mailer->FromName = config::get('post_mailhost'); |
---|
85 | $mailer->Subject = "Killmail #" . $killid; |
---|
86 | $mailer->Host = $server; |
---|
87 | $mailer->Port = 25; |
---|
88 | $mailer->Helo = $server; |
---|
89 | $mailer->Mailer = "smtp"; |
---|
90 | $mailer->AddReplyTo("no_reply@".config::get('post_mailhost'), "No-Reply"); |
---|
91 | $mailer->Sender = "mailer@".config::get('post_mailhost'); |
---|
92 | $mailer->Body = $_POST['killmail']; |
---|
93 | $mailer->AddAddress(config::get('post_mailhost')); |
---|
94 | $mailer->Send(); |
---|
95 | } |
---|
96 | |
---|
97 | $qry = new DBQuery(); |
---|
98 | $qry->execute("insert into kb3_log values(".$killid.",'".KB_SITE."','".$_SERVER['REMOTE_ADDR']."', now())"); |
---|
99 | if (config::get('apiuser_killmail') && !$page->isAdmin()) |
---|
100 | { |
---|
101 | |
---|
102 | $qry->execute("select charID from kb3_api_user where charName='".$_POST['username']."'"); |
---|
103 | $tbl=$qry->getRow(); |
---|
104 | |
---|
105 | $qry->execute("insert into kb3_kill_poster values(".$killid.",'".$tbl['charID']."')"); |
---|
106 | } |
---|
107 | |
---|
108 | header("Location: ?a=kill_detail&kll_id=".$killid); |
---|
109 | exit; |
---|
110 | } |
---|
111 | } |
---|
112 | else |
---|
113 | { |
---|
114 | $html = "Invalid password."; |
---|
115 | } |
---|
116 | |
---|
117 | } |
---|
118 | elseif (!config::get('post_forbid') && !config::get('post_oog_forbid') && (config::get('apiuser_killmail') && (user::role('post_killmail') || user::role('admin')) || !config::get('apiuser_killmail'))) |
---|
119 | { |
---|
120 | |
---|
121 | $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."; |
---|
122 | $html .= "<br><br>Remember to post your losses as well.<br><br>"; |
---|
123 | |
---|
124 | |
---|
125 | $html .= "<b>Killmail:</b><br>"; |
---|
126 | $html .= "<form id=postform name=postform class=f_killmail method=post action=\"?a=post\">"; |
---|
127 | $html .= "<textarea name=killmail id=killmail class=f_killmail cols=\"70\" rows=\"24\"></textarea>"; |
---|
128 | |
---|
129 | if (!$page->isAdmin()) |
---|
130 | { |
---|
131 | |
---|
132 | if (config::get('apiuser_killmail') && !user::loggedin()) |
---|
133 | $html .= "<i>You need to have a valid APIkey user and be ident to post killmail.<br><br></i>"; |
---|
134 | else if (!config::get('apiuser_killmail')) |
---|
135 | $html .= "<br><br><b>Password:</b><br><input id=password name=password type=password></input>"; |
---|
136 | // HACK API USER |
---|
137 | } |
---|
138 | $html .= " <input id=submit name=submit type=submit value=\"Process !\"></input>"; |
---|
139 | $html .= "</form>"; |
---|
140 | } |
---|
141 | else |
---|
142 | { |
---|
143 | if (config::get('post_oog_forbid')) |
---|
144 | { |
---|
145 | $html .= 'Out of game posting is disabled, please use the ingame browser.<br/>'; |
---|
146 | } |
---|
147 | else if (config::get('post_forbid')) |
---|
148 | { |
---|
149 | $html .= 'Posting killmails is disabled<br/>'; |
---|
150 | } |
---|
151 | else if (config::get('apiuser_killmail') && !user::role('post_killmail') && !user::role('admin') && user::loggedin()) |
---|
152 | $html .= 'You don\'t have the role \'post_killmail\' <br/>'; |
---|
153 | else |
---|
154 | |
---|
155 | $html .= 'You need to be logged to post killmail, go <a href="?a=login">Here</a><br/>'; |
---|
156 | |
---|
157 | } |
---|
158 | $page->setContent($html); |
---|
159 | $page->generate(); |
---|
160 | |
---|
161 | ?> |
---|