Skip to content

Commit

Permalink
fixed php code
Browse files Browse the repository at this point in the history
  • Loading branch information
rbbeeston committed Aug 13, 2024
1 parent bb1d26e commit e43d7d1
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion common/code/boost_filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function extract_html_body($text) {
if (!isset($body_begin[0]))
{
//~ Attempt to recover some content from illegal HTML that is missing the body tag.
preg_match('@<script defer data-domain="original.boost.org" src="https://plausible.io/js/script.js"></script></head>@i',$text,$body_begin,PREG_OFFSET_CAPTURE);
preg_match('@</head>@i',$text,$body_begin,PREG_OFFSET_CAPTURE);
}
if (!isset($body_begin[0]))
{
Expand Down Expand Up @@ -153,6 +153,7 @@ function template_params($content) {

$head = "<meta name=\"viewport\" content=\"width=device-width,initial-scale=1.0\" />\n";
$head .= "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=${charset}\" />\n";
$head .= "<script defer data-domain=\"original.boost.org\" src=\"https://plausible.io/js/script.js\"></script>\n";

if (!empty($this->noindex))
$head .= "<meta name=\"robots\" content=\"noindex\">\n";
Expand Down
3 changes: 2 additions & 1 deletion common/code/boost_filter_basic.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function echo_filtered()

$match = null;

if(preg_match('@(?:<script defer data-domain="original.boost.org" src="https://plausible.io/js/script.js"></script></head>\s*)?<body[^>]*>@is', $text, $match, PREG_OFFSET_CAPTURE)) {
if(preg_match('@(?:</head>\s*)?<body[^>]*>@is', $text, $match, PREG_OFFSET_CAPTURE)) {
$is_xhtml = preg_match('@<!DOCTYPE[^>]*xhtml@i', $match[0][0]);
$tag_end = $is_xhtml ? '/>' : '>';

Expand All @@ -22,6 +22,7 @@ function echo_filtered()
echo $this->alter_title($head);
echo '<link rel="icon" href="/favicon.ico" type="image/ico"'.$tag_end;
echo '<link rel="stylesheet" type="text/css" href="/style-v2/section-basic.css"'.$tag_end;
echo '<script defer data-domain="original.boost.org" src="https://plausible.io/js/script.js"></script>';
if ($is_asciidoctor) {
echo str_replace('class="', 'class="boost-asciidoctor ', $match[0][0]);
} else {
Expand Down
3 changes: 2 additions & 1 deletion common/code/boost_filter_boost_book_basic.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ function echo_filtered()

$match = null;

$pos1 = strpos($text, '<script defer data-domain="original.boost.org" src="https://plausible.io/js/script.js"></script></head>');
$pos1 = strpos($text, '</head>');
$pos2 = strpos($text, '<body', $pos1);
$pos3 = strpos($text, '>', $pos2) + 1;
$pos4 = strpos($text, '<div class="spirit-nav">', $pos3);
$head = $this->alter_title(substr($text, 0, $pos1));
echo $head;
echo '<link rel="icon" href="/favicon.ico" type="image/ico"/>';
echo '<link rel="stylesheet" type="text/css" href="/style-v2/section-basic.css"/>';
echo '<script defer data-domain="original.boost.org" src="https://plausible.io/js/script.js"></script>';
if (!preg_match('@<meta\b[^<>]*\bname\s*=\s*["\']?viewport\b@', $head)) {
echo '<meta name="viewport" content="width=device-width,initial-scale=1.0"/>';
}
Expand Down
3 changes: 2 additions & 1 deletion common/code/boost_filter_develop_box.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ function echo_filtered()
{
$text = $this->content;
$box = latest_link($this->data);
if ($box && preg_match('@(?:<script defer data-domain="original.boost.org" src="https://plausible.io/js/script.js"></script></head>\s*)?<body[^>]*>@is', $text, $match, PREG_OFFSET_CAPTURE)) {
if ($box && preg_match('@(?:</head>\s*)?<body[^>]*>@is', $text, $match, PREG_OFFSET_CAPTURE)) {
$is_xhtml = preg_match('@<!DOCTYPE[^>]*xhtml@i', $match[0][0]);
$tag_end = $is_xhtml ? '/>' : '>';
$head = substr($text, 0, $match[0][1]);
echo $this->alter_title($head);
echo '<link rel="icon" href="/favicon.ico" type="image/ico"'.$tag_end;
echo '<link rel="stylesheet" type="text/css" href="/style-v2/section-basic.css"'.$tag_end;
echo '<script defer data-domain="original.boost.org" src="https://plausible.io/js/script.js"></script>';
echo $match[0][0];
echo $box;
echo $this->prepare_html(substr($text, $match[0][1] + strlen($match[0][0])));
Expand Down

0 comments on commit e43d7d1

Please sign in to comment.