当前位置: 首页>>代码示例>>PHP>>正文


PHP cache::date方法代码示例

本文整理汇总了PHP中cache::date方法的典型用法代码示例。如果您正苦于以下问题:PHP cache::date方法的具体用法?PHP cache::date怎么用?PHP cache::date使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cache的用法示例。


在下文中一共展示了cache::date方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: prepare

 public function prepare()
 {
     global $schema, $settings;
     $this->template = "economy";
     $this->tab = 'item';
     $this->title = "State of the economy";
     $b = new backpack(false);
     $json = cache::read('item_stats.json');
     $item_stats = json_decode($json, true);
     $total_items = $item_stats['total_items'];
     $metal_index = $item_stats['total_metal'] / $item_stats['total_players'];
     $this->params['metal_index'] = $metal_index;
     krsort($this->params['effects']);
     $this->params['profiles'] = $item_stats['total_players'];
     $this->params['time'] = cache::date('item_stats.json');
 }
开发者ID:mwilchez,项目名称:master,代码行数:16,代码来源:economy.view.php

示例2: prepare

 public function prepare()
 {
     global $schema, $settings;
     $this->template = "paints";
     $this->tab = 'item';
     $this->title = "Paint statistics";
     $sort_table = array('total' => 'painted', 'owned' => 'owned', 'used' => 'usage');
     $b = new backpack(false);
     $sortkey = 'painted';
     if ($this->request['sort'] && array_key_exists($this->request['sort'], $sort_table)) {
         $sortkey = $sort_table[$this->request['sort']];
         $this->params['sort'][$this->request['sort']] = 'selected';
     } else {
         $this->params['sort']['total'] = 'selected';
     }
     $item_stats = cache::Memcached()->get('item_stats');
     if ($item_stats === false) {
         $json = file_get_contents($settings['cache']['folder'] . 'item_stats.json');
         $item_stats = json_decode($json, true);
         cache::Memcached()->set('item_stats', $item_stats, time() + 60 * 15);
     }
     $total_paints = $item_stats['total_colors'];
     $total_items = $item_stats['total_items'];
     foreach ($item_stats['colors'] as $c => $p) {
         $id = get_paint_by_color($c);
         if (!$id) {
             continue;
         }
         //printf("Color: %s, id: %s <br />",$c, $id);
         $s = $item_stats['items'][$id];
         $si = $schema['items'][$id];
         $i = $b->get_item($si);
         $owned = $s['total'] / $item_stats['total_players'];
         //printf("Owned: %s, Total: %s<br>", $s['total'], $item_stats['total_players']);
         $paint = array('total' => $p, 'color' => $c, 'painted' => $p / $total_paints, 'owned' => ($s['total'] + $p) / $item_stats['total_players'], 'usage' => $p / ($s['total'] + $p));
         $key = (string) intval($paint[$sortkey] * 10000);
         while ($paints[$key] > 0) {
             $key++;
         }
         //printf("%s -> %s: %s<br />",$paint[$sortkey], $key, $i['name']);
         $paints[$key] = array_merge($paint, $i);
     }
     $this->params['paints'] = $paints;
     krsort($this->params['paints']);
     $this->params['profiles'] = $item_stats['total_players'];
     $this->params['time'] = cache::date('item_stats.json');
 }
开发者ID:mwilchez,项目名称:master,代码行数:47,代码来源:paints.view.php

示例3: prepare

 public function prepare()
 {
     global $schema, $settings;
     $this->template = "effects";
     $this->tab = 'item';
     $this->title = "Effect statistics";
     $b = new backpack(false);
     $item_stats = cache::Memcached()->get('item_stats');
     if ($item_stats === false) {
         $json = file_get_contents($settings['cache']['folder'] . 'item_stats.json');
         $item_stats = json_decode($json, true);
         cache::Memcached()->set('item_stats', $item_stats, time() + 60 * 15);
     }
     $total_effects = $item_stats['total_effects'];
     $total_items = $item_stats['total_items'];
     foreach ($item_stats['effects'] as $c => $p) {
         $c = (int) $c;
         // I don't even
         //if($c && $c > 0)
         //{
         $name = int_to_effect($c);
         $class = 'rarity4';
         if ($c == 4) {
             $class = 'community';
         }
         if ($c == 2) {
             $class = 'developer';
         }
         $img = sprintf("%sxy78/%d.png", $settings['upload']['resized_ext']['effects'], $c);
         if (!file_exists($settings['upload']['folder']['effects'] . $c . '.png')) {
             $img = '/static/images/items/sized/xy78/unknown.png';
         }
         $i = $p;
         while ($effects[(string) $i]) {
             $i += 0.01;
         }
         $effects[(string) $i] = array('total' => $p / $total_effects, 'global' => $p / $total_items, 'players' => $p / $item_stats['total_players'], 'effect' => $c, 'image' => $img, 'name' => $name, 'tooltip' => sprintf('<h1 class="%s">%s</h1>', $class, $name), 'raw' => $p, 'sort' => $i);
         //}
     }
     $this->params['effects'] = $effects;
     krsort($this->params['effects']);
     $this->params['profiles'] = $item_stats['total_players'];
     $this->params['time'] = cache::date('item_stats.json');
 }
