Update destination_imports.php (#4266)

* Update destination_imports.php

* Update destination_imports.php
This commit is contained in:
AlexanderDCrane 2019-06-08 14:54:59 -06:00 committed by FusionPBX
parent 0d68e63e0e
commit aa31288df3
1 changed files with 41 additions and 34 deletions

View File

@ -112,10 +112,10 @@
//remove the v_ table prefix //remove the v_ table prefix
if (substr($table_name, 0, 2) == 'v_') { if (substr($table_name, 0, 2) == 'v_') {
$table_name = substr($table_name, 2); $table_name = substr($table_name, 2);
} }
if (substr($parent_name, 0, 2) == 'v_') { if (substr($parent_name, 0, 2) == 'v_') {
$parent_name = substr($parent_name, 2); $parent_name = substr($parent_name, 2);
} }
//filter for specific tables and build the schema array //filter for specific tables and build the schema array
@ -489,16 +489,16 @@
foreach($results as $row) { foreach($results as $row) {
echo "<tr>\n"; echo "<tr>\n";
echo " <td class='vncell' valign='top' align='left'>\n"; echo " <td class='vncell' valign='top' align='left'>\n";
echo $row['FirstName'] ." ".$row['LastName']; echo escape($row['FirstName'])." ".escape($row['LastName']);
echo " </td>\n"; echo " </td>\n";
echo " <td class='vncell' valign='top' align='left'>\n"; echo " <td class='vncell' valign='top' align='left'>\n";
echo $row['Company']."&nbsp;\n"; echo escape($row['Company'])."&nbsp;\n";
echo " </td>\n"; echo " </td>\n";
echo " <td class='vncell' valign='top' align='left'>\n"; echo " <td class='vncell' valign='top' align='left'>\n";
echo $row['EmailAddress']."&nbsp;\n"; echo escape($row['EmailAddress'])."&nbsp;\n";
echo " </td>\n"; echo " </td>\n";
echo " <td class='vncell' valign='top' align='left'>\n"; echo " <td class='vncell' valign='top' align='left'>\n";
echo $row['Web Page']."&nbsp;\n"; echo escape($row['Web Page'])."&nbsp;\n";
echo " </td>\n"; echo " </td>\n";
echo "</tr>\n"; echo "</tr>\n";
} }
@ -591,12 +591,13 @@
//get the dialplan uuid //get the dialplan uuid
if (strlen($row['destination_number']) == 0 || strlen($row['dialplan_uuid']) == 0 ) { if (strlen($row['destination_number']) == 0 || strlen($row['dialplan_uuid']) == 0 ) {
$sql = "select * from v_destinations "; $sql = "select * from v_destinations ";
$sql .= "where domain_uuid = '$domain_uuid' "; $sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and destination_number = '$destination_number'; "; $sql .= "and destination_number = :destination_number; ";
//echo $sql."<br />\n"; //echo $sql."<br />\n";
$prep_statement = $db->prepare(check_sql($sql)); $parameters['domain_uuid'] = $domain_uuid;
$prep_statement->execute(); $parameters['destination_number'] = $destination_number;
$destinations = $prep_statement->fetchAll(PDO::FETCH_NAMED); $database = new database;
$destinations = $database->select($sql, $parameters, 'all');
$row = $destinations[0]; $row = $destinations[0];
//add to the array //add to the array
@ -620,25 +621,28 @@
//delete the dialplan //delete the dialplan
if (strlen($row['dialplan_uuid']) > 0) { if (strlen($row['dialplan_uuid']) > 0) {
$sql = "delete from v_dialplan_details "; $sql = "delete from v_dialplan_details ";
$sql .= "where dialplan_uuid = '".$row['dialplan_uuid']."';"; $sql .= "where dialplan_uuid = :dialplan_uuid ";
//echo "$sql<br />\n"; //echo "$sql<br />\n";
$db->query($sql); $parameters['dialplan_uuid'] = $row['dialplan_uuid'];
unset($sql); $database = new database;
$database->execute($sql, $parameters);
$sql = "delete from v_dialplans "; $sql = "delete from v_dialplans ";
$sql .= "where dialplan_uuid = '".$row['dialplan_uuid']."';"; $sql .= "where dialplan_uuid = :dialplan_uuid ";
//echo "$sql<br />\n"; //echo "$sql<br />\n";
$db->query($sql); $parameters['dialplan_uuid'] = $row['dialplan_uuid'];
unset($sql); $database = dialplan_uuid database;
$database->execute($sql, $parameters);
} }
//delete the destinations //delete the destinations
if (strlen($row['destination_uuid']) > 0) { if (strlen($row['destination_uuid']) > 0) {
$sql = "delete from v_destinations "; $sql = "delete from v_destinations ";
$sql .= "where destination_uuid = '".$row['destination_uuid']."';"; $sql .= "where destination_uuid = :destination_uuid ";
//echo "$sql<br />\n"; //echo "$sql<br />\n";
$db->query($sql); $parameters['destination_uuid'] = $row['destination_uuid'];
unset($sql); $database = new database;
$database->execute($sql, $parameters);
} }
} //foreach } //foreach
@ -667,25 +671,28 @@
//delete the dialplan //delete the dialplan
if (strlen($row['dialplan_uuid']) > 0) { if (strlen($row['dialplan_uuid']) > 0) {
$sql = "delete from v_dialplan_details "; $sql = "delete from v_dialplan_details ";
$sql .= "where dialplan_uuid = '".$row['dialplan_uuid']."';"; $sql .= "where dialplan_uuid = :dialplan_uuid ";
//echo "$sql<br />\n"; //echo "$sql<br />\n";
$db->query($sql); $parameters['dialplan_uuid'] = $row['dialplan_uuid'];
unset($sql); $database = new database;
$database->execute($sql, $parameters);
$sql = "delete from v_dialplans "; $sql = "delete from v_dialplans ";
$sql .= "where dialplan_uuid = '".$row['dialplan_uuid']."';"; $sql .= "where dialplan_uuid = :dialplan_uuid ";
//echo "$sql<br />\n"; //echo "$sql<br />\n";
$db->query($sql); $parameters['dialplan_uuid'] = $row['dialplan_uuid'];
unset($sql); $database = new database;
$database->execute($sql, $parameters);
} }
//delete the destinations //delete the destinations
if (strlen($row['destination_uuid']) > 0) { if (strlen($row['destination_uuid']) > 0) {
$sql = "delete from v_destinations "; $sql = "delete from v_destinations ";
$sql .= "where destination_uuid = '".$row['destination_uuid']."';"; $sql .= "where destination_uuid = :destination_uuid ";
//echo "$sql<br />\n"; //echo "$sql<br />\n";
$db->query($sql); $parameters['destination_uuid'] = $row['destination_uuid'];
unset($sql); $database = new database;
$database->execute($sql, $parameters);
} }
} //foreach } //foreach
} }
@ -762,7 +769,7 @@
$selected = "selected='selected'"; $selected = "selected='selected'";
} }
if ($field !== 'domain_uuid') { if ($field !== 'domain_uuid') {
echo " <option value='".$row['table'].".".$field."' ".$selected.">".$field."</option>\n"; echo " <option value='".escape($row['table']).".".$field."' ".$selected.">".$field."</option>\n";
} }
} }
echo " </optgroup>\n"; echo " </optgroup>\n";
@ -822,7 +829,7 @@
echo " ".$text['label-destination_context']."\n"; echo " ".$text['label-destination_context']."\n";
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' align='left'>\n"; echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='destination_context' id='destination_context' maxlength='255' value=\"$destination_context\">\n"; echo " <input class='formfld' type='text' name='destination_context' id='destination_context' maxlength='255' value=\"".escape($destination_context)."\">\n";
echo "<br />\n"; echo "<br />\n";
echo $text['description-destination_context']."\n"; echo $text['description-destination_context']."\n";
echo "</td>\n"; echo "</td>\n";
@ -858,10 +865,10 @@
} }
foreach ($_SESSION['domains'] as $row) { foreach ($_SESSION['domains'] as $row) {
if ($row['domain_uuid'] == $domain_uuid) { if ($row['domain_uuid'] == $domain_uuid) {
echo " <option value='".$row['domain_uuid']."' selected='selected'>".$row['domain_name']."</option>\n"; echo " <option value='".escape($row['domain_uuid'])."' selected='selected'>".escape($row['domain_name'])."</option>\n";
} }
else { else {
echo " <option value='".$row['domain_uuid']."'>".$row['domain_name']."</option>\n"; echo " <option value='".escape($row['domain_uuid'])."'>".escape($row['domain_name'])."</option>\n";
} }
} }
echo " </select>\n"; echo " </select>\n";
@ -871,7 +878,7 @@
echo "</tr>\n"; echo "</tr>\n";
} }
else { else {
echo "<input type='hidden' name='domain_uuid' value='".$domain_uuid."'>\n"; echo "<input type='hidden' name='domain_uuid' value='".escape($domain_uuid)."'>\n";
} }
echo "<tr>\n"; echo "<tr>\n";