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