/usr/share/arc/ldap-monitor/includes/cache.inc is in nordugrid-arc-ldap-monitor 1.1.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | <?php
/**
* @return integer
* @param string $fname
* @desc Returns modification time of a file, or 100000 if no file found
*/
function last_modified($fname)
{
$tdif = 100000;
$now = time();
if ( file_exists($fname) ) {
$last_touched = filemtime($fname);
$tdif = $now - $last_touched;
}
return $tdif;
}
/**
* @return void
* @param string $fname
* @param array $trows
* @desc Dumps a table to a file
*/
function cache_table($fname,$trows)
{
$fhandle = @fopen($fname,"wb");
$arstring = "array(";
$i = 0;
$imax = count($trows);
foreach ($trows as $row) {
$i++;
$arstring .= "array(";
$j = 0;
$jmax = count($row);
foreach ($row as $value) {
$j++;
$value = addcslashes($value,"\"");
$arstring .= "\"$value\"";
if ( $j < $jmax ) $arstring .= ",";
}
$arstring .= ")";
if ( $i < $imax ) $arstring .= ",";
}
$arstring .= ")";
@fwrite($fhandle,$arstring,strlen($arstring));
@fclose($fhandle);
}
/**
* @return array
* @param string $fname
* @param integer $ttl
* @desc Checks whether query is cached already and returns the result or FALSE
*/
function get_from_cache($fname,$ttl)
{
$cache = FALSE;
if ( last_modified($fname) < $ttl ) {
$contents = file_get_contents($fname);
eval("\$cache = $contents;");
if ( count($cache) < 1 ) $cache = FALSE;
}
return $cache;
}
?>
|