console.log("Successfully sent the email - not an error.");
}
});
}
catch(e){
console.log(e);
}
//END TEST//
*/
/*
//Setup the passwords used by users to access the content. Allows us to track who has used the site when and how much.
//Note: This is mostly for marketing purposes so it won't be very secure at all (no hashing, salting, SSL, or anything), and it allows the search engines to bypass it to the content.
//Note: This is mostly for marketing purposes so it won't be very secure at all (no hashing, salting, SSL, or anything), and it allows the search engines to bypass it to the content.
console.log("Received an error while sending the download brief email to the user. "+error);
fs.appendFile(rootPath+'/emailFailures.txt',JSON.stringify(params)+'\n',function(err){if(err){console.log("Failed to write email data to file! (request brief)");}});
}
else{
params={from:config.fromAddress,to:config.contactUsRecipient,subject:"Downloaded Brief",text:"A user has requested the Payback brief.\n\nFirst Name: "+firstName+"\nLast Name: "+lastName+"\nEmail: "+email+"\nPartnership: "+isPartnership+"\nInvestment: "+isInvestment+"\nOther: "+isOther};
console.log("Received an error while sending the request brief email to the admin. "+error);
fs.appendFile(rootPath+'/emailFailures.txt',JSON.stringify(params)+'\n',function(err){if(err){console.log("Failed to write email data to file! (request brief)");}});
console.log("Received an error while sending the request financials email to the user. "+error);
fs.appendFile(rootPath+'/emailFailures.txt',JSON.stringify(params)+'\n',function(err){if(err){console.log("Failed to write email data to file! (request financials)");}});
}
else{
params={from:config.fromAddress,to:config.contactUsRecipient,subject:"Downloaded Financials",text:"A user has requested Payback's financials.\n\nFirst Name: "+firstName+"\nLast Name: "+lastName+"\nEmail: "+email+"\nPhone: "+phone+"\nCompany: "+company+"\nPartnership: "+isPartnership+"\nInvestment: "+isInvestment+"\nOther: "+isOther+"\nMessage: "+message};
console.log("Received an error while sending the request financials email to the admin. "+error);
fs.appendFile(rootPath+'/emailFailures.txt',JSON.stringify(params)+'\n',function(err){if(err){console.log("Failed to write email data to file! (request financials)");}});
}catch(e){console.log(e);}
}
});
}
res.status(200).send('success');
}catch(e){console.log(e);}
});
}catch(e){console.log(e);}
});
*/
app.use('/ContactUs',function(req,res){
try{
varfirstName=req.body.FirstName;
varlastName=req.body.LastName;
varemail=req.body.Email;
varmessage=req.body.Text;
varparams={from:config.fromAddress,to:config.contactUsRecipient,subject:"Contact Us",text:"A user has commented via the Petit Teton website.\n\nFirst Name: "+firstName+"\nLast Name: "+lastName+"\nEmail: "+email+"\n"+message};
console.log("Received an error while sending the contact us email to the admin. "+error);
fs.appendFile(rootPath+'/emailFailures.txt',JSON.stringify(params)+'\n',function(err){if(err){console.log("Failed to write email data to file! (contact us)");}});
}catch(e){console.log(e);}
}
});
res.status(200).send('success');
}catch(e){console.log(e);}
});
/*
app.use('/LoginUser',function(req,res){
//Note: This is mostly for marketing purposes so it won't be very secure at all (no hashing, salting, SSL, or anything), and it allows the search engines to bypass it to the content.
console.log("Time now is: "+moment(newDate()).format("MMM Do YYYY, h:mm:ss a"));
/*
app.use('/Admin/UserData',function(req,res){
//TODO: Return a table of user data. This is a hidden function, and since the data is not very sensitive we won't bother with password protection or ssl.
varbody="<html><body><table><thead><tr><th style='padding: 0 20px 0 0'>Password</th><th style='padding: 0 20px 0 20px'>Page Request Count</th><th style='padding: 0 20px 0 20px'>First Login</th><th style='padding: 0 0 0 20px'>Last Login</th></tr></thead><tbody>";
body+="<td style='padding: 0 20px 0 20px'>"+(pwdData[index].firstLogin?(moment(pwdData[index].firstLogin).format("MMM Do YYYY, h:mm:ss a")+" ("+moment(pwdData[index].firstLogin).fromNow()+")"):"")+"</td>";
body+="<td style='padding: 0 20px 0 20px'>"+(pwdData[index].lastLogin?(moment(pwdData[index].lastLogin).format("MMM Do YYYY, h:mm:ss a")+" ("+moment(pwdData[index].lastLogin).fromNow()+")"):"")+"</td>";
body+="</tr>";
}
body+="</tbody></table></body></html>";
res.send(body);
});
*/
//Handle the root being requested, and the search engine requesting a static page with content.
app.use('/',function(req,res){
try{
//Note: This is for search engines. It bypasses the password, which is fine since that is mostly a marketing gimmic to make users feel that they have some special access priviliges.
//The DIY method which is somewhat brittle since it relies on <!--CONTENT--> existing in the index.html file, and it replaces that with the contents of the passed parameter (what is after the #!) for the content html which is inserted into the index.html in place of <!--CONTENT-->.