How to safely display an email address (spamproof) - email

A similar question has been asked, but it was 6 years ago and there hasn't been any recent answers to the problem since then. I know the smarter way of allowing visitors to email via a website would be a contact form or a captcha to display the email address, but what about situations where the page design doesn't allow for such luxuries? My options are either display an email address or display a "click here" mailto link. Is there a more modern & unto date solution thank those in the original question?
Regards,
--Michael

So far, js remains the only efficient way of doing this.
See this long discussion for more information
Here's a sample js snipp that does the job.
<SCRIPT TYPE="text/javascript">
emailE = 'emailserver.com'
emailE = ('yourname' + '#' + emailE)
document.write('' + emailE + '')
</script>
<NOSCRIPT>
Email address protected by JavaScript
</NOSCRIPT>

a.reverse {
unicode-bidi: bidi-override;
direction: rtl;
}
<h1>Copy and paste the email below box</h1>
<span style="color:#FFF;">
<p style="color:black">Email Enquiry:</p>
<a class="reverse" style="color:blue">moc.sysartxed#ofni</a>
</span>
<div style="margin-top:20px">
<input type="text">
</div>

Related

I can´t submit a form in html when I´m using a file input type and I deploy it as a web-app with only access to me [duplicate]

This question already has an answer here:
Moving google apps script to v8 file upload stopped working from sidebar
(1 answer)
Closed 2 years ago.
I don´t know if there is a way on making this work, but I want to make a form with input type=file.
But when I submit the form it won't work cause of the input type=file and cause of my access permission is set to me only in the Google Apps Script.
Well the code goes like this, I'm just showing the base code which I'm having trouble with. Whenever I remove the line with the input file it will submit the form and add in a spreadsheet the value I've input in the first name text box. And I've notice that it also works when I leave the input file line, when I change the permissions in my script, when I publish the code as a web app, and in the "Who has access to the app" put "Anyone, even anonymous", the thing is that I don't want that anyone could access the webapp. I'm just thinking on rewritting the gs code to check the user accessing the web app, but I'm not sure if this would be safe.
GS Code:
function doGet() {
var template = HtmlService.createTemplateFromFile('HtmlName');
return template.evaluate().setSandboxMode(HtmlService.SandboxMode.IFRAME);}
function processForm(formObject) {
var formBlob = formObject.myFile;
var driveFile = DriveApp.createFile(formBlob);
var firstName = formObject.firstName;
DriveApp.getFolderById("anyID").addFile(driveFile);
ss.appendRow([formObject.firstName,
]);}
Html File
<!DOCTYPE html>
<html>
<body>
<form class="w3-container" id="myForm" onsubmit="handleFormSubmit(this); ">
<p>
<input class="w3-input" name="myFile" type="file">
<input class="w3-input" type="text" name="firstName">
<p>
<input class="w3-button" type="submit" value="Submit">
</form>
</body>
<script>
// Prevent forms from submitting.
function preventFormSubmit() {
var forms = document.querySelectorAll('form');
for (var i = 0; i < forms.length; i++) {
forms[i].addEventListener('submit', function(event) {
event.preventDefault();
}); } }
window.addEventListener('load', preventFormSubmit);
function handleFormSubmit(formObject) {
google.script.run.withSuccessHandler(updateUrl).processForm(formObject);
}
</script>
</html>
There is a known issue regarding the use of <input type="file" /> on Google Apps Script HTML Service when using the new default runtime (Chrome V8)1. As your code isn't using features not supported by the old runtime, try to disable the new runtime (click on Run > Disable new Google Apps Script runtime powered by Chrome V8).
If disabling the new runtime doesn't work try using FileReader.
NOTES:
See Tanaike's answer to Moving google apps script to v8 file upload stopped working from sidebar

Prepend a form field response in Angular 2

