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