/**
  * @return null|str
  */
 public static function checkEID()
 {
     $e = null;
     if (isset($_GET["eid"])) {
         //Sanitize for base 64
         $e = base64_decode(SystemTool::sanitize($_GET["eid"], 1));
         //Sanitize for email
         $e = SystemTool::sanitize($e, 2);
         //Is it a valid email?
         if (SystemTool::validate($e)) {
             setcookie(SystemTool::getCookieName(), base64_encode($e), PageTool::getCookieLength(), CShell::cookiePath(), CShell::cookieDomain());
         } else {
             $e = null;
         }
     }
     return $e;
 }
 public function refer()
 {
     $this->setCache(false);
     $this->_return = self::PROCESS;
     $backto = '';
     if (isset($_POST["backto"])) {
         $backto = $_POST["backto"];
     }
     $from = '';
     if (isset($_POST["from"])) {
         $from = $_POST["from"];
     }
     //Sanitize for base 64
     $sender = base64_decode(SystemTool::sanitize($_COOKIE[SystemTool::getCookieName()], 1));
     //Sanitize for email
     $sender = SystemTool::sanitize($sender, 2);
     //Is it a valid email? If not back to refer page.
     if (!SystemTool::validate($sender)) {
         header("Location: " . PageTool::getSiteRoot() . $backto);
         exit;
     }
     $success = 0;
     $emails = explode(",", $_POST["email"]);
     foreach ($emails as $email) {
         $email = SystemTool::sanitize($email, 2);
         if (SystemTool::validate($email)) {
             $WRM = new Webinar_referModel();
             $WRM->addRecord(CShell::webinar_id(), $email, SystemTool::getTimestamp());
             //Set up and render the email HTML.
             $eTemplate = new Template('email_share');
             if ($from == "cr") {
                 $eTemplate->set('cr', true);
             }
             $body = $eTemplate->render(false);
             $body = str_replace("!!EMAIL!!", $sender, $body);
             $alt = strip_tags($body);
             //Send the email.
             $PHPEmails = CShell::emails();
             $PHPEmails["refer"]["subject"] = 'An invitation from ' . $sender . ' - The Street Gold Event';
             SystemTool::sendEmail($PHPEmails["refer"], $email, $body, $alt);
             $success = 1;
         }
     }
     if ($success) {
         setcookie(CShell::REFER, '1', PageTool::getCookieLength(), CShell::cookiePath(), CShell::cookieDomain());
         // 1yr cookie
         header('Location: /' . $backto);
         exit;
     } else {
         header('Location: /' . $backto . '?e=no');
         exit;
     }
 }