I'm building a registration form in Angular 2 that asks a user to provide their website's URL before submitting.
When the form is submitted, I need the provided URL to be in the style of "http://www.google.com". To steer the user towards that format, I want the form field to autofill the initial "http://" as soon as the user clicks on the field (or when the user begins typing - either case would be acceptable). Currently I have placeholder text in the field that says "Please provide your website's URL", but I'm having trouble making the "http://" prefix appear when the user actually clicks on the field or starts typing.
Any ideas would be appreciated. Here is what the form field looks like when the user clicks on it. It's contents should switch to "http://" when clicked or typed in. Here is what the code looks like at the moment:
<div class="form-group">
<input
class="form-control"
type="text"
name="companyUrl"
[(ngModel)]="user.companyUrl"
placeholder="Company url"
required pattern='https?://.+'
#companyUrl
>
<div *ngIf="companyUrl.errors && (companyUrl.dirty || companyUrl.touched)" class="text-danger">
<div [hidden]="!companyUrl.errors.required">
Company URL is required.
</div>
<div [hidden]="!companyUrl.errors.pattern">
URL should begin with http:// or https://
</div>
</div>
<div>
Add a function to add the prefix on click event of the input.
Something like below:
<input #companyUrl (click)="addHttpPrefix()" >
And in this function
1. Get the value of companyUrl.
2. Check if it begins with http then skip else prepend with http://
if(companyUrl.indexOf('http') > -1) {
companyUrl = 'http://' + companyUrl;
}
This way when the user initially clicks on the input http:// would be appended.
if the (click) event does not meet your requirement you can try using (change) or other events.

Soundcloud track /download slug no longer working

Soundcloud has feature that allows any track to auto download if you add "/download" to the end of the track URL.
We have made use of that feature for many years on our soundcloud hosted podcast:
http://techzinglive.com
http://soundcloud.com/techzing
As of a few days ago the feature seems to have stopped working.
Now that we have 300 episodes it would be quite difficult to go back and retrospectively change the URLs by copy pasting the download link for each episode.
a) Is there any way Soundcloud could fix this?
b) Is there an alternative that does the same thing?
Example:
168: TZ Interview - Patrick Collison / Stripe
~~~
http://soundcloud.com/techzing/techzing-168 (regular link)
http://soundcloud.com/techzing/techzing-168/download (auto download link)
Note: I posted this here as directed by the soundcloud support page.
Well the answer to the question is that SoundCloud no longer support the download slug option. But you can get it to work using their API.
Backend (PHP)
<?php
$yourSoundCloudClientId = '<CLIENTID>';
$yourSoundCloudTrackUrl = 'http://soundcloud.com/techzing/techzing-001';
if ( ! $trackData = json_decode(file_get_contents("http://api.soundcloud.com/resolve?url={$yourSoundCloudTrackUrl}&client_id={$yourSoundCloudClientId}")) )
{
die('Could not get the track because Soundcloud is down, or somethign else weird is happening.');
}
header("Location: {$trackData->download_url}?client_id={$yourSoundCloudClientId}");
?>
Frontend (JS)
<head>
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<script src="https://connect.soundcloud.com/sdk/sdk-3.0.0.js"></script>
<script>
var yourSoundCloudClientId = '<CLIENTID>';
var yourSoundCloudTrackUrl = 'http://soundcloud.com/techzing/techzing-001';
SC.initialize
({
client_id: yourSoundCloudClientId
});
SC.get('/resolve?url='+yourSoundCloudTrackUrl).then
(
function(track)
{
$('#trackDiv').html('<iframe width="100%" height="450" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/'+track.id+'&auto_play=false&hide_related=false&show_comments=true&show_user=true&show_reposts=false&visual=true"></iframe>');
}
);
</script>
</head>
<body>
<div id="trackDiv"></div>
</body>
Forgive the malformed HTML... but, you know, it works ;)

Prevent form submission at all costs in Dojo

