2011-07-19 19:31:07 +02:00
|
|
|
<?php
|
|
|
|
function admin_arrive() {
|
2011-07-19 21:08:19 +02:00
|
|
|
$msg = "";
|
2011-07-19 21:18:14 +02:00
|
|
|
$search = "";
|
|
|
|
if (isset ($_REQUEST['search']))
|
|
|
|
$search = strip_request_item('search');
|
2011-07-19 21:08:19 +02:00
|
|
|
|
|
|
|
if (isset ($_REQUEST['reset']) && preg_match("/^[0-9]*$/", $_REQUEST['reset'])) {
|
|
|
|
$id = $_REQUEST['reset'];
|
|
|
|
sql_query("UPDATE `User` SET `Gekommen`=0 WHERE `UID`=" . sql_escape($id) . " LIMIT 1");
|
|
|
|
$msg = success("Reset done. Angel has not arrived.");
|
|
|
|
}
|
|
|
|
elseif (isset ($_REQUEST['arrived']) && preg_match("/^[0-9]*$/", $_REQUEST['arrived'])) {
|
|
|
|
$id = $_REQUEST['arrived'];
|
|
|
|
sql_query("UPDATE `User` SET `Gekommen`=1 WHERE `UID`=" . sql_escape($id) . " LIMIT 1");
|
|
|
|
$msg = success("Angel has been marked as arrived.");
|
|
|
|
}
|
|
|
|
|
|
|
|
$users = sql_select("SELECT * FROM `User` ORDER BY `Nick`");
|
|
|
|
$table = "";
|
2011-07-19 21:18:14 +02:00
|
|
|
if ($search == "")
|
|
|
|
$tokens = array ();
|
|
|
|
else
|
|
|
|
$tokens = explode(" ", $search);
|
2011-07-19 21:08:19 +02:00
|
|
|
foreach ($users as $usr) {
|
2011-07-19 21:18:14 +02:00
|
|
|
if (count($tokens) > 0) {
|
|
|
|
$match = false;
|
|
|
|
$index = join("", $usr);
|
|
|
|
foreach ($tokens as $t)
|
|
|
|
if (strstr($index, trim($t))) {
|
|
|
|
$match = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!$match)
|
|
|
|
continue;
|
|
|
|
}
|
2011-07-19 21:08:19 +02:00
|
|
|
$table .= '<tr>';
|
|
|
|
$table .= '<td>' . $usr['Nick'] . '</td>';
|
|
|
|
if ($usr['Gekommen'] == 1)
|
2011-07-19 21:18:14 +02:00
|
|
|
$table .= '<td>yes</td><td><a href="' . page_link_to('admin_arrive') . '&reset=' . $usr['UID'] . '&search=' . $search . '">reset</a></td>';
|
2011-07-19 21:08:19 +02:00
|
|
|
else
|
2011-07-19 21:18:14 +02:00
|
|
|
$table .= '<td></td><td><a href="' . page_link_to('admin_arrive') . '&arrived=' . $usr['UID'] . '&search=' . $search . '">arrived</a></td>';
|
2011-07-19 21:08:19 +02:00
|
|
|
$table .= '</tr>';
|
|
|
|
}
|
|
|
|
return template_render('../templates/admin_arrive.html', array (
|
2011-07-19 21:18:14 +02:00
|
|
|
'search' => $search,
|
2011-07-19 21:08:19 +02:00
|
|
|
'table' => $table,
|
2011-07-19 21:18:14 +02:00
|
|
|
'msg' => $msg,
|
|
|
|
'link' => page_link_to('admin_arrive')
|
2011-07-19 21:08:19 +02:00
|
|
|
));
|
2011-07-19 19:31:07 +02:00
|
|
|
}
|
|
|
|
?>
|