本文整理汇总了PHP中Cache::setContent方法的典型用法代码示例。如果您正苦于以下问题:PHP Cache::setContent方法的具体用法?PHP Cache::setContent怎么用?PHP Cache::setContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cache
的用法示例。
在下文中一共展示了Cache::setContent方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: indexAction
function indexAction()
{
/* @var $model CidadesModel */
$model = newModel('CidadesModel');
/* @var $v CidadeVO */
$start = microtime(true);
$estado = url_parans(0) ? url_parans(0) : inputPost('estado');
$cidade = url_parans(1) ? url_parans(1) : inputPost('cidade');
if ($estado > 0 or preg_match('/^[A-Z]{2}$/i', $estado)) {
$cache = new Cache('cidades.' . $estado, 60);
if (!($options = $cache->getContent())) {
$cidades = $model->getCidades($estado);
if (count($cidades)) {
$options = formOption('-- Selecione a cidade --', '');
} else {
$options = formOption('-- Selecione o estado --', '');
}
foreach ($cidades as $v) {
$options .= formOption($v->getTitle(), $v->getId(), false);
}
# Salvando cache
$cache->setContent($options);
}
echo preg_replace(['/(value="' . preg_quote($cidade) . '")/', '/>(' . preg_quote($cidade) . ')</'], ['$1 selected=""', 'selected="" >$1<'], $options);
}
$end = microtime(true);
echo "\n\n<!-- " . number_format(($end - $start) * 1000, 5, ',', '.') . "ms --> Buscou por {$cidade}";
exit;
}
示例2: guild_list
function guild_list($TFSVersion)
{
$cache = new Cache('engine/cache/guildlist');
if ($cache->hasExpired()) {
if ($TFSVersion != 'TFS_10') {
$guilds = mysql_select_multi("SELECT `t`.`id`, `t`.`name`, `t`.`creationdata`, `motd`, (SELECT count(p.rank_id) FROM players AS p LEFT JOIN guild_ranks AS gr ON gr.id = p.rank_id WHERE gr.guild_id =`t`.`id`) AS `total` FROM `guilds` as `t` ORDER BY `t`.`name`;");
} else {
$guilds = mysql_select_multi("SELECT `id`, `name`, `creationdata`, `motd`, (SELECT COUNT('guild_id') FROM `guild_membership` WHERE `guild_id`=`id`) AS `total` FROM `guilds` ORDER BY `name`;");
}
// Add level data info to guilds
if ($guilds !== false) {
for ($i = 0; $i < count($guilds); $i++) {
$guilds[$i]['level'] = get_guild_level_data($guilds[$i]['id']);
}
}
$cache->setContent($guilds);
$cache->save();
} else {
$guilds = $cache->load();
}
return $guilds;
}
示例3: join
}
if (!empty($playerlist)) {
$ids = join(',', $playerlist);
$tmpPlayers = mysql_select_multi("SELECT `id`, `name` FROM players WHERE `id` IN ({$ids});");
// Sort $tmpPlayers by player id
$tmpById = array();
foreach ($tmpPlayers as $p) {
$tmpById[$p['id']] = $p['name'];
}
for ($i = 0; $i < count($houses); $i++) {
if ($houses[$i]['owner'] > 0) {
$houses[$i]['ownername'] = $tmpById[$houses[$i]['owner']];
}
}
}
$cache->setContent($houses);
$cache->save();
}
} else {
$houses = $cache->load();
}
if ($houses !== false || !empty($houses)) {
// Intialize stuff
//data_dump($houses, false, "House data");
?>
<table id="housetable">
<tr class="yellow">
<th>Name</th>
<th>Size</th>
<th>Beds</th>
<th>Rent</th>
示例4: Cache
<div class="sidebar">
<h3>Top 5 players</h3>
<?php
$cache = new Cache('engine/cache/topPlayer');
if ($cache->hasExpired()) {
$players = mysql_select_multi('SELECT `name`, `level`, `experience` FROM `players` WHERE `group_id` < ' . $config['highscore']['ignoreGroupId'] . ' ORDER BY `experience` DESC LIMIT 5;');
$cache->setContent($players);
$cache->save();
} else {
$players = $cache->load();
}
if ($players) {
$count = 1;
foreach ($players as $player) {
echo "{$count} - <a href='characterprofile.php?name=" . $player['name'] . "'>" . $player['name'] . "</a> (" . $player['level'] . ").<br>";
$count++;
}
}
?>
<br>
</div>
示例5: Cache
echo $action === 2 ? $old['text'] : '';
?>
</textarea><br>
<input type="submit" value="Add or update changelog">
</form>
<?php
}
}
?>
<h1>Changelog</h1>
<?php
$cache = new Cache('engine/cache/changelog');
if ($updateCache === true) {
$changelogs = mysql_select_multi("SELECT `id`, `text`, `time`, `report_id`, `status` FROM `znote_changelog` ORDER BY `id` DESC;");
$cache->setContent($changelogs);
$cache->save();
} else {
$changelogs = $cache->load();
}
if (isset($changelogs) && !empty($changelogs) && $changelogs !== false) {
?>
<table id="changelogTable">
<tr class="yellow">
<td>Changelogs</td>
<?php
if (user_logged_in()) {
if (is_admin($user_data)) {
echo "<td>Delete</td><td>Update</td>";
}
}
示例6: VALUES
$updatechangelog = false;
if ($changelog !== false) {
// Update it
mysql_update("UPDATE `znote_changelog` SET `text`='{$changelogText}', `time`='{$time}' WHERE `id`='" . $changelog['id'] . "' LIMIT 1;");
echo "<h2>Changelog message updated!</h2>";
$updatechangelog = true;
} else {
// Create it
mysql_insert("INSERT INTO `znote_changelog` (`text`, `time`, `report_id`, `status`) \n VALUES ('{$changelogText}', '{$time}', '{$changelogReportId}', '{$status}');");
echo "<h2>Changelog message created!</h2>";
$updatechangelog = true;
}
if ($updatechangelog) {
// Cache changelog
$cache = new Cache('engine/cache/changelog');
$cache->setContent(mysql_select_multi("SELECT `id`, `text`, `time`, `report_id`, `status` FROM `znote_changelog` ORDER BY `id` DESC;"));
$cache->save();
}
}
// If we should give user price
if ($price > 0) {
$account = mysql_select_single("SELECT `a`.`id`, `a`.`email` FROM `accounts` AS `a` \n INNER JOIN `players` AS `p` ON `p`.`account_id` = `a`.`id`\n WHERE `p`.`name` = '{$playerName}' LIMIT 1;");
if ($account !== false) {
// transaction log
mysql_insert("INSERT INTO `znote_paypal` VALUES ('', '{$reportId}', 'report@admin." . $user_data['name'] . " to " . $account['email'] . "', '" . $account['id'] . "', '0', '" . $price . "')");
// Process payment
$data = mysql_select_single("SELECT `points` AS `old_points` FROM `znote_accounts` WHERE `account_id`='" . $account['id'] . "';");
// Give points to user
$new_points = $data['old_points'] + $price;
mysql_update("UPDATE `znote_accounts` SET `points`='{$new_points}' WHERE `account_id`='" . $account['id'] . "'");
// Remind GM that he sent points to character
示例7: skillName
$highscore = $config['highscore'];
$rows = $highscore['rows'];
$rowsPerPage = $highscore['rowsPerPage'];
function skillName($type)
{
$types = array(1 => "Club", 2 => "Sword", 3 => "Axe", 4 => "Distance", 5 => "Shield", 6 => "Fish", 7 => "Experience", 8 => "Magic Level", 9 => "Fist");
return $types[(int) $type];
}
function pageCheck($index, $page, $rowPerPage)
{
return $index < $page * $rowPerPage && $index >= $page * $rowPerPage - $rowPerPage ? true : false;
}
$cache = new Cache('engine/cache/highscores');
if ($cache->hasExpired()) {
$scores = fetchAllScores($rows, $config['TFSVersion'], $highscore['ignoreGroupId']);
$cache->setContent($scores);
$cache->save();
} else {
$scores = $cache->load();
}
if ($scores) {
?>
<h1>Ranking for <?php
echo skillName($type);
?>
.</h1>
<form action="" method="GET">
<select name="type">
<option value="7" <?php
if ($type == 7) {
echo "selected";
示例8: Cache
<?php
require_once 'engine/init.php';
include 'layout/overall/header.php';
$cache = new Cache('engine/cache/deaths');
if ($cache->hasExpired()) {
if ($config['TFSVersion'] == 'TFS_02' || $config['TFSVersion'] == 'TFS_10') {
$deaths = fetchLatestDeaths();
} else {
if ($config['TFSVersion'] == 'TFS_03') {
$deaths = fetchLatestDeaths_03(30);
}
}
$cache->setContent($deaths);
$cache->save();
} else {
$deaths = $cache->load();
}
if ($deaths) {
?>
<h1>Latest Deaths</h1>
<table id="deathsTable" class="table table-striped">
<tr class="yellow">
<th>Victim</th>
<th>Time</th>
<th>Killer</th>
</tr>
<?php
foreach ($deaths as $death) {
echo '<tr>';
echo "<td>At level " . $death['level'] . ": <a href='characterprofile.php?name=" . $death['victim'] . "'>" . $death['victim'] . "</a></td>";
示例9: Cache
?>
</td>
</tr>
<?php
}
?>
</table>
<?php
} else {
echo "No changelogs submitted.";
}
}
$cache = new Cache('engine/cache/news');
if ($cache->hasExpired()) {
$news = fetchAllNews();
$cache->setContent($news);
$cache->save();
} else {
$news = $cache->load();
}
// Design and present the list
if ($news) {
$total_news = count($news);
$row_news = $total_news / $config['news_per_page'];
$page_amount = ceil($total_news / $config['news_per_page']);
$current = $config['news_per_page'] * $page;
function TransformToBBCode($string)
{
$tags = array('[center]{$1}[/center]' => '<center>$1</center>', '[b]{$1}[/b]' => '<b>$1</b>', '[size={$1}]{$2}[/size]' => '<font size="$1">$2</font>', '[img]{$1}[/img]' => '<a href="$1" target="_BLANK"><img src="$1" alt="image" style="width: 100%"></a>', '[link]{$1}[/link]' => '<a href="$1">$1</a>', '[link={$1}]{$2}[/link]' => '<a href="$1" target="_BLANK">$2</a>', '[color={$1}]{$2}[/color]' => '<font color="$1">$2</font>', '[*]{$1}[/*]' => '<li>$1</li>', '[youtube]{$1}[/youtube]' => '<div class="youtube"><div class="aspectratio"><iframe src="//www.youtube.com/embed/$1" frameborder="0" allowfullscreen></iframe></div></div>');
foreach ($tags as $tag => $value) {
$code = preg_replace('/placeholder([0-9]+)/', '(.*?)', preg_quote(preg_replace('/\\{\\$([0-9]+)\\}/', 'placeholder$1', $tag), '/'));
示例10: foreach
$staffs = support_list();
// Fetch group ids and names from config.php
$groups = $config['ingame_positions'];
// Loops through groups, separating each group element into an ID variable and name variable
foreach ($groups as $group_id => $group_name) {
// Loops through list of staffs
if (!empty($staffs)) {
foreach ($staffs as $staff) {
if ($staff['group_id'] == $group_id) {
$srtGrp[$group_name][] = $staff;
}
}
}
}
if (!empty($srtGrp)) {
$cache->setContent($srtGrp);
$cache->save();
}
} else {
$srtGrp = $cache->load();
}
$writeHeader = true;
if (!empty($srtGrp)) {
foreach (array_reverse($srtGrp) as $grpName => $grpList) {
?>
<table id="supportTable" class="table table-striped">
<?php
if ($writeHeader) {
$writeHeader = false;
?>
<tr class="yellow">
示例11: list_paths
/**
* Lista todas as pastas do diretório informado
* @param string $Pasta
* @return array
*/
function list_paths($Pasta)
{
$cache = new Cache('config.paths_' . sha1($Pasta), 1);
if (!($Pastas = $cache->getContent())) {
$Pastas = [];
foreach (glob(ABSPATH . "/{$Pasta}/*") as $Path) {
if (is_dir($Path)) {
$Path = str_replace([ABSPATH . '/', ABSPATH . '\\'], null, $Path);
$Pastas[] = str_replace(['/', '\\'], DIRECTORY_SEPARATOR, $Path);
$Pastas = array_merge($Pastas, list_paths($Path));
}
}
$cache->setContent($Pastas);
}
return $Pastas;
}
示例12: convert_number_to_words
<?php
require_once 'engine/init.php';
include 'layout/overall/header.php';
// Cache the results
$cache = new Cache('engine/cache/topGuilds');
if ($cache->hasExpired()) {
$guilds = mysql_select_multi("SELECT `g`.`id` AS `id`, `g`.`name` AS `name`, COUNT(`g`.`name`) as `frags` FROM `players` p LEFT JOIN `player_deaths` pd ON `pd`.`killed_by` = `p`.`name` LEFT JOIN `guild_membership` gm ON `p`.`id` = `gm`.`player_id` LEFT JOIN `guilds` g ON `gm`.`guild_id` = `g`.`id` WHERE `pd`.`unjustified` = 1 GROUP BY `name` ORDER BY `frags` DESC, `name` ASC LIMIT 0, 10;");
$cache->setContent($guilds);
$cache->save();
} else {
$guilds = $cache->load();
}
$count = 1;
function convert_number_to_words($number)
{
$hyphen = '-';
$conjunction = ' and ';
$separator = ', ';
$negative = 'negative ';
$decimal = ' point ';
$dictionary = array(0 => 'zero', 1 => 'First', 2 => 'Second', 3 => 'Third', 4 => 'Fourth', 5 => 'Fifth', 6 => 'Sixth', 7 => 'Seventh', 8 => 'Eighth', 9 => 'Ninth', 10 => 'Tenth', 11 => 'eleventh', 12 => 'twelve', 13 => 'thirteen', 14 => 'fourteen', 15 => 'fifteen', 16 => 'sixteen', 17 => 'seventeen', 18 => 'eighteen', 19 => 'nineteen', 20 => 'twenty', 30 => 'thirty', 40 => 'fourty', 50 => 'fifty', 60 => 'sixty', 70 => 'seventy', 80 => 'eighty', 90 => 'ninety', 100 => 'hundred', 1000 => 'thousand', 1000000 => 'million', 1000000000 => 'billion', 1000000000000 => 'trillion', 1000000000000000 => 'quadrillion', 1000000000000000000 => 'quintillion');
if (!is_numeric($number)) {
return false;
}
if ($number >= 0 && (int) $number < 0 || (int) $number < 0 - PHP_INT_MAX) {
// overflow
trigger_error('convert_number_to_words only accepts numbers between -' . PHP_INT_MAX . ' and ' . PHP_INT_MAX, E_USER_WARNING);
return false;
}
if ($number < 0) {
示例13: Cache
if (isset($_POST['accept']) || isset($_POST['delete'])) {
$cache = new Cache('engine/cache/gallery');
$images = fetchImages(2);
if ($images != false) {
$data = array();
foreach ($images as $image) {
$row['title'] = $image['title'];
$row['desc'] = $image['desc'];
$row['date'] = $image['date'];
$row['image'] = $image['image'];
$data[] = $row;
}
} else {
$data = "";
}
$cache->setContent($data);
$cache->save();
}
?>
<h1>Images in need of moderation:</h1><?php
$images = fetchImages(1);
if ($images != false) {
foreach ($images as $image) {
$pw = explode("!", $image['image']);
?>
<table>
<tr class="yellow">
<td><h2><?php
echo $image['title'];
?>
<form action="" method="post"><input type="submit" name="accept" value="<?php
示例14: getItemList
<?php
require_once 'engine/init.php';
include 'layout/overall/header.php';
$server = $config['shop']['imageServer'];
$imageType = $config['shop']['imageType'];
$items = getItemList();
$compare =& $_GET['compare'];
// If you are not comparing any items, present the list.
if (!$compare) {
$cache = new Cache('engine/cache/market');
$cache->setExpiration(6);
if ($cache->hasExpired()) {
$offers = array('wts' => mysql_select_multi("SELECT `id`, `itemtype` AS `item_id`, `amount`, `price`, `created`, `anonymous`, (SELECT `name` FROM `players` WHERE `id` = `player_id`) AS `player_name` FROM `market_offers` WHERE `sale` = 1 ORDER BY `created` DESC;"), 'wtb' => mysql_select_multi("SELECT `id`, `itemtype` AS `item_id`, `amount`, `price`, `created`, `anonymous`, (SELECT `name` FROM `players` WHERE `id` = `player_id`) AS `player_name` FROM `market_offers` WHERE `sale` = 0 ORDER BY `created` DESC;"));
$cache->setContent($offers);
$cache->save();
} else {
$offers = $cache->load();
}
?>
<h1>Marketplace</h1>
<p>You can buy and sell items by clicking on the <a target="_BLANK" href="http://4.ii.gl/CAPcBp.png">market in depot.</a> <br>To sell an item: Place item inside your depot, click on market, search for your item and sell it.</p>
<h2>WTS: Want to sell</h2>
<table class="table tbl-hover">
<tr class="yellow">
<td>Item name</td>
<td>Item</td>
<td>Count</td>
<td>Price for 1</td>
<td>Added</td>
<td>By</td>