本文整理汇总了PHP中db_select_one函数的典型用法代码示例。如果您正苦于以下问题:PHP db_select_one函数的具体用法?PHP db_select_one怎么用?PHP db_select_one使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了db_select_one函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validate_two_factor_auth_code
function validate_two_factor_auth_code($code)
{
require_once CONFIG_PATH_THIRDPARTY . 'Google2FA/Google2FA.php';
$valid = false;
$secret = db_select_one('two_factor_auth', array('secret'), array('user_id' => $_SESSION['id']));
try {
$valid = Google2FA::verify_key($secret['secret'], $code);
} catch (Exception $e) {
message_error('Could not verify key.');
}
return $valid;
}
示例2: db_count
function db_count($tbl, $where = '')
{
return db_select_one($tbl, 'COUNT(1)', $where);
}
示例3: enforce_authentication
<?php
require '../../include/ctf.inc.php';
enforce_authentication(CONST_USER_CLASS_MODERATOR);
validate_id($_GET['id']);
$challenge = db_select_one('challenges', array('*'), array('id' => $_GET['id']));
head('Site management');
menu_management();
section_subhead('Edit challenge: ' . $challenge['title']);
form_start(CONFIG_SITE_ADMIN_RELPATH . 'actions/edit_challenge');
form_input_text('Title', $challenge['title']);
form_textarea('Description', $challenge['description']);
form_textarea('Flag', $challenge['flag']);
form_input_checkbox('Automark', $challenge['automark']);
form_input_checkbox('Case insensitive', $challenge['case_insensitive']);
form_input_text('Points', $challenge['points']);
form_input_text('Num attempts allowed', $challenge['num_attempts_allowed']);
form_input_text('Min seconds between submissions', $challenge['min_seconds_between_submissions']);
$opts = db_query_fetch_all('SELECT * FROM categories ORDER BY title');
form_select($opts, 'Category', 'id', $challenge['category'], 'title');
$opts = db_query_fetch_all('
SELECT
ch.id,
ch.title,
ca.title AS category
FROM challenges AS ch
LEFT JOIN categories AS ca ON ca.id = ch.category
ORDER BY ca.title, ch.title');
array_unshift($opts, array('id' => 0, 'title' => '-- User must solve selected challenge before revealing this one --'));
form_select($opts, 'Relies on', 'id', $challenge['relies_on'], 'title', 'category');
form_input_checkbox('Exposed', $challenge['exposed']);
示例4: enforce_authentication
<?php
require '../../include/ctf.inc.php';
enforce_authentication(CONST_USER_CLASS_MODERATOR);
validate_id($_GET['id']);
$category = db_select_one('categories', array('*'), array('id' => $_GET['id']));
head('Site management');
menu_management();
section_subhead('Edit category: ' . $category['title']);
form_start(CONFIG_SITE_ADMIN_RELPATH . 'actions/edit_category');
form_input_text('Title', $category['title']);
form_textarea('Description', $category['description']);
form_input_checkbox('Exposed', $category['exposed']);
form_input_text('Available from', date_time($category['available_from']));
form_input_text('Available until', date_time($category['available_until']));
form_hidden('action', 'edit');
form_hidden('id', $_GET['id']);
form_button_submit('Save changes');
form_end();
section_subhead('Delete category: ' . $category['title']);
form_start(CONFIG_SITE_ADMIN_RELPATH . 'actions/edit_category');
form_input_checkbox('Delete confirmation');
form_hidden('action', 'delete');
form_hidden('id', $_GET['id']);
message_inline_red('Warning! This will delete all challenges under this category, as well as all submissions, files, and hints related those challenges!');
form_button_submit('Delete category', 'danger');
form_end();
foot();
示例5: enforce_authentication
<?php
require '../../include/mellivora.inc.php';
enforce_authentication(CONFIG_UC_MODERATOR);
validate_id($_GET['id']);
head('Site management');
menu_management();
section_subhead('Edit user type');
$user_type = db_select_one('user_types', array('*'), array('id' => $_GET['id']));
form_start(CONFIG_SITE_ADMIN_RELPATH . 'actions/edit_user_type');
form_input_text('Title', $user_type['title']);
form_textarea('Description', $user_type['description']);
form_hidden('action', 'edit');
form_hidden('id', $_GET['id']);
form_button_submit('Save changes');
form_end();
section_subhead('Delete user type');
form_start(CONFIG_SITE_ADMIN_RELPATH . 'actions/edit_user_type');
form_input_checkbox('Delete confirmation');
form_hidden('action', 'delete');
form_hidden('id', $_GET['id']);
message_inline_red('Warning! Any users of this type will be without a type.
You must manually give them a type in the DB. If no types will exist after this action, you must set their type to 0.');
form_button_submit('Delete user type', 'danger');
form_end();
foot();
示例6: enforce_authentication
<?php
require '../../include/ctf.inc.php';
enforce_authentication(CONST_USER_CLASS_MODERATOR);
validate_id($_GET['id']);
$user = db_select_one('users', array('team_name', 'email', 'enabled', 'competing', 'country_id'), array('id' => $_GET['id']));
head('Site management');
menu_management();
section_subhead('Edit user: ' . $user['team_name']);
form_start(CONFIG_SITE_ADMIN_RELPATH . 'actions/edit_user');
form_input_text('Email', $user['email']);
form_input_text('Team name', $user['team_name']);
$opts = db_query_fetch_all('SELECT * FROM countries ORDER BY country_name ASC');
form_select($opts, 'Country', 'id', $user['country_id'], 'country_name');
form_input_checkbox('Enabled', $user['enabled']);
form_input_checkbox('Competing', $user['competing']);
form_hidden('action', 'edit');
form_hidden('id', $_GET['id']);
form_button_submit('Save changes');
form_end();
section_subhead('Reset password');
form_start(CONFIG_SITE_ADMIN_RELPATH . 'actions/edit_user');
form_input_checkbox('Reset confirmation');
form_hidden('action', 'reset_password');
form_hidden('id', $_GET['id']);
form_button_submit('Reset password', 'warning');
form_end();
section_subhead('Delete user');
form_start(CONFIG_SITE_ADMIN_RELPATH . 'actions/edit_user');
form_input_checkbox('Delete confirmation');
form_hidden('action', 'delete');
示例7: enforce_authentication
<?php
require '../../include/mellivora.inc.php';
enforce_authentication(CONFIG_UC_MODERATOR);
head('IP log');
menu_management();
// show a users IP log
if (isset($_GET['id']) && valid_id($_GET['id'])) {
$user = db_select_one('users', array('team_name'), array('id' => $_GET['id']));
section_head('IP log for team: <a href="' . CONFIG_SITE_URL . 'user?id=' . $_GET['id'] . '">' . htmlspecialchars($user['team_name']) . '</a>', '', false);
user_ip_log($_GET['id']);
} else {
if (isset($_GET['ip']) && valid_ip($_GET['ip'])) {
section_head('Teams using IP ' . $_GET['ip']);
echo '
<table id="files" class="table table-striped table-hover">
<thead>
<tr>
<th>Team name</th>
<th>Hostname</th>
<th>First used</th>
<th>Last used</th>
<th>Times used</th>
</tr>
</thead>
<tbody>
';
$entries = db_query_fetch_all('
SELECT
INET_NTOA(ipl.ip) AS ip,
ipl.added,
示例8: session_start
<?php
/**
* componet: job
* liet ke cac job cua user
*/
//kiem tra userlogin chua
session_start();
if (!isset($_SESSION["username"])) {
header('Location:' . BASE_URL . 'index.php');
exit;
}
//Liet ke tat cac cac cong viec cua user
//Ket noi co so du lieu
require_once LIB_PATH . '/database.php';
db_connect();
//dau tien lay id cua nguoi dung
$username = $_SESSION["username"];
$userIDQuery = "SELECT uid FROM user WHERE uaccount = '{$username}'";
$uid = db_select_one($userIDQuery);
//Liet ke cong viec
$job_query = "SELECT * FROM job WHERE juser = {$uid} and jprioty = 3";
$jobs = db_select($job_query);
//load template
$pageTitle = "qhxh.todo | manager your idea";
require PUBLIC_PATH . '/tjob.php';
示例9: enforce_authentication
<?php
require '../../../include/ctf.inc.php';
enforce_authentication(CONST_USER_CLASS_MODERATOR);
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
validate_id($_POST['id']);
validate_xsrf_token($_POST[CONST_XSRF_TOKEN_KEY]);
if ($_POST['action'] == 'delete') {
db_delete('submissions', array('id' => $_POST['id']));
redirect(CONFIG_SITE_ADMIN_RELPATH . 'list_submissions.php?generic_success=1');
} else {
if ($_POST['action'] == 'mark_incorrect') {
db_update('submissions', array('correct' => 0, 'marked' => 1), array('id' => $_POST['id']));
redirect(CONFIG_SITE_ADMIN_RELPATH . 'list_submissions.php?generic_success=1');
} else {
if ($_POST['action'] == 'mark_correct') {
$submission = db_select_one('submissions', array('user_id', 'challenge', 'correct'), array('id' => $_POST['id']));
$num_correct_submissions = db_count_num('submissions', array('user_id' => $submission['user_id'], 'challenge' => $submission['challenge'], 'correct' => 1));
if ($num_correct_submissions > 0) {
message_error('This user already has a correct submission for this challenge');
}
db_update('submissions', array('correct' => 1, 'marked' => 1), array('id' => $_POST['id']));
redirect(CONFIG_SITE_ADMIN_RELPATH . 'list_submissions.php?generic_success=1');
}
}
}
}
示例10: isPeakTime
/**
* isPeakTime()
*/
public static function isPeakTime($f_iResource, $f_szDate, $f_szTime)
{
$iUtcStartTime = common::mktime($f_szDate);
$iToday = (int) date('w', $iUtcStartTime);
if ($iSpecialSet = db_select_one('special_opening_hours_sets', 'id', 'resource_id = ' . (int) $f_iResource . " AND ('" . $f_szDate . "' BETWEEN start_date AND end_date) ORDER BY id DESC")) {
return 0 < db_count('resource_opening_hours t, peak_times_in_special_opening_hours_sets p', 't.id = p.resource_opening_hours_id AND p.special_opening_hours_set_id = ' . (int) $iSpecialSet . ' AND t.open_' . $iToday . " <= '" . $f_szTime . "' AND t.closed_" . $iToday . " > '" . $f_szTime . "' AND t.open_" . $iToday . ' != t.closed_' . $iToday);
}
return 0 < db_count('resource_opening_hours t, peak_hours_in_resources p', 't.id = p.resource_opening_hours_id AND p.resource_id = ' . (int) $f_iResource . ' AND t.open_' . $iToday . " <= '" . $f_szTime . "' AND t.closed_" . $iToday . " > '" . $f_szTime . "' AND t.open_" . $iToday . ' != t.closed_' . $iToday);
}
示例11: prefer_ssl
<?php
require '../../include/mellivora.inc.php';
prefer_ssl();
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if ($_POST['action'] == 'register') {
if (CONFIG_RECAPTCHA_ENABLE_PUBLIC) {
validate_captcha();
}
validate_email($_POST['email']);
$interest = db_select_one('interest', array('id'), array('email' => $_POST['email']));
if ($interest['id']) {
message_error('You have already registered your interest!');
}
$id = db_insert('interest', array('added' => time(), 'name' => $_POST['name'], 'email' => $_POST['email'], 'secret' => generate_random_string(40)));
if ($id) {
message_generic('Success', 'The email ' . htmlspecialchars($_POST['email']) . ' has been registered. We look forward to seeing you in our next competition!');
} else {
message_error('Could not register interest. You must not be interested enough!');
}
}
}
示例12: login_session_refresh
<?php
require '../include/mellivora.inc.php';
login_session_refresh();
if (!isset($_GET['show'])) {
message_error(lang_get('please_request_page'));
}
$menu_data = db_select_one('dynamic_menu', array('internal_page'), array('permalink' => $_GET['show']));
if (!is_valid_id($menu_data['internal_page'])) {
message_error(lang_get('not_a_valid_link'));
}
$content = db_select_one('dynamic_pages', array('id', 'title', 'body', 'visibility', 'min_user_class'), array('id' => $menu_data['internal_page']));
if ($content['visibility'] == 'private') {
enforce_authentication($content['min_user_class']);
}
head($content['title']);
if (cache_start($content['id'], CONFIG_CACHE_TIME_DYNAMIC, CONST_CACHE_DYNAMIC_PAGES_GROUP)) {
section_head($content['title']);
require CONST_PATH_THIRDPARTY . 'nbbc/nbbc.php';
$bbc = new BBCode();
$bbc->SetEnableSmileys(false);
echo $bbc->parse($content['body']);
cache_end($content['id'], CONST_CACHE_DYNAMIC_PAGES_GROUP);
}
foot();
示例13: htmlspecialchars
echo '<tr class="bt">';
echo '<td><a href=?id=' . $arrTopic['id'] . '>' . (trim($arrTopic['title']) ? htmlspecialchars($arrTopic['title']) : '---') . '</a></td>';
echo '<td align="center"><b>' . $arrTopic['rulername'] . '</b><!-- of <b>' . $arrTopic['planetname'] . '</b>--></td>';
echo '<td class="right">' . strtolower(date("d-M-Y \\a\\t H:i", $arrTopic['utc_time'])) . '</td>';
echo '<th class="right">' . $arrTopic['num_replies'] . '</th>';
if ((int) $g_arrUser['moc_planet_id'] === PLANET_ID) {
echo '<td align=right><a href="?delete_id=' . $arrTopic['id'] . '">del</a></td>';
}
echo '</tr>';
}
echo '</table>';
}
echo "<br>\n<br>\n\n";
$disabled_ornot = '';
if (isset($_GET['id']) && !empty($t) && (int) $GAMEPREFS['galaxy_forum_wait_for_turn']) {
if (PLANET_ID === (int) db_select_one('politics', 'creator_planet_id', 'galaxy_id = ' . (int) $g_arrUser['galaxy_id'] . ' AND (id = ' . (int) $_GET['id'] . ' OR parent_thread_id = ' . (int) $_GET['id'] . ') ORDER BY id DESC')) {
$disabled_ornot = ' disabled="1"';
}
}
?>
<form method="post" action="">
<table border="0" cellpadding="4" cellspacing="0" width="600" align="center">
<tr>
<th class="bb"><?php
echo !empty($t) ? 'REPLY' : 'NEW POST';
?>
</th>
</tr>
<?php
echo !empty($t) ? '<input type="hidden" name="parent_thread_id" value="' . (int) $_GET['id'] . '" />' : '<tr class="bt"><td class="c">Title:</td></tr><tr><td class="c"><input' . $disabled_ornot . ' type="text" name="title" style="width:450px;" /></td></tr>';
?>
示例14: prefer_ssl
<?php
require '../../include/ctf.inc.php';
prefer_ssl();
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if ($_POST['action'] == 'register') {
if (CONFIG_RECAPTCHA_ENABLE_PRIVATE) {
validate_captcha();
}
validate_email($_POST['email']);
$recruit = db_select_one('recruit', array('id'), array('email' => $_POST['email']));
if ($recruit['id']) {
message_generic('Thank you', 'Your email was already registered!');
}
$id = db_insert('recruit', array('added' => time(), 'user_id' => $_SESSION['id'], 'name' => $_POST['name'], 'email' => $_POST['email'], 'city' => $_POST['city'], 'country' => $_POST['country']));
if ($id) {
message_generic('Success', 'The email ' . htmlspecialchars($_POST['email']) . ' has been registered. Thanks!');
} else {
message_error('Could not register interest. You must not be interested enough!');
}
}
}
示例15: enforce_authentication
<?php
require '../../../include/mellivora.inc.php';
enforce_authentication(CONFIG_UC_MODERATOR);
enforce_instance_auth();
if ($_GET['action'] == 'view') {
$instanceInformation = db_select_one('instances', array('id', 'instanceURI', 'name', 'authoratativeAccountID', 'registrationToken'), array('id' => $_GET['id']));
$_SESSION['IID'] = $instanceInformation['id'];
$_SESSION['IName'] = $instanceInformation['name'];
$_SESSION['IAID'] = $instanceInformation['authoratativeAccountID'];
redirect(CONFIG_SITE_ADMIN_RELPATH . 'index.php');
}
if ($_GET['action'] == 'reset') {
$instanceInformation = db_select_one('instances', array('id', 'instanceURI', 'name', 'authoratativeAccountID', 'registrationToken'), array('id' => '0'));
$_SESSION['IID'] = $instanceInformation['id'];
$_SESSION['IName'] = $instanceInformation['name'];
$_SESSION['IAID'] = $instanceInformation['authoratativeAccountID'];
redirect(CONFIG_SITE_ADMIN_RELPATH . 'index.php');
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
validate_id($_POST['id']);
validate_xsrf_token($_POST['xsrf_token']);
if ($_POST['action'] == 'delete') {
db_delete('categories', array('instanceID' => $_POST['id']));
db_delete('challenges', array('instanceID' => $_POST['id']));
db_delete('news', array('instanceID' => $_POST['id']));
db_delete('submissions', array('instanceID' => $_POST['id']));
db_delete('purchases', array('instanceID' => $_POST['id']));
db_delete('hints', array('instanceID' => $_POST['id']));
db_delete('instances', array('id' => $_POST['id']));
redirect(CONFIG_SITE_ADMIN_RELPATH . 'list_instance.php');