index.php 2.51 KB
<?php
require_once('basepath.inc.php');
require_once($__PATH_to_mcClasses . 'include.php');

//D::show($_GET, 'get',1,1);
if(array_key_exists('qrcode', $_GET) && $_GET['qrcode']) {
//	echo mcQRCode::createQRCode($_GET['qrcode']);
//	return QRcode::png($_GET['qrcode'], $outfile = false, $level = QR_ECLEVEL_L, $size = 1, $margin = 4, $saveandprint=false); 
//} else {
	
//	$qrtxt = array(
//		'www.quaink.de/qr',
//		'user',
//		'XXSSAA'
//	);
//	$qrtxt = serialize($qrtxt);
//	
	$qrtxt = $_GET['qrcode'];
	

	
	/**
	 * text
	 */
	if(strpos($qrtxt, '}')) {
		$array_qrtxt = unserialize($qrtxt);
		if(isset ($array_qrtxt) && is_array($array_qrtxt) && count($array_qrtxt) ==3) {
			$_txt1 = $array_qrtxt[0];
			$_txt2 = 'ID: '.$array_qrtxt[1];
			$_txt3 = 'Passwort: '.$array_qrtxt[2];
			$_url =	'http://'.$array_qrtxt[0].'/index_cs.php?user_id='.$array_qrtxt[1].'&pw='.$array_qrtxt[2];					
		}
	} else {
		$_txt1 = $qrtxt;
		$_txt2 = 'ID: '.$qrtxt;
		$_txt3 = 'Passwort: '.$qrtxt;
		$_url = 'http://'.$qrtxt.'/';				
	}
		
	
	
//	$qrcode_size = 200;
	$qrcode_size = 581;
	$tmp_qrfilepath = 'tmp/tmp_qrfile.png';
	$margin = 2;
	$font_size = 60;
	$font_type = 'Arial';
	$font_start = 38;
	
	QRcode::png($_url, $tmp_qrfilepath , $level = QR_ECLEVEL_L, $size = 10, $margin, $saveandprint=false); 
	$qr_image = new Imagick($tmp_qrfilepath);
	$qr_image->scaleImage($qrcode_size,$qrcode_size); 


	$draw = new ImagickDraw();
	$draw->setFillColor('black');
	$draw->setFont($font_type);
	$draw->setFontSize( $font_size );

	$text_image = new Imagick();
	$text_image->newImage($qrcode_size/2, $qrcode_size, new ImagickPixel( 'white' ));
	$text_image->setImageFormat('png');

	$text_image->annotateImage($draw, 160, $font_start, 90, $_txt1);
	$text_image->annotateImage($draw, 80, $font_start, 90, $_txt2);
	$text_image->annotateImage($draw, 20, $font_start, 90, $_txt3);


	

	$canvas = new Imagick();
	$canvas->newImage($qrcode_size + $qrcode_size/2, $qrcode_size, new ImagickPixel("white"));
	$canvas->setImageFormat("png");
	$canvas->compositeImage($qr_image, imagick::COMPOSITE_OVER, 0, 0);
	$canvas->compositeImage($text_image, imagick::COMPOSITE_OVER, $qr_image->getImageWidth() + 0, 0);
	$canvas->borderImage(new ImagickPixel("black"), 5, 5);
	header('Content-type: image/png');
	echo $canvas;
}


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
//$image->thumbnailImage(100, 0);
// bild größe skalieren
//	$image->adaptiveResizeImage(1024,768);
//	$image->scaleImage(800,800); 
//	$qr_image->setSize(800,800); 
?>