Added full source code

This commit is contained in:
Emmanuel BENOîT 2016-01-10 11:01:49 +01:00
commit 33f8586698
1377 changed files with 123808 additions and 0 deletions

View file

@ -0,0 +1,61 @@
<form action="?" method="POST">
<input type="hidden" name="c" value="a" />
<h2>Select an account</h2>
<p>
Name of the account to manage:
<input type="text" name="an" value="<?=utf8entities($data['account'])?>" size="17" maxlength="16" />
<input name="sa" value="Select account" type="submit" />
<?php
if ($data['notfound']) {
print "<br/><span style='color:red; font-weight: bold'>Account not found.</span>";
} elseif ($data['admin']) {
?>
<br/><span style='color:red; font-weight: bold'>Administrative account, no changes allowed.</span>
<?php
} elseif ($data['account'] != '') {
?>
</p>
<h2>Manage account</h2>
<p>
Account status: <b><?=$data['status']?></b>
</p>
<p>
Account email address:
<input type="text" name="ma" value="<?=utf8entities($data['email'])?>" size="32" maxlength="128" />
<input type="submit" name="mma" value="Change mail address" />
<?
switch ($data['mailerr']) :
case -1: print "<br/><span style='color:green; font-weight: bold'>Address changed</span>"; break;
case 1: print "<br/><span style='color:red; font-weight: bold'>Invalid address</span>"; break;
case 2: print "<br/><span style='color:red; font-weight: bold'>Address already used by account "
. utf8entities($data['oacc']) . "</span>"; break;
case 3: print "<br/><span style='color:red; font-weight: bold'>Database error</span>"; break;
endswitch;
?>
</p>
<p>
Account password:
<input type="text" name="pw" value="<?=utf8entities($data['password'])?>" size="32" maxlength="64" />
<input type="submit" name="mpw" value="Change password" />
<?
switch ($data['passerr']) :
case -1: print "<br/><span style='color:green; font-weight: bold'>Password updated</span>"; break;
case 1: print "<br/><span style='color:red; font-weight: bold'>Password too short (min 4 characters)</span>"; break;
case 2: print "<br/><span style='color:red; font-weight: bold'>Database error</span>"; break;
endswitch;
}
?>
</p>
<?php
if (!is_null($data['conf_code'])) {
?>
<p>
Confirmation code: <i><?=$data['conf_code']?></i>
</p>
<?php
}
?>
</form>

View file

