本文整理汇总了PHP中sql_num_query函数的典型用法代码示例。如果您正苦于以下问题:PHP sql_num_query函数的具体用法?PHP sql_num_query怎么用?PHP sql_num_query使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sql_num_query函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: admin_new_questions
function admin_new_questions()
{
global $user, $privileges;
if (in_array("admin_questions", $privileges)) {
$new_messages = sql_num_query("SELECT * FROM `Questions` WHERE `AID` IS NULL");
if ($new_messages > 0) {
return info('<a href="' . page_link_to("admin_questions") . '">' . _('There are unanswered questions!') . '</a>', true);
}
}
return "";
}
示例2: user_unread_messages
function user_unread_messages()
{
global $user;
if (isset($user)) {
$new_messages = sql_num_query("SELECT * FROM `Messages` WHERE isRead='N' AND `RUID`='" . sql_escape($user['UID']) . "'");
if ($new_messages > 0) {
return ' <span class="badge danger">' . $new_messages . '</span>';
}
}
return '';
}
示例3: Message_send
/**
* TODO: use validation functions, return new message id
* TODO: global $user con not be used in model!
* send message
*
* @param $id User
* ID of Reciever
* @param $text Text
* of Message
*/
function Message_send($id, $text)
{
global $user;
$text = preg_replace("/([^\\p{L}\\p{P}\\p{Z}\\p{N}\n]{1,})/ui", '', strip_tags($text));
$to = preg_replace("/([^0-9]{1,})/ui", '', strip_tags($id));
if ($text != "" && is_numeric($to) && sql_num_query("SELECT * FROM `User` WHERE `UID`='" . sql_escape($to) . "' AND NOT `UID`='" . sql_escape($user['UID']) . "' LIMIT 1") > 0) {
sql_query("INSERT INTO `Messages` SET `Datum`='" . sql_escape(time()) . "', `SUID`='" . sql_escape($user['UID']) . "', `RUID`='" . sql_escape($to) . "', `Text`='" . sql_escape($text) . "'");
return true;
} else {
return false;
}
}
示例4: AngelType_validate_name
/**
* Validates a name for angeltypes.
* Returns array containing validation success and validated name.
*
* @param string $name
* @param AngelType $angeltype
*/
function AngelType_validate_name($name, $angeltype)
{
$name = strip_item($name);
if ($name == "") {
return array(false, $name);
}
if (isset($angeltype) && isset($angeltype['id'])) {
return array(sql_num_query("\n SELECT * \n FROM `AngelTypes` \n WHERE `name`='" . sql_escape($name) . "' \n AND NOT `id`='" . sql_escape($angeltype['id']) . "'\n LIMIT 1") == 0, $name);
} else {
return array(sql_num_query("\n SELECT `id` \n FROM `AngelTypes` \n WHERE `name`='" . sql_escape($name) . "' \n LIMIT 1") == 0, $name);
}
}
示例5: _add_index
function _add_index($table, $cols, $type = "INDEX")
{
$table = sql_escape($table);
$cols = array_map('sql_escape', $cols);
$type = sql_escape($type);
if (sql_num_query("SHOW INDEX FROM `" . $table . "` WHERE `Key_name` = '" . $cols[0] . "'") == 0) {
sql_query("ALTER TABLE `" . $table . "` ADD " . $type . " (`" . implode($cols, '`,`') . "`)");
global $applied;
$applied = true;
return true;
} else {
return false;
}
}
示例6: 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'])) {
//.........这里部分代码省略.........
示例7: User_is_AngelType_coordinator
/**
* Returns true if user is angeltype coordinator or has privilege admin_user_angeltypes.
*
* @param User $user
* @param AngelType $angeltype
*/
function User_is_AngelType_coordinator($user, $angeltype)
{
return sql_num_query("\n SELECT `id` \n FROM `UserAngelTypes` \n WHERE `user_id`='" . sql_escape($user['UID']) . "'\n AND `angeltype_id`='" . sql_escape($angeltype['id']) . "'\n AND `coordinator`=TRUE\n LIMIT 1") > 0 || in_array('admin_user_angeltypes', privileges_for_user($user['UID']));
}
示例8: _rename_table
<?php
// Most complex update yet. Let's go...
_rename_table("UserGroups", "Groups");
if (sql_num_query("SHOW TABLES LIKE 'UserCVS'") === 1 && sql_num_query("SHOW TABLES LIKE 'UserGroups'") === 0) {
// First of all, create a separate table for group assignments of users
sql_query("CREATE TABLE `UserGroups` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n `uid` int(11) NOT NULL,\n `group_id` int(11) NOT NULL,\n PRIMARY KEY (`id`),\n KEY `uid` (`uid`,`group_id`),\n KEY `group_id` (`group_id`)\n )");
// ...and fill it with the old data
sql_query("INSERT INTO UserGroups (`uid`, `group_id`) SELECT `UID`, `GroupID` FROM `UserCVS` WHERE `UID` > 0");
if (sql_num_query("SHOW TABLES LIKE 'Privileges'") == 0) {
// Then create a separate table that stores the available privileges...
sql_query("CREATE TABLE IF NOT EXISTS `Privileges` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n `name` varchar(128) NOT NULL,\n `desc` varchar(1024) NOT NULL,\n PRIMARY KEY (`id`),\n UNIQUE KEY `name` (`name`)\n )");
// ...and fill it with genuine data. We cannot determine these from the old data!
sql_query("INSERT INTO `Privileges` (`id`, `name`, `desc`) VALUES\n (1, 'start', 'Startseite für Gäste/Nicht eingeloggte User'),\n (2, 'login', 'Logindialog'),\n (3, 'news', 'Anzeigen der News-Seite'),\n (4, 'logout', 'User darf sich ausloggen'),\n (5, 'register', 'Einen neuen Engel registerieren'),\n (6, 'admin_rooms', 'Orte administrieren'),\n (7, 'admin_angel_types', 'Engel Typen administrieren'),\n (8, 'user_settings', 'User profile settings'),\n (9, 'user_messages', 'Writing and reading messages from user to user'),\n (10, 'admin_groups', 'Manage usergroups and their rights'),\n (11, 'user_questions', 'Let users ask questions'),\n (12, 'admin_questions', 'Answer user''s questions'),\n (13, 'admin_faq', 'Edit FAQs'),\n (14, 'admin_news', 'Administrate the news section'),\n (15, 'news_comments', 'User can comment news'),\n (16, 'admin_user', 'Administrate the angels'),\n (17, 'user_meetings', 'Lists meetings (news)'),\n (18, 'admin_language', 'Translate the system'),\n (19, 'admin_log', 'Display recent changes'),\n (20, 'user_wakeup', 'User wakeup-service organization'),\n (21, 'admin_import', 'Import locations and shifts from pentabarf'),\n (22, 'credits', 'View credits'),\n (23, 'faq', 'View FAQ'),\n (24, 'user_shifts', 'Signup for shifts'),\n (25, 'user_shifts_admin', 'Signup other angels for shifts.'),\n (26, 'user_myshifts', 'Allow angels to view their own shifts and cancel them.'),\n (27, 'admin_arrive', 'Mark angels when they are available.'),\n (28, 'admin_shifts', 'Create shifts'),\n (30, 'ical', 'iCal shift export'),\n (31, 'admin_active', 'Mark angels as active and if they got a t-shirt.'),\n (32, 'admin_free', 'Show a list of free/unemployed angels.'),\n (39, 'faq2', 'View FAQ'),\n (40, 'imprint', 'View imprint'),\n (41, 'privacy', 'View privacy statement')\n ");
}
if (sql_num_query("SHOW TABLES LIKE 'GroupPrivileges'") == 0) {
// Last, we create the table for the privileges a group can have
sql_query("CREATE TABLE `GroupPrivileges` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n `group_id` int(11) NOT NULL,\n `privilege_id` int(11) NOT NULL,\n PRIMARY KEY (`id`),\n KEY `group_id` (`group_id`,`privilege_id`)\n )");
// ...and fill it with data.
/// XXX: We could determine this from the old UserCVS table, at lease partially!
sqL_query("INSERT INTO `GroupPrivileges` (`id`, `group_id`, `privilege_id`) VALUES\n (107, -2, 24),\n (24, -1, 5),\n (106, -2, 8),\n (105, -2, 11),\n (23, -1, 2),\n (142, -5, 16),\n (141, -5, 28),\n (104, -2, 26),\n (103, -2, 9),\n (86, -6, 21),\n (140, -5, 6),\n (139, -5, 12),\n (102, -2, 17),\n (138, -5, 14),\n (137, -5, 13),\n (136, -5, 7),\n (101, -2, 15),\n (87, -6, 18),\n (100, -2, 3),\n (85, -6, 10),\n (99, -2, 4),\n (88, -1, 1),\n (133, -3, 32),\n (108, -2, 20),\n (109, -4, 27),\n (135, -5, 31),\n (134, -3, 25),\n (143, -5, 5),\n (260, -1, 39),\n (261, -1, 40),\n (262, -1, 41);");
}
/* Hardest things last: We need to transform the old column-based system
* with filename-based permissions to the new privileges system.
*
* For that to work, we need a manual mapping filename -> privilege, so we
* can use the old data. So here we go:
*/
#$files_to_privileges = array(
# "index.php" => "start",
# "logout.php" => "logout",
示例9: user_myshifts
function user_myshifts()
{
global $LETZTES_AUSTRAGEN;
global $user, $privileges;
$msg = "";
if (isset($_REQUEST['id']) && in_array("user_shifts_admin", $privileges) && preg_match("/^[0-9]{1,}\$/", $_REQUEST['id']) && sql_num_query("SELECT * FROM `User` WHERE `UID`='" . sql_escape($_REQUEST['id']) . "'") > 0) {
$id = $_REQUEST['id'];
} else {
$id = $user['UID'];
}
list($shifts_user) = sql_select("SELECT * FROM `User` WHERE `UID`='" . sql_escape($id) . "' LIMIT 1");
if (isset($_REQUEST['reset'])) {
if ($_REQUEST['reset'] == "ack") {
User_reset_api_key($user);
success(_("Key changed."));
redirect(page_link_to('user_myshifts'));
}
return page_with_title(_("Reset API key"), array(error(_("If you reset the key, the url to your iCal- and JSON-export and your atom feed changes! You have to update it in every application using one of these exports."), true), button(page_link_to('user_myshifts') . '&reset=ack', _("Continue"), 'btn-danger')));
} elseif (isset($_REQUEST['edit']) && preg_match("/^[0-9]*\$/", $_REQUEST['edit'])) {
$id = $_REQUEST['edit'];
$shift = sql_select("SELECT\n `ShiftEntry`.`freeloaded`,\n `ShiftEntry`.`freeload_comment`,\n `ShiftEntry`.`Comment`,\n `ShiftEntry`.`UID`,\n `ShiftTypes`.`name`,\n `Shifts`.*,\n `Room`.`Name`,\n `AngelTypes`.`name` as `angel_type`\n FROM `ShiftEntry`\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($id) . "'\n AND `UID`='" . sql_escape($shifts_user['UID']) . "' LIMIT 1");
if (count($shift) > 0) {
$shift = $shift[0];
if (isset($_REQUEST['submit'])) {
$freeloaded = $shift['freeloaded'];
$freeload_comment = $shift['freeload_comment'];
if (in_array("user_shifts_admin", $privileges)) {
$freeloaded = isset($_REQUEST['freeloaded']);
$freeload_comment = strip_request_item_nl('freeload_comment');
}
$comment = strip_request_item_nl('comment');
$user_source = User($shift['UID']);
$result = ShiftEntry_update(array('id' => $id, 'Comment' => $comment, 'freeloaded' => $freeloaded, 'freeload_comment' => $freeload_comment));
if ($result === false) {
engelsystem_error('Unable to update shift entr.');
}
engelsystem_log("Updated " . User_Nick_render($user_source) . "'s shift " . $shift['name'] . " from " . date("Y-m-d H:i", $shift['start']) . " to " . date("Y-m-d H:i", $shift['end']) . " with comment " . $comment . ". Freeloaded: " . ($freeloaded ? "YES Comment: " . $freeload_comment : "NO"));
success(_("Shift saved."));
redirect(page_link_to('users') . '&action=view&user_id=' . $shifts_user['UID']);
}
return ShiftEntry_edit_view(User_Nick_render($shifts_user), date("Y-m-d H:i", $shift['start']) . ', ' . shift_length($shift), $shift['Name'], $shift['name'], $shift['angel_type'], $shift['Comment'], $shift['freeloaded'], $shift['freeload_comment'], in_array("user_shifts_admin", $privileges));
} else {
redirect(page_link_to('user_myshifts'));
}
} elseif (isset($_REQUEST['cancel']) && preg_match("/^[0-9]*\$/", $_REQUEST['cancel'])) {
$id = $_REQUEST['cancel'];
$shift = sql_select("\n SELECT *\n FROM `Shifts` \n INNER JOIN `ShiftEntry` USING (`SID`) \n WHERE `ShiftEntry`.`id`='" . sql_escape($id) . "' AND `UID`='" . sql_escape($shifts_user['UID']) . "'");
if (count($shift) > 0) {
$shift = $shift[0];
if ($shift['start'] > time() + $LETZTES_AUSTRAGEN * 3600 || in_array('user_shifts_admin', $privileges)) {
$result = ShiftEntry_delete($id);
if ($result === false) {
engelsystem_error('Unable to delete shift entry.');
}
$room = Room($shift['RID']);
$angeltype = AngelType($shift['TID']);
$shifttype = ShiftType($shift['shifttype_id']);
engelsystem_log("Deleted own shift: " . $shifttype['name'] . " at " . $room['Name'] . " from " . date("Y-m-d H:i", $shift['start']) . " to " . date("Y-m-d H:i", $shift['end']) . " as " . $angeltype['name']);
success(_("You have been signed off from the shift."));
} else {
error(_("It's too late to sign yourself off the shift. If neccessary, ask the dispatcher to do so."));
}
} else {
redirect(user_link($shifts_user));
}
}
redirect(page_link_to('users') . '&action=view');
}
示例10: user_news
function user_news()
{
global $DISPLAY_NEWS, $privileges, $user;
$html = '<div class="col-md-12"><h1>' . news_title() . '</h1>' . msg();
if (isset($_POST["text"]) && isset($_POST["betreff"]) && in_array("admin_news", $privileges)) {
if (!isset($_POST["treffen"]) || !in_array("admin_news", $privileges)) {
$_POST["treffen"] = 0;
}
sql_query("INSERT INTO `News` (`Datum`, `Betreff`, `Text`, `UID`, `Treffen`) " . "VALUES ('" . sql_escape(time()) . "', '" . sql_escape($_POST["betreff"]) . "', '" . sql_escape($_POST["text"]) . "', '" . sql_escape($user['UID']) . "', '" . sql_escape($_POST["treffen"]) . "');");
engelsystem_log("Created news: " . $_POST["betreff"] . ", treffen: " . $_POST["treffen"]);
success(_("Entry saved."));
redirect(page_link_to('news'));
}
if (isset($_REQUEST['page']) && preg_match("/^[0-9]{1,}\$/", $_REQUEST['page'])) {
$page = $_REQUEST['page'];
} else {
$page = 0;
}
$news = sql_select("SELECT * FROM `News` ORDER BY `Datum` DESC LIMIT " . sql_escape($page * $DISPLAY_NEWS) . ", " . sql_escape($DISPLAY_NEWS));
foreach ($news as $entry) {
$html .= display_news($entry);
}
$dis_rows = ceil(sql_num_query("SELECT * FROM `News`") / $DISPLAY_NEWS);
$html .= '<div class="text-center">' . '<ul class="pagination">';
for ($i = 0; $i < $dis_rows; $i++) {
if (isset($_REQUEST['page']) && $i == $_REQUEST['page']) {
$html .= '<li class="active">';
} elseif (!isset($_REQUEST['page']) && $i == 0) {
$html .= '<li class="active">';
} else {
$html .= '<li>';
}
$html .= '<a href="' . page_link_to("news") . '&page=' . $i . '">' . ($i + 1) . '</a></li>';
}
$html .= '</ul></div>';
if (in_array("admin_news", $privileges)) {
$html .= '<hr />';
$html .= '<h2>' . _("Create news:") . '</h2>';
$html .= form(array(form_text('betreff', _("Subject"), ''), form_textarea('text', _("Message"), ''), form_checkbox('treffen', _("Meeting"), false, 1), form_submit('submit', _("Save"))));
}
return $html . '</div>';
}
示例11: VALUES
<?php
// create admin_user_angeltypes permission/privilege and assign it to the archangel usergroup.
if (sql_num_query("SELECT * FROM `Privileges` WHERE `name`='admin_user_angeltypes'") == 0) {
sql_query("INSERT INTO `Privileges` (`id`, `name`, `desc`) VALUES ( NULL , 'admin_user_angeltypes', 'Confirm restricted angel types' );");
$id = sql_id();
sql_query("INSERT INTO `GroupPrivileges` SET `group_id`=-5, `privilege_id`='" . sql_escape($id) . "'");
sql_query("INSERT INTO `Sprache` (\n\t\t`TextID` ,\n\t\t`Sprache` ,\n\t\t`Text`\n\t\t)\n\t\tVALUES (\n\t\t'admin_user_angeltypes', 'DE', 'Engeltypen freischalten'\n\t\t), (\n\t\t'admin_user_angeltypes', 'EN', 'Confirm angeltypes'\n\t\t);");
$applied = true;
}
示例12: view_user_shifts
//.........这里部分代码省略.........
$shifts_table .= "</td>";
for ($j = 0; $j < $blocks && $i + $j < $maxshow; $j++) {
$todo[$rid][$i + $j]--;
}
}
}
}
// fill up row with empty <td>
while ($todo[$rid][$i]-- > 0) {
$shifts_table .= '<td class="empty"></td>';
}
}
$shifts_table .= "</tr>\n";
}
$shifts_table .= '</tbody></table></div>';
// qqq
} else {
$shifts_table = array();
foreach ($shifts as $shift) {
$info = array();
if ($_SESSION['user_shifts']['start_day'] != $_SESSION['user_shifts']['end_day']) {
$info[] = date("Y-m-d", $shift['start']);
}
$info[] = date("H:i", $shift['start']) . ' - ' . date("H:i", $shift['end']);
if (count($_SESSION['user_shifts']['rooms']) > 1) {
$info[] = Room_name_render(['Name' => $shift['room_name'], 'RID' => $shift['RID']]);
}
$shift_row = array('info' => join('<br />', $info), 'entries' => '<a href="' . shift_link($shift) . '">' . $shift['name'] . '</a>' . ($shift['title'] ? '<br />' . $shift['title'] : ''));
if (in_array('admin_shifts', $privileges)) {
$shift_row['info'] .= ' ' . table_buttons(array(button(page_link_to('user_shifts') . '&edit_shift=' . $shift['SID'], glyph('edit'), 'btn-xs'), button(page_link_to('user_shifts') . '&delete_shift=' . $shift['SID'], glyph('trash'), 'btn-xs')));
}
$shift_row['entries'] .= '<br />';
$is_free = false;
$shift_has_special_needs = 0 < sql_num_query("SELECT `id` FROM `NeededAngelTypes` WHERE `shift_id` = " . $shift['SID']);
$query = "SELECT `NeededAngelTypes`.`count`, `AngelTypes`.`id`, `AngelTypes`.`restricted`, `UserAngelTypes`.`confirm_user_id`, `AngelTypes`.`name`, `UserAngelTypes`.`user_id`\n FROM `NeededAngelTypes`\n JOIN `AngelTypes` ON (`NeededAngelTypes`.`angel_type_id` = `AngelTypes`.`id`)\n LEFT JOIN `UserAngelTypes` ON (`NeededAngelTypes`.`angel_type_id` = `UserAngelTypes`.`angeltype_id`AND `UserAngelTypes`.`user_id`='" . sql_escape($user['UID']) . "')\n WHERE ";
if ($shift_has_special_needs) {
$query .= "`shift_id` = '" . sql_escape($shift['SID']) . "'";
} else {
$query .= "`room_id` = '" . sql_escape($shift['RID']) . "'";
}
$query .= " AND `count` > 0 ";
if (!empty($_SESSION['user_shifts']['types'])) {
$query .= "AND `angel_type_id` IN (" . implode(',', $_SESSION['user_shifts']['types']) . ") ";
}
$query .= "ORDER BY `AngelTypes`.`name`";
$angeltypes = sql_select($query);
if (count($angeltypes) > 0) {
$my_shift = sql_num_query("SELECT * FROM `ShiftEntry` WHERE `SID`='" . sql_escape($shift['SID']) . "' AND `UID`='" . sql_escape($user['UID']) . "' LIMIT 1") > 0;
foreach ($angeltypes as &$angeltype) {
$entries = sql_select("SELECT * FROM `ShiftEntry` JOIN `User` ON (`ShiftEntry`.`UID` = `User`.`UID`) WHERE `SID`='" . sql_escape($shift['SID']) . "' AND `TID`='" . sql_escape($angeltype['id']) . "' ORDER BY `Nick`");
$entry_list = array();
$entry_nicks = [];
$freeloader = 0;
foreach ($entries as $entry) {
if (in_array('user_shifts_admin', $privileges)) {
$member = User_Nick_render($entry) . ' ' . table_buttons(array(button(page_link_to('user_shifts') . '&entry_id=' . $entry['id'], glyph('trash'), 'btn-xs')));
} else {
$member = User_Nick_render($entry);
}
if ($entry['freeloaded']) {
$member = '<strike>' . $member . '</strike>';
$freeloader++;
}
$entry_list[] = $member;
$entry_nicks[] = $entry['Nick'];
}
示例13: die
<?php
if (sql_num_query("SHOW COLUMNS FROM `Shifts` LIKE 'Date_'") == 2) {
if (sql_num_query("DESCRIBE `Shifts` `Len`") != 0) {
if (sql_num_query("SELECT * FROM `Shifts` WHERE DATE_SUB(`DateE`, INTERVAL (`Len`*60) MINUTE) != `DateS`") != 0) {
die("Inconsistent data in Shifts table, won't do update " . __FILE__);
} else {
sql_query("ALTER TABLE `Shifts` DROP `Len`");
}
}
_datetime_to_int("Shifts", "DateS");
_datetime_to_int("Shifts", "DateE");
sql_query("ALTER TABLE `Shifts` CHANGE `DateS` `start` INT NOT NULL, CHANGE `DateE` `end` INT NOT NULL");
$applied = true;
}
if (sql_num_query("DESCRIBE `Shifts` `Man`") === 1 && sql_num_query("DESCRIBE `Shifts` `name`") === 0) {
sql_query("ALTER TABLE `Shifts` CHANGE `Man` `name` VARCHAR(1024) NULL");
$applied = true;
}
$res = sql_select("DESCRIBE `Shifts` `PSID`");
if ($res[0]['Type'] == 'text') {
sql_query("ALTER TABLE `Shifts` CHANGE `PSID` `PSID` INT NULL");
$applied = true;
}
_add_index("Shifts", array("PSID"), "UNIQUE");
_add_index("Shifts", array("RID"));
示例14: sql_query
<?php
if (sql_num_query("SHOW TABLES LIKE 'LogEntries'") == 0) {
sql_query("CREATE TABLE `LogEntries` (\n `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,\n `timestamp` INT NOT NULL ,\n `nick` VARCHAR( 23 ) NOT NULL ,\n `message` TEXT NOT NULL ,\n INDEX ( `timestamp` )\n ) ENGINE = InnoDB;");
$applied = true;
}
if (sql_num_query("SHOW TABLES LIKE 'ChangeLog'") == 0) {
sql_query("DROP TABLE `ChangeLog`");
$applied = true;
}
示例15: array
<?php
if (sql_num_query("DESCRIBE `Messages` `id`") === 0) {
sql_query("ALTER TABLE `Messages`\n DROP PRIMARY KEY,\n ADD `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST\n ");
$applied = true;
}
_add_index("Messages", array("SUID"));
_add_index("Messages", array("RUID"));
_datetime_to_int("Messages", "Datum");
_add_index("Messages", array("Datum"));