Update petition.php
[clinton/MarylandElectronicPetitionSignature.git] / soft_copy.php
1 <?php
2 include_once('/var/www/secure.php');
3 include_once('slack.php');
4 $id = intval($_GET['id']);
5 $q = "select * from signatures where id = '$id' ";
6 $r = $petition->query($q);
7 $d = mysqli_fetch_array($r);
8
9 $DOB = $d['date_of_birth'];
10 $SIGNED = $d['date_time_signed'];
11 $PETITION_ID = $d['petition_id'];
12 $signed_name_as = $d['signed_name_as'];
13 $signed_name_as_circulator = $d['signed_name_as_circulator'];
14 if ($_COOKIE['pVTRID'] != $d['VTRID']){
15 slack_general('SECURITY INVALID: soft_copy.php ('.$_COOKIE['invite'].')','md-petition');
16 die('Error #294');
17 }
18
19 $q2 = "select * from VoterList where VTRID = '$d[VTRID]' ";
20 $r2 = $petition->query($q2);
21 $d2 = mysqli_fetch_array($r2);
22 $FIRSTNAME = $d2['FIRSTNAME'];
23 $MIDDLENAME = $d2['MIDDLENAME'];
24 $LASTNAME = $d2['LASTNAME'];
25 $ADDRESS = $d2['ADDRESS'];
26 $RESIDENTIALCITY = $d2['RESIDENTIALCITY'];
27 $COUNTY = $d2['COUNTY'];
28 $RESIDENTIALZIP5 = $d2['RESIDENTIALZIP5'];
29 $full_name = "$FIRSTNAME $MIDDLENAME $LASTNAME";
30 $address = "$ADDRESS $RESIDENTIALCITY $RESIDENTIALZIP5";
31
32 $contact_phone = $d2['contact_phone'];
33
34
35 $qX = "select * from petitions where petition_id = '$PETITION_ID'";
36 $rX = $petition->query($qX);
37 $dX = mysqli_fetch_array($rX);
38
39 $hide_county = $dX['hide_county_on_petition'];
40 $offset_x = $dX['offset_x_cords'];
41 $offset_y = $dX['offset_y_cords'];
42 $offset_x_circulator = $dX['offset_x_cords_circulator'];
43 $offset_y_circulator = $dX['offset_y_cords_circulator'];
44
45 // imagettftext ( resource $image , float $size , float $angle , int $x , int $y , int $color , string $fontfile , string $text )
46 // x how far from left
47 // y how far from top
48
49
50 //Set the Content Type
51 header('Content-type: image/jpeg');
52
53 // Create Image From Existing File -- going to have to make this a reqired size??? 2550x3300
54 $jpg_image = imagecreatefromjpeg($dX['petition_jpg']);
55
56 // Allocate A Color For The Text
57 $black = imagecolorallocate($jpg_image, 0, 0, 0);
58
59 // Set Path to Font File
60 $font_path = 'files/coolvetica rg.ttf';
61 $font_path_sig = 'files/Claston Script.ttf';
62
63 if ($hide_county == 'NO'){
64 if ( $_COOKIE['pCOUNTY'] == 'Baltimore City'){
65 // City Checkbox
66 $cord = $dX['text_cord_cityX'];
67 $array = explode(",",$cord);
68 $debug = "$id : $cord : $array[0]";
69 imagettftext($jpg_image, $array[0], $array[1], $array[2], $array[3], $black, $font_path, 'X');
70 }else{
71 // County on Petition
72 $cord = $dX['text_cord_county'];
73 $array = explode(",",$cord);
74 imagettftext($jpg_image, $array[0], $array[1], $array[2], $array[3], $black, $font_path, str_replace('County','',$_COOKIE['pCOUNTY']) );
75 }
76 }
77 // name
78 imagettftext($jpg_image, 50, 0, 350+$offset_x, 1070+$offset_y, $black, $font_path, $full_name);
79 // signed
80 imagettftext($jpg_image, 70, 0, 400+$offset_x, 1180+$offset_y, $black, $font_path_sig, $signed_name_as);
81 // address
82 imagettftext($jpg_image, 50, 0, 400+$offset_x, 1300+$offset_y, $black, $font_path, $address);
83
84 // date of birth
85 if($DOB != ''){
86 imagettftext($jpg_image, 50, 0, 1900+$offset_x, 1070+$offset_y, $black, $font_path, date('m d Y',strtotime($DOB)));
87 }
88 // date signed
89 imagettftext($jpg_image, 50, 0, 1900+$offset_x, 1200+$offset_y, $black, $font_path, date('m d Y',strtotime($SIGNED)));
90
91
92 // name
93 imagettftext($jpg_image, 40, 0, 100+$offset_x_circulator, 2880+$offset_y_circulator, $black, $font_path, $_COOKIE['pNAME']);
94 // address
95 imagettftext($jpg_image, 40, 0, 100+$offset_x_circulator, 2975+$offset_y_circulator, $black, $font_path, $_COOKIE['pADDRESS1']);
96 // city state zip
97 imagettftext($jpg_image, 40, 0, 100+$offset_x_circulator, 3065+$offset_y_circulator, $black, $font_path, $_COOKIE['pADDRESS2']);
98 // phone
99 imagettftext($jpg_image, 40, 0, 100+$offset_x_circulator, 3160+$offset_y_circulator, $black, $font_path, $_COOKIE['pPHONE']);
100 // signed
101 imagettftext($jpg_image, 70, 0, 1290+$offset_x_circulator, 3160+$offset_y_circulator, $black, $font_path_sig, $signed_name_as_circulator);
102 // date signed
103 imagettftext($jpg_image, 50, 0, 2150+$offset_x_circulator, 3160+$offset_y_circulator, $black, $font_path, date('m / d / y',strtotime($SIGNED)));
104
105
106
107 // Send Image to Browser
108 imagejpeg($jpg_image);
109
110 // Clear Memory
111 imagedestroy($jpg_image);
112 ?>