[Foo7BaL3r$]-ll-[Your Nick]

  [BG]   EN   RU  

 
Рейтинг: 3.00
(51)
Начало
Клан срещу Клан
Класиране
Клан срещу Клан
Членове на клана

БЛОГ АРХИВ
«« април 2024 »»
Пн Вт Ср Чт Пт Сб Нд
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30          


Анкети Форум Календар Фото Галерия За контакти 5vs5

Начало 13:07
« Обратно
Вземи в gLOG
Вземи в gLOG
IP-та на сарварите ни!!
89.215.6.202:27015-[Foo7BaL3r$]-classic
89.215.6.202:27016-{BG}[Foo7BaL3r$]{BG}
85.187.229.5:27027-[Foo7BaLer$]-ll-[CLAN] (WAR3)







/* library with necessary functions: */
include('for_smspay.php');

$my_pay = new ForSmspay(
'93aef5992a45ac09420376db01a56c7f', // your SMS-pay service id
'942e2059a5b1adfe8dcf1fbc4bac610e' // your SMS-pay service secret
);

/*
* NB! Response headers are set by session_start() function and thus,
* it must be executed before generating the response body.
*
* If your application already calls session_start() before executing this script,
* it will be recommended to remove the function call:
*/
if ($my_pay->sessions) {
session_start();
}

/* The content can be displayed by another script which generates HTML output: */
global $smspay_resp;

if ($my_pay->payment_verified()) {
/* User entered a valid password, authentication successful and the content can be displayed to the user */
$smspay_resp = $my_pay->restricted_content();

/* Or you can redirect the user to a separate script which verifies that $_SESSION["payment_ok"] is set: */
/*
* header('HTTP/1.0 302 Moved temporarily');
* header('Location: content.php');
*/
} else {
/*
* Invalid password or an error occurred;
* display the login widget with an error message
*/
$smspay_resp = $my_pay->widget();
}

?>








SMS-pay sample app
















$FORSMSPAY_SERVER = "smspay.fortumo.com";

/*
* We do not use "http_get" as the function name here, because http_get
* has already been defined in the standard PHP 5 extension "http"
*/
function http_get4($url) {
$s = "";
if( ($fp = @fopen($url, 'r')) !== false ) {
while (!feof($fp)) { $s .= fgets($fp); }
}
return $s;
}

class ForSmspay {

/*
* Parameters:
* $id - your service_id
* $secret - your service secret
* $do_sessions - if true, authentication status will be kept in the session after successful authentication
*/
function ForSmspay($id, $secret, $do_sessions = true) {
$this->id = $id;
$this->secret = $secret;
$this->sessions = $do_sessions;
$this->error = "";
}

function payment_verified() {
if($this->sessions) {
return (isset($_SESSION["payment_ok"]) || $this->authenticate($_POST['code']));
} else {
return $this->authenticate($_POST['code']);
}
}

/*
* This function performs an HTTP GET request to http://smspay.fortumo.com/tokens/show/
* in order to authenticate a password submitted by an end-user.
*
* Mandatory request parameters:
* service_id - an unique string identifying your service
* (see the general configuration page of your service in Fortumo)
* code - password submitted by the end-user from your widget
* sig - request signature, generated as following:
* 1) concatenate request params as "param=value" strings in alphabetical order into one string
* 2) append your service secret to the end of this string
* 3) apply md5() to the result
*
* The result is an XML with status code and message
* Code "0" indicates successful authentication.
* Otherwise, authentication failed and the widget should be displayed to the end-user
*
*/
function authenticate($code) {
global $FORSMSPAY_SERVER;
if( strlen($code) == 0 ) {
return false;
} else {
$sig = md5("code=".urlencode($code)."service_id=".$this->id.$this->secret);
$response = http_get4(
"http://".$FORSMSPAY_SERVER."/tokens/show/?".
"service_id=".$this->id.
"&code=".urlencode($code).
"&sig=".$sig
);

// if we are using php5, use simplexml to parse the xml
if (version_compare(PHP_VERSION,'5','>=')) {
$doc = simplexml_load_string($response);
$status = $doc->status_code;
$message = $doc->message;
} else { // use domxml for parsing the xml
$doc = domxml_open_mem($response);
}

/* if xml parsing does not work for you for whatever reason,
* then comment it out and use the following regexp instead. */

/* $matches = Array();
preg_match("/(\d+)\<.+(.+)<\/message/", str_replace("\n", '', $response), $matches);
$status = $matches[1];
$message = $matches[2]; */
if($status == "0") {
if($this->sessions) {
$_SESSION["payment_ok"] = true;
}
return true;
} else {
$this->error = $status;
return false;
}
}
}

/*
* Parameters which you can use to control the content of the widget:
*
* submit_url - the "SUBMIT" button on the widget needs to point to your password-processing script
* status_code - when password validation failed,
* use the status_code to reload the widget with a proper error message
*
* Description of error codes:
* 1 - password processing error
* 2 - end-user submitted a wrong password
* 3 - password has expired
* 6 - end-user reply SMS hasn't been billed yet (billing is pending)
* 7 - end-user reply SMS billing failed
*
*/
function widget() {
global $FORSMSPAY_SERVER;
$widget_params = "?submit_url=".$_SERVER['REQUEST_URI'];
if ($this->error != null) {
$widget_params = $widget_params."&status_code=".$this->error;
}

return http_get4("http://".$FORSMSPAY_SERVER."/widgets/show/".$this->id.$widget_params);
}

function restricted_content() {
return "Great Success!";
}
};

?>
19 Януари 08, 13:07    Коментари (1834)

Дир ID: 
Парола: Забравена парола
  Нов потребител

0.1009