本文整理汇总了PHP中cache::log方法的典型用法代码示例。如果您正苦于以下问题:PHP cache::log方法的具体用法?PHP cache::log怎么用?PHP cache::log使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cache
的用法示例。
在下文中一共展示了cache::log方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: multi_run
public static function multi_run()
{
global $MULTI_REQUESTS;
if (count($MULTI_REQUESTS) > 0) {
cache::log(sprintf("multi_run on %s urls.", count($MULTI_REQUESTS)));
return cache::curl_multi_get($MULTI_REQUESTS);
}
}
示例2: prepare
public function prepare()
{
global $db, $user, $settings;
// auth check
$auth = $db->query_first("SELECT mp.type FROM tf2stats_map_to_player mp LEFT JOIN tf2_maps m ON m.id = mp.map_id\r\n\t\t\t\t\t\tWHERE mp.player_id = %s AND m.name = %s", array($user->id(), $this->request[0]));
if (!in_array($auth['type'], array('M', 'A', 'C'))) {
page::error("Little man", "You are no match for me!");
}
// handle file removals
if ($this->request[1] == 'delimg') {
$db->query("DELETE FROM tf2stats_map_images WHERE image = %s", array($this->request[2]));
$this->params['success'] = "Deleted " . $this->request[2];
}
// update
if ($_REQUEST['update']) {
if ($_REQUEST['filesize'] && !is_numeric($_REQUEST['filesize'])) {
$this->params['error'] = 'Filesize must be numeric. Do not append "MB".';
} elseif ($_REQUEST['url'] && !filter_var($_REQUEST['url'], FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED)) {
$this->params['error'] = 'Download URL is not valid.';
} else {
$i = $db->query_first("SELECT m.id, m.official FROM tf2_maps m WHERE m.name = %s", array($this->request[0]));
if (IsUserAdmin()) {
$Official = (int) (isset($_REQUEST['official']) && $_REQUEST['official'] == 'official');
cache::log("Changing official status for " . $i['id'] . " - old: " . $i['official'] . " - new: " . $Official);
if ($i['official'] != $Official) {
$db->query("UPDATE tf2_maps SET official = %s WHERE id = %s", array($Official, $i['id']));
}
}
$db->query("INSERT INTO tf2stats_managed_maps (player_id, map_id, edit_time, description, file_size, download_url) VALUES(%s, %s, %s, %s, %s, %s)\r\n\t\t\t\t\t\t\tON DUPLICATE KEY UPDATE edit_time=%s, description=%s, file_size=%s, download_url = %s", array($user->id(), $i['id'], time(), $_REQUEST['description'], $_REQUEST['filesize'], $_REQUEST['url'], time(), $_REQUEST['description'], $_REQUEST['filesize'], $_REQUEST['url']));
}
}
// map info
$map_info = $db->query_first("SELECT m.name, m.id, m.official, mp.description, mp.file_size, mp.download_url, mp.edit_time, p.name as player_name FROM tf2stats_managed_maps mp \r\n\t\t\t\t\t\tLEFT JOIN tf2_maps m ON m.id = mp.map_id\r\n\t\t\t\t\t\tLEFT JOIN tf2_players p on mp.player_id = p.id\r\n\t\t\t\t\t\tWHERE m.name = %s\r\n\t\t\t\t\t\tORDER BY edit_time DESC\r\n\t\t\t\t\t\tLIMIT 1", array($this->request[0]));
if ($map_info) {
$this->params['old'] = true;
} else {
$map_info = $db->query_first("SELECT m.name, m.id FROM tf2_maps m WHERE m.name = %s", array($this->request[0]));
}
$this->params['map_info'] = $map_info;
// handle adding authors.
if ($this->request[1] == 'addauthor') {
if ($this->request['search']) {
$player_id = $this->request['search'];
if (!is_id64($player_id)) {
$player_id = get_id64($this->request['search']);
}
$player = new player($player_id);
if ($player->id()) {
$db->query("INSERT INTO tf2stats_map_to_player(player_id, map_id, type) VALUES(%s, %s, %s)", array($player->id(), $map_info['id'], 'A'));
$this->params['success'] = $player_id . ' has been added to the author list.';
} else {
$this->params['error'] = "Could not find a player by '" . $_REQUEST['search'] . "'. Please refine your search.";
}
} else {
$this->template = "manage_map_author";
$this->title = sprintf("Adding author for %s", htmlspecialchars($map_info['name']));
return;
}
}
if ($this->request[1] == 'delauthor') {
$id = $this->request[2];
$db->query("DELETE FROM tf2stats_map_to_player WHERE player_id=%s AND map_id = %s", array($id, $map_info['id']));
$this->params['success'] = "Deleted author";
}
// handle file uploads.
if ($this->request[1] == 'upload') {
$this->template = "manage_map_upload";
$this->title = sprintf("Upload image for %s", htmlspecialchars($map_info['name']));
$this->params['allowed_images'] = implode(', ', $settings['upload']['allowed_images']);
if ($_FILES['image']) {
if (!$_FILES['image']['tmp_name']) {
$this->params['error'] = 'Upload failed. (This usually happens when you try to upload a file larger than 1MB!)';
return;
}
// check extension.
$ext = end(explode(".", strtolower($_FILES['image']['name'])));
if (!in_array($ext, $settings['upload']['allowed_images'])) {
$this->params['error'] = 'Unsupported file extension ' . $ext . '. Please convert your image to one of these formats: ' . implode(', ', $settings['upload']['allowed_images']);
return;
}
// rename if already exists
$filename = sprintf("%s_%s", $map_info['id'], str_replace(array('(', ')', ' '), '_', basename($_FILES['image']['name'])));
$target_path = $settings['upload']['folder']['maps'] . $filename;
while (file_exists($target_path)) {
$filename = md5(time() . rand()) . '.' . $ext;
$target_path = $settings['upload']['folder']['maps'] . $filename;
}
//var_dump($target_path);
if (filesize($_FILES['image']['tmp_name']) > 2097152) {
$this->params['error'] = 'Uploaded file cannot exceed 1MB.';
return;
}
if (move_uploaded_file($_FILES['image']['tmp_name'], $target_path)) {
$db->query("INSERT INTO tf2stats_map_images (map_id, player_id, image) VALUES(%s, %s, %s)", array($map_info['id'], $user->id(), $filename));
$this->params['success'] = basename($_FILES['image']['name']) . ' uploaded successfully.';
} else {
echo $_FILES['image']['tmp_name'];
echo $target_path;
$this->params['error'] = 'Unknown error. Please nag FireSlash until he fixes it.';
}
//.........这里部分代码省略.........
示例3: update_schema
function update_schema()
{
global $db, $settings;
$response = cache::get(sprintf('http://api.steampowered.com/IEconItems_440/GetSchema/v0001/?key=%s&format=json&language=en', $settings['api_key']), 60);
$json = json_decode($response, true);
$s = $json['result'];
//print $response;
$s['items'] = $s['items'];
$s['attributes'] = $s['attributes'];
if (!isset($s['items'])) {
die("FAILED" . PHP_EOL . $response);
}
foreach ($s['items'] as $k => $i) {
//$bits = explode('/',$i['image_url']);
//$im = $bits[count($bits)-1];
$s['items'][$k]['quality'] = $i['item_quality'];
//$s['items'][$k]['image'] = basename($i['image_inventory']).'.png';
//$s['items'][$k]['image_url'] = sprintf('http://media.steampowered.com/apps/440/icons/%s',$s['items'][$k]['image']);
//$img = $settings['upload']['folder']['items'].basename($i['image_inventory']).'.png';
if ($i['image_inventory'] == 'backpack/player/items/crafting/paintcan') {
$s['items'][$k]['image'] = 'paintcan.png';
$s['items'][$k]['image_url'] = 'http://media.steampowered.com/apps/440/icons/paintcan.png';
continue;
}
$url = $i['image_url'];
$name = basename($url);
if (!strlen($url)) {
cache::log(sprintf("<i>(ID: %d)</i> <b>%s</b> — no image!", $i['defindex'], substr($i['item_name'], 0, 60)));
$s['items'][$k]['image_url'] = 'http://tf2stats.net/images/unknown.png';
$s['items'][$k]['image'] = 'unknown.png';
continue;
}
$s['items'][$k]['image'] = $name;
$img = $settings['upload']['folder']['items'] . $name;
if (!file_exists($img)) {
//printf("<br><b>%s</b> <i>(ID: %d)</i> - Fetching image at %s", $i[ 'item_name' ], $i[ 'defindex' ], $url);
cache::log(sprintf("<i>(ID: %d)</i> <b>%s</b> — fetching image at \"%s\"", $i['defindex'], $i['item_name'], $url));
$idata = file_get_contents($url);
if (!$idata) {
cache::log(sprintf("<b>File not found.</b> (<a href=\"%s\">check</a>)\n", $url));
//printf('- <b>File not found on server.</b> (<a href="%s">check</a>)', $url);
} else {
file_put_contents($img, $idata);
}
}
if (filesize($img) == 0) {
cache::log("<b>" . $img . ".</b> failed\n");
@unlink($img);
}
if (!file_exists($img) || filesize($img) == 0) {
$s['items'][$k]['image_url'] = 'http://tf2stats.net/images/unknown.png';
$s['items'][$k]['image'] = 'unknown.png';
}
}
foreach ($s['attribute_controlled_attached_particles'] as $i) {
if (!file_exists($settings['upload']['folder']['effects'] . $i['id'] . '.png')) {
cache::log("<b>" . $i['name'] . "</b> - particle image doesn't exist! (ID: " . $i['id'] . ")");
}
}
foreach ($s['items'] as $i) {
$o['items'][$i['defindex']] = $i;
}
foreach ($s['attributes'] as $a) {
$o['attributes'][$a['defindex']] = $a;
}
$o['qualities'] = $s['qualities'];
$o['origins'] = $s['originNames'];
$o['particles'] = $s['attribute_controlled_attached_particles'];
$o['kill_eater_ranks'] = $s['kill_eater_ranks'];
$php = var_export($o, true);
cache::writeFile('tf2_items_schema.php', sprintf('<?php global $schema; $schema = %s ?>', $php));
backpack::update_asset_info();
backpack::update_valve_employees();
}