@ -0,0 +1,87 @@
<h2>Pending kick requests</h2>
<table class="list">
<tr>
<th style="text-align:left;width:15%">Account name</th>
<th style="text-align:left;width:15%">Requested by</th>
<th style="text-align:left;width:15%">Date</th>
<th style="text-align:left">Reason</th>
<th style="text-align:left;width:15%">Actions</th>
</tr>
<?php
if (empty($data['lists'][0])) {
echo "<tr><td colspan='5' style='text-align:center'>No pending kick requests</td></tr>";
} else {
foreach ($data['lists'][0] as $r) {
$pn = handler::$h->accounts->call('getUser', $r['to_kick']);
$an = handler::$h->accounts->call('getUser', $r['requested_by']);
echo "<tr><td>" . utf8entities($pn['name']) . "</td><td>" . utf8entities($an['name'])
. "</td><td>" . gmstrftime("%Y-%m-%d %H:%M:%S", $r['requested_at'])
. "</td><td>" . utf8entities($r['reason']) . "</td><td>";
if ($r['requested_by'] == $_SESSION['userid']) {
echo "<a href='?c=kl&i={$r['id']}&a=0'>Cancel</a>";
} else {
echo "<a href='?c=kl&i={$r['id']}&a=0'>Reject</a> - <a href='?c=kl&i={$r['id']}&a=1'>Kick player</a>";
}
echo "</td></tr>\n";
}
}
?>
</table>
<h2>Accepted kick requests</h2>
<table class="list">
<tr>
<th style="text-align:left;width:15%">Account name</th>
<th style="text-align:left;width:15%">Requested by</th>
<th style="text-align:left;width:15%">Date</th>
<th style="text-align:left">Reason</th>
<th style="text-align:left;width:15%">Validated by</th>
</tr>
<?php
if (empty($data['lists'][1])) {
echo "<tr><td colspan='5' style='text-align:center'>No accepted kick requests</td></tr>";
} else {
foreach ($data['lists'][1] as $r) {
$pn = handler::$h->accounts->call('getUser', $r['to_kick']);
$an = handler::$h->accounts->call('getUser', $r['requested_by']);
$vn = handler::$h->accounts->call('getUser', $r['examined_by']);
echo "<tr><td>" . utf8entities($pn['name']) . "</td><td>" . utf8entities($an['name'])
. "</td><td>" . gmstrftime("%Y-%m-%d %H:%M:%S", $r['requested_at'])
. "</td><td>" . utf8entities($r['reason']) . "</td><td>"
. utf8entities($vn['name']) . "</td></tr>\n";
}
}
?>
</table>
<h2>Rejected kick requests</h2>
<table class="list">
<tr>
<th style="text-align:left;width:15%">Account name</th>
<th style="text-align:left;width:15%">Requested by</th>
<th style="text-align:left;width:15%">Date</th>
<th style="text-align:left">Reason</th>
<th style="text-align:left;width:15%">Rejected by</th>
</tr>
<?php
if (empty($data['lists'][2])) {
echo "<tr><td colspan='5' style='text-align:center'>No rejected requests</td></tr>";
} else {
foreach ($data['lists'][2] as $r) {
$pn = handler::$h->accounts->call('getUser', $r['to_kick']);
$an = handler::$h->accounts->call('getUser', $r['requested_by']);
$vn = handler::$h->accounts->call('getUser', $r['examined_by']);
echo "<tr><td>" . utf8entities($pn['name']) . "</td><td>" . utf8entities($an['name'])
. "</td><td>" . gmstrftime("%Y-%m-%d %H:%M:%S", $r['requested_at'])
. "</td><td>" . utf8entities($r['reason']) . "</td><td>"
. utf8entities($vn['name']) . "</td></tr>\n";
}
}
?>
</table>

View file

@ -0,0 +1,49 @@
<h2>Request a kick</h2>
<p>
Please indicate the name of the player to be kicked as well as the reason why the player should be kicked in the form below.<br/>
The player will only be kicked after another administrator confirms it.
</p>
<?php
if ($data['error'] != 0) {
echo "<p style='font-weight:bold;color:red'>";
switch($data['error']) :
case 1:
echo "Account not found.";
break;
case 2:
echo "Please specify a reason (&gt;10 characters).";
break;
case 3:
echo "This player is already on the list of pending kicks.";
break;
default:
echo "Unknown error.";
break;
endswitch;
echo "</p>";
}
?>
<form method="POST" action="?">
<input type="hidden" name="c" value="k" />
<input type="hidden" name="kr" value="1" />
<table>
<tr>
<th style="text-align:left;width:200px;padding:0px 0px 0px 40px">Player to kick:</th>
<td><input style="width:50%" maxlength="15" type="text" name="p" value="<?=preg_replace('/"/', '&quot;', $data['name'])?>" /></td>
</tr>
<tr>
<th style="text-align:left;padding:0px 0px 0px 40px">Reason:</th>
<td><textarea style="width:50%" name="r"><?=utf8entities($data['reason'])?></textarea></td>
</tr>
<tr><td colspan="2">&nbsp;</td></tr>
<tr>
<td>&nbsp;</td>
<td>
<input style="font-weight:bold;border-color:white;border-style:solid;border-width:1px;color:white;background-color:red" type="submit" value="Request kick" />
<input style="border-color:white;border-style:solid;border-width:1px;color:white;background-color:green" type="submit" name="cancel" value="Cancel" />
</td>
</tr>
</table>
</form>

View file

