Skip to content

Commit

Permalink
Update phpab.php
Browse files Browse the repository at this point in the history
Minor change to ensure that the </body> with the A/B tests version info and comment is the last </body> on the page.

Running this code on a page with </body> in comment tags (due to DoubleClick Floodlight tag comments) would cause problems.
  • Loading branch information
jeffsawyer committed Jul 7, 2014
1 parent 0959e27 commit 7467c40
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions phpab.php
Expand Up @@ -242,8 +242,12 @@ public function execute ($buffer)
}
unset($tmp);

$this->content = str_replace('</body>', '<!--A/B tests active with phpA/B ' . $this->version . '--></body>', $this->content);

$pos = strrpos($this->content, '</body>');
if($pos !== false)
{
$this->content = substr_replace($this->content, '<!--A/B tests active with phpA/B ' . $this->version . '--></body>', $pos, strlen('</body>'));
}

$this->content = str_replace('{' . $this->tag . ' ' . $this->test_name . ' current_varation}', $this->current_variation, $this->content);

if($this->trial_mode != TRUE)
Expand Down

0 comments on commit 7467c40

Please sign in to comment.