Path : /var/www/html/main/logs/qrcode/
File Upload :
Current File : /var/www/html/main/logs/qrcode/qrcode.php

<?php
/*!
 * Copyright Anucha Puangpaka
 * Contacts anucha.ppk@icloud.com 062-479-9836
 */
 
error_reporting(E_ALL);
ini_set("display_errors", 0);

$arrContextOptions = array(
	"ssl"=>array(
	  "verify_peer"=>false,
	  "verify_peer_name"=>false,
	),
);

/* Get QR Code image from Google Chart API
http://code.google.com/apis/chart/infographics/docs/qr_codes.html */

$data = isset($_GET['data']) ? $_GET['data'] : '';
$size = isset($_GET['size']) ? $_GET['size'] : '';
$logo = isset($_GET['logo']) ? $_GET['logo'] : '';
$filename = isset($_GET['filename']) ? $_GET['filename'] : '';

$g_qr = 'https://chart.googleapis.com/chart?cht=qr&chld=H|1&chs='.$size.'&chl='.urlencode($data);

if(empty($logo)){
	$QR = imagecreatefrompng($g_qr);
	imagepng($QR);
}else{
	$size = getimagesize($logo);

	if($size['mime']=="image/gif"){
		$QR = imagecreatefromgif($g_qr);
	}elseif($size['mime']=="image/jpeg"){
		$QR = imagecreatefromjpeg($g_qr);
	}elseif($size['mime']=="image/png"){
		$QR = imagecreatefrompng($g_qr);
	}

	$logo = imagecreatefromstring(file_get_contents($logo, false, stream_context_create($arrContextOptions)));
	$QR_width = imagesx($QR);
	$QR_height = imagesy($QR);

	$logo_width = imagesx($logo);
	$logo_height = imagesy($logo);

	$logo_qr_width = $QR_width/3;
	$scale = $logo_width/$logo_qr_width;
	$logo_qr_height = $logo_height/$scale;

	imagecopyresampled($QR, $logo, $QR_width/3, $QR_height/3, 0, 0, $logo_qr_width, $logo_qr_height, $logo_width, $logo_height);

	if($size['mime']=="image/gif"){
		header("Content-type: image/gif");
	}elseif($size['mime']=="image/jpeg"){
		header("Content-type: image/jpeg");
	}elseif($size['mime']=="image/png"){
		header("Content-type: image/png");
	}

	if($size['mime']=="image/gif"){
		imagegif($QR,"../contents/qrcode/$filename".".gif");
	}elseif($size['mime']=="image/jpeg"){
		imagejpeg($QR,"../contents/qrcode/$filename".".jpg");
	}elseif($size['mime']=="image/png"){
		imagepng($QR,"../contents/qrcode/$filename".".png");
	}
}

imagedestroy($QR);
?>