Adds initial files for membership integration with SnappOrder
This commit is contained in:
1 parent
33468ed02f
commit
b0ef7061c1
8 files changed
+136
No files matched your search
@@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
/* User activation form (step 2).
|
||||||
|
* SnappOrder first saves initial data in our temp user db
|
||||||
|
*
|
||||||
|
* TODO:
|
||||||
|
* - Present user form
|
||||||
|
* - validate user data
|
||||||
|
* - load inside user object and populate it
|
||||||
|
* - persist to db
|
||||||
|
*/
|
||||||
|
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* Lookup a members phone number and return a member-like object.
|
||||||
|
*
|
||||||
|
* Request:
|
||||||
|
*
|
||||||
|
* $ curl /snapporder/api/query.php?phone=48105885
|
||||||
|
*
|
||||||
|
* Response:
|
||||||
|
*
|
||||||
|
* {
|
||||||
|
* "phone":12345678,
|
||||||
|
* "memberStatus":1, // 0 - ikke medlem, 1 - medlem, 2 - aktiv
|
||||||
|
* "endDate": "2015-04-23",
|
||||||
|
* "membershipNumber": "dsadsa2333",
|
||||||
|
* "firstName": "Jon",
|
||||||
|
* "lastName": "Hansen",
|
||||||
|
* "email": "jon@uio.no"
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* TODO:
|
||||||
|
* - Decode http body
|
||||||
|
* - validate and sanitize query param
|
||||||
|
* - lookup up phone number
|
||||||
|
* - return result
|
||||||
|
*/
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* Registers a temporary user in the temp user table
|
||||||
|
*
|
||||||
|
* Request:
|
||||||
|
*
|
||||||
|
* $ curl /snapporder/api/register.php
|
||||||
|
* {
|
||||||
|
* "phone":12345678,
|
||||||
|
* "firstName": "Jon",
|
||||||
|
* "lastName": "Hansen",
|
||||||
|
* "email": "jon@uio.no"
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* Response:
|
||||||
|
*
|
||||||
|
* {
|
||||||
|
* "phone":12345678,
|
||||||
|
* "memberStatus":1,
|
||||||
|
* "endDate": "2015-04-23" ,
|
||||||
|
* "membershipNumber": "dsadsa2333",
|
||||||
|
* "firstName": "Jon",
|
||||||
|
* "lastName": "Hansen",
|
||||||
|
* "email": "jon@uio.no"
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* TODO:
|
||||||
|
* - Decode encrypted http body
|
||||||
|
* - validate http body
|
||||||
|
* - register user in temp user db
|
||||||
|
* - return result
|
||||||
|
*/
|
||||||
|
?>
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
<?php
|
||||||
|
define("SNAP_IV", 'kdj87wncboq20jcv');
|
||||||
|
define("SNAP_KEY", 'lkdowdjf82736esc');
|
||||||
|
?>
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
<?php /* Tumbleweeds */ ?>
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
<?php
|
||||||
|
/* Encryption library for
|
||||||
|
* Provided by Rasmus in SnapOrder */
|
||||||
|
|
||||||
|
class CryptoHelper
|
||||||
|
{
|
||||||
|
|
||||||
|
private $iv;
|
||||||
|
private $key;
|
||||||
|
|
||||||
|
function __construct($iv, $key)
|
||||||
|
{
|
||||||
|
$this->$iv = $iv;
|
||||||
|
$this->$key = $key;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function encrypt($str)
|
||||||
|
{
|
||||||
|
$iv = $this->iv;
|
||||||
|
|
||||||
|
$td = mcrypt_module_open('rijndael-128', '', 'cbc', $iv);
|
||||||
|
|
||||||
|
mcrypt_generic_init($td, $this->key, $iv);
|
||||||
|
$encrypted = mcrypt_generic($td, $str);
|
||||||
|
|
||||||
|
mcrypt_generic_deinit($td);
|
||||||
|
mcrypt_module_close($td);
|
||||||
|
|
||||||
|
return bin2hex($encrypted);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function decrypt($code)
|
||||||
|
{
|
||||||
|
$code = $this->hex2bin($code);
|
||||||
|
$iv = $this->iv;
|
||||||
|
|
||||||
|
$td = mcrypt_module_open('rijndael-128', '', 'cbc', $iv);
|
||||||
|
|
||||||
|
mcrypt_generic_init($td, $this->key, $iv);
|
||||||
|
$decrypted = mdecrypt_generic($td, $code);
|
||||||
|
|
||||||
|
mcrypt_generic_deinit($td);
|
||||||
|
mcrypt_module_close($td);
|
||||||
|
|
||||||
|
return utf8_encode(trim($decrypted));
|
||||||
|
}
|
||||||
|
|
||||||
|
private function hex2bin($hexdata)
|
||||||
|
{
|
||||||
|
$bindata = '';
|
||||||
|
|
||||||
|
for ($i = 0; $i < strlen($hexdata); $i += 2) {
|
||||||
|
$bindata .= chr(hexdec(substr($hexdata, $i, 2)));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $bindata;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
Whitespace-only changes.
Whitespace-only changes.
Reference in new issue
Block a user