Inizializzazione

This commit is contained in:
cmaffio
2015-10-08 11:00:52 +02:00
parent 61949a0cdc
commit 22de29deda
2768 changed files with 254794 additions and 0 deletions

View File

@@ -0,0 +1,75 @@
<?php
require_once "jpgraph/jpgraph.php";
require_once "jpgraph/jpgraph_canvas.php";
require_once "jpgraph/jpgraph_barcode.php";
$params = array(
array('code',1),array('data',''),array('modwidth',1),array('info',false),
array('notext',false),array('checksum',false),array('showframe',false),
array('vertical',false) , array('backend','IMAGE'), array('file',''),
array('scale',1), array('height',70), array('pswidth','') );
$n=count($params);
for($i=0; $i < $n; ++$i ) {
$v = $params[$i][0];
if( empty($_GET[$params[$i][0]]) ) {
$$v = $params[$i][1];
}
else
$$v = $_GET[$params[$i][0]];
}
if( $modwidth < 1 || $modwidth > 5 ) {
echo "<h4>Module width must be between 1 and 5 pixels</h4>";
}
elseif( $data==="" ) {
echo "<h3>Please enter data to be encoded, select symbology and press 'Ok'.</h3>";
echo "<i>Note: Data must be valid for the choosen encoding.</i>";
}
elseif( $code==-1 ) {
echo "<h4>No code symbology selected.</h4>";
}
elseif( $height < 10 || $height > 500 ) {
echo "<h4> Height must be in range [10, 500]</h4>";
}
elseif( $scale < 0.1 || $scale > 15 ) {
echo "<h4> Scale must be in range [0.1, 15]</h4>";
}
else {
if( $code==20 ) {
$encoder = BarcodeFactory::Create(6);
$encoder->UseExtended();
}
else {
$encoder = BarcodeFactory::Create($code);
}
$b = $backend=='EPS' ? 'PS' : $backend;
$b = substr($backend,0,5) == 'IMAGE' ? 'IMAGE' : $b;
$e = BackendFactory::Create($b,$encoder);
if( substr($backend,0,5) == 'IMAGE' ) {
if( substr($backend,5,1) == 'J' )
$e->SetImgFormat('JPEG');
}
if( $e ) {
if( $backend == 'EPS' )
$e->SetEPS();
if( $pswidth!='' )
$modwidth = $pswidth;
$e->SetModuleWidth($modwidth);
$e->AddChecksum($checksum);
$e->NoText($notext);
$e->SetScale($scale);
$e->SetVertical($vertical);
$e->ShowFrame($showframe);
$e->SetHeight($height);
$r = $e->Stroke($data,$file,$info,$info);
if( $r )
echo nl2br(htmlspecialchars($r));
if( $file != '' )
echo "<p>Wrote file $file.";
}
else
echo "<h3>Can't create choosen backend: $backend.</h3>";
}
?>

View File

@@ -0,0 +1,125 @@
<H2>JpGraph Barcode 1.0</h2>
<hr>
</font>
<form name="barcodespec" action="barcode_image.php" target=barcode
method post>
<table cellspacing=4 cellpadding=0>
<tr>
<td colspan=2>
Data:<br>
<input type=text name=data size=25 maxlength=30>
</td>
<tr><td>
Encoding:<br>
<select name=code>
<option selected value=-1> Choose encoding </option>
<option value=4> UPC A </option>
<option value=5> UPC E </option>
<option value=3> EAN 8 </option>
<option value=2> EAN 13 </option>
<option value=1> EAN 128 </option>
<option value=11> Industrial 2 of 5 </option>
<option value=12> Interleaved 2 of 5 </option>
<option value=14> CODE 11 </option>
<option value=6> CODE 39 </option>
<option value=20> CODE 39 Extended </option>
<option value=8> CODE 128 </option>
<option value=13> CODABAR </option>
<option value=10> BOOKLAND (ISBN) </option>
</select>
</td>
<td>
Module width:<br>
<select name=modwidth>
<option value=1> One </option>
<option value=2> Two </option>
<option value=3> Three </option>
<option value=4> Four </option>
<option value=5> Five </option>
</select>
</td>
</tr>
<tr>
<td>
Add checksum:<br>
<input type=checkbox value=1 name=checksum>
</td>
<td>
Hide text:<br>
<input type=checkbox value=1 name=notext>
</td>
</tr>
<tr>
<td>
Show frame:<br>
<input type=checkbox value=1 name=showframe>
</td>
<td>
Vertical layout:<br>
<input type=checkbox value=1 name=vertical>
</td>
</tr>
<tr>
<td>
Height:<br>
<input type=text name=height value="70" size=3 maxlength=3>
</td>
<td>
Scale:<br>
<input type=text name=scale value="1.0" size=4 maxlength=4>
</td>
</tr>
<tr>
<td>
Write to file:<br>
<input type=text name=file size=15 maxlength=80>
</td>
<td>
Format:<br>
<select name=backend>
<option selected value="IMAGEPNG">Image (PNG)</option>
<option value="IMAGEJPG">Image (JPEG)</option>
<option value="PS">Postscript</option>
<option value="EPS">EPS</option>
</select>
</td>
<tr>
<td>
PS module width:
</td>
<td>
<input type=text name=pswidth size=4 maxlength=4><br>
</td>
</tr>
<tr>
<td colspan=2>
<small><i>(If specified will override Module width above)</i></small><br>
</td>
</tr>
<tr>
<td>
Debug info:<br>
<input type=checkbox value=1 name=info>
</td>
<td align=right valign=bottom>
<br>
<input type=submit name=submit value="&nbsp; Create &nbsp;" style="font-weight:bold;">
</td>
</tr></table>
</form>
<p>
<hr>

