diff --git a/src/Codec.php b/src/Codec.php index 2137540..be76109 100644 --- a/src/Codec.php +++ b/src/Codec.php @@ -27,7 +27,7 @@ protected function decode($id) $did = ''; if (substr($id, 0, 1)=='x') { - $id = '0' . $id; + $id = hexdec(substr($id, 1)); } if (is_numeric($id)) { @@ -41,11 +41,13 @@ protected function decode($id) $did = intval(substr($id, strlen($srcurl))); } + $hexid = 'x' . strtoupper(dechex($did)); + return [ 'id' => $did, 'url' => $desturl . $did, - 'hexid' => 'x' . dechex($did), - 'hexurl' => $srcurl . 'x' . dechex($did) + 'hexid' => $hexid, + 'hexurl' => $srcurl . $hexid ]; } @@ -76,8 +78,8 @@ protected function encode($id) $qrhtml = ''; $barcode = new BarcodeGenerator(); - $barcode->setText($aid); - $barcode->setType(BarcodeGenerator::Upca); + $barcode->setText($aid . ' ' . $this->getConfig('DEST_SITE_NAME')); + $barcode->setType(BarcodeGenerator::Code128); $barcode->setScale(2); $barcode->setThickness(25); $barcode->setFontSize(10); @@ -85,6 +87,7 @@ protected function encode($id) } $result = [ + 'oid' => $id, 'sitename' => $this->getConfig('DEST_SITE_NAME'), 'siteurl' => $this->getConfig('DEST_SITE_URL'), 'srcurl' => $this->getConfig('SRC_SITE_IDURL'), diff --git a/src/idforward.php b/src/idforward.php index 6f2b3bc..109cade 100644 --- a/src/idforward.php +++ b/src/idforward.php @@ -24,7 +24,8 @@ protected function getTitleHTML($data) protected function getInputHTML($data) { $html = '
'; - $html .= '

Enter ID or profile URL:

'; + $html .= '

Enter ID or profile URL: '; + $html .= '

'; $html .= '
'; return $html; @@ -33,10 +34,10 @@ protected function getInputHTML($data) protected function getOutputHTML($data) { $html = '

'; - $html .= 'Profile URL: ' . $data['id'] . '
'; - $html .= 'Hexidecimal URL: ' . $data['hexid'] . '
'; + $html .= 'Profile: ' . $data['id'] . '
'; + $html .= 'Hexidecimal: ' . $data['hexid'] . '
'; $html .= $data['qrhtml'] . '
'; - $html .= $data['bchtml'] . '
'; + //$html .= $data['bchtml'] . '
'; $html .= '

'; return $html; @@ -44,7 +45,7 @@ protected function getOutputHTML($data) public function getHTML($id) { - $result = $this->decode($id); + $result = $this->encode($id); $html = $this->getTitleHTML($result); $html .= $this->getInputHTML($result);