Function createshtml ()
{
Ob_start (Array ("callback_createshtml", "callback_gotoshtml "));
}
Function callback_createshtml ($ buffer)
{
$ Page = intval (@ $ _ request ["page"]);
$ Filename = $ _ server ['document _ root']. dirname ($ _ server ['php _ Self ']). "/". basename ($ _ server ['php _ Self '], ". PHP "). ($ page = 0? "": "_". Strval ($ page). ". htm ";
$ Fp = fopen ($ filename, "WB ");
Fwrite ($ FP, $ buffer );
Fclose ($ FP );
Return $ buffer;
}
Function callback_gotoshtml ($ buffer)
{
$ Page = intval (@ $ _ request ["page"]);
$ Filename = basename ($ _ server ['php _ Self '], ". php"). ($ page = 0? "": "_". Strval ($ page). ". htm ";
Header ("Location:". $ filename );
Return $ buffer;
}
Function gotoshtml ()
{
$ Page = intval (@ $ _ request ["page"]);
$ Filename = basename ($ _ server ['php _ Self '], ". php"). ($ page = 0? "": "_". Strval ($ page). ". htm ";
If (file_exists ($ filename ))
Header ("Location:". $ filename );
}
Function deleteshtml ($ filename = NULL)
{
If (is_null ($ filename ))
$ Filename = $ _ server ['document _ root']. $ _ server ['php _ Self '];
If ($ filename [0] = "/")
$ Filename = $ _ server ['document _ root']. $ filename;
$ Path = dirname ($ filename );
$ Dir = Dir ($ PATH );
$ Patten = "/^". basename ($ filename, ". php"). "(_ [0-9] + )?. Htm /";
While ($ entry = $ Dir-> Read ())! = False)
{
If (is_file ($ path. "/". $ entry) & preg_match ($ Patten, $ entry ))
Unlink ($ path. "/". $ entry );
}
}