Login   Register  
PHP Classes
elePHPant
Icontem

File: paramAuthQueryString.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Marcelo Costa  >  securityAuthParam  >  paramAuthQueryString.php  >  Download  
File: paramAuthQueryString.php
Role: Example script
Content type: text/plain
Description: exemple
Class: securityAuthParam
Encrypt and verify URL parameters
Author: By
Last change:
Date: 4 years ago
Size: 1,277 bytes
 

Contents

Class file image Download
<?php
include_once ("securityAuthParam.php");

// This exemple query string is a encode64 param

define("PRIVATEKEY""Marcelo Costa");
define("HASHMODE","MD5");// opcional default are ripemd160
define("AUTHMODE""AUTHSTR");// opcional default are AUTHARRAY

$Objeto = new securityAuthParam();

// Check ecode auth string in request
if(array_key_exists('param'$_REQUEST))
{
echo 
"DECODE REQUEST<br>\r\n";
$queryStringRequest="id=".$_GET['id']."&date=".$_GET['date']."&randon=".$_GET['randon'];
echo 
$queryStringRequest."<br>\r\n";
echo 
$_GET['param']."<br>\r\n";
try {
$CHECK=$Objeto->decodeAuthParam($_GET['param'],$queryStringRequest);
if(
$CHECK==true)
{
echo 
"query string ok<br/>\r\n";
}
} catch (
Exception $e) {
echo 
"invalid param auth";
}
}

echo 
"<br/>New query string for encode<br/>\r\n";

$rand rand();
$queryString ="id=321&date=".date('d/m/y')."&randon=".$rand;

echo 
"<br/>query string => ".$queryString."<br/>\r\n";

$param=$Objeto->encodeAuthParam($queryString);

$paramlegth=$queryString."&param=".$param;

echo 
"<br/><br/>Encode Auth => ".$param."<br/>\r\n";

echo 
"<br/>param length =" strlen($paramlegth) . " chars,<a href=\"?".$queryString."&param=".$param ."\">clique here for decode</a><br/><br/>\r\n";

echo 
$Objeto->authParam($queryString);
?>