@ -0,0 +1,47 @@
<h2><?=$data['id'] ? "Edit" : "Add"?> category</h2>
<form action="?" method="POST">
<input type="hidden" name="c" value="lk" />
<input type="hidden" name="ac" value="<?=$data['id'] ? 2 : 0?>" />
<input type="hidden" name="r" value="1" />
<?php
if ($data['id']) {
?>
<input type="hidden" name="cid" value="<?=$data['id']?>" />
<?php
}
?>
<table style="width:80%;padding:0px 0px 0px 30px">
<tr>
<td style="font-weight:bold;padding:0px 10px 0px 0px">Name:</td>
<td><input type="text" name="title" size="40" value="<?=utf8entities($data['title'])?>" /></td>
</tr>
<?php
if ($data['error'] && $data['error'] < 4) {
echo "<tr><td>&nbsp;</td><td><b>";
switch ($data['error']) :
case 1: echo "This title is too short"; break;
case 2: echo "This title is too long"; break;
case 3: echo "There is already such a category"; break;
endswitch;
echo "</b></td></tr>\n";
}
?>
<tr>
<td style="vertical-align:top;font-weight:bold;padding:0px 10px 0px 0px">Description:</td>
<td><textarea name="desc" rows="5" cols="40"><?=utf8entities($data['desc'])?></textarea></td>
</tr>
<?php
if ($data['error'] == 4) {
echo "<tr><td>&nbsp;</td><td><b>This description is too short.</b></td></tr>\n";
}
?>
<tr>
<td style="text-align:right;padding:0px 5px 0px 0px">
<input type="submit" value="<?=$data['id'] ? "Modify" : "Add"?> category" style="color:white;border-color:white;background-color:green" />
</td>
<td style="padding:0px 0px 0px 5px">
<input type="submit" name="cancel" value="Cancel" style="color:white;border-color:white;background-color:red" />
</tr>
</table>
</form>

View file

@ -0,0 +1,42 @@
<?php
echo "<h2>Links and categories</h2>";
if (!count($data)) {
echo "<p>There are no categories. Click <a href='?c=lk&ac=0'>here</a> to add one.</p>";
return;
}
$hasAccount = (is_array($_SESSION) && !is_null($_SESSION['userid']));
for ($i=0;$i<count($data);$i++) {
echo "<p style='margin:10px 0px 5px 20px;text-align:justify'><b><u>" . utf8entities($data[$i]['title']) . "</u></b>";
if (!is_null($data[$i]['description'])) {
echo "<br/>" . preg_replace('/\n/', '<br/>', utf8entities($data[$i]['description']));
}
echo "<br/><a href='?c=lk&ac=1&cid={$data[$i]['id']}'>Add link</a> - <a href='?c=lk&ac=2&cid={$data[$i]['id']}'>Edit</a>";
echo " - <a onclick='return confirm(\"Are you sure you want to delete this category?\")' href='?c=lk&ac=3&cid={$data[$i]['id']}'>Delete</a>";
if ($i > 0) {
echo " - <a href='?c=lk&ac=4&cid={$data[$i]['id']}'>Move up</a>";
}
if ($i < count($data) - 1) {
echo " - <a href='?c=lk&ac=5&cid={$data[$i]['id']}'>Move down</a>";
}
echo "</p>";
echo "<ul style='margin:0px 30px 0px 60px'>";
if (!count($data[$i]['links'])) {
echo "<li><i>No links in this category.</i></li>";
} else {
foreach ($data[$i]['links'] as $l) {
echo "<li><a href='{$l['url']}' target='_blank' title=\"" . utf8entities($l['title']) . "\"><u>" . utf8entities($l['title']) . "</u></a>";
if (!is_null($l['description'])) {
echo "<br/>" . preg_replace('/\n/', '<br/>', utf8entities($l['description']));
}
echo "<br/><a href='?c=lk&ac=10&lid={$l['id']}'>Edit</a> - <a onclick='return confirm(\"Are you sure you want to delete this link?\")' href='?c=lk&ac=11&lid={$l['id']}'>Delete</a>";
echo "<br/>&nbsp;</li>";
}
}
echo "</ul>";
}
echo "<p style='margin:10px 0px 5px 20px;text-align:justify'><a href='?c=lk&ac=0'>Add category</a></p>";
?>

View file

