{"id":102,"date":"2009-05-25T23:59:30","date_gmt":"2009-05-25T16:59:30","guid":{"rendered":"http:\/\/www.icez.net\/blog\/?p=102"},"modified":"2009-05-28T21:52:37","modified_gmt":"2009-05-28T14:52:37","slug":"php-dynamic-page-static-html-generator","status":"publish","type":"post","link":"https:\/\/www.icez.net\/blog\/102\/php-dynamic-page-static-html-generator","title":{"rendered":"0060 | PHP Dynamic page static HTML generator"},"content":{"rendered":"<p>\u0e0a\u0e37\u0e48\u0e2d\u0e22\u0e32\u0e27\u0e40\u0e1b\u0e47\u0e19\u0e27\u0e32 code \u0e2d\u0e30\u0e44\u0e23\u0e27\u0e30 (\u0e27\u0e31\u0e19\u0e2b\u0e25\u0e31\u0e07\u0e21\u0e32 search \u0e08\u0e30\u0e40\u0e08\u0e2d\u0e21\u0e31\u0e49\u0e22\u0e40\u0e19\u0e35\u0e48\u0e22\u0e15\u0e39 555)<\/p>\n<p>code \u0e19\u0e35\u0e49\u0e41\u0e1b\u0e30\u0e14\u0e49\u0e32\u0e19\u0e1a\u0e19\u0e2a\u0e38\u0e14\u0e02\u0e2d\u0e07\u0e44\u0e1f\u0e25\u0e4c (\u0e08\u0e30\u0e43\u0e2a\u0e48\u0e43\u0e19 auto prepend \u0e40\u0e25\u0e22\u0e01\u0e47\u0e22\u0e31\u0e07\u0e44\u0e2b\u0e27)<\/p>\n<pre lang=\"php\">\r\n<?php\r\n$_cachetime = 43200;\r\n$_info = parse_url($_SERVER[\"REQUEST_URI\"]);\r\nif (!isset($_info['query'])) $_info['query'] = '';\r\n$_path = end(explode('\/', $_info['path']));\r\n$_info['query'] = str_replace('&#038;nocache', '', $_info['query']);\r\n$_info['query'] = str_replace('nocache&#038;', '', $_info['query']);\r\n$_info['query'] = str_replace('nocache', '', $_info['query']);\r\n$_cachename = sprintf(\"%x\", crc32($_path.\"?\".$_info['query']));\r\n$_cachefolder = '\/path\/to\/cache\/'.substr($_cachename,0,2).'\/';\r\n$_cachefile = $_cachefolder.$_cachename;\r\nif ($_SERVER[\"REQUEST_URI\"] != '\/' &#038;&#038; $_SERVER[\"REQUEST_METHOD\"] == 'GET' &#038;&#038;\r\n    !isset($_GET[\"nocache\"]) &#038;&#038;\r\n    file_exists($_cachefile) &#038;&#038; filemtime($_cachefile) > time() - $_cachetime) {\r\n        readfile($_cachefile);\r\n        exit();\r\n}\r\nfunction fetch_cache($_buffer) {\r\n        global $_cachefile, $_cachefolder;\r\n        umask( 0);\r\n        if (!file_exists($_cachefolder))\r\n                mkdir($_cachefolder,0777, true);\r\n        if ($_h = fopen($_cachefile, \"w\")) {\r\n                fwrite($_h, $_buffer);\r\n                fclose($_h);\r\n        }\r\n        return $_buffer;\r\n}\r\nob_start('fetch_cache');\r\n?>\r\n<\/pre>\n<p>code \u0e19\u0e35\u0e49\u0e43\u0e2a\u0e48\u0e14\u0e49\u0e32\u0e19\u0e17\u0e49\u0e32\u0e22 (\u0e43\u0e19 auto append \u0e01\u0e47\u0e44\u0e14\u0e49\u0e19\u0e30\u0e04\u0e23\u0e31\u0e1a)<\/p>\n<pre lang=\"php\">\r\n<?php\r\nob_end_flush();\r\n?>\r\n<\/pre>\n<p>* \u0e41\u0e01\u0e49\u0e44\u0e02\u0e40\u0e1e\u0e34\u0e48\u0e21 2009\/05\/28<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0e0a\u0e37\u0e48\u0e2d\u0e22\u0e32\u0e27\u0e40\u0e1b\u0e47\u0e19\u0e27\u0e32 code \u0e2d\u0e30\u0e44\u0e23\u0e27\u0e30 (\u0e27\u0e31\u0e19\u0e2b\u0e25\u0e31\u0e07\u0e21\u0e32 search \u0e08\u0e30\u0e40\u0e08\u0e2d\u0e21\u0e31\u0e49\u0e22\u0e40\u0e19\u0e35\u0e48\u0e22\u0e15\u0e39 555) code \u0e19\u0e35\u0e49\u0e41\u0e1b\u0e30\u0e14\u0e49\u0e32\u0e19\u0e1a\u0e19\u0e2a\u0e38\u0e14\u0e02\u0e2d\u0e07\u0e44\u0e1f\u0e25\u0e4c (\u0e08\u0e30\u0e43\u0e2a\u0e48\u0e43\u0e19 auto prepend \u0e40\u0e25\u0e22\u0e01\u0e47\u0e22\u0e31\u0e07\u0e44\u0e2b\u0e27) code \u0e19\u0e35\u0e49\u0e43\u0e2a\u0e48\u0e14\u0e49\u0e32\u0e19\u0e17\u0e49\u0e32\u0e22 (\u0e43\u0e19 auto append \u0e01\u0e47\u0e44\u0e14\u0e49\u0e19\u0e30\u0e04\u0e23\u0e31\u0e1a) * \u0e41\u0e01\u0e49\u0e44\u0e02\u0e40\u0e1e\u0e34\u0e48\u0e21 2009\/05\/28<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,8,3],"tags":[87,5903,16],"class_list":["post-102","post","type-post","status-publish","format-standard","hentry","category-php","category-programming","category-webserver","tag-cache","tag-mysql","tag-optimize"],"_links":{"self":[{"href":"https:\/\/www.icez.net\/blog\/wp-json\/wp\/v2\/posts\/102","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.icez.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.icez.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.icez.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.icez.net\/blog\/wp-json\/wp\/v2\/comments?post=102"}],"version-history":[{"count":0,"href":"https:\/\/www.icez.net\/blog\/wp-json\/wp\/v2\/posts\/102\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.icez.net\/blog\/wp-json\/wp\/v2\/media?parent=102"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.icez.net\/blog\/wp-json\/wp\/v2\/categories?post=102"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.icez.net\/blog\/wp-json\/wp\/v2\/tags?post=102"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}