github.com/piotrnar/gocoin@v0.0.0-20240512203912-faa0448c5e96/website/page.php (about)

     1  <?php
     2  
     3  $page = isset($_GET['id']) ? preg_replace("/[^a-zA-Z_]/", "", $_GET['id']) : '';
     4  //echo $page;
     5  if ($page=='') {
     6  	$page = 'index';
     7  }
     8  
     9  function get_between_tags($content, $tag) {
    10  	$beg = strpos($content, "<$tag>");
    11  	if ($beg!==FALSE) {
    12  		$beg += strlen($tag)+2;
    13  	}
    14  	$end = strpos($content, "</$tag>");
    15  	if ($end===FALSE) {
    16  		$end = strlen($content);
    17  	}
    18  	return substr($content, $beg, $end-$beg);
    19  }
    20  
    21  
    22  function get_body($fn) {
    23  	$content = file_get_contents($fn);
    24  	return get_between_tags($content, "body");
    25  }
    26  
    27  $menu = get_body("menu.html");
    28  $fielname = "gocoin_$page.html";
    29  
    30  // add class="selected" to the main menu
    31  $apos = strpos($menu, 'href="' . $fielname);
    32  if ($apos!==FALSE) {
    33  	$menu = substr($menu, 0, $apos) . 'class="selected" ' . substr($menu, $apos);
    34  }
    35  
    36  $content = get_body($fielname);
    37  $title = get_between_tags($content, "h1");
    38  
    39  
    40  echo '<html>
    41  <head>
    42  <link rel="stylesheet" href="style.css" type="text/css">
    43  <title>Gocoin: '.$title.'</title>
    44  </head>
    45  <body>
    46  <table cellspacing="10">
    47  <tr>
    48  <td valign="top" width="200">';
    49  echo $menu;
    50  echo '</td>
    51  <td valign="top">';
    52  echo $content;
    53  echo
    54  '</td></tr></table>
    55  </body>
    56  </html>';
    57  
    58  ?>