function cache_save($srcpath, $thumbimg, $thumbw, $thumbh)
{
    cache_clear();
    global $cfg, $imgName, $imgIsRemote;
    // GET data
    foreach ($_GET as $k => $v) {
        $get[] = "{$k}={$v}";
    }
    $get = "?" . implode("&", $get);
    // Catch
    if ($cfg["cacheMaxImgW"] > 0 && $cfg["cacheMaxImgW"] < $thumbw) {
        return false;
    }
    if ($cfg["cacheMaxImgH"] > 0 && $cfg["cacheMaxImgH"] < $thumbh) {
        return false;
    }
    // Setup
    $time = time();
    $wh = "w" . formatInt($thumbw) . "h" . formatInt($thumbh);
    $rand = rand(100000, 999999);
    // Handle remote images
    if ($imgIsRemote) {
        $time = time() + $cfg["cacheSustainability"] * 24 * 60 * 60;
    }
    // Generate thumbname/-path
    $thumbpath = "cache/cachedimg.{$time}.{$wh}.{$rand}.{$imgName}";
    // Get data
    $data = fr("cache/cacheData.txt");
    if ($data) {
        $data = explode("####\r\n", $data);
    } else {
        $data = array();
    }
    // Add data
    $data[] = "{$srcpath}##{$thumbpath}##{$thumbw}##{$thumbh}##{$time}";
    while (count($data) > $cfg["cacheMaxFiles"]) {
        cache_log("CACHE_CLEANUP :: " . $srcpath);
        $arr = explode("##", array_shift($data));
        if (!file_exists($arr[1])) {
            continue;
        }
        if (!@unlink($arr[1])) {
            error("Cache failed: unlink({$arr[1]})");
            return false;
        }
    }
    // Save data
    $data = implode("####\r\n", $data);
    $fw = fw("cache/cacheData.txt", $data);
    if (!$fw) {
        return false;
    }
    // Return thumbpath
    cache_log("CACHE_SAVE :: " . $srcpath);
    return $thumbpath;
}
Esempio n. 2
0
    $page = intval($_GET['p']);
}
$stats = getLatestStatsFrom($user, 10, $page);
?>
<div class="title"><?php 
echo makeSafeHTML($user->username);
?>
</div>
<div class="block">
	<div class="blocktitle">Profile</div>
	<div class="blockcontent">
		<table>
			<tr>
				<td width="25%">XP:</td>
				<td width="25%"><?php 
echo formatInt($user->xp);
?>
</td>
				
				<td width="25%"></td>
				<td width="25%"></td>
			</tr>
			<tr>
				<td>Level:</td>
				<td><?php 
echo $user->level();
?>
 <a href="index.php?page=help_levels">(?)</a></td>
				
				<td></td>
				<td></td>
Esempio n. 3
0
    $topUsers = getTopUsers(10);
    foreach ($topUsers as $user) {
        echo "<li>" . $user->linkName() . " (" . formatInt($user->xp) . ")</li>";
    }
    ?>
								</ol>
							</div>
						</div>
						<div class="block">
							<div class="blocktitle">Top 10 songs</div>
							<div class="blockcontent">
								<ol>
									<?php 
    $topSongs = getTopSongs(10);
    foreach ($topSongs as $song) {
        echo "<li>" . $song->linkName() . " (" . formatInt($song->played) . ")</li>";
    }
    ?>
								</ol>
							</div>
						</div>
					</div>
					<div class="content">
						<?php 
    $page = "home";
    if (isset($_GET['page'])) {
        if (preg_match("/^([a-z_]+)\$/", $_GET['page'])) {
            $page = $_GET['page'];
        }
    }
    $page = str_replace("_", "/", $page);