background image

66.    str_replace

(

"\\"

,

 

"/"

,

 $pathname

);

67.    $pathArr 

=

 split

(

"/"

,

 $pathname

);

68.    

if

 

(

$pathArr

[

0

]

 

==

 

""

)

 

{

 

//使用绝对路径

69.    $currentPath 

=

 $_SERVER

[

'DOCUMENT_ROOT'

];

70.    

}

 

else

 

{

71.    $currentPath 

=

 $_SERVER

[

'DOCUMENT_ROOT'

]

 

dirname

(

$_SERVER

[

'PHP_SELF'

]);

72.    

}

73.    

for

 

(

$i 

=

 

0

;

 $i 

<

 count

(

$pathArr

);

 $i

++)

 

{

74.    

if

 

(

$pathArr

[

$i

]

 

==

 

""

)

75.    

continue

;

76.    

else

77.    

if

 

(

is_dir

(

$currentPath 

.

 

" / "

 

.

 $pathArr

[

$i

]))

78.    $currentPath 

=

 $currentPath 

.

 

" / "

 

.

 $pathArr

[

$i

];

79.    

else

80.    mkdir

(

$currentPath 

=

 $currentPath 

.

 

" / "

 

.

 $pathArr

[

$i

]);

81.    

}

82.    

}

83.  
84.    

// 生成静态文件

85.    

function

 

Create

()

86.    

{

87.    $tmp 

=

 $this

->

Templet

;

88.    

foreach

 

(

$this

->

DataSource

 

as

 $key 

=>

 $value

)

 

{

89.    $tmp 

=

 str_replace

(

" < FIELD_"

 

.

 $key 

.

 

" > "

,

 $value

,

 $tmp

);

90.    

}

91.    $this

->

MkDir

(

dirname

(

$this

->

fileName

));

92.    $this

->

Open

();

93.    $this

->

Write

(

$tmp

);

94.    $this

->

Close

();

95.    

}

96. }

97.  
98.

function

 

CreateShtml

()

 

{

99.    ob_start

(

"callback_CteateShtml"

);

100. }

101.  
102.

function

 callback_CteateShtml

(

$buffer

)

 

{

103.    $page 

=

 intval

(

@$_REQUEST

[

"page"

]);

104.    $shtml 

=

 

new

 

Shtml

();

105.    $shtml

->

SetFileName

(

$_SERVER

[

'DOCUMENT_ROOT'

]

 

dirname

(

$_SERVER

[

'PHP_SELF'

])

 

.

 

"/"

 

basename

(

$_SERVER

[

'PHP_SELF'

],

 

".php"

)

 

.

 

(

$page 

==

 

0

 

?

 

""

 

:

 

"_"

 

strval

(

$page

))

 

.

 

".html"

);