Fix PHP 8.1 warnings
This commit is contained in:
parent
09219263e1
commit
d964f354db
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
The Initial Developer of the Original Code is
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
Portions created by the Initial Developer are Copyright (C) 2022
|
||||
Portions created by the Initial Developer are Copyright (C) 2008-2023
|
||||
the Initial Developer. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
|
|
@ -45,13 +45,13 @@
|
|||
$language = new text;
|
||||
$text = $language->get();
|
||||
|
||||
//built in str_getcsv requires PHP 5.3 or higher, this function can be used to reproduct the functionality but requirs PHP 5.1.0 or higher
|
||||
//built in str_getcsv requires PHP 5.3 or higher, this function can be used to reproduce the functionality but requires PHP 5.1.0 or higher
|
||||
if (!function_exists('str_getcsv')) {
|
||||
function str_getcsv($input, $delimiter = ",", $enclosure = '"', $escape = "\\") {
|
||||
$fp = fopen("php://memory", 'r+');
|
||||
fputs($fp, $input);
|
||||
rewind($fp);
|
||||
$data = fgetcsv($fp, null, $delimiter, $enclosure, $escape);
|
||||
$data = fgetcsv($fp, null, $delimiter, $enclosure); // $escape only got added in 5.3.0
|
||||
fclose($fp);
|
||||
return $data;
|
||||
}
|
||||
|
|
@ -61,29 +61,29 @@
|
|||
ini_set('max_execution_time', 7200);
|
||||
|
||||
//get the http get values and set them as php variables
|
||||
$action = $_POST["action"];
|
||||
$from_row = $_POST["from_row"];
|
||||
$delimiter = $_POST["data_delimiter"];
|
||||
$enclosure = $_POST["data_enclosure"];
|
||||
$action = $_POST["action"] ?? '';
|
||||
$from_row = $_POST["from_row"] ?? '';
|
||||
$delimiter = $_POST["data_delimiter"] ?? '';
|
||||
$enclosure = $_POST["data_enclosure"] ?? '';
|
||||
|
||||
//save the data to the csv file
|
||||
if (isset($_POST['data'])) {
|
||||
$file = $_SESSION['server']['temp']['dir']."/access_control_nodes-".$_SESSION['domain_name'].".csv";
|
||||
file_put_contents($file, $_POST['data']);
|
||||
if (file_put_contents($file, $_POST['data'])) {
|
||||
$_SESSION['file'] = $file;
|
||||
}
|
||||
}
|
||||
|
||||
//copy the csv file
|
||||
//$_POST['submit'] == "Upload" &&
|
||||
if ( is_uploaded_file($_FILES['ulfile']['tmp_name']) && permission_exists('contact_upload')) {
|
||||
if ($_POST['type'] == 'csv') {
|
||||
move_uploaded_file($_FILES['ulfile']['tmp_name'], $_SESSION['server']['temp']['dir'].'/'.$_FILES['ulfile']['name']);
|
||||
$save_msg = "Uploaded file to ".$_SESSION['server']['temp']['dir']."/". htmlentities($_FILES['ulfile']['name']);
|
||||
//system('chmod -R 744 '.$_SESSION['server']['temp']['dir'].'*');
|
||||
if (!empty($_FILES['ulfile']['tmp_name']) && is_uploaded_file($_FILES['ulfile']['tmp_name']) && permission_exists('access_control_node_add')) {
|
||||
if (!empty($_POST['type']) &&$_POST['type'] == 'csv') {
|
||||
$file = $_SESSION['server']['temp']['dir'].'/'.$_FILES['ulfile']['name'];
|
||||
if (move_uploaded_file($_FILES['ulfile']['tmp_name'], $file)) {
|
||||
$_SESSION['file'] = $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//get the schema
|
||||
if (!empty($delimiter)) {
|
||||
|
|
@ -97,7 +97,12 @@
|
|||
$i = 0;
|
||||
foreach ($apps[0]['db'] as $table) {
|
||||
//get the table name and parent name
|
||||
if (is_array($table["table"]['name'])) {
|
||||
$table_name = $table["table"]['name']['text'];
|
||||
}
|
||||
else {
|
||||
$table_name = $table["table"]['name'];
|
||||
}
|
||||
$parent_name = $table["table"]['parent'];
|
||||
|
||||
//remove the v_ table prefix
|
||||
|
|
@ -108,10 +113,12 @@
|
|||
$parent_name = substr($parent_name, 2);
|
||||
}
|
||||
|
||||
//filter for specific tables and build the schema array
|
||||
if ($table_name == 'access_control_nodes') {
|
||||
$schema[$i]['table'] = $table_name;
|
||||
$schema[$i]['parent'] = $parent_name;
|
||||
foreach($table['fields'] as $row) {
|
||||
$row['deprecated'] = $row['deprecated'] ?? '';
|
||||
if ($row['deprecated'] !== 'true') {
|
||||
if (is_array($row['name'])) {
|
||||
$field_name = $row['name']['text'];
|
||||
|
|
@ -122,10 +129,10 @@
|
|||
$schema[$i]['fields'][] = $field_name;
|
||||
}
|
||||
}
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//match the column names to the field names
|
||||
if (!empty($delimiter) && file_exists($_SESSION['file']) && $action != 'import') {
|
||||
|
|
@ -150,7 +157,7 @@
|
|||
echo "<form name='frmUpload' method='post' enctype='multipart/form-data'>\n";
|
||||
|
||||
echo "<div class='action_bar' id='action_bar'>\n";
|
||||
echo " <div class='heading'><b>".$text['header-import']."</b></div>\n";
|
||||
echo " <div class='heading'><b>".$text['label-import']."</b></div>\n";
|
||||
echo " <div class='actions'>\n";
|
||||
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','style'=>'margin-right: 15px;','link'=>'access_control_node_edit.php?id='.$_GET['id']]);
|
||||
echo button::create(['type'=>'submit','label'=>$text['button-import'],'icon'=>$_SESSION['theme']['button_icon_import'],'id'=>'btn_save']);
|
||||
|
|
@ -218,7 +225,7 @@
|
|||
}
|
||||
|
||||
//upload the csv
|
||||
if (file_exists($_SESSION['file']) && $action == 'import') {
|
||||
if (file_exists($_SESSION['file'] ?? '') && $action == 'import') {
|
||||
|
||||
//validate the token
|
||||
$token = new token;
|
||||
|
|
@ -229,8 +236,8 @@
|
|||
}
|
||||
|
||||
//user selected fields, labels
|
||||
$fields = $_POST['fields'];
|
||||
$labels = $_POST['labels'];
|
||||
$fields = $_POST['fields'] ?? '';
|
||||
$labels = $_POST['labels'] ?? '';
|
||||
|
||||
//set the domain_uuid
|
||||
$domain_uuid = $_SESSION['domain_uuid'];
|
||||
|
|
@ -320,8 +327,7 @@
|
|||
$row_id = 0;
|
||||
}
|
||||
|
||||
} //if ($from_row <= $row_number)
|
||||
unset($field_count);
|
||||
} //if ($from_row <= $row_id)
|
||||
$row_number++;
|
||||
$row_id++;
|
||||
} //end while
|
||||
|
|
@ -331,7 +337,7 @@
|
|||
//view_array($array);
|
||||
|
||||
//save to the data
|
||||
if (is_array($array)) {
|
||||
if (!empty($array)) {
|
||||
$database = new database;
|
||||
$database->app_name = 'access_controls';
|
||||
$database->app_uuid = '1416a250-f6e1-4edc-91a6-5c9b883638fd';
|
||||
|
|
@ -341,7 +347,7 @@
|
|||
|
||||
//send the redirect header
|
||||
header("Location: access_control_edit.php?id=".$_GET['id']);
|
||||
exit;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -350,14 +356,14 @@
|
|||
$token = $object->create($_SERVER['PHP_SELF']);
|
||||
|
||||
//include the header
|
||||
$document['title'] = $text['title-import'];
|
||||
$document['title'] = $text['label-import'];
|
||||
require_once "resources/header.php";
|
||||
|
||||
//show content
|
||||
echo "<form name='frmUpload' method='post' enctype='multipart/form-data'>\n";
|
||||
|
||||
echo "<div class='action_bar' id='action_bar'>\n";
|
||||
echo " <div class='heading'><b>".$text['header-import']."</b></div>\n";
|
||||
echo " <div class='heading'><b>".$text['label-import']."</b></div>\n";
|
||||
echo " <div class='actions'>\n";
|
||||
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','style'=>'margin-right: 15px;','link'=>'access_control_edit.php?id='.$_GET['id']]);
|
||||
echo button::create(['type'=>'submit','label'=>$text['button-continue'],'icon'=>$_SESSION['theme']['button_icon_upload'],'id'=>'btn_save']);
|
||||
|
|
@ -375,7 +381,7 @@
|
|||
echo " ".$text['label-import_data']."\n";
|
||||
echo "</td>\n";
|
||||
echo "<td width='70%' class='vtable' align='left'>\n";
|
||||
echo " <textarea name='data' id='data' class='formfld' style='width: 100%; min-height: 150px;' wrap='off'>$data</textarea>\n";
|
||||
echo " <textarea name='data' id='data' class='formfld' style='width: 100%; min-height: 150px;' wrap='off'></textarea>\n";
|
||||
echo "<br />\n";
|
||||
echo $text['description-import_data']."\n";
|
||||
echo "</td>\n";
|
||||
|
|
@ -438,8 +444,7 @@
|
|||
echo "</tr>\n";
|
||||
|
||||
echo "</table>\n";
|
||||
echo "<br />\n";
|
||||
echo "<br />\n";
|
||||
echo "<br /><br />\n";
|
||||
|
||||
echo "<input name='type' type='hidden' value='csv'>\n";
|
||||
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
|
||||
|
|
|
|||
|
|
@ -2055,31 +2055,31 @@ $text['label-summary']['zh-cn'] = "概括";
|
|||
$text['label-summary']['ja-jp'] = "まとめ";
|
||||
$text['label-summary']['ko-kr'] = "요약";
|
||||
|
||||
$text['header-import']['en-us'] = "Import";
|
||||
$text['header-import']['en-gb'] = "Import";
|
||||
$text['header-import']['ar-eg'] = "يستورد";
|
||||
$text['header-import']['de-at'] = "Importieren";
|
||||
$text['header-import']['de-ch'] = "Importieren";
|
||||
$text['header-import']['de-de'] = "Importieren";
|
||||
$text['header-import']['el-gr'] = "Εισαγωγή";
|
||||
$text['header-import']['es-cl'] = "Importar";
|
||||
$text['header-import']['es-mx'] = "Importar";
|
||||
$text['header-import']['fr-ca'] = "Importer";
|
||||
$text['header-import']['fr-fr'] = "Importer";
|
||||
$text['header-import']['he-il'] = "יְבוּא";
|
||||
$text['header-import']['it-it'] = "Importare";
|
||||
$text['header-import']['nl-nl'] = "Importeren";
|
||||
$text['header-import']['pl-pl'] = "Importuj";
|
||||
$text['header-import']['pt-br'] = "Importar";
|
||||
$text['header-import']['pt-pt'] = "Importat";
|
||||
$text['header-import']['ro-ro'] = "Import";
|
||||
$text['header-import']['ru-ru'] = "Импорт";
|
||||
$text['header-import']['sv-se'] = "Importera";
|
||||
$text['header-import']['uk-ua'] = "Імпорт";
|
||||
$text['header-import']['tr-tr'] = "İçe Aktar";
|
||||
$text['header-import']['zh-cn'] = "进口";
|
||||
$text['header-import']['ja-jp'] = "輸入";
|
||||
$text['header-import']['ko-kr'] = "수입";
|
||||
$text['label-import']['en-us'] = "Import";
|
||||
$text['label-import']['en-gb'] = "Import";
|
||||
$text['label-import']['ar-eg'] = "يستورد";
|
||||
$text['label-import']['de-at'] = "Importieren";
|
||||
$text['label-import']['de-ch'] = "Importieren";
|
||||
$text['label-import']['de-de'] = "Importieren";
|
||||
$text['label-import']['el-gr'] = "Εισαγωγή";
|
||||
$text['label-import']['es-cl'] = "Importar";
|
||||
$text['label-import']['es-mx'] = "Importar";
|
||||
$text['label-import']['fr-ca'] = "Importer";
|
||||
$text['label-import']['fr-fr'] = "Importer";
|
||||
$text['label-import']['he-il'] = "יְבוּא";
|
||||
$text['label-import']['it-it'] = "Importare";
|
||||
$text['label-import']['nl-nl'] = "Importeren";
|
||||
$text['label-import']['pl-pl'] = "Importuj";
|
||||
$text['label-import']['pt-br'] = "Importar";
|
||||
$text['label-import']['pt-pt'] = "Importat";
|
||||
$text['label-import']['ro-ro'] = "Import";
|
||||
$text['label-import']['ru-ru'] = "Импорт";
|
||||
$text['label-import']['sv-se'] = "Importera";
|
||||
$text['label-import']['uk-ua'] = "Імпорт";
|
||||
$text['label-import']['tr-tr'] = "İçe Aktar";
|
||||
$text['label-import']['zh-cn'] = "进口";
|
||||
$text['label-import']['ja-jp'] = "輸入";
|
||||
$text['label-import']['ko-kr'] = "수입";
|
||||
|
||||
$text['description-import']['en-us'] = "Upload delimited data to add multiple records.";
|
||||
$text['description-import']['en-gb'] = "Upload delimited data to add multiple records.";
|
||||
|
|
|
|||
Loading…
Reference in New Issue