ñìñ:êëþ÷

MobilPass

Technical info

The MobilPass is, from the implementational point of view, just a way of restricting user's ability to visit certain web-resources. In order to allow a user to review the restricted content, individual access passwords are generated; each one of these passwords can have a time and/or visit count limit, up to you. The access for the certain password is denied when the time is up OR when the visit count limit is hit, whichever comes first. Be careful while adjusting the options thought: note that when you change your MobilPass options, only those users that signed up after the change are affected.

The obvious positive sides of the MobilPass follow:

  • ease of installation (with a typical setup taking 5-10 minutes);
  • ease of adaptation to the user's specific needs (it's possible not only to fine-tune the look and feel of the entry form, but to replace the form as a whole with your own - without any functionality loss).

The tarification grid of your MobilPass is always available in XML at the address like

http://engine.mobilcent.com/xml/pass/MobilPass id/

The XML file mentioned includes also the data on messages' target numbers (the number field) and prefixes needed by the local cellular operators in order to transfer the message to our system (the prefix field); in different countries there are, respectively, different numbers and prefixes. In order for the message to be associated with your service, it must be formed like

prefix MobilPass id message text

and sent to number available in that country, according to the fee you're planning to collect.

If some country isn't present in the tarification grid mentioned, it means that the country just lacks the fee you set in the service's properties; try lowering the fee. All messages sent from such country will be simply ignored.

Implementation samples

Ready-to-use code samples are given below; basically just copy/paste the one which fits you best to the very beginning of the page you are restricting, and that's it. On the first visit the user will be instructed how to retrieve the password to the key by sending a message. The phrase saying MobilPass id in the following pieces of code should be replaced by your actual MobilPass id. Obviously, it's vital that your server supports the scripting language of your choice.

PHP

<?php
### MobilPass v1.0.4 ###
$key =
MobilPass id;
$response = implode("", file("http://engine.mobilcent
.com/pass/?s_key=" . $key
    . "&s_pair=" . urlencode(substr($_GET["s_pair"], 0, 10))
    . "&s_language=" . urlencode(substr($_GET["s_language"], 0, 10))
    . "&s_ip=" . $_SERVER["REMOTE_ADDR"]
    . "&s_url=" . $_SERVER["SERVER_NAME"]
    .
htmlentities(urlencode($_SERVER["REQUEST_URI"]))));
if($response != "true") {
    die($response);
}
### MobilPass end ###
?>

Perl

#!/usr/bin/perl
use CGI qw(:standard);
use HTML::Entities; use LWP::Simple;
use URI::Escape;

### MobilPass v1.0.4 ###
$key = MobilPass id;
$response = get("http://engine.mobilcent
.com/pass/?s_key=" . $key
    . "&s_pair=" . uri_escape(substr($_ = param("s_pair"), 0, 10))
    . "&s_language=" . uri_escape(substr($_ = param("s_language"), 0, 10))
    . "&s_ip=" . $ENV{ "REMOTE_ADDR" }
    . "&s_url=" . $ENV{ "SERVER_NAME" }

    . encode_entities(
uri_escape($ENV{ "REQUEST_URI" })));
if($response ne "true") {
    print "Content-Type: text/html\n\n", $response;
    exit;
}

### MobilPass end ###

ASP.NET

<%@page language="C#" %>
<%@import namespace="System.Net" %>
<%
/*** MobilPass v1.0.4 ***/
string key = "
MobilPass id";
byte[] response =
    new WebClient().DownloadData("http://engine.mobilcent
.com/pass/?s_key=" + key
    + "&s_pair=" + (Request.Params["s_pair"] != null
        ? Server.UrlEncode(Request.Params["s_pair"].Length > 10
            ? Request.Params["s_pair"].Substring(0, 10)
            : Request.Params["s_pair"]) : "")
    + "&s_language=" + (Request.Params["s_language"] != null
        ? Server.UrlEncode(Request.Params["s_language"].Length > 10
            ? Request.Params["s_language"].Substring(0, 10)
            : Request.Params["s_language"]) : "")
    + "&s_ip=" + Request.Params["REMOTE_ADDR"]
    + "&s_url=" + Request.Params["SERVER_NAME"]
    + Server.HtmlEncode(Server.UrlEncode(Request.Params["URL"]
        + Request.Params["QUERY_STRING"])));

if(Encoding.ASCII.GetString(response, 0, 4) != "true") {
    Response.BinaryWrite(response);
    Response.End();
}
/*** MobilPass end ***/
%>

The sample usage can be seen here. If you have checked the "Adult" checkbox in the service's settings, then the result will slightly differ, as shown here.

Flash technology

Despite the fact that we do not offer a separate MobilPass version for use on sites built fully with Flash technology, you are easily able to check key passwords with the following ActionScript code:

var key : String = new String("MobilPass");
var pair : String = new String("user-supplied password");
var loadVars : LoadVars = new LoadVars();
loadVars.onLoad = function(success : Boolean) {
    if(success && loadVars.toString() == "true") {
        // password accepted
    } else {
        // password declined
    }
}
loadVars.load("http://engine.mobilcent
.com/pass/?s_key=" + key
    + "&s_pair=" + pair);

Note that you need to replace MobilPass with your actual MobilPass id, user-supplied password with the password you need to check, and the password accepted and password declined comments with the code you need executed for both cases, respectively - redirect to the restricted zone of the site and an error message/retry proposal.

Code modifications

English by default

All our services default to Russian language historically; given that you need it changed, just replace in the above code snippets

http://engine.mobilcent.com/pass/

with

http://engine.mobilcent.com/language/english/pass/

An example of usage is here.

For mobile browsers

MobilPass is now available also to WAP-site visitors - in order for the key to generate WML markup instead of default HTML one, you should change the request address in the code snippets shown above from

http://engine.mobilcent.com/pass/

to

http://engine.mobilcent.com/pass_wml/

An example is given here.

Without decorations

This variation is suited for the tightest integration with your website's design. Just pass a parameter s_pure=1 (engine.mobilcent.com/pass/?s_pure=1) to the script, and the resulting page is stripped from both headers and CSS, leaving just HTML markup; it's trivial to adjust the look and feel using CSS as you see fit. The demonstration resides here.