I am developing a simple Dojo application. I have a bit of a problem with my forms.
I have a form like this:
<form data-dojo-type="dijit.form.Form" data-dojo-attach-point="loginForm" method="POST">
<label for="${id}_login">Login</label>
<input name="login" id="${id}_login" data-dojo-attach-point="login" data-dojo-type="dijit.form.ValidationTextBox" data-dojo-props="required:true"/>
<label for="${id}_password">Password</label>
<input name="password" id="${id}_password0" data-dojo-attach-point="password" data-dojo-type="app.ValidationPassword" />
<input type="submit" data-dojo-attach-point="loginButton" data-dojo-type="app.BusyButton" label="Login!" />
</form>
In the app I have:
this.loginForm.onSubmit = function(e){
// Do Ajax calls etc.
// ..
// Prevents actual submission
return false;
}
However, if anything goes wrong with the Javascript before that "return false", the form is actually submitted, which results in an error (my node app will return Cannot POST /login as there is no POST action defined for that URL).
How can I make 1000% sure that the form doesn't get submitted in any case? I know I could get rid of the tag altogether since I do everything with Ajax, but... then I wouldn't get the nice data = that.loginForm.getValues(); for example. (I mean, it is a form after all)
(NOTE: I am NOT interested in non-javascript downgrading, really. The app is a 1-page ajax app, and there is no point in getting it to work if the user doesn't have AJAX) )
preventDefault will stop the browser from performing the default action (ie: submitting).
this.loginForm.onSubmit = function(e){
e.preventDefault();
// Do Ajax calls etc.
// ..
}
See here for more information.

PayPal Standard not giving option for Check out as Guest

MVC 3 VB.NET applicaiton... Using express checkout with html razor view. I have tried everything mentioned in all of the docs i could google for as well as the ones on paypal's dev network. Our Paypal account is setup to allow users to Check out as Guest without requiring paypal account creation or login. However when users are taken to the paypal site after clicking the checkout button there is no option to check out as guest. I am including my checkout view for reference. Please understand that this is a valid question and do not down vote it. If there is something not clear I will clarify it..
#modeltype xxxxxxx.orderVM
#Code
ViewData("Title") = "CheckOut"
End Code
<p style="text-align:center">Once you complete your transaction you will be redirected back to the site</p>
<p></p>
<p style="text-align:center">We will process your payment within 24 hours at which time you will recieve a confirmation email which you will need for addmission. Along with a PDF attachment in this email which is your parking permit.. Please print and follow the instructions</p>
<p></p>
<p></p>
<p></p>
<p></p>
<p style="text-align: center"> Please Click on the paypal button below to be redirected to the PayPal Site to complete the payment Transaction</p>
<form id="PayPal" name="PayPal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
#Html.Hidden("cmd", "_cart")
#Html.Hidden("upload", "1")
#Html.Hidden("business", ConfigurationManager.AppSettings("PayPalMerchantEmail"))
#Html.Hidden("page_style","primary")
#Html.Hidden("custom", Model.id.ToString)
#Html.Hidden("image_url", "http://www.xxxxxxxxxx.com/content/images/xxxxxxxxLogo.jpg")
#Html.Hidden("cpp_header_image", "http://www.xxxxxxxx.com/content/images/xxxxxxxLogo.jpg")
#Html.Hidden("cpp_logo_image", "http://www.xxxxxxxxxxe.com/content/images/xxxxxxxLogo.jpg")
#Html.Hidden("return", "http://www.xxxxxxxxxx.com/")
#Html.Hidden("cancel_return", "http://www.xxxxxxxxxx.com")
#Html.Hidden("first_name", Model.first_name)
#Html.Hidden("last_name", Model.last_name)
#Html.Hidden("address1", Model.address1)
#Html.Hidden("address2", Model.address2)
#Html.Hidden("city", Model.city)
#Html.Hidden("state", Model.state)
#Html.Hidden("zip", Model.zip)
#If Not String.IsNullOrEmpty(Model.Class1) Then
#Html.Hidden("item_name_1", Model.Class1)
#Html.Hidden("amount_1", Model.fee1)
#Html.Hidden("quantity_1", ViewBag.quan)
#Html.Hidden("shipping_1", " 0.00 ")
#Html.Hidden("handling_1", " 0.00 ")
End If
<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif" align="middle" style="text-align:center"/>
</form>
I do not feel the code for the controller is required here since it does pass all the values correctly into the view... The only issue is I can not get check out as guest working...
Have you turned on 'Account Optional' in your PayPal Profile?
Which country is your account located in? The guest checkout functionality is not available in all countries yet.