| Server IP : 172.67.201.108 / Your IP : 216.73.216.11 Web Server : Apache/2.4.68 (Amazon Linux) OpenSSL/3.5.5 System : Linux ip-172-31-69-123.ec2.internal 6.1.176-223.369.amzn2023.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Jul 24 13:34:27 UTC 2026 x86_64 User : ec2-user ( 1000) PHP Version : 8.4.23 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/tgnewdev/mod/ |
Upload File : |
<?php require('_mod_security.php'); ?>
<?php
$event_slug = parse_uri('event_slug', 0, 'home', true);
if (!$row = load_event($event_slug)) :
return(page_404());
endif;
set_analytics_reference('get_tickets', $row->id);
$sql = "SELECT tt.*, COALESCE(SUM(p.qty), 0) AS tickets_sold, (tt.capacity - COALESCE(SUM(p.qty), 0)) AS tickets_remaining FROM ticket_tiers tt
LEFT JOIN payments p ON (p.ticket_tier_id = tt.id)
WHERE
tt.reference_type = 'event' AND tt.reference_id = " . nz($row->id, '0') . " AND tt.active = 1
GROUP BY tt.id
ORDER BY tt.price ASC
";
$result = $db->query($sql) or die('Database Error!');
$ar_ticket_tiers = $result->fetchAll(PDO::FETCH_ASSOC);
$form_success = false;
form_prep('', '', 'frm_purchase', false);
if (($_POST['form_submitted'] ?? '') === '1') :
if (submit_limiter_exceeded('purchase_form_submitted', 20)) :
echo '<h1>Sorry, you have exceeded your daily submission limit</h1>';
return;
endif;
form_prep_submit();
//form_validate_all();
form_validate('cust_first_name', 'string', true);
form_validate('cust_last_name', 'string', true);
form_validate('cust_street_1', 'string', true);
form_validate('cust_city', 'string', true);
form_validate('cust_state', 'string', true);
form_validate('cust_zip', 'string', true);
form_validate('cust_phone', 'string', true);
form_validate('cust_email', 'email', true);
if ($_POST['xsubmit'] !== 'Waitlist') :
form_validate('ticket_tier_id', 'int', true);
form_validate('qty', 'int', true);
endif;
form_validate('consent', 'int', true);
if ($_POST['xsubmit'] !== 'Waitlist') :
if (!$err_flag) :
$ticket_tier_id = $_POST['ticket_tier_id'];
$index = array_search($ticket_tier_id, array_column($ar_ticket_tiers, 'id'));
if ($index !== false) :
$ticket_tier = $ar_ticket_tiers[$index];
if ($ticket_tier['tickets_remaining'] < $_POST['qty']) :
$ar_err['qty'] = 'Ticket quantity no longer available!';
$err_flag = true;
elseif ($_POST['qty'] > max($ticket_tier['tickets_remaining'], 8)) :
$ar_err['qty'] = 'Ticket quantity invalid!';
$err_flag = true;
endif;
else :
$ar_err['ticket_tier_id'] = 'Invalid selection!';
$err_flag = true;
endif;
endif;
if (!$err_flag) :
$net_amt = ($ticket_tier['price'] + $ticket_tier['fee']) * $_POST['qty'];
$ar_search = array(' ', '-', '.');
$_POST['cc_number'] = str_replace($ar_search, '', $_POST['cc_number']);
if (empty($_POST['cc_number']) && $net_amt > 0.00) :
$ar_err['cc_number'] = 'Credit card required!';
$err_flag = true;
endif;
if ((empty($_POST['cc_exp_month']) || empty($_POST['cc_exp_year'])) && $net_amt > 0.00) :
$ar_err['cc_exp_month'] = 'Both required!';
$ar_err['cc_exp_year'] = 'Both required!';
$err_flag = true;
endif;
if (empty($_POST['cc_name']) && $net_amt > 0.00) :
$ar_err['cc_name'] = 'Credit card holder required!';
$err_flag = true;
endif;
if (empty($_POST['cc_cvv']) && $net_amt > 0.00) :
$ar_err['cc_cvv'] = 'Verification (CVV) code required!';
$err_flag = true;
endif;
endif;
if (!$err_flag) :
//************* Find customer (if exists) **************
$cust_id = lookup_db_field('customers', 'email', $_POST['cust_email'], 'id');
//***************** Process Payment ****************
$sku = 'Tickets: ' . $_POST['qty'] . ' X ' . $ticket_tier['sku_description'] . ' - ' . nzdate_display_datetime($row->start_time_local) . ' - ' . $row->name;
$location = '';
if (!empty($row->location_id)) :
$location_row = lookup_db_field('locations', 'id', $row->location_id, ['slug', 'name', 'address', 'phone']);
$location .= '<a href="' . APP_BASE_USER_SITE_SECURE . 'locations/' . $location_row['slug'] . '/">' . $location_row['name'];
if (!empty($location_row['address'])) :
$location .= '<br>' . $location_row['address'];
endif;
$location .= '</a>';
if (!empty($location_row['phone'])) :
$location .= '<br>' . $location_row['phone'];
endif;
elseif (!empty($row->submitted_location)) :
$location .= $row->submitted_location;
endif;
$pmt_result = process_payment(
$net_amt,
$_POST['cc_number'],
$_POST['cc_exp_month'],
$_POST['cc_exp_year'],
$_POST['cc_cvv'],
'INV-' . strval(next_id('payments')) . '-' . date('YmdHis'),
//$ticket_tier['id'] . ' - ' . $ticket_tier['reference_type'] . ' - ' . $ticket_tier['reference_id'] . ' - ' . $row->name,
$sku,
!empty($cust_id) ? strval($cust_id) : strval(next_id('customers')),
$_POST['cust_first_name'],
$_POST['cust_last_name'],
$_POST['cust_street_1'],
$_POST['cust_street_2'],
$_POST['cust_city'],
$_POST['cust_state'],
$_POST['cust_zip'],
$_POST['cust_phone'],
$_POST['cust_email'],
'',
'<a href="' . APP_BASE_USER_SITE_SECURE . 'events/' . $row->slug . '/">' . $row->name . '</a>',
date('l, F j, Y, g:i a', strtotime($row->start_time_local)),
$location,
$ticket_tier['sku_description'],
$_POST['qty'],
$row->internal_ticketing_instruction,
'<a style="font-size:17px; " href="' . APP_BASE_USER_SITE_SECURE . 'events/' . $row->slug . '/ical/"><br><strong>Add to Calendar</strong><br><img src="' . APP_BASE_USER_SITE_SECURE . 'img/calendar_icon.png" style="width:45px; outline:none; border:none;"></a>'
);
if ($pmt_result[0] === false) :
$ar_err['cc_number'] = 'Credit card transaction failed!';
$err_flag = true;
else :
$response = $pmt_result[1];
endif;
//**************************************************
endif;
else :
//************* Find customer (if exists) **************
$cust_id = lookup_db_field('customers', 'email', $_POST['cust_email'], 'id');
endif;
if (!$err_flag) :
try {
$db->beginTransaction();
$set = sql_set_update() .
"first_name = ".$db->quote($_POST['cust_first_name']).", ".
"last_name = ".$db->quote($_POST['cust_last_name']).", ".
"street_1 = ".$db->quote($_POST['cust_street_1']).", ".
"street_2 = ".$db->quote($_POST['cust_street_2']).", ".
"city = ".$db->quote($_POST['cust_city']).", ".
"state = ".$db->quote($_POST['cust_state']).", ".
"zip = ".$db->quote($_POST['cust_zip']).", ".
"phone = ".$db->quote($_POST['cust_phone']).", ".
"email = ".$db->quote($_POST['cust_email'])." "
;
if (!empty($cust_id)) :
$sql = "UPDATE customers SET ". $set . " WHERE id = " . nz($cust_id, '0');
else :
$sql = "INSERT INTO customers SET " . sql_set_create() . $set;
endif;
$db->query($sql);
if (empty($cust_id)) :
$cust_id = last_id();
endif;
if ($_POST['xsubmit'] !== 'Waitlist') :
$sql = "INSERT INTO payments SET " .
"ticket_tier_id = " . nz($ticket_tier['id'], '0') . ", " .
"reference_type = " . $db->quote($ticket_tier['reference_type']) . ", " .
"reference_id = " . nz($ticket_tier['reference_id'], '0') . ", " .
"sku_description = " . $db->quote($ticket_tier['sku_description']) . ", " .
"price = " . nzfloat($ticket_tier['price'], '0') . ", " .
"fee = " . nzfloat($ticket_tier['fee'], '0') . ", " .
"qty = " . nz($_POST['qty'], '0') . ", " .
"total_amt = " . nzfloat($net_amt, '0') . ", " .
"cust_id = " . nz($cust_id, '0') . ", " .
"cust_email = " . $db->quote($_POST['cust_email']) . ", " .
"cust_first_name = " . $db->quote($_POST['cust_first_name']) . ", " .
"cust_last_name = " . $db->quote($_POST['cust_last_name']) . ", " .
"cust_street_1 = " . $db->quote($_POST['cust_street_1']) . ", " .
"cust_street_2 = " . $db->quote($_POST['cust_street_2']) . ", " .
"cust_city = " . $db->quote($_POST['cust_city']) .", " .
"cust_state = " . $db->quote($_POST['cust_state']) . ", " .
"cust_zip = " . $db->quote($_POST['cust_zip']) . ", " .
"cust_phone = " . $db->quote($_POST['cust_phone']) . ", " .
"pmt_date = NOW(), " .
"pmt_cc = " . $db->quote(str_pad(substr($_POST['cc_number'], strlen($_POST['cc_number']) -4), 12, '*', STR_PAD_LEFT)) . ", " .
"pmt_amt = " . nzfloat($net_amt, '0') . ", " .
"pmt_cred_deb = 1, " .
"auth_code = " . $db->quote($response->authorization_code) . ", " .
"trans_id = " . $db->quote($response->transaction_id) . " "
;
else :
$sql = "INSERT INTO waitlist SET " .
"reference_type = " . $db->quote('event') . ", " .
"reference_id = " . nz($row->id, '0') . ", " .
"cust_id = " . nz($cust_id, '0') . ", " .
"cust_email = " . $db->quote($_POST['cust_email']) . ", " .
"cust_first_name = " . $db->quote($_POST['cust_first_name']) . ", " .
"cust_last_name = " . $db->quote($_POST['cust_last_name']) . ", " .
"cust_street_1 = " . $db->quote($_POST['cust_street_1']) . ", " .
"cust_street_2 = " . $db->quote($_POST['cust_street_2']) . ", " .
"cust_city = " . $db->quote($_POST['cust_city']) .", " .
"cust_state = " . $db->quote($_POST['cust_state']) . ", " .
"cust_zip = " . $db->quote($_POST['cust_zip']) . ", " .
"cust_phone = " . $db->quote($_POST['cust_phone']) . " "
;
endif;
$db->query($sql);
$db->commit();
} catch(Exception $e) {
db_err_rollback($e);
}
if ($_POST['xsubmit'] !== 'Waitlist') :
$form_message = "Thank you.<br>Your purchase has been processed. You will receive a confirmation by email.";
write_log('I', 0, 'purchase_form_submitted');
set_analytics_reference('tickets_purchased', $row->id);
else :
$form_message = "Thank you.<br>You have been added to our waitlist. You will be notified if an open slot becomes available.";
write_log('I', 0, 'purchase_form_waitlist');
set_analytics_reference('added_to_waitlist', $row->id);
endif;
$form_success = true;
else :
$form_message = "Errors found!";
endif;
endif;
?>
<script>
const ar_ticket_tiers = <?php echo json_encode($ar_ticket_tiers); ?>;
function ticket_tier_change(page_load = false) {
const tier_id = $('#ticket_tier_id').val();
const remaining = ar_ticket_tiers.find(t => t.id === Number(tier_id))?.tickets_remaining;
$('#qty option').each(function () {
const raw = $(this).val();
if (raw === '') {
return;
}
const val = parseInt(raw, 10);
if (tier_id === '' || val > remaining) {
$(this).hide();
} else {
$(this).show();
}
});
if (!page_load) {
$('#qty').val('').change();
}
}
function qty_change() {
const qty = parseInt(Number($('#qty').val()), 10);
const tier_id = $('#ticket_tier_id').val();
const tier = ar_ticket_tiers.find(t => t.id === Number(tier_id));
const price = Number(tier?.price) || 0;
const fee = Number(tier?.fee) || 0;
const total_amt = qty * (price + fee);
const formatted_amt = new Intl.NumberFormat('en-US', {
style: 'currency',
currency: 'USD'
}).format(total_amt);
$('#total_amt').text(formatted_amt);
if (total_amt > 0) {
$('#credit_card_section').show();
} else {
$('#credit_card_section').hide();
}
}
function customer_lookup() {
$.ajax({
url: "ajax.php?call=lookup_ajax&func=customer_lookup&email=" + $('#cust_email').val(),
cache: false,
dataType: "json",
success: function(json) {
if (json.result == 'Success') {
//$('#cust_first_name').val(json.first_name);
$('#cust_first_name').val() || $('#cust_first_name').val(json.first_name);
$('#cust_last_name').val() || $('#cust_last_name').val(json.last_name);
$('#cust_street_1').val() || $('#cust_street_1').val(json.street_1);
$('#cust_street_2').val() || $('#cust_street_2').val(json.street_2);
$('#cust_city').val() || $('#cust_city').val(json.city);
$('#cust_state').val() || $('#cust_state').val(json.state);
$('#cust_zip').val() || $('#cust_zip').val(json.zip);
$('#cust_phone').val() || $('#cust_phone').val(json.phone);
} else {
//alert(json.result);
}
}
,error: function (request, status, error) {
//alert(status + ", " + error);
}
})
}
$(document).ready(function() {
ticket_tier_change(true);
qty_change();
});
</script>
<?php
if (strtotime($row->start_time_local) < strtotime('now +30 minutes')) :
echo '<p class="announcement">This event has already taken place. Find a full list of upcoming events <a href="all-categories/">here</a>.</p>';
return;
endif;
if ($form_success) :
echo form_message($form_message, 'form_message_confirmation');
echo '<br><strong>Add to Calendar</strong>';
echo '<br><a href="events/' . $row->slug . '/ical/"><img src="img/calendar_icon.png" style="width:45px;"></a><br><br>';
echo '<button type="button" onclick="window.location.href = \'home\';">Continue</button>';
return;
endif;
$slug = parse_uri('slug', 0, 'home', true);
$sql = "SELECT * FROM articles WHERE slug = :slug AND post_status = 1 ORDER BY post_date DESC";
$stmt = $db->prepare($sql);
$stmt->execute([
':slug' => $slug,
]);
if ($row_article = $stmt->fetch(PDO::FETCH_OBJ)) :
echo '<h1>' . $row_article->post_title . '</h1>';
else :
echo '<h1>Get tickets / Register for an Event</h1>';
endif;
echo form_message($form_message);
if (!empty($row_article->featured_image)) :
echo '<img src="' . image_url_fix($row_article->featured_image, 'img/content/') . '" alt="' . $row_article->post_title . '">';
endif;
if (!empty($row_article->html)) :
echo '<div class="post_content">' . apply_shortcodes(format_html($row_article->html)) . '</div>';
endif;
echo '<hr>';
echo '<h2>' . $row->name . '</h2>';
echo '<h2>' . format_event_date_display($row->start_time_local, $row->end_time_local) . '</h2>';
echo '<hr>';
?>
<form name="frm_purchase" id="frm_purchase" class="standard_form" method="post" enctype="multipart/form-data" action="">
<input name="form_submitted" type="hidden" value="1" />
<?php
echo '<div class="ticket_form_box">';
form_field(['fname'=>'cust_email', 'ftype'=>'text', 'fsize'=>90, 'frequired'=>true, 'fdbname'=>'cust_email', 'flabel'=>'Your Email', 'tag_required'=>true, 'onchange'=>'customer_lookup();']);
form_field(['fname'=>'cust_first_name', 'ftype'=>'text', 'fsize'=>40, 'frequired'=>true, 'fdbname'=>'cust_first_name', 'flabel'=>'First Name', 'tag_required'=>true]);
form_field(['fname'=>'cust_last_name', 'ftype'=>'text', 'fsize'=>40, 'frequired'=>true, 'fdbname'=>'cust_last_name', 'flabel'=>'Last Name', 'tag_required'=>true]);
form_field(['fname'=>'cust_street_1', 'ftype'=>'text', 'fsize'=>90, 'frequired'=>true, 'fdbname'=>'cust_street_1', 'flabel'=>'Billing Street Address', 'tag_required'=>true]);
form_field(['fname'=>'cust_street_2', 'ftype'=>'text', 'fsize'=>90, 'frequired'=>false, 'fdbname'=>'cust_street_2', 'flabel'=>'', 'tag_required'=>false]);
form_field(['fname'=>'cust_city', 'ftype'=>'text', 'fsize'=>45, 'frequired'=>true, 'fdbname'=>'cust_city', 'flabel'=>'Billing City', 'tag_required'=>true]);
$sql = "SELECT state, CONCAT((CASE country_sort_code WHEN 1 THEN '' WHEN 2 THEN 'Canada - ' END), state_name) AS country_state FROM states WHERE country_sort_code IN (1,2) ORDER BY country_sort_code, state_name ";
$result = $db->query($sql) or die('Database Error!');
$ar_states = $result->fetchAll(PDO::FETCH_KEY_PAIR);
form_field(['fname'=>'cust_state', 'ftype'=>'select', 'fsize'=>15, 'frequired'=>true, 'fdbname'=>'cust_state', 'flabel'=>'Billing State', 'tag_required'=>true, 'ar_group'=>$ar_states]);
form_field(['fname'=>'cust_zip', 'ftype'=>'text', 'fsize'=>15, 'frequired'=>true, 'fdbname'=>'cust_zip', 'flabel'=>'Billing Zip Code', 'tag_required'=>true]);
form_field(['fname'=>'cust_phone', 'ftype'=>'text', 'fsize'=>15, 'frequired'=>true, 'fdbname'=>'cust_phone', 'flabel'=>'Phone Number', 'tag_required'=>true]);
echo '</div>'; //ticket_form_box
echo '<h3>Ticket Selection</h3>';
echo '<div class="ticket_form_box">';
//$ar_tiers = array_column($ar_ticket_tiers, 'sku_description', 'id');
$ar_tiers = [];
$sold_out_count = 0;
foreach ($ar_ticket_tiers as $ticket_tier) :
$low_warning = '';
if ($ticket_tier['tickets_sold'] >= $ticket_tier['capacity']) :
$low_warning = ' - Sold Out!';
$sold_out_count++;
elseif (($ticket_tier['capacity'] - $ticket_tier['tickets_sold']) < 10 ) :
$low_warning = ' - Almost Sold Out!';
endif;
$ar_tiers[$ticket_tier['id']] = $ticket_tier['sku_description'] . ' - Price: $' . $ticket_tier['price'] . ' - Fee: $' . $ticket_tier['fee'] . $low_warning;
endforeach;
$sold_out_event = false;
if ($sold_out_count > 0 && $sold_out_count == count($ar_ticket_tiers)) :
echo '<h3>This event has sold out. Click "waitlist" below to be added to our waitlist. You will be notified if an open slot becomes available.</h3>';
$submit_caption = 'Waitlist';
$sold_out_event = true;
else :
$submit_caption = 'Submit';
if (count($ar_ticket_tiers) === 1) :
$_POST['ticket_tier_id'] = $ticket_tier['id'];
endif;
form_field(['fname'=>'ticket_tier_id', 'ftype'=>'select', 'fsize'=>15, 'frequired'=>true, 'fdbname'=>'ticket_tier_id', 'flabel'=>'Select Ticket Option', 'tag_required'=>true, 'ar_group'=>$ar_tiers, 'onchange'=>'ticket_tier_change();']);
$ar_qty = [];
for ($i = 1; $i <= 8; $i++) :
$ar_qty[$i] = $i;
endfor;
form_field(['fname'=>'qty', 'ftype'=>'select', 'fsize'=>15, 'frequired'=>true, 'fdbname'=>'qty', 'flabel'=>'Select Quantity', 'tag_required'=>true, 'ar_group'=>$ar_qty, 'onchange'=>'qty_change();']);
endif;
echo '</div>'; //ticket_form_box
if (!$sold_out_event) :
echo '<h2>';
echo 'Total Amount: <span id="total_amt"></span>';
echo '</h2>';
endif;
echo '<div id="credit_card_section">';
echo '<h3>Payment Details</h3>';
echo '<div class="ticket_form_box">';
echo cc_images();
form_field(['fname'=>'cc_number', 'ftype'=>'text', 'fsize'=>16, 'frequired'=>true, 'fdbname'=>'cc_number', 'flabel'=>'Credit Card Number']);
$ar_months = [];
for ($mo = 1; $mo <= 12; $mo++) :
$ar_months[$mo] = date('F', mktime(0, 0, 0, $mo, 1));
endfor;
echo '<div style="width:45%; min-width:130px; display:inline-block; vertical-align:top;">';
form_field(['fname'=>'cc_exp_month', 'ftype'=>'select', 'fsize'=>15, 'frequired'=>true, 'fdbname'=>'cc_exp_month', 'flabel'=>'Exp. Month', 'ar_group'=>$ar_months]);
echo '</div>';
$ar_years = [];
$curr_year = date('Y');
for ($yr = $curr_year; $yr <= $curr_year + 15; $yr++) :
array_push($ar_years, $yr);
endfor;
echo '<div style="width:45%; min-width:130px; display:inline-block; vertical-align:top;">';
form_field(['fname'=>'cc_exp_year', 'ftype'=>'select', 'fsize'=>15, 'frequired'=>true, 'fdbname'=>'cc_exp_year', 'flabel'=>'Exp. Year', 'ar_group'=>$ar_years]);
echo '</div>';
echo '<div style="width:45%; min-width:130px; vertical-align:top;">';
form_field(['fname'=>'cc_cvv', 'ftype'=>'text', 'fsize'=>4, 'frequired'=>true, 'fdbname'=>'cc_cvv', 'flabel'=>'CVV (3 or 4 digits)']);
echo '</div>';
form_field(['fname'=>'cc_name', 'ftype'=>'text', 'fsize'=>40, 'frequired'=>true, 'fdbname'=>'cc_name', 'flabel'=>'Name on Card']);
echo '</div>'; //ticket_form_box
echo '</div>';
form_field(['fname'=>'consent', 'ftype'=>'checkbox', 'fdbname'=>'', 'frequired'=>true, 'flabel'=>'I consent to my submitted data being collected and stored as <a href="terms" target="_blank">outlined by the site</a>.', 'fstyle'=>'font-size:17px;', 'tag_required'=>true]);
?>
<?php form_button_strip('bottom', [
'save' => ['show' => $submit_caption === 'Submit', 'caption' => $submit_caption, 'js' => "sheet_dirty = false; this.form.requestSubmit();"],
'save_close' => ['show' => $submit_caption === 'Waitlist', 'caption' => $submit_caption, 'js' => "sheet_dirty = false; document.getElementById('xsubmit').value = this.value; this.form.submit();"],
'save_new' => ['show' => false, 'caption' => 'Save & New', 'js' => "sheet_dirty = false; document.getElementById('xsubmit').value = this.value; this.form.submit();"],
'cancel' => ['show' => true, 'caption' => 'Cancel', 'js' => "sheet_dirty = false; window.location.href = 'home';"],
], false); ?>
</form>