View File

@@ -0,0 +1,10 @@
<!doctype html public "-//W3C//DTD HTML 4.0 Frameset//EN">
<HTML><HEAD>
<LINK REL=STYLESHEET TYPE="text/css" HREF="de_normal.css">
<title>Barcode SYSTEMTEST</title>
</head>
<frameset cols="280,*">
<frame src=barcode_menu.php name=menu>;
<frame src=barcode_image.php name=barcode>
</frameset>
</html>

View File

@@ -0,0 +1,16 @@
<?php
// ==============================================
// Output Image using Code 39 using only default values
// ==============================================
require_once ('jpgraph/jpgraph_barcode.php');
try {
$encoder = BarcodeFactory::Create(ENCODING_CODE39);
$e = BackendFactory::Create(BACKEND_IMAGE,$encoder);
$e->Stroke('abc123');
} catch( JpGraphException $e ) {
//echo 'Error: ' . $e->getMessage()."\n";
JpGraphError::Raise($e->getMessage());
}
?>

View File

@@ -0,0 +1,11 @@
<?php
// ==============================================
// Output Image using Code 39 using only default values
// ==============================================
require_once ('jpgraph/jpgraph_barcode.php');
$encoder = BarcodeFactory::Create(ENCODING_CODE39);
$e = BackendFactory::Create(BACKEND_IMAGE,$encoder);
$e->Stroke('ABC123');
?>

View File

@@ -0,0 +1,14 @@
<?php
// ==============================================
// Output Image using Code 128
// ==============================================
require_once ('jpgraph/jpgraph_barcode.php');
$encoder = BarcodeFactory::Create(ENCODING_CODE128);
$e = BackendFactory::Create(BACKEND_PS,$encoder);
$e->SetModuleWidth(2);
$e->SetHeight(20);
echo nl2br($e->Stroke('3125134772'));
?>

View File

@@ -0,0 +1,14 @@
<?php
// ==============================================
// Output Postscript of nterleaved 2 of 5
// ==============================================
require_once ('jpgraph/jpgraph_barcode.php');
$encoder = BarcodeFactory::Create(ENCODING_CODEI25);
$e = BackendFactory::Create(BACKEND_PS,$encoder);
$e->SetModuleWidth(2);
$e->SetHeight(70);
$ps = $e->Stroke('3125134772');
echo nl2br(htmlspecialchars($ps));
?>

View File

@@ -0,0 +1,17 @@
<?php
// ==============================================
// Output Encapsulated Postscript of interleaved 2 of 5
// ==============================================
require_once ('jpgraph/jpgraph_barcode.php');
echo "Start ...<br>";
$encoder = BarcodeFactory::Create(ENCODING_CODEI25);
$e = BackendFactory::Create(BACKEND_PS,$encoder);
$e->SetModuleWidth(2);
$e->SetHeight(70);
$e->SetEPS();
$ps = $e->Stroke('3125134772');
echo nl2br(htmlspecialchars($ps));
?>

View File

@@ -0,0 +1,12 @@
<?php
// ==============================================
// Output Image using Code Interleaved 2 of 5
// ==============================================
require_once ('jpgraph/jpgraph_barcode.php');
$encoder = BarcodeFactory::Create(ENCODING_CODEI25);
$e = BackendFactory::Create(BACKEND_IMAGE,$encoder);
$e->SetModuleWidth(2);
$e->Stroke('1234');
?>

View File

