예제 #1
0
            $month = 12;
        }
        $tries++;
        // Never try too hard to get game records. A player may not have played enough games to fill the quota, or may not even exist.
        if ($tries > 3) {
            break;
        }
    }
    // convert game records to json
    $games = json_encode($games);
    // Write contents of KGS Game Archives page to user-specified $gameFile
    echo $cacheFile;
    echo getcwd();
    $fh = fopen($cacheFile, 'w') or die('Can\'t open file.');
    fwrite($fh, $games);
    fclose($fh);
}
/* Outputs the contents of the cached archive file in JSON format */
function outputCache()
{
    global $cacheFile;
    $output = file_get_contents($cacheFile);
    echo $output;
}
// If checkCacheFreshness returns false, update the file from KGS
if (checkCacheFreshness() == false || $_GET[noCache] == 'true') {
    updateCache();
}
// Output the contents of the cached archive file
outputCache();
예제 #2
0
<?php

/**
 * $file : file full path 
 * $dir :  root directory 
 * $id : repository id 
 * $cache_file : cache file path 
 * $url_root : url based root path 
 * $relative_path : relative path of file 
 * 
 */
header('Content-Type: text/html');
if (!hasCache($file) || $is_new) {
    generateCache($file, HtmlPreprocessor(file_get_contents($file), 'markdown'));
}
outputCache($file);