/**
  * @return unknown
  * @desc Gets the root folder for any files accessed on the server-side
  */
 function GetServerRoot()
 {
     if (SiteContext::IsWordPress()) {
         return ABSPATH;
     } else {
         return $_SERVER['DOCUMENT_ROOT'] . '/';
     }
 }
 /**
  * Parses the device and token from an auto sign-in cookie
  * @param string $cookie_value
  * @return array
  */
 private function ParseAutoSignInCookie($cookie_value)
 {
     # In wp-settings.php WordPress runs add_magic_quotes() over every value in $_COOKIE.
     # Need to undo that otherwise it's not the value we put there.
     if (SiteContext::IsWordPress()) {
         $cookie_value = stripslashes($cookie_value);
     }
     $value = array();
     $separator = strpos($cookie_value, ';');
     if ($separator and strlen($cookie_value) > $separator + 1) {
         $value['device'] = (int) substr($cookie_value, 0, $separator);
         $value['token'] = substr($cookie_value, $separator + 1);
     }
     return $value;
 }
    /**
     * Display an advert for something we sell
     */
    protected function BuySomething()
    {
        $spreadshirt = gmdate("U") % 10 > 0;
        if ($spreadshirt) {
            $folder = SiteContext::IsWordPress() ? ABSPATH : $_SERVER['DOCUMENT_ROOT'];
            // File downloaded from http://api.spreadshirt.net/api/v1/shops/629531/articles?limit=50
            $articles = simplexml_load_file($folder . "/spreadshirt.xml");
            $article = $articles->article[rand(0, 49)];
            echo '<div class="spreadshirt large">';
            #echo '<h2><img src="/images/christmas.gif" alt="Stoolball at Christmas" width="204" height="90" /></h2>';
            echo '<h2><img src="/images/gifts.gif" alt="Visit our stoolball gift shop" width="204" height="90" /></h2>';
            echo '<div class="spreadshirt-box">' . '<a href="https://shop.spreadshirt.co.uk/stoolball/-A' . Html::Encode($article['id']) . '">' . '<img src="' . Html::Encode($article->resources->resource->attributes("http://www.w3.org/1999/xlink")->href) . '" alt="' . Html::Encode($article->name) . '" width="159" height="159" />' . '<p>' . Html::Encode($article->name) . '</p>' . '<p class="price">&pound;' . Html::Encode(number_format((double) $article->price->vatIncluded, 2, '.', '')) . '</p>
			<p class="buy"><span>Buy it now</span></p></a></div></div>';
        } else {
            echo '<a class="promo large" href="/shop"><img alt="Bats &pound;39, Balls &pound;7, Wickets &pound;150, Scorebooks &pound;4. Buy yours now." width="185" height="214" src="' . $this->resource_root . '/images/equipment/bat-ad-' . rand(1, 2) . '.jpg" /></a>';
        }
    }