开发者ID:mwilchez,项目名称:master,代码行数:44,代码来源:effects.view.php

示例4: prepare

 public function prepare()
 {
     global $schema, $settings;
     $this->template = "qualities";
     $this->tab = 'item';
     $this->title = "Quality statistics";
     $b = new backpack(false);
     $json = cache::read('item_stats.json');
     $item_stats = json_decode($json, true);
     $total_qualities = $item_stats['qualities_total'];
     $total_items = $item_stats['total_items'];
     $qualities = array();
     foreach ($item_stats['qualities'] as $c => $p) {
         $qualities[$p] = array('total' => $p / $total_items, 'quality' => $c, 'name' => quality_to_label(int_to_quality($c)), 'color' => quality_to_color(int_to_quality($c)), 'tooltip' => sprintf('<h1 class="%s">%s</h1>', int_to_quality($c), quality_to_label(int_to_quality($c))));
     }
     $this->params['qualities'] = $qualities;
     krsort($this->params['qualities']);
     //var_dump($this->params['qualities']);
     $this->params['profiles'] = $item_stats['total_players'];
     $this->params['time'] = cache::date('item_stats.json');
 }
开发者ID:mwilchez,项目名称:master,代码行数:21,代码来源:qualities.view.php

示例5: prepare


//.........这里部分代码省略.........
         $sortkey = $sort_table[$this->request['sort']];
         $this->params['sort'][$this->request['sort']] = 'selected';
     } else {
         $this->params['sort']['owned'] = 'selected';
     }
     $item_stats = cache::Memcached()->get('item_stats');
     if ($item_stats === false) {
         $json = file_get_contents($settings['cache']['folder'] . 'item_stats.json');
         $item_stats = json_decode($json, true);
         cache::Memcached()->set('item_stats', $item_stats, time() + 60 * 15);
     }
     // First. build a class->slot->items[] array for our stats
     foreach ($item_stats['items'] as $defindex => $s) {
         // Skip tokens
         if ($defindex > 5000) {
             continue;
         }
         $si = $schema['items'][$defindex];
         if (in_array($si['item_slot'], array('primary', 'secondary', 'melee', 'pda', 'pda2'))) {
             $i = $b->get_item($si);
             $i['owned'] = $s['unique_total'] / $item_stats['total_players'];
             //if($i['owned'] > 1)
             //	$i['owned'] = 1;
             if (!empty($i['used_by_classes'])) {
                 foreach ($i['used_by_classes'] as $c) {
                     $ci = class_to_int($c);
                     $i['equipped'] = $s['equipped'][$ci] / $item_stats['total_players'];
                     $i['owned_equipped'] = $s['equipped'][$ci] / $s['unique_total'];
                     $i['owned_equipped_key'] = $i['owned_equipped'] * 1000;
                     $key = $i[$sortkey];
                     while ($weapons[$c][$si['item_slot']][(string) $key] > 0) {
                         $key += 0.001;
                     }
                     $weapons[$c][$si['item_slot']][(string) $key] = $i;
                     $weapon_totals[$c][$si['item_slot']] += $i['equipped'];
                 }
             }
         }
     }
     // Now go through and combine the cosmetics defined above, as well as determine
     // stats for the 'base' weapon since valve's solution is to leave the slot
     // blank if we're using one
     foreach ($base_weapons as $class => $slots) {
         foreach ($slots as $slot => $s) {
             $si = $schema['items'][$s['base']];
             $i = $b->get_item($si);
             //$i['owned'] = ($s['total'] / $item_stats['total_players']);
             //if($i['owned'] > 1)
             //	$i['owned'] = 1;
             //$i['equipped'] = ($s['total_equipped'] / $item_stats['total_players']);
             //$i['owned_equipped'] = ($s['total_equipped'] / $s['total']);
             $i['equipped'] = 1 - $weapon_totals[$class][$slot];
             $i['owned'] = 1;
             //echo $i['equipped'];
             if (!$s['add']) {
                 continue;
             }
             foreach ($s['add'] as $a) {
                 foreach ($weapons[$class] as $csl => $t) {
                     foreach ($weapons[$class][$csl] as $k => $w) {
                         if ($w['defindex'] == $a) {
                             $sl = $csl;
                             $other = $w;
                             $key = $k;
                             break;
                         }
                     }
                 }
                 $i['equipped'] += $other['equipped'];
                 // Fix that silly rounding error causing the
                 // pipe launcher to be used by 100.01%
                 if ($i['equipped'] > 1) {
                     $i['equipped'] = 1;
                 }
                 $weapons[$class][$sl][$key]['hide'] = true;
             }
             $i['owned_equipped'] = $i['equipped'];
             $i['owned_equipped_key'] = $i['owned_equipped'] * 1000;
             $key = $i[$sortkey];
             while ($weapons[$class][$slot][(string) $key]) {
                 $key += 0.001;
             }
             $weapons[$class][$slot][(string) $key] = $i;
             unset($key);
         }
     }
     // finally, sort the results
     // Instead of wasting time sorting arrays and subarrays we can just
     // reconstruct a new array in the order of the slot array above
     // and only sort the bits that really need it.
     foreach ($base_weapons as $class => $slots) {
         foreach ($slots as $slot => $info) {
             $out[$class][$slot] = $weapons[$class][$slot];
             krsort($out[$class][$slot]);
         }
     }
     $this->params['profiles'] = $item_stats['total_players'];
     $this->params['time'] = cache::date('item_stats.json');
     $this->params['weapons'] = $out;
 }
