-
Notifications
You must be signed in to change notification settings - Fork 1
/
voter_search.php
400 lines (347 loc) · 12 KB
/
voter_search.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
<?php
header("Location: http://data.lohud.com/tools/voterlookup/index.php");
die();
function cond_concat() {
$thestring = "";
$args = func_get_args();
foreach ($args as $arg) {
if (!empty($arg)) {
$thestring .= $arg . " ";
}
}
return $thestring;
};
if ($_GET['frm_area']) {
$area = htmlentities($_GET['frm_area']);
};
if ($_GET['frm_last']) {
$last = str_replace("'","''", htmlentities($_GET['frm_last']));
};
if ($_GET['frm_first']) {
$first = htmlentities($_GET['frm_first']);
};
if ($_GET['frm_city']) {
$city = htmlentities($_GET['frm_city']);
};
if ($_GET['frm_street']) {
$street = htmlentities($_GET['frm_street']);
};
//$tablename= "voter_reg_sw_0313";
$tablename= "voter_reg_sw_1015";
$where = " where 1";
if ($area=="lohud") {
$where .= " and countycode in ('44','60','40')";
}
if ($area=="nyc") {
$where .= " and countycode in ('31','43','24','41','3')";
}
if (!($area)) { // this is the opening screen
$tablename = "";
$txtmsg = "Use form above to search for voters";
}
if (strlen($area) < 3 && strlen($area) > 0) {
$where .= " and countycode = '" . $area . "'";
}
if(strlen($last) > 0) {
$where .= " and lastname like '" . $last . "%'";
}
if(strlen($first) > 0) {
$where .= " and firstname like '" . $first . "%'";
}
if(strlen($city) > 0) {
$where .= " and city = '" . $city . "'";
}
if(strlen($street) > 0) {
$where .= " and street like '%" . $street . "%'";
}
$from = " from {$tablename}";
$select = "select lastname, firstname, midname, housenum, street, city, zip5, towncity, dob, party, status, sregnumber";
$order = " ORDER BY lastname, firstname";
$sql = "$select$from$where$order";
// echo $sql;
include("../../js/header_newtemp.html");
$pageref = "Voter search";
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<!-- version 1.4.0 -->
<!-- Kai's ver, WIP update started on 3/8/16 -->
<!-- Good luck to those who are trying to troubbleshoot this page -->
<!-- Going to start off with cleaning up the indents so that the page can be SOMEWHAT readable -->
<!-- Jesus Christ I'd rather see M. Night Shyamalan's "Avatar The Last Airbender" on repeat for a full day -->
<title>NYS voter lookup</title>
<html>
<head>
<style type="text/css">
body {
background-color: #eee;
}
table.datagrid {
background-color: #eee;
font-family:Verdana, Arial, Helvetica, sans-serif;
font-size: 10pt;
border-collapse: collapse;
width: 750px;
}
.datagrid thead th {
color: white;
background-color: #ccc;
border-color: white #807070 #807070 white;
border-width: 1px;
border-style: solid;
text-align: left;
padding-left: 5px;
font-weight: bold;
}
/**
* Format the table cells
*/
.datagrid tbody td {
padding-left: 5px;
border: 1px solid #ddd;
background-color: white;
}
/*
* Format the alternate table columns
*/
.datagrid tbody td.col_1,
.datagrid tbody td.col_3, {
background-color: #eee;
}
/**
* No link underlining
*/
.datagrid tbody a {
text-decoration: underline;
}
/**
* Mouse overs
*/
.datagrid tbody td.mouseover {
background-color: #eee;
border-left: 1px solid #0A246A;
border-right: 1px solid #0A246A;
}
.datagrid tbody td.mouseover a {
background-color: #0A246A;
color: white;
}
// -->
</style>
</head>
<body>
<h2>New York State Voters Lookup</h3>
<p style="font-size:-1;">Data is as of October 2015</p>
<br>
<form id = "searchform" action = "voter_search.php" method = "GET" style="padding-bottom:20px;">
<fieldset>
<legend>Search options</legend>
<br clear = "left">
<label for "id_frm_area">Choose an area:</label>
<select name = "frm_area" id = "id_frm_area">
<option SELECTED= 1 value = "lohud">Lower Hudson Valley
<option value = "40">Putnam
<option value = "44">Rockland
<option value = "60">Westchester
<option value = "stw">Statewide name-only search
<option value = "nyc">New York City
<option value = '1'>Albany
<option value = '2'>Allegany
<option value = '3'>Bronx
<option value = '4'>Broome
<option value = '5'>Cattaraugus
<option value = '6'>Cayuga
<option value = '7'>Chautauqua
<option value = '8'>Chemung
<option value = '9'>Chenango
<option value = '10'>Clinton
<option value = '11'>Columbia
<option value = '12'>Cortland
<option value = '13'>Delaware
<option value = '14'>Duchess
<option value = '15'>Erie
<option value = '16'>Essex
<option value = '17'>Franklin
<option value = '18'>Fulton
<option value = '19'>Genesee
<option value = '20'>Greene
<option value = '21'>Hamilton
<option value = '22'>Herkimer
<option value = '23'>Jefferson
<option value = '24'>Kings
<option value = '25'>Lewis
<option value = '26'>Livingston
<option value = '27'>Madison
<option value = '28'>Monroe
<option value = '29'>Montgomery
<option value = '30'>Nassau
<option value = '31'>New York
<option value = '32'>Niagara
<option value = '33'>Oneida
<option value = '34'>Onondaga
<option value = '35'>Ontario
<option value = '36'>Orange
<option value = '37'>Orleans
<option value = '38'>Oswego
<option value = '39'>Otsego
<option value = '41'>Queens
<option value = '42'>Rensselaer
<option value = '43'>Richmond
<option value = '45'>St. Lawrence
<option value = '46'>Saratoga
<option value = '47'>Schenectady
<option value = '48'>Schoharie
<option value = '49'>Schuyler
<option value = '50'>Seneca
<option value = '51'>Steuben
<option value = '52'>Suffolk
<option value = '53'>Sullivan
<option value = '54'>Tioga
<option value = '55'>Tompkins
<option value = '56'>Ulster
<option value = '57'>Warren
<option value = '58'>Washington
<option value = '59'>Wayne
<option value = '61'>Wyoming
<option value = '62'>Yates
</select>
<br clear = "left">
<label for "id_frmlast">Enter part of last name</label>
<input type = "text" name = "frm_last" id = "id_frmlast"></input>
<br clear = "left">
<label for "id_frmfirst">Enter part of first name</label>
<input type = "text" name = "frm_first" id = "id_frmfirst"></input>
<br clear = "left">
<label for "id_frmfirst">If desired, specify city name (from mailing address)</label>
<input type = "text" name = "frm_city" id = "id_frmcity"></input>
<br clear = "left">
<label for "id_frmfirst">Enter street name keyword ("Main" not "Main Street")</label>
<input type = "text" name = "frm_street" id = "id_frmstreet"></input>
<br clear = "left">
<input type = "submit" value = "SUBMIT">
<input type=button value="NEW SEARCH" onClick="location.href='voter_search.php'">
</fieldset>
</form>
<?php
if(strlen($txtmsg)>0){ echo $txtmsg;}
else {
require_once('../../php/RGrid/RGrid.php');
$params['hostname'] = 'localhost';
$params['username'] = 'php_user';
$params['password'] = 'datadesk';
$params['database'] = 'voters';
function getQueryStringLocal($startnum = null,$exception = null)
{
if ($startnum === null) {
$startnum = !empty($_GET['start']) ? $_GET['start'] : 0;
}
$_GET['start'] = $startnum;
$qs = '';
foreach ($_GET as $k => $v) {
if(!($k == $exception))
$qs .= urlencode($k) . '=' . urlencode($v) . '&';
}
// If the query string is just a question mark, lose it
if ($qs == '?') {
$qs = '';
}
return preg_replace('/&$/', '', $qs);
}
$grid = RGrid::Create($params, $sql);
$grid->showHeaders = true;
// $select = "select lastname, firstname, midname, housenum, street, city, zip5, towncity, dob, party, status";
$grid->SetDisplayNames(array( 'lastname' => 'Name',
'housenum' => 'Address',
'towncity' => 'Municipality',
'dob' => 'DOB',
'party' => 'Party',
'status' => 'Status'
));
$grid->NoSpecialChars('lastname');
$grid->HideColumn('firstname', 'midname', 'street', 'city', 'zip5', 'sregnumber');
$grid->SetPerPage(10);
$grid->AddCallback('RowCallback');
function RowCallback(&$row) // The ampersand is so that any changes made are reflected in the final grid
{
$row['lastname'] = '<a href = "voter_detail.php?id=' . $row['sregnumber'] . '">' . $row['lastname'] . ", " . $row['firstname'] . " " . $row['midname'] . '</a>';
$row['housenum'] = $row['housenum'] . " " . $row['street'] . ", " . $row['city'] . " " . $row ['zip5'];
}
?>
<style type="text/css">
body {
background-color: #eee;
}
table.datagrid {
background-color: #eee;
font-family:Verdana, Arial, Helvetica, sans-serif;
font-size: 10pt;
border-collapse: collapse;
width: 750px;
}
.datagrid thead th {
color: white;
background-color: #ccc;
border-color: white #807070 #807070 white;
border-width: 1px;
border-style: solid;
text-align: left;
padding-left: 5px;
font-weight: bold;
}
/**
* Format the table cells
*/
.datagrid tbody td {
padding-left: 5px;
border: 1px solid #ddd;
background-color: white;
}
/*
* Format the alternate table columns
*/
.datagrid tbody td.col_1,
.datagrid tbody td.col_3, {
background-color: #eee;
}
/**
* No link underlining
*/
.datagrid tbody a {
text-decoration: underline;
}
/**
* Mouse overs
*/
.datagrid tbody td.mouseover {
background-color: #eee;
border-left: 1px solid #0A246A;
border-right: 1px solid #0A246A;
}
.datagrid tbody td.mouseover a {
background-color: #0A246A;
color: white;
}
// -->
</style>
<script language="javascript" type="text/javascript" defer="defer">
<!--
/**
*
*/
function TdMouseOver()
{
this.className += ' mouseover';
}
var elements = document.getElementsByTagName('td');
for (var i=0; i<elements.length; i++) {
elements[i].onmouseover = TdMouseOver;
}
// -->
</script>
<?php
$grid->Display();
} // end else
?>
</body>
</html>