@ -0,0 +1,65 @@
<h2><?=$data['id'] ? "Edit" : "Add"?> link</h2>
<form action="?" method="POST">
<input type="hidden" name="c" value="lk" />
<input type="hidden" name="ac" value="<?=$data['id'] ? 10 : 1?>" />
<input type="hidden" name="r" value="1" />
<?php
if ($data['id']) {
?>
<input type="hidden" name="lid" value="<?=$data['id']?>" />
<?php
} else {
?>
<input type="hidden" name="cid" value="<?=$data['cid']?>" />
<?php
}
?>
<table style="width:80%;padding:0px 0px 0px 30px">
<tr>
<td style="font-weight:bold;padding:0px 10px 0px 0px">Name:</td>
<td><input type="text" name="title" size="40" value="<?=utf8entities($data['title'])?>" /></td>
</tr>
<?php
if ($data['error'] && $data['error'] < 3) {
echo "<tr><td>&nbsp;</td><td><b>";
switch ($data['error']) :
case 1: echo "This title is too short"; break;
case 2: echo "This title is too long"; break;
endswitch;
echo "</b></td></tr>\n";
}
?>
<tr>
<td style="font-weight:bold;padding:0px 10px 0px 0px">URL:</td>
<td><input type="text" name="url" size="40" value="<?=utf8entities($data['url'])?>" /></td>
</tr>
<?php
if ($data['error'] >= 3 && $data['error'] <= 5) {
echo "<tr><td>&nbsp;</td><td><b>";
switch ($data['error']) :
case 3: echo "This URL is invalid"; break;
case 4: echo "The server could not be found"; break;
case 5: echo "The URL is already in the DB"; break;
endswitch;
echo "</b></td></tr>\n";
}
?>
<tr>
<td style="vertical-align:top;font-weight:bold;padding:0px 10px 0px 0px">Description:</td>
<td><textarea name="desc" rows="5" cols="40"><?=utf8entities($data['desc'])?></textarea></td>
</tr>
<?php
if ($data['error'] == 6) {
echo "<tr><td>&nbsp;</td><td><b>This description is too short.</b></td></tr>\n";
}
?>
<tr>
<td style="text-align:right;padding:0px 5px 0px 0px">
<input type="submit" value="<?=$data['id'] ? "Modify" : "Add"?> link" style="color:white;border-color:white;background-color:green" />
</td>
<td style="padding:0px 0px 0px 5px">
<input type="submit" name="cancel" value="Cancel" style="color:white;border-color:white;background-color:red" />
</tr>
</table>
</form>

View file

@ -0,0 +1,19 @@
<?php
echo "<h2>Broken links report</h2>";
if (!count($data)) {
echo "<p>No broken links have been reported.</p>";
return;
}
echo "<ul>";
foreach ($data as $link) {
echo "<li>Link <b>" . utf8entities($link['title']) . "</b> to <a href='{$link['url']}' target='_blank'>"
. utf8entities($link['url']) . "</a> in category " . utf8entities($link['category']['title']) . "<br/>"
. "Reported by: <b>" . join('</b> - <b>', $link['reporters']) . "</b><br/>"
. "<a href='?c=lkr&id={$link['id']}&dr=1'>Remove report</a> - "
. "<a onclick='return confirm(\"Please confirm that you want to remove this link\")' href='?c=lkr&id={$link['id']}&dl=1'>Remove link</a><br/>&nbsp;</li>";
}
echo "</ul>";
?>

View file

@ -0,0 +1,31 @@
<h2>Accept submission</h2>
<p>
You are about to accept the following submission:
</p>
<ul>
<li>Title: <b><?=utf8entities($data['sub']['title'])?></b></li>
<li>URL: <b><?=utf8entities($data['sub']['url'])?></b></li>
<?php
if ($data['sub']['description'] != '') {
echo " <li>Description: <b>" . utf8entities($data['sub']['description']) . "</b></li>\n";
}
?>
</ul>
<form action="?" method="GET">
<input type="hidden" name="c" value="lks" />
<input type="hidden" name="su" value="<?=utf8entities($data['sub']['url'])?>" />
<input type="hidden" name="sid" value="<?=$data['sub']['submitted_by']?>" />
<p>
Select the category into which the link should be added:
<select name="cid">
<option value="">---------------------------------------</option>
<?php
foreach ($data['cats'] as $cat) {
echo "<option value='{$cat['id']}'>" . utf8entities($cat['title']) . "</option>\n";
}
?>
</select><br/>
<input type="submit" value="Add link" style="color:white;border-color:white;background-color:green" />
<input type="submit" name="cancel" value="Cancel" style="color:white;border-color:white;background-color:red" />
</p>
</form>