开发者ID:mwilchez,项目名称:master,代码行数:101,代码来源:weapons.view.php

示例6: prepare

 public function prepare()
 {
     global $schema, $settings;
     $this->template = "hats";
     $this->tab = 'item';
     $this->title = "Hat statistics";
     $this->canonical = 'http://tf2stats.net/hats/';
     $sort_table = array('owned' => 'unique_total', 'equipped' => 'total_equipped', 'own_equip' => 'owned_equipped');
     $b = new backpack(false);
     $sortkey = 'unique_total';
     if ($this->request['sort'] && array_key_exists($this->request['sort'], $sort_table)) {
         $sortkey = $sort_table[$this->request['sort']];
         $this->params['sort'][$this->request['sort']] = 'selected';
     } else {
         $this->params['sort']['owned'] = 'selected';
     }
     $item_stats = cache::Memcached()->get('item_stats');
     if ($item_stats === false) {
         $json = file_get_contents($settings['cache']['folder'] . 'item_stats.json');
         $item_stats = json_decode($json, true);
         cache::Memcached()->set('item_stats', $item_stats, time() + 60 * 15);
     }
     foreach ($item_stats['items'] as $defindex => $s) {
         $si = $schema['items'][$defindex];
         if ($si['item_slot'] == 'head') {
             $i = $b->get_item($si);
             $i['owned'] = $s['unique_total'] / $item_stats['total_players'];
             //if($i['owned'] > 1)
             //	$i['owned'] = 1;
             $i['equipped'] = $s['total_equipped'] / $item_stats['total_players'];
             $i['owned_equipped'] = $s['total_equipped'] / $s['total'];
             $s['owned_equipped'] = intval($s['total_equipped'] / $s['total'] * 1000);
             // Colors
             /*
             	arsort($s['colors']);
             	
             	foreach($s['colors'] as $c => $num)
             	{
             		$html = dechex($c);
             		if($html === '0')
             			continue;//$html = '914c3f';
             		$key = $num;
             		while($i['colors'][$key] > 0)
             			$key++;
             		$i['colors'][$key] = array('color' => $html, 'num' => ($num/$s['total_colored']));
             	}	
             */
             if (count($i['used_by_classes']['class']) < 1) {
                 for ($c = 1; $c < 10; $c++) {
                     $num = $s['equipped'][$c];
                     if ($s['total_equipped'] > 0) {
                         $i['classes'][] = array('class' => int_to_class($c), 'id' => $c, 'num' => $num / $s['total_equipped']);
                     }
                 }
             }
             $key = $s[$sortkey];
             while ($this->params['hats'][$key] > 0) {
                 $key++;
             }
             $this->params['hats'][$key] = $i;
         }
     }
     krsort($this->params['hats']);
     $this->params['profiles'] = $item_stats['total_players'];
     $this->params['time'] = cache::date('item_stats.json');
 }
开发者ID:mwilchez,项目名称:master,代码行数:66,代码来源:hats.view.php


注:本文中的cache::date方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。