My specific implementation example is to help you have a perceptual knowledge. here I will show how to implement file-based processing on my homepage. Only the main processing code is incomplete. $ #@ 60 ;? 1 $ tmpfile ../tmp/. basename ($ REQUEST_URI); 2 $ tmpfilestr_replace (?, SyntaxHi
My specific implementation example
To help you have a perceptual knowledge, I will provide a file-based processing method on my homepage. Only the main processing code is incomplete.
$ #@ 60 ;?
1 $ tmpfile = "../tmp/". basename ($ REQUEST_URI );
2 $ tmpfile = str_replace ("? "," _ ", $ Tmpfile );
3 $ tmpfile = str_replace ("&", "_", $ tmpfile );
4 if (file_exists ($ tmpfile ))
5 {
6 $ cflag = false;
7 $ dtmp = filemtime ($ tmpfile );
8 $ itmp = filemtime ($ incfile );
9 $ cflag = $ cflag | ($ dtmp $ #@ 60; $ itmp );
10 $ ctmp = filemtime (basename ($ PHP_SELF ));
11 $ cflag = $ cflag | ($ dtmp $ #@ 60; $ ctmp );
12 $ ttmp = filemtime ("template/content. ihtml ");
13 $ cflag = $ cflag | ($ dtmp $ #@ 60; $ ttmp );
14}
15 else
16 $ cflag = true;
17
18 if (! $ Cflag) // use an existing file
19 {
20 readfile ($ tmpfile );
21 exit;
22}
23
24 // create a new file
25 include "template. class. php3 ";
26
27 $ fp = fopen ($ incfile, "r ");
28 $ content = fread ($ fp, filesize ($ incfile ));
29 fclose ($ fp );
30
31 // process the template below
32 $ t = new Template ("template", "keep ");
33
34 $ t-$ # @ 62; set_file ("contentfile", "content. ihtml ");
35
36 $ t-$ # @ 62; set_var (
37 array (
38 "content" =$ # @ 62; $ content
39 ));
40
41 $ t-$ # @ 62; parse ("outputcontent", "contentfile ");
42
43 $ fp = fopen ($ tmpfile, "w ");
44 if ($ fp)
45 {
46 flock ($ fp, 3 );
47 fwrite ($ fp, $ t-$ # @ 62; get_var ("outputcontent "));
48 flock ($ fp, 1 );
49 fclose ($ fp );
50}
51 $ t-$ # @ 62; p ("outputcontent ");
? $ #@ 62;
First, I would like to introduce my directory structure:
/--- Bin/execution program directory
| -- Content. php3: The program used to process file display
| -- Template/directory used to store template files
| --- Content. ihtml template file
|-Docs/data file
|-Tmp/stores cached files