@@ -0,0 +1,74 @@
<?php
// =======================================================
// Example of how to format US Postal shipping information
// =======================================================
require_once ('jpgraph/jpgraph_barcode.php');
// The Full barcode standard is described in
// http://www.usps.com/cpim/ftp/pubs/pub91/91c4.html#508hdr1
//
// The data start with AI=420 which means
// "Ship to/Deliver To Postal Code (within single authority)
//
class USPS_Confirmation {
function USPS_Confirmation() {
}
// Private utility function
function _USPS_chkd($aData) {
$n = strlen($aData);
// Add all even numbers starting from position 1 from the end
$et = 0 ;
for( $i=1; $i <= $n; $i+=2 ) {
$d = intval(substr($aData,-$i,1));
$et += $d;
}
// Add all odd numbers starting from position 2 from the end
$ot = 0 ;
for( $i=2; $i <= $n; $i+=2 ) {
$d = intval(substr($aData,-$i,1));
$ot += $d;
}
$tot = 3*$et + $ot;
$chkdigit = (10 - ($tot % 10))%10;;
return $chkdigit;
}
// Get type 1 of confirmation code (with ZIP)
function GetPICwithZIP($aZIP,$aServiceType,$aDUNS,$aSeqNbr) {
// Convert to USPS format with AI=420 and extension starting with AI=91
$data = '420'. $aZIP . '91' . $aServiceType . $aDUNS . $aSeqNbr;
// Only calculate the checkdigit from the AI=91 and forward
// and do not include the ~1 (FUNC1) in the calculation
$cd = $this->_USPS_chkd(substr($data,8));
$data = '420'. $aZIP . '~191' . $aServiceType . $aDUNS . $aSeqNbr;
return $data . $cd;
}
// Get type 2 of confirmation code (without ZIP)
function GetPIC($aServiceType,$aDUNS,$aSeqNbr) {
// Convert to USPS format with AI=91
$data = '91' . $aServiceType . $aDUNS . $aSeqNbr;
$cd = $this->_USPS_chkd($data);
return $data . $cd;
}
}
$usps = new USPS_Confirmation();
$zip = '92663';
$service = '21';
$DUNS = '805213907';
$seqnr = '04508735';
$data = $usps->GetPICwithZIP($zip,$service,$DUNS,$seqnr);
//$data = $usps->GetPIC('01','123456789','00000001');
$encoder = BarcodeFactory::Create(ENCODING_EAN128);
$e = BackendFactory::Create(BACKEND_IMAGE,$encoder);
$e->SetModuleWidth(2);
$e->SetFont(FF_ARIAL,FS_NORMAL,14);
$e->Stroke($data);
?>

View File

