include_once "/var/www/vhosts/sonrisayachting.com/includes/databaselogin_viewspecs.php";
include_once "/var/www/vhosts/sonrisayachting.com/includes/mailer.php";
include_once "/var/www/vhosts/sonrisayachting.com/includes/form.php";
class Session
{
var $email;
/* Class constructor */
function Session()
{
$this->time = time();
$this->startSession();
}
/**
* startSession - Performs all the actions necessary to
* initialize this session object. Tries to determine if the
* the user has logged in already, and sets the variables
* accordingly. Also takes advantage of this page load to
* update the active visitors tables.
*/
function startSession()
{
global $database; //The database connection
session_start(); //Tell PHP to start the session
/* Determine if user is logged in */
$this->doShow = $this->checkGrantshow();
}
/**
* checkGrantshow - Checks if the user has already previously
* submitted the view specification form, and a session with the email of the visitor has already been
* established. Also checks to see if visitor has been remembered.
* Returns true if the user has logged in.
*/
function checkGrantshow()
{
global $database; //The database connection
/* Check if the visitor has been remembered */
if(isset($_COOKIE['cookmail']))
{
$this->email = $_SESSION['email'] = $_COOKIE['cookmail'];
}
/* Username and userid have been set and not guest */
if(isset($_SESSION['email']))
{
/* User is logged in, set class variables */
// $this->email = $this->userinfo['email'];
return true;
}
/* User not logged in */
else
{
return false;
}
}
/**
* login - The visitor has submitted his name and email through the
* view specifications form, this function checks the authenticity
* of that information in the database and creates the session.
* Effectively shows the specifications if all goes well.
*/
function submitshow($subsex, $subfirst_name, $sublast_name, $subemail, $submailing, $subyms_id, $subyms_field, $subreference, $subbrand, $suburl, $subremember)
{
require_once("/var/www/vhosts/sonrisayachting.com/includes/formfields.php");
global $database, $form; //The database and form object
if ((isset($_COOKIE['cookmail'])) || (isset($_SESSION['email'])))
{
//echo "test";
}
else
{
if ( (check_spam($subfirst_name)) || (check_spam($sublast_name)) || (check_spam($subemail)) ) {
$subject = stripslashes("Spamwords detected on Yacht Publisher System");
$text = stripslashes("IP: ".getenv("REMOTE_ADDR")."\nFirst name: ".$subfirst_name."\nLast name: ".$sublast_name."\nE-mail: ".$subemail);
$eol="\r\n";
$headers="From: ".$subfirst_name." ".$sublast_name." <".$subemail.">".$eol."Content-Type: text/plain; charset=utf-8".$eol;
// mail("info@hoogmawebdesign.com", $subject, $text, $headers);
$form->setError("checkspam", "
* ".$field['checkspam'][$_SESSION['language']]);
}
/* First name error checking */
$formfield = "first_name"; //Use field name for username
if(!$subfirst_name || strlen($subfirst_name = trim($subfirst_name)) == 0)
{
$form->setError($formfield, "* ".$field['missingfirstname'][$_SESSION['language']]);
}
/* Last name error checking */
$formfield = "last_name"; //Use field name for username
if(!$sublast_name || strlen($sublast_name = trim($sublast_name)) == 0)
{
$form->setError($formfield, "* ".$field['missinglastname'][$_SESSION['language']]);
}
/* Email error checking */
$formfield = "email"; //Use field name for email
if(!$subemail || strlen($subemail = trim($subemail)) == 0)
{
$form->setError($formfield, "* ".$field["missingemail"][$_SESSION['language']]);
}
else
{
/* Check if valid email address */
$regex = "/^[_\.0-9a-zA-Z-]+@([0-9a-zA-Z][0-9a-zA-Z-]+\.)+[a-zA-Z]{2,6}$/i";
if(!preg_match($regex, $subemail)) {
$form->setError($formfield, "* ".$field["invalidemail"][$_SESSION['language']]);
}
$subemail = stripslashes($subemail);
}
/* Return if form errors exist */
if($form->num_errors > 0)
{
return false;
}
}
/* Checks that email is in database, get the id from the visitor and updates the visitors's hits */
$clientid = $database->confirmVisitorEmail($subsex, $subfirst_name, $sublast_name, $subemail, $submailing, $subyms_id, $subyms_field, $_SESSION['language']);
/* Updates hits and hitlog */
$result = $database->updateHits($subreference, $clientid, $subyms_id, $subyms_field);
/* Register session variables */
$this->email = $_SESSION['email'] = $subemail;
/**
* This is the cool part: the user has requested that we remember that
* he's logged in, so we set two cookies. One to hold his username,
* and one to hold his random value userid. It expires by the time
* specified in constants.php. Now, next time he comes to our site, we will
* log him in automatically, but only if he didn't log out before he left.
*/
// 2008-10-02 Session email probleem opgelost, als remember uit staat en sessie actief is, true geven
if($subremember)
{
setcookie("cookmail", $this->email, time()+COOKIE_EXPIRE, COOKIE_PATH);
/* Login completed successfully */
return true;
}
elseif ((isset($_COOKIE['cookmail'])) || (isset($_SESSION['email'])))
{
return true;
}
}
}
/**
* Initialize session object - This must be initialized before
* the form object because the form uses session variables,
* which cannot be accessed unless the session has started.
*/
$session = new Session;
/* Initialize form object */
$form = new Form;
?>
Nachdem sie Ihre Name und E-mailadresse eingetragen haben, öffnetes ein neues venster und sehen Sie sofort die vollständige Unterlagen echo $form->error("checkspam"); ?>