- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexample2.php
More file actions
Latest commit
27 lines (19 loc) · 691 Bytes
/
Copy pathexample2.php
File metadata and controls
27 lines (19 loc) · 691 Bytes
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
<?php
require"SafeCache.class.php";
header("Content-Type:text/plain");
//
$newContent = function($safe, $out) {
// content going to $safe->file
// direct write with fwrite for large content
foreach (range(0,20) as$n) fwrite($out, rand(0,9));
fwrite($out, " writing directly via fwrite <?php print time();?>\n\n");
};
// prepare file for safe access
$safe = newSafeCache("/tmp/file2.txt", array(
"cacheTTL" => 1*60, // cache expire in seconds
"newContent" => $newContent, // function to generate new content
));
// include compiled php template
$safe->include_php();
// fastest file output, only for static content
$safe->output();