forked from kestasjk/webDiplomacy
-
Notifications
You must be signed in to change notification settings - Fork 13
/
contactUsDirect.php
521 lines (457 loc) · 20.4 KB
/
contactUsDirect.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
<?php
/**
* @package Base
*/
// do not use this feature for vdip
die();
require_once('header.php');
require_once(l_r('gamesearch/search.php'));
require_once(l_r('pager/pagergame.php'));
require_once(l_r('objects/game.php'));
require_once(l_r('gamepanel/game.php'));
require_once(l_r('objects/mailer.php'));
require_once(l_r('gamemaster/game.php'));
global $Mailer;
$Mailer = new Mailer();
$tab = '';
global $DB;
if( !$User->type['User'] )
{
libHTML::error(l_t("This page is only for registered users."));
}
$submitted = false;
$issueType = '';
$gamesValid = false;
$games = -1;
$postedGameName = '';
$postedGameIssue = '';
$postedOtherIssue = '';
$postedAdditionalInfo = '';
$postedEmergencyIssue = '';
$subject = '';
$actualProblem = '';
// Game Search Objects
class GameResultData
{
public $gameID;
public $gameName;
public $gameOver; // enum('No','Won','Drawn')
public $processStatus; // enum('Not-processing','Processing','Crashed','Paused')
public $hasPassword; // is password set?
public $phaseMinutes;
public $anon; // yes/no
public $pressType; //enum('Regular','PublicPressOnly','NoPress','RulebookPress')
public $directorUserID;
public $processTime;
public $phase;
}
// Game Search Variables
$GamesData = array();
// Get values from posted contact requests.
if(isset($_POST['submit']))
{
libAuth::formToken_Valid();
$submitted = true;
if (isset($_POST['issueType']))
{
if ($_POST['issueType'] == 'gameIssue') { $issueType='gameIssue'; }
else if ($_POST['issueType'] == 'otherIssue') { $issueType='otherIssue'; }
else if ($_POST['issueType'] == 'emergencyIssue') { $issueType='emergencyIssue'; }
}
if ($issueType=='gameIssue')
{
$subject = 'WebDip Generated Game Support Task';
if(isset($_POST['games']))
{
$games = (int)$_POST["games"];
if ($games == 0 || $games == 1) { $gamesValid = true;}
}
if(isset($_POST['gamesIssue']))
{
if ($_POST['gamesIssue'] == 'pause')
{
$postedGameIssue='pause';
$actualProblem = 'user is requesting a pause';
}
else if ($_POST['gamesIssue'] == 'unpause')
{
$postedGameIssue='unpause';
$actualProblem = 'user is requesting an un-pause';
}
else if ($_POST['gamesIssue'] == 'cheating')
{
$postedGameIssue='cheating';
$actualProblem = 'user is requesting a cheating investigation';
}
else if ($_POST['gamesIssue'] == 'orders')
{
$postedGameIssue='orders';
$actualProblem = 'user is requesting help with orders';
}
else if ($_POST['gamesIssue'] == 'replace')
{
$postedGameIssue='replace';
$actualProblem = 'user is requesting to be replaced';
}
else if ($_POST['gamesIssue'] == 'stalemate')
{
$postedGameIssue='stalemate';
$actualProblem = 'user is requesting a stalemate investigation';
}
else if ($_POST['gamesIssue'] == 'wfo')
{
$postedGameIssue='wfo';
$actualProblem = 'user is requesting help with a wfo game';
}
else if ($_POST['gamesIssue'] == 'crash')
{
$postedGameIssue='crash';
$actualProblem = 'user is requesting help with a crashed game';
}
else if ($_POST['gamesIssue'] == 'other')
{
$postedGameIssue='other';
$actualProblem = 'user is requesting something else, check additional details';
}
}
}
else if ($issueType=='otherIssue')
{
$subject = 'WebDip Generated Other Support Task';
if(isset($_POST['otherIssue']))
{
if ($_POST['otherIssue'] == 'rules')
{
$postedOtherIssue='rules';
$actualProblem = 'user is requesting help with the rules';
}
else if ($_POST['otherIssue'] == 'otherGame')
{
$postedOtherIssue='otherGame';
$actualProblem = 'user is requesting help with a game they are not in';
}
else if ($_POST['otherIssue'] == 'finishedGame')
{
$postedOtherIssue='finishedGame';
$actualProblem = 'user is requesting help with a finished game';
}
else if ($_POST['otherIssue'] == 'bug')
{
$postedOtherIssue='bug';
$actualProblem = 'user is requesting help with a bug';
}
else if ($_POST['otherIssue'] == 'other')
{
$postedOtherIssue='other';
$actualProblem = 'user is requesting something else, check additional details';
}
}
}
else if ($issueType =='emergencyIssue')
{
$subject = 'WebDip Generated Emergency Pause';
if(isset($_POST['emergencyIssue']))
{
if ($_POST['emergencyIssue'] == 'naturalDisaster')
{
$postedEmergencyIssue='naturalDisaster';
$actualProblem = 'user paused all games for a natural disaster impacting them';
}
else if ($_POST['emergencyIssue'] == 'medical')
{
$postedEmergencyIssue='medical';
$actualProblem = 'user paused all games for a medical emergency';
}
else if ($_POST['emergencyIssue'] == 'powerOutage')
{
$postedEmergencyIssue='powerOutage';
$actualProblem = 'user paused all games due to a power outage';
}
}
}
// Use db escape to guard against special characters.
if(isset($_POST['additionalInfo']) && strlen($_POST['additionalInfo']))
{
$postedAdditionalInfo = $DB->escape($_POST['additionalInfo']);
$postedAdditionalInfo = strip_tags(html_entity_decode(trim($postedAdditionalInfo)));
}
}
// Print the header and standard php for the site that is required on every page.
libHTML::starthtml();
print libHTML::pageTitle(l_t('Contact Us'),l_t('Directly submit a support request to the moderator team.'));
?>
<?php
$sql = "SELECT g.id, g.name, g.gameOver, g.processStatus, ( CASE WHEN g.password IS NULL THEN 'False' ELSE 'True' END ) AS password,
g.phaseMinutes, g.anon, g.pressType, g.directorUserID, g.processTime, g.phase
FROM wD_Games g
inner join wD_Members m on m.gameID = g.id
WHERE g.gameOver = 'No' and g.phase <> 'Pre-Game' and m.status = 'Playing' and m.userID = ". $User->id;
$tablChecked = $DB->sql_tabl($sql);
$allGames = '';
$allRunningGames = '';
$numberOfGames = 0;
while (list($gameID, $gameName, $gameOver, $processStatus, $password, $phaseMinutes, $anon, $pressType, $directorUserID, $processTime, $phase) = $DB->tabl_row($tablChecked))
{
$myGame = new GameResultData();
$myGame->gameID = $gameID;
$myGame->gameName = $gameName;
$myGame->gameOver = $gameOver;
if ($password == 'True' ) {$myGame->password = true; } else {$myGame->password = false; };
$myGame->phaseMinutes = $phaseMinutes;
$myGame->anon = $anon;
$myGame->pressType = $pressType;
$myGame->directorUserID = $directorUserID;
$myGame->processStatus = $processStatus;
$myGame->processTime = $processTime;
$myGame->phase = $phase;
array_push($GamesData,$myGame);
$allGames = $allGames.'https://www.webdiplomacy.net/board.php?gameID='.$gameID.'<br>';
if($processStatus != 'Paused' )
{
$allRunningGames = $allRunningGames.'https://www.webdiplomacy.net/board.php?gameID='.$gameID.'<br>';
$numberOfGames = $numberOfGames+1;
}
if ($gamesValid == false && $games == $gameID)
{
$gamesValid = true;
$postedGameName = $gameName;
}
}
if ($submitted == true)
{
// validate and send email.
$email = Config::$modEMail;
$userPickedGame = 'no specific game';
if ($issueType=='gameIssue' && $postedGameIssue == 'pause') { $subject = $subject.' URGENT-Pause';}
if ($gamesValid == true && $games == 1)
{
$userPickedGame = 'all of their games';
}
else if ($gamesValid == true && $games > 1)
{
$userPickedGame = '<a href="https://www.webdiplomacy.net/board.php?gameID='.$games.'" class="contactUs"> '.$postedGameName.'</a>';
}
$worked = true;
$pausedGames = '';
if ($issueType=='emergencyIssue')
{
if ($User->qualifiesForEmergency())
{
foreach ($GamesData as $values)
{
// This is a reduced version of the toggle Pause function, altered so that it can only impact non-paused games.
if ($values->processStatus != 'Paused')
{
if($values->phase != 'Pre-game' && $values->phase != 'Finished' && $values->processStatus == 'Not-processing')
{
// Use processTime to find pauseTimeRemaining
$pauseTimeRemaining = $values->processTime - time();
$processTime=false;
$DB->sql_put(
"UPDATE wD_Games
SET processStatus = 'Paused',
pauseTimeRemaining = ".(false===$pauseTimeRemaining ? "NULL" : $pauseTimeRemaining).",
processTime = ".(false===$processTime ? "NULL" : $processTime)."
WHERE id = ".$values->gameID);
// Any votes to toggle the pause are now void
$DB->sql_put("UPDATE wD_Members SET votes = REPLACE(votes,'Pause','') WHERE gameID = ".$values->gameID);
}
}
}
// Update the users emergency pause time to now.
$User->updateEmergencyPauseDate(time());
// Add a record to the admin log just in case the email fails.
$DB->sql_put("
INSERT INTO wD_AdminLog ( name, userID, time, details, params )
VALUES ( 'Emergency Pause', ".$User->id.", ".time().", 'The following games were paused due to a player emergency ', '".$allRunningGames."' )");
try
{
$Mailer->Send(array($email=>$email), $subject.' '.$User->username,
"
This request is from <a href='https://www.webdiplomacy.net/profile.php?userID=".$User->id."' class = 'contactUs'>".$User->username."</a>,
and their registered email is: ".$User->email."<br><br>
<strong>An emergency pause was used because of ".$actualProblem."</strong>
<br><br>
All the games impacted will need a moderator to post in the global chat explaining why the game was paused. Simply say 'A user in this game
needed an emergency pause', do <strong>not</strong> give the reason.
The games that were paused as a result of this are: <br><br>".$allRunningGames. "
<br><br>
Please note that any games they are in that were already paused will NOT show up in the above list. Please check all this users games to make sure none are
about to be unpaused and then follow up with the user to see how long they need this pause for and determine if the reason was acceptable.
<br><br>
<strong>Additional Information:</strong> <br><br>
".$postedAdditionalInfo."</br></br>
");
}
catch(Exception $e)
{
print '<div class="contactUs"> Sorry, but there was a problem sending this message, contact the moderator team directly at '.Config::$modEMail;
print '<p class="contactUs">'.$e->getMessage().'</p>';
print '</div>';
$worked = false;
}
}
}
else
{
try
{
$Mailer->Send(array($email=>$email), $subject.' '.$User->username,
"
This request is from <a href='https://www.webdiplomacy.net/profile.php?userID=".$User->id."' class = 'contactUs'>".$User->username."</a>,
and their registered email is: ".$User->email."<br><br>
<strong>The user called out ".$userPickedGame. ".</strong><br><br>
The ".$actualProblem." and their games are: <br><br>".$allGames. "
<br><br>
<strong>Additional Information:</strong> <br><br>
".$postedAdditionalInfo."</br></br>
");
}
catch(Exception $e)
{
print '<div class="contactUs"> Sorry, but there was a problem sending this message, if this is an emergency contact the moderator team directly at '.Config::$modEMail;
print '<p class="contactUs">'.$e->getMessage().'</p>';
print '</div>';
$worked = false;
}
}
if ($worked == true)
{
print '<p class = "contactUs">The moderator team will get back to you shortly';
if ($gamesValid == true && $games == 1)
{
print' about all of your games';
}
else if ($gamesValid == true && $games > 1)
{
print ' about <i>'.$postedGameName.'</i>';
}
else
{
print ' about your issue';
}
print'.</br></br>
The email address the moderators will reply to you at is '.$User->email.' if that is not accurate please update
it in <a href="usercp.php" class="contactUs"> settings</a> asap!</p>';
}
print '<p class = "contactUs"> <a class="contactUs" href="contactUsDirect.php">Submit another request. </a>';
}
else
{
print '<div class = "contactUs"><p>Fill out the following form to get assistance from the moderator team. We will do our
best to get to your problem as soon as possible. </br></br>
If you have a question about how the game works, please read the <a href="faq.php" class="contactUs">FAQ</a>
and the <a href="intro.php" class="contactUs"> intro to webDiplomacy</a> before using this form. </p>
<p> Need something else? Take a look at our <a href="contactUs.php" class="contactUs">Contact Info</a>
page to learn how to contact an owner and see all the problems moderators can help with!</p>
</div>';
print '<div class = "contactUsShow">';
print '<form action="#" method="post">';
print libAuth::formTokenHTML();
print '<p><strong>What do you need to contact us about?</strong></p>
Issue with game(s) <input type="radio" value="gameIssue" onclick="javascript:gameIssueCheck();" name="issueType" id="gameIssue" required>
</br>Other issue <input type="radio" value="otherIssue" onclick="javascript:gameIssueCheck();" name="issueType" id="otherIssue">';
if ($numberOfGames > 0 && $User->qualifiesForEmergency() )
{
print '</br>Personal Emergency (Automatic Pause)
<input type="radio" value="emergencyIssue" onclick="javascript:gameIssueCheck();" name="issueType" id="emergencyIssue"><br>';
}
else
{
print '<input type="radio" value="emergencyIssue" style="display:none" name="issueType" id="emergencyIssue">';
}
print '<div id="ifGames" style="display:none">
<p>Which game(s): </br>
<select class = "contactUs" name="games">
<option selected="selected" value="0">None</option>
<option value="1">All</option>';
foreach ($GamesData as $values)
{
print '<option value="'.$values->gameID.'">'.$values->gameName.'</option>';
}
print '</select></p>';
print ' What is the problem? </br>
<select class="contactUs" name="gamesIssue">
<option value="orders" selected="selected">Issue entering orders</option>
<option value="pause">I need a Pause</option>
<option value="unpause">Game is stuck paused</option>
<option value="cheating">I think someone is cheating</option>
<option value="replace">I need a replacement</option>
<option value="stalemate">Game is stalemated</option>
<option value="wfo">Game is stuck in Wait-for-Orders</option>
<option value="crash">Game is crashed</option>
<option value="other">Other</option>
</select></p>';
print '<p class="contact-us-desc">If you asked for a pause tell us for how long and why or your request will <strong>not</strong> be granted.</font></p>';
print '</div>';
print '<div id="ifOther" style="display:none">';
print '<p> What is the problem? </br>
<select class="contactUs" name="otherIssue">
<option value="rules" selected="selected">Rules violation</option>
<option value="otherGame">Issue with game I am not in</option>
<option value="finishedGame">Issue with a finished game</option>
<option value="bug">Report bug</option>
<option value="other">Other</option>
</select></p>';
print '</div>';
print '<div id="ifEmergency" style="display:none">';
print '<p class="contact-us-desc">This is for personal emergencies only and will instantly pause all of your running games that you are not defeated in. The
moderator team will give you 7 days to let us know when you expect to be back. If we do not hear back in 7 days we will look for a replacement. <br><br>
<u>Vacations, business trips, or any other absence you know of ahead of time do not count as a personal emergency.</u>
This tool is intended for unexpected absences, such as a family emergency, widespread power outage, natural disaster, or other circumstance you cannot plan for.
If you can plan for your pause ahead of time, it is not an emergency. You should inform others in your game in advance that you will need a pause,
and if you cannot do so instead contact the moderators at ' .Config::$modEMail.'.</font></br></br>
Abuse of the emergency pause will be punished with a 50% point dock and removal of your emergency pause privilege at minimum. <br><br>
Using your emergency pause will instantly pause the following games: ';
$counter = 1;
foreach ($GamesData as $values)
{
if ($values->processStatus != 'Paused')
{
print $values->gameName;
if ($counter < $numberOfGames) print ', ';
$counter++;
}
}
print'</br></br>To prevent abuse we need to know the reason for the emergency pause. We will follow up with this request later at '.$User->email.' to find
out how long you need your games to be paused.</br></br>
<select class="contactUs" name="emergencyIssue">
<option value="medical" selected="selected">Illness or injury to yourself/family</option>
<option value="naturalDisaster">Natural Disaster</option>
<option value="powerOutage">Power Outage</option>
</select></p>';
print '</div>';
print ' <p class="contact-us-desc">Please give us any additional details below.</p>
<textarea name="additionalInfo" class = "contactUs" rows="5"></textarea>';
print '<p><input type="submit" class = "green-Submit" name="submit"/></p>';
print '</form>';
}
print '</div>';
print '</div>';
?>
<script type="text/javascript">
function gameIssueCheck()
{
if (document.getElementById('gameIssue').checked)
{
document.getElementById('ifGames').style.display = 'block';
document.getElementById('ifOther').style.display = 'none';
document.getElementById('ifEmergency').style.display = 'none';
}
else if (document.getElementById('emergencyIssue').checked)
{
document.getElementById('ifGames').style.display = 'none';
document.getElementById('ifOther').style.display = 'none';
document.getElementById('ifEmergency').style.display = 'block';
}
else
{
document.getElementById('ifGames').style.display = 'none';
document.getElementById('ifOther').style.display = 'block';
document.getElementById('ifEmergency').style.display = 'none';
}
}
</script>
<?php
libHTML::footer();
?>