@@ -0,0 +1,281 @@
<?php
require_once('jpgraph/jpgraph_barcode.php');
/*=======================================================================
// File: MKBARCODE.PHP
// Description: Comman line tool to generate linear barcodes
// Created: 2009-06-20
// Ver: $Id: mkbarcode.php 1455 2009-07-03 18:52:25Z ljp $
//
// Copyright (c) Asial Corporation. All rights reserved.
//=======================================================================
*/
//----------------------------------------------------------------------
// CLASS ParseArgs
// Parse command line arguments and make sanity checks
//----------------------------------------------------------------------
class ParseArgs {
var $argc,$argv;
function ParseArgs() {
// Get command line argument
$this->argv = ($_SERVER['argv']);
$this->argc = ($_SERVER['argc']);
}
function PrintUsage() {
$n = $this->argv[0];
echo "$n -b <symbology> [-r -h -c -o <output format> -m <width> -s <scale> -y <height> -f <filename> ] datastring \n".
"Create the specified barcode\n".
"-b What symbology to use, one of the following strings (case insensitive)\n".
" UPCA \n".
" UPCE \n".
" EAN128 \n".
" EAN13 \n".
" EAN8 \n".
" CODE11 \n".
" CODE39 \n".
" CODE128 \n".
" CODE25 \n".
" CODEI25 \n".
" CODABAR \n".
" BOOKLAND \n".
"-c Add checkdigit for symbologies where this is optional\n".
"-o Output format. 0=Image, 1=PS, 2=EPS\n".
"-m Module width\n".
"-s Scale factor\n".
"-h Show this help\n".
"-f Filename to write to\n".
"-r Rotate barcode 90 degrees\n".
"-y height Set height in pixels\n".
"-x Hide the human readable text\n".
"--silent Silent. Don't give any error mesages\n";
exit(1);
}
function Get() {
$barcode='code39';
$hide=false;
$checkdigit=false;
$modulewidth=2;
$scale=1;
$output=0;
$filename='';
$data = '';
$rotate = false;
$silent=false;
$height = 70;
if( ($n=$this->GetNum()) > 0 ) {
$i=1;
while( $i <= $n ) {
switch( $this->argv[$i] ) {
case '-h':
$this->PrintUsage();
exit(0);
break;
case '-b':
$barcode = $this->argv[++$i];
break;
case '-o':
$output = (int)$this->argv[++$i];
break;
case '-y':
$height = (int)$this->argv[++$i];
break;
case '-x':
$hide=true;
break;
case '-r':
$rotate=true;
break;
case '-c':
$checkdigit=true;
break;
case '--silent':
$silent=true;
break;
case '-s':
$scale = (float)$this->argv[++$i];
break;
case '-m':
$modulewidth = (float)$this->argv[++$i];
break;
case '-f':
$filename = $this->argv[++$i];
break;
default:
if( $data == '' ) {
$data = $this->argv[$i];
}
else {
$this->PrintUsage();
die("Illegal specified parameters");
}
break;
}
++$i;
}
}
if( $output < 0 || $output > 2 ) {
fwrite(STDERR,"Unkown output format ($output)\n");
exit(1);
}
if( $output === 0 ) {
$modulewidth = floor($modulewidth);
}
// Sanity check
if( $modulewidth > 15 ) {
fwrite(STDERR,"Too large modulewidth\n");
exit(1);
}
// Sanity check
if( $height > 1000 ) {
fwrite(STDERR,"Too large height\n");
exit(1);
}
// Sanity check
if( $scale > 15 ) {
fwrite(STDERR,"Too large scale factor\n");
exit(1);
}
if( strlen($filename) > 256 ) {
fwrite(STDERR,"Too long filename\n");
exit(1);
}
if( trim($data) == '' ) {
fwrite(STDERR,"No input data specified\n");
exit(1);
}
$barcodes = array(
'UPCA' => ENCODING_UPCA,
'UPCE' => ENCODING_UPCE,
'EAN128' => ENCODING_EAN128,
'EAN13' => ENCODING_EAN13,
'EAN8' => ENCODING_EAN8,
'CODE11' => ENCODING_CODE11,
'CODE39' => ENCODING_CODE39,
'CODE128' => ENCODING_CODE128,
'CODE25' => ENCODING_CODE25,
'CODEI25' => ENCODING_CODEI25,
'CODABAR' => ENCODING_CODABAR,
'BOOKLAND' => ENCODING_BOOKLAND,
);
$barcode = strtoupper($barcode);
if( key_exists($barcode,$barcodes) ) {
$barcode = $barcodes[$barcode];
}
else {
fwrite(STDERR,'Specified barcode symbology ('.$barcode.") is not supported\n");
exit(1);
}
$ret = array(
'barcode' => $barcode,
'hide' => $hide,
'modulewidth' => $modulewidth,
'scale' => $scale,
'output' => $output,
'data' => $data,
'silent' => $silent,
'rotate' => $rotate,
'height' => $height,
'checkdigit' => $checkdigit,
'filename' => $filename
);
return $ret;
}
function _Dump() {
var_dump($this->argv);
}
function GetNum() {
return $this->argc-1;
}
}
//----------------------------------------------------------------------
// CLASS Driver
// Main driver class to create barcodes with the parmeters specified on
// the command line.
//----------------------------------------------------------------------
class Driver {
private $iParams;
static public $silent=false;
static public function ErrHandlerPS(Exception $e) {
if( !Driver::$silent )
fwrite(STDERR,$e->getMessage()."\n");
exit(1);
}
static public function ErrHandlerImg(Exception $e) {
if( !Driver::$silent )
fwrite(STDERR,$e->getMessage()."\n");
$errobj = new JpGraphErrObjectImg();
$errobj->Raise($e->getMessage());
exit(1);
}
function Run($aParams) {
$this->iParams = $aParams;
Driver::$silent = $aParams['silent'];
$encoder = BarcodeFactory::Create($aParams['barcode']);
$encoder->AddChecksum($aParams['checkdigit']);
switch( $aParams['output'] ) {
case 0:
$e = BackendFactory::Create(BACKEND_IMAGE,$encoder);
set_exception_handler(array('Driver','ErrHandlerImg'));
break;
case 1:
$e = BackendFactory::Create(BACKEND_PS,$encoder);
set_exception_handler(array('Driver','ErrHandlerPS'));
break;
case 2:
$e = BackendFactory::Create(BACKEND_PS,$encoder);
$e->SetEPS();
set_exception_handler(array('Driver','ErrHandlerPS'));
break;
}
$e->SetHeight($aParams['height']);
$e->SetVertical($aParams['rotate']);
$e->SetModuleWidth($aParams['modulewidth']);
$e->SetScale($aParams['scale']);
$e->HideText($aParams['hide']);
if( $aParams['output'] === 0 ) {
$err = $e->Stroke($aParams['data'], $aParams['filename']);
}
else {
$s = $e->Stroke($aParams['data'], $aParams['filename']);
if( $aParams['filename'] == '' ) {
// If no filename specified then return the generated postscript
echo $s;
}
}
}
}
$pa = new ParseArgs();
$params = $pa->Get();
$driver = new Driver();
$driver->Run($params);
// Successfull termination
exit(0);
?>