本文整理汇总了PHP中db_query_cached函数的典型用法代码示例。如果您正苦于以下问题:PHP db_query_cached函数的具体用法?PHP db_query_cached怎么用?PHP db_query_cached使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了db_query_cached函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: viewcommentaryargs_dohook
function viewcommentaryargs_dohook($hook, $args)
{
global $currentCommentaryArea;
switch ($hook) {
case 'blockcommentarea':
$currentCommentaryArea = $args['section'];
break;
case 'viewcommentary':
$accounts = db_prefix('accounts');
$commentary = db_prefix('commentary');
preg_match("/bio.php\\?char=(.*)&ret/", $args['commentline'], $matches);
$acctid = filter_var($matches[1], FILTER_SANITIZE_NUMBER_INT);
$sql = db_query_cached("SELECT login, name FROM {$accounts} WHERE acctid = {$acctid}", "commentary-author_name-{$acctid}", 86400);
$row = db_fetch_assoc($sql);
$name = $row['name'];
$login = $row['login'];
$temp = explode($row['name'], $args['commentline']);
$temp = str_replace('`3 says, "`#', '', $temp[1]);
$temp = str_replace('`3"', '', $temp);
$temp = str_replace('/me', '', $temp);
$temp = str_replace(':', '', $temp);
$temp = str_replace('</a>', '', $temp);
$temp = full_sanitize($temp);
$temp = addslashes(implode('%', str_split(trim($temp))));
$sql = db_query("SELECT commentid, comment, postdate FROM {$commentary}\n WHERE comment LIKE '%{$temp}%'\n AND section = '{$currentCommentaryArea}'");
$row = db_fetch_assoc($sql);
$args = ['commentline' => $args['commentline'], 'section' => $currentCommentaryArea, 'commentid' => $row['commentid'], 'comment' => $row['comment'], 'author_acctid' => $acctid, 'author_login' => $login, 'author_name' => $name, 'date' => $row['postdate']];
unset($row);
unset($temp);
break;
}
return $args;
}
示例2: pollitem
function pollitem($id, $subject, $body, $author, $date, $showpoll = true)
{
global $session;
$sql = "SELECT count(resultid) AS c, MAX(choice) AS choice FROM " . db_prefix("pollresults") . " WHERE motditem='{$id}' AND account='{$session['user']['acctid']}'";
$result = db_query($sql);
$row = db_fetch_assoc($result);
$choice = $row['choice'];
$body = unserialize($body);
$poll = translate_inline("Poll:");
if ($session['user']['loggedin'] && $showpoll) {
rawoutput("<form action='motd.php?op=vote' method='POST'>");
rawoutput("<input type='hidden' name='motditem' value='{$id}'>", true);
}
output_notl("`b`&%s `^%s`0`b", $poll, $subject);
if ($showpoll) {
motd_admin($id, true);
}
output_notl("`n`3%s`0 – `#%s`0`n", $author, $date, true);
output_notl("`2%s`0`n", stripslashes($body['body']));
$sql = "SELECT count(resultid) AS c, choice FROM " . db_prefix("pollresults") . " WHERE motditem='{$id}' GROUP BY choice ORDER BY choice";
$result = db_query_cached($sql, "poll-{$id}");
$choices = array();
$totalanswers = 0;
$maxitem = 0;
while ($row = db_fetch_assoc($result)) {
$choices[$row['choice']] = $row['c'];
$totalanswers += $row['c'];
if ($row['c'] > $maxitem) {
$maxitem = $row['c'];
}
}
while (list($key, $val) = each($body['opt'])) {
if (trim($val) != "") {
if ($totalanswers <= 0) {
$totalanswers = 1;
}
$percent = 0;
if (isset($choices[$key])) {
$percent = round($choices[$key] / $totalanswers * 100, 1);
}
if ($session['user']['loggedin'] && $showpoll) {
rawoutput("<input type='radio' name='choice' value='{$key}'" . ($choice == $key ? " checked" : "") . ">");
}
output_notl("%s (%s - %s%%)`n", stripslashes($val), isset($choices[$key]) ? (int) $choices[$key] : 0, $percent);
if ($maxitem == 0 || !isset($choices[$key])) {
$width = 1;
} else {
$width = round($choices[$key] / $maxitem * 400, 0);
}
$width = max($width, 1);
rawoutput("<img src='images/rule.gif' width='{$width}' height='2' alt='{$percent}'><br>");
}
}
if ($session['user']['loggedin'] && $showpoll) {
$vote = translate_inline("Vote");
rawoutput("<input type='submit' class='button' value='{$vote}'></form>");
}
rawoutput("<hr>", true);
}
开发者ID:Beeps,项目名称:Improbable-Island---DragonScales---DragonBones---LotGD-2.0---Season-Three,代码行数:59,代码来源:motd.php
示例3: iitems_get_item_details
function iitems_get_item_details($localname)
{
$sql = "SELECT id,localname,data FROM " . db_prefix("iitems") . " WHERE localname = '{$localname}'";
$result = db_query_cached($sql, "iitems-" . $localname);
$row = db_fetch_assoc($result);
$sarray = unserialize($row['data']);
return $sarray;
}
开发者ID:CavemanJoe,项目名称:Improbable-Island---DragonScales---DragonBones---LotGD-2.0---Season-Three,代码行数:8,代码来源:lib.php
示例4: eboy_dohook
function eboy_dohook($hookname, $args)
{
global $session;
switch ($hookname) {
case "village":
tlschema($args['schemas']['marketnav']);
addnav($args['marketnav']);
tlschema();
addnav("eBoy's Trading Station", "runmodule.php?module=eboy&op=start");
break;
case "newday-runonce":
$eboyitems = get_items_with_settings("eboy");
//get number of players
$sql = "SELECT count(acctid) AS c FROM " . db_prefix("accounts") . " WHERE locked=0";
$result = db_query_cached($sql, "numplayers", 600);
$row = db_fetch_assoc($result);
$numplayers = $row['c'];
$sql = "SELECT * from " . db_prefix("cityprefs");
$result = db_query($sql);
$numrows = db_num_rows($result);
for ($i = 0; $i < $numrows; $i++) {
$row = db_fetch_assoc($result);
$cid = $row['cityid'];
foreach ($eboyitems as $item => $settings) {
//Advance Multiplier
if ($settings['eboy_multiplier_' . $cid]) {
if ($settings['eboy_stock_' . $cid] < $numplayers / 10) {
increment_item_setting("eboy_multiplier_" . $cid, 0.1, $item);
} else {
if ($settings['stock_' . $cid] > $numplayers / 5) {
increment_item_setting("eboy_multiplier_" . $cid, -0.1, $item);
}
}
//stop prices staying ridiculously low
if (get_item_setting("eboy_multiplier_" . $cid, $item) < 0.1) {
set_item_setting("eboy_multiplier_" . $cid, 0.1, $item);
}
//or going ridiculously high
if (get_item_setting("eboy_multiplier_" . $cid, $item) > 50) {
set_item_setting("eboy_multiplier_" . $cid, 50, $item);
}
} else {
set_item_setting("eboy_multiplier_" . $cid, 1, $item);
}
if (!isset($settings['eboy_stock_' . $cid])) {
set_item_setting("eboy_stock_" . $cid, 1, $item);
}
increment_item_setting("eboy_stock_" . $cid, $settings['eboy_dailyadd'], $item);
}
}
break;
case "items-returnlinks":
$args['eboy'] = "runmodule.php?module=eboy&op=start";
break;
}
return $args;
}
开发者ID:Beeps,项目名称:Improbable-Island---DragonScales---DragonBones---LotGD-2.0---Season-Three,代码行数:57,代码来源:eboy.php
示例5: getmount
function getmount($horse = 0)
{
$sql = "SELECT * FROM " . db_prefix("mounts") . " WHERE mountid='{$horse}'";
$result = db_query_cached($sql, "mountdata-{$horse}", 3600);
if (db_num_rows($result) > 0) {
return db_fetch_assoc($result);
} else {
return array();
}
}
示例6: good_word_list
function good_word_list() : array
{
$nastyWords = db_prefix('nastywords');
$sql = db_query_cached("SELECT * FROM {$nastyWords} WHERE type = 'good'", 'goodwordlist');
$row = db_fetch_assoc($sql);
if (!empty($row['words'])) {
return explode(' ', $row['words']);
} else {
return [];
}
}
示例7: statue_dohook
function statue_dohook($hookname, $args)
{
global $REQUEST_URI;
global $session;
$capital = getsetting("villagename", LOCATION_FIELDS);
$hero = get_module_setting("hero");
switch ($hookname) {
case "village-desc":
if ($session['user']['location'] != $capital) {
break;
}
if ($hero == 0) {
output("`n`@The people wandering past periodically stop to admire a statue of the ancient hero, `&MightyE`@.`0`n");
} else {
$sql = "SELECT name FROM " . db_prefix("accounts") . " WHERE acctid='{$hero}'";
$result = db_query_cached($sql, "lasthero");
$row = db_fetch_assoc($result);
output("`0The inhabitants of %s are busy erecting a statue for their newest hero, `&%s`0, on the only statue pedestal around. The remains of the statue that had stood there before lie in such ruins around the pedestal that it is no longer recognizable.`0`n`n", $session['user']['location'], $row['name']);
}
break;
case "index":
if (!get_module_setting("showonindex")) {
break;
}
$heroname = "MightyE";
if ($hero != 0) {
$sql = "SELECT name FROM " . db_prefix("accounts") . " WHERE acctid='{$hero}'";
$result = db_query_cached($sql, "lasthero");
$row = db_fetch_assoc($result);
$heroname = $row['name'];
}
output("`@The most recent hero of the realm is: `&%s`0`n`n", $heroname);
break;
case "dragonkill":
set_module_setting("hero", $session['user']['acctid']);
invalidatedatacache("lasthero");
break;
case "namechange":
if ($hero == $session['user']['acctid']) {
invalidatedatacache("lasthero");
}
break;
}
return $args;
}
开发者ID:CavemanJoe,项目名称:Improbable-Island---DragonScales---DragonBones---LotGD-2.0---Season-Three,代码行数:45,代码来源:statue.php
示例8: get_cityprefs_cityname
function get_cityprefs_cityname($lookup, $value, $player = false)
{
if ($player > 0) {
$sql1 = "select location from " . db_prefix("accounts") . " where acctid={$player}";
$res1 = db_query($sql1);
$row1 = db_fetch_assoc($res1);
return $row1['location'];
}
if ($lookup == 'module') {
$where = "module='" . addslashes($value) . "'";
} else {
$where = "cityid={$value}";
}
$sql = "select cityname from " . db_prefix("cityprefs") . " where {$where}";
$res = db_query_cached($sql, "cityid_" . $value);
$row = db_fetch_assoc($res);
return $row['cityname'];
}
开发者ID:CavemanJoe,项目名称:Improbable-Island---DragonScales---DragonBones---LotGD-2.0---Season-Three,代码行数:18,代码来源:lib.php
示例9: innchat_dohook
function innchat_dohook($hookname, $args)
{
global $session;
switch ($hookname) {
case "innchatter":
$id = $session['user']['acctid'];
if (e_rand(1, 2) == 1) {
$sql = "SELECT name FROM " . db_prefix("accounts") . " WHERE locked=0 AND acctid != '{$id}' ORDER BY rand(" . e_rand() . ") LIMIT 1";
} else {
$sql = "SELECT creaturename AS name FROM " . db_prefix("masters") . " WHERE 1 ORDER BY rand(" . e_rand() . ") LIMIT 1";
}
// Only let this hit the database once every 10 minute if we're
// using data caching. Otherwise it could be expensive. If they
// hit it multiple times within ten minutes, it'll use the same
// random name of player or master. We'll invalidate the name when someone's name changes
// for any reason.
$res = db_query_cached($sql, "innchat-names");
$row = db_fetch_assoc($res);
// Give 2 out of X (currently 7 (5+these 2)) chances of hearing about
// a player.
$noplayers = translate_inline("loneliness in town");
if ($row['name'] == "") {
$row['name'] = $noplayers;
}
$args[] = $row['name'];
$args[] = $row['name'];
$args[] = translate_inline("Frequently Asked Questions");
$args[] = translate_inline("dwarf tossing");
$args[] = translate_inline("YOU");
$args[] = getsetting("villagename", LOCATION_FIELDS);
$args[] = translate_inline("today's weather");
$args[] = translate_inline("the elementary discord of being");
// "Das elementare Zerwürfnis des Seins" no idea if that makes any sense in english. (Ok, it doesn't make sense in german too.) It's from a "Jägermeister" commercial spot :)
break;
case "namechange":
case "dragonkill":
// Someone just did a dragonkill or had their name changed. Since it
// it could have been this person, we'll just invalidate the cache
invalidatedatacache("innchat-names");
break;
}
return $args;
}
开发者ID:CavemanJoe,项目名称:Improbable-Island---DragonScales---DragonBones---LotGD-2.0---Season-Three,代码行数:43,代码来源:innchat.php
示例10: funddrive_getpercent
function funddrive_getpercent()
{
$targetmonth = get_module_setting("targetmonth");
if ($targetmonth == "") {
$targetmonth = date("m");
}
$start = date("Y") . "-" . $targetmonth . "-01";
$end = date("Y-m-d", strtotime("+1 month", strtotime($start)));
$result = db_query_cached("SELECT sum(amount) AS gross, sum(txfee) AS fees FROM " . db_prefix("paylog") . " WHERE processdate >= '{$start}' AND processdate < '{$end}'", "mod_funddrive_totals", 10);
$goal = get_module_setting("goalamount");
$base = get_module_setting("baseamount");
$row = db_fetch_assoc($result);
$current = $row['gross'] + $base;
if (get_module_setting("deductfees")) {
$current -= $row['fees'];
}
$pct = round($current / $goal * 100, 0);
$ret = array('percent' => $pct, 'goal' => $goal, 'current' => $current);
return $ret;
}
开发者ID:CavemanJoe,项目名称:Improbable-Island---DragonScales---DragonBones---LotGD-2.0---Season-Three,代码行数:20,代码来源:funddrive.php
示例11: improbablehousing_getnearbyhouses
function improbablehousing_getnearbyhouses($loc)
{
global $session;
//$sql = "SELECT hid,ownedby FROM " . db_prefix("buildings") . " WHERE location = '$loc'";
$sql = "SELECT * FROM " . db_prefix("buildings") . " WHERE location = '{$loc}'";
$result = db_query_cached($sql, "housing/housing_location_" . $loc);
//$result = db_query($sql);
//todo: cache this query, or rather, invalidate the cache properly after staking a claim
$n = db_num_rows($result);
//debug($n);
if (!$n) {
return null;
} else {
$r = array();
for ($i = 0; $i < $n; $i++) {
$row = db_fetch_assoc($result);
$house = improbablehousing_gethousedata($row['hid']);
$r[] = $house;
}
}
return $r;
}
开发者ID:Beeps,项目名称:Improbable-Island---DragonScales---DragonBones---LotGD-2.0---Season-Three,代码行数:22,代码来源:lib.php
示例12: tlschema
if (!$race) {
$race = RACE_UNKNOWN;
}
tlschema("race");
$race = translate_inline($race);
tlschema();
// output("`^Race: `@%s`n",$race);
$genders = array("Male", "Female");
$genders = translate_inline($genders);
output("`^Gender: `@%s`n", $genders[$target['sex']]);
$specialties = modulehook("specialtynames", array("" => translate_inline("Unspecified")));
if (isset($specialties[$target['specialty']])) {
output("`^Specialty: `@%s`n", $specialties[$target['specialty']]);
}
$sql = "SELECT * FROM " . db_prefix("mounts") . " WHERE mountid='{$target['hashorse']}'";
$result = db_query_cached($sql, "mountdata-{$target['hashorse']}", 3600);
$mount = db_fetch_assoc($result);
$mount['acctid'] = $target['acctid'];
$mount = modulehook("bio-mount", $mount);
$none = translate_inline("`iNone`i");
if (!isset($mount['mountname']) || $mount['mountname'] == "") {
$mount['mountname'] = $none;
}
output("`^Creature: `@%s`0`n", $mount['mountname']);
modulehook("biostat", $target);
if ($target['dragonkills'] > 0) {
output("`^Dragon Kills: `@%s`n", $target['dragonkills']);
}
if ($target['bio'] > "") {
output("`^Bio: `@`n%s`n", soap($target['bio']));
}
开发者ID:CavemanJoe,项目名称:Improbable-Island---DragonScales---DragonBones---LotGD-2.0---Season-Three,代码行数:31,代码来源:bio.php
示例13: stocks_dohook
function stocks_dohook($hookname, $args)
{
global $REQUEST_URI;
global $session;
$stocks = get_module_setting("victim");
$capital = getsetting("villagename", LOCATION_FIELDS);
switch ($hookname) {
case "village-desc":
if ($session['user']['location'] != $capital) {
break;
}
$op = httpget("op");
if ($op == "stocks") {
// Get rid of the op=stocks bit from the URI
$REQUEST_URI = preg_replace("/[&?]?op=stocks/", "", $REQUEST_URI);
$_SERVER['REQUEST_URI'] = preg_replace("/[&?]?op=stocks/", "", $_SERVER['REQUEST_URI']);
if ($stocks == 0) {
output("`n`0You head over to examine the stocks, and wondering how they work, you place your head and hands in the notches for them when SNAP, they clap shut, trapping you inside!`0`n");
modulehook("stocksenter");
} elseif ($stocks != $session['user']['acctid']) {
$sql = "SELECT name FROM " . db_prefix("accounts") . " WHERE acctid='{$stocks}'";
$result = db_query_cached($sql, "stocks");
$row = db_fetch_assoc($result);
output("`n`0You head over to examine the stocks, and out of compassion, you help %s`0 out of the stocks. ", $row['name']);
output("Wondering how they got in there in the first place, you place your own head and hands in them when SNAP, they clap shut, trapping you inside! `0`n");
modulehook("stocksenter");
}
set_module_setting("victim", $session['user']['acctid']);
invalidatedatacache("stocks");
} else {
$examine = translate_inline("Examine Stocks");
if ($stocks == 0) {
output("`n`0Next to the stables is an empty set of stocks.");
rawoutput(" [<a href='village.php?op=stocks'>{$examine}</a>]");
output_notl("`0`n");
addnav("", "village.php?op=stocks");
} elseif ($stocks == $session['user']['acctid']) {
output("`n`@You are now stuck in the stocks! All around you, people gape and stare. Small children climb on your back, waving wooden swords, and declaring you to be the slain dragon, with them the victor. This really grates you because you know you could totally take any one of these kids! Nearby, artists are drawing caricatures of paying patrons pretending to throw various vegetables at you.`0`n");
if (is_module_active("medals")) {
require_once "modules/medals.php";
medals_award_medal("stocks", "Stock Hog", "This player got stuck in the stocks!", "medal_stockades.png");
}
} else {
$sql = "SELECT name FROM " . db_prefix("accounts") . " WHERE acctid='{$stocks}'";
$result = db_query_cached($sql, "stocks");
$row = db_fetch_assoc($result);
output("`n`0Next to the statue is a set of stocks in which `&%s`0 seems to have become stuck!", $row['name']);
output_notl(" [");
rawoutput("<a href='village.php?op=stocks'>{$examine}</a>");
output_notl("]`0`n");
addnav("", "village.php?op=stocks");
}
}
break;
case "dragonkill":
case "namechange":
if ($stocks == $session['user']['acctid']) {
invalidatedatacache("stocks");
}
break;
}
return $args;
}
开发者ID:CavemanJoe,项目名称:Improbable-Island---DragonScales---DragonBones---LotGD-2.0---Season-Three,代码行数:63,代码来源:stocks.php
示例14: getsetting
$iname = getsetting("innname", LOCATION_INN);
$valid_loc[$vname] = "village";
$valid_loc = modulehook("validlocation", $valid_loc);
if (!isset($valid_loc[$session['user']['location']])) {
$session['user']['location'] = $vname;
}
$newestname = "";
$newestplayer = getsetting("newestplayer", "");
if ($newestplayer == $session['user']['acctid']) {
$newtext = "`nYou're the newest member of the village. As such, you wander around, gaping at the sights, and generally looking lost.";
$newestname = $session['user']['name'];
} else {
$newtext = "`n`2Wandering near the inn is `&%s`2, looking completely lost.";
if ((int) $newestplayer != 0) {
$sql = "SELECT name FROM " . db_prefix("accounts") . " WHERE acctid='{$newestplayer}'";
$result = db_query_cached($sql, "newest");
if (db_num_rows($result) == 1) {
$row = db_fetch_assoc($result);
$newestname = $row['name'];
} else {
$newestplayer = "";
}
} else {
if ($newestplayer > "") {
$newestname = $newestplayer;
} else {
$newestname = "";
}
}
}
$basetext = array("`@`c`b%s Square`b`cThe village of %s hustles and bustles. No one really notices that you're standing there. " . "You see various shops and businesses along main street. There is a curious looking rock to one side. " . "On every side the village is surrounded by deep dark forest.`n`n", $vname, $vname);
开发者ID:Beeps,项目名称:Improbable-Island---DragonScales---DragonBones---LotGD-2.0---Season-Three,代码行数:31,代码来源:village.php
示例15: checkday
checkday();
page_header("%s", sanitize($name));
set_module_pref("dwelling_saver", $dwid, "dwellings");
output_notl("`c`b%s`b`n`n%s`n`n`c`0", $row['name'], $row['description']);
if (get_module_setting("ownersleep", $type) && $session['user']['acctid'] == $row['ownerid']) {
addnav("Leave");
addnav("Go to Sleep (Log Out)", "runmodule.php?module=dwellings&op=logout&dwid={$dwid}&type={$type}&owner=1");
}
if (get_module_setting("othersleep", $type)) {
if ($session['user']['acctid'] != $row['ownerid']) {
addnav("Go to Sleep (Log Out)", "runmodule.php?module=dwellings&op=logout&dwid={$dwid}&type={$type}");
}
$ac = db_prefix("accounts");
$mu = db_prefix("module_userprefs");
$sql = "SELECT {$ac}.name AS name,\r\n\t\t\t\t{$ac}.acctid AS acctid,\r\n\t\t\t\t{$mu}.userid FROM {$mu} \r\n\t\t\t\tINNER JOIN {$ac} ON {$ac}.acctid = {$mu}.userid \r\n\t\t\t\tWHERE {$mu}.setting = 'dwelling_saver'\r\n\t\t\t\tand {$mu}.value = {$dwid} \r\n\t\t\t\tand {$ac}.loggedin = 0";
$res = db_query_cached($sql, "dwellings-sleepers-{$dwid}");
$i = 0;
$num = db_num_rows($res);
while ($row1 = db_fetch_assoc($res)) {
$pre = "";
$suf = "";
if ($i == 0) {
$pre = translate_inline("`nThe following people are sleeping here: ");
} elseif ($i > 0 && $num > 2) {
$pre = ", ";
}
if ($i > 0 && $i == $num - 1) {
$pre = $pre . "" . translate_inline("and ");
}
if ($i == $num - 1) {
$suf = ".`n`n";
开发者ID:CavemanJoe,项目名称:Improbable-Island---DragonScales---DragonBones---LotGD-2.0---Season-Three,代码行数:31,代码来源:case_enter.php