本文整理汇总了PHP中strip_request_item函数的典型用法代码示例。如果您正苦于以下问题:PHP strip_request_item函数的具体用法?PHP strip_request_item怎么用?PHP strip_request_item使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了strip_request_item函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: admin_free
function admin_free()
{
global $privileges;
$search = "";
if (isset($_REQUEST['search'])) {
$search = strip_request_item('search');
}
$angeltypesearch = "";
if (empty($_REQUEST['angeltype'])) {
$_REQUEST['angeltype'] = '';
} else {
$angeltypesearch = " INNER JOIN `UserAngelTypes` ON (`UserAngelTypes`.`angeltype_id` = '" . sql_escape($_REQUEST['angeltype']) . "' AND `UserAngelTypes`.`user_id` = `User`.`UID`";
if (isset($_REQUEST['confirmed_only'])) {
$angeltypesearch .= " AND `UserAngelTypes`.`confirm_user_id`";
}
$angeltypesearch .= ") ";
}
$angel_types_source = sql_select("SELECT `id`, `name` FROM `AngelTypes` ORDER BY `name`");
$angel_types = array('' => 'alle Typen');
foreach ($angel_types_source as $angel_type) {
$angel_types[$angel_type['id']] = $angel_type['name'];
}
$users = sql_select("\n SELECT `User`.* \n FROM `User` \n {$angeltypesearch} \n LEFT JOIN `ShiftEntry` ON `User`.`UID` = `ShiftEntry`.`UID` \n LEFT JOIN `Shifts` ON (`ShiftEntry`.`SID` = `Shifts`.`SID` AND `Shifts`.`start` < '" . sql_escape(time()) . "' AND `Shifts`.`end` > '" . sql_escape(time()) . "') \n WHERE `User`.`Gekommen` = 1 AND `Shifts`.`SID` IS NULL \n GROUP BY `User`.`UID` \n ORDER BY `Nick`");
$free_users_table = array();
if ($search == "") {
$tokens = array();
} else {
$tokens = explode(" ", $search);
}
foreach ($users as $usr) {
if (count($tokens) > 0) {
$match = false;
$index = join("", $usr);
foreach ($tokens as $t) {
if (stristr($index, trim($t))) {
$match = true;
break;
}
}
if (!$match) {
continue;
}
}
$free_users_table[] = array('name' => User_Nick_render($usr), 'shift_state' => User_shift_state_render($usr), 'handy' => $usr['Handy'], 'telefon' => $usr['Telefon'], 'email' => $usr['email'], 'kommentar' => $usr['kommentar'], 'actions' => in_array('admin_user', $privileges) ? button(page_link_to('admin_user') . '&id=' . $usr['UID'], _("edit"), 'btn-xs') : '');
}
return page_with_title(admin_free_title(), array(form(array(div('row', array(div('col-md-4', array(form_text('search', _("Search"), $search))), div('col-md-4', array(form_select('angeltype', _("Angeltype"), $angel_types, $_REQUEST['angeltype']))), div('col-md-2', array(form_checkbox('confirmed_only', _("Only confirmed"), isset($_REQUEST['confirmed_only'])))), div('col-md-2', array(form_submit('submit', _("Search")))))))), table(array('name' => _("Nick"), 'shift_state' => '', 'handy' => _("Mobile"), 'telefon' => _("Phone"), 'email' => _("E-Mail"), 'kommentar' => _("add. Info"), 'actions' => ''), $free_users_table)));
}
示例2: admin_arrive
function admin_arrive()
{
$msg = "";
$search = "";
if (isset($_REQUEST['search'])) {
$search = strip_request_item('search');
}
if (isset($_REQUEST['reset']) && preg_match("/^[0-9]*\$/", $_REQUEST['reset'])) {
$id = $_REQUEST['reset'];
$user_source = User($id);
if ($user_source != null) {
sql_query("UPDATE `User` SET `Gekommen`=0, `arrival_date` = NULL WHERE `UID`='" . sql_escape($id) . "' LIMIT 1");
engelsystem_log("User set to not available: " . User_Nick_render($user_source));
$msg = success(_("Reset done. Angel is not available."), true);
} else {
$msg = error(_("Angel not found."), true);
}
} elseif (isset($_REQUEST['arrived']) && preg_match("/^[0-9]*\$/", $_REQUEST['arrived'])) {
$id = $_REQUEST['arrived'];
$user_source = User($id);
if ($user_source != null) {
sql_query("UPDATE `User` SET `Gekommen`=1, `arrival_date`='" . time() . "' WHERE `UID`='" . sql_escape($id) . "' LIMIT 1");
engelsystem_log("User is available: " . User_Nick_render($user_source));
$msg = success(_("Angel has been marked as available."), true);
} else {
$msg = error(_("Angel not found."), true);
}
}
$users = sql_select("SELECT * FROM `User` ORDER BY `Nick`");
$arrival_count_at_day = [];
$planned_arrival_count_at_day = [];
$planned_departure_count_at_day = [];
$table = "";
$users_matched = [];
if ($search == "") {
$tokens = [];
} else {
$tokens = explode(" ", $search);
}
foreach ($users as $usr) {
if (count($tokens) > 0) {
$match = false;
$index = join(" ", $usr);
foreach ($tokens as $t) {
if (stristr($index, trim($t))) {
$match = true;
break;
}
}
if (!$match) {
continue;
}
}
$usr['nick'] = User_Nick_render($usr);
if ($usr['planned_departure_date'] != null) {
$usr['rendered_planned_departure_date'] = date('Y-m-d', $usr['planned_departure_date']);
} else {
$usr['rendered_planned_departure_date'] = '-';
}
$usr['rendered_planned_arrival_date'] = date('Y-m-d', $usr['planned_arrival_date']);
$usr['rendered_arrival_date'] = $usr['arrival_date'] > 0 ? date('Y-m-d', $usr['arrival_date']) : "-";
$usr['arrived'] = $usr['Gekommen'] == 1 ? _("yes") : "";
$usr['actions'] = $usr['Gekommen'] == 1 ? '<a href="' . page_link_to('admin_arrive') . '&reset=' . $usr['UID'] . '&search=' . $search . '">' . _("reset") . '</a>' : '<a href="' . page_link_to('admin_arrive') . '&arrived=' . $usr['UID'] . '&search=' . $search . '">' . _("available") . '</a>';
if ($usr['arrival_date'] > 0) {
$day = date('Y-m-d', $usr['arrival_date']);
if (!isset($arrival_count_at_day[$day])) {
$arrival_count_at_day[$day] = 0;
}
$arrival_count_at_day[$day]++;
}
if ($usr['planned_arrival_date'] != null) {
$day = date('Y-m-d', $usr['planned_arrival_date']);
if (!isset($planned_arrival_count_at_day[$day])) {
$planned_arrival_count_at_day[$day] = 0;
}
$planned_arrival_count_at_day[$day]++;
}
if ($usr['planned_departure_date'] != null && $usr['Gekommen'] == 1) {
$day = date('Y-m-d', $usr['planned_departure_date']);
if (!isset($planned_departure_count_at_day[$day])) {
$planned_departure_count_at_day[$day] = 0;
}
$planned_departure_count_at_day[$day]++;
}
$users_matched[] = $usr;
}
ksort($arrival_count_at_day);
ksort($planned_arrival_count_at_day);
ksort($planned_departure_count_at_day);
$arrival_at_day = [];
$arrival_sum = 0;
foreach ($arrival_count_at_day as $day => $count) {
$arrival_sum += $count;
$arrival_at_day[$day] = ['day' => $day, 'count' => $count, 'sum' => $arrival_sum];
}
$planned_arrival_sum_at_day = [];
$planned_arrival_sum = 0;
foreach ($planned_arrival_count_at_day as $day => $count) {
$planned_arrival_sum += $count;
$planned_arrival_at_day[$day] = ['day' => $day, 'count' => $count, 'sum' => $planned_arrival_sum];
//.........这里部分代码省略.........
示例3: admin_rooms
function admin_rooms()
{
global $user;
$rooms_source = sql_select("SELECT * FROM `Room` ORDER BY `Name`");
$rooms = array();
foreach ($rooms_source as $room) {
$rooms[] = array('name' => $room['Name'], 'from_pentabarf' => $room['FromPentabarf'] == 'Y' ? '✓' : '', 'public' => $room['show'] == 'Y' ? '✓' : '', 'actions' => buttons(array(button(page_link_to('admin_rooms') . '&show=edit&id=' . $room['RID'], _("edit"), 'btn-xs'), button(page_link_to('admin_rooms') . '&show=delete&id=' . $room['RID'], _("delete"), 'btn-xs'))));
}
$room = null;
if (isset($_REQUEST['show'])) {
$msg = "";
$name = "";
$from_pentabarf = "";
$public = 'Y';
$number = "";
$angeltypes_source = sql_select("SELECT * FROM `AngelTypes` ORDER BY `name`");
$angeltypes = array();
$angeltypes_count = array();
foreach ($angeltypes_source as $angeltype) {
$angeltypes[$angeltype['id']] = $angeltype['name'];
$angeltypes_count[$angeltype['id']] = 0;
}
if (test_request_int('id')) {
$room = sql_select("SELECT * FROM `Room` WHERE `RID`='" . sql_escape($_REQUEST['id']) . "'");
if (count($room) > 0) {
$id = $_REQUEST['id'];
$name = $room[0]['Name'];
$from_pentabarf = $room[0]['FromPentabarf'];
$public = $room[0]['show'];
$number = $room[0]['Number'];
$needed_angeltypes = sql_select("SELECT * FROM `NeededAngelTypes` WHERE `room_id`='" . sql_escape($id) . "'");
foreach ($needed_angeltypes as $needed_angeltype) {
$angeltypes_count[$needed_angeltype['angel_type_id']] = $needed_angeltype['count'];
}
} else {
redirect(page_link_to('admin_rooms'));
}
}
if ($_REQUEST['show'] == 'edit') {
if (isset($_REQUEST['submit'])) {
$ok = true;
if (isset($_REQUEST['name']) && strlen(strip_request_item('name')) > 0) {
$name = strip_request_item('name');
if (isset($room) && sql_num_query("SELECT * FROM `Room` WHERE `Name`='" . sql_escape($name) . "' AND NOT `RID`=" . sql_escape($id)) > 0) {
$ok = false;
$msg .= error(_("This name is already in use."), true);
}
} else {
$ok = false;
$msg .= error(_("Please enter a name."), true);
}
if (isset($_REQUEST['from_pentabarf'])) {
$from_pentabarf = 'Y';
} else {
$from_pentabarf = '';
}
if (isset($_REQUEST['public'])) {
$public = 'Y';
} else {
$public = '';
}
if (isset($_REQUEST['number'])) {
$number = strip_request_item('number');
} else {
$ok = false;
}
foreach ($angeltypes as $angeltype_id => $angeltype) {
if (isset($_REQUEST['angeltype_count_' . $angeltype_id]) && preg_match("/^[0-9]{1,4}\$/", $_REQUEST['angeltype_count_' . $angeltype_id])) {
$angeltypes_count[$angeltype_id] = $_REQUEST['angeltype_count_' . $angeltype_id];
} else {
$ok = false;
$msg .= error(sprintf(_("Please enter needed angels for type %s.", $angeltype)), true);
}
}
if ($ok) {
if (isset($id)) {
sql_query("UPDATE `Room` SET `Name`='" . sql_escape($name) . "', `FromPentabarf`='" . sql_escape($from_pentabarf) . "', `show`='" . sql_escape($public) . "', `Number`='" . sql_escape($number) . "' WHERE `RID`='" . sql_escape($id) . "' LIMIT 1");
engelsystem_log("Room updated: " . $name . ", pentabarf import: " . $from_pentabarf . ", public: " . $public . ", number: " . $number);
} else {
$id = Room_create($name, $from_pentabarf, $public, $number);
if ($id === false) {
engelsystem_error("Unable to create room.");
}
engelsystem_log("Room created: " . $name . ", pentabarf import: " . $from_pentabarf . ", public: " . $public . ", number: " . $number);
}
sql_query("DELETE FROM `NeededAngelTypes` WHERE `room_id`='" . sql_escape($id) . "'");
$needed_angeltype_info = array();
foreach ($angeltypes_count as $angeltype_id => $angeltype_count) {
$angeltype = AngelType($angeltype_id);
if ($angeltype === false) {
engelsystem_error("Unable to load angeltype.");
}
if ($angeltype != null) {
sql_query("INSERT INTO `NeededAngelTypes` SET `room_id`='" . sql_escape($id) . "', `angel_type_id`='" . sql_escape($angeltype_id) . "', `count`='" . sql_escape($angeltype_count) . "'");
$needed_angeltype_info[] = $angeltype['name'] . ": " . $angeltype_count;
}
}
engelsystem_log("Set needed angeltypes of room " . $name . " to: " . join(", ", $needed_angeltype_info));
success(_("Room saved."));
redirect(page_link_to("admin_rooms"));
//.........这里部分代码省略.........
示例4: user_settings
function user_settings()
{
global $enable_tshirt_size, $tshirt_sizes, $themes, $locales;
global $user;
$msg = "";
$nick = $user['Nick'];
$lastname = $user['Name'];
$prename = $user['Vorname'];
$age = $user['Alter'];
$tel = $user['Telefon'];
$dect = $user['DECT'];
$mobile = $user['Handy'];
$mail = $user['email'];
$email_shiftinfo = $user['email_shiftinfo'];
$jabber = $user['jabber'];
$hometown = $user['Hometown'];
$tshirt_size = $user['Size'];
$password_hash = "";
$selected_theme = $user['color'];
$selected_language = $user['Sprache'];
$planned_arrival_date = $user['planned_arrival_date'];
$planned_departure_date = $user['planned_departure_date'];
if (isset($_REQUEST['submit'])) {
$ok = true;
if (isset($_REQUEST['mail']) && strlen(strip_request_item('mail')) > 0) {
$mail = strip_request_item('mail');
if (!check_email($mail)) {
$ok = false;
$msg .= error(_("E-mail address is not correct."), true);
}
} else {
$ok = false;
$msg .= error(_("Please enter your e-mail."), true);
}
$email_shiftinfo = isset($_REQUEST['email_shiftinfo']);
if (isset($_REQUEST['jabber']) && strlen(strip_request_item('jabber')) > 0) {
$jabber = strip_request_item('jabber');
if (!check_email($jabber)) {
$ok = false;
$msg .= error(_("Please check your jabber account information."), true);
}
}
if (isset($_REQUEST['tshirt_size']) && isset($tshirt_sizes[$_REQUEST['tshirt_size']])) {
$tshirt_size = $_REQUEST['tshirt_size'];
} elseif ($enable_tshirt_size) {
$ok = false;
}
if (isset($_REQUEST['planned_arrival_date']) && DateTime::createFromFormat("Y-m-d", trim($_REQUEST['planned_arrival_date']))) {
$planned_arrival_date = DateTime::createFromFormat("Y-m-d", trim($_REQUEST['planned_arrival_date']))->getTimestamp();
} else {
$ok = false;
$msg .= error(_("Please enter your planned date of arrival."), true);
}
if (isset($_REQUEST['planned_departure_date']) && $_REQUEST['planned_departure_date'] != '') {
if (DateTime::createFromFormat("Y-m-d", trim($_REQUEST['planned_departure_date']))) {
$planned_departure_date = DateTime::createFromFormat("Y-m-d", trim($_REQUEST['planned_departure_date']))->getTimestamp();
} else {
$ok = false;
$msg .= error(_("Please enter your planned date of departure."), true);
}
} else {
$planned_departure_date = null;
}
// Trivia
if (isset($_REQUEST['lastname'])) {
$lastname = strip_request_item('lastname');
}
if (isset($_REQUEST['prename'])) {
$prename = strip_request_item('prename');
}
if (isset($_REQUEST['age']) && preg_match("/^[0-9]{0,4}\$/", $_REQUEST['age'])) {
$age = strip_request_item('age');
}
if (isset($_REQUEST['tel'])) {
$tel = strip_request_item('tel');
}
if (isset($_REQUEST['dect'])) {
$dect = strip_request_item('dect');
}
if (isset($_REQUEST['mobile'])) {
$mobile = strip_request_item('mobile');
}
if (isset($_REQUEST['hometown'])) {
$hometown = strip_request_item('hometown');
}
if ($ok) {
sql_query("\n UPDATE `User` SET\n `Nick`='" . sql_escape($nick) . "',\n `Vorname`='" . sql_escape($prename) . "',\n `Name`='" . sql_escape($lastname) . "',\n `Alter`='" . sql_escape($age) . "',\n `Telefon`='" . sql_escape($tel) . "',\n `DECT`='" . sql_escape($dect) . "',\n `Handy`='" . sql_escape($mobile) . "',\n `email`='" . sql_escape($mail) . "',\n `email_shiftinfo`=" . sql_bool($email_shiftinfo) . ",\n `jabber`='" . sql_escape($jabber) . "',\n `Size`='" . sql_escape($tshirt_size) . "',\n `Hometown`='" . sql_escape($hometown) . "',\n `planned_arrival_date`='" . sql_escape($planned_arrival_date) . "',\n `planned_departure_date`=" . sql_null($planned_departure_date) . "\n WHERE `UID`='" . sql_escape($user['UID']) . "'");
success(_("Settings saved."));
redirect(page_link_to('user_settings'));
}
} elseif (isset($_REQUEST['submit_password'])) {
$ok = true;
if (!isset($_REQUEST['password']) || !verify_password($_REQUEST['password'], $user['Passwort'], $user['UID'])) {
$msg .= error(_("-> not OK. Please try again."), true);
} elseif (strlen($_REQUEST['new_password']) < MIN_PASSWORD_LENGTH) {
$msg .= error(_("Your password is to short (please use at least 6 characters)."), true);
} elseif ($_REQUEST['new_password'] != $_REQUEST['new_password2']) {
$msg .= error(_("Your passwords don't match."), true);
} elseif (set_password($user['UID'], $_REQUEST['new_password'])) {
success(_("Password saved."));
//.........这里部分代码省略.........
示例5: user_shifts
function user_shifts()
{
global $user, $privileges, $max_freeloadable_shifts;
if (User_is_freeloader($user)) {
redirect(page_link_to('user_myshifts'));
}
// Locations laden
$rooms = sql_select("SELECT * FROM `Room` WHERE `show`='Y' ORDER BY `Name`");
$room_array = array();
foreach ($rooms as $room) {
$room_array[$room['RID']] = $room['Name'];
}
// Löschen einzelner Schicht-Einträge (Also Belegung einer Schicht von Engeln) durch Admins
if (isset($_REQUEST['entry_id']) && in_array('user_shifts_admin', $privileges)) {
if (isset($_REQUEST['entry_id']) && test_request_int('entry_id')) {
$entry_id = $_REQUEST['entry_id'];
} else {
redirect(page_link_to('user_shifts'));
}
$shift_entry_source = sql_select("\n SELECT `User`.`Nick`, `ShiftEntry`.`Comment`, `ShiftEntry`.`UID`, `ShiftTypes`.`name`, `Shifts`.*, `Room`.`Name`, `AngelTypes`.`name` as `angel_type` \n FROM `ShiftEntry` \n JOIN `User` ON (`User`.`UID`=`ShiftEntry`.`UID`) \n JOIN `AngelTypes` ON (`ShiftEntry`.`TID` = `AngelTypes`.`id`) \n JOIN `Shifts` ON (`ShiftEntry`.`SID` = `Shifts`.`SID`) \n JOIN `ShiftTypes` ON (`ShiftTypes`.`id` = `Shifts`.`shifttype_id`)\n JOIN `Room` ON (`Shifts`.`RID` = `Room`.`RID`) \n WHERE `ShiftEntry`.`id`='" . sql_escape($entry_id) . "'");
if (count($shift_entry_source) > 0) {
$shift_entry_source = $shift_entry_source[0];
$result = ShiftEntry_delete($entry_id);
if ($result === false) {
engelsystem_error('Unable to delete shift entry.');
}
engelsystem_log("Deleted " . User_Nick_render($shift_entry_source) . "'s shift: " . $shift_entry_source['name'] . " at " . $shift_entry_source['Name'] . " from " . date("y-m-d H:i", $shift_entry_source['start']) . " to " . date("y-m-d H:i", $shift_entry_source['end']) . " as " . $shift_entry_source['angel_type']);
success(_("Shift entry deleted."));
} else {
error(_("Entry not found."));
}
redirect(page_link_to('user_shifts'));
} elseif (isset($_REQUEST['edit_shift']) && in_array('admin_shifts', $privileges)) {
$msg = "";
$ok = true;
if (isset($_REQUEST['edit_shift']) && test_request_int('edit_shift')) {
$shift_id = $_REQUEST['edit_shift'];
} else {
redirect(page_link_to('user_shifts'));
}
$shift = sql_select("\n SELECT `ShiftTypes`.`name`, `Shifts`.*, `Room`.* FROM `Shifts` \n JOIN `Room` ON (`Shifts`.`RID` = `Room`.`RID`) \n JOIN `ShiftTypes` ON (`ShiftTypes`.`id` = `Shifts`.`shifttype_id`)\n WHERE `SID`='" . sql_escape($shift_id) . "'");
if (count($shift) == 0) {
redirect(page_link_to('user_shifts'));
}
$shift = $shift[0];
// Engeltypen laden
$types = sql_select("SELECT * FROM `AngelTypes` ORDER BY `name`");
$angel_types = array();
$needed_angel_types = array();
foreach ($types as $type) {
$angel_types[$type['id']] = $type;
$needed_angel_types[$type['id']] = 0;
}
$shifttypes_source = ShiftTypes();
$shifttypes = [];
foreach ($shifttypes_source as $shifttype) {
$shifttypes[$shifttype['id']] = $shifttype['name'];
}
// Benötigte Engeltypen vom Raum
$needed_angel_types_source = sql_select("SELECT `AngelTypes`.*, `NeededAngelTypes`.`count` FROM `AngelTypes` LEFT JOIN `NeededAngelTypes` ON (`NeededAngelTypes`.`angel_type_id` = `AngelTypes`.`id` AND `NeededAngelTypes`.`room_id`='" . sql_escape($shift['RID']) . "') ORDER BY `AngelTypes`.`name`");
foreach ($needed_angel_types_source as $type) {
if ($type['count'] != "") {
$needed_angel_types[$type['id']] = $type['count'];
}
}
// Benötigte Engeltypen von der Schicht
$needed_angel_types_source = sql_select("SELECT `AngelTypes`.*, `NeededAngelTypes`.`count` FROM `AngelTypes` LEFT JOIN `NeededAngelTypes` ON (`NeededAngelTypes`.`angel_type_id` = `AngelTypes`.`id` AND `NeededAngelTypes`.`shift_id`='" . sql_escape($shift_id) . "') ORDER BY `AngelTypes`.`name`");
foreach ($needed_angel_types_source as $type) {
if ($type['count'] != "") {
$needed_angel_types[$type['id']] = $type['count'];
}
}
$shifttype_id = $shift['shifttype_id'];
$title = $shift['title'];
$rid = $shift['RID'];
$start = $shift['start'];
$end = $shift['end'];
if (isset($_REQUEST['submit'])) {
// Name/Bezeichnung der Schicht, darf leer sein
$title = strip_request_item('title');
// Auswahl der sichtbaren Locations für die Schichten
if (isset($_REQUEST['rid']) && preg_match("/^[0-9]+\$/", $_REQUEST['rid']) && isset($room_array[$_REQUEST['rid']])) {
$rid = $_REQUEST['rid'];
} else {
$ok = false;
$rid = $rooms[0]['RID'];
$msg .= error(_("Please select a room."), true);
}
if (isset($_REQUEST['shifttype_id']) && isset($shifttypes[$_REQUEST['shifttype_id']])) {
$shifttype_id = $_REQUEST['shifttype_id'];
} else {
$ok = false;
$msg .= error(_('Please select a shifttype.'), true);
}
if (isset($_REQUEST['start']) && ($tmp = DateTime::createFromFormat("Y-m-d H:i", trim($_REQUEST['start'])))) {
$start = $tmp->getTimestamp();
} else {
$ok = false;
$msg .= error(_("Please enter a valid starting time for the shifts."), true);
}
//.........这里部分代码省略.........
示例6: admin_active
function admin_active()
{
global $tshirt_sizes, $shift_sum_formula;
$msg = "";
$search = "";
$forced_count = sql_num_query("SELECT * FROM `User` WHERE `force_active`=1");
$count = $forced_count;
$limit = "";
$set_active = "";
if (isset($_REQUEST['search'])) {
$search = strip_request_item('search');
}
if (isset($_REQUEST['set_active'])) {
$ok = true;
if (isset($_REQUEST['count']) && preg_match("/^[0-9]+\$/", $_REQUEST['count'])) {
$count = strip_request_item('count');
if ($count < $forced_count) {
error(sprintf(_("At least %s angels are forced to be active. The number has to be greater."), $forced_count));
redirect(page_link_to('admin_active'));
}
} else {
$ok = false;
$msg .= error(_("Please enter a number of angels to be marked as active."), true);
}
if ($ok) {
$limit = " LIMIT " . $count;
}
if (isset($_REQUEST['ack'])) {
sql_query("UPDATE `User` SET `Aktiv` = 0 WHERE `Tshirt` = 0");
$users = sql_select("\n SELECT `User`.*, COUNT(`ShiftEntry`.`id`) as `shift_count`, {$shift_sum_formula} as `shift_length` \n FROM `User` \n LEFT JOIN `ShiftEntry` ON `User`.`UID` = `ShiftEntry`.`UID` \n LEFT JOIN `Shifts` ON `ShiftEntry`.`SID` = `Shifts`.`SID` \n WHERE `User`.`Gekommen` = 1 AND `User`.`force_active`=0 \n GROUP BY `User`.`UID` \n ORDER BY `force_active` DESC, `shift_length` DESC" . $limit);
$user_nicks = array();
foreach ($users as $usr) {
sql_query("UPDATE `User` SET `Aktiv` = 1 WHERE `UID`='" . sql_escape($usr['UID']) . "'");
$user_nicks[] = User_Nick_render($usr);
}
sql_query("UPDATE `User` SET `Aktiv`=1 WHERE `force_active`=TRUE");
engelsystem_log("These angels are active now: " . join(", ", $user_nicks));
$limit = "";
$msg = success(_("Marked angels."), true);
} else {
$set_active = '<a href="' . page_link_to('admin_active') . '&serach=' . $search . '">« ' . _("back") . '</a> | <a href="' . page_link_to('admin_active') . '&search=' . $search . '&count=' . $count . '&set_active&ack">' . _("apply") . '</a>';
}
}
if (isset($_REQUEST['active']) && preg_match("/^[0-9]+\$/", $_REQUEST['active'])) {
$id = $_REQUEST['active'];
$user_source = User($id);
if ($user_source != null) {
sql_query("UPDATE `User` SET `Aktiv`=1 WHERE `UID`='" . sql_escape($id) . "' LIMIT 1");
engelsystem_log("User " . User_Nick_render($user_source) . " is active now.");
$msg = success(_("Angel has been marked as active."), true);
} else {
$msg = error(_("Angel not found."), true);
}
} elseif (isset($_REQUEST['not_active']) && preg_match("/^[0-9]+\$/", $_REQUEST['not_active'])) {
$id = $_REQUEST['not_active'];
$user_source = User($id);
if ($user_source != null) {
sql_query("UPDATE `User` SET `Aktiv`=0 WHERE `UID`='" . sql_escape($id) . "' LIMIT 1");
engelsystem_log("User " . User_Nick_render($user_source) . " is NOT active now.");
$msg = success(_("Angel has been marked as not active."), true);
} else {
$msg = error(_("Angel not found."), true);
}
} elseif (isset($_REQUEST['tshirt']) && preg_match("/^[0-9]+\$/", $_REQUEST['tshirt'])) {
$id = $_REQUEST['tshirt'];
$user_source = User($id);
if ($user_source != null) {
sql_query("UPDATE `User` SET `Tshirt`=1 WHERE `UID`='" . sql_escape($id) . "' LIMIT 1");
engelsystem_log("User " . User_Nick_render($user_source) . " has tshirt now.");
$msg = success(_("Angel has got a t-shirt."), true);
} else {
$msg = error("Angel not found.", true);
}
} elseif (isset($_REQUEST['not_tshirt']) && preg_match("/^[0-9]+\$/", $_REQUEST['not_tshirt'])) {
$id = $_REQUEST['not_tshirt'];
$user_source = User($id);
if ($user_source != null) {
sql_query("UPDATE `User` SET `Tshirt`=0 WHERE `UID`='" . sql_escape($id) . "' LIMIT 1");
engelsystem_log("User " . User_Nick_render($user_source) . " has NO tshirt.");
$msg = success(_("Angel has got no t-shirt."), true);
} else {
$msg = error(_("Angel not found."), true);
}
}
$users = sql_select("\n SELECT `User`.*, COUNT(`ShiftEntry`.`id`) as `shift_count`, {$shift_sum_formula} as `shift_length` \n FROM `User` LEFT JOIN `ShiftEntry` ON `User`.`UID` = `ShiftEntry`.`UID` \n LEFT JOIN `Shifts` ON `ShiftEntry`.`SID` = `Shifts`.`SID` \n WHERE `User`.`Gekommen` = 1 \n GROUP BY `User`.`UID` \n ORDER BY `force_active` DESC, `shift_length` DESC" . $limit);
$matched_users = array();
if ($search == "") {
$tokens = array();
} else {
$tokens = explode(" ", $search);
}
foreach ($users as &$usr) {
if (count($tokens) > 0) {
$match = false;
$index = join("", $usr);
foreach ($tokens as $t) {
if (stristr($index, trim($t))) {
$match = true;
break;
}
//.........这里部分代码省略.........
示例7: admin_shifts
function admin_shifts()
{
$ok = true;
$rid = 0;
$start = DateTime::createFromFormat("Y-m-d H:i", date("Y-m-d") . " 00:00")->getTimestamp();
$end = $start + 24 * 60 * 60;
$mode = 'single';
$angelmode = 'manually';
$length = '';
$change_hours = array();
$title = "";
$shifttype_id = null;
// Locations laden (auch unsichtbare - fuer Erzengel ist das ok)
$rooms = sql_select("SELECT * FROM `Room` ORDER BY `Name`");
$room_array = array();
foreach ($rooms as $room) {
$room_array[$room['RID']] = $room['Name'];
}
// Engeltypen laden
$types = sql_select("SELECT * FROM `AngelTypes` ORDER BY `name`");
$needed_angel_types = array();
foreach ($types as $type) {
$needed_angel_types[$type['id']] = 0;
}
// Load shift types
$shifttypes_source = ShiftTypes();
if ($shifttypes_source === false) {
engelsystem_error('Unable to load shift types.');
}
$shifttypes = [];
foreach ($shifttypes_source as $shifttype) {
$shifttypes[$shifttype['id']] = $shifttype['name'];
}
if (isset($_REQUEST['preview']) || isset($_REQUEST['back'])) {
if (isset($_REQUEST['shifttype_id'])) {
$shifttype = ShiftType($_REQUEST['shifttype_id']);
if ($shifttype === false) {
engelsystem_error('Unable to load shift type.');
}
if ($shifttype == null) {
$ok = false;
error(_('Please select a shift type.'));
} else {
$shifttype_id = $_REQUEST['shifttype_id'];
}
} else {
$ok = false;
error(_('Please select a shift type.'));
}
// Name/Bezeichnung der Schicht, darf leer sein
$title = strip_request_item('title');
// Auswahl der sichtbaren Locations für die Schichten
if (isset($_REQUEST['rid']) && preg_match("/^[0-9]+\$/", $_REQUEST['rid']) && isset($room_array[$_REQUEST['rid']])) {
$rid = $_REQUEST['rid'];
} else {
$ok = false;
$rid = $rooms[0]['RID'];
error(_('Please select a location.'));
}
if (isset($_REQUEST['start']) && ($tmp = DateTime::createFromFormat("Y-m-d H:i", trim($_REQUEST['start'])))) {
$start = $tmp->getTimestamp();
} else {
$ok = false;
error(_('Please select a start time.'));
}
if (isset($_REQUEST['end']) && ($tmp = DateTime::createFromFormat("Y-m-d H:i", trim($_REQUEST['end'])))) {
$end = $tmp->getTimestamp();
} else {
$ok = false;
error(_('Please select an end time.'));
}
if ($start >= $end) {
$ok = false;
error(_('The shifts end has to be after its start.'));
}
if (isset($_REQUEST['mode'])) {
if ($_REQUEST['mode'] == 'single') {
$mode = 'single';
} elseif ($_REQUEST['mode'] == 'multi') {
if (isset($_REQUEST['length']) && preg_match("/^[0-9]+\$/", trim($_REQUEST['length']))) {
$mode = 'multi';
$length = trim($_REQUEST['length']);
} else {
$ok = false;
error(_('Please enter a shift duration in minutes.'));
}
} elseif ($_REQUEST['mode'] == 'variable') {
if (isset($_REQUEST['change_hours']) && preg_match("/^([0-9]{2}(,|\$))/", trim(str_replace(" ", "", $_REQUEST['change_hours'])))) {
$mode = 'variable';
$change_hours = array_map('trim', explode(",", $_REQUEST['change_hours']));
} else {
$ok = false;
error(_('Please split the shift-change hours by colons.'));
}
}
} else {
$ok = false;
error(_('Please select a mode.'));
}
if (isset($_REQUEST['angelmode'])) {
//.........这里部分代码省略.........
示例8: guest_register
function guest_register()
{
global $tshirt_sizes, $enable_tshirt_size, $default_theme;
$msg = "";
$nick = "";
$lastname = "";
$prename = "";
$age = "";
$tel = "";
$dect = "";
$mobile = "";
$mail = "";
$email_shiftinfo = false;
$jabber = "";
$hometown = "";
$comment = "";
$tshirt_size = '';
$password_hash = "";
$selected_angel_types = array();
$planned_arrival_date = null;
$angel_types_source = sql_select("SELECT * FROM `AngelTypes` ORDER BY `name`");
$angel_types = array();
foreach ($angel_types_source as $angel_type) {
$angel_types[$angel_type['id']] = $angel_type['name'] . ($angel_type['restricted'] ? " (restricted)" : "");
if (!$angel_type['restricted']) {
$selected_angel_types[] = $angel_type['id'];
}
}
if (isset($_REQUEST['submit'])) {
$ok = true;
if (isset($_REQUEST['nick']) && strlen(User_validate_Nick($_REQUEST['nick'])) > 1) {
$nick = User_validate_Nick($_REQUEST['nick']);
if (sql_num_query("SELECT * FROM `User` WHERE `Nick`='" . sql_escape($nick) . "' LIMIT 1") > 0) {
$ok = false;
$msg .= error(sprintf(_("Your nick "%s" already exists."), $nick), true);
}
} else {
$ok = false;
$msg .= error(sprintf(_("Your nick "%s" is too short (min. 2 characters)."), User_validate_Nick($_REQUEST['nick'])), true);
}
if (isset($_REQUEST['mail']) && strlen(strip_request_item('mail')) > 0) {
$mail = strip_request_item('mail');
if (!check_email($mail)) {
$ok = false;
$msg .= error(_("E-mail address is not correct."), true);
}
} else {
$ok = false;
$msg .= error(_("Please enter your e-mail."), true);
}
if (isset($_REQUEST['email_shiftinfo'])) {
$email_shiftinfo = true;
}
if (isset($_REQUEST['jabber']) && strlen(strip_request_item('jabber')) > 0) {
$jabber = strip_request_item('jabber');
if (!check_email($jabber)) {
$ok = false;
$msg .= error(_("Please check your jabber account information."), true);
}
}
if ($enable_tshirt_size) {
if (isset($_REQUEST['tshirt_size']) && isset($tshirt_sizes[$_REQUEST['tshirt_size']]) && $_REQUEST['tshirt_size'] != '') {
$tshirt_size = $_REQUEST['tshirt_size'];
} else {
$ok = false;
$msg .= error(_("Please select your shirt size."), true);
}
}
if (isset($_REQUEST['password']) && strlen($_REQUEST['password']) >= MIN_PASSWORD_LENGTH) {
if ($_REQUEST['password'] != $_REQUEST['password2']) {
$ok = false;
$msg .= error(_("Your passwords don't match."), true);
}
} else {
$ok = false;
$msg .= error(sprintf(_("Your password is too short (please use at least %s characters)."), MIN_PASSWORD_LENGTH), true);
}
if (isset($_REQUEST['planned_arrival_date']) && DateTime::createFromFormat("Y-m-d", trim($_REQUEST['planned_arrival_date']))) {
$planned_arrival_date = DateTime::createFromFormat("Y-m-d", trim($_REQUEST['planned_arrival_date']))->getTimestamp();
} else {
$ok = false;
$msg .= error(_("Please enter your planned date of arrival."), true);
}
$selected_angel_types = array();
foreach ($angel_types as $angel_type_id => $angel_type_name) {
if (isset($_REQUEST['angel_types_' . $angel_type_id])) {
$selected_angel_types[] = $angel_type_id;
}
}
// Trivia
if (isset($_REQUEST['lastname'])) {
$lastname = strip_request_item('lastname');
}
if (isset($_REQUEST['prename'])) {
$prename = strip_request_item('prename');
}
if (isset($_REQUEST['age']) && preg_match("/^[0-9]{0,4}\$/", $_REQUEST['age'])) {
$age = strip_request_item('age');
}
if (isset($_REQUEST['tel'])) {
//.........这里部分代码省略.........
示例9: user_resend_verification_token
function user_resend_verification_token()
{
global $user, $privileges;
$success = false;
if (isset($_GET['uid'])) {
$uid = $_GET['uid'];
if (is_numeric($uid)) {
$user = User($uid);
if ($user != null && $user['user_account_approved'] == 0) {
// found user entry, check verification bit set? and send email
user_send_verification_email($user['email'], $user['mailaddress_verification_token']);
success(_("Verification E-Mail was send again to your E-Mail address. If you still don't receive it, please check your spam folder and ask a Dispatcher."));
$success = true;
}
}
} elseif (isset($_REQUEST['email']) && strlen(strip_request_item('email')) > 0) {
$email = strip_request_item('email');
if (check_email($email)) {
$user = User_by_email($email);
if ($user != null && $user['user_account_approved'] == 0) {
user_send_verification_email($user['email'], $user['mailaddress_verification_token']);
success(_("Verification E-Mail was send again to your E-Mail address. If you still don't receive it, please check your spam folder and ask a Dispatcher."));
$success = true;
}
}
} else {
// show page to input E-Mail
return User_request_verification_token_view();
}
$admin_priv = in_array('admin_user', $privileges);
if ($success == false) {
// failure, couldn't find user or something went wrong
error(_("Verification E-Mail Could not be send. Please ask a Dispatcher."));
}
if ($admin_priv && $success == true && isset($user) && isset($user['UID'])) {
redirect(user_link($user));
} else {
redirect('?');
}
}
示例10: shifttype_edit_controller
/**
* Edit or create shift type.
*/
function shifttype_edit_controller()
{
$shifttype_id = null;
$name = "";
$angeltype_id = null;
$description = "";
$angeltypes = AngelTypes();
if ($angeltypes === false) {
engelsystem_error("Unable to load angel types.");
}
if (isset($_REQUEST['shifttype_id'])) {
$shifttype = ShiftType($_REQUEST['shifttype_id']);
if ($shifttype === false) {
engelsystem_error('Unable to load shifttype.');
}
if ($shifttype == null) {
error(_('Shifttype not found.'));
redirect(page_link_to('shifttypes'));
}
$shifttype_id = $shifttype['id'];
$name = $shifttype['name'];
$angeltype_id = $shifttype['angeltype_id'];
$description = $shifttype['description'];
}
if (isset($_REQUEST['submit'])) {
$ok = true;
if (isset($_REQUEST['name']) && $_REQUEST['name'] != '') {
$name = strip_request_item('name');
} else {
$ok = false;
error(_('Please enter a name.'));
}
if (isset($_REQUEST['angeltype_id']) && preg_match("/^[0-9]+\$/", $_REQUEST['angeltype_id'])) {
$angeltype_id = $_REQUEST['angeltype_id'];
} else {
$angeltype_id = null;
}
if (isset($_REQUEST['description'])) {
$description = strip_request_item_nl('description');
}
if ($ok) {
if ($shifttype_id) {
$result = ShiftType_update($shifttype_id, $name, $angeltype_id, $description);
if ($result === false) {
engelsystem_error('Unable to update shifttype.');
}
engelsystem_log('Updated shifttype ' . $name);
success(_('Updated shifttype.'));
} else {
$shifttype_id = ShiftType_create($name, $angeltype_id, $description);
if ($shifttype_id === false) {
engelsystem_error('Unable to create shifttype.');
}
engelsystem_log('Created shifttype ' . $name);
success(_('Created shifttype.'));
}
redirect(page_link_to('shifttypes') . '&action=view&shifttype_id=' . $shifttype_id);
}
}
return [shifttypes_title(), ShiftType_edit_view($name, $angeltype_id, $angeltypes, $description, $shifttype_id)];
}
示例11: guest_register
function guest_register()
{
global $default_theme, $genders;
$msg = "";
$nick = "";
$lastname = "";
$prename = "";
$age = "";
$tel = "";
$mobile = "";
$mail = "";
$email_shiftinfo = false;
$hometown = "";
$comment = "";
$password_hash = "";
$selected_angel_types = array();
$gender = "none";
$angel_types_source = sql_select("SELECT * FROM `AngelTypes` ORDER BY `name`");
$angel_types = array();
foreach ($angel_types_source as $angel_type) {
$angel_types[$angel_type['id']] = $angel_type['name'] . ($angel_type['restricted'] ? " (restricted)" : "");
if (!$angel_type['restricted']) {
$selected_angel_types[] = $angel_type['id'];
}
}
if (isset($_REQUEST['submit'])) {
$ok = true;
if (isset($_REQUEST['nick']) && strlen(User_validate_Nick($_REQUEST['nick'])) > 1) {
$nick = User_validate_Nick($_REQUEST['nick']);
if (sql_num_query("SELECT * FROM `User` WHERE `Nick`='" . sql_escape($nick) . "' LIMIT 1") > 0) {
$ok = false;
$msg .= error(sprintf(_("Your nick "%s" already exists."), $nick), true);
}
} else {
$ok = false;
$msg .= error(sprintf(_("Your nick "%s" is too short (min. 2 characters)."), User_validate_Nick($_REQUEST['nick'])), true);
}
if (isset($_REQUEST['mail']) && strlen(strip_request_item('mail')) > 0) {
$mail = strip_request_item('mail');
if (!check_email($mail)) {
$ok = false;
$msg .= error(_("E-mail address is not correct."), true);
}
} else {
$ok = false;
$msg .= error(_("Please enter your e-mail."), true);
}
if (isset($_REQUEST['email_shiftinfo'])) {
$email_shiftinfo = true;
}
if (isset($_REQUEST['password']) && strlen($_REQUEST['password']) >= MIN_PASSWORD_LENGTH) {
if ($_REQUEST['password'] != $_REQUEST['password2']) {
$ok = false;
$msg .= error(_("Your passwords don't match."), true);
}
} else {
$ok = false;
$msg .= error(sprintf(_("Your password is too short (please use at least %s characters)."), MIN_PASSWORD_LENGTH), true);
}
$selected_angel_types = array();
foreach ($angel_types as $angel_type_id => $angel_type_name) {
if (isset($_REQUEST['angel_types_' . $angel_type_id])) {
$selected_angel_types[] = $angel_type_id;
}
}
// Trivia
if (isset($_REQUEST['lastname'])) {
$lastname = strip_request_item('lastname');
}
if (isset($_REQUEST['prename'])) {
$prename = strip_request_item('prename');
}
if (isset($_REQUEST['age']) && preg_match("/^[0-9]{0,4}\$/", $_REQUEST['age'])) {
$age = strip_request_item('age');
}
if (isset($_REQUEST['tel'])) {
$tel = strip_request_item('tel');
}
if (isset($_REQUEST['mobile'])) {
$mobile = strip_request_item('mobile');
}
if (isset($_REQUEST['hometown'])) {
$hometown = strip_request_item('hometown');
}
if (isset($_REQUEST['comment'])) {
$comment = strip_request_item_nl('comment');
}
if (isset($_REQUEST['gender']) && array_key_exists($_REQUEST['gender'], $genders)) {
$gender = $_REQUEST['gender'];
}
if ($ok) {
$confirmationToken = bin2hex(mcrypt_create_iv(16, MCRYPT_DEV_URANDOM));
$confirmationTokenUrl = page_link_to_absolute('user_activate_account') . '&token=' . $confirmationToken;
sql_query("\n INSERT INTO `User` SET \n `color`='" . sql_escape($default_theme) . "', \n `Nick`='" . sql_escape($nick) . "', \n `Vorname`='" . sql_escape($prename) . "', \n `Name`='" . sql_escape($lastname) . "', \n `Alter`='" . sql_escape($age) . "', \n `gender`='" . sql_escape($gender) . "',\n `Telefon`='" . sql_escape($tel) . "', \n `Handy`='" . sql_escape($mobile) . "', \n `email`='" . sql_escape($mail) . "', \n `email_shiftinfo`=" . sql_bool($email_shiftinfo) . ", \n `Passwort`='" . sql_escape($password_hash) . "', \n `kommentar`='" . sql_escape($comment) . "', \n `Hometown`='" . sql_escape($hometown) . "', \n `CreateDate`=NOW(), \n `Sprache`='" . sql_escape($_SESSION["locale"]) . "',\n `arrival_date`=NULL,\n `planned_arrival_date`= 0,\n `mailaddress_verification_token` = '" . sql_escape($confirmationToken) . "',\n `user_account_approved` = 0");
// Assign user-group and set password
$user_id = sql_id();
sql_query("INSERT INTO `UserGroups` SET `uid`='" . sql_escape($user_id) . "', `group_id`=-2");
set_password($user_id, $_REQUEST['password']);
// Assign angel-types
$user_angel_types_info = array();
//.........这里部分代码省略.........
示例12: user_password_recovery_controller
/**
* User password recovery.
* (By email)
*/
function user_password_recovery_controller()
{
if (isset($_REQUEST['token'])) {
$user_source = User_by_password_recovery_token($_REQUEST['token']);
if ($user_source === false) {
engelsystem_error("Unable to load user.");
}
if ($user_source == null) {
error(_("Token is not correct."));
redirect(page_link_to('login'));
}
if (isset($_REQUEST['submit'])) {
$ok = true;
if (isset($_REQUEST['password']) && strlen($_REQUEST['password']) >= MIN_PASSWORD_LENGTH) {
if ($_REQUEST['password'] != $_REQUEST['password2']) {
$ok = false;
error(_("Your passwords don't match."));
}
} else {
$ok = false;
error(_("Your password is to short (please use at least 6 characters)."));
}
if ($ok) {
$result = set_password($user_source['UID'], $_REQUEST['password']);
if ($result === false) {
engelsystem_error(_("Password could not be updated."));
}
success(_("Password saved."));
redirect(page_link_to('login'));
}
}
return User_password_set_view();
} else {
if (isset($_REQUEST['submit'])) {
$ok = true;
if (isset($_REQUEST['email']) && strlen(strip_request_item('email')) > 0) {
$email = strip_request_item('email');
if (check_email($email)) {
$user_source = User_by_email($email);
if ($user_source === false) {
engelsystem_error("Unable to load user.");
}
if ($user_source == null) {
$ok = false;
error(_("E-mail address is not correct."));
}
} else {
$ok = false;
error(_("E-mail address is not correct."));
}
} else {
$ok = false;
error(_("Please enter your e-mail."));
}
if ($ok) {
$token = User_generate_password_recovery_token($user_source);
if ($token === false) {
engelsystem_error("Unable to generate password recovery token.");
}
$result = engelsystem_email_to_user($user_source, _("Password recovery"), sprintf(_("Please visit %s to recover your password."), page_link_to_absolute('user_password_recovery') . '&token=' . $token));
if ($result === false) {
engelsystem_error("Unable to send password recovery email.");
}
success(_("We sent an email containing your password recovery link."));
redirect(page_link_to('login'));
}
}
return User_password_recovery_view();
}
}
示例13: admin_arrive
function admin_arrive()
{
$msg = "";
$search = "";
if (isset($_REQUEST['search'])) {
$search = strip_request_item('search');
}
if (isset($_REQUEST['reset']) && preg_match("/^[0-9]*\$/", $_REQUEST['reset'])) {
$id = $_REQUEST['reset'];
$user_source = User($id);
if ($user_source != null) {
sql_query("UPDATE `User` SET `Gekommen`=0, `arrival_date` = NULL WHERE `UID`='" . sql_escape($id) . "' LIMIT 1");
engelsystem_log("User set to not arrived: " . User_Nick_render($user_source));
$msg = success(_("Reset done. Angel has not arrived."), true);
} else {
$msg = error(_("Angel not found."), true);
}
} elseif (isset($_REQUEST['arrived']) && preg_match("/^[0-9]*\$/", $_REQUEST['arrived'])) {
$id = $_REQUEST['arrived'];
$user_source = User($id);
if ($user_source != null) {
sql_query("UPDATE `User` SET `Gekommen`=1, `arrival_date`='" . time() . "' WHERE `UID`='" . sql_escape($id) . "' LIMIT 1");
engelsystem_log("User set has arrived: " . User_Nick_render($user_source));
$msg = success(_("Angel has been marked as arrived."), true);
} else {
$msg = error(_("Angel not found."), true);
}
}
$users = sql_select("SELECT * FROM `User` ORDER BY `Nick`");
$arrival_count_at_day = array();
$table = "";
$users_matched = array();
if ($search == "") {
$tokens = array();
} else {
$tokens = explode(" ", $search);
}
foreach ($users as $usr) {
if (count($tokens) > 0) {
$match = false;
$index = join(" ", $usr);
foreach ($tokens as $t) {
if (stristr($index, trim($t))) {
$match = true;
break;
}
}
if (!$match) {
continue;
}
}
$usr['nick'] = User_Nick_render($usr);
$usr['rendered_planned_arrival_date'] = date('Y-m-d', $usr['planned_arrival_date']);
$usr['rendered_arrival_date'] = $usr['arrival_date'] > 0 ? date('Y-m-d', $usr['arrival_date']) : "-";
$usr['arrived'] = $usr['Gekommen'] == 1 ? _("yes") : "";
$usr['actions'] = $usr['Gekommen'] == 1 ? '<a href="' . page_link_to('admin_arrive') . '&reset=' . $usr['UID'] . '&search=' . $search . '">' . _("reset") . '</a>' : '<a href="' . page_link_to('admin_arrive') . '&arrived=' . $usr['UID'] . '&search=' . $search . '">' . _("arrived") . '</a>';
$day = $usr['arrival_date'] > 0 ? date('Y-m-d', $usr['arrival_date']) : date('Y-m-d', $usr['planned_arrival_date']);
if (!isset($arrival_count_at_day[$day])) {
$arrival_count_at_day[$day] = 0;
}
$arrival_count_at_day[$day]++;
$users_matched[] = $usr;
}
ksort($arrival_count_at_day);
$arrival_count = array();
$arrival_sums = array();
$arrival_sum = 0;
foreach ($arrival_count_at_day as $day => $count) {
$arrival_sum += $count;
$arrival_sums[$day] = $arrival_sum;
$arrival_count[] = array('day' => $day, 'count' => $count, 'sum' => $arrival_sum);
}
return page_with_title(admin_arrive_title(), array(msg(), form(array(form_text('search', _("Search"), $search), form_submit('submit', _("Search")))), table(array('nick' => _("Nickname"), 'rendered_planned_arrival_date' => _("Planned date"), 'arrived' => _("Arrived?"), 'rendered_arrival_date' => _("Arrival date"), 'actions' => ""), $users_matched), heading(_("Arrival statistics"), 2), '<canvas id="daily_arrives" style="width: 100%; height: 300px;"></canvas>
<script type="text/javascript">
$(function(){
var ctx = $("#daily_arrives").get(0).getContext("2d");
var chart = new Chart(ctx).Bar(' . json_encode(array('labels' => array_keys($arrival_count_at_day), 'datasets' => array(array('label' => _("arrived"), 'fillColor' => "#444", 'data' => array_values($arrival_count_at_day)), array('label' => _("arrived sum"), 'fillColor' => "#888", 'data' => array_values($arrival_sums))))) . ');
});
</script>', table(array('day' => _("Date"), 'count' => _("arrived"), 'sum' => _("arrived sum")), $arrival_count)));
}
示例14: admin_arrive
function admin_arrive()
{
$msg = "";
$search = "";
if (isset($_REQUEST['search'])) {
$search = strip_request_item('search');
}
if (isset($_REQUEST['reset']) && preg_match("/^[0-9]*\$/", $_REQUEST['reset'])) {
$id = $_REQUEST['reset'];
$user_source = User($id);
if ($user_source != null) {
sql_query("UPDATE `User` SET `Gekommen`=0, `arrival_date` = NULL WHERE `UID`='" . sql_escape($id) . "' LIMIT 1");
engelsystem_log("User set to not arrived: " . User_Nick_render($user_source));
$msg = success(_("Reset done. Angel has not arrived."), true);
} else {
$msg = error(_("Angel not found."), true);
}
} elseif (isset($_REQUEST['arrived']) && preg_match("/^[0-9]*\$/", $_REQUEST['arrived'])) {
$id = $_REQUEST['arrived'];
$user_source = User($id);
if ($user_source != null) {
sql_query("UPDATE `User` SET `Gekommen`=1, `arrival_date`='" . time() . "' WHERE `UID`='" . sql_escape($id) . "' LIMIT 1");
engelsystem_log("User set has arrived: " . User_Nick_render($user_source));
$msg = success(_("Angel has been marked as arrived."), true);
} else {
$msg = error(_("Angel not found."), true);
}
}
$users = sql_select("SELECT * FROM `User` ORDER BY `Nick`");
$table = "";
$users_matched = array();
if ($search == "") {
$tokens = array();
} else {
$tokens = explode(" ", $search);
}
foreach ($users as $usr) {
if (count($tokens) > 0) {
$match = false;
$index = join(" ", $usr);
foreach ($tokens as $t) {
if (stristr($index, trim($t))) {
$match = true;
break;
}
}
if (!$match) {
continue;
}
}
$table .= '<tr>';
$table .= '<td>' . User_Nick_render($usr) . '</td>';
$usr['nick'] = User_Nick_render($usr);
$usr['planned_arrival_date'] = date('Y-m-d', $usr['planned_arrival_date']);
$usr['arrival_date'] = $usr['arrival_date'] > 0 ? date('Y-m-d', $usr['arrival_date']) : "-";
$usr['arrived'] = $usr['Gekommen'] == 1 ? _("yes") : "";
$usr['actions'] = $usr['Gekommen'] == 1 ? '<a href="' . page_link_to('admin_arrive') . '&reset=' . $usr['UID'] . '&search=' . $search . '">' . _("reset") . '</a>' : '<a href="' . page_link_to('admin_arrive') . '&arrived=' . $usr['UID'] . '&search=' . $search . '">' . _("arrived") . '</a>';
if ($usr['Gekommen'] == 1) {
$table .= '<td>yes</td><td><a href="' . page_link_to('admin_arrive') . '&reset=' . $usr['UID'] . '&search=' . $search . '">reset</a></td>';
} else {
$table .= '<td></td><td><a href="' . page_link_to('admin_arrive') . '&arrived=' . $usr['UID'] . '&search=' . $search . '">arrived</a></td>';
}
$table .= '</tr>';
$users_matched[] = $usr;
}
return page_with_title(admin_arrive_title(), array(msg(), form(array(form_text('search', _("Search"), $search), form_submit('submit', _("Search")))), table(array('nick' => _("Nickname"), 'planned_arrival_date' => _("Planned date"), 'arrived' => _("Arrived?"), 'arrival_date' => _("Arrival date"), 'actions' => ""), $users_matched)));
}
示例15: admin_rooms
function admin_rooms()
{
global $user;
global $user, $enable_frab_import;
$rooms_source = sql_select("SELECT * FROM `Room` ORDER BY `Name`");
$rooms = array();
foreach ($rooms_source as $room) {
$rooms[] = array('name' => $room['Name'], 'from_pentabarf' => $room['FromPentabarf'] == 'Y' ? '✓' : '', 'public' => $room['show'] == 'Y' ? '✓' : '', 'actions' => buttons(array(button(page_link_to('admin_rooms') . '&show=edit&id=' . $room['RID'], _("edit"), 'btn-xs'), button(page_link_to('admin_rooms') . '&show=delete&id=' . $room['RID'], _("delete"), 'btn-xs'))));
}
if (isset($_REQUEST['show'])) {
$msg = "";
$name = "";
$location = "";
$lat = "";
$long = "";
$from_pentabarf = "";
$public = 'Y';
$number = "";
$angeltypes_source = sql_select("SELECT * FROM `AngelTypes` ORDER BY `name`");
$angeltypes = array();
$angeltypes_count = array();
foreach ($angeltypes_source as $angeltype) {
$angeltypes[$angeltype['id']] = $angeltype['name'];
$angeltypes_count[$angeltype['id']] = 0;
}
if (test_request_int('id')) {
$room = sql_select("SELECT * FROM `Room` WHERE `RID`='" . sql_escape($_REQUEST['id']) . "'");
if (count($room) > 0) {
$id = $_REQUEST['id'];
$name = $room[0]['Name'];
$location = $room[0]['Location'];
$lat = $room[0]['Lat'];
$long = $room[0]['Long'];
$from_pentabarf = $room[0]['FromPentabarf'];
$public = $room[0]['show'];
$needed_angeltypes = sql_select("SELECT * FROM `NeededAngelTypes` WHERE `room_id`='" . sql_escape($id) . "'");
foreach ($needed_angeltypes as $needed_angeltype) {
$angeltypes_count[$needed_angeltype['angel_type_id']] = $needed_angeltype['count'];
}
} else {
redirect(page_link_to('admin_rooms'));
}
}
if ($_REQUEST['show'] == 'edit') {
if (isset($_REQUEST['submit'])) {
$ok = true;
if (isset($_REQUEST['name']) && strlen(strip_request_item('name')) > 0) {
$name = strip_request_item('name');
} else {
$ok = false;
$msg .= error(_("Please enter a name."), true);
}
if (isset($_REQUEST['location']) && strlen(strip_request_item('location')) > 0) {
$location = strip_request_item('location');
} else {
$ok = false;
$msg .= error(_("Please enter a location."));
}
if (isset($_REQUEST['Lat']) && isset($_REQUEST['Long'])) {
$lat = $_REQUEST['Lat'];
$long = $_REQUEST['Long'];
} else {
$ok = false;
$msg .= error(_("Please enter a location - no lat long values found."));
}
$from_pentabarf = isset($_REQUEST['from_pentabarf']) ? 'Y' : '';
$public = isset($_REQUEST['public']) ? 'Y' : '';
if (isset($_REQUEST['number'])) {
$number = strip_request_item('number');
} else {
$ok = false;
}
foreach ($angeltypes as $angeltype_id => $angeltype) {
if (isset($_REQUEST['angeltype_count_' . $angeltype_id]) && preg_match("/^[0-9]{1,4}\$/", $_REQUEST['angeltype_count_' . $angeltype_id])) {
$angeltypes_count[$angeltype_id] = $_REQUEST['angeltype_count_' . $angeltype_id];
} else {
$ok = false;
$msg .= error(sprintf(_("Please enter needed angels for type %s.", $angeltype)), true);
}
}
if ($ok) {
if (isset($id)) {
sql_query(sprintf("UPDATE `Room` SET `Name`='%s', `FromPentabarf`='%s', `show`='%s', `Number`='%s', `location` = '%s', `lat` = '%s', `long` = '%s' WHERE `RID`='%s' LIMIT 1", sql_escape($name), sql_escape($from_pentabarf), sql_escape($public), sql_escape($number), sql_escape($location), sql_escape($lat), sql_escape($long), sql_escape($id)));
engelsystem_log("Location updated: " . $name . ", pentabarf import: " . $from_pentabarf . ", public: " . $public . ", number: " . $number);
} else {
$id = Room_create($name, $from_pentabarf, $public, $location, $lat, $long);
if ($id === false) {
engelsystem_error("Unable to create location.");
}
engelsystem_log("Location created: " . $name . ", pentabarf import: " . $from_pentabarf . ", public: " . $public . ", number: " . $number);
}
sql_query("DELETE FROM `NeededAngelTypes` WHERE `room_id`='" . sql_escape($id) . "'");
$needed_angeltype_info = array();
foreach ($angeltypes_count as $angeltype_id => $angeltype_count) {
$angeltype = AngelType($angeltype_id);
if ($angeltype === false) {
engelsystem_error("Unable to load angeltype.");
}
if ($angeltype != null) {
sql_query(sprintf("INSERT INTO `NeededAngelTypes` SET `room_id`='%s', `angel_type_id`='%s', `count`='%s'", sql_escape($id), sql_escape($angeltype_id), sql_escape($angeltype_count)));
//.........这里部分代码省略.........