Merge branch 'bug-1459' into release (Emergency bugfix)
[cacert-devel.git] / www / coapnew.php
1 <?php
2 /*
3 LibreSSL - CAcert web application
4 Copyright (C) 2004-2008 CAcert Inc.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; version 2 of the License.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20 // $Id: coapnew.php,v 1.5 2015/01/08 15:02:41 wytze Exp $
21 define('REV', '$Revision: 1.5 $');
22
23 /*
24 ** Created from old cap.php 2003, which used the now obsoleted ftpdf package
25 ** First created: 12 July 2008
26 ** Last change: see Revision date
27 ** Reviews:
28 ** printed text by Ian Grigg and Teus Hagen (July 2008)
29 ** layout/design by Teus Hagen and Johan Vromans (July 2008)
30 ** coding by Teus Hagen and ...
31 **
32 ** Installation:
33 ** std PHP lib:
34 ** recode_string(), zcompress() (PHP-ZLIB) only used if present
35 ** zcompress (pdf compression) gives performance loss, disable it?
36 ** PDF generation package (tcpdf/tcpdf.php):
37 ** TCPDF package + define the TCPDF_DIR install directory (GPL)
38 ** tcpdf package is patched for text subtypes see tcpdf diff file.
39 ** Add free embedding zapfdingbat font
40 ** ttf2pt1 -F zapfdinbats.ttf -> zapfdingbats.utf metrics file
41 ** php -q makefont.php zapfsdingbats.ttf zapfdingbats.utf -> .php,.ctg.z,.z
42 ** install files: zapfdingbats.{php,z,ctg.z} in tcpdf/fonts dir
43 ** UTF8 package for unicode (utf8/native/core.php):
44 ** utf8_substr() only when package is found and needs to be used
45 ** transliteration (and abbreviation):
46 ** if full name has non-ascii char(s) try to use: utf8_to_ascii()
47 ** First from transtab.php package which is Markus Kuhn compliant
48 ** transtab.php is CAcert php package.
49 ** Transtab depends on on its turn on UTF8 package.
50 ** Secondly if not found utf8ascii lib tried (artistic license)
51 ** http://sourceforge.net/projects/phputf8
52 ** .../utf8_to_ascii-0.3.tar.gz
53 ** see UTF8_ASCII definition for location requirements
54 ** Thirdly: if not found transliteration feature is disabled.
55 **
56 ** policy documents for pdf inclusion:
57 ** define CCA file (default policy)
58 ** LOGO: CAcert logo logos directory is LOGO
59 **
60 ** Functionality:
61 ** Test: use environment variable settings as parameters for
62 ** Organisation: name, dba's, director, sign date, trade license ID
63 ** address, country/state jurisdiction, domain(s)
64 ** o-admins: name, email, phone
65 ** Registry: name, region
66 ** Assurer: name, email, sign date
67 **
68 ** Form fields: javascript form fields with fields for printout and change
69 ** Printout: printed, and completed for final signatures
70 ** On transliteration and abbreviation of a name:
71 ** if shoes a std way show accepted conversion as pdf comment
72 ** Orientation: on landscape (dflt) print 2-up
73 ** PDF URL links are used to web, wiki, and faq for more info search
74 ** Only on non-ascii chars in a name the utf8 routines are loaded
75 ** PDF reader has wiki info url's and easy email feedback
76 ** ENABLED:
77 ** included is the CCA generates 2 extra pages (needs work to limit vert spacing)
78 **
79 ** For other re-use of some routines:
80 ** abbreviate() abbreviate a name on std way
81 ** transliterate() provide name in translated format in std way
82 **
83 ** For tests:
84 ** environment settings (FORM, FORMAT, CCA, ...) define used test data
85 ** In test modus variable path_url from tcpdf package unset warnings
86 ** Set for operation modus TEST on false (or comment code out)
87 **
88 ** Future:
89 ** digitally sign form and process it via network
90 **
91 ** unicode and UTF-8 support:
92 ** php4/5 recode() is alias of recode_string() of PHP library
93 ** If not provided: should check every string is transcoded?
94 ** recode(), recode_string(0 is said to have too many (japanese) defeats
95 ** recode_string() is only used on GET[] input (html->utf-8),
96 ** UTF-8 use routines from http://www.sourceforge.net/projects/phputf8
97 ** which replaces php recode() package.
98 ** on many places own utf-8 handling code exists and is loaded (tcpdf problem)
99 ** _() translation routine. The returned HTML string is translated to utf-8 string.
100 ** the GET() routines expects utf-8 code (see test defs) but might be changed
101 ** to use html entity conversion routine of PHP (5.2 has a problem...).
102 **
103 ** PDF compression zlib: (now disabled)
104 ** if PHP lib zcompress() is present, generated PDF is compressed
105 **
106 ** FONTS future use ? http://www.slovo.info/unifonts.htm? (not used now)
107 ** or Bitstream Cyberbit http://www.orwell.ru/download/cyberbit.zip
108 ** Latter font is no longer for free download
109 ** For now: FreeVeraSans is used now and embedded (std in TCPDF package)
110 ** Zapf Dingbats font: some Open Source readers have bad font handling or
111 ** no zapfdingbat font. So one is embedded
112 ** To be generated with tooling in util directory.
113 **
114 ** TO DO, to CHECK and KNOWN PROBLEMS:
115 ** _() translation routine returns recoded and checks UTF-8 chars?
116 ** Japanse package (maybe not needed with TCPDF?)
117 ** CCA informal should be on one page (no CCA printed yet)
118 ** form field checks, print button (Java script)
119 ** data structs in Java script and globalize property settings
120 ** XML
121 ** timestamping, signatures and certificate usage
122 ** list of recipients, encrypt the document and send it off
123 ** On Acrobat 7.0: first form field call error (have work around)
124 ** eps problem with logo (no eps logo yet)
125 ** multi selection of ID types in form fields (value editable now)
126 ** ugly capital char use in intro to bold or italic lowercase
127 ** tables over page boundaries do not fully work yet
128 **
129 ** DEPENDENCIES:
130 ** This PDF GENERATION package relies on the PHP PDF generation
131 ** package of TCPDF source force project:
132 ** http://sourceforge.net/projects/tcpdf/ V 4.0.007 18th July 2008
133 ** The tcpdf software supports encryption, signatures, and form fields
134 ** TCPDF is using URF-8 code (good!)
135 ** The TRANSLITERATE code tables db (utf8ascii) is not compliant (!?) with
136 ** Markus Kuhn <http://www.cl.cam.ac.uk/~mgk25/> -- 2001-09-02
137 ** First is tried to use Markus his tables
138 ** For a test file with all chars see there (it is also in tcpdf package).
139 ** Both transliteration packages rely on UTF-8 code, only loaded when available and
140 ** when really needed.
141 ** PDF generation: The alternative is the one from the std PHP library.
142 **
143 ** SECURITY:
144 ** PHP libs: packages seems to download files on the fly into local filesystem!!!
145 **
146 ** All sizes (in mm) is related to A5 base, so other page formats are scaled.
147 **
148 ** Parameters (API):
149 ** $_GET['date'] date of assurance and signature applicant organisation
150 ** $_GET['name'] full name assuree default empty for upward compatibility
151 ** $_GET['dba<1-9>'] etc. %d = 1-9 trade names
152 ** $_GET['address'] postal address department, office, street, zip, city
153 ** $_GET['state'] jurisdiction
154 ** $_GET['country'] jurisdiction address
155 ** $_GET['type'] type of organisation: e.g. foundation, partnership, Lmtd
156 ** $_GET['domain<0..n>'] domain names of organisation
157 ** $_GET['director'] can sign for the organisation
158 ** $_GET['email'] email address for organisation contact
159 ** $_GET['phone'] organisation phone number for contact
160 ** $_GET['admin'] o-admin name
161 ** $_GET['adminemail'] o-admin emailo address
162 ** $_GET['adminphone'] o-admin phone number
163 ** $_GET['admin<1-9>'] o-admin name
164 ** $_GET['admin<1-9>email'] o-admin emailo address
165 ** $_GET['admin<1-9>phone'] o-admin phone number
166 ** $_GET['identity'] trade office license Identification number
167 ** $_GET['tor'] trade office name
168 //** $_GET['tordate'] trade office extract date (depreciated)
169 ** $_GET['torregion'] trade office region (depreciated)
170 ** $_GET['assurer'] full name assurer default empty
171 ** $_GET['assureremail'] email address assurer default empty (new)
172 ** $_GET['assurerdate'] date of signature assurer (new)
173 ** $_GET['assurerphone'] contact phone number of assurer (new)
174 //** $_GET['assurancedate'] date of assurance (new) (depreciated)
175 //** $_GET['location'] location of assurance (depreciated)
176 ** $_GET['nocca'] do not print CCA on back side (dflt: false)
177 ** $_GET['policy<%d>'] to include policy document(s) in pdf file %d = 1-9 (new)
178 ** $_GET['noform'] do not print form (dflt: true) (new)
179 ** $_GET['format'] paper format required A0-A6,Letter, Folio, B0-B6 (dflt A4)
180 ** $_GET['watermark'] watermark on the page
181 ** $_GET['orientation'] paper orientation default "landscape" default 2-up (new)
182 ** $_SESSION['_config']['language'] for "ja" japanese default != ja
183 ** $_SESSION['_config']['recode'] = "format" recode() uses it: needed ?
184 ** recode() is aliased to php lib function recode_string()
185 ** $_REQUEST[bw] if exists use black/white, default use colour
186 **
187 ** Output, package generates:
188 ** PDF display screen is scaled to 100% A4 size
189 ** PDF property fields have CAcert info
190 ** on non empty _GET strings, the package generates prefilled form fields.
191 ** PDF form field variables (Java Script):
192 ** Applicant
193 ** Organisation.Names[0] organisation name
194 ** Organisation.Address street address, zip, city
195 ** Organisation.Type comma separated values (csv)
196 ** type of organisation
197 ** state
198 ** country
199 ** Organisation.DBA registered trade names (csv)
200 ** Organisation.Domains organisation domain names (csv)
201 ** Organisation.Director.Name name of director with signing power
202 ** Organisation.Director.Email corporate email address
203 ** Organisation.Director.Phone corporate phone number
204 ** Organisation.Date date of signature director
205 ** Organisation.Admin[].Name 0..9 name of org. admnin
206 ** Organisation.Admin[].Email 0..9 o-admin email address
207 ** Organisation.Admin[].Phone 0..9 o-admin phone number
208 ** Trade Office Registry
209 ** tor.info comma separated values (csv):
210 ** unique trade office Identification number
211 ** name trade office registry
212 ** region trade office (depreciated)
213 ** date of trade office Extract (depreciated)
214 ** Assurer
215 ** Assurer.Name full name of assurer
216 ** Assurer.Email email address assurer
217 ** Assurer.Date date signature assurer
218 //** Assurance info (depreciated)
219 //** assurance.location string may have date of meeting (depreciated)
220 //** assurance.date date of assurance (depreciated)
221 ** Form Revision string is generated from RCS revision string.
222 ** More info on PDF fields:
223 ** http://www.adobe.com/devnet/acrobat/pdfs/js_developer_guide.pdf
224 **
225 */
226
227 // use next define if you test this code
228 define( 'TEST', true );
229
230 // INSTALLATION DIRS OF PACKAGES ==============================
231 // make sure packages are installed here
232 define('RT','./');
233 define('TCPDF_DIR','/usr/share/tcpdf_php4');
234 define('UTF8',RT."/utf8/native/core.php");
235 if( file_exists(RT.'/transtab.php') ) // wherever it is
236 define('UTF8_ASCII', RT.'/transtab.php');
237 else
238 define('UTF8_ASCII', RT.'/utf8_to_ascii/utf8_to_ascii.php'); // optional
239 // end operational special code defs
240
241 if( defined( 'TEST' ) ) {
242 // ONLY FOR TEST PURPOSES =====================================
243 /* test data */
244
245 $_SESSION['_config']['recode'] = "html..utf-8"; // ????
246 if( isset($_SERVER['LANG']) )
247 $_SESSION['_config']['language'] = $_SERVER['LANG'];
248
249 if( array_key_exists('FORMAT',$_SERVER) AND $_SERVER['FORMAT'] )
250 $_GET['format'] = $_SERVER['FORMAT'];
251 else {
252 //$_GET['format'] = "A5"; // margin scale problem... does not work
253 //$_GET['format'] = "Legal"; // ok
254 //$_GET['format'] = "Folio"; // ok
255 //$_GET['format'] = "Letter"; // letter little margin problem
256 //$_GET['format'] = "A4"; // A4, default ok
257 }
258 if( array_key_exists('ORIENTATION',$_SERVER) AND $_SERVER['ORIENTATION'] )
259 $_GET['orientation'] = $_SERVER['ORIENTATION'];
260 else {
261 //$_GET['orientation'] = "portrait"; // default 2 pages, or portrait
262 }
263 $_GET['nocca'] = isset($_SERVER['CCA']) ? $_SERVER['CCA'] : "";
264 if( isset($_SERVER['FORM']) AND $_SERVER['FORM'] == "noform" )
265 $_GET['noform'] = "true";
266
267 if( array_key_exists('FORM',$_SERVER) AND $_SERVER['FORM'] != 'empty' ){
268 // organisation info part
269 $_GET['name'] = "Stichting Oophaga foundation";
270 $_GET['address'] = "De Burgerstraat 25, office 268, 1098 SJ, Amsterdam-Buitenveldert";
271 $_GET['state'] = "";
272 $_GET['country'] = "Netherlands";
273 $_GET['type'] = "foundation";
274 $_GET['dba1'] = "Oophaga"; // trade names
275 //$_GET['DBA2..9'] = "St. Oophaga";
276 // applicant signer for organisation
277 $_GET['director'] = "Gerard H. M. Sühmple"; // upwards competable
278 //$_GET['email'] = "director@oophaga.org";
279 $_GET['phone'] = "+31 773270066";
280 $_GET['date'] = "2008-08-18"; // upwards compatible
281 // trade office information
282 $_GET['identifier'] = "NL-238603-AA02";
283 $_GET['tor'] = "Kamer van Koophandel";
284 $_GET['torregion'] = "Amsterdam";
285 //$_GET['tordate'] = "2008-04-03";
286 // contact name(s)
287 $_GET['domain1'] = "oophaga.org, oophaga.nl";
288 $_GET['domain2'] = "oophaga.net";
289 $_GET['domain4'] = "oophaga.eu";
290 $_GET['admin'] = "Görge H. M. Sämple"; // upwards competable
291 $_GET['adminemail'] = "tesu.hagaen@thesu.xs4all.eu";
292 $_GET['adminphone'] = "+31 77 327996";
293 //$_GET['admin2..9XX'] = ""; // name, email, phone
294 // assurer info
295 $_GET['assurer'] = "My O. Assurer-Name";
296 $_GET['assurerdate'] = "now";
297 $_GET['assureremail'] = "Assurer@cacert.org";
298 $_GET['assurerphone'] = "+31737201060";
299 // assurance info
300 //$_GET['assurancedate'] = "2008-12-21"; depreciated
301 //$_GET['location'] = "Amsterdam, Holland"; depreciated
302 //$_GET['notes'] = "bla bla"; depreciated
303 // handy
304 $_GET['watermark'] = "just an EXAMPLE";
305 } else {
306 //$_GET['ALL'] = "empty";
307 }
308
309 //$_REQUEST['bw'] = true;
310
311 } // end of TEST code ===========================================================
312
313 /* Directory settings for installation */
314 // change next for directory settings for packages !!!!!!!!!!!!!!!!!!!!!!
315 // set to correct internal path to TCPDF pakage installation
316 // Make sure pdf generation package is not connecting internet for
317 // whatever reason and downloading files into this host!!!!
318 // UCPDF as well PHP PDF std package have unsecure code as well....
319 require_once(TCPDF_DIR . '/config/lang/eng.php');
320 require_once(TCPDF_DIR . '/tcpdf.php');
321
322 // CAcert logo path/file name is extended with eg color, mono and format type
323 define( 'LOGO','logos/CAcert-logo-');
324 // eps should give better quality, LOGO_TYPE -> .eps
325 // eps does not work with CAcert logo, set to .eps when ok
326 define( 'LOGO_DPI', '1000');
327 define( 'LOGO_TYPE','-'.LOGO_DPI.'.png');
328 // logo colors RGB hex
329 define('BLUE', '#11568C'); // RGB 17 86 140
330 define('LBLUE', '#ADC5D7'); // RGB 112 154 186
331 define('LLBLUE','#D6E2EB'); // lighhter blue RGB 173 197 215
332 define('LIME', '#C7FF00'); // RGB 199 255 0
333 define('GREEN', '#00BE00'); // 0 190 0
334
335 define('POBOX','Hangar 10 Airfield Avenue, Murwillumbah NSW 2484, New South Wales, (Commonwealth of) Australia ');
336 define('WEB', 'http://www.cacert.org');
337 define('WIKI','http://wiki.cacert.org/wiki');
338 define('ROOTKEYS','http://www.cacert.org/index.php?id=3');
339 define('ASSCOAP', WIKI.'/FAQ/AssuranceByCAP');
340 define('ASSHBK', WIKI.'/OrganisationAssuranceManual');
341 define('ASSINFO', WIKI.'/OrganisationEntities');
342 define('ASSINTRO', WIKI.'/FAQ/AssuranceIntroduction');
343 define('ASSORG', WIKI."/OrganisationAssurance");
344 define('ARBIT', WIKI."/ArbitrationForum");
345 // CAcert Community Agreement
346 define('CCA', "CAcertCommunityAgreement"); // default policy to print
347 define('POLICY','policy/'); // default polciy doc directory
348 define('EXT','.html'); // default polciy doc extention, should be html
349 /* finger print CAcert Root Key SHA256 since 2019*/ // should obtain this automatically
350 define('CLASS1_SHA256','07ED BD82 4A49 88CF EF42 15DA 20D4 8C2B 41D7 1529 D7C9 00F5 7092 6F27 7CC2 30C5');
351 define('CLASS3_SHA256','F687 3D70 D675 96C2 ACBA 3440 1E69 738B 5270 1DD6 AB06 B497 49BC 5515 0936 D544');
352 /* finger print CAcert Root Key */ // not to use since 2019
353 /* finger print CAcert Root Key */ // should obtain this automatically
354 define('CLASS1_SHA1','DDFC DA54 1E75 77AD DCA8 7E88 27A9 8A50 6032 52A5');
355 define('CLASS3_SHA1','A7C4 8FBE 6B02 6DBD 0EC1 B465 B88D D813 EE1D EFA0');
356 // next two are not used on the form
357 define('CLASS1_MD5','A6:1B:37:5E:39:0D:9C:36:54:EE:BD:20:31:46:1F:6B');
358 define('CLASS3_MD5','F7:25:12:82:4E:67:B5:D0:8D:92:B7:7C:0B:86:7A:42');
359 // if on draft provide std message
360 define('WATERMARK',"");
361
362 // other definitions for the form
363 define("MAX_COLS", 2); // max coulumns per page Landscape is printed with 2-up
364 // put next to 200 and it will disable printout
365 define("MINH", 107.5); // in A5 mm is current estimated left over space on one page
366 define("H", 5); // height of a name entry field
367 //set margins
368 define("MARGIN",11.296); // 2-up will be scaled
369 // base of font size
370 define( 'F_SIZE', 7 );
371
372 define('DFL_FORMAT', 'html..utf-8');
373
374 // enviroment dependent constants
375 // Japanese is not supported?
376 if( array_key_exists('_config', $_SESSION) ) {
377 if( isset($_SESSION['_config']['language']) ) {
378 if($_SESSION['_config']['language'] == "ja")
379 define('FONT','SJIS');
380 else define( 'FONT', 'freesans');
381 }
382 else define( 'FONT', 'freesans');
383 }
384 else
385 //define( 'FONT', 'dejavusans');
386 define( 'FONT', 'freesans');
387
388 // generate black/white?
389 if(array_key_exists('bw',$_REQUEST))
390 define('BW', true);
391 else
392 define('BW', false);
393
394 // function is left in tact, but to new tcpdf code UFT-8 is fully supported now.
395 function my_recode($strg = NULL )
396 {
397 static $format = NULL;
398 if( $strg == NULL OR !$strg ) return ( "" );
399 if( $format == NULL ) {
400 if( array_key_exists('_config', $_SESSION) ) {
401 if( isset( $_SESSION['_config']['recode']) )
402 $format = $_SESSION['_config']['recode'];
403 else $format = DFL_FORMAT;
404 }
405 else $format = DFL_FORMAT;
406 }
407 // newer tcpdf package is full UTF-8 Voided by this package?
408 if( function_exists("recode_string" ) )
409 return ( recode_string($format, $strg) );
410 else return( $strg );
411 }
412
413 // return TRUE if string is ascii and not device control chars specialized for
414 // personal names (no device controls)
415 function utf8_is_ascii_ctrl($str) {
416 if ( strlen($str) > 0 ) {
417 // Search for any bytes which are outside the ASCII range,
418 // or are device control codes
419 //return (preg_match('/[^\x09\x0A\x0D\x20-\x7E]/',$str) !== 1); deleted \r and \n
420 return (preg_match('/[^\x09\x20-\x7E]/',$str) !== 1);
421 }
422 return FALSE;
423 }
424
425
426 // extend TCPF with custom functions
427 class COAPPDF extends TCPDF {
428
429 // do cap form version numbering automatically "$Revision: 1.5 $"
430 /*public*/ function Version() {
431 strtok(REV, " ");
432 return(strtok(" "));
433 }
434
435 /*public*/ function myHeader( $msg = NULL, $url = NULL )
436 {
437 static $my_url = NULL;
438 if( $msg != NULL ) {
439 $this->my_header_msg = $msg; $my_url = $url; return;
440 }
441 if( $this->my_header_msg == NULL ) return;
442 if( $this->msg_page_nr > 0 ) {
443 $font_fam = $this->FontFamily;
444 $font_style = $this->FontStyle.($this->underline ? 'U' : '').($this->linethrough ? 'D' : '');
445 $font_size = $this->getFontSize();
446 $this->SetFont(FONT,'', F_SIZE-1);
447 $this->setXY($this->lMargin, MARGIN-3);
448 $this->Cell($this->colwidth, 3,$this->my_header_msg, 0, 0, 'R');
449 if( !empty($font_fam ) )
450 $this->SetFont($font_fam,$font_style,$font_size);
451 if( $my_url != NULL AND $my_url != "" )
452 $this->myLink($this->lMargin+$this->colwidth/2,$this->lMargin-4,$this->colwidth,(F_SIZE+5)/2.9,$my_url);
453 }
454 $this->setXY($this->lMargin, MARGIN+3);
455 $this->y0 = $this->getY();
456 }
457
458 // undefine default header and footer handling
459 // default routines do not handle columns
460 function Footer() { }
461 function Header() { }
462 function Mark( $string = "" ) {
463 return array( $string, 1+substr_count($string,'.') );
464 }
465
466 /*public*/ function myFooter( $msg = NULL, $url = NULL )
467 {
468 static $my_url = NULL;
469 if( $msg != NULL ) {
470 $this->my_footer_msg = $msg; $this->msg_page_nr = 0;
471 $my_url = $url; return;
472 }
473 if( $this->my_footer_msg == NULL ) return;
474 $this->InFooter = true;
475 $this->msg_page_nr++;
476 $font_fam = $this->FontFamily;
477 $font_style = $this->FontStyle.($this->underline ? 'U' : '').($this->linethrough ? 'D' : '');
478 $font_size = $this->getFontSize();
479 $this->SetFont(FONT,'', F_SIZE-1);
480 if( $this->msg_page_nr > 1 ) {
481 $this->SetXY($this->lMargin, $this->GetPageHeight()/$this->scale*100.0-6);
482 $this->Cell($this->colwidth, 3,
483 sprintf("%s %d", $this->unhtmlentities( _('page') ), $this->msg_page_nr),
484 0, 0, 'C');
485 }
486 if( $this->my_footer_msg != "" ) {
487 $strg = "© ". date("Y"). " CAcert Inc.".", ". $this->my_footer_msg;
488 $this->SetXY($this->lMargin+MARGIN/2, $this->GetPageHeight()/$this->scale*100.0-6);
489 $this->Cell($this->colwidth, 3, $strg, 0, 0, 'R');
490 if( $my_url != NULL AND $my_url != "" )
491 $this->myLink($this->lMargin+MARGIN/2,$this->GetPageHeight()/$this->scale*100.0-6,$this->colwidth,(F_SIZE+5)/2.9,$my_url);
492 }
493 if( $this->Watermark != "" ) {
494 $this->StartTransform();
495 $savex = $this->GetX(); $savey = $this->GetY();
496 $this->SetFont(FONT,'', F_SIZE*7);
497 $l = $this->GetStringWidth($this->Watermark);
498 $h = $this->GetPageHeight()/$this->scale*100.0/2;
499 $w = $this->colwidth/2+MARGIN;
500 $this->SetXY(0,0);
501 $this->TranslateY($h+(F_SIZE*7)/2.9);
502 $this->TranslateX($w-MARGIN+$this->lMargin);
503 $this->Rotate(rad2deg(atan($h/$w)));
504 $this->Text(-$l/2,0,$this->Watermark, 0.8);
505 $this->StopTransform();
506 $this->SetXY($savex,$savey);
507 }
508
509 if( !empty($font_fam ) )
510 $this->SetFont($font_fam,$font_style,$font_size);
511 $this->InFooter = false;
512 }
513
514 // user and print preferences
515 // NumCopies, PrintPageRange, DisplayDocTitle, HideMenuBar, HideToolBar, ...
516 /*public*/ var $ViewerPrefs = array(
517 'Duplex' => 'Simplex',
518 'NumCopies'=> '1',
519 'DisplayDocTitle' => 'CAcert Organisation Assurance Programme (COAP) form',
520 'HideToolBar' => true,
521 'FitWindow' => true,
522 );
523
524 //number of colums
525 /*protected*/ var $ncols=1;
526
527 // columns width
528 /*protected*/ var $colwidth=0;
529
530 // space between columns
531 /*protected*/ var $column_space = 0;
532
533 //Current column
534 /*protected*/ var $col=0;
535
536 //Ordinate of column start
537 /*protected*/ var $y0;
538
539 // scaling factor
540 /*protected*/ var $scale = 100.0;
541
542 // print header and footer
543 /*protected*/ var $my_footer_msg = NULL;
544 /*protected*/ var $my_header_msg = NULL;
545 /*protected*/ var $msg_page_nr = 0;
546
547 // print short watermark on the page
548 /*public*/ var $Watermark = WATERMARK;
549
550 /*public*/ function SetFormat( $format = "A4" ) {
551 switch( strtolower($format) ) {
552 // there is some scale problems with margins...
553 case "a1":
554 case "b1":
555 $this->scale *= 1.4142;
556 case "a2":
557 case "b2":
558 $this->scale *= 1.4142;
559 case "a3":
560 case "b3":
561 $this->scale *= 1.4142; break;
562 case "a5":
563 case "b5":
564 $this->scale /= 1.4142; break;
565 case "letter":
566 $this->scale *= 0.97; break;
567 default: $format = "A4";
568 case "a4":
569 case "b4":
570 case "folio":
571 case "legal":
572 break;
573 }
574 $this->SetDisplayMode(intval($this->scale), 'SinglePage', 'UseOC');
575 return( $format );
576 }
577
578 //Set position at a given column
579 /*private*/ function SetCol($col = -1) {
580 static $pagecolwidth = 1.0;
581 static $column_space = 1.0;
582
583 if( $col == -1 ) $col = $this->col+1;
584 if( $this->colwidth == 0 ) {
585 // only once at start; set default values
586 //set margins
587 $this->addPage(); $col = 0; // reset to zero
588 $this->SetMargins(MARGIN, MARGIN, MARGIN);
589 if( $this->CurOrientation != 'L' ) {
590 $this->scale *= 1.4142;
591 $this->ScaleXY($this->scale,0,0);
592 } else {
593 $this->scale *= 1.0;
594 $this->ScaleXY($this->scale,0,0);
595 }
596 $this->ncols = $this->CurOrientation == 'L'? MAX_COLS : 1;
597 $this->colwidth = $this->w / $this->scale * 100 / $this->ncols - MARGIN*2;
598 $pagecolwidth = $this->w/$this->ncols;
599 // space between columns
600 if ($this->ncols > 1) {
601 $column_space = round((float)($this->w - ($this->ncols * $pagecolwidth)) / ($this->ncols - 1));
602 } else {
603 $column_space = 0;
604 }
605 $this->y0 = $this->GetY();
606 }
607 else {
608 if( $col == $this->col ) { // reset on close of this column
609 $x = MARGIN + $this->col*($pagecolwidth+$column_space);
610 $this->SetLeftMargin($x);
611 //$this->SetRightMargin($this->w - $x - $this->colwidth);
612 }
613 $this->PrintTable("", -1); // if pending table close up table
614 $this->myFooter(); // print footer msg if defined
615 }
616 if( $col >= $this->ncols ) {
617 $this->addPage(); $col = 0;
618 $this->ScaleXY($this->scale,0,0);
619 $this->y0 = 0; //no header/footer done...
620 } elseif ( $col > 0 AND $col < $this->ncols) {
621 // print column separator
622 $x = $this->w/$this->ncols*($this->col+1);
623 $y = $this->tMargin;
624 $this->SetLineWidth(0.1); $this->SetDrawColor(195);
625 $this->SetLineStyle(array('dash'=>'1,8') ); // gray dotted
626 $this->Line( $x, $y+27, $x, $y+185);
627 $this->SetLineWidth(0.2); $this->SetDrawColor(0);
628 $this->SetLineStyle(array('dash'=>'0') );
629 }
630 $this->col = $col;
631 // X position of the current column
632 $x = MARGIN + $col*($pagecolwidth+$column_space);
633 $this->SetLeftMargin($x);
634 $this->SetRightMargin($this->w - $x - $this->colwidth);
635 $this->SetXY($x, $this->y0);
636 $this->myHeader(); //print header msg if defined
637 $this->PrintTable("", 0); // if in table reprint title table
638 }
639
640 //Method accepting or not automatic page break
641 /*public*/ function AcceptPageBreak() {
642 $this->SetCol();
643 return false;
644 }
645
646 // redefine this routine from tcpdf.php due to scaling bug
647 /*protected*/ function checkPageBreak($h) {
648 if (((($this->y + $h)*$this->scale/100.0) > $this->PageBreakTrigger) ) {
649 if ( !$this->InFooter ) {
650 if ( ($this->AcceptPageBreak())) {
651 $rs = "";
652 //Automatic page break
653 $x = $this->x;
654 $ws = $this->ws;
655 if ($ws > 0) {
656 $this->ws = 0;
657 $rs .= '0 Tw';
658 }
659 $this->AddPage($this->CurOrientation);
660 if ($ws > 0) {
661 $this->ws = $ws;
662 $rs .= sprintf('%.3f Tw', $ws * $k);
663 }
664 $this->_out($rs);
665 $this->y = $this->tMargin;
666 $this->x = $x;
667 }
668 }
669 }
670 }
671
672 /*private*/ function S( $value = 1.0 ) {
673 return( $value * $this->scale / 100.0 );
674 }
675
676 // put Link in user space
677 /*private*/ function myLink( $x, $y, $w, $h, $Lnk = NULL, $Type = array('SubType'=>'Link') ) {
678 if( $Lnk == NULL ) return;
679 if( $Lnk == "" ) $Lnk = WEB."/";
680 $this->Annotation( $this->S($x), $this->S($y), $this->S($w), $this->S($h), $Lnk, $Type);
681 //$this->Annotation( $x, $y, $w, $h, $Lnk, $Type);
682 }
683
684
685 //require_once("../utf8/native/core.php");
686 // only for to upper case //require_once("../utf8/utils/unicode.php");
687
688 //setlocale(LC_ALL, 'de_DE');
689 // try to abbreviate a full name, returns name if abbreviation was/is done
690 // has pointers to sur name, first name, avoids titles and extentions
691 // is based that given names and family names starts with capital
692 // all names between first given name and surname are secondary names
693 // will use utf8 routines only when needed and available
694 /*private*/ function Abbreviate( $name = "") {
695 // need to change this for utf8 uppercase detection
696 // substr and strtoupper arte dependent of setlocale...
697 $substr = 'substr';
698 $strtoupper = 'strtoupper';
699 $tokens = array();
700 $cnt = preg_match_all('/([^\s\.]+\.|[^\s\.]+)/', $name, $tokens, PREG_SET_ORDER);
701 if( $cnt <= 0 ) return ( $name );
702 $fam = -1; $married = 0; $i = 0; $success = FALSE; $first_name = -1;
703 for( $j = 0; $j < $cnt ; $j++ ) {
704 $tk = $tokens[$j];
705 $nm = $tk[0]; if( $nm == "" ) continue;
706 // not utf8
707 $ltr = $substr( $nm, 0, 1 );
708 if(preg_match('/[^\x09\x20-\x7E]/',$ltr) !== 1 AND // it is utf8
709 function_exists( 'utf8_substr') ) {
710 $substr='utf8_substr';
711 //$strtoupper = 'utf8_strtoupper'; // requires utf8/utils/unicode.php
712 }
713 if( $strtoupper($ltr) != $ltr ) continue; // lower case setlocale dependent
714 elseif( preg_match('/\./', $nm ) ) {
715 if( $first_name < 0 ) $first_name = $j;
716 if( $first_name >= 0 ) $success = TRUE; // was abbreviated
717 continue; // title
718 }
719 if( $first_name < 0 ) $first_name = $j;
720 if( $married == 0 ) $fam = $j;
721 if( preg_match('/[-_]/', $nm ) ) {
722 // find special markers
723 if( $married == 0 ) $fam = $j;
724 $married++;
725 }
726 }
727 $name = "";
728 for( $j = 0; $j < $cnt; $j++ ){
729 $tk = $tokens[$j];
730 if( !isset($tk[0]) ) continue;
731 $nm = $tk[0]; if( $nm == "" ) continue;
732 if( $name != "") $name .= " ";
733 $ltr = $substr( $nm, 0, 1 );
734 if( $j == $fam ) $name .= $nm;
735 elseif( $strtoupper($ltr) != $ltr ) $name .= $nm; // lower case
736 elseif( preg_match('/\./', $nm ) ) $name .= $nm;
737 elseif( $j < $fam ) { // need to abbreviate
738 // not utf8
739 // and abbreviate
740 if( $j == $first_name )
741 $abr = "(". $substr( $nm, 1 ) . ")";
742 else $abr = ".";
743 $name .= $ltr . $abr; $success = TRUE; // is abbreviated
744 } else $name .= $nm;
745 }
746 $ext = -1; for( $j = $cnt-1; $j >= 0 AND $j >= $fam; $j-- ) {
747 // try to find family names and see if there is abbreviation
748 $tk = $tokens[$j];
749 if( !isset($tk[0]) ) continue;
750 $nm = $tk[0];
751 if( $ext < 0 AND preg_match('/(^[^A-Z]|\.)/', $nm ) ) continue;
752 if( $ext < 0 ) $ext = $j+1;
753 if( preg_match('/\./', $nm ) ) { $success = TRUE; break; }
754 }
755 return( $success? $name : "" ); // and return abbriviated name
756 }
757
758 // set formfield coordinates
759 // this routine is needed due to field ordinates are not scaled and in user space
760 // to be called before form field call (or as width parameter)
761 // and just after with true argument to restore X Y ordinates.
762 /*private*/ function SetFieldXY( $x=NULL, $y=NULL, $w=0) {
763 static $savex;
764 static $savey;
765 static $restored = true;
766 $restoreXY = $x == NULL ? true : false;
767
768 if( $restored == $restoreXY )
769 $this->Error("internal Form Field save/restore error\n");
770 if( !$restoreXY ) {
771 /* save X Y ordinates */
772 $savex = $this->GetX(); $savey = $this->GetY();
773 // scale to user ordinates
774 $this->SetY( $this->S($y));
775 $this->SetX( $this->S($x));
776 } else {
777 /* restore X Y ordinates */
778 $this->SetY( $savey); // different from SetXY()
779 $this->SetX( $savex); // different from SetXY()
780 }
781 $restored = $restoreXY;
782 return( $this->S($w) );
783 }
784
785 // print Date on left or right side
786 /*private*/ function PrintDate( $x=10, $y=10, $dstrg="teus", $dvalue="1945-10-6", $field = NULL , $RL = 'L')
787 {
788 static $TextProps = array('strokeColor' => LLBLUE, 'value' => "", 'fillColor' => LBLUE , 'textSize' => '11', 'charLimit'=> 10);
789 $TextProps['userName'] = $this->unhtmlentities( _("yyyy-mm-dd") );
790
791 $this->SetFont( FONT, '', F_SIZE);
792 $this->SetXY($RL == 'L'? $x : $x-50, $y);
793 $this->Cell(50, 3, $dstrg, 0, 0, $RL);
794 if($dvalue) {
795 $this->SetXY($RL == 'L'? $x :$x-50, $y+3.5);
796 $this->SetFont(FONT, "B", F_SIZE);
797 $this->Cell(50, 3, $dvalue, 0 , 0, $RL);
798 }
799 if( $field == NULL ) return;
800 $TextProps['value'] = $dvalue;
801 $this->TextField($field, $this->SetFieldXY(($RL == 'L'? $x+1 : $x-17), ($y+3.5),17), 5, $TextProps );
802 $this->SetFieldXY();
803 }
804
805 // Add import HTML text eg from CCA
806 /*public*/ function PrintHTML( $url = NULL ) {
807 if( $url == NULL OR $url == "" ) return;
808 $error = ""; $title = ""; $url = POLICY.$url.EXT;
809 if( ! file_exists($url) ) $url = WEB."/".$url;
810 $data = file_get_contents($url);
811 if( !$data ) $error = "\nInternal Error: no ".$url." found.";
812 else {
813 $regs = array();
814 preg_match('/<[Tt][Ii][Tt][Ll][Ee][^>]*>/', $data, $regs);
815 if( count($regs) < 1 ) $error .= "\nInternal Error: no open tag title found on $url.";
816 else {
817 $start = strpos($data, $regs[0]) + strlen($regs[0]);
818 $data = substr($data, $start);
819 }
820 $regs = array();
821 preg_match('/<\/[Tt][Ii][Tt][Ll][Ee][^>]*>/', $data, $regs);
822 if( count($regs) < 1 ) $error .= "\nInternal Error: no close title tag found on $url.";
823 else {
824 $end = strpos($data, $regs[0]);
825 $title = trim(substr($data,0,$end));
826 $data = substr($data, $end+strlen($regs[0]));
827 }
828 $regs = array();
829 preg_match('/<[Bb][oO][Dd][yY][^>]*>/', $data, $regs);
830 if( count($regs) < 1 ) $error .= "\nInternal Error: no open html body tag found on $url.";
831 else {
832 $start = strpos($data, $regs[0]) + strlen($regs[0]);
833 $data = substr($data, $start);
834 }
835 $regs = array();
836 preg_match('/<\/[Bb][oO][Dd][yY][^>]*>/', $data, $regs);
837 if( count($regs) < 1 ) $error .= "\nInternal Error: no closing html body tag found on $url.";
838 else {
839 $end = strpos($data, $regs[0])-1;
840 $data = substr($data, 1, $end);
841 }
842 }
843 if( !$title ) $title = $url;
844 $this->SetCol();
845 $this->setFont(FONT, F_SIZE);
846 if( !$error ) {
847 $this->PrintHeader(_($title), $this->unhtmlentities( _('policy document') ), strncmp($url,WEB,strlen(WEB))==0? $url : (WEB."/".$url));
848 if( $title ) $this->Bookmark($title,0);
849 $this->writeHTMLCell($this->colwidth,2.5,$this->lMargin+1,$this->GetY()+2.5,
850 $data, 0,2,0,'L');
851 }
852 else
853 $this->MultiCell($this->colwidth, 3, $error);
854 }
855
856 /*private*/ function PrintCOAP($organisation = NULL, $registry = NULL, $assurer = NULL, $assurance = NULL){
857 $this->SetCol();
858 $this->PrintHeader($this->unhtmlentities( _('CAcert Organisation Assurance Programme'), _('Organisation Information (COAP) form'), defined('ASSCOAP')?ASSCOAP:"",defined('WEB')? WEB.substr(__FILE__, strrpos(__FILE__,"/")) : "") );
859 // define slighly different footer message
860 $this->myFooter("V". substr($this->Version(), 0, strpos($this->Version(), '.')).", ". $this->unhtmlentities( _('generated')." ".date("Y-n-j") ));
861 $this->AssuranceInfo();
862 $this->InfoOrganisation($organisation, $registry);
863 $this->StatementOrganisation($organisation);
864 $this->StatementAssurer( $assurer, $assurance );
865 }
866
867 //Add form and/or CCA (on duplex only when more as one page is printed)
868 /*public*/ function PrintForm( $organisation = NULL, $registry = NULL, $assurer = NULL, $page = NULL ) {
869
870 for($cnt=0 ; $cnt < $this->ncols; $cnt++ ) {
871 if( !isset( $page['form']) OR $page['form'] ) {
872 // the form is one page, use new room?
873 if ( $organisation == NULL OR $registry == NULL OR $assurer == NULL )
874 $this->Error("Organisation or Assurer data records failure");
875 $this->PrintCOAP( $organisation, $registry, $assurer);
876 }
877 // print off policy documents to be included in pdf file
878 foreach( $page['policies'] as $i => $file ) {
879 $this->Watermark = WATERMARK; // no watermark on these pages
880 if( $file ) $this->PrintHTML( $file );
881 }
882 if( $this->col > 0 OR $this->getPage() > 1 ) break;
883 }
884 if( $this->getPage() > 1 ) {
885 // and on duplex print back side with Community Agreement
886 if( $this->CurOrientation == 'P' )
887 $this->ViewerPrefs['Duplex'] = 'DuplexFlipLongEdge';
888 else
889 $this->ViewerPrefs['Duplex'] = 'DuplexFlipShortEdge';
890 }
891 // close up this column, make sure footer is printed.
892 $this->my_header_msg = NULL; $this->SetCol($this->col);
893 }
894
895 // Set form title (right align)
896 /*public*/ function PrintHeader($title1 = " ", $title2 = " " , $url1 = NULL, $url2 = NULL) {
897 // store current top margin value
898 $tSide = $this->tMargin;
899
900 // CAcert logo
901 // eps should be better, but it does not seem to work with CAcert logo
902 $this->rMargin -= 1;
903 $this->myFooter($title1,$url1);
904 $this->myHeader($title2,$url2);
905 if( LOGO_TYPE == '.eps' )
906 $this->ImageEPS(BW?LOGO.'mono'.LOGO_TYPE:LOGO.'colour'.LOGO_TYPE,
907 ($this->lMargin+$this->colwidth)-51,$tSide-3,51);
908 else
909 // png image 1000 X 229 * 8 bits
910 $this->Image(BW?LOGO.'mono'.LOGO_TYPE:LOGO.'colour'.LOGO_TYPE,
911 ($this->lMargin+$this->colwidth)-51,$tSide-3,51,0,0,
912 NULL,0,true,intval(LOGO_DPI));
913 $this->myLink($this->lMargin+$this->colwidth-51, $tSide-3,51,51/1000*229,WEB."/");
914 // form type
915 $this->SetFont(FONT,'B',F_SIZE+5);
916 $this->SetY($tSide+5); $this->SetX($this->lMargin);
917 $l = $this->GetStringWidth($title1);
918 $this->Cell($this->colwidth+1,14,$title1,0,0,'R',0,NULL);
919 if( $url1 != NULL AND $url1 != "" )
920 $this->myLink($this->lMargin+$this->colwidth-$l,$this->GetY()+5,$l,(F_SIZE+5)/2.9,$url1);
921 $this->Ln(5); $this->SetX($this->lMargin);
922 $l = $this->GetStringWidth($title2);
923 $this->Cell($this->colwidth+1,14,$title2,0,0,'R',0,NULL);
924 if( $url2 != NULL AND $url2 != "" )
925 $this->myLink($this->lMargin+$this->colwidth-$l,$this->GetY()+5,$l,(F_SIZE+5)/2.9,$url2);
926
927 // CAcert Inc. postbox address
928 $this->Ln(6); $this->SetX($this->lMargin);
929 $this->SetFont(FONT,'',F_SIZE);
930 $savex = $this->GetX(); $savey = $this->GetY();
931 $strg = POBOX ." - ". WEB;
932 $this->SetXY($this->lMargin+$this->colwidth-$this->GetStringWidth($strg)-1.1,$this->GetY()+3.5); // right align
933 if( !BW ) $this->SetTextColor(17,86,140);
934 $ret = $this->Write(0, $strg, NULL);
935 $l = $this->GetStringWidth($strg);
936 $this->myLink($this->lMargin+$this->colwidth-$l,$this->GetY()+0.5,$l,F_SIZE/2.9,WEB);
937 $this->Ln();
938 if( !BW ) $this->SetTextColor(0);
939 $this->SetXY($savex,$savey);
940
941 // sha1 fingerprint CAcert rootkeys class 1 and class 3
942 $strg = $this->unhtmlentities( _("CAcert's Root Certificate sha256 fingerprints") ) . ", class 1: ". CLASS1_SHA256 . ", class 3: " . CLASS3_SHA256;
943 $this->Ln(3); $this->SetX($this->lMargin);
944 $this->SetFont(FONT,'',F_SIZE * $this->colwidth / ($this->GetStringWidth($strg) +1));
945 $this->Cell($this->colwidth,10, $strg,0,0,'C',0,NULL);
946 $this->myLink($this->lMargin, $this->GetY()+4,$this->colwidth,F_SIZE/2.9,ROOTKEYS);
947 $this->SetLineWidth(0.1);
948 if ( BW ) { $this->SetDrawColor(195);
949 } else { $this->SetDrawColor(17,86,140);
950 }
951
952 $this->Line($this->lMargin, $tSide+25, $this->lMargin+$this->colwidth, $tSide+25);
953 $this->SetLineWidth(0.2); $this->SetDrawColor(0);
954 $this->rMargin += 1;
955 $this->SetXY($this->lMargin, $tSide+26); // top
956 }
957
958 // Set general form information
959 /*private*/ function PrintInfo( $strg = "", $url = "") {
960 // store current margin values
961
962 // Print text blurb paragraph at top of page
963 $this->SetFont(FONT,'',F_SIZE+0.5);
964 $this->SetXY($this->lMargin, $this->GetY()-1.5);
965 $y = $this->GetY(); $x = $this->GetX();
966 $cnt=$this->MultiCell($this->colwidth+1, 0, $strg,0,'L',0,2);
967 if ( $url != "" ) // link should be in user space
968 $this->myLink($x, $y, $this->colwidth, $this->GetY()-$y, $url);
969 return($cnt);
970 }
971
972 // print general CAP info
973 /*public*/ function AssuranceInfo( ) {
974 // store current margin values
975 $cellcnt = 0;
976 $this->SetY($this->GetY()+0.5);
977 $this->Bookmark($this->unhtmlentities( _('CAcert COAP form') ),0,$this->S($this->GetY()));
978
979 // Show text blurb at top of page
980 $strg = $this->unhtmlentities( _('The CAcert Organisation Programme (COAP) aims to verify the identity of the organisation.') );
981 $strg .= "\r\n". $this->unhtmlentities( _('The Applicant asks the Organisation Assurer to verify to CAcert Community that the information provided by the Applicant is correct, and according to the official trade office registration bodies.') );
982 $cellcnt += $this->PrintInfo( $strg, defined('ASSINTRO')? ASSINTRO:"");
983 $cellcnt += $this->PrintInfo( $this->unhtmlentities( _('For more information about the CAcert Organisation Assurance Programme, including detailed guides to CAcert Organisation Assurers, please visit:')." ".WEB, defined('ASSCOAP')?ASSCOAP:"") );
984 $cellcnt += $this->PrintInfo( $this->unhtmlentities( _('A CAcert Arbitrator can require the Organisation Assurer to deliver the completed forms and accompanying documents in the event of a dispute.'),defined('ARBIT')?ARBIT:"") );
985 $this->SetY($this->GetY()+0.3);
986 return( $cellcnt);
987 }
988
989 // print empty table with title for statements (called twice per table)
990 /*private*/ function PrintTable( $strg = NULL, $height = -1, $ext = 0 ) {
991 // store current margin values
992 static $tSide = -1;
993 static $title = "";
994 if( $height < 0 ) { // mark table position, leave room for title
995 if( $strg != "" ) $title = $strg;
996 if( $title == "" ) return ($this->GetY()); // nothing to do
997 $tSide = $this->GetY()+1;
998 // background
999 if ( BW ) {
1000 $this->SetFillColor(195);
1001 $this->SetDrawColor(195);
1002 } else {
1003 $this->SetFillColor(173,197,215);
1004 $this->SetDrawColor(173,197,215);
1005 }
1006 $this->Rect($this->lMargin-1,$tSide-1,1,9, "F");
1007 $this->Rect($this->lMargin-1,$tSide-1,$this->colwidth,1, "F");
1008 $this->SetFillColor(255);
1009 if ( BW ) { $this->SetFillColor(125);
1010 } else { $this->SetFillColor(17,86,140);
1011 }
1012 $this->Rect($this->lMargin,$tSide,$this->colwidth,7, "DF");
1013 $this->SetFillColor(255); $this->SetDrawColor(0);
1014
1015 $this->SetXY($this->lMargin+1, $tSide+0.6);
1016 $this->Bookmark($title,1,$this->S($tSide));
1017 $this->SetFont(FONT, '', F_SIZE+7);
1018 $this->SetTextColor(255);
1019 $this->Write(0, $title);
1020 $this->SetTextColor(0);
1021 $this->SetXY($this->lMargin+1, $tSide + 7);
1022 $tSide += 8; // save old top
1023 if ( $height != 0 ) return($this->GetY());
1024 }
1025 elseif( $tSide < 0 ) return( $this->GetY());
1026 if( $height == 0 ) { // interrupted bottum of column reached
1027 $height = $this-GetY() - $tSide; $save = $title;
1028 $this->PrintTable("", $height); // finish till bottumn page
1029 $tSide = $this->originalMargin;
1030 $title = $save;
1031 return( $this->GetY());
1032 }
1033 if( $strg != "" ) $title = $strg; // just to be defensive
1034
1035 // background
1036 if ( BW ) {
1037 $this->SetFillColor(195);
1038 $this->SetDrawColor(195);
1039 } else {
1040 $this->SetFillColor(173,197,215);
1041 $this->SetDrawColor(173,197,215);
1042 }
1043 $this->Rect($this->lMargin-1,$tSide,1,$height-1+$ext, "F");
1044 if( $ext )
1045 $this->Rect($this->lMargin-1,$tSide+$height,$this->colwidth,$ext, "F");
1046 $this->SetFillColor(255);
1047 // borders of the table left, bottumn, right
1048 $this->Line($this->lMargin,$tSide+$height-1, $this->lMargin, $tSide+$height);
1049 $this->Line($this->lMargin,$tSide+$height,$this->lMargin+$this->colwidth,$tSide+$height);
1050 $this->Line($this->lMargin+$this->colwidth,$tSide-1, $this->lMargin+$this->colwidth, $tSide+$height);
1051 $this->SetDrawColor(0);
1052 $this->SetY($tSide + $height + 1); // set Y ordinate to plus 7
1053 $tSide = -1; $title = "";
1054 return($this->GetY());
1055 }
1056
1057 // a name, email address, phone number
1058 /*private*/ function PrintName( $info = "", $title = "", $field = "", $name = "", $email = NULL, $phone = NULL, $backgrnd = false ) {
1059 static $TextProps = array('strokeColor'=> LLBLUE, 'value' => " ", 'fillColor'=> LBLUE, 'doNotScrole'=> 'false', 'textSize' => 10, 'rotate'=> '0');
1060
1061 // just once to recover from Acrobat 7.0 problem !!!!!!!!!!!!!!!!!!!!!!!!!!
1062 // make sure before the first time form field JS is called the fake is done
1063 static $AcrobatName = array('strokeColor'=> LLBLUE, 'fillColor'=> LLBLUE, 'readonly' => 'true');
1064 if( $AcrobatName != NULL ) {
1065 $this->TextField( 'NameNone', $this->SetFieldXY(300, $this->GetY()+2, 0), 0, $AcrobatName);
1066 $this->SetFieldXY(); $AcrobatName = NULL;
1067 }
1068 // end of Acrobat defeat !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1069 $cellcnt = 1; $msg = "";
1070 // put assurer help for assurance in pdf file for mouse over
1071 if ( $info != "" ) $msg = $info;
1072 if ( $email != NULL AND $email != "" AND $title != "" )
1073 $msg .= " ". $this->unhtmlentities( _('The email address, which matches the CAcert account email address, is handy for administrative and contact reasons. For organisation administrator the email address is required.') );
1074 if( $msg != "" )
1075 $this->myLink($this->lMargin-7, $this->GetY()-1, 5, 3, $msg,
1076 array('subtype'=> 'Text', 'Open' => true,
1077 'c'=> array(173,197,215), 'name' => 'Comment',
1078 'f'=> array( 'nozoom', 'readonly', 'norotate'),
1079 't'=> $this->unhtmlentities( _('COAP form help') ))
1080 );
1081 if( $backgrnd ) {
1082 if ( BW ) {
1083 $this->SetFillColor(241);
1084 } else {
1085 //$this->SetFillColor(173,197,215);
1086 $this->SetFillColor(234, 241, 246);
1087 }
1088 $this->Rect($this->lMargin+37.5,$this->GetY()+0.1,
1089 $this->colwidth-38.5,
1090 ($email != NULL AND $email != "") ? 5.7 : 2.8,
1091 "F");
1092 $this->Rect($this->lMargin+1,$this->GetY()+0.1,
1093 35.5,
1094 ($email != NULL AND $email != "") ? 5.7 : 2.8,
1095 "F");
1096 $this->SetFillColor(255);
1097 }
1098 // assurer identity info
1099 $this->SetX($this->lMargin+1);
1100 $savey = $this->GetY();
1101 $this->SetFont(FONT, '', F_SIZE);
1102 $l = $this->GetStringWidth($title);
1103 //$l = ($l<=0? 0 : ($l < 35? 35 : $l));
1104 $l = $l < 35 ? 35 : $l;
1105 $this->Write(0, $title);
1106 $this->SetXY($this->lMargin+2+$l, $savey);
1107 if( $name ) {
1108 $this->SetFont(FONT, 'B', F_SIZE);
1109 $this->SetXY( $this->lMargin+2 + $l, $savey-1);
1110 $cellcnt += $this->MultiCell($this->colwidth-$l-3, 3, $name, 0, 1);
1111 if( function_exists('utf8_to_ascii') AND
1112 !utf8_is_ascii_ctrl( $name) )
1113 $ascii = utf8_to_ascii($name);
1114 else
1115 $ascii = "";
1116 if( $ascii == $name ) $ascii = "";
1117 if( $email != NULL ) $abbr = $this->Abbreviate( $name ); else $abbr="";
1118 if( $ascii != "" OR $abbr != "") {
1119 $la = $this->GetStringWidth($name) + 5;
1120 $msg = $this->unhtmlentities( _('The exact name of the individual may have transliterated characters and/or some given names may be abbreviated. If present the first given name will be shown abbreviated and parentheses around the last part of the given name.') )."\r\n";
1121 if( $ascii != "" ) $msg .= '* '. $ascii . "\r\n";
1122 if( $abbr != "" ) $msg .= '* '. $abbr . "\r\n";
1123 $this->myLink($this->lMargin+$l+$la, $savey, 3, 2, $msg,
1124 array('subtype'=> 'Text', 'Open' => false,
1125 'c' => array(173,197,215), 'name' => 'Comment',
1126 'f'=> array( 'nozoom', 'readonly', 'norotate'),
1127 't' => $this->unhtmlentities( _('On the full name of the Assurer') )));
1128 }
1129 }
1130 $TextProps['value'] = $name ? $name : " ";
1131 $TextProps['userName'] = $this->unhtmlentities( _('Full exact name of the individual.') );
1132 $this->TextField($field.($email? 'Name' : ""), $this->SetFieldXY($this->lMargin+2+$l, $savey, $this->colwidth-$l-3-($phone?25:0)), 4.5, $TextProps );
1133 $this->SetFieldXY();
1134 if( $phone AND $phone != " " ) {
1135 $sx = $this->GetX(); $sy = $this->GetY();
1136 $this->SetFont(FONT, "", F_SIZE);
1137 $sw = $this->GetStringWidth($phone) + 2;
1138 $this->SetXY( $this->lMargin+$this->colwidth-$sw -4, $sy-4.8);
1139 $this->SetFont('zapfdingbats', "", F_SIZE+3);
1140 $this->Write(0, "&"); // telephone symbol
1141 $this->SetXY( $this->lMargin+$this->colwidth-$sw-1, $sy-4.1);
1142 $this->SetFont(FONT, "", F_SIZE);
1143 $this->Cell($sw+1,0,$phone);
1144 }
1145 if( $phone ) {
1146 $TextProps['value'] = $phone ? $phone : $this->unhtmlentities( _('phone nr') ) . "?";
1147 $TextProps['userName'] = $this->unhtmlentities( _('For organisation administrators and assurer: provide email address and optionally your phone number.') );
1148 $this->TextField($field.'Phone', $this->SetFieldXY($this->lMargin+$this->colwidth-25, $savey, 24), 4.5, $TextProps );
1149 $this->SetFieldXY();
1150 }
1151 $savey += 3;
1152 if( $email AND $email != " " ) {
1153 $this->SetXY($this->lMargin+2+$l, $savey); $cellcnt++;
1154 $this->SetFont(FONT, "", F_SIZE);
1155 if( !BW ) $this->SetTextColor(17,86,140);
1156 $this->Write(0, $email);
1157 $this->myLink($this->lMargin+$l, $savey,$this->GetStringWidth($email), 3, "mailto:". $email . "?subject=" . $this->unhtmlentities( _('Organisation Assurance') ));
1158 if( !BW ) $this->SetTextColor(0);
1159 }
1160 if( $email ) {
1161 $TextProps['value'] = $email ? $email : $this->unhtmlentities( _('email') ) . "?";
1162 $TextProps['userName'] = $this->unhtmlentities( _('For organisation administrators and assurer: provide email address and optionally your phone number.') );
1163 $this->TextField($field.'Email', $this->SetFieldXY($this->lMargin+2+$l, $savey, $this->colwidth-$l-28), 4.5, $TextProps);
1164 $this->SetFieldXY(); $savey += 3;
1165 }
1166 // phone number
1167 $this->SetXY($this->lMargin+2, $savey);
1168 return( $cellcnt );
1169 //$H = 5; // height of the name cell
1170 }
1171
1172 // All information of Applicant goes in one table
1173 /*public*/ function InfoOrganisation( $organisation = NULL, $registry = NULL ){
1174 // Applicant Identity information part
1175 $tSide = $this->PrintTable($this->unhtmlentities( _('Organisation Identity Information') ))+1;
1176
1177 $msg = $this->unhtmlentities( _('The organisation name, director name and signature, and applicable company law is checked by the Organisation Assurer with the official Trade Office Registration (Extract) or by other means. The organisation domain name(s) are checked of ownership against the internet domain DNS records.') );
1178 $msg .= "\r\nThe organisation administrator (a CAcert Assurer) email address must be the primary email address registered with CAcert.";
1179 // put hint on comparing names on title table
1180 $this->myLink($this->lMargin-7, $tSide-7, 5, 5, $msg,
1181 array('subtype'=> 'Text', 'Open' => true,
1182 'c'=> array(173,197,215), 'name' => 'Comment',
1183 'f'=> array( 'nozoom', 'readonly', 'norotate'),
1184 't'=> $this->unhtmlentities( _('On organisation identity information') )));
1185
1186 $this->SetXY($this->lMargin+1, $tSide);
1187 $this->PrintName(
1188 $this->unhtmlentities( _('The official full name of the organisation equal to the name of the organisation registered e.g. at the trade office registration of the state.') ),
1189 $this->unhtmlentities( _('Name of the organisation') )." ",
1190 "OrganisationNames0",
1191 $organisation['namecnt']>0?$organisation['names'][0]:" ",
1192 NULL, NULL, true);
1193 $this->PrintName(
1194 $this->unhtmlentities( _('The organisation address which should be equal to the address registered with the trade office.') ),
1195 $this->unhtmlentities( _('Address (comma separated)') )." ",
1196 "OrganisationAddress",
1197 $organisation['address'],
1198 NULL, NULL, true);
1199 $strg = "";
1200 foreach( array( $organisation['type'], $organisation['state'], $organisation['country']) as $i )
1201 if( $i != "" ) $strg .= ($strg != "" ? ", ": "") . $i;
1202 $this->PrintName(
1203 $this->unhtmlentities( _('The legal organisation type: eg Ltd, EPS, society, foundation, association, etc. The state/country under which jurisdiction the organisation operates.') ),
1204 $this->unhtmlentities( _('Type, jurisdiction (state)') )." ",
1205 "OrganisationType",
1206 $strg,
1207 NULL, NULL, true);
1208 //$this->Ln(0.4);
1209 $strg = $organisation['namecnt'] <= 1 ? "" : $organisation['names'][1];
1210 for( $i = 3; $i <= $organisation['namecnt']; $i++)
1211 $strg .= ", ". $organisation['names'][$i-1];
1212 $this->PrintName( $this->unhtmlentities( _('Other registered trade names of the organisation. (comma separated)') ),
1213 $this->unhtmlentities( _('Registered Trade Names') ), 'OrganisationDBA',
1214 $strg,
1215 NULL, NULL, true);
1216 //$this->Ln(0.4);
1217 $strg = "";
1218 foreach( array( $registry['identifier'], $registry['name'], $registry['region'], $registry['date'] ) as $i )
1219 if( $i != "" ) $strg .= ($strg != "" ? ", " : "") . $i;
1220 $this->PrintName(
1221 $this->unhtmlentities( _('Trade Office Registry information, as organisation registration Identification number or license number, name of the trade office registry, trade office operating region, and optionally date of extract.') ),
1222 $this->unhtmlentities( _('Registration (id, name, region)') ),
1223 'torinfo',
1224 $strg,
1225 NULL, NULL, true);
1226 $this->Ln(0.4);
1227 $strg = ""; foreach( $organisation['domains'] as $i )
1228 $strg .= ($strg != "" ? ", " : "") . $i;
1229 $this->PrintName(
1230 $this->unhtmlentities( _('The internet domain name(s) the organisation controls and owns. The names will be checked with WHOIS with e.g. the DNS official top domain registrar e.g. the country ccTLD .<country code> registrar.') ),
1231 $this->unhtmlentities( _('Internet Domain(s)') ),
1232 'OrganisationDomains',
1233 $strg,
1234 NULL, NULL, true);
1235 $this->Ln(0.4);
1236 // all (max) three names with ID type right aligned.
1237 // contact info o-admin address assuree
1238 $cnt = $organisation['admincnt'];
1239 $space = $this->getPageHeight()/$this->scale*100.0 -MINH ; // margin
1240 for( $i = 0; $i < $cnt; $i++ ) { // names to be printed
1241 $this->PrintName(
1242 $this->unhtmlentities( _('The organisation administrator (CAcert Assurer) contact information. The administrator is appointed by the organisation director to administer the organisation domain certificates, secure the certificates and maintain them.') ),
1243 $this->unhtmlentities( _('Organisation Administrator') ),
1244 sprintf("OrganisationAdmin%d",$i),
1245 $organisation['admins'][$i]['name'],
1246 $organisation['admins'][$i]['email']? $organisation['admins'][$i]['email']:" ",
1247 $organisation['admins'][$i]['phone']? $organisation['admins'][$i]['phone']:" ",
1248 TRUE);
1249 if( $space < $this->getY() ) break;
1250 }
1251 for( $j=0 ; $j < $i+3; $j++ ) {
1252 // empty fields up to max 3 empty fields and allowed space
1253 if( $space < $this->getY() ) break;
1254 $this->PrintName(
1255 $i+$j == 0? $this->unhtmlentities( _('The organisation administrator (CAcert Assurer) contact information. The administrator is appointed by the organisation director to administer the organisation domain certificates, secure the certificates and maintain them.') ):"",
1256 $i+$j > 0? "": $this->unhtmlentities( _('Organisation Administrator') ),
1257 sprintf("OrganisationAdmin%d",$i+$j),
1258 "", " ", " ", TRUE);
1259 }
1260 $this->Ln(0.8);
1261 //$this->SetXY($this->lMargin+1, $this->GetY()+0.35);
1262 $next = $this->PrintTable( "", $this->GetY()-$tSide, 5);
1263 $this->SetY($next);
1264 }
1265
1266 // print marked paragraph in the table
1267 /*private*/ function PrintTicked( $strg = "", $tick = true ) {
1268 // store current margin values
1269 $savey = $this->GetY();
1270
1271 $celcnt = 0; $this->SetX($this->lMargin + 1);
1272 if( $tick ) {
1273 // use ✔ and ❑ of zapfdingbats font for OK tick
1274 $savex = $this->GetX();
1275 $this->SetXY($this->GetX(), $savey+0.9);
1276 $this->SetFont("zapfdingbats", F_SIZE+3);
1277 $this->Write(0,"q"); // ❑
1278 $this->SetXY($savex+0.1, $savey+0.1);
1279 if ( BW )
1280 $this->SetTextColor(80);
1281 else
1282 $this->SetTextColor(17, 86, 140);
1283 //$this->SetTextColor(0,92,0); // #00BE00 lime
1284 $this->Write(0,"4 ");// ✓
1285 $this->SetTextColor(0);
1286 }
1287 $this->SetXY($this->GetX(), $savey);
1288 $this->SetFont(FONT,'',F_SIZE+0.5);
1289 $celcnt = $this->MultiCell($this->lMargin+$this->colwidth-$this->GetX(), 3, $strg,0,'L');
1290 $this->SetXY($this->lMargin+1, $this->GetY()-1.5);
1291 return($celcnt);
1292 }
1293
1294 // assuree statement
1295 /*public*/ function StatementOrganisation( $organisation = NULL ) {
1296 // store current margin values
1297 $cellcnt = 0;
1298
1299 // assuree statement section
1300 $tSide = $this->PrintTable($this->unhtmlentities( _("Organisation's Statement") )); // mark table header
1301 $msg = $this->unhtmlentities( _('The Director indicated by the Trade Office Registry Extract, has to underwrite the correctness of the information for the organisation and allowance of certificate operations by the administrators.') );
1302 $msg .= "\r\nFor formal contact with the organisation the email address of the organisation is required.";
1303 // put hint on comparing names on title table
1304 $this->myLink($this->lMargin-7, $tSide-7, 5, 5, $msg,
1305 array('subtype'=> 'Text', 'Open' => true,
1306 'c'=> array(173,197,215), 'name'=> 'Comment',
1307 'f'=> array( 'nozoom', 'readonly', 'norotate'),
1308 't'=> $this->unhtmlentities( _("On director's statement") )));
1309
1310 $cellcnt += $this->PrintTicked( $this->unhtmlentities( _("Make sure you have read and agreed with the CAcert Community Agreement") ), false /* no tick */);
1311 if( !BW ) $this->SetTextColor(17, 86, 140);
1312 $this->SetXY($this->lMargin+2,$this->GetY()-0.5);
1313 $ret = $this->Write($this->lasth, WEB."/".POLICY.CCA.EXT, NULL);
1314 $this->myLink($this->lMargin+1, $this->GetY()-F_SIZE/2.9, $this->colwidth-2, F_SIZE*2.9/2.9, WEB."/".POLICY.CCA.EXT);
1315 $this->Ln(4);
1316 if( !BW ) $this->SetTextColor(0);
1317 $this->Ln(0.3);
1318
1319 $this->PrintName($this->unhtmlentities( _('Name and contact details (organisation email address & optionally phone number), of the Director of the organisation as is referred to in the trade office extract.') ),
1320 $this->unhtmlentities( _('Director') ), "OrganisationDirector", $organisation['director'],
1321 $organisation['email']?$organisation['email'] : "email:",
1322 $organisation['phone']? $organisation['phone']:" ");
1323 $cellcnt += $this->PrintTicked( $this->unhtmlentities( _('I agree to the CAcert Community Agreement.') ), true /* tick */);
1324 $cellcnt += $this->PrintTicked( $this->unhtmlentities( _('I hereby confirm that all information is complete and accurate and will notify CAcert of any updates or changes thereof.') ), true /* tick */);
1325 $cellcnt += $this->PrintTicked( $this->unhtmlentities( _('I am duly authorised to act on behalf of the organisation, I grant operational certificate administrative privileges to the specified Organisation Administrator and, I request the Organisation Assurer to verify the organisation information according to the Assurance Policies.') ), true /* tick */);
1326
1327 $this->Ln(0.5);
1328 $savey = $this->GetY();
1329 $strg = $this->unhtmlentities( _('Date') );
1330 if($organisation['date'] == "")
1331 $strg .= " (". $this->unhtmlentities( _("yyyy-mm-dd") ). ")";
1332 $strg = $strg;
1333 $this->PrintDate( $this->lMargin+1, $savey+1, $strg, $organisation['date'], 'OrganisationDate', 'L');
1334
1335 $strg = $this->unhtmlentities( _('Signature and organisation stamp') );
1336 $this->SetFont(FONT, '', F_SIZE);
1337 $l = $this->GetStringWidth( $strg );
1338 $this->SetXY($this->lMargin+$this->colwidth-$l-3, $savey+1);
1339 $this->Write(0, $strg); $this->Ln(7) ; // and leave some room
1340
1341 // draw the table borders and header at marked ordinate
1342 $next = $this->PrintTable("", $this->GetY()-$tSide);
1343
1344 $this->SetY($next);
1345 }
1346
1347 // assurer statement
1348 /*public*/ function StatementAssurer( $assurer = NULL ) {
1349 if( $assurer == NULL ) return;
1350
1351 // store current margin values
1352 $TextProps = array('strokeColor'=> LLBLUE, 'value' => "", 'fillColor'=> LBLUE, 'doNotScrole'=> 'true', 'textSize' => '14', 'rotate'=>0);
1353 $cellcnt = 0;
1354
1355 $tSide = $this->PrintTable($this->unhtmlentities( _("Organisation Assurer's Statement") )); // mark table ordinate
1356 // put assurer help for assurance in pdf file for mouse over
1357 $msg = $this->unhtmlentities( _('The organisation assurer will check the trade office registry for company information (name, location, country of jurisdiction, director names, trade office Identification number, domain name ownership, and system admin reference). Any associated costs for this research will be reimborsed by the assurer from the organisation.') );
1358 $this->myLink($this->lMargin-7, $tSide-6, 5, 5, $msg,
1359 array('subtype'=> 'Text', 'Open' => true,
1360 'c'=> array(173,197,215), 'name'=> 'Comment',
1361 'f'=> array( 'nozoom', 'readonly', 'norotate'),
1362 't'=> $this->unhtmlentities( _('On mutual assurance') )));
1363 // assurer identity info
1364 $this->Ln(0.9);
1365 $this->PrintName(
1366 $this->unhtmlentities( _('The Organisation Assurer contact information. This assurer will verify the organisation identity and registration information.') ),
1367 $this->unhtmlentities( _('Organisation Assurer') ) . " ","Assurer",
1368 $assurer['name'],
1369 $assurer['email']? $assurer['email']:" ",
1370 $assurer['phone']? $assurer['phone']:" ");
1371
1372 // assurer statements
1373 $this->SetY($this->GetY()-0.5);
1374 $cellcnt += $this->PrintTicked( $this->unhtmlentities( _("I, the Assurer, hereby confirm that I have verified the official Information for the organisation, I will witness the organisation's identity in the CAcert Organisation Assurance Programme, and complete the Assurance.") ), true /* ticked */);
1375 $cellcnt += $this->PrintTicked( $this->unhtmlentities( _('I am a CAcert Community Member, have passed the Organisation Assurance Challenge, and have been appointed for Organisation Assurances within the country where the organisation is registered.') ), true /* ticked */);
1376 $this->Ln(1); $savey = $this->GetY();
1377
1378 $strg = $this->unhtmlentities( _('Date') );
1379 if( $assurer['date'] == "" ) $strg .= " (" . $this->unhtmlentities( _("yyyy-mm-dd") ).")";
1380 $strg = $strg;
1381 $this->PrintDate( $this->lMargin+1, $savey, $strg, $assurer['date'], 'AssurerDate', 'L');
1382
1383 $this->SetXY($this->lMargin+1, $savey);
1384 $this->SetFont(FONT, "",F_SIZE);
1385 $strg = $this->unhtmlentities( _("Organisation Assurer's signature") );
1386 $this->SetXY($this->lMargin+$this->colwidth-$this->GetStringWidth($strg)-3, $savey);
1387 $this->Write(0, $strg );
1388 $savey = $this->GetY()+7; // leave room for date and signature
1389 if( $this->GetPageHeight()/$this->scale*100.0-$savey > MARGIN+4)
1390 $savey += 2;
1391 $this->SetXY($this->lMargin+1, $savey);
1392 $l = $this->GetPageHeight()/$this->scale*100.0-$this->GetY() - MARGIN;
1393 if($l > 3 ) $l = 3; if( $l > 0 ) $this->Ln($l); // try to come close to margin
1394 $next = $this->PrintTable("", $this->GetY()-$tSide);
1395 $this->SetY($next);
1396 }
1397
1398 // End of CAPPDF TCPDF class extension
1399 }
1400
1401
1402 // --------------------------------------------------------------------------------
1403 // import environmental data -------------------------------------------------------
1404 // get $form, $orientation, $assuree, $assurer, $assurance info
1405 // FONT and BW are set already
1406
1407 // import info
1408 $utf8 = false;
1409 function GET( $key = "" ) {
1410 global $utf8;
1411 $strg = array_key_exists( $key, $_GET) ? $_GET[$key] : "";
1412 if(!$utf8 AND $strg != "" AND
1413 !utf8_is_ascii_ctrl($strg) AND
1414 !function_exists('utf8_to_ascii')) {
1415 $utf8 = true;
1416 }
1417 return( $strg );
1418 }
1419
1420 // form, CCA and page format info
1421 $page['format'] = strtolower(GET('format')); // A3, A4, A5, letter, legal, etc.
1422 if( !$page['format'] ) $page['format'] = 'a4'; // default a4, portrait
1423 // on landscape orientation we do two half pages
1424 $page['orientation'] = strtolower(GET('orientation'));
1425 if( $page['orientation'] != 'l' AND $page['orientation'] != "landscape" ) {
1426 $page['orientation'] = 'p'; // default is portrait and 1 up
1427 }
1428 $page['form'] = GET('noform') != "" ? false : true;
1429 // dft is now true it should go to true
1430 $page['policies'] = array();
1431 if( GET('nocca') == "" ) {
1432 if( defined('CCA') ) $page['policies'][] = CCA;
1433 }
1434 // set $page['form'] on 'simplex' or 'duplex' to get CCA on pdf page
1435
1436 // Assurer info
1437 $assurer = array ( 'name' => my_recode(GET('assurer')) ,
1438 'email' => my_recode(GET('assureremail')),
1439 'date' => my_recode(GET('assurerdate')),
1440 'phone' => my_recode(GET('assurerphone')),
1441 );
1442
1443 /*
1444 // assurance info
1445 $assurance = array ( 'location' => my_recode(GET('location')),
1446 'date' => my_recode(GET('assurancedate'))?my_recode(GET('assurancedate')):
1447 my_recode(GET('date')),
1448 'notes' => '' // not yet used
1449 );
1450 */
1451
1452 // trade office info
1453 $registry = array (
1454 'identifier' => my_recode(GET('identifier')),
1455 'date' => my_recode(GET('tordate')),
1456 'region' => my_recode(GET('torregion')),
1457 'name' => my_recode(GET('tor')),
1458 );
1459
1460 // Assuree info
1461 $organisation = array (
1462 'names' => array( ), // [0] full name, [>0] DBA's
1463 'namecnt' => 0,
1464 'date' => my_recode(GET('date')) == "now" ? date("Y-m-d") :
1465 my_recode(GET('date')),
1466 'address' => my_recode(GET('address')),
1467 'state' => my_recode(GET('state')),
1468 'country' => my_recode(GET('country')),
1469 'type' => my_recode(GET('type')),
1470 'director' => my_recode(GET('director')),
1471 'email' => my_recode(GET('email')),
1472 'phone' => my_recode(GET('phone')),
1473 'domains' => array(), // dns names for server certs
1474 'admincnt' => 0,
1475 'admins' => array(), // name, email, phone
1476 );
1477
1478 if( $assurer['date'] == "now" ) $assurer['date'] = date("Y-m-d");
1479 //if( $registry['date'] == "now" ) $registry['date'] = date("Y-m-d");
1480
1481 function Dstr( $first = "", $strg = "", $cnt = 0 ) {
1482 return( $cnt>0? sprintf("%s%d%s", $first, $cnt, $strg) : $first.$strg );
1483 }
1484 // company name info and trade names
1485 $j = 0; // after two successive empty names we stop
1486 for( $i = -1; $i <= 9 AND $j < 3; $i++) { // max 9 names we only print 4 max...
1487 $name = my_recode(GET(Dstr($i>=0? "dba" : "name", "", $i)));
1488 if( $name ) { $j = 0;
1489 $organisation[ 'namecnt' ]++;
1490 $organisation[ 'names' ] [] = $name;
1491 } else $j++;
1492 }
1493 // administrator info
1494 $j = 0; // after two successive empty names we stop
1495 for( $i = 0; $i <= 9 AND $j < 2; $i++) { // max 9 names we only print 4 max...
1496 $name = my_recode(GET(Dstr("admin", "", $i)));
1497 if( $name ) { $j = 0;
1498 $organisation[ 'admincnt' ]++;
1499 $organisation[ 'admins' ] [] = array (
1500 'name' => $name ? $name : "",
1501 'email' => my_recode(GET(Dstr("admin","email",$i))),
1502 'phone' => my_recode(GET(Dstr("admin","phone",$i))),
1503 );
1504 } else $j++;
1505 }
1506 // organisation domain names convert to array of lowercased names
1507 $j = 0; $domains = "";
1508 for( $i = 0; $i <= 25 AND $j < 2; $i++ ) {
1509 $name = my_recode(GET(Dstr("domain", "", $i)));
1510 if( $name ) { $j = 0;
1511 if( $domains != "" ) $domains .= ",";
1512 $domains .= strtolower($name);
1513 } else $j ++;
1514 }
1515 $i = 0;
1516 if( $domains ) { // csv list to array and trim white spaces
1517 $domains = strtok($domains,',');
1518 for( ; $domains != ""; $i++) {
1519 $organisation['domains'][$i] = trim($domains); $domains = strtok(',');
1520 }
1521 sort( $organisation['domains'] );
1522 } else $organisation['domains'][0] = " ";
1523 unset($domains);
1524
1525 // try to get policy documents names to be printed off
1526 $j = 0; // after two successive empty name we stop searching
1527 for( $i = 1; $i <= 9 AND $j<2; $i++ ) {
1528 $name = GET(sprintf("policy%d", $i));
1529 if( $name != "" ) { $page['policies'][] = $name; $j = 0; }
1530 else $j++;
1531 }
1532
1533 if( $utf8 ) { // have scanned arguments for non-ascii code now
1534 //require_once("../utf8/native/core.php");
1535 // only for to upper case require_once("../utf8/utils/unicode.php");
1536 require_once ( UTF8_ASCII );
1537 }
1538
1539 unset( $i ); unset( $j); unset( $utf8 ); // unset($_GET);
1540 // end of arguments imports
1541
1542 header("Expires: ".gmdate("D, j M Y G:i:s \G\M\T", time()+10800));
1543 header("Content-Disposition: attachment; filename=CAcert cap.pdf");
1544 header("Cache-Control: public, max-age=10800");
1545 header("Pragma: cache");
1546 // Content-Type and Content Length is done by tcpdf package
1547
1548 // create new PDF document =====================================================
1549 $pdf = new COAPPDF(
1550 /* PDF_PAGE_ORIENTATION */ $page['orientation'],
1551 PDF_UNIT /* mm */,
1552 /* PDF_PAGE_FORMAT */ $page['format'],
1553 true
1554 );
1555 $pdf->SetFormat( $page['format'] ); // set paper size scaling
1556
1557 // protection is encryption and this will cause 3.5 times performance loss
1558 // $pdf->SetProtection(array('print', 'annot-forms'));
1559
1560 // set document property information
1561 $pdf->SetCreator("LibreSSL - CAcert web application");
1562 $pdf->SetAuthor("© " . date("Y") . " CAcert Inc., Australia.");
1563 $pdf->SetKeywords("X.509, Organisation Assurance Programme, COAP form, digital certificates, CAcert, Community Agreement");
1564 $pdf->SetTitle("CAcert Organisation Assurance Programme");
1565 $pdf->SetSubject("COAP form V".$pdf->Version().", generated " . date("Y-n-j H:i:s T"));
1566 if( GET('watermark') != '') $pdf->Watermark = my_recode(GET('watermark'));
1567 // requires zlib and will decrease response time but increase bandwidth
1568 // if no zlib is found, automatically no compression is done
1569 $pdf->SetCompression(true); // turn it off when more pperformance is needed
1570
1571 // AddSJISFont function is not present in tcpdf package !!!!
1572
1573 //set auto page breaks
1574 $pdf->SetAutoPageBreak(TRUE, MARGIN*0.707);
1575
1576 //set image scale factor
1577 $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
1578
1579 //set some language-dependent strings
1580 $pdf->setLanguageArray($l);
1581
1582 //initialize document
1583 $pdf->AliasNbPages();
1584
1585 // AND GENERATE THE FORM ===================================
1586 // generation properties which have been set from environment:
1587 // BW (color), FONT (free Sans Vera), orientation (portrait, 1-up), format (A4)
1588 if ( FONT == 'SJIS') $pdf->AddSJISFont();
1589 $pdf->PrintForm($organisation, $registry, $assurer, $page);
1590 $pdf->setViewerPreferences($pdf->ViewerPrefs);
1591
1592 //Close and output PDF document
1593 $pdf->Output("CAcert COAP.pdf", "I");
1594
1595 //============================================================+
1596 // END OF FILE
1597 //============================================================+
1598 ?>