qrlib.php 1.54 KB
Newer Older
Kulya's avatar
Kulya committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
<?php namespace QRL;  date_default_timezone_set('Asia/Tashkent');

class QRC
{
    public $configs;
    public $QR_BASEDIR;
    public $files;
	
	public function __construct() {
		$this->QR_BASEDIR = dirname(__FILE__).DIRECTORY_SEPARATOR."src/";
		$this->configs = \AloVoice\AloVoiceConnector->getConfigs();
		$this->files = dirname(dirname(__DIR__))."/".$this->configs["files_folder"];
	}

	public function makeQR($data,$file=false,$errorCorrectionLevel="L",$matrixPointSize=4){
		if(empty($data)){ return false; }
		// Required libs
		
		include $this->QR_BASEDIR."qrconst.php";
		include $this->QR_BASEDIR."qrconfig.php";
		include $this->QR_BASEDIR."qrtools.php";
		include $this->QR_BASEDIR."qrspec.php";
		include $this->QR_BASEDIR."qrimage.php";
		include $this->QR_BASEDIR."qrinput.php";
		include $this->QR_BASEDIR."qrbitstream.php";
		include $this->QR_BASEDIR."qrsplit.php";
		include $this->QR_BASEDIR."qrrscode.php";
		include $this->QR_BASEDIR."qrmask.php";
		include $this->QR_BASEDIR."qrencode.php";
		
		
		//$errorCorrectionLevel s = // array('L','M','Q','H')))
		//$matrixPointSize = min(max((int)$_REQUEST['size'], 1), 10);
		
		var_dump($this->configs);
		var_dump($this->files);
		
        // user data
		if(empty($file)){
			$file = $this->files.'qrcode_'.time().'.png';
		}
        // $filename = $PNG_TEMP_DIR.'test'.md5($_REQUEST['data'].'|'.$errorCorrectionLevel.'|'.$matrixPointSize).'.png';
        QRcode::png($data, $file, $errorCorrectionLevel, $matrixPointSize, 2);
		
		return $filename;
	}	
}