Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
peeto committed Jan 2, 2018
1 parent 8cde8dc commit eef1415
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
13 changes: 8 additions & 5 deletions src/Codec.php
Expand Up @@ -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)) {
Expand All @@ -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
];
}

Expand Down Expand Up @@ -76,15 +78,16 @@ protected function encode($id)
$qrhtml = '<img src="data:'.$qrCode->getContentType().';base64,'.$qrCode->generate().'" />';

$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);
$bchtml = '<img src="data:image/png;base64,'.$barcode->generate().'" />';
}

$result = [
'oid' => $id,
'sitename' => $this->getConfig('DEST_SITE_NAME'),
'siteurl' => $this->getConfig('DEST_SITE_URL'),
'srcurl' => $this->getConfig('SRC_SITE_IDURL'),
Expand Down
11 changes: 6 additions & 5 deletions src/idforward.php
Expand Up @@ -24,7 +24,8 @@ protected function getTitleHTML($data)
protected function getInputHTML($data)
{
$html = '<form method="get" action="' . $data['srcurl'] . '">';
$html .= '<p>Enter ID or profile URL: <input type="text" name="id" value="' . $data['id'] . '"></p>';
$html .= '<p>Enter ID or profile URL: <input type="text" name="id" value="' . $data['oid'] . '" />';
$html .= '<input type="submit" value="Find" /></p>';
$html .= '</form>';

return $html;
Expand All @@ -33,18 +34,18 @@ protected function getInputHTML($data)
protected function getOutputHTML($data)
{
$html = '<p>';
$html .= 'Profile URL: <a href="' . $data['url'] . '" title="' . $data['id'] . '">' . $data['id'] . '</a><br />';
$html .= 'Hexidecimal URL: <a href="' . $data['hexurl'] . '" title="' . $data['hexid'] . '">' . $data['hexid'] . '</a><br />';
$html .= 'Profile: <a href="' . $data['url'] . '" title="' . $data['id'] . '" target="other">' . $data['id'] . '</a><br />';
$html .= 'Hexidecimal: <a href="' . $data['hexurl'] . '" title="' . $data['hexid'] . '">' . $data['hexid'] . '</a><br />';
$html .= $data['qrhtml'] . '<br />';
$html .= $data['bchtml'] . '<br />';
//$html .= $data['bchtml'] . '<br />';
$html .= '</p>';

return $html;
}

public function getHTML($id)
{
$result = $this->decode($id);
$result = $this->encode($id);

$html = $this->getTitleHTML($result);
$html .= $this->getInputHTML($result);
Expand Down

0 comments on commit eef1415

Please sign in to comment.