views:

70

answers:

2

I have a rails app which requires users to verify that they own a website before submitting links from that site.

I have implemented a website verification system that works thanks to the answers given to a question I made several months ago. This system works but it is rather cumbersome for users. It requires them to create a web page on their site with a specific verification key for a url. I feel like I'm asking the user to jump through a lot of hoops just to submit their pages to my site. Site verification is vital, however, and I can't let go of this feature, however cumbersome.

I'm looking to create some javascript code that will help validate websites. When users install the plugin, all they would then have to do is click "verify" on the web app, and all the work is done for them. They don't have to go through the chore of creating a new web page and deleting it.

I have a faint idea of how to get started...

Step one: the javascript code to be placed on the website (simplified version of google analytics code):

        "<script type='text/javascript' id="THE VERIFICATION CODE GENERATED BY THE RAILS APP">

          (function() {
            var secondScript = document.createElement('script');
secondScript.type = 'text/javascript';
            secondScript.src = 'http://www.mywebapp.com/verify.js';
            var firstScript = document.getElementsByTagName('script')[0]; firstScript.parentNode.insertBefore(secondScript, firstScript);
          })();

        </script>"

In the second script(verify.js):

//find some way to ensure that the first script has an id of "VERIFICATION KEY"
//if so, return some data that the rails app can understand and verify the site

Any ideas?

+2  A: 

That's a REALLY interesting problem, but I don't know if there is a good solution in the way you're looking for. In other words, I don't think you can create some sort of automated utility to upload the script in step one.

You can't assume they have FTP access, or SSH access; some web hosts might disallow those things. You can't assume they have some sort of 'package' installed to communicate with, or even the ability to install such a thing.

One thing that might work (but still has its own set of issues) is to do a whois lookup and email the owner of the site on record with a confirmation link... Of course that's assuming the whois is listed and they didn't provide a dummy email.

Google accounts checks for domain ownership by doing the file upload thing, or letting the user create a custom subdomain (CNAME) on the site. Of course, if your users are having issues uploading a single file, the CNAME thing is probably right out.

swilliams
Hmm, I suppose the problem is that I have to make it worth the user's while to verify their site. Google Analytics is a very useful service. Useful enough for third parties to write detailed blog articles on how to set it up on ANY kind of site.That said, setting up google analytics for my wordpress blog just required me to download a plugin and click "activate." I'm hoping there is a way to make it that easy for my site.
Kenji Crosland
+1  A: 

There are other ways to verify ownership of website. Many companies will send an e-mail to the registrant of the domain. Create a file with a certain name. Put a piece of specific text into the header of the index page. I think the way you're attempting above is more complex than it needs to be. It's pretty easy for any webmaster to create a file with a certain name and with certain content. I've done it many times for different tools.

Don't sweat it :-)

godswearhats
It is easy for a webmaster to upload a file, but what about someone who own's a domain that is pointing to something like a Tumblr blog? They simply cannot upload a plain text file that way...
swilliams
Correct, however they can easily put something on a particular page. I myself have done this for Wordpress blogs. Get them to put code like this:`<div id="my-app-validation" style="display: none;"> put autogenerated validation string here</div>`
godswearhats
So the app would use a screen scraper to ensure that the validation string was there?
Kenji Crosland
Precisely. The user clicks a button to say "I've done it" and your screenscraper hits the page and looks for the div. It's a small amount of code to make that happen.
godswearhats
I've been testing this in development mode with nokogiri with the invisible div. It works as far as I can see.I think this could be easier for users because with uploading a page there are too many variables (especially with CMS apps that do wierd things to urls). I almost want to have both verification options on the site, but I suppose that would make things more complex than they should be.
Kenji Crosland
I've just realized that there's a problem with this solution because someone could paste the code in the comments and not have ownership of the site...yikes!
Kenji Crosland
Hmmm ... most comment code strips out div tags, but you are correct. I think that's why other sites ask for the special code to go in the <head> of the page.
godswearhats
Problem with that is difficult for wordpress users to put code into the head. I've seen that google analytics overcomes the problem with some sort of javascript hash, but that functionality is beyond me.
Kenji Crosland
I've finally decided to have user place the code in the HEAD portion of the site. If you have a video demonstration that instructs users where to look, then it's not so hard.
Kenji Crosland