Created
March 18, 2014 17:51
-
-
Save brunokruse/9625480 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private function __get_id($qr_code) { | |
if (empty($qr_code)) { | |
return false; | |
} | |
$arrBarCode = explode(',', $qr_code); | |
if (empty($arrBarCode[1])) { | |
return false; | |
} | |
$beginning = substr($arrBarCode[1], 0, 16); | |
$end = substr($arrBarCode[1], -16); | |
$id = str_replace(array($beginning, $end), '', $arrBarCode[1]); | |
if (empty($id) || !is_numeric($id)) { | |
return false; | |
} | |
$qrOptions = Configure::read('Campaign.QR'); | |
$md5 = md5(urlencode(trim($arrBarCode[0])) . ',' . $id . ',' . $qrOptions['secret']); | |
if ($beginning . $end !== $md5) { | |
return false; | |
} | |
return $id; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment