Skip to content

Instantly share code, notes, and snippets.

@andreia
Created May 27, 2010 12:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andreia/415746 to your computer and use it in GitHub Desktop.
Save andreia/415746 to your computer and use it in GitHub Desktop.
Gerar código de verificação da Redecard
<?php
// gerar código de verificação da Redecard
function redecardCodver($varFiliacao, $varTotal, $varEndIP){
$dataAtual = getdate();
$segundosAtuais = $dataAtual['seconds'];
$segundosCodificados = array(11,17,21,31,56,34,42,3,18,13,12,18,22,32,57,35,43,4,19,14,9,20,23,33,58,36,44,5,24,15,62,25,34,59,37,45,6,25,16,27,63,26,35,60,38,46,7,26,17,28,14,36,2,39,47,8,29,22,55,33);
$i = $segundosCodificados[$segundosAtuais];
$s2 = ($i < 10) ? "0" : "";
$k1 = strlen($varEndIP);
$i1 = intval($varTotal);
$j = intval($varFiliacao);
$j1 = $i1 + $i;
$l1 = $i + $k1;
$k = $i * $j;
$s3 = strlen($k);
return "$k$j1$l1-$s3$s2$i";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment