| Server IP : 172.67.201.108 / Your IP : 216.73.216.201 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/hotel-dev/public_html/mod/ |
Upload File : |
<?php include('_mod_security.php'); ?>
<?php
function update_concierge_nycahc(int $concierge_id = 0, string $first_name, string $last_name, string $email = NULL) {
global $db;
$sql = "UPDATE concierges SET " . sql_set_update() . ", nycahc_member = 1";
if (!empty($email)) :
$sql .= ", email_3 = {$email}";
endif;
$sql .= " WHERE concierge_id = {$concierge_id} ";
//echo '<br>SQL: ' . $sql;
//return;
try {
$db->query($sql);
} catch(PDOException $ex) {
die('Database Error! '.$ex->getMessage().' === '.$sql.' === ');
}
echo '<p>UPDATED: ';
echo 'ID: ' . $concierge_id . ' ';
echo 'First Name: ' . $first_name . ' ';
echo 'Last Name: ' . $last_name . ' ';
echo 'Email: ' . $email . ' ';
echo '</p>';
}
function insert_concierge_nycahc(string $first_name, string $last_name, string $email = NULL) {
global $db;
$sql = "
INSERT INTO concierges SET " . sql_set_create() . sql_set_update() . ",
first_name = {$first_name},
last_name = {$last_name},
hotel_id = 0,
title = 'Concierge',
nycahc_member = 1
";
if (!empty($email)) :
$sql .= ", primary_email = {$email}";
endif;
//echo '<br>SQL: ' . $sql;
//return;
try {
$db->query($sql);
$last_id = $db->lastInsertId();
} catch(PDOException $ex) {
die('Database Error! '.$ex->getMessage().' === '.$sql.' === ');
}
echo '<p>ADDED: ';
echo 'ID: ' . $last_id . ' ';
echo 'First Name: ' . $first_name . ' ';
echo 'Last Name: ' . $last_name . ' ';
echo 'Email: ' . $email . ' ';
echo '</p>';
}
//var_dump($_POST);
//var_dump($_GET);
$err_flag = false;
$validate_function = '';
if ($_POST['submitted'] == 1) :
//var_dump($_FILES);
if (!empty($_FILES['import_file']['name'])) :
$uploaddir = APP_UPLOAD_DIR.'/hoteldb/data_import/'.date('Y_m_d_H_i_s');
if (!is_dir($uploaddir)) :
//echo 'trying to make directory';
mkdir($uploaddir, 0777, true);
endif;
$uploadfile = $uploaddir.'/'.date("Ymd_His").'_'.basename($_FILES['import_file']['name']);
if (move_uploaded_file($_FILES['import_file']['tmp_name'], $uploadfile)) :
//echo 'File upload successful!';
//require_once dirname(__FILE__) . '/../vendor_classes/PHPExcel/IOFactory.php';
$file_type = strtoupper(\PhpOffice\PhpSpreadsheet\IOFactory::identify($uploadfile));
if (substr($file_type,0,5) == 'EXCEL' || $file_type == 'CSV') :
$objPHPExcel = \PhpOffice\PhpSpreadsheet\IOFactory::load($uploadfile);
$import_sheet_data = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true);
//var_dump($import_sheet_data);
if (count($import_sheet_data) <= 1 && count($import_sheet_data[1]) <= 1) :
$err_flag = true;
$form_message = "File does not appear to contain valid import data! Please select a valid Excel file to import.";
else :
if ($_POST['first_row_field_names'] == '1') :
$r_start = 2;
else :
$r_start = 1;
endif;
for ($r = $r_start; $r <= count($import_sheet_data); $r++) :
$email = $db->quote(trim(strip_tags($import_sheet_data[$r]['A'])));
$first_name = $db->quote(trim(strip_tags($import_sheet_data[$r]['B'])));
$last_name = $db->quote(trim(strip_tags($import_sheet_data[$r]['C'])));
//*********** Check by email **********
$sql = "
SELECT concierge_id FROM concierges WHERE
primary_email = {$email} OR
secondary_email = {$email} OR
email_3 = {$email} OR
email_4 = {$email}
ORDER BY update_date DESC
";
$result = $db->query($sql) or die('Database Error!');
if ($result->rowCount() > 0) :
$row = $result->fetch(PDO::FETCH_OBJ);
$concierge_id = $row->concierge_id;
update_concierge_nycahc($concierge_id, $first_name, $last_name,);
continue;
endif;
//*********** Check by name **********
$sql = "
SELECT concierge_id FROM concierges WHERE
first_name = {$first_name} AND
last_name = {$last_name}
ORDER BY update_date DESC
";
$result = $db->query($sql) or die('Database Error!');
if ($result->rowCount() > 0) :
$row = $result->fetch(PDO::FETCH_OBJ);
$concierge_id = $row->concierge_id;
update_concierge_nycahc($concierge_id, $first_name, $last_name, $email);
continue;
endif;
//*********** No match, insert new concierge record *******
insert_concierge_nycahc($first_name, $last_name, $email);
endfor;
endif;
else :
$err_flag = true;
$form_message = "File is invalid! Please select a valid Excel<sup>®</sup> file to import.";
endif;
else :
$err_flag = true;
$form_message = "File upload failed! Please select a valid Excel<sup>®</sup> file to import.";
endif;
else :
$err_flag = true;
$form_message = "Please specify import file.";
endif;
endif;
?>
<script>
var active_tab = '';
$(document).ready(function()
{
//switch_tab('<?php echo $active_tab; ?>');
$("#tab_content_general").show();
});
</script>
<h1>Data Load - NYCAHC</h1>
<?php echo form_message($form_message); ?>
<form name="frm_import" id="frm_import" method="post" action="" enctype="multipart/form-data" target="" >
<input name="submitted" type="hidden" value="1" />
<input name="active_tab" id="active_tab" type="hidden" value="general" />
<div class="cleardiv">
</div>
<div class="tab_content" id="tab_content_general" style="display:block; position:relative;">
<div class="form_header">
Import File Selection
</div>
Select Excel® file to import:
<input type="file" name="import_file" /><br /><br />
<input type="checkbox" name="first_row_field_names" value="1" /> First row contains field names
</div>
<!-- -------------------------------------------------------------------------------------------------------------- -->
<div class="form_strip">
<input type="submit" value="Submit" />
<input type="button" value="Cancel" onclick="window.location.href = 'index.php?IX=hotels';" />
</div>
</form>