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