Skip to content

Commit

Permalink
Merge branch 'master' of github.com:londonhackspace/hackspace-foundat…
Browse files Browse the repository at this point in the history
…ion-sites
  • Loading branch information
JasperWallace committed May 1, 2016
2 parents a301090 + b98b73e commit cc8378d
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 14 deletions.
23 changes: 23 additions & 0 deletions lib/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,26 @@ function send404($message) {
echo $message;
exit;
}

// Throw an exception if the card UID is invalid
function validateCardUID($uid) {
if ($uid == '21222324' || $uid == '01020304') {
/* Some Visa cards issued around 2013 return 21222324, presumably for privacy.
* Android phones always return 01020304. */
throw new fValidationException('Non-unique UID. This card cannot be added to the system.');
}

// Random IDs are 4 bytes long and start with 0x08
// http://www.nxp.com/documents/application_note/AN10927.pdf
if(strlen($uid) === 8 && substr($uid,0,2) === "08") {
throw new fValidationException('ID is randomly generated and will change every time the card is used!');
}

if(strlen($uid) === 8 && substr($uid,0,2) === "88") {
throw new fValidationException('Card UID\'s can\'t start with 88');
}

if(strlen($uid) > 8 && substr($uid,6,8) === "88") {
throw new fValidationException('Can\'t have cards with long uid\'s and UID3 == 88');
}
}
5 changes: 1 addition & 4 deletions london.hackspace.org.uk/kiosk/addcard.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@
$validator->validate();

$uid = strtoupper($_POST['uid']);
if ($uid == '21222324') {
/* New Visa cards return this, presumably for privacy */
throw new fValidationException('Non-unique UID. This card cannot be added to the system.');
}
validateCardUID($uid);

// Random IDs are 4 bytes long and start with 0x08
// http://www.nxp.com/documents/application_note/AN10927.pdf
Expand Down
5 changes: 1 addition & 4 deletions london.hackspace.org.uk/login_and_addcard.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@
$validator->validate();

$uid = strtoupper($_POST['uid']);
if ($uid == '21222324') {
/* New Visa cards return this, presumably for privacy */
throw new fValidationException('Non-unique UID. This card cannot be added to the system.');
}
validateCardUID($uid);

// Random IDs are 4 bytes long and start with 0x08
// http://www.nxp.com/documents/application_note/AN10927.pdf
Expand Down
7 changes: 2 additions & 5 deletions london.hackspace.org.uk/members/addcard.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,8 @@
$validator->validate();

$uid = strtoupper($_POST['uid']);
if ($uid == '21222324') {
/* New Visa cards return this, presumably for privacy */
throw new fValidationException('Non-unique UID. This card cannot be added to the system.');
}

validateCardUID($uid);

$card = new Card();
$card->setUserId($user->getId());
$card->setAddedDate(time());
Expand Down
4 changes: 3 additions & 1 deletion london.hackspace.org.uk/members/webcams.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
3 => "Main Room",
6 => "Classroom",
5 => "Workshop",
1 => "Back Gate"
1 => "Back Gate",
8 => "Back Door",
9 => "Quiet Room"
);

if (!isset($user) || !$user->isMember()) {
Expand Down

0 comments on commit cc8378d

Please sign in to comment.