This repository has been archived by the owner on Apr 9, 2024. It is now read-only.
forked from RobKohr/print.printcoins.com
/
index.php
841 lines (750 loc) · 23.5 KB
/
index.php
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
<?php
require_once('fpdf.php');
require_once('fpdf_extensions.php');
require_once('lib/phpqrcode/qrlib.php');
require_once('utils.php');
$s->design = 'standard';
$s->bill_w = 6.14;
$s->bill_h = 2.61;
if($_REQUEST['design']=='psy_business_card'){
$_REQUEST['card'] = true;
$margin_layout = 'avery 8371';
}
if($_REQUEST['card']){
$s->bill_w = 3.5;
$s->bill_h = 2;
}
if($_REQUEST['design']){
$s->design = $_REQUEST['design'];
design_resize_dimensions($s->design.'.png');
}
$s->draw = 100;//light draw color
$s->l_w = .008;
$s->page_width = 8.5;
$s->page_height = 11;
$s->margin_top = .1;
$s->margin_bottom = .1;
$s->margin_left = .5;
$s->margin_right = .5;
$s->page_usable_width = $s->page_width - ($s->margin_left + $s->margin_right);
$s->page_usable_height = $s->page_height - ($s->margin_bottom + $s->margin_bottom);
$s->bill_pad = 0.2;
$s->shadow=.02;
$s->shadow_c=80;
if(isset($margin_layout)){
if($margin_layout == 'avery 8371'){
$s->margin_top = .5;
$s->margin_bottom = .42;
$s->margin_left = .84;
$s->margin_right = .31;
}
}
//Source (div by 100) http://boardgames.about.com/od/poker/a/chip_denoms.htm
$s->colors = array(
'0.01'=>array(255, 255, 255),
// '0.02'=>array(255, 255, 0),
'0.05'=>array(255, 0, 0),
'0.10'=>array(0, 0, 255),
// '0.20'=>array(127, 127, 127),
'0.25'=>array(0, 255, 0),
'0.50'=>array(255, 165, 0),
'open'=>array(255,217,0),
'1'=>array(0, 0, 0),
'5'=>array(160, 32, 240),
'10'=>array(159, 139, 112),//beaver brown
'20'=>array(173, 216, 230),
'50'=>array(165, 42, 42),
'100'=>array(255, 215, 0)//Gold (not a normal poker chip)
);
$s->icon = 'bitcoin_450x450.png';
$s->crypto = 'IN CRYPTOGRAPHY WE TRUST';
if($_REQUEST['client']=='IBB'){
$s->icon = 'IBBlogo3agreen.png';
$f = 2.5;
$s->icon_w = $f * 807/807;
$s->icon_h = $f * 501/807;
// $s->sample = 1;
$s->crypto = 'Decentralized P2P Digital Currency';
$s->hide_vires = 1;
$s->hide_printcoins = 1;
$s->bottom_message = 'Interest Free Banking In Your Interest';
}
if($_REQUEST['client']=='ronpaul'){
$s->icon = 'ronpaul.png';
$f = 2;
$s->icon_w = $f * 600/840;
$s->icon_h = $f * 840/840;
$s->crypto = 'END THE FED';
$s->hide_vires = 1;
}
$pdf = new PDF('P','in','Letter');
$pdf->SetMargins($s->margin_top, $s->margin_left, $s->margin_right);
$pdf->SetAutoPageBreak(false);
if($_REQUEST['squares']){
squares();
exit;
}
$p_c = $s->page_width/2;
$off_x = $p_c - $s->bill_w/2;
$off_y = 99999999;
if(!$_REQUEST['bills']){
include('form.html');
exit;
}
$bills = str_replace('"', '', $_REQUEST['bills']);
$bills = str_replace('\\', '', $bills);
$bills = explode("\n", $bills);
$printer = $_REQUEST['printer'];
if($printer)
$printer = "Printed By: ".$printer;
$bills = array_slice($bills, 0, 50);//limit number of bills
foreach($bills as $bill){
$off_y +=$s->bill_h;
if($off_y>($s->page_height-$s->bill_h)){
$pdf->AddPage();
$off_y = $s->margin_top;
}
$reverse=$_REQUEST['reverse'];
$pdf->SetXY($off_x, $off_y);
$bill = explode(',', $bill);
$pub = $bill[1];
$priv = $bill[2];
if($bill[3])
$amount = trim($bill[3]);
if(!$amount)
$amount = $_REQUEST['amount'];
if(!$pub)
continue;
if(!$priv)
continue;
bill(array('pub'=>$pub, 'priv'=>$priv, 'printer'=>$printer,
'amount'=>$_REQUEST['amount'], 'reverse'=>$reverse, 'funded_by', $funded_by));
}
$pdf->Output();
function squares(){
$width = .6;
global $s, $pdf;
$pdf->AddPage();
$pdf->SetDrawColor(0,0,0);
for($i = 0; $i<($s->page_width/$width); $i++){
$j =1;
for($j = 0; $j<($s->page_height/$width); $j++){
$x = $i * $width;
$y = $j * $width;
$pdf->Rect($x, $y, $width, $width, 'D');
}
}
$pdf->Output();
}
function bill($params){
global $s, $pdf;
$bill = (object) array_merge(
$params,
array(
'x'=>$pdf->GetX(),
'y'=>$pdf->getY(),
'w'=>$s->bill_w,
'h'=>$s->bill_h,
'shadow_c'=>$s->shadow_c,
'shadow'=>$s->shadow,
'font'=>'Helvetica'
)
);
$bill->s = $s;
$bill->pdf = $pdf;
if($s->design){
$f = 'design_'.$s->design;
if(function_exists($f))
return $f($bill);
}
set_is_card($bill);
bill_init($bill);
bill_reset($bill);
if($bill->reverse){
leave_your_mark($bill);
return;
}
bill_background($bill);
bill_cuts($bill);
color_borders($bill);
bill_denominations($bill);
bitcoin_image($bill);
printer_info($bill);
private_and_public_qr($bill);
if($bill->amount=='open'){
$pdf->SetFont($bill->font,'',7);
quick_text($bill, ' Funding amount',
$bill->y+0.65, 'L');
}
$pdf->SetFont($bill->font,'I',8);
if(!$s->hide_vires){
quick_text($bill, 'Vires in Numeris',
$bill->y + $bill->h - $bill->p, 'C');
}
$pdf->SetFont($bill->font,'',5);
quick_text($bill, 'Version 2012B ', $bill->y+$bill->p-.02, 'R');
bitcoin_cheque_text($bill);
checkmark_funded($bill);
if($s->sample){
show_sample_mark($bill);
}
$pdf->SetFont($bill->font,'B', 10);
$pdf->SetTextColor(73,146,65);
quick_text($bill, $s->bottom_message, $bill->y+ $bill->h - $bill->p - .25, 'C');
if($_REQUEST['client']=='ronpaul'){
ron_paul_details($bill);
}
}
////Helper Functions
function design_leote($bill){
design_leo($bill, 1);
}
// Leonardo design by : BitPay Business Solutions <info@bitpay.com>
// Code modifications by: FLHippy - 1FLH1pPyN5nNxhJUafyd2cUkBwbAaZUNQP
function design_leo($bill, $tamper_evident=0){
global $s, $pdf;
$img = "leo.png";
$bill->w = $s->bill_w;
$bill->h = $s->bill_h;
$pdf->Image($img, $bill->x, $bill->y, $bill->w, $bill->h, 'png');
// Public key QR Code. location is x/y. Size is s
$x = .775; $y = .815; $si = .95;
qr($bill, $bill->pub, $bill->y+$y, 'L', $si, 1, 0, $x);
// Private key QR Code. location is x/y. Size is si
// If you're looking to put tamper evident stickers on your bills. you probably want size .6
if($tamper_evident) {
$x = -.717; $y = .765; $si = .6;
} else {
$x = -.717; $y = .765; $si = .95;
}
qr($bill, $bill->priv, $bill->y+$y, 'R', $si, 1.1, 0, $x);
// Set text color
$pdf->SetTextColor(34, 111, 88);
$pdf->SetFont($bill->font,'',14);
// Print demoninations.
if($bill->amount!='open'){
if(strlen($bill->amount) == 4) {
// Left side demonination.
$x = $bill->x -.045;
$y = $bill->y+$bill->h-.85;
rot_text($bill->amount.' BTC', $x, $y);
// right side demonination.
$y = $bill->y+$bill->h-1.75;
$x = $bill->x + 6.15;
rot_text($bill->amount . ' BTC', $x, $y, -90);
} else if(strlen($bill->amount) == 3) {
// Left side demonination.
$x = $bill->x -.045;
$y = $bill->y+$bill->h-.85;
rot_text($bill->amount.' BTC', $x, $y);
// right side demonination.
$y = $bill->y+$bill->h-1.75;
$x = $bill->x + 6.15;
rot_text($bill->amount . ' BTC', $x, $y, -90);
} else if(strlen($bill->amount) == 2) {
// Left side demonination.
$x = $bill->x -.045;
$y = $bill->y+$bill->h-.95;
rot_text($bill->amount.' BTC', $x, $y);
// right side demonination.
$y = $bill->y+$bill->h-1.65;
$x = $bill->x + 6.15;
rot_text($bill->amount . ' BTC', $x, $y, -90);
} else {
// Left side demonination.
$x = $bill->x -.045;
$y = $bill->y+$bill->h-.98;
rot_text($bill->amount.' BTC', $x, $y);
// right side demonination.
$y = $bill->y+$bill->h-1.63;
$x = $bill->x + 6.15;
rot_text($bill->amount . ' BTC', $x, $y, -90);
}
}
// PUBLIC key (twice).
$pdf->SetFont($bill->font,'',4.8);
$pdf->setXY($bill->x+$bill->w -5.4, $bill->y+$bill->h-2.53);
$pdf->Write(.5,"Bitcoin Address");
$pdf->setXY($bill->x+$bill->w -5.4, $bill->y+$bill->h-2.45);
$pdf->Write(.5,$bill->pub);
// Distributed By Line.
$pdf->SetFont($bill->font,'',8);
$pdf->setXY($bill->x+$bill->w - 1.9, $bill->y+$bill->h-.6);
$pdf->Write(.5,$bill->printer);
}
// Turing bill image by Aristus Bitcoin Printer <carlos@bueno.org>
// Aristus Bitcoin Printer - http://carlos.bueno.org/2012/07/paper-bitcoins.html
// Code modifications by: FLHippy - 1FLH1pPyN5nNxhJUafyd2cUkBwbAaZUNQP
function design_turing($bill){
global $s, $pdf;
$img = "turing.png";
$bill->w = $s->bill_w;
$bill->h = $s->bill_h;
$pdf->Image($img, $bill->x, $bill->y, $bill->w, $bill->h, 'png');
$pdf->Rect($bill->x, $bill->y, $bill->w, $bill->h, 'D');
// Private key QR Code. location is x/y. Size is si
$x = 1.2; $y = 3.44; $si = .6;
rot_qr($bill, $bill->pub, $bill->y+$y, 'L', $si, 1, 0, $x, 45);
// Public key QR Code. location is x/y. Size is s
$x = 1.3; $y = 6.17; $si = .6;
rot_qr($bill, $bill->priv, $bill->y+$y, 'R', $si, 1.1, 0, $x, 45);
// Set text color
$pdf->SetTextColor(0, 0, 0);
// Demonination Line.
$pdf->SetFont($bill->font,'',14);
$pdf->setXY($bill->x+ 2, $bill->y+$bill->h-.85);
if ($bill->amount <= 1) {
$disp=" Bitcoin";
} else {
$disp=" Bitcoins";
}
if($bill->amount!='open'){
shadow_text($bill,$bill->y + .6, $bill->amount . $disp, $bill->color, $bill->shadow_c, $bill->shadow, 'L', +.45);
} else {
shadow_text($bill,$bill->y + .6, "____ " . $disp . "s", $bill->color, $bill->shadow_c, $bill->shadow, 'L', +.35);
}
// PUBLIC key (twice).
$pdf->SetFont($bill->font,'',4.8);
$pdf->setXY($bill->x+ .4, $bill->y+$bill->h-.85);
$pdf->Write(.5,"Bitcoin Address");
$pdf->setXY($bill->x+ .4, $bill->y+$bill->h-.75);
$pdf->Write(.5,$bill->pub);
// Slogan line.
$pdf->SetFont($bill->font,'B',8);
$pdf->setXY($bill->x+$bill->w - 1.54, $bill->y+.36);
$pdf->Write(.5,"Vires In Numeris");
// Distributed By Line.
$pdf->SetFont($bill->font,'',6);
$pdf->setXY($bill->x+$bill->w - 1.85, $bill->y+$bill->h-.75);
$pdf->Write(.5,$bill->printer);
}
function design_psyte($bill){
design_psy($bill, 1);
}
function design_psy($bill, $tamper_evident){
global $s, $pdf;
$img = $s->design . '.png';
$bill->w = $s->bill_w;
$bill->h = $s->bill_h;
$pdf->Image($img, $bill->x, $bill->y, $bill->w, $bill->h, 'png');
$x = .2; $y = .48;
if($tamper_evident) {
qr($bill, $bill->priv, $bill->y+$y, 'L', .6, 1, 0, $x);
} else {
qr($bill, $bill->priv, $bill->y+$y, 'L', .9, 1, 0, $x);
}
$x = -.143; $y = .97;
qr($bill, $bill->pub, $bill->y+$y, 'R', .95, 1.1, 0, $x);
$pdf->SetTextColor(145, 101, 0);
$pdf->SetFont($bill->font,'',5);
$x = $bill->x+.9;
$y = $bill->y+$bill->h-.3;
$line = .1;
if(!$tamper_evident) {
rot_text("Private Key", $x, $y);
rot_text($bill->priv, $x+$line, $y);
}
$y = $y;
$x = $bill->x+$bill->w-2;
rot_text("Public Address", $x, $y);
rot_text($bill->pub, $x+$line, $y);
$pdf->SetTextColor(0, 0, 0);
if($bill->amount!='open'){
$pdf->setXY($bill->x+$bill->w - 2.8, $bill->y+$bill->h-.4);
$pdf->Write(.5, $bill->amount.' Bitcoins');
}
$pdf->SetTextColor(145, 101, 0);
$pdf->SetFont($bill->font,'',10);
$x = .15; $y = 1.38;
$pdf->setXY($bill->x+$x, $bill->y+$y);
$pdf->Write(.5, 'Spend');
$y = $bill->y+$y+.6;
$x = $bill->x+$bill->w-.98;
$pdf->setXY($x, $y);
$pdf->Write(.5, 'Load & Verify');
}
//x, y is would be where the bottom is for the text
function rot_text($text, $x, $y, $degrees=90){
global $pdf;
$pdf->setXY($x, $y);
$pdf->Rotate($degrees, $pdf->getX(), $pdf->getY());
$pdf->Write(1, $text);
$pdf->Rotate(0, $pdf->getX(), $pdf->getY());
}
// Rotates the bill around to print a tilted QR code.
function rot_qr($bill, $contents, $y, $align, $width, $frame_width, $show_frame=true, $nudge_x=0, $degrees=0){
global $pdf;
$pdf->setXY($x, $y);
$pdf->Rotate($degrees, $pdf->getX(), $pdf->getY());
qr($bill, $contents, $y, $align, $width, $frame_width, $show_frame, $nudge_x);
$pdf->Rotate(0, $pdf->getX(), $pdf->getY());
}
function design_resize_dimensions($img){
global $s;
if(!$s->image_size){
$s->image_size = getimagesize($img);
}
//to make a bill fit in your wallet, the height should remain the same
$w = $s->image_size[0];
$h = $s->image_size[1];
$ratio = $w/$h;
$s->bill_w = $s->bill_h * $w/$h;
}
function bitcoin_cheque_text($bill){
global $s, $pdf;
$pdf->SetFont($bill->font,'',8);
if($bill->amount=='open'){
$y = $bill->y+$bill->h-$bill->p - .3;
$pdf->SetFont($bill->font,'B',6);
$pdf->SetTextColor(0);
quick_text($bill, 'Bitcoin Cheque', $y, 'L');
$pdf->SetFont($bill->font,'B',6);
$pdf->SetTextColor(0);
$txt = 'An easy way to give someone bitcoins';
if($_REQUEST['client']=='IBB')
$txt = 'An easy way to give physical bitcoins';
quick_text($bill, $txt, $y+.07, 'L');
}
}
function checkmark_funded($bill){
global $pdf, $s;
$txt = '[_] Checkmark here when bill has been funded.';
quick_text($bill, $txt,
$bill->y + $bill->h - $bill->p, 'R');
$pdf->SetFont('Courier','',8);
quick_text($bill, $s->crypto, $bill->y+$bill->p, 'C');
}
function show_sample_mark($bill){
global $pdf, $s;
$pdf->SetFont('Courier','',18);
quick_text($bill, 'SAMPLE SAMPLE SAMPLE SAMPLE SAMPLE', $bill->y+$bill->h*.2, 'C');
quick_text($bill, 'SAMPLE SAMPLE SAMPLE SAMPLE SAMPLE', $bill->y+$bill->h*.5, 'C');
}
function ron_paul_details($bill){
global $pdf, $s;
$pdf->SetTextColor(0);
$pdf->SetFont($bill->font,'I', 7);
$a = '"A system of capitalism presumes sound money,';
$b = 'not fiat money manipulated by a central bank."';
$lh = .12;
quick_text($bill, $a, $bill->y+ $bill->h - $bill->p - .25, 'C');
quick_text($bill, $b, $bill->y+ $bill->h - $bill->p - .25+$lh, 'C');
$pdf->SetFont($bill->font,'', 7);
quick_text($bill, 'Ron Paul', $bill->y+ $bill->h - $bill->p - .25+$lh*2, 'C');
}
function bill_init($bill){
global $s;
if($bill->pub=='test'){
$bill->amount = $bill->priv;
$bill->priv = 'test';
$bill->priv = 'http://printcoins.com/r/5HueCGU8rMjxEXxiPuD5BDku4MkFqeZyd4dZ1jvhTVqvbTLvyTJ';
$bill->pub = 'Example Public key asdfljasdlfjlasjdflsadjf';
}else{
if(!$bill->amount){
$url = 'http://blockexplorer.com/q/addressbalance/'.$bill->pub;
$bill->amount = get_page($url);
}
}
if($bill->amount=='open'){
//do nothing
}elseif($bill->amount < 1){
$bill->amount = number_format($bill->amount, 2, '.', ',');
}else{
$bill->amount = number_format($bill->amount, 0, '.', ',');
}
$bill->color = $s->colors[$bill->amount];
foreach($bill->color as $key=>$val){
if($val==0)
$bill->color[$key] = 1;//for some reason 0s were causing problem for setFillColor
}
$bill->p = .2;
if($bill->card){
$p = .15;
}
}
function leave_your_mark($bill){
global $pdf;
$size = .6;
$count_w = 5;
$top = $bill->h/2 - $size;
$left = $bill->w/2 - ($size * ($count_w/2));
for($i = 0; $i<5; $i++){
for($j = 0; $j < 2; $j++){
$x = $left + $i*$size + $bill->x;
$y = $top + $j*$size + $bill->y;
$pdf->setXY($x, $y);
$pdf->Rect($x, $y, $size, $size, 'D');
}
}
$pdf->SetFont($bill->font,'',7);
$top = $bill->y + $top;
quick_text($bill, 'Leave Your Mark', $top-.05, 'C');
quick_text($bill, 'Upload photos of well traveled bills to:', $top+($size*2)+.07, 'C');
quick_text($bill, 'www.flickr.com/groups/bitcoin/', $top+($size*2)+.18, 'C');
$link = 'http://www.flickr.com/groups/bitcoin/';
// qr($bill, $link, $top+($size*2)+.16, 'C', .4, .4, false, -$size*1.6);
}
function check_balance($bill){
global $pdf;
$y = $bill->y+.9;
$pdf->SetFont($font,'',5);
quick_text($bill, 'Check balance link ', $y+.10, 'L');
$link = 'http://blockexplorer.com/q/addressbalance/'.$bill->pub;
qr($bill, $link, $y, 'L', .6, 1, false);
}
function priv_block($bill){
global $pdf;
$y = $bill->y+.9;
qr($bill, 'fill', $y, 'R', .6, 1, false);
qr($bill, 'fill', $y, 'L', .6, 1, false);
}
function private_and_public_qr($bill){
global $pdf;
$p = $bill->p;
$y = $bill->y+.6;
$priv_y = $y+.3;
$line_height = .08;
$pdf->SetFont($font,'',5);
quick_text($bill, 'Private Key (Used to transfer coins)', $priv_y-.05, 'L');
qr($bill, $bill->priv, $priv_y, 'L', .6, 1.125);
$size = .8;
$y = $bill->y+.65;
$nudge = 1.2;
$link='http://blockexplorer.com/q/addressbalance/'.$bill->pub;
$size = .6;
quick_text($bill, 'Check Balance at this QR link', $y-$line_height*2, 'R');
quick_text($bill, 'with a smartphone barcode scanner', $y-$line_height, 'R');
qr($bill, $link, $y, 'R', .6, .6);
$y = $bill->y+1.5;
quick_text($bill, "Fund this bill at this public address", $y-$line_height*2, 'R');
quick_text($bill, $bill->pub, $y-$line_height, 'R');
qr($bill, $bill->pub, $y, 'R', $size, $size, 0);
}
function color_borders($bill){
global $pdf;
$pdf->SetFillColor($bill->color[0], $bill->color[1], $bill->color[2]);
$cp = .4;//padding to corners
$t = .06;//thickness
$bp = .05;//padding to edges of bill
$pdf->Rect($bill->x+$cp, $bill->y+$bp, $bill->w-($cp*2), $t, 'F');//top
$pdf->Rect($bill->x+$cp, $bill->y+$bill->h-$t-$bp, $bill->w-($cp*2), $t, 'F');//bottom
$pdf->Rect($bill->x+$bp, $bill->y+$cp, $t, $bill->h-($cp*2), 'F');//left
$pdf->Rect($bill->x + $bill->w - $t - $bp, $bill->y+$cp, $t, $bill->h-($cp*2), 'F');//right
}
function printer_info($bill){
global $pdf, $s;
$p = $bill->p;
$y = $bill->y + $bill->h - $p -.03;
$pdf->SetFont($bill->font,'B',6);
$pdf->SetTextColor(0);
if(!$s->hide_printcoins)
quick_text($bill, "".$bill->printer, $y, 'L');
$pdf->SetFont($bill->font,'',4);
quick_text($bill, 'Convert back to digital bitcoins: http://printcoins.com/redeem', $y+.06);
}
function quick_text($bill, $text, $y, $align='L', $nudge_x=0){
global $pdf;
$x = $bill->x + $bill->p + $nudge_x;
$pdf->SetXY($x, $y);
$width = $bill->w - ($bill->p*2);
$pdf->Cell($width, 0, $text, 0, 0, $align);
}
function qr($bill, $contents, $y, $align, $width, $frame_width, $show_frame=true, $nudge_x=0){
global $pdf;
if(!$frame_width){
$frame_width = $width;
$show_frame = 0;
}
$x = $bill->x + $bill->p;
if($align=='R')
$x = $bill->x + $bill->w - $bill->p - $frame_width;
if($align=='C'){
$x = $bill->x + $bill->w/2 - $frame_width/2;
}
$x = $x+$nudge_x;
$pdf->SetXY($x, $y);
if($show_frame)
$pdf->Cell($frame_width, $frame_width, '', 1);
$qr_p = ($frame_width - $width)/2;
if($contents=='fill'){
$pdf->SetFillColor(0);
$pdf->Rect($x + $qr_p, $y + $qr_p, $width, $width, 'F');
}else{
$pdf->QR($contents, '', $x + $qr_p, $y + $qr_p, $width, $width);
}
}
function bill_denominations($bill){
global $pdf;
$p = $bill->p;
$font_size = 23;
if($bill->card)
$font_size = 18;
$pdf->SetFont('Helvetica','B',$font_size);
$pl = 's';//plaural
if($bill->amount==1)
$pl = '';
$disp = $bill->amount;
if($bill->amount == 'open'){
$disp.=' Bitcoin'.$pl;
$disp = '____ Bitcoins';
$main = $disp;
}else{
$main = $disp.' Bitcoin'.$pl;
}
//top left
shadow_text($bill,
$bill->y+$p + .2,
$main,
$bill->color, $bill->shadow_c, $bill->shadow);
if($bill->amount =='open')
return;
//bottom right
$pdf->SetFont($font,'B',20);
shadow_text($bill,
$bill->y + $bill->h - $p -.18,
$disp.' BTC',
$bill->color, $bill->shadow_c, $bill->shadow,
'R');
//top right
$pdf->SetFont($font,'B',16);
shadow_text($bill,
$bill->y + $p+.12,
$disp,
$bill->color, $bill->shadow_c, $bill->shadow/2,
'R');
//bottom left
$pdf->SetFont($font,'B',16);
shadow_text($bill,
$bill->y + $bill->h - $p -.18,
$disp,
$bill->color, $bill->shadow_c, $bill->shadow*.75,
'L');
$pdf->SetTextColor(0);
}
function shadow_text($bill, $y, $text, $color, $shadow_c, $shadow, $align = 'L', $nudge_x=0){
global $pdf;
$width = $bill->w - ($bill->p*2);
$x = ($bill->x + $bill->p) + $nudge_x;
$pdf->SetTextColor($shadow_c);
$pdf->SetXY($x+$shadow, $y+$shadow);
$pdf->Cell($width, 0, $text, 0, 0, $align);
$pdf->SetTextColor($color);
$pdf->SetXY($x, $y);
$pdf->Cell($width, 0, $text, 0, 0, $align);
}
function bill_reset($bill){
global $s, $pdf;
$pdf->SetLineWidth($s->l_w);
$pdf->SetDrawColor($s->draw);
$pdf->SetFillColor($bill->color);
}
function draw_frame($bill){
bill_reset($bill);
}
function bill_background($bill){
global $pdf;
bill_reset($bill);
$pdf->SetFillColor(
light($bill->color[0]),
light($bill->color[1]),
light($bill->color[2])
);
$inset = -.05;
$pdf->Rect($bill->x+$inset, $bill->y+$inset, $bill->w-$inset*2, $bill->h-$inset*2, 'F');
bill_reset($bill);
}
function bill_cuts($bill){
global $pdf, $s;
bill_reset($bill);
$pdf->SetDrawColor($s->draw);
//top bottom of sheet
$pdf->Line($bill->x, 0, $bill->x, $s->margin_top/2);
$pdf->Line($bill->x+$bill->w, 0, $bill->x+$bill->w, $s->margin_bottom/2);
//bill horz
if($bill->y < 1){
//do first line
$pdf->Line(0, $bill->y, $bill->x-.1, $bill->y);
$pdf->Line($bill->x+ $bill->w + .1, $bill->y, $s->page_width, $bill->y);
}
$pdf->Line(0, $bill->y+$bill->h, $bill->x-.1, $bill->y+$bill->h);
$pdf->Line($bill->x+ $bill->w + .1, $bill->y+$bill->h, $s->page_width, $bill->y+$bill->h);
//bill vert
$y_s = .05;
$pdf->Line($bill->x, $bill->y-$y_s, $bill->x, $bill->y+$y_s);
$pdf->Line($bill->x+$bill->w, $bill->y-$y_s, $bill->x+$bill->w, $bill->y+$y_s);
}
function bill_center_text_amount($bill){
$txt = denomination_to_words($bill->amount);
$pdf->SetXY($bill->x+$s->shadow, $bill->y+$bill->h/2+$s->shadow);
$pdf->SetTextColor($s->shadow_c, $s->shadow_c, $s->shadow_c);
$pdf->Cell($bill->w, 0, $txt ,0, 0, 'C');
$pdf->SetXY($bill->x, $bill->y+$bill->h/2);
$pdf->SetTextColor($color[0], $color[1], $color[2]);
$pdf->Cell($bill->w, 0, $txt ,0, 0, 'C');
}
function bitcoin_image($bill){
global $pdf, $s;
$base = 1.2;//width at 1 btc
$max = 1.8;//100 btc
if($bill->card){
$base = 1.1;
$max = 1.5;
}
if($bill->amount<=1){
$size = $base + ($bill->amount - 1);
}
if($bill->amount>1){
$size = $base + ($max-$base)*(log($bill->amount)/4.6);
}
if($bill->amount=='open')
$size = $base;
$w = $size;
$h = $size;
if($s->icon_w){
$w = $s->icon_w;
$h = $s->icon_h;
}
$x = $bill->x + ($bill->w/2);
$y = $bill->y + ($bill->h/2);
$image =
$pdf->SetFillColor($color[0], $color[1], $color[2]);
$pdf->Image($s->icon,$x-$w/2, $y-$h/2, $w, $h);
}
function set_is_card($bill){
$bill->card = false;
if(((float) $bill->w) < 4){
$bill->card = true;
}
}
function denomination_to_words($amt){
if($amt<1){
return ucwords(int_to_words($amt*100).' Bitcents');
}else{
return ucwords(int_to_words($amt).' Bitcoins');
}
}
function get_page($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
return $output;
}
//make a lighter version of a color
function light($num){
if(is_array($num)){
return array(light($num[0]), light($num[1]), light($num[2]));
}else{
$diff = 255 - $num;
$inc = round($diff*.85);
return $num+$inc;
}
}
//for testing
function pr($var){
echo '<pre>';
print_r($var);
echo '</pre>';
}
?>