<?php

class Qrcode
{

  public function scan($filename)
  {
    $data = '';
    $file = urldecode($filename);

    if (!file_exists($file)) {
      return '';
    }

    $image = new ZBarCodeImage($file);
    $scanner = new ZBarCodeScanner();
    $barcode = $scanner->scan($image);
    if (!empty($barcode)) {
      foreach ($barcode as $code) {
        $data .= ',' . $code['data'];
      }
      if (!empty($data))
        $data = substr($data, 1);
    }

    return $data;
  }

}