function getCacheFederated() { // set-up the cache file path $timestamp = date('Ymd'); $fed_cache_file = '../../cache/fed_cache_' . $timestamp . '.txt'; // check if cache file exists if (!file_exists($fed_cache_file)) { // if cache doesn't exist yet get the dynamic js files $federated_a = findFederated(); // build the text array to be cached $federated_txt = "array("; foreach ($federated_a as $federated) { $federated_txt .= "'" . $federated . "',"; } $federated_txt .= ");"; // write out the cache file $fp = fopen($fed_cache_file, 'w'); fwrite($fp, "<?php \$federated_a = " . $federated_txt . " ?>"); fclose($fp); } else { // if cache does exist simply include it and merge it with standard js includes include $fed_cache_file; } return $federated_a; }
/** * Copyright (c) 2010 West Virginia University * * Licensed under the MIT License * Redistributions of files must retain the above copyright notice. * */ // various copy includes require_once "../../config.gen.inc.php"; // records stats require_once "../page_builder/page_header.php"; // require libs require_once "lib/federated.lib.php"; $filter = $_REQUEST['filter']; $html = ''; if ($filter != '') { if ($fed_cache_support) { // check fed cache support, if set to true see if the cache file is created $federated_a = getCacheFederated(); } else { // find the fed files to include on the fly since cache is apparently not needed $federated_a = findFederated(); } // go through each appropriate file and include it foreach ($federated_a as $federated) { include $federated; } } require "templates/{$prefix}/index.html"; $page->output();