本文整理汇总了PHP中mysql_queryf函数的典型用法代码示例。如果您正苦于以下问题:PHP mysql_queryf函数的具体用法?PHP mysql_queryf怎么用?PHP mysql_queryf使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mysql_queryf函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadBrowsers
function loadBrowsers($name, $mobile) {
global $found, $browser, $version, $os;
$result = mysql_queryf("SELECT useragents.engine as engine, useragents.name as name, (SELECT COUNT(*) FROM clients WHERE useragent_id=useragents.id AND updated > DATE_SUB(NOW(), INTERVAL 1 minute)) as clients, (engine=%s AND %s REGEXP version) as found FROM useragents WHERE active=1 AND mobile=%s ORDER BY engine, name;", $browser, $version, $mobile);
$engine = "";
echo "<div class='browsers'><h3>$name</h3>";
while ( $row = mysql_fetch_array($result) ) {
if ( $row[3] ) {
$found = 1;
}
if ( $row[0] != $engine ) {
echo '<br style="clear:both;"/>';
}
$num = preg_replace("/\w+ /", "", $row[1]);
?>
<div class="browser<?php echo $row[0] != $engine ? " clear" : "";?><?php echo $row[3] ? " you" : "";?>">
<img src="<?php echo swarmpath( "images/{$row[0]}.sm.png" ); ?>" class="browser-icon <?php echo $row[0]; ?>" alt="<?php echo $row[1]; ?>" title="<?php echo $row[1]; ?>"/>
<span class="browser-name"><?php echo $num; ?></span>
<?php if ( intval($row[2]) > 0 ) {
echo '<span class="active">' . $row[2] . '</span>';
}?>
</div>
<?php $engine = $row[0];
}
echo '</div>';
}
示例2: loadBrowsers
function loadBrowsers($name, $mobile)
{
global $found, $browser, $version, $os;
$result = mysql_queryf("SELECT useragents.engine as engine, useragents.name as name, (SELECT COUNT(*) FROM clients WHERE useragent_id=useragents.id AND updated > DATE_SUB(NOW(), INTERVAL 1 minute)) as clients, (engine=%s AND %s REGEXP version) as found FROM useragents WHERE active=1 AND mobile=%s ORDER BY engine, name;", $browser, $version, $mobile);
$engine = "";
echo "<div class='browsers'><h3>{$name}</h3>";
while ($row = mysql_fetch_array($result)) {
if ($row[3]) {
$found = 1;
}
if ($row[0] != $engine) {
echo "<br style='clear:both;'/>";
}
# <?php echo $row[0] != $engine ? ' clear' : ''?
$num = preg_replace('/\\w+ /', "", $row[1]);
?>
<div class="browser<?php
echo $row[0] != $engine ? ' clear' : '';
echo $row[3] ? ' you' : '';
?>
">
<img src="<?php
echo $GLOBALS['contextpath'];
?>
/images/<?php
echo $row[0];
?>
.sm.png" class="browser-icon <?php
echo $row[0];
?>
" alt="<?php
echo $row[1];
?>
" title="<?php
echo $row[1];
?>
"/>
<span class="browser-name"><?php
echo $num;
?>
</span>
<?php
if (intval($row[2]) > 0) {
echo "<span class='active'>", $row[2], "</span>";
}
?>
</div>
<?php
$engine = $row[0];
}
echo "</div>";
}
示例3: array
$header = "<tr><th></th>\n";
$last_browser = array();
foreach ($browsers as $browser) {
if ($last_browser["id"] != $browser["id"]) {
$header .= '<th><div class="browser">' . '<img src="/images/' . $browser["engine"] . '.sm.png" class="browser-icon ' . $browser["engine"] . '" alt="' . $browser["name"] . ', ' . $browser["os"] . '" title="' . $browser["name"] . ', ' . $browser["os"] . '"/><span class="browser-name">' . preg_replace('/\\w+ /', "", $browser["name"]) . ', ' . $browser["os"] . '</span></div></th>';
}
$last_browser = $browser;
}
$header .= "</tr>\n";
$output = $header . $output;
}
$output .= "</tr>\n";
$addBrowser = false;
}
$useragents = array();
$runResult = mysql_queryf("SELECT run_client.client_id as client_id, run_client.status as status, run_client.fail as fail, run_client.error as error, run_client.total as total, clients.useragent_id as useragent_id, users.name as name, useragents.name as browser FROM useragents, run_client, clients, users WHERE run_client.run_id=%u AND run_client.client_id=clients.id AND clients.user_id=users.id AND useragents.id=useragent_id ORDER BY browser;", $row["run_id"]);
while ($ua_row = mysql_fetch_assoc($runResult)) {
if (!$useragents[$ua_row['useragent_id']]) {
$useragents[$ua_row['useragent_id']] = array();
}
array_push($useragents[$ua_row['useragent_id']], $ua_row);
}
$output .= '<tr><th><a href="' . $row["run_url"] . '">' . $row["run_name"] . "</a></th>\n";
}
if ($addBrowser) {
array_push($browsers, array("name" => $row["browsername"], "engine" => $row["browser"], "os" => $row["os"], "id" => $row["useragent_id"]));
}
#echo "<li>" . $row["browser"] . " (" . get_status(intval($row["status"])) . ")<ul>";
$last_browser = "";
if ($useragents[$row["useragent_id"]]) {
foreach ($useragents[$row["useragent_id"]] as $ua) {
示例4: preg_replace
<?php
$run_id = preg_replace("/[^0-9]/", "", $_REQUEST['run_id']);
$client_id = preg_replace("/[^0-9]/", "", $_REQUEST['client_id']);
$result = mysql_queryf("SELECT results FROM run_client WHERE run_id=%s AND client_id=%s;", $run_id, $client_id);
if ($row = mysql_fetch_array($result)) {
echo $row[0];
}
示例5: getItem
<?php
require "inc/init.php";
$user = getItem('username', $_REQUEST, getItem('username', $_SESSION, ''));
if (!getItem('user', $_REQUEST, false) && $user) {
header("Location: {$contextpath}/run/{$user}/");
exit;
}
$result = mysql_queryf("SELECT name FROM clients, useragents WHERE clients.id=%u AND useragents.id=useragent_id LIMIT 1;", $client_id);
if ($row = mysql_fetch_array($result)) {
$useragent_name = $row[0];
}
$title = "Run the Test Swarm";
$scripts = "";
if ($client_id) {
$scripts = "<script type='text/javascript'>var client_id = {$client_id};</script>";
}
$scripts .= '<script type="text/javascript" src="' . $GLOBALS['contextpath'] . '/js/jquery.js"></script>' . '<script type="text/javascript" src="' . $GLOBALS['contextpath'] . '/js/run.js?' . time() . '"></script>';
示例6: preg_replace
<?php
$run_id = preg_replace("/[^0-9]/", "", $_POST['run_id']);
$client_id = preg_replace("/[^0-9]/", "", $_POST['client_id']);
if ($run_id && $client_id && $_SESSION['username'] && $_SESSION['auth'] == 'yes') {
$results = mysql_queryf("SELECT jobs.id FROM users, jobs, runs WHERE users.name=%s AND jobs.user_id=users.id AND runs.id=%u AND runs.job_id=jobs.id;", $_SESSION['username'], $run_id);
if ($row = mysql_fetch_row($results)) {
$job_id = $row[0];
$results = mysql_queryf("SELECT useragent_id FROM clients WHERE id=%u;", $client_id);
if ($row = mysql_fetch_row($results)) {
$useragent_id = $row[0];
mysql_queryf("DELETE run_client FROM run_client,clients WHERE run_id=%u AND clients.id=client_id AND clients.useragent_id=%u;", $run_id, $useragent_id);
mysql_queryf("UPDATE run_useragent SET status=0, runs=0, completed=0, updated=NOW() WHERE run_id=%u AND useragent_id=%u;", $run_id, $useragent_id);
mysql_queryf("UPDATE runs SET status=1, updated=NOW() WHERE run_id=%u;", $run_id);
}
}
header("Location: /job/{$job_id}/");
}
exit;
示例7: downloadJobResults
function downloadJobResults($job_id, $view)
{
$result = mysql_queryf("SELECT runs.id FROM runs,jobs WHERE runs.job_id=jobs.id AND jobs.id=%s LIMIT 1", $job_id);
if ($row = mysql_fetch_array($result)) {
$run_id = $row[0];
downloadJobResultsForRunId($run_id, $view);
}
}
示例8: in
mysql_queryf("DELETE FROM run_client WHERE run_id in (select id from runs where job_id=%u);", $job_id);
mysql_queryf("DELETE FROM run_useragent WHERE run_id in (select id from runs where job_id=%u);", $job_id);
mysql_queryf("DELETE FROM runs WHERE job_id=%u;", $job_id);
mysql_queryf("DELETE FROM jobs WHERE id=%u;", $job_id);
} else {
mysql_queryf("UPDATE jobs SET status=0, updated=NOW() WHERE id=%u;", $job_id);
mysql_queryf("UPDATE runs SET status=0, updated=NOW() WHERE job_id=%u;", $job_id);
}
}
while ( $row = mysql_fetch_row($results) ) {
$run_id = $row[0];
mysql_queryf("DELETE FROM run_client WHERE run_id=%u;", $run_id);
if ( $type == "delete" ) {
mysql_queryf("DELETE FROM run_useragent WHERE run_id=%u;", $run_id);
} else {
mysql_queryf("UPDATE run_useragent SET runs=0, completed=0, status=0, updated=NOW() WHERE run_id=%u;", $run_id);
}
}
if ( $type == "delete" ) {
header("Location: " . swarmpath( "user/{$_SESSION["username"]}/" ) );
} else {
header("Location: " . swarmpath( "job/{$job_id}/" ) );
}
}
exit();
示例9: mysql_queryf
# TODO: Improve error message quality.
} else {
echo "Client doesn't exist.";
exit;
}
# The user is setting up a new client session
} else {
# Figure out the exact useragent that the user is using
$result = mysql_queryf("SELECT id, name from useragents WHERE engine=%s AND %s REGEXP version;", $browser, $version);
if ($row = mysql_fetch_array($result)) {
$useragent_id = $row[0];
$useragent_name = $row[1];
# If the useragent isn't needed, failover with an error message
# TODO: Improve error message quality.
} else {
echo "Browser is not needed for testing. Browser: {$browser} Version: {$version}";
exit;
}
# Figure out what the user's ID number is
$result = mysql_queryf("SELECT id FROM users WHERE name=%s;", $username);
if ($row = mysql_fetch_array($result)) {
$user_id = intval($row[0]);
# If the user doesn't have one, create a new user account
} else {
$result = mysql_queryf("INSERT INTO users (name,created,seed) VALUES(%s,NOW(),RAND());", $username);
$user_id = intval(mysql_insert_id());
}
# Insert in a new record for the client and get its ID
mysql_queryf("INSERT INTO clients (user_id, useragent_id, useragent, os, ip, created) VALUES(%u,%u,%s,%s,%s,NOW());", $user_id, $useragent_id, $useragent, $os, $ip);
$client_id = mysql_insert_id();
}
示例10: mysql_queryf
<?php
$result = mysql_queryf("SELECT run_id, client_id, useragent_id FROM run_client, clients WHERE DATE_ADD(run_client.updated, INTERVAL 5 MINUTE) < NOW() AND clients.id = client_id AND run_client.status = 1;");
while ($row = mysql_fetch_array($result)) {
$run_id = $row[0];
$client_id = $row[1];
$useragent_id = $row[2];
# Update run_useragent (clients, useragents)
mysql_queryf("UPDATE run_useragent SET runs = runs - 1 WHERE run_id=%u AND useragent_id=%u;", $run_id, $useragent_id);
mysql_queryf("DELETE FROM run_client WHERE run_id=%u AND client_id=%u;", $run_id, $client_id);
}
# Reset runs that race-condition deleted themselves
mysql_queryf("UPDATE run_useragent SET runs=0, completed=0, status=0 WHERE runs=max AND NOT EXISTS (SELECT * FROM run_client, clients WHERE run_client.run_id=run_useragent.run_id AND run_client.client_id=clients.id AND clients.useragent_id=run_useragent.useragent_id);");
echo "done";
exit;
示例11: array
$header = "<tr><th></th>\n";
$last_browser = array();
foreach ($browsers as $browser) {
if ($last_browser["id"] != $browser["id"]) {
$header .= '<th><div class="browser">' . '<img src="' . $GLOBALS['contextpath'] . '/images/' . $browser["engine"] . '.sm.png" class="browser-icon ' . $browser["engine"] . '" alt="' . $browser["name"] . '" title="' . $browser["name"] . '"/><span class="browser-name">' . preg_replace('/\\w+ /', "", $browser["name"]) . ', ' . '</span></div></th>';
}
$last_browser = $browser;
}
$header .= "</tr>\n";
$output = $header . $output;
}
$output .= "</tr>\n";
$addBrowser = false;
}
$useragents = array();
$runResult = mysql_queryf("SELECT run_client.client_id as client_id, run_client.status as status, run_client.fail as fail, run_client.error as error, run_client.total as total, clients.useragent_id as useragent_id FROM run_client, clients WHERE run_client.run_id=%u AND run_client.client_id=clients.id ORDER BY useragent_id;", $row["run_id"]);
while ($ua_row = mysql_fetch_assoc($runResult)) {
if (!$useragents[$ua_row['useragent_id']]) {
$useragents[$ua_row['useragent_id']] = array();
}
array_push($useragents[$ua_row['useragent_id']], $ua_row);
}
$output .= '<tr><th><a href="' . $row["run_url"] . '">' . $row["run_name"] . "</a></th>\n";
}
if ($addBrowser) {
array_push($browsers, array("name" => $row["browsername"], "engine" => $row["browser"], "id" => $row["useragent_id"]));
}
#echo "<li>" . $row["browser"] . " (" . get_status(intval($row["status"])) . ")<ul>";
$last_browser = -1;
if ($useragents[$row["useragent_id"]]) {
foreach ($useragents[$row["useragent_id"]] as $ua) {
示例12: generate_results_table
function generate_results_table(&$browsers, &$runs, $job_id)
{
$result = mysql_queryf("SELECT runs.id as run_id, runs.url as run_url, runs.name as run_name FROM runs WHERE runs.job_id=%u ORDER BY run_id;", $job_id);
$last = "";
$output = "";
$browsers = array();
$runs = array();
/* cache all of the report data */
while ($row = mysql_fetch_assoc($result)) {
if (array_key_exists($row["run_id"], $runs)) {
/* append the run info */
} else {
$useragents = setup_useragents_for_run($row["run_id"], &$browsers);
$run_data = array();
$run_data["useragents"] = $useragents;
$run_data["run_url"] = $row["run_url"];
$run_data["run_name"] = $row["run_name"];
$run_data["run_id"] = $row["run_id"];
$runs[$row["run_id"]] = $run_data;
}
}
ksort($browsers);
}
示例13: mysql_queryf
<?php
# Uncomment to reload all connected clients.
#echo "{cmd:'reload',args:''}";
#exit();
require "inc/init.php";
$result = mysql_queryf("SELECT run_id FROM run_useragent WHERE useragent_id=%u AND runs < max AND NOT EXISTS (SELECT 1 FROM run_client WHERE run_useragent.run_id=run_id AND client_id=%u) ORDER BY run_id DESC LIMIT 1;", $useragent_id, $client_id);
# A run was found
if ($row = mysql_fetch_array($result)) {
$run_id = $row[0];
$result = mysql_queryf("SELECT url, jobs.name, runs.name FROM runs, jobs WHERE runs.id=%u AND jobs.id=runs.job_id LIMIT 1;", $run_id);
if ($row = mysql_fetch_array($result)) {
$url = $row[0];
$text = $row[1] . " " . ucfirst($row[2]);
}
# Mark the run as "in progress" on the useragent
mysql_queryf("UPDATE run_useragent SET runs = runs + 1, status = 1 WHERE run_id=%u AND useragent_id=%u LIMIT 1;", $run_id, $useragent_id);
# Initialize the client run
mysql_queryf("INSERT INTO run_client (run_id,client_id,status,created) VALUES(%u,%u,1,NOW());", $run_id, $client_id);
echo "{id:{$run_id},url:'{$url}',desc:'{$text}'}";
}
exit;
示例14: preg_replace
<?php
$title = "Signup";
$username = preg_replace("/[^a-zA-Z0-9_ -]/", "", $_POST['username']);
$password = $_POST['password'];
$email = $_POST['email'];
$request = $_POST['request'];
$error = "";
if ($username && $password) {
# Figure out what the user's ID number is
$result = mysql_queryf("SELECT id, password FROM users WHERE name=%s;", $username);
if ($row = mysql_fetch_array($result)) {
$user_id = intval($row[0]);
$has_pass = $row[1];
# If the user doesn't have one, create a new user account
} else {
$result = mysql_queryf("INSERT INTO users (name,created,seed) VALUES(%s,NOW(),RAND());", $username);
$user_id = intval(mysql_insert_id());
}
if ($has_pass) {
$error = "<p>Error: Account is already created. Please <a href='/login/'>login</a> instead.</p>";
} else {
mysql_queryf("UPDATE users SET updated=NOW(), password=SHA1(CONCAT(seed, %s)), email=%s, request=%s, auth=SHA1(RAND()) WHERE id=%u LIMIT 1;", $password, $email, $request, $user_id);
$_SESSION['username'] = $username;
$_SESSION['auth'] = "yes";
session_write_close();
header("Location: /user/{$username}/");
exit;
}
}
示例15: getSettings
function getSettings()
{
$query = "SELECT name,auth FROM users WHERE users.name='" . $_SESSION['username'] . "'";
$result = mysql_queryf($query);
$settings_assoc = mysql_fetch_assoc($result);
echo dataset_encode_assoc($settings_assoc);
}