View file

@ -0,0 +1,25 @@
<?php
echo "<h2>Submitted links</h2>";
if (!count($data)) {
echo "<p>No links have been submitted.</p>";
return;
}
echo "<ul>";
foreach ($data as $link => $entries) {
echo "<li>Link to <a target='_blank' href='$link'>" . utf8entities($link) . "</a>:<ul>";
foreach ($entries as $entry) {
echo "<li>Submitted by <b>{$entry['submitter']}</b> as <b>{$entry['title']}</b><br/>";
if ($entry['description'] != '') {
echo "Description: <b>{$entry['description']}</b>";
} else {
echo "No description";
}
echo "<br/><a href='?c=lks&su=" . urlencode($link) . "&sid={$entry['sid']}'>Accept entry</a></li>";
}
echo "<li><a onclick='return confirm(\"Are you sure?\")' href='?c=lks&su=" . urlencode($link) . "'>Delete entry</a></ul></li>";
}
echo "</ul>";
?>

View file

@ -0,0 +1,30 @@
<h2>Main administrative tools</h2>
<p>
<a href="?c=m">Manual update</a><br/>
Tool that updates the manual from the XML files on the server.<br/>
<b>Warning</b>: this tool is very resource-consuming; please don't run it unless you have a good reason to.
</p>
<p>
<a href="?c=a">Account management</a><br/>
This tool allows operations such as changing an account's email address or password.
</p>
<p>
<a href="?c=k">Request player kick</a><br/>
Request that a player be banned from the game. Another admin will have to validate your request.<br/>
<a href="?c=kl">Manage kicks</a><br/>
Display the list of pending, accepted and rejected kick requests, and validate pending requests.
</p>
<p>
<u>Link management:</u> <a href="?c=lk">Links &amp; categories</a> - <a href='?c=lkr'>Reports</a> - <a href='?c=lks'>Submissions</a><br/>
Different tools to manage the main page's links.
</p>
<h2>Beta 5 administrative tools</h2>
<p>
<a href="?c=p">Planet names</a><br/>
Planet names moderation tools to spot planets with insulting or "politically incorrect" names.
</p>
<p>
<a href="?c=s">Admin spam</a><br/>
Sends a message to all players.
</p>

View file

@ -0,0 +1,98 @@
<?php
function printOption($value, $text, $cVal) {
return "<option value='$value'" . ($cVal === $value ? " selected='selected'" : "") . ">" . utf8entities($text) . "</option>";
}
function printPrompt($id) {
$prompts = array(
"You are about to send this planet a warning regarding its name.",
"You are about to validate this planet name.",
"You are about to reset this planet."
);
return " onclick='return confirm(\"{$prompts[$id]}\\nPlease confirm.\")'";
}
?>
<h2>Planet names</h2>
<form action="?" method="GET">
<input type="hidden" name="c" value="p" />
<table style="width:90%;margin: 0 4%">
<tr>
<td style="text-align:center;width:50%">List: <select name="m" onchange="this.form.submit()">
<?=printOption("r", "Unmoderated", $data['mode'])?>
<?=printOption("o", "Validated", $data['mode'])?>
<?=printOption("p", "Pending", $data['mode'])?>
<?=printOption("w", "Renamed after warning", $data['mode'])?>
</select></td>
<td style="text-align:center"><?php
if ($data['pages'] == 0) {
echo "&nbsp;";
} else {
echo "Page <select name='p' onchange='this.form.submit()'>";
for ($i=0;$i<$data['pages'];$i++) {
echo printOption($i, $i+1, $data['page']);
}
echo "</select> / {$data['pages']}";
}
?></td>
</tr>
<tr>
<?php
if (count($data['list'])) {
?>
<td colspan='2'><table class='list'>
<tr>
<th style='text-align:left;width:33%'>Planet name</th>
<th style='text-align:left;width:33%'>Owner</th>
<th style='text-align:left;width:34%'>Actions</th>
</tr>
<?php
for ($i=0;$i<count($data['list']);$i++) {
$planet = $data['list'][$i];
?>
<tr>
<td><a href="planet?id=<?=$planet['id']?>"><?=utf8entities($planet['name'])?></a></td>
<td><?php
if (is_null($planet['owner'])) {
echo "(neutral)";
} else {
echo "<a href='message?a=c&ct=0&id={$planet['owner']}'>" . utf8entities($planet['oname']) . "</a>";
}
?></td>
<td>
<a target='_blank' href="map?menu=p&ctr=<?=$planet['id']?>">Centre map</a><?php
if ($data['mode'] == 'r' || $data['mode'] == 'o') {
if (is_null($planet['owner'])) {
echo " - <a href='?c=p&m=r&p={$data['page']}&pc=r&id={$planet['id']}'" . printPrompt(2) . ">Reset</a>\n";
} else {
echo " - <a href='?c=p&m=r&p={$data['page']}&pc=w&id={$planet['id']}'" . printPrompt(0) . ">Send warning</a>\n";
}
if ($data['mode'] == 'r') {
echo " - <a href='?c=p&m=r&p={$data['page']}&pc=v&id={$planet['id']}'" . printPrompt(1) . ">Validate</a>\n";
}
} elseif ($data['mode'] != 'p') {
echo " - <a href='?c=p&m=r&p={$data['page']}&pc=r&id={$planet['id']}'>Reset</a>\n";
if ($data['mode'] == 'w') {
echo " - <a href='?c=p&m=r&p={$data['page']}&pc=v&id={$planet['id']}'" . printPrompt(1) . ">Validate</a>\n";
}
}
?>
</td>
</tr>
<?php
}
?>
</table></td>
<?php
} else {
echo " <td colspan='2' style='text-align:center'>No planets in this list.</td>\n";
}
?>
</tr>
</table>
</form>

