Bug 1114: Deleted CAcert postal address
[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.4 2012-01-24 14:26:05 root Exp $
21 define('REV', '$Revision: 1.4 $');
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','CAcert Inc. - P.O. Box 4107 - Denistone East NSW 2112 - 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','.php'); // default polciy doc extention, should be html
349 /* finger print CAcert Root Key */ // should obtain this automatically
350 define('CLASS1_SHA1','135C EC36 F49C B8E9 3B1A B270 CD80 8846 76CE 8F33');
351 define('CLASS3_SHA1','AD7C 3F64 FC44 39FE F4E9 0BE8 F47C 6CFA 8AAD FDCE');
352 // next two are not used on the form
353 define('CLASS1_MD5','A6:1B:37:5E:39:0D:9C:36:54:EE:BD:20:31:46:1F:6B');
354 define('CLASS3_MD5','F7:25:12:82:4E:67:B5:D0:8D:92:B7:7C:0B:86:7A:42');
355 // if on draft provide std message
356 define('WATERMARK',"");
357
358 // other definitions for the form
359 define("MAX_COLS", 2); // max coulumns per page Landscape is printed with 2-up
360 // put next to 200 and it will disable printout
361 define("MINH", 107.5); // in A5 mm is current estimated left over space on one page
362 define("H", 5); // height of a name entry field
363 //set margins
364 define("MARGIN",11.296); // 2-up will be scaled
365 // base of font size
366 define( 'F_SIZE', 7 );
367
368 define('DFL_FORMAT', 'html..utf-8');
369
370 // enviroment dependent constants
371 // Japanese is not supported?
372 if( array_key_exists('_config', $_SESSION) ) {
373 if( isset($_SESSION['_config']['language']) ) {
374 if($_SESSION['_config']['language'] == "ja")
375 define('FONT','SJIS');
376 else define( 'FONT', 'freesans');
377 }
378 else define( 'FONT', 'freesans');
379 }
380 else
381 //define( 'FONT', 'dejavusans');
382 define( 'FONT', 'freesans');
383
384 // generate black/white?
385 if(array_key_exists('bw',$_REQUEST))
386 define('BW', true);
387 else
388 define('BW', false);
389
390 // function is left in tact, but to new tcpdf code UFT-8 is fully supported now.
391 function my_recode($strg = NULL )
392 {
393 static $format = NULL;
394 if( $strg == NULL OR !$strg ) return ( "" );
395 if( $format == NULL ) {
396 if( array_key_exists('_config', $_SESSION) ) {
397 if( isset( $_SESSION['_config']['recode']) )
398 $format = $_SESSION['_config']['recode'];
399 else $format = DFL_FORMAT;
400 }
401 else $format = DFL_FORMAT;
402 }
403 // newer tcpdf package is full UTF-8 Voided by this package?
404 if( function_exists("recode_string" ) )
405 return ( recode_string($format, $strg) );
406 else return( $strg );
407 }
408
409 // return TRUE if string is ascii and not device control chars specialized for
410 // personal names (no device controls)
411 function utf8_is_ascii_ctrl($str) {
412 if ( strlen($str) > 0 ) {
413 // Search for any bytes which are outside the ASCII range,
414 // or are device control codes
415 //return (preg_match('/[^\x09\x0A\x0D\x20-\x7E]/',$str) !== 1); deleted \r and \n
416 return (preg_match('/[^\x09\x20-\x7E]/',$str) !== 1);
417 }
418 return FALSE;
419 }
420
421
422 // extend TCPF with custom functions
423 class COAPPDF extends TCPDF {
424
425 // do cap form version numbering automatically "$Revision: 1.4 $"
426 /*public*/ function Version() {
427 strtok(REV, " ");
428 return(strtok(" "));
429 }
430
431 /*public*/ function myHeader( $msg = NULL, $url = NULL )
432 {
433 static $my_url = NULL;
434 if( $msg != NULL ) {
435 $this->my_header_msg = $msg; $my_url = $url; return;
436 }
437 if( $this->my_header_msg == NULL ) return;
438 if( $this->msg_page_nr > 0 ) {
439 $font_fam = $this->FontFamily;
440 $font_style = $this->FontStyle.($this->underline ? 'U' : '').($this->linethrough ? 'D' : '');
441 $font_size = $this->getFontSize();
442 $this->SetFont(FONT,'', F_SIZE-1);
443 $this->setXY($this->lMargin, MARGIN-3);
444 $this->Cell($this->colwidth, 3,$this->my_header_msg, 0, 0, 'R');
445 if( !empty($font_fam ) )
446 $this->SetFont($font_fam,$font_style,$font_size);
447 if( $my_url != NULL AND $my_url != "" )
448 $this->myLink($this->lMargin+$this->colwidth/2,$this->lMargin-4,$this->colwidth,(F_SIZE+5)/2.9,$my_url);
449 }
450 $this->setXY($this->lMargin, MARGIN+3);
451 $this->y0 = $this->getY();
452 }
453
454 // undefine default header and footer handling
455 // default routines do not handle columns
456 function Footer() { }
457 function Header() { }
458 function Mark( $string = "" ) {
459 return array( $string, 1+substr_count($string,'.') );
460 }
461
462 /*public*/ function myFooter( $msg = NULL, $url = NULL )
463 {
464 static $my_url = NULL;
465 if( $msg != NULL ) {
466 $this->my_footer_msg = $msg; $this->msg_page_nr = 0;
467 $my_url = $url; return;
468 }
469 if( $this->my_footer_msg == NULL ) return;
470 $this->InFooter = true;
471 $this->msg_page_nr++;
472 $font_fam = $this->FontFamily;
473 $font_style = $this->FontStyle.($this->underline ? 'U' : '').($this->linethrough ? 'D' : '');
474 $font_size = $this->getFontSize();
475 $this->SetFont(FONT,'', F_SIZE-1);
476 if( $this->msg_page_nr > 1 ) {
477 $this->SetXY($this->lMargin, $this->GetPageHeight()/$this->scale*100.0-6);
478 $this->Cell($this->colwidth, 3,
479 sprintf("%s %d", $this->unhtmlentities( _('page') ), $this->msg_page_nr),
480 0, 0, 'C');
481 }
482 if( $this->my_footer_msg != "" ) {
483 $strg = "© ". date("Y"). " CAcert Inc.".", ". $this->my_footer_msg;
484 $this->SetXY($this->lMargin+MARGIN/2, $this->GetPageHeight()/$this->scale*100.0-6);
485 $this->Cell($this->colwidth, 3, $strg, 0, 0, 'R');
486 if( $my_url != NULL AND $my_url != "" )
487 $this->myLink($this->lMargin+MARGIN/2,$this->GetPageHeight()/$this->scale*100.0-6,$this->colwidth,(F_SIZE+5)/2.9,$my_url);
488 }
489 if( $this->Watermark != "" ) {
490 $this->StartTransform();
491 $savex = $this->GetX(); $savey = $this->GetY();
492 $this->SetFont(FONT,'', F_SIZE*7);
493 $l = $this->GetStringWidth($this->Watermark);
494 $h = $this->GetPageHeight()/$this->scale*100.0/2;
495 $w = $this->colwidth/2+MARGIN;
496 $this->SetXY(0,0);
497 $this->TranslateY($h+(F_SIZE*7)/2.9);
498 $this->TranslateX($w-MARGIN+$this->lMargin);
499 $this->Rotate(rad2deg(atan($h/$w)));
500 $this->Text(-$l/2,0,$this->Watermark, 0.8);
501 $this->StopTransform();
502 $this->SetXY($savex,$savey);
503 }
504
505 if( !empty($font_fam ) )
506 $this->SetFont($font_fam,$font_style,$font_size);
507 $this->InFooter = false;
508 }
509
510 // user and print preferences
511 // NumCopies, PrintPageRange, DisplayDocTitle, HideMenuBar, HideToolBar, ...
512 /*public*/ var $ViewerPrefs = array(
513 'Duplex' => 'Simplex',
514 'NumCopies'=> '1',
515 'DisplayDocTitle' => 'CAcert Organisation Assurance Programme (COAP) form',
516 'HideToolBar' => true,
517 'FitWindow' => true,
518 );
519
520 //number of colums
521 /*protected*/ var $ncols=1;
522
523 // columns width
524 /*protected*/ var $colwidth=0;
525
526 // space between columns
527 /*protected*/ var $column_space = 0;
528
529 //Current column
530 /*protected*/ var $col=0;
531
532 //Ordinate of column start
533 /*protected*/ var $y0;
534
535 // scaling factor
536 /*protected*/ var $scale = 100.0;
537
538 // print header and footer
539 /*protected*/ var $my_footer_msg = NULL;
540 /*protected*/ var $my_header_msg = NULL;
541 /*protected*/ var $msg_page_nr = 0;
542
543 // print short watermark on the page
544 /*public*/ var $Watermark = WATERMARK;
545
546 /*public*/ function SetFormat( $format = "A4" ) {
547 switch( strtolower($format) ) {
548 // there is some scale problems with margins...
549 case "a1":
550 case "b1":
551 $this->scale *= 1.4142;
552 case "a2":
553 case "b2":
554 $this->scale *= 1.4142;
555 case "a3":
556 case "b3":
557 $this->scale *= 1.4142; break;
558 case "a5":
559 case "b5":
560 $this->scale /= 1.4142; break;
561 case "letter":
562 $this->scale *= 0.97; break;
563 default: $format = "A4";
564 case "a4":
565 case "b4":
566 case "folio":
567 case "legal":
568 break;
569 }
570 $this->SetDisplayMode(intval($this->scale), 'SinglePage', 'UseOC');
571 return( $format );
572 }
573
574 //Set position at a given column
575 /*private*/ function SetCol($col = -1) {
576 static $pagecolwidth = 1.0;
577 static $column_space = 1.0;
578
579 if( $col == -1 ) $col = $this->col+1;
580 if( $this->colwidth == 0 ) {
581 // only once at start; set default values
582 //set margins
583 $this->addPage(); $col = 0; // reset to zero
584 $this->SetMargins(MARGIN, MARGIN, MARGIN);
585 if( $this->CurOrientation != 'L' ) {
586 $this->scale *= 1.4142;
587 $this->ScaleXY($this->scale,0,0);
588 } else {
589 $this->scale *= 1.0;
590 $this->ScaleXY($this->scale,0,0);
591 }
592 $this->ncols = $this->CurOrientation == 'L'? MAX_COLS : 1;
593 $this->colwidth = $this->w / $this->scale * 100 / $this->ncols - MARGIN*2;
594 $pagecolwidth = $this->w/$this->ncols;
595 // space between columns
596 if ($this->ncols > 1) {
597 $column_space = round((float)($this->w - ($this->ncols * $pagecolwidth)) / ($this->ncols - 1));
598 } else {
599 $column_space = 0;
600 }
601 $this->y0 = $this->GetY();
602 }
603 else {
604 if( $col == $this->col ) { // reset on close of this column
605 $x = MARGIN + $this->col*($pagecolwidth+$column_space);
606 $this->SetLeftMargin($x);
607 //$this->SetRightMargin($this->w - $x - $this->colwidth);
608 }
609 $this->PrintTable("", -1); // if pending table close up table
610 $this->myFooter(); // print footer msg if defined
611 }
612 if( $col >= $this->ncols ) {
613 $this->addPage(); $col = 0;
614 $this->ScaleXY($this->scale,0,0);
615 $this->y0 = 0; //no header/footer done...
616 } elseif ( $col > 0 AND $col < $this->ncols) {
617 // print column separator
618 $x = $this->w/$this->ncols*($this->col+1);
619 $y = $this->tMargin;
620 $this->SetLineWidth(0.1); $this->SetDrawColor(195);
621 $this->SetLineStyle(array('dash'=>'1,8') ); // gray dotted
622 $this->Line( $x, $y+27, $x, $y+185);
623 $this->SetLineWidth(0.2); $this->SetDrawColor(0);
624 $this->SetLineStyle(array('dash'=>'0') );
625 }
626 $this->col = $col;
627 // X position of the current column
628 $x = MARGIN + $col*($pagecolwidth+$column_space);
629 $this->SetLeftMargin($x);
630 $this->SetRightMargin($this->w - $x - $this->colwidth);
631 $this->SetXY($x, $this->y0);
632 $this->myHeader(); //print header msg if defined
633 $this->PrintTable("", 0); // if in table reprint title table
634 }
635
636 //Method accepting or not automatic page break
637 /*public*/ function AcceptPageBreak() {
638 $this->SetCol();
639 return false;
640 }
641
642 // redefine this routine from tcpdf.php due to scaling bug
643 /*protected*/ function checkPageBreak($h) {
644 if (((($this->y + $h)*$this->scale/100.0) > $this->PageBreakTrigger) ) {
645 if ( !$this->InFooter ) {
646 if ( ($this->AcceptPageBreak())) {
647 $rs = "";
648 //Automatic page break
649 $x = $this->x;
650 $ws = $this->ws;
651 if ($ws > 0) {
652 $this->ws = 0;
653 $rs .= '0 Tw';
654 }
655 $this->AddPage($this->CurOrientation);
656 if ($ws > 0) {
657 $this->ws = $ws;
658 $rs .= sprintf('%.3f Tw', $ws * $k);
659 }
660 $this->_out($rs);
661 $this->y = $this->tMargin;
662 $this->x = $x;
663 }
664 }
665 }
666 }
667
668 /*private*/ function S( $value = 1.0 ) {
669 return( $value * $this->scale / 100.0 );
670 }
671
672 // put Link in user space
673 /*private*/ function myLink( $x, $y, $w, $h, $Lnk = NULL, $Type = array('SubType'=>'Link') ) {
674 if( $Lnk == NULL ) return;
675 if( $Lnk == "" ) $Lnk = WEB."/";
676 $this->Annotation( $this->S($x), $this->S($y), $this->S($w), $this->S($h), $Lnk, $Type);
677 //$this->Annotation( $x, $y, $w, $h, $Lnk, $Type);
678 }
679
680
681 //require_once("../utf8/native/core.php");
682 // only for to upper case //require_once("../utf8/utils/unicode.php");
683
684 //setlocale(LC_ALL, 'de_DE');
685 // try to abbreviate a full name, returns name if abbreviation was/is done
686 // has pointers to sur name, first name, avoids titles and extentions
687 // is based that given names and family names starts with capital
688 // all names between first given name and surname are secondary names
689 // will use utf8 routines only when needed and available
690 /*private*/ function Abbreviate( $name = "") {
691 // need to change this for utf8 uppercase detection
692 // substr and strtoupper arte dependent of setlocale...
693 $substr = 'substr';
694 $strtoupper = 'strtoupper';
695 $tokens = array();
696 $cnt = preg_match_all('/([^\s\.]+\.|[^\s\.]+)/', $name, $tokens, PREG_SET_ORDER);
697 if( $cnt <= 0 ) return ( $name );
698 $fam = -1; $married = 0; $i = 0; $success = FALSE; $first_name = -1;
699 for( $j = 0; $j < $cnt ; $j++ ) {
700 $tk = $tokens[$j];
701 $nm = $tk[0]; if( $nm == "" ) continue;
702 // not utf8
703 $ltr = $substr( $nm, 0, 1 );
704 if(preg_match('/[^\x09\x20-\x7E]/',$ltr) !== 1 AND // it is utf8
705 function_exists( 'utf8_substr') ) {
706 $substr='utf8_substr';
707 //$strtoupper = 'utf8_strtoupper'; // requires utf8/utils/unicode.php
708 }
709 if( $strtoupper($ltr) != $ltr ) continue; // lower case setlocale dependent
710 elseif( preg_match('/\./', $nm ) ) {
711 if( $first_name < 0 ) $first_name = $j;
712 if( $first_name >= 0 ) $success = TRUE; // was abbreviated
713 continue; // title
714 }
715 if( $first_name < 0 ) $first_name = $j;
716 if( $married == 0 ) $fam = $j;
717 if( preg_match('/[-_]/', $nm ) ) {
718 // find special markers
719 if( $married == 0 ) $fam = $j;
720 $married++;
721 }
722 }
723 $name = "";
724 for( $j = 0; $j < $cnt; $j++ ){
725 $tk = $tokens[$j];
726 if( !isset($tk[0]) ) continue;
727 $nm = $tk[0]; if( $nm == "" ) continue;
728 if( $name != "") $name .= " ";
729 $ltr = $substr( $nm, 0, 1 );
730 if( $j == $fam ) $name .= $nm;
731 elseif( $strtoupper($ltr) != $ltr ) $name .= $nm; // lower case
732 elseif( preg_match('/\./', $nm ) ) $name .= $nm;
733 elseif( $j < $fam ) { // need to abbreviate
734 // not utf8
735 // and abbreviate
736 if( $j == $first_name )
737 $abr = "(". $substr( $nm, 1 ) . ")";
738 else $abr = ".";
739 $name .= $ltr . $abr; $success = TRUE; // is abbreviated
740 } else $name .= $nm;
741 }
742 $ext = -1; for( $j = $cnt-1; $j >= 0 AND $j >= $fam; $j-- ) {
743 // try to find family names and see if there is abbreviation
744 $tk = $tokens[$j];
745 if( !isset($tk[0]) ) continue;
746 $nm = $tk[0];
747 if( $ext < 0 AND preg_match('/(^[^A-Z]|\.)/', $nm ) ) continue;
748 if( $ext < 0 ) $ext = $j+1;
749 if( preg_match('/\./', $nm ) ) { $success = TRUE; break; }
750 }
751 return( $success? $name : "" ); // and return abbriviated name
752 }
753
754 // set formfield coordinates
755 // this routine is needed due to field ordinates are not scaled and in user space
756 // to be called before form field call (or as width parameter)
757 // and just after with true argument to restore X Y ordinates.
758 /*private*/ function SetFieldXY( $x=NULL, $y=NULL, $w=0) {
759 static $savex;
760 static $savey;
761 static $restored = true;
762 $restoreXY = $x == NULL ? true : false;
763
764 if( $restored == $restoreXY )
765 $this->Error("internal Form Field save/restore error\n");
766 if( !$restoreXY ) {
767 /* save X Y ordinates */
768 $savex = $this->GetX(); $savey = $this->GetY();
769 // scale to user ordinates
770 $this->SetY( $this->S($y));
771 $this->SetX( $this->S($x));
772 } else {
773 /* restore X Y ordinates */
774 $this->SetY( $savey); // different from SetXY()
775 $this->SetX( $savex); // different from SetXY()
776 }
777 $restored = $restoreXY;
778 return( $this->S($w) );
779 }
780
781 // print Date on left or right side
782 /*private*/ function PrintDate( $x=10, $y=10, $dstrg="teus", $dvalue="1945-10-6", $field = NULL , $RL = 'L')
783 {
784 static $TextProps = array('strokeColor' => LLBLUE, 'value' => "", 'fillColor' => LBLUE , 'textSize' => '11', 'charLimit'=> 10);
785 $TextProps['userName'] = $this->unhtmlentities( _("yyyy-mm-dd") );
786
787 $this->SetFont( FONT, '', F_SIZE);
788 $this->SetXY($RL == 'L'? $x : $x-50, $y);
789 $this->Cell(50, 3, $dstrg, 0, 0, $RL);
790 if($dvalue) {
791 $this->SetXY($RL == 'L'? $x :$x-50, $y+3.5);
792 $this->SetFont(FONT, "B", F_SIZE);
793 $this->Cell(50, 3, $dvalue, 0 , 0, $RL);
794 }
795 if( $field == NULL ) return;
796 $TextProps['value'] = $dvalue;
797 $this->TextField($field, $this->SetFieldXY(($RL == 'L'? $x+1 : $x-17), ($y+3.5),17), 5, $TextProps );
798 $this->SetFieldXY();
799 }
800
801 // Add import HTML text eg from CCA
802 /*public*/ function PrintHTML( $url = NULL ) {
803 if( $url == NULL OR $url == "" ) return;
804 $error = ""; $title = ""; $url = POLICY.$url.EXT;
805 if( ! file_exists($url) ) $url = WEB."/".$url;
806 $data = file_get_contents($url);
807 if( !$data ) $error = "\nInternal Error: no ".$url." found.";
808 else {
809 $regs = array();
810 preg_match('/<[Tt][Ii][Tt][Ll][Ee][^>]*>/', $data, $regs);
811 if( count($regs) < 1 ) $error .= "\nInternal Error: no open tag title found on $url.";
812 else {
813 $start = strpos($data, $regs[0]) + strlen($regs[0]);
814 $data = substr($data, $start);
815 }
816 $regs = array();
817 preg_match('/<\/[Tt][Ii][Tt][Ll][Ee][^>]*>/', $data, $regs);
818 if( count($regs) < 1 ) $error .= "\nInternal Error: no close title tag found on $url.";
819 else {
820 $end = strpos($data, $regs[0]);
821 $title = trim(substr($data,0,$end));
822 $data = substr($data, $end+strlen($regs[0]));
823 }
824 $regs = array();
825 preg_match('/<[Bb][oO][Dd][yY][^>]*>/', $data, $regs);
826 if( count($regs) < 1 ) $error .= "\nInternal Error: no open html body tag found on $url.";
827 else {
828 $start = strpos($data, $regs[0]) + strlen($regs[0]);
829 $data = substr($data, $start);
830 }
831 $regs = array();
832 preg_match('/<\/[Bb][oO][Dd][yY][^>]*>/', $data, $regs);
833 if( count($regs) < 1 ) $error .= "\nInternal Error: no closing html body tag found on $url.";
834 else {
835 $end = strpos($data, $regs[0])-1;
836 $data = substr($data, 1, $end);
837 }
838 }
839 if( !$title ) $title = $url;
840 $this->SetCol();
841 $this->setFont(FONT, F_SIZE);
842 if( !$error ) {
843 $this->PrintHeader(_($title), $this->unhtmlentities( _('policy document') ), strncmp($url,WEB,strlen(WEB))==0? $url : (WEB."/".$url));
844 if( $title ) $this->Bookmark($title,0);
845 $this->writeHTMLCell($this->colwidth,2.5,$this->lMargin+1,$this->GetY()+2.5,
846 $data, 0,2,0,'L');
847 }
848 else
849 $this->MultiCell($this->colwidth, 3, $error);
850 }
851
852 /*private*/ function PrintCOAP($organisation = NULL, $registry = NULL, $assurer = NULL, $assurance = NULL){
853 $this->SetCol();
854 $this->PrintHeader($this->unhtmlentities( _('CAcert Organisation Assurance Programme'), _('Organisation Information (COAP) form'), defined('ASSCOAP')?ASSCOAP:"",defined('WEB')? WEB.substr(__FILE__, strrpos(__FILE__,"/")) : "") );
855 // define slighly different footer message
856 $this->myFooter("V". substr($this->Version(), 0, strpos($this->Version(), '.')).", ". $this->unhtmlentities( _('generated')." ".date("Y-n-j") ));
857 $this->AssuranceInfo();
858 $this->InfoOrganisation($organisation, $registry);
859 $this->StatementOrganisation($organisation);
860 $this->StatementAssurer( $assurer, $assurance );
861 }
862
863 //Add form and/or CCA (on duplex only when more as one page is printed)
864 /*public*/ function PrintForm( $organisation = NULL, $registry = NULL, $assurer = NULL, $page = NULL ) {
865
866 for($cnt=0 ; $cnt < $this->ncols; $cnt++ ) {
867 if( !isset( $page['form']) OR $page['form'] ) {
868 // the form is one page, use new room?
869 if ( $organisation == NULL OR $registry == NULL OR $assurer == NULL )
870 $this->Error("Organisation or Assurer data records failure");
871 $this->PrintCOAP( $organisation, $registry, $assurer);
872 }
873 // print off policy documents to be included in pdf file
874 foreach( $page['policies'] as $i => $file ) {
875 $this->Watermark = WATERMARK; // no watermark on these pages
876 if( $file ) $this->PrintHTML( $file );
877 }
878 if( $this->col > 0 OR $this->getPage() > 1 ) break;
879 }
880 if( $this->getPage() > 1 ) {
881 // and on duplex print back side with Community Agreement
882 if( $this->CurOrientation == 'P' )
883 $this->ViewerPrefs['Duplex'] = 'DuplexFlipLongEdge';
884 else
885 $this->ViewerPrefs['Duplex'] = 'DuplexFlipShortEdge';
886 }
887 // close up this column, make sure footer is printed.
888 $this->my_header_msg = NULL; $this->SetCol($this->col);
889 }
890
891 // Set form title (right align)
892 /*public*/ function PrintHeader($title1 = " ", $title2 = " " , $url1 = NULL, $url2 = NULL) {
893 // store current top margin value
894 $tSide = $this->tMargin;
895
896 // CAcert logo
897 // eps should be better, but it does not seem to work with CAcert logo
898 $this->rMargin -= 1;
899 $this->myFooter($title1,$url1);
900 $this->myHeader($title2,$url2);
901 if( LOGO_TYPE == '.eps' )
902 $this->ImageEPS(BW?LOGO.'mono'.LOGO_TYPE:LOGO.'colour'.LOGO_TYPE,
903 ($this->lMargin+$this->colwidth)-51,$tSide-3,51);
904 else
905 // png image 1000 X 229 * 8 bits
906 $this->Image(BW?LOGO.'mono'.LOGO_TYPE:LOGO.'colour'.LOGO_TYPE,
907 ($this->lMargin+$this->colwidth)-51,$tSide-3,51,0,0,
908 NULL,0,true,intval(LOGO_DPI));
909 $this->myLink($this->lMargin+$this->colwidth-51, $tSide-3,51,51/1000*229,WEB."/");
910 // form type
911 $this->SetFont(FONT,'B',F_SIZE+5);
912 $this->SetY($tSide+5); $this->SetX($this->lMargin);
913 $l = $this->GetStringWidth($title1);
914 $this->Cell($this->colwidth+1,14,$title1,0,0,'R',0,NULL);
915 if( $url1 != NULL AND $url1 != "" )
916 $this->myLink($this->lMargin+$this->colwidth-$l,$this->GetY()+5,$l,(F_SIZE+5)/2.9,$url1);
917 $this->Ln(5); $this->SetX($this->lMargin);
918 $l = $this->GetStringWidth($title2);
919 $this->Cell($this->colwidth+1,14,$title2,0,0,'R',0,NULL);
920 if( $url2 != NULL AND $url2 != "" )
921 $this->myLink($this->lMargin+$this->colwidth-$l,$this->GetY()+5,$l,(F_SIZE+5)/2.9,$url2);
922
923 // CAcert Inc. postbox address
924 $this->Ln(6); $this->SetX($this->lMargin);
925 $this->SetFont(FONT,'',F_SIZE);
926 $savex = $this->GetX(); $savey = $this->GetY();
927 $strg = POBOX ." - ". WEB;
928 $this->SetXY($this->lMargin+$this->colwidth-$this->GetStringWidth($strg)-1.1,$this->GetY()+3.5); // right align
929 if( !BW ) $this->SetTextColor(17,86,140);
930 $ret = $this->Write(0, $strg, NULL);
931 $l = $this->GetStringWidth($strg);
932 $this->myLink($this->lMargin+$this->colwidth-$l,$this->GetY()+0.5,$l,F_SIZE/2.9,WEB);
933 $this->Ln();
934 if( !BW ) $this->SetTextColor(0);
935 $this->SetXY($savex,$savey);
936
937 // sha1 fingerprint CAcert rootkeys class 1 and class 3
938 $strg = $this->unhtmlentities( _("CAcert's Root Certificate sha1 fingerprints") ) . ", class 1: ". CLASS1_SHA1 . ", class 3: " . CLASS3_SHA1;
939 $this->Ln(3); $this->SetX($this->lMargin);
940 $this->SetFont(FONT,'',F_SIZE * $this->colwidth / ($this->GetStringWidth($strg) +1));
941 $this->Cell($this->colwidth,10, $strg,0,0,'C',0,NULL);
942 $this->myLink($this->lMargin, $this->GetY()+4,$this->colwidth,F_SIZE/2.9,ROOTKEYS);
943 $this->SetLineWidth(0.1);
944 if ( BW ) { $this->SetDrawColor(195);
945 } else { $this->SetDrawColor(17,86,140);
946 }
947
948 $this->Line($this->lMargin, $tSide+25, $this->lMargin+$this->colwidth, $tSide+25);
949 $this->SetLineWidth(0.2); $this->SetDrawColor(0);
950 $this->rMargin += 1;
951 $this->SetXY($this->lMargin, $tSide+26); // top
952 }
953
954 // Set general form information
955 /*private*/ function PrintInfo( $strg = "", $url = "") {
956 // store current margin values
957
958 // Print text blurb paragraph at top of page
959 $this->SetFont(FONT,'',F_SIZE+0.5);
960 $this->SetXY($this->lMargin, $this->GetY()-1.5);
961 $y = $this->GetY(); $x = $this->GetX();
962 $cnt=$this->MultiCell($this->colwidth+1, 0, $strg,0,'L',0,2);
963 if ( $url != "" ) // link should be in user space
964 $this->myLink($x, $y, $this->colwidth, $this->GetY()-$y, $url);
965 return($cnt);
966 }
967
968 // print general CAP info
969 /*public*/ function AssuranceInfo( ) {
970 // store current margin values
971 $cellcnt = 0;
972 $this->SetY($this->GetY()+0.5);
973 $this->Bookmark($this->unhtmlentities( _('CAcert COAP form') ),0,$this->S($this->GetY()));
974
975 // Show text blurb at top of page
976 $strg = $this->unhtmlentities( _('The CAcert Organisation Programme (COAP) aims to verify the identity of the organisation.') );
977 $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.') );
978 $cellcnt += $this->PrintInfo( $strg, defined('ASSINTRO')? ASSINTRO:"");
979 $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:"") );
980 $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:"") );
981 $this->SetY($this->GetY()+0.3);
982 return( $cellcnt);
983 }
984
985 // print empty table with title for statements (called twice per table)
986 /*private*/ function PrintTable( $strg = NULL, $height = -1, $ext = 0 ) {
987 // store current margin values
988 static $tSide = -1;
989 static $title = "";
990 if( $height < 0 ) { // mark table position, leave room for title
991 if( $strg != "" ) $title = $strg;
992 if( $title == "" ) return ($this->GetY()); // nothing to do
993 $tSide = $this->GetY()+1;
994 // background
995 if ( BW ) {
996 $this->SetFillColor(195);
997 $this->SetDrawColor(195);
998 } else {
999 $this->SetFillColor(173,197,215);
1000 $this->SetDrawColor(173,197,215);
1001 }
1002 $this->Rect($this->lMargin-1,$tSide-1,1,9, "F");
1003 $this->Rect($this->lMargin-1,$tSide-1,$this->colwidth,1, "F");
1004 $this->SetFillColor(255);
1005 if ( BW ) { $this->SetFillColor(125);
1006 } else { $this->SetFillColor(17,86,140);
1007 }
1008 $this->Rect($this->lMargin,$tSide,$this->colwidth,7, "DF");
1009 $this->SetFillColor(255); $this->SetDrawColor(0);
1010
1011 $this->SetXY($this->lMargin+1, $tSide+0.6);
1012 $this->Bookmark($title,1,$this->S($tSide));
1013 $this->SetFont(FONT, '', F_SIZE+7);
1014 $this->SetTextColor(255);
1015 $this->Write(0, $title);
1016 $this->SetTextColor(0);
1017 $this->SetXY($this->lMargin+1, $tSide + 7);
1018 $tSide += 8; // save old top
1019 if ( $height != 0 ) return($this->GetY());
1020 }
1021 elseif( $tSide < 0 ) return( $this->GetY());
1022 if( $height == 0 ) { // interrupted bottum of column reached
1023 $height = $this-GetY() - $tSide; $save = $title;
1024 $this->PrintTable("", $height); // finish till bottumn page
1025 $tSide = $this->originalMargin;
1026 $title = $save;
1027 return( $this->GetY());
1028 }
1029 if( $strg != "" ) $title = $strg; // just to be defensive
1030
1031 // background
1032 if ( BW ) {
1033 $this->SetFillColor(195);
1034 $this->SetDrawColor(195);
1035 } else {
1036 $this->SetFillColor(173,197,215);
1037 $this->SetDrawColor(173,197,215);
1038 }
1039 $this->Rect($this->lMargin-1,$tSide,1,$height-1+$ext, "F");
1040 if( $ext )
1041 $this->Rect($this->lMargin-1,$tSide+$height,$this->colwidth,$ext, "F");
1042 $this->SetFillColor(255);
1043 // borders of the table left, bottumn, right
1044 $this->Line($this->lMargin,$tSide+$height-1, $this->lMargin, $tSide+$height);
1045 $this->Line($this->lMargin,$tSide+$height,$this->lMargin+$this->colwidth,$tSide+$height);
1046 $this->Line($this->lMargin+$this->colwidth,$tSide-1, $this->lMargin+$this->colwidth, $tSide+$height);
1047 $this->SetDrawColor(0);
1048 $this->SetY($tSide + $height + 1); // set Y ordinate to plus 7
1049 $tSide = -1; $title = "";
1050 return($this->GetY());
1051 }
1052
1053 // a name, email address, phone number
1054 /*private*/ function PrintName( $info = "", $title = "", $field = "", $name = "", $email = NULL, $phone = NULL, $backgrnd = false ) {
1055 static $TextProps = array('strokeColor'=> LLBLUE, 'value' => " ", 'fillColor'=> LBLUE, 'doNotScrole'=> 'false', 'textSize' => 10, 'rotate'=> '0');
1056
1057 // just once to recover from Acrobat 7.0 problem !!!!!!!!!!!!!!!!!!!!!!!!!!
1058 // make sure before the first time form field JS is called the fake is done
1059 static $AcrobatName = array('strokeColor'=> LLBLUE, 'fillColor'=> LLBLUE, 'readonly' => 'true');
1060 if( $AcrobatName != NULL ) {
1061 $this->TextField( 'NameNone', $this->SetFieldXY(300, $this->GetY()+2, 0), 0, $AcrobatName);
1062 $this->SetFieldXY(); $AcrobatName = NULL;
1063 }
1064 // end of Acrobat defeat !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1065 $cellcnt = 1; $msg = "";
1066 // put assurer help for assurance in pdf file for mouse over
1067 if ( $info != "" ) $msg = $info;
1068 if ( $email != NULL AND $email != "" AND $title != "" )
1069 $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.') );
1070 if( $msg != "" )
1071 $this->myLink($this->lMargin-7, $this->GetY()-1, 5, 3, $msg,
1072 array('subtype'=> 'Text', 'Open' => true,
1073 'c'=> array(173,197,215), 'name' => 'Comment',
1074 'f'=> array( 'nozoom', 'readonly', 'norotate'),
1075 't'=> $this->unhtmlentities( _('COAP form help') ))
1076 );
1077 if( $backgrnd ) {
1078 if ( BW ) {
1079 $this->SetFillColor(241);
1080 } else {
1081 //$this->SetFillColor(173,197,215);
1082 $this->SetFillColor(234, 241, 246);
1083 }
1084 $this->Rect($this->lMargin+37.5,$this->GetY()+0.1,
1085 $this->colwidth-38.5,
1086 ($email != NULL AND $email != "") ? 5.7 : 2.8,
1087 "F");
1088 $this->Rect($this->lMargin+1,$this->GetY()+0.1,
1089 35.5,
1090 ($email != NULL AND $email != "") ? 5.7 : 2.8,
1091 "F");
1092 $this->SetFillColor(255);
1093 }
1094 // assurer identity info
1095 $this->SetX($this->lMargin+1);
1096 $savey = $this->GetY();
1097 $this->SetFont(FONT, '', F_SIZE);
1098 $l = $this->GetStringWidth($title);
1099 //$l = ($l<=0? 0 : ($l < 35? 35 : $l));
1100 $l = $l < 35 ? 35 : $l;
1101 $this->Write(0, $title);
1102 $this->SetXY($this->lMargin+2+$l, $savey);
1103 if( $name ) {
1104 $this->SetFont(FONT, 'B', F_SIZE);
1105 $this->SetXY( $this->lMargin+2 + $l, $savey-1);
1106 $cellcnt += $this->MultiCell($this->colwidth-$l-3, 3, $name, 0, 1);
1107 if( function_exists('utf8_to_ascii') AND
1108 !utf8_is_ascii_ctrl( $name) )
1109 $ascii = utf8_to_ascii($name);
1110 else
1111 $ascii = "";
1112 if( $ascii == $name ) $ascii = "";
1113 if( $email != NULL ) $abbr = $this->Abbreviate( $name ); else $abbr="";
1114 if( $ascii != "" OR $abbr != "") {
1115 $la = $this->GetStringWidth($name) + 5;
1116 $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";
1117 if( $ascii != "" ) $msg .= '* '. $ascii . "\r\n";
1118 if( $abbr != "" ) $msg .= '* '. $abbr . "\r\n";
1119 $this->myLink($this->lMargin+$l+$la, $savey, 3, 2, $msg,
1120 array('subtype'=> 'Text', 'Open' => false,
1121 'c' => array(173,197,215), 'name' => 'Comment',
1122 'f'=> array( 'nozoom', 'readonly', 'norotate'),
1123 't' => $this->unhtmlentities( _('On the full name of the Assurer') )));
1124 }
1125 }
1126 $TextProps['value'] = $name ? $name : " ";
1127 $TextProps['userName'] = $this->unhtmlentities( _('Full exact name of the individual.') );
1128 $this->TextField($field.($email? 'Name' : ""), $this->SetFieldXY($this->lMargin+2+$l, $savey, $this->colwidth-$l-3-($phone?25:0)), 4.5, $TextProps );
1129 $this->SetFieldXY();
1130 if( $phone AND $phone != " " ) {
1131 $sx = $this->GetX(); $sy = $this->GetY();
1132 $this->SetFont(FONT, "", F_SIZE);
1133 $sw = $this->GetStringWidth($phone) + 2;
1134 $this->SetXY( $this->lMargin+$this->colwidth-$sw -4, $sy-4.8);
1135 $this->SetFont('zapfdingbats', "", F_SIZE+3);
1136 $this->Write(0, "&"); // telephone symbol
1137 $this->SetXY( $this->lMargin+$this->colwidth-$sw-1, $sy-4.1);
1138 $this->SetFont(FONT, "", F_SIZE);
1139 $this->Cell($sw+1,0,$phone);
1140 }
1141 if( $phone ) {
1142 $TextProps['value'] = $phone ? $phone : $this->unhtmlentities( _('phone nr') ) . "?";
1143 $TextProps['userName'] = $this->unhtmlentities( _('For organisation administrators and assurer: provide email address and optionally your phone number.') );
1144 $this->TextField($field.'Phone', $this->SetFieldXY($this->lMargin+$this->colwidth-25, $savey, 24), 4.5, $TextProps );
1145 $this->SetFieldXY();
1146 }
1147 $savey += 3;
1148 if( $email AND $email != " " ) {
1149 $this->SetXY($this->lMargin+2+$l, $savey); $cellcnt++;
1150 $this->SetFont(FONT, "", F_SIZE);
1151 if( !BW ) $this->SetTextColor(17,86,140);
1152 $this->Write(0, $email);
1153 $this->myLink($this->lMargin+$l, $savey,$this->GetStringWidth($email), 3, "mailto:". $email . "?subject=" . $this->unhtmlentities( _('Organisation Assurance') ));
1154 if( !BW ) $this->SetTextColor(0);
1155 }
1156 if( $email ) {
1157 $TextProps['value'] = $email ? $email : $this->unhtmlentities( _('email') ) . "?";
1158 $TextProps['userName'] = $this->unhtmlentities( _('For organisation administrators and assurer: provide email address and optionally your phone number.') );
1159 $this->TextField($field.'Email', $this->SetFieldXY($this->lMargin+2+$l, $savey, $this->colwidth-$l-28), 4.5, $TextProps);
1160 $this->SetFieldXY(); $savey += 3;
1161 }
1162 // phone number
1163 $this->SetXY($this->lMargin+2, $savey);
1164 return( $cellcnt );
1165 //$H = 5; // height of the name cell
1166 }
1167
1168 // All information of Applicant goes in one table
1169 /*public*/ function InfoOrganisation( $organisation = NULL, $registry = NULL ){
1170 // Applicant Identity information part
1171 $tSide = $this->PrintTable($this->unhtmlentities( _('Organisation Identity Information') ))+1;
1172
1173 $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.') );
1174 $msg .= "\r\nThe organisation administrator (a CAcert Assurer) email address must be the primary email address registered with CAcert.";
1175 // put hint on comparing names on title table
1176 $this->myLink($this->lMargin-7, $tSide-7, 5, 5, $msg,
1177 array('subtype'=> 'Text', 'Open' => true,
1178 'c'=> array(173,197,215), 'name' => 'Comment',
1179 'f'=> array( 'nozoom', 'readonly', 'norotate'),
1180 't'=> $this->unhtmlentities( _('On organisation identity information') )));
1181
1182 $this->SetXY($this->lMargin+1, $tSide);
1183 $this->PrintName(
1184 $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.') ),
1185 $this->unhtmlentities( _('Name of the organisation') )." ",
1186 "OrganisationNames0",
1187 $organisation['namecnt']>0?$organisation['names'][0]:" ",
1188 NULL, NULL, true);
1189 $this->PrintName(
1190 $this->unhtmlentities( _('The organisation address which should be equal to the address registered with the trade office.') ),
1191 $this->unhtmlentities( _('Address (comma separated)') )." ",
1192 "OrganisationAddress",
1193 $organisation['address'],
1194 NULL, NULL, true);
1195 $strg = "";
1196 foreach( array( $organisation['type'], $organisation['state'], $organisation['country']) as $i )
1197 if( $i != "" ) $strg .= ($strg != "" ? ", ": "") . $i;
1198 $this->PrintName(
1199 $this->unhtmlentities( _('The legal organisation type: eg Ltd, EPS, society, foundation, association, etc. The state/country under which jurisdiction the organisation operates.') ),
1200 $this->unhtmlentities( _('Type, jurisdiction (state)') )." ",
1201 "OrganisationType",
1202 $strg,
1203 NULL, NULL, true);
1204 //$this->Ln(0.4);
1205 $strg = $organisation['namecnt'] <= 1 ? "" : $organisation['names'][1];
1206 for( $i = 3; $i <= $organisation['namecnt']; $i++)
1207 $strg .= ", ". $organisation['names'][$i-1];
1208 $this->PrintName( $this->unhtmlentities( _('Other registered trade names of the organisation. (comma separated)') ),
1209 $this->unhtmlentities( _('Registered Trade Names') ), 'OrganisationDBA',
1210 $strg,
1211 NULL, NULL, true);
1212 //$this->Ln(0.4);
1213 $strg = "";
1214 foreach( array( $registry['identifier'], $registry['name'], $registry['region'], $registry['date'] ) as $i )
1215 if( $i != "" ) $strg .= ($strg != "" ? ", " : "") . $i;
1216 $this->PrintName(
1217 $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.') ),
1218 $this->unhtmlentities( _('Registration (id, name, region)') ),
1219 'torinfo',
1220 $strg,
1221 NULL, NULL, true);
1222 $this->Ln(0.4);
1223 $strg = ""; foreach( $organisation['domains'] as $i )
1224 $strg .= ($strg != "" ? ", " : "") . $i;
1225 $this->PrintName(
1226 $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.') ),
1227 $this->unhtmlentities( _('Internet Domain(s)') ),
1228 'OrganisationDomains',
1229 $strg,
1230 NULL, NULL, true);
1231 $this->Ln(0.4);
1232 // all (max) three names with ID type right aligned.
1233 // contact info o-admin address assuree
1234 $cnt = $organisation['admincnt'];
1235 $space = $this->getPageHeight()/$this->scale*100.0 -MINH ; // margin
1236 for( $i = 0; $i < $cnt; $i++ ) { // names to be printed
1237 $this->PrintName(
1238 $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.') ),
1239 $this->unhtmlentities( _('Organisation Administrator') ),
1240 sprintf("OrganisationAdmin%d",$i),
1241 $organisation['admins'][$i]['name'],
1242 $organisation['admins'][$i]['email']? $organisation['admins'][$i]['email']:" ",
1243 $organisation['admins'][$i]['phone']? $organisation['admins'][$i]['phone']:" ",
1244 TRUE);
1245 if( $space < $this->getY() ) break;
1246 }
1247 for( $j=0 ; $j < $i+3; $j++ ) {
1248 // empty fields up to max 3 empty fields and allowed space
1249 if( $space < $this->getY() ) break;
1250 $this->PrintName(
1251 $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.') ):"",
1252 $i+$j > 0? "": $this->unhtmlentities( _('Organisation Administrator') ),
1253 sprintf("OrganisationAdmin%d",$i+$j),
1254 "", " ", " ", TRUE);
1255 }
1256 $this->Ln(0.8);
1257 //$this->SetXY($this->lMargin+1, $this->GetY()+0.35);
1258 $next = $this->PrintTable( "", $this->GetY()-$tSide, 5);
1259 $this->SetY($next);
1260 }
1261
1262 // print marked paragraph in the table
1263 /*private*/ function PrintTicked( $strg = "", $tick = true ) {
1264 // store current margin values
1265 $savey = $this->GetY();
1266
1267 $celcnt = 0; $this->SetX($this->lMargin + 1);
1268 if( $tick ) {
1269 // use ✔ and ❑ of zapfdingbats font for OK tick
1270 $savex = $this->GetX();
1271 $this->SetXY($this->GetX(), $savey+0.9);
1272 $this->SetFont("zapfdingbats", F_SIZE+3);
1273 $this->Write(0,"q"); // ❑
1274 $this->SetXY($savex+0.1, $savey+0.1);
1275 if ( BW )
1276 $this->SetTextColor(80);
1277 else
1278 $this->SetTextColor(17, 86, 140);
1279 //$this->SetTextColor(0,92,0); // #00BE00 lime
1280 $this->Write(0,"4 ");// ✓
1281 $this->SetTextColor(0);
1282 }
1283 $this->SetXY($this->GetX(), $savey);
1284 $this->SetFont(FONT,'',F_SIZE+0.5);
1285 $celcnt = $this->MultiCell($this->lMargin+$this->colwidth-$this->GetX(), 3, $strg,0,'L');
1286 $this->SetXY($this->lMargin+1, $this->GetY()-1.5);
1287 return($celcnt);
1288 }
1289
1290 // assuree statement
1291 /*public*/ function StatementOrganisation( $organisation = NULL ) {
1292 // store current margin values
1293 $cellcnt = 0;
1294
1295 // assuree statement section
1296 $tSide = $this->PrintTable($this->unhtmlentities( _("Organisation's Statement") )); // mark table header
1297 $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.') );
1298 $msg .= "\r\nFor formal contact with the organisation the email address of the organisation is required.";
1299 // put hint on comparing names on title table
1300 $this->myLink($this->lMargin-7, $tSide-7, 5, 5, $msg,
1301 array('subtype'=> 'Text', 'Open' => true,
1302 'c'=> array(173,197,215), 'name'=> 'Comment',
1303 'f'=> array( 'nozoom', 'readonly', 'norotate'),
1304 't'=> $this->unhtmlentities( _("On director's statement") )));
1305
1306 $cellcnt += $this->PrintTicked( $this->unhtmlentities( _("Make sure you have read and agreed with the CAcert Community Agreement") ), false /* no tick */);
1307 if( !BW ) $this->SetTextColor(17, 86, 140);
1308 $this->SetXY($this->lMargin+2,$this->GetY()-0.5);
1309 $ret = $this->Write($this->lasth, WEB."/".POLICY.CCA.EXT, NULL);
1310 $this->myLink($this->lMargin+1, $this->GetY()-F_SIZE/2.9, $this->colwidth-2, F_SIZE*2.9/2.9, WEB."/".POLICY.CCA.EXT);
1311 $this->Ln(4);
1312 if( !BW ) $this->SetTextColor(0);
1313 $this->Ln(0.3);
1314
1315 $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.') ),
1316 $this->unhtmlentities( _('Director') ), "OrganisationDirector", $organisation['director'],
1317 $organisation['email']?$organisation['email'] : "email:",
1318 $organisation['phone']? $organisation['phone']:" ");
1319 $cellcnt += $this->PrintTicked( $this->unhtmlentities( _('I agree to the CAcert Community Agreement.') ), true /* tick */);
1320 $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 */);
1321 $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 */);
1322
1323 $this->Ln(0.5);
1324 $savey = $this->GetY();
1325 $strg = $this->unhtmlentities( _('Date') );
1326 if($organisation['date'] == "")
1327 $strg .= " (". $this->unhtmlentities( _("yyyy-mm-dd") ). ")";
1328 $strg = $strg;
1329 $this->PrintDate( $this->lMargin+1, $savey+1, $strg, $organisation['date'], 'OrganisationDate', 'L');
1330
1331 $strg = $this->unhtmlentities( _('Signature and organisation stamp') );
1332 $this->SetFont(FONT, '', F_SIZE);
1333 $l = $this->GetStringWidth( $strg );
1334 $this->SetXY($this->lMargin+$this->colwidth-$l-3, $savey+1);
1335 $this->Write(0, $strg); $this->Ln(7) ; // and leave some room
1336
1337 // draw the table borders and header at marked ordinate
1338 $next = $this->PrintTable("", $this->GetY()-$tSide);
1339
1340 $this->SetY($next);
1341 }
1342
1343 // assurer statement
1344 /*public*/ function StatementAssurer( $assurer = NULL ) {
1345 if( $assurer == NULL ) return;
1346
1347 // store current margin values
1348 $TextProps = array('strokeColor'=> LLBLUE, 'value' => "", 'fillColor'=> LBLUE, 'doNotScrole'=> 'true', 'textSize' => '14', 'rotate'=>0);
1349 $cellcnt = 0;
1350
1351 $tSide = $this->PrintTable($this->unhtmlentities( _("Organisation Assurer's Statement") )); // mark table ordinate
1352 // put assurer help for assurance in pdf file for mouse over
1353 $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.') );
1354 $this->myLink($this->lMargin-7, $tSide-6, 5, 5, $msg,
1355 array('subtype'=> 'Text', 'Open' => true,
1356 'c'=> array(173,197,215), 'name'=> 'Comment',
1357 'f'=> array( 'nozoom', 'readonly', 'norotate'),
1358 't'=> $this->unhtmlentities( _('On mutual assurance') )));
1359 // assurer identity info
1360 $this->Ln(0.9);
1361 $this->PrintName(
1362 $this->unhtmlentities( _('The Organisation Assurer contact information. This assurer will verify the organisation identity and registration information.') ),
1363 $this->unhtmlentities( _('Organisation Assurer') ) . " ","Assurer",
1364 $assurer['name'],
1365 $assurer['email']? $assurer['email']:" ",
1366 $assurer['phone']? $assurer['phone']:" ");
1367
1368 // assurer statements
1369 $this->SetY($this->GetY()-0.5);
1370 $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 */);
1371 $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 */);
1372 $this->Ln(1); $savey = $this->GetY();
1373
1374 $strg = $this->unhtmlentities( _('Date') );
1375 if( $assurer['date'] == "" ) $strg .= " (" . $this->unhtmlentities( _("yyyy-mm-dd") ).")";
1376 $strg = $strg;
1377 $this->PrintDate( $this->lMargin+1, $savey, $strg, $assurer['date'], 'AssurerDate', 'L');
1378
1379 $this->SetXY($this->lMargin+1, $savey);
1380 $this->SetFont(FONT, "",F_SIZE);
1381 $strg = $this->unhtmlentities( _("Organisation Assurer's signature") );
1382 $this->SetXY($this->lMargin+$this->colwidth-$this->GetStringWidth($strg)-3, $savey);
1383 $this->Write(0, $strg );
1384 $savey = $this->GetY()+7; // leave room for date and signature
1385 if( $this->GetPageHeight()/$this->scale*100.0-$savey > MARGIN+4)
1386 $savey += 2;
1387 $this->SetXY($this->lMargin+1, $savey);
1388 $l = $this->GetPageHeight()/$this->scale*100.0-$this->GetY() - MARGIN;
1389 if($l > 3 ) $l = 3; if( $l > 0 ) $this->Ln($l); // try to come close to margin
1390 $next = $this->PrintTable("", $this->GetY()-$tSide);
1391 $this->SetY($next);
1392 }
1393
1394 // End of CAPPDF TCPDF class extension
1395 }
1396
1397
1398 // --------------------------------------------------------------------------------
1399 // import environmental data -------------------------------------------------------
1400 // get $form, $orientation, $assuree, $assurer, $assurance info
1401 // FONT and BW are set already
1402
1403 // import info
1404 $utf8 = false;
1405 function GET( $key = "" ) {
1406 global $utf8;
1407 $strg = array_key_exists( $key, $_GET) ? $_GET[$key] : "";
1408 if(!$utf8 AND $strg != "" AND
1409 !utf8_is_ascii_ctrl($strg) AND
1410 !function_exists('utf8_to_ascii')) {
1411 $utf8 = true;
1412 }
1413 return( $strg );
1414 }
1415
1416 // form, CCA and page format info
1417 $page['format'] = strtolower(GET('format')); // A3, A4, A5, letter, legal, etc.
1418 if( !$page['format'] ) $page['format'] = 'a4'; // default a4, portrait
1419 // on landscape orientation we do two half pages
1420 $page['orientation'] = strtolower(GET('orientation'));
1421 if( $page['orientation'] != 'l' AND $page['orientation'] != "landscape" ) {
1422 $page['orientation'] = 'p'; // default is portrait and 1 up
1423 }
1424 $page['form'] = GET('noform') != "" ? false : true;
1425 // dft is now true it should go to true
1426 $page['policies'] = array();
1427 if( GET('nocca') == "" ) {
1428 if( defined('CCA') ) $page['policies'][] = CCA;
1429 }
1430 // set $page['form'] on 'simplex' or 'duplex' to get CCA on pdf page
1431
1432 // Assurer info
1433 $assurer = array ( 'name' => my_recode(GET('assurer')) ,
1434 'email' => my_recode(GET('assureremail')),
1435 'date' => my_recode(GET('assurerdate')),
1436 'phone' => my_recode(GET('assurerphone')),
1437 );
1438
1439 /*
1440 // assurance info
1441 $assurance = array ( 'location' => my_recode(GET('location')),
1442 'date' => my_recode(GET('assurancedate'))?my_recode(GET('assurancedate')):
1443 my_recode(GET('date')),
1444 'notes' => '' // not yet used
1445 );
1446 */
1447
1448 // trade office info
1449 $registry = array (
1450 'identifier' => my_recode(GET('identifier')),
1451 'date' => my_recode(GET('tordate')),
1452 'region' => my_recode(GET('torregion')),
1453 'name' => my_recode(GET('tor')),
1454 );
1455
1456 // Assuree info
1457 $organisation = array (
1458 'names' => array( ), // [0] full name, [>0] DBA's
1459 'namecnt' => 0,
1460 'date' => my_recode(GET('date')) == "now" ? date("Y-m-d") :
1461 my_recode(GET('date')),
1462 'address' => my_recode(GET('address')),
1463 'state' => my_recode(GET('state')),
1464 'country' => my_recode(GET('country')),
1465 'type' => my_recode(GET('type')),
1466 'director' => my_recode(GET('director')),
1467 'email' => my_recode(GET('email')),
1468 'phone' => my_recode(GET('phone')),
1469 'domains' => array(), // dns names for server certs
1470 'admincnt' => 0,
1471 'admins' => array(), // name, email, phone
1472 );
1473
1474 if( $assurer['date'] == "now" ) $assurer['date'] = date("Y-m-d");
1475 //if( $registry['date'] == "now" ) $registry['date'] = date("Y-m-d");
1476
1477 function Dstr( $first = "", $strg = "", $cnt = 0 ) {
1478 return( $cnt>0? sprintf("%s%d%s", $first, $cnt, $strg) : $first.$strg );
1479 }
1480 // company name info and trade names
1481 $j = 0; // after two successive empty names we stop
1482 for( $i = -1; $i <= 9 AND $j < 3; $i++) { // max 9 names we only print 4 max...
1483 $name = my_recode(GET(Dstr($i>=0? "dba" : "name", "", $i)));
1484 if( $name ) { $j = 0;
1485 $organisation[ 'namecnt' ]++;
1486 $organisation[ 'names' ] [] = $name;
1487 } else $j++;
1488 }
1489 // administrator info
1490 $j = 0; // after two successive empty names we stop
1491 for( $i = 0; $i <= 9 AND $j < 2; $i++) { // max 9 names we only print 4 max...
1492 $name = my_recode(GET(Dstr("admin", "", $i)));
1493 if( $name ) { $j = 0;
1494 $organisation[ 'admincnt' ]++;
1495 $organisation[ 'admins' ] [] = array (
1496 'name' => $name ? $name : "",
1497 'email' => my_recode(GET(Dstr("admin","email",$i))),
1498 'phone' => my_recode(GET(Dstr("admin","phone",$i))),
1499 );
1500 } else $j++;
1501 }
1502 // organisation domain names convert to array of lowercased names
1503 $j = 0; $domains = "";
1504 for( $i = 0; $i <= 25 AND $j < 2; $i++ ) {
1505 $name = my_recode(GET(Dstr("domain", "", $i)));
1506 if( $name ) { $j = 0;
1507 if( $domains != "" ) $domains .= ",";
1508 $domains .= strtolower($name);
1509 } else $j ++;
1510 }
1511 $i = 0;
1512 if( $domains ) { // csv list to array and trim white spaces
1513 $domains = strtok($domains,',');
1514 for( ; $domains != ""; $i++) {
1515 $organisation['domains'][$i] = trim($domains); $domains = strtok(',');
1516 }
1517 sort( $organisation['domains'] );
1518 } else $organisation['domains'][0] = " ";
1519 unset($domains);
1520
1521 // try to get policy documents names to be printed off
1522 $j = 0; // after two successive empty name we stop searching
1523 for( $i = 1; $i <= 9 AND $j<2; $i++ ) {
1524 $name = GET(sprintf("policy%d", $i));
1525 if( $name != "" ) { $page['policies'][] = $name; $j = 0; }
1526 else $j++;
1527 }
1528
1529 if( $utf8 ) { // have scanned arguments for non-ascii code now
1530 //require_once("../utf8/native/core.php");
1531 // only for to upper case require_once("../utf8/utils/unicode.php");
1532 require_once ( UTF8_ASCII );
1533 }
1534
1535 unset( $i ); unset( $j); unset( $utf8 ); // unset($_GET);
1536 // end of arguments imports
1537
1538 header("Expires: ".gmdate("D, j M Y G:i:s \G\M\T", time()+10800));
1539 header("Content-Disposition: attachment; filename=CAcert cap.pdf");
1540 header("Cache-Control: public, max-age=10800");
1541 header("Pragma: cache");
1542 // Content-Type and Content Length is done by tcpdf package
1543
1544 // create new PDF document =====================================================
1545 $pdf = new COAPPDF(
1546 /* PDF_PAGE_ORIENTATION */ $page['orientation'],
1547 PDF_UNIT /* mm */,
1548 /* PDF_PAGE_FORMAT */ $page['format'],
1549 true
1550 );
1551 $pdf->SetFormat( $page['format'] ); // set paper size scaling
1552
1553 // protection is encryption and this will cause 3.5 times performance loss
1554 // $pdf->SetProtection(array('print', 'annot-forms'));
1555
1556 // set document property information
1557 $pdf->SetCreator("LibreSSL - CAcert web application");
1558 $pdf->SetAuthor("© " . date("Y") . " CAcert Inc., Australia.");
1559 $pdf->SetKeywords("X.509, Organisation Assurance Programme, COAP form, digital certificates, CAcert, Community Agreement");
1560 $pdf->SetTitle("CAcert Organisation Assurance Programme");
1561 $pdf->SetSubject("COAP form V".$pdf->Version().", generated " . date("Y-n-j H:i:s T"));
1562 if( GET('watermark') != '') $pdf->Watermark = my_recode(GET('watermark'));
1563 // requires zlib and will decrease response time but increase bandwidth
1564 // if no zlib is found, automatically no compression is done
1565 $pdf->SetCompression(true); // turn it off when more pperformance is needed
1566
1567 // AddSJISFont function is not present in tcpdf package !!!!
1568
1569 //set auto page breaks
1570 $pdf->SetAutoPageBreak(TRUE, MARGIN*0.707);
1571
1572 //set image scale factor
1573 $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
1574
1575 //set some language-dependent strings
1576 $pdf->setLanguageArray($l);
1577
1578 //initialize document
1579 $pdf->AliasNbPages();
1580
1581 // AND GENERATE THE FORM ===================================
1582 // generation properties which have been set from environment:
1583 // BW (color), FONT (free Sans Vera), orientation (portrait, 1-up), format (A4)
1584 if ( FONT == 'SJIS') $pdf->AddSJISFont();
1585 $pdf->PrintForm($organisation, $registry, $assurer, $page);
1586 $pdf->setViewerPreferences($pdf->ViewerPrefs);
1587
1588 //Close and output PDF document
1589 $pdf->Output("CAcert COAP.pdf", "I");
1590
1591 //============================================================+
1592 // END OF FILE
1593 //============================================================+
1594 ?>