Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1 <?php
- 2 require_once('libmenu.php');
- 3
- 4 /* function make_me_example()
- 5 * doda example elemente na vsako podstran
- 6 * to so:
- 7 * -
- 8 * -
- 9 * -
- 10 */
- 11 function make_me_example() {
- 12 global $EXAMPLE_ENABLED;
- 13
- 14 if ($EXAMPLE_ENABLED === false) { return; } // a.k.a. LEAVE ME ALONE
- 15
- 16 ob_start("parse_and_include_stuff");
- 17 }
- 18
- 19 /* function parse_and_include_stuff(): funkcija dobi html v stringu,
- 20 * ki mu doda example elemente. parsa po zančkah <head> in <body>
- 21 * je case insensitive.
- 22 * pri bodyu podpira atribute
- 23 * @return nov html
- 24 * funkcija se uporablja kot callbakc pri ob_start()
- 25 */
- 26 function parse_and_include_stuff($html) {
- 27 $add_to_head = <<<EOHTML
- 28
- 29 <meta name='description' content='' />
- 30 <meta name='author' content='' />
- 31 <meta name='keywords' content='' />
- 32 <meta name='robots' content='index, follow' />
- 33 <meta http-equiv='content-type' content='text/html; charset=utf-8' />
- 34 <meta http-equiv="content-style-type" content="text/css" />
- 35 <meta http-equiv='content-language' content='' />
- 36 <link type="text/css" rel="stylesheet" href="" />
- 37 <link rel='shortcut icon' href='' />
- 38
- 39 EOHTML;
- 40
- 41 $add_to_body = "\n\n".get_navbar_html()."\n";
- 42
- 43 $broken = preg_split("/(<head>)/i", $html, null, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_OFFSET_CAPTURE);
- 44 if (count($broken) != 3) {
- 45 throw new Exception("HTML file for parsing is highly malformed! It has none or too many head tags! Cannot parse!");
- 46 }
- 47 $html = $broken[0][0] . $broken[1][0] . $add_to_head . $broken[2][0];
- 48 $broken = preg_split("/(<body[^>]*>)/i", $html, null, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_OFFSET_CAPTURE);
- 49 var_dump($broken);
- 50 if (count($broken) != 3) {
- 51 throw new Exception("HTML file for parsing is highly malformed! It has none or too many body tags! Cannot parse!");
- 52 }
- 53
- 54 $html = $broken[0][0] . $broken[1][0] . $add_to_body . $broken[2][0];
- 55
- 56 return $html;
- 57 }
- 58
- 59 ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement