Esempio n. 1
0
<?php

/**
 * @author Matthew McNaney <mcnaney at gmail dot com>
 */
if (isset($_GET['id']) && isset($_GET['size'])) {
    $qr = new QR($_GET['id'], $_GET['size']);
    echo $qr->get();
    exit;
} else {
    PHPWS_Core::errorPage('404');
}
Esempio n. 2
0
 private function format()
 {
     //Build format string
     $f = $this->mask + ($this->ecc << 3);
     $f = QR::bits(QR::crc($f, 1335) + ($f << 10) ^ 21522, 15);
     $this->place(substr($f, 7, 8), 8, $this->dim - 8, 8);
     $this->place(strrev(substr($f, 0, 7)), 1, 8, $this->dim - 7);
     $this->place(strrev(substr($f, 9, 6)), 1, 8, 0);
     $this->place(strrev(substr($f, 7, 2)), 1, 8, 7);
     $this->place(substr($f, 6, 1), 1, 7, 8);
     $this->place(substr($f, 0, 6), 6, 0, 8);
     //Build version string
     if ($this->vers > 5) {
         $v = $this->vers + 1;
         $v = strrev(QR::bits(QR::crc($v, 7973) + ($v << 12), 18));
         $this->place($v, 3, $this->dim - 11, 0);
         $this->place(QR::transpose($v, 3), 6, 0, $this->dim - 11);
     }
 }
Esempio n. 3
0
<?php

include "qr.php";
$qr = new QR(array(data => './data', images => './image'));
$qr->encode(array('d' => 'http://upcoming.org/event/155488/', 'path' => '/home/asc/papers/dwim/img/qr.jpg'));
Esempio n. 4
0
<?php

/**
 * @author Matthew McNaney <mcnaney at gmail dot com>
 */
if (Current_User::isLogged()) {
    $key = Key::getCurrent(true);
    if ($key) {
        $qr_func = function ($key_id, $size) {
            $qr = new QR($key_id);
            $qr->setSize($size);
            $image = $qr->get();
            return '<a download="QR-image.png" href="' . $qr->image . '">' . $qr->get() . '</a>';
        };
        $tpl_vars['small'] = $qr_func($key->id, 5);
        $tpl_vars['medium'] = $qr_func($key->id, 6);
        $tpl_vars['large'] = $qr_func($key->id, 8);
        $tpl_vars['xlarge'] = $qr_func($key->id, 12);
        $tpl = new \Template($tpl_vars);
        $tpl->setModuleTemplate('qr', 'modal.html');
        $content = $tpl->get();
        $modal = new Modal('qr-modal', $content, 'QR Codes (click to download)');
        $modal->sizeLarge();
        Layout::add($modal->get());
        MiniAdmin::add('qr', '<a data-toggle="modal" data-target="#qr-modal" class="pointer">Show QR codes</a>');
    }
}
Esempio n. 5
0
 function generate_qrcode($text)
 {
     $qr_args = array('data' => QR . "data", 'images' => QR . "image");
     $enc = md5($text);
     $qr_img_black = tempnam("/tmp", time()) . "qr-{$enc}.png";
     $qr = new QR($qr_args);
     $args = array('d' => $text, 'path' => $qr_img_black);
     $qr->encode($args);
     $im_black = imagecreatefrompng($qr_img_black);
     imagecolorset($im_black, 1, 126, 126, 126);
     imagepng($im_black, $qr_img_black);
     return $qr_img_black;
 }
Esempio n. 6
0
require_once 'app_code/zipcode.class.php';
require_once 'app_code/class.Event_Contacts.php';
require_once 'class/class.local_calendar.php';
ob_end_clean();
$casecreation = new case_creation();
$case = $_REQUEST['case_id'];
$data = $casecreation->get_case_data($case);
$use_data = array();
$use_data['case_id'] = $data['case_id'];
//$use_data['company_name'] = $data['company_name'];
//ini_set('display_errors' , 1 );
$font = "freefont/FreeSansBold.ttf";
//header('Content-Type: image/gif');
require_once 'class/class.qrcode.php';
require_once 'class/class.print.php';
$qr = new QR(json_encode($use_data));
$image = $qr->image();
$qrsize = 140;
$img2 = imagecreatefromstring($image);
$img = imagecreatetruecolor($qrsize, $qrsize);
imagecopyresized($img, $img2, 0, 0, 0, 0, $qrsize, $qrsize, imagesx($img2), imagesy($img2));
$width = 420;
$height = 130;
$im = imagecreatetruecolor($width, $height);
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, (int) $width - 1, (int) $height - 1, $white);
imagecopymerge($im, $img, 0, 0, 0, 0, $height, $height, 100);
// Create some colors
//imagettftext($im, 12, 0, 150 , , $grey, $font, $order);
Esempio n. 7
0
<?php

namespace tatt;
require_once 'tatt/webcommon.php';
$page->load_javascript_include("items/item.js");

//This file displays an individual item
//TODO Check item exists in database.
if(!isset($_GET['id']) || !is_numeric($_GET['id'])){
	redirect_to_url('/'); //Send to homepage.
} else {
	$item_id = (int)$_GET['id'];
}

$item = new Item($item_id);
QR::item($item_id);

$valid_actions = array('delete', 'checkout', 'return');
if(isset($_GET['action']) && in_array($_GET['action'], $valid_actions)){
	$auth->require_login();
	$action = $_GET['action'];
	if( $action == 'delete' && $item->get_owner_id() == $user_id ){
		Item::delete($item_id);
		redirect_to_url('/items/view_items.php?u=' . $user_id);
	}
	//TODO: May want to add check if item is available to be checked out
	else if( $action == 'checkout' ){
		Item::checkout_by_ids($item_id, $user_id);
		redirect_to_url('/items/view_items.php?u=' . $user_id);
	}
	else if( $action == 'return' ){
Esempio n. 8
0
 /**
  * Output a QR Code image
  *
  * @since 3.1
  */
 public function onAjax_renderQRCode()
 {
     $app = JFactory::getApplication();
     $input = $app->input;
     $this->setId($input->getInt('element_id'));
     $this->loadMeForAjax();
     $this->getElement();
     $params = $this->getParams();
     $lang = JFactory::getLanguage();
     $lang->load('com_fabrik.plg.element.field', JPATH_ADMINISTRATOR);
     if (!$this->canView()) {
         $app->enqueueMessage(JText::_('PLG_ELEMENT_FIELD_NO_PERMISSION'));
         $app->redirect($url);
         exit;
     }
     $rowid = $input->get('rowid', '', 'string');
     if (empty($rowid)) {
         $app->enqueueMessage(JText::_('PLG_ELEMENT_FIELD_NO_SUCH_FILE'));
         $app->redirect($url);
         exit;
     }
     $repeatcount = $input->getInt('repeatcount', 0);
     $listModel = $this->getListModel();
     $row = $listModel->getRow($rowid, false);
     if (empty($row)) {
         $app->enqueueMessage(JText::_('PLG_ELEMENT_FIELD_NO_SUCH_FILE'));
         $app->redirect($url);
         exit;
     }
     $elName = $this->getFullName(true, false);
     $value = $row->{$elName};
     require JPATH_SITE . '/components/com_fabrik/libs/qrcode/qrcode.php';
     // Usage: $a=new QR('234DSKJFH23YDFKJHaS');$a->image(4);
     $qr = new QR($value);
     $img = $qr->image(4);
     if (!empty($img)) {
         // Some time in the past
         header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
         header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
         header("Cache-Control: no-store, no-cache, must-revalidate");
         header("Cache-Control: post-check=0, pre-check=0", false);
         header("Pragma: no-cache");
         header('Accept-Ranges: bytes');
         header('Content-Length: ' . strlen($img));
         header('Content-Type: ' . 'image/gif');
         // Serve up the file
         echo $img;
         // And we're done.
         exit;
     } else {
         $app->enqueueMessage(JText::_('PLG_ELEMENT_FIELD_NO_SUCH_FILE'));
         $app->redirect($url);
         exit;
     }
 }
Esempio n. 9
0
<?php

include_once "QR.php";
$text = "http://m.flickr.com/search/?q=filtr%3Aprocess%3Dheathr&st=rec";
$path = "/home/asc/Desktop/qr.jpg";
$qr = new QR(array('data' => dirname(__FILE__) . '/data', 'images' => dirname(__FILE__) . '/image'));
$qr->encode(array('d' => $text, 'path' => $path));
Esempio n. 10
0
 public function anggota($id)
 {
     // data sekolah
     $sekolah = Sekolah::data();
     $logo_sekolah = $sekolah->logo ?: 'blank.png';
     $nama_sekolah = $sekolah->nama;
     $alamat_sekolah = $sekolah->alamat;
     // data siswa
     $siswa = Siswa::set($id);
     $foto_siswa = $siswa->foto ?: 'blank.png';
     $nis_siswa = $siswa->nis;
     $nama_siswa = $siswa->nama;
     $kelas_siswa = $siswa->kelas;
     $telp_siswa = $siswa->telp ?: '-';
     $alamat_siswa = $siswa->alamat ?: '-';
     // path font
     $helvetica = public_path() . '/font/helvetica.ttf';
     $calibri = public_path() . '/font/calibri.ttf';
     // canvas
     $canvas = Image::canvas(325, 205);
     // logo sekolah
     $logo = Image::make(public_path() . '/foto/sekolah/' . $logo_sekolah)->resize(null, 38, true);
     $canvas->insert($logo, 5, 5, 'top-left');
     // header nama
     $header_nama = imagettfbbox(10, 0, $helvetica, $nama_sekolah);
     $lebar_header_nama = abs($header_nama[2] - $header_nama[0]);
     $canvas->text($nama_sekolah, 350 / 2 - $lebar_header_nama / 2, 15, 10, '333', 0, $helvetica);
     // nama kartu
     $nama_kartu = imagettfbbox(10, 0, $helvetica, 'KARTU ANGGOTA PERPUSTAKAAN');
     $lebar_nama_kartu = abs($nama_kartu[2] - $nama_kartu[0]);
     $canvas->text('KARTU ANGGOTA PERPUSTAKAAN', 350 / 2 - $lebar_nama_kartu / 2, 30, 10, '333', 0, $helvetica);
     // header alamat
     $header_alamat = imagettfbbox(8, 0, $calibri, $alamat_sekolah);
     $lebar_header_alamat = abs($header_alamat[2] - $header_alamat[0]);
     $canvas->text($alamat_sekolah, 350 / 2 - $lebar_header_alamat / 2, 42, 8, '000', 0, $calibri);
     // garis
     $canvas->line('333', 5, 46, 315, 46);
     // nis
     $canvas->text('N I S', 5, 60, 8, '000', 0, $calibri);
     $canvas->text(': ' . $nis_siswa, 40, 60, 8, '000', 0, $calibri);
     // nama
     $canvas->text('Nama', 5, 73, 8, '000', 0, $calibri);
     $canvas->text(': ' . $nama_siswa, 40, 73, 8, '000', 0, $calibri);
     // kelas
     $canvas->text('Kelas', 5, 86, 8, '000', 0, $calibri);
     $canvas->text(': ' . $kelas_siswa, 40, 86, 8, '000', 0, $calibri);
     // telp
     $canvas->text('Telp', 5, 99, 8, '000', 0, $calibri);
     $canvas->text(': ' . $telp_siswa, 40, 99, 8, '000', 0, $calibri);
     // alamat
     $canvas->text('Alamat', 5, 112, 8, '000', 0, $calibri);
     $canvas->text(': ' . $alamat_siswa, 40, 112, 8, '000', 0, $calibri);
     // foto
     $foto = Image::make(public_path() . '/foto/siswa/' . $foto_siswa)->resize(null, 80, true);
     $canvas->insert($foto, 5, 5, 'bottom-left');
     // qrcode
     $path_qr = public_path() . '/qrcode/' . $siswa->nis . '.png';
     // belum ada qrcode
     if (!File::exists($path_qr)) {
         $qr = new QR();
         $qr->setText($nama_siswa);
         $qr->setSize(80);
         $qr->setPadding(0);
         $qr->save($path_qr);
         $qr_code = $path_qr;
         // ada qrcode
     } else {
         $qr_code = Image::make($path_qr)->resize(null, 80, true);
     }
     $canvas->insert($qr_code, 5, 5, 'bottom-right');
     // simpan
     $canvas->save(public_path() . '/anggota/' . $nis_siswa . '.png', 100);
     // gambar
     $gambar = asset('anggota/' . $nis_siswa . '.png');
     return View::make('modal.anggota', compact('siswa', 'gambar'));
 }