Avoid badmatch when replicator dbnames have leading slashes.

Closes COUCHDB-317

Patch by Joan Touzet.
Do not log errors on creating new view index.

While view index file may be really missed, it's ok for new views
and this error will be self-healed on next couch_file:open call
so there is no reason to worry user about.

COUCHDB-1666

Patch by Alexander Shorin.
COUCHDB-1667: Revert index_dir to view_index_dir config option.

Patch by Alexander Shorin. (backport from couchdb 1.3.x branch)
COUCHDB-1654: Transparently update view signatures from <= 1.2.x.

Updates 1.2.x or earlier view files to 1.3.x or later view files
transparently, the first time the 1.2.x view file is opened by
1.3.x or later.

Here's how it works:

Before opening a view index,
If no matching index file is found in the new location:
 calculate the <= 1.2.x view signature
 if a file with that signature lives in the old location
   copy it to the new location with the new signature in the name.
Then proceed to open the view index as usual.
After opening, read its header.

If the header matches the <= 1.2.x style #index_header record:
  upgrade the header to the new #mrheader record
The next time the view is used, the new header is used.

If we crash after the rename, but before the header upgrade,
  the header upgrade is done on the next view opening.

If we crash between upgrading to the new header and writing
  that header to disk, we start with the old header again,
  do the upgrade and write to disk.

backport from Couchdb 1.3.x branch
Unfix view compaction progress reports

This reverts the compaction task status progress back to what exists on
1.2.x. The issue is that we use the number of documents in the database
instead of the number of docids in the union of all views (the number of
rows in the view's id btree). In this particular case the desire to have
seamless view upgrades outweighs fixing the relatively minor UI bug.

backport from couchdb 1.3.x branch
support JSONP in externals

COUCHDB-1313
refactor replicator_db_security to be more resilient