View file

@ -0,0 +1,55 @@
<h2>Send admin spam</h2>
<p>
Type the spam in the form below. You can use forum tags inside the spam.<br/>
Use the "Preview" button to check on your spam before sending it.<br/>
If you need to send the spam to all players within all active games, check the "Send in all games" box.
</p>
<form action="?" method='post'>
<input type='hidden' name='c' value='s' />
<a name='box'></a>
<table cellspacing="0" cellpadding="0" style="width: 75%">
<tr><td colspan='3'>&nbsp;</td></tr>
<?
$errs = array('Subject is too short.', 'Subject is too long.', 'Contents are too short.', 'Contents are too long.');
if ($data['err']) {
echo " <tr><td>&nbsp;</td><th style='text-align:left;color:red'>" . $errs[$data['err']-1]
. "</th><td>&nbsp;</td></tr>";
}
?>
<tr>
<th style="width:10%;text-align:right"><label for="sub" accesskey="s">Subject:</label></th>
<td colspan="2"><input type='text' id="sub" name='sub' style="width:90%" value="<?=utf8entities($data['sub'], ENT_QUOTES)?>" maxlength="100" size='60' /></td>
</tr>
<tr>
<th style="vertical-align:top;width:10%;text-align:right"><label for="txt" accesskey="t">Text:</label></th>
<td colspan="2"><textarea name='txt' id="txt" style="width:90%" rows='15'><?=utf8entities($data['txt'])?></textarea></td>
</tr>
<tr>
<th style="width:10%;text-align:right">Options:</th>
<td colspan="2">
<input type='checkbox' name='ag' id="eag" value='1'<?=$data['ag']?" checked='checked'":""?> /> <label for="eag" accesskey="a">Send in all games</label>
</td>
</tr>
<tr><td colspan='3'>&nbsp;</td></tr>
<tr>
<td>&nbsp;</td>
<td colspan='2' class='butt'>
<input type='submit' name='e' value='Spam, spam, spam' accesskey="g" />
<input type='submit' name='p' value='Preview' accesskey="p" />
<input type='submit' name='cc' value='Cancel' accesskey="c" />
</td>
</tr>
<?php
if ($data['prev'] != "") {
echo " <tr><td rowspan='3'>&nbsp;</td><td>&nbsp;</td><td rowspan='3'>&nbsp;</td></tr>\n";
echo " <tr><th style='text-align:left'>Preview - " . utf8entities($data['sub']) . "</th></tr>\n";
echo " <tr><td style='border: 1px solid #3f3f3f;padding: 4px'>" . $data['prev'] . "</td></tr>\n";
}
?>
</table>
</form>