Add CSV Escaping to the Sample Export CSV Files
This commit is contained in:
@@ -995,6 +995,8 @@ if (isset($_GET['download_assets_csv_template'])) {
|
|||||||
$client_name = $row['client_name'];
|
$client_name = $row['client_name'];
|
||||||
|
|
||||||
$delimiter = ",";
|
$delimiter = ",";
|
||||||
|
$enclosure = '"';
|
||||||
|
$escape = '\\';
|
||||||
$filename = strtoAZaz09($client_name) . "-Assets-Template.csv";
|
$filename = strtoAZaz09($client_name) . "-Assets-Template.csv";
|
||||||
|
|
||||||
//create a file pointer
|
//create a file pointer
|
||||||
@@ -1002,7 +1004,7 @@ if (isset($_GET['download_assets_csv_template'])) {
|
|||||||
|
|
||||||
//set column headers
|
//set column headers
|
||||||
$fields = array('Name', 'Description', 'Type', 'Make', 'Model', 'Serial', 'OS', 'Purchase Date', 'Assigned To', 'Location', 'Physical Location', 'Notes');
|
$fields = array('Name', 'Description', 'Type', 'Make', 'Model', 'Serial', 'OS', 'Purchase Date', 'Assigned To', 'Location', 'Physical Location', 'Notes');
|
||||||
fputcsv($f, $fields, $delimiter);
|
fputcsv($f, $fields, $delimiter, $enclosure, $escape);
|
||||||
|
|
||||||
//move back to beginning of file
|
//move back to beginning of file
|
||||||
fseek($f, 0);
|
fseek($f, 0);
|
||||||
@@ -1619,6 +1621,8 @@ if (isset($_GET['download_client_asset_interfaces_csv_template'])) {
|
|||||||
$asset_name = $row['asset_name'];
|
$asset_name = $row['asset_name'];
|
||||||
|
|
||||||
$delimiter = ",";
|
$delimiter = ",";
|
||||||
|
$enclosure = '"';
|
||||||
|
$escape = '\\';
|
||||||
$filename = strtoAZaz09($asset_name) . "-Asset-Interfaces-Template.csv";
|
$filename = strtoAZaz09($asset_name) . "-Asset-Interfaces-Template.csv";
|
||||||
|
|
||||||
//create a file pointer
|
//create a file pointer
|
||||||
@@ -1626,7 +1630,7 @@ if (isset($_GET['download_client_asset_interfaces_csv_template'])) {
|
|||||||
|
|
||||||
//set column headers
|
//set column headers
|
||||||
$fields = array('Name', 'Description', 'Type', 'MAC', 'IP', 'NAT IP', 'IPv6', 'Network');
|
$fields = array('Name', 'Description', 'Type', 'MAC', 'IP', 'NAT IP', 'IPv6', 'Network');
|
||||||
fputcsv($f, $fields, $delimiter);
|
fputcsv($f, $fields, $delimiter, $enclosure, $escape);
|
||||||
|
|
||||||
//move back to beginning of file
|
//move back to beginning of file
|
||||||
fseek($f, 0);
|
fseek($f, 0);
|
||||||
|
|||||||
@@ -700,6 +700,8 @@ if (isset($_POST["import_clients_csv"])) {
|
|||||||
if (isset($_GET['download_clients_csv_template'])) {
|
if (isset($_GET['download_clients_csv_template'])) {
|
||||||
|
|
||||||
$delimiter = ",";
|
$delimiter = ",";
|
||||||
|
$enclosure = '"';
|
||||||
|
$escape = '\\'; // backsla
|
||||||
$filename = "Clients-Template.csv";
|
$filename = "Clients-Template.csv";
|
||||||
|
|
||||||
//create a file pointer
|
//create a file pointer
|
||||||
@@ -707,7 +709,7 @@ if (isset($_GET['download_clients_csv_template'])) {
|
|||||||
|
|
||||||
//set column headers
|
//set column headers
|
||||||
$fields = array('Client Name', 'Industry', 'Referral', 'Website', 'Primary Location Name', 'Location Phone', 'Location Address', 'City', 'State', 'Postal Code', 'Country', 'Primary Contact Name', 'Title', 'Contact Phone', 'Extension', 'Contact Mobile', 'Contact Email', 'Hourly Rate', 'Currency', 'Payment Terms', 'Tax ID', 'Abbreviation');
|
$fields = array('Client Name', 'Industry', 'Referral', 'Website', 'Primary Location Name', 'Location Phone', 'Location Address', 'City', 'State', 'Postal Code', 'Country', 'Primary Contact Name', 'Title', 'Contact Phone', 'Extension', 'Contact Mobile', 'Contact Email', 'Hourly Rate', 'Currency', 'Payment Terms', 'Tax ID', 'Abbreviation');
|
||||||
fputcsv($f, $fields, $delimiter);
|
fputcsv($f, $fields, $delimiter, $enclosure, $escape);
|
||||||
|
|
||||||
//move back to beginning of file
|
//move back to beginning of file
|
||||||
fseek($f, 0);
|
fseek($f, 0);
|
||||||
|
|||||||
@@ -1305,7 +1305,10 @@ if (isset($_POST["import_contacts_csv"])) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_GET['download_contacts_csv_template'])) {
|
if (isset($_GET['download_contacts_csv_template'])) {
|
||||||
|
|
||||||
$delimiter = ",";
|
$delimiter = ",";
|
||||||
|
$enclosure = '"';
|
||||||
|
$escape = '\\';
|
||||||
$filename = "Contacts-Template.csv";
|
$filename = "Contacts-Template.csv";
|
||||||
|
|
||||||
//create a file pointer
|
//create a file pointer
|
||||||
@@ -1322,7 +1325,7 @@ if (isset($_GET['download_contacts_csv_template'])) {
|
|||||||
'Mobile Phone ',
|
'Mobile Phone ',
|
||||||
'Office Location '
|
'Office Location '
|
||||||
);
|
);
|
||||||
fputcsv($f, $fields, $delimiter);
|
fputcsv($f, $fields, $delimiter, $enclosure, $escape);
|
||||||
|
|
||||||
//move back to beginning of file
|
//move back to beginning of file
|
||||||
fseek($f, 0);
|
fseek($f, 0);
|
||||||
|
|||||||
@@ -456,6 +456,8 @@ if (isset($_POST["import_credentials_csv"])) {
|
|||||||
if (isset($_GET['download_credentials_csv_template'])) {
|
if (isset($_GET['download_credentials_csv_template'])) {
|
||||||
|
|
||||||
$delimiter = ",";
|
$delimiter = ",";
|
||||||
|
$enclosure = '"';
|
||||||
|
$escape = '\\';
|
||||||
$filename = "Credentials-Template.csv";
|
$filename = "Credentials-Template.csv";
|
||||||
|
|
||||||
//create a file pointer
|
//create a file pointer
|
||||||
@@ -463,7 +465,7 @@ if (isset($_GET['download_credentials_csv_template'])) {
|
|||||||
|
|
||||||
//set column headers
|
//set column headers
|
||||||
$fields = array('Name', 'Description', 'Username', 'Password', 'TOTP', 'URI');
|
$fields = array('Name', 'Description', 'Username', 'Password', 'TOTP', 'URI');
|
||||||
fputcsv($f, $fields, $delimiter);
|
fputcsv($f, $fields, $delimiter, $enclosure, $escape);
|
||||||
|
|
||||||
//move back to beginning of file
|
//move back to beginning of file
|
||||||
fseek($f, 0);
|
fseek($f, 0);
|
||||||
|
|||||||
@@ -507,6 +507,8 @@ if (isset($_POST["import_locations_csv"])) {
|
|||||||
if(isset($_GET['download_locations_csv_template'])){
|
if(isset($_GET['download_locations_csv_template'])){
|
||||||
|
|
||||||
$delimiter = ",";
|
$delimiter = ",";
|
||||||
|
$enclosure = '"';
|
||||||
|
$escape = '\\';
|
||||||
$filename = "Locations-Template.csv";
|
$filename = "Locations-Template.csv";
|
||||||
|
|
||||||
//create a file pointer
|
//create a file pointer
|
||||||
@@ -514,7 +516,7 @@ if(isset($_GET['download_locations_csv_template'])){
|
|||||||
|
|
||||||
//set column headers
|
//set column headers
|
||||||
$fields = array('Name', 'Description', 'Address', 'City', 'State', 'Postal Code', 'Phone', 'Hours');
|
$fields = array('Name', 'Description', 'Address', 'City', 'State', 'Postal Code', 'Phone', 'Hours');
|
||||||
fputcsv($f, $fields, $delimiter);
|
fputcsv($f, $fields, $delimiter, $enclosure, $escape);
|
||||||
|
|
||||||
//move back to beginning of file
|
//move back to beginning of file
|
||||||
fseek($f, 0);
|
fseek($f, 0);
|
||||||
|
|||||||
Reference in New Issue
Block a user