本文整理汇总了PHP中db_select_all函数的典型用法代码示例。如果您正苦于以下问题:PHP db_select_all函数的具体用法?PHP db_select_all怎么用?PHP db_select_all使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了db_select_all函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: json_scoreboard
function json_scoreboard()
{
// generate a json scoreboard
// this function is so hacky..
// could probably do with a rewrite
$user_types = db_select_all('user_types', array('id', 'title AS category'));
if (empty($user_types)) {
$user_types = array(array('id' => 0, 'category' => 'all'));
}
for ($i = 0; $i < count($user_types); $i++) {
$scores = db_query_fetch_all('
SELECT
u.id AS user_id,
u.team_name,
u.competing,
co.country_code,
SUM(c.points) AS score,
MAX(s.added) AS tiebreaker
FROM users AS u
LEFT JOIN countries AS co ON co.id = u.country_id
LEFT JOIN submissions AS s ON u.id = s.user_id AND s.correct = 1
LEFT JOIN challenges AS c ON c.id = s.challenge
WHERE u.competing = 1 AND u.user_type = :user_type
GROUP BY u.id
ORDER BY score DESC, tiebreaker ASC', array('user_type' => $user_types[$i]['id']));
unset($user_types[$i]['id']);
for ($j = 0; $j < count($scores); $j++) {
$user_types[$i]['teams'][htmlspecialchars($scores[$j]['team_name'])] = array('position' => $j + 1, 'score' => isset($scores[$j]['score']) ? $scores[$j]['score'] : 0, 'country' => $scores[$j]['country_code']);
}
}
echo json_encode($user_types);
}
示例2: read
public function read()
{
$sql = "record_id = '" . $this->id . "'";
// AND user_id = '".$this->uid()."'";
if (!empty($this->smpte)) {
$sql .= " AND cuepoint = '" . $this->smpte . "'";
}
$sql .= " ORDER BY record_id ASC";
$notes = db_select_all(TBL_PREFIX . TBL_HYPERNOTES, "*", $sql);
foreach ($notes as $note) {
$this->data[] = array("uid" => $note['user_id'], "pos" => $note['cuepoint'], "txt" => $note['hypernote']);
}
}
示例3: allowed_email
function allowed_email($email)
{
$allowedEmail = true;
$rules = db_select_all('restrict_email', array('rule', 'white'), array('enabled' => 1), 'priority ASC');
foreach ($rules as $rule) {
if (preg_match('/' . $rule['rule'] . '/', $email)) {
if ($rule['white']) {
$allowedEmail = true;
} else {
$allowedEmail = false;
}
}
}
return $allowedEmail;
}
示例4: query
protected function query()
{
$records = db_select_all(TBL_PREFIX . TBL_RECORDS, "id,cache_id,sess_date,DATE_FORMAT(sess_date,'%W %D %M %Y (%H:%i:%s)') as udate,sess_time", "client_id = '" . $this->cid . "' ORDER BY id ASC");
$this->num = count($records);
$count = 0;
$prevRecord = null;
foreach ($records as $record) {
// split browsing sessions by access date
if ($prevRecord && strtotime($record['sess_date']) - strtotime($prevRecord['sess_date']) > 1200) {
$count++;
}
// this $cache query is really needed only on the 'analyze' module
$cache = db_select(TBL_PREFIX . TBL_CACHE, "url", "id = '" . $record['cache_id'] . "'");
// to track the REAL clickpath we need both the id AND the trail group of each record
$this->data[] = array("id" => $record['id'], "date" => $record['udate'], "time" => $record['sess_time'], "url" => $cache['url'], "trail" => $count);
// update
$prevRecord = $record;
}
}
示例5: check_notified_request
" class="vspace">JavaScript API <small class="del">deprecated!</small></h2>
<?php
check_notified_request(TBL_JSOPT);
?>
<p>
If you wish to use the JavaScript (JS) visualization API, you can customize it here.
These options are stored on your MySQL database. <em>Leave fields blank for default values</em>.
</p>
<p>This API will be not supported in a future, and maybe it will be removed definitely in next smt2 releases.</p>
<br />
<form action="savesettings.php" method="post">
<?php
$jsoption = db_select_all(TBL_PREFIX . TBL_JSOPT, "*", "1");
echo display_options($jsoption);
?>
<fieldset>
<input type="hidden" name="submit" value="<?php
echo TBL_JSOPT;
?>
" />
<input type="submit" class="button round" value="Set JS replay options" />
</fieldset>
</form>
-->
<?php
include INC_DIR . 'footer.php';
示例6: country_select
function country_select()
{
$countries = db_select_all('countries', array('id', 'country_name'), null, 'country_name ASC');
echo '<select name="country" class="form-control" required="required">
<option disabled selected>-- Please select a country --</option>';
foreach ($countries as $country) {
echo '<option value="', htmlspecialchars($country['id']), '">', htmlspecialchars($country['country_name']), '</option>';
}
echo '</select>';
}
示例7: ext_available
<?php
// server settings are required - relative path to smt2 root dir
require '../../../config.php';
// protect extension from being browsed by anyone
require SYS_DIR . 'logincheck.php';
// now you have access to all CMS API
include INC_DIR . 'header.php';
// retrieve extensions
$MODULES = ext_available();
// get all roles
$ROLES = db_select_all(TBL_PREFIX . TBL_ROLES, "*", "1");
// query DB once
$ROOT = is_root();
// helper function
function table_row($role, $new = false)
{
global $MODULES, $ROOT;
$self = $role['id'] == $_SESSION['role_id'];
// wrap table row in a form, so each user can be edited separately
$row = '<form action="saveroles.php" method="post">';
$row .= '<tr>';
$row .= ' <td>';
$row .= !$new ? '<strong>' . $role['name'] . '</strong>' : '<input type="text" class="text center" id="newrole" name="name" value="type role name" size="15" maxlength="100" />';
$row .= ' </td>';
$allowed = explode(",", $role['ext_allowed']);
// check available extensions
foreach ($MODULES as $module) {
// disable admin roles (they have wide access)
$disabled = $self || $role['id'] == 1 && !$new ? ' disabled="disabled"' : null;
// look for registered users' roles
示例8: form_button_submit
form_button_submit('Upload file');
echo 'Max file size: ', bytes_to_pretty_size(max_file_upload_size());
form_end();
section_subhead('Hints');
echo '
<table id="hints" class="table table-striped table-hover">
<thead>
<tr>
<th>Added</th>
<th>Hint</th>
<th>Manage</th>
</tr>
</thead>
<tbody>
';
$hints = db_select_all('hints', array('id', 'added', 'body'), array('challenge' => $_GET['id']));
foreach ($hints as $hint) {
echo '
<tr>
<td>', date_time($hint['added']), '</td>
<td>', htmlspecialchars($hint['body']), '</td>
<td><a href="edit_hint.php?id=', htmlspecialchars(short_description($hint['id'], 100)), '" class="btn btn-xs btn-primary">Edit</a></td>
</tr>
';
}
echo '
</tbody>
</table>
<a href="new_hint.php?id=', htmlspecialchars($_GET['id']), '" class="btn btn-sm btn-warning">Add a new hint</a>
';
示例9: enforce_authentication
<?php
require '../../include/ctf.inc.php';
enforce_authentication(CONST_USER_CLASS_MODERATOR);
head('Dynamic pages');
menu_management();
section_head('Dynamic pages', button_link('New page', 'new_dynamic_page'), false);
$pages = db_select_all('dynamic_pages', array('id', 'title', 'visibility', 'min_user_class'), null, 'title ASC');
echo '
<table id="dynamic_pages" class="table table-striped table-hover">
<thead>
<tr>
<th>Title</th>
<th>visibility</th>
<th>Min user class</th>
<th>Manage</th>
</tr>
</thead>
<tbody>
';
foreach ($pages as $item) {
echo '
<tr>
<td>', htmlspecialchars($item['title']), '</td>
<td>', visibility_enum_to_name($item['visibility']), '</td>
<td>', user_class_name($item['min_user_class']), '</td>
<td><a href="' . CONFIG_SITE_ADMIN_URL . 'edit_dynamic_page?id=', $item['id'], '" class="btn btn-xs btn-primary">Edit</a></td>
</tr>
';
}
echo '
示例10: enforce_authentication
<?php
require '../../include/mellivora.inc.php';
enforce_authentication(CONST_USER_CLASS_MODERATOR);
head('Site management');
menu_management();
if (array_get($_GET, 'bcc') == 'all') {
$users = db_select_all('users', array('email'));
$bcc = '';
foreach ($users as $user) {
$bcc .= $user['email'] . ",\n";
}
$bcc = trim($bcc);
}
section_subhead('New email');
message_inline_blue('Separate receiver emails with a comma and optional whitespace. You can use BBCode. If you do, you must send as HTML email.');
form_start(CONFIG_SITE_ADMIN_RELPATH . 'actions/new_email');
if (isset($bcc)) {
form_input_text('To', CONFIG_EMAIL_FROM_EMAIL);
form_input_text('CC');
form_textarea('BCC', $bcc);
} else {
form_input_text('To', isset($_GET['to']) ? $_GET['to'] : '');
form_input_text('CC');
form_input_text('BCC');
}
form_input_text('Subject');
form_textarea('Body');
form_input_checkbox('HTML email');
form_hidden('action', 'new');
message_inline_yellow('Important email? Remember to Ctrl+C before attempting to send!');
示例11: 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'] == 'edit') {
db_update('categories', array('title' => $_POST['title'], 'description' => $_POST['description'], 'exposed' => $_POST['exposed'], 'available_from' => strtotime($_POST['available_from']), 'available_until' => strtotime($_POST['available_until'])), array('id' => $_POST['id']));
redirect(CONFIG_SITE_ADMIN_RELPATH . 'edit_category.php?id=' . $_POST['id'] . '&generic_success=1');
} else {
if ($_POST['action'] == 'delete') {
if (!$_POST['delete_confirmation']) {
message_error('Please confirm delete');
}
db_delete('categories', array('id' => $_POST['id']));
$challenges = db_select_all('challenges', array('id'), array('category' => $_POST['id']));
foreach ($challenges as $challenge) {
delete_challenge_cascading($challenge['id']);
}
redirect(CONFIG_SITE_ADMIN_RELPATH . '?generic_success=1');
}
}
}
示例12: error_reporting
error_reporting(E_ALL);
debug('Start timestamp is ' . $startTime, 40, __FILE__, __LINE__);
debug('Configuration:' . print_r($iniConfig, TRUE), 40, __FILE__, __LINE__);
$maxRunTime = 55;
$cleanUntil = date('Y-m-d', mktime(0, 0, 0, substr($today, 5, 2), substr($today, 8, 2) - getConfigValue($link, 'keepHistoryDays'), substr($today, 0, 4)));
debug('Cleaning up until ' . $cleanUntil, 40, __FILE__, __LINE__);
// array containing tables to be cleaned
$cleanTable = array('sites', 'traffic', 'trafficSummaries', 'users');
reset($cleanTable);
while (list($key, $tableName) = each($cleanTable)) {
debug('Cleaning-up ' . $tableName . '...', 40, __FILE__, __LINE__);
$query = 'DELETE FROM ' . $tableName . " WHERE date<'" . $cleanUntil . "'";
db_delete($link, $query);
}
$query = 'SHOW TABLES';
$tables = db_select_all($link, $query);
reset($tables);
while (list($key, $tableName) = each($tables)) {
$timestampNow = time();
debug('Now timestamp is: ' . $timestampNow . '. Script start was at: ' . $startTime, 40, __FILE__, __LINE__);
debug('Checking if run time exceeded ' . $maxRunTime . ' seconds...', 40, __FILE__, __LINE__);
if ($timestampNow - $startTime > $maxRunTime) {
debug('YES', 40);
debug('Exceeded run time', 30, __FILE__, __LINE__);
my_exit($link, 0);
}
debug('NO', 40);
$query = "OPTIMIZE TABLE {$tableName['0']}";
debug('Optimizing ' . $tableName[0] . '...', 30, __FILE__, __LINE__);
db_query($link, $query);
debug('Optimization finished.', 30, __FILE__, __LINE__);
示例13: db_select_all
$where = "id='" . $_GET['id'] . "'";
} else {
if (isset($_GET['pid'])) {
$where = "id='" . $_GET['pid'] . "'";
} else {
if (isset($_GET['cid'])) {
$where = "id='" . $_GET['cid'] . "'";
} else {
$where = "1";
}
}
}
}
}
// default: download all logs
$records = db_select_all(TBL_PREFIX . TBL_RECORDS, "*", $where . " ORDER BY sess_date, client_id");
if (!$records) {
die("No logs found matching your criteria!");
}
$format = isset($_POST['format']) ? $_POST['format'] : "csv";
switch ($format) {
case 'txt':
case 'xml':
die("Sorry, TXT and XML formats are not yet implemented.");
break;
case 'csv':
default:
$delimiter = ";";
break;
case 'tsv':
$delimiter = "\t";
示例14: die_msg
<div id="global">
<h1><strong>smt2</strong> uninstaller</h1>
<?php
if ($isInstalled) {
// is root logged?
if (!is_root()) {
die_msg($_loginMsg["NOT_ALLOWED"]);
}
if (isset($_REQUEST['submit']) && isset($_REQUEST['really_sure']) && isset($_REQUEST['safety_input'])) {
$msgs = array();
die('deleted');
if (isset($_REQUEST['droptables'])) {
// delete cache logs first
$logs = db_select_all(TBL_PREFIX . TBL_CACHE, "file", 1);
foreach ($logs as $log) {
if (is_file(CACHE_DIR . $log)) {
unlink(CACHE_DIR . $log);
}
}
// then delete (smt) tables
foreach ($_lookupTables as $table) {
db_query("DROP TABLE " . TBL_PREFIX . $table);
}
// notify
$msgs[] = 'Tables were dropped.';
$msgs[] = 'Cache logs were deleted.';
}
?>
示例15: login_session_refresh
<?php
require '../include/mellivora.inc.php';
login_session_refresh();
head('Scoreboard');
if (cache_start('scores', CONFIG_CACHE_TIME_SCORES)) {
$now = time();
echo '
<div class="row">
<div class="col-lg-6">';
$user_types = db_select_all('user_types', array('id', 'title'));
// no user types
if (empty($user_types)) {
section_head('Scoreboard', '<a href="' . CONFIG_SITE_URL . 'json?view=scoreboard">
<img src="' . CONFIG_SITE_URL . 'img/json.png" title="View json" alt="json" class="discreet-inline small-icon" />
</a>', false);
$scores = db_query_fetch_all('
SELECT
u.id AS user_id,
u.team_name,
u.competing,
co.id AS country_id,
co.country_name,
co.country_code,
SUM(c.points) AS score,
MAX(s.added) AS tiebreaker
FROM users AS u
LEFT JOIN countries AS co ON co.id = u.country_id
LEFT JOIN submissions AS s ON u.id = s.user_id AND s.correct = 1
LEFT JOIN challenges AS c ON c.id = s.challenge
WHERE u.competing = 1