Vars PHP 8.1 updates

This commit is contained in:
markjcrane 2023-05-27 13:06:32 -06:00
parent c92ebd8f0a
commit 2fd25f3621
4 changed files with 104 additions and 80 deletions

View File

@ -288,29 +288,29 @@ $text['header-hostname']['zh-cn'] = "主机名";
$text['header-hostname']['ja-jp'] = "ホスト名";
$text['header-hostname']['ko-kr'] = "호스트 이름";
$text['description-variables_advanced']['en-us'] = "Define preprocessor variables here. Can be accessed in the xml configuration with $.";
$text['description-variables_advanced']['en-gb'] = "Define preprocessor variables here. Can be accessed in the xml configuration with $.";
$text['description-variables_advanced']['ar-eg'] = "حدد متغيرات المعالج المسبق هنا. يمكن الوصول إليه في تكوين xml باستخدام $.";
$text['description-variables_advanced']['de-at'] = "Definieren Sie Preprozessor Variablen. Auf diese kann in der XML Konfiguration mittels $ zugegriffen werden.";
$text['description-variables_advanced']['de-ch'] = "Definieren Sie Preprozessor Variablen. Auf diese kann in der XML Konfiguration mittels $ zugegriffen werden.";
$text['description-variables_advanced']['de-de'] = "Definieren Sie Preprozessor Variablen. Auf diese kann in der XML Konfiguration mittels $ zugegriffen werden.";
$text['description-variables_advanced']['es-cl'] = "Defina variables de preprocesador aquí. Pueden ser accesadas en la configuración XML con $.";
$text['description-variables_advanced']['es-mx'] = "Defina variables de preprocesador aquí. Pueden ser accesadas en la configuración XML con $.";
$text['description-variables_advanced']['fr-ca'] = "Définir ici les variables préprocessées. Se retrouve dans la configuration XML avec $.";
$text['description-variables_advanced']['fr-fr'] = "Définir ici les variables préprocessées. Se retrouve dans la configuration XML avec $.";
$text['description-variables_advanced']['he-il'] = "הגדר כאן משתני קדם-מעבד. ניתן לגשת בתצורת xml עם $.";
$text['description-variables_advanced']['it-it'] = "Definire qui le variabili per il preprocessore. Possono essere usate nella configurazione xml con $.";
$text['description-variables_advanced']['nl-nl'] = "Definieer voorbewerkings variabelen. Kan in XML configuraties gebruikt worden met $.";
$text['description-variables_advanced']['pl-pl'] = "Tutaj zdefiniuj zmienne preprocesora. Mogą być dostępne w konfiguracji xml z $.";
$text['description-variables_advanced']['pt-br'] = "Defina as variáveis aqui. Podem ser acessadas na configuração XML com $";
$text['description-variables_advanced']['pt-pt'] = "Defina as variáveis aqui. Podem ser acedidas na configuração xml com $.";
$text['description-variables_advanced']['ro-ro'] = "Definiți aici variabilele preprocesorului. Poate fi accesat în configurația xml cu $.";
$text['description-variables_advanced']['ru-ru'] = "Определите здесь параметры FreeSwitch. Доступ к файлу xml можно получить с помощью $.";
$text['description-variables_advanced']['sv-se'] = "Definiera preprocessor variabler här. Kan nås i xml konfigurationen med $.";
$text['description-variables_advanced']['uk-ua'] = "Задайте змінні препроцесора тут. Вони будуть доступними в конфігурації XML з символом $.";
$text['description-variables_advanced']['zh-cn'] = "在这里定义预处理器变量。 可以在xml配置中用$访问。";
$text['description-variables_advanced']['ja-jp'] = "ここでプリプロセッサ変数を定義します。 XML 設定で $ を使用してアクセスできます。";
$text['description-variables_advanced']['ko-kr'] = "여기에서 전처리기 변수를 정의합니다. $를 사용하여 xml 구성에서 액세스할 수 있습니다.";
$text['description-variables_advanced']['en-us'] = "Define preprocessor variables here. Can be accessed in the xml configuration with \$.";
$text['description-variables_advanced']['en-gb'] = "Define preprocessor variables here. Can be accessed in the xml configuration with \$.";
$text['description-variables_advanced']['ar-eg'] = "حدد متغيرات المعالج المسبق هنا. يمكن الوصول إليه في تكوين xml باستخدام \$.";
$text['description-variables_advanced']['de-at'] = "Definieren Sie Preprozessor Variablen. Auf diese kann in der XML Konfiguration mittels \$ zugegriffen werden.";
$text['description-variables_advanced']['de-ch'] = "Definieren Sie Preprozessor Variablen. Auf diese kann in der XML Konfiguration mittels \$ zugegriffen werden.";
$text['description-variables_advanced']['de-de'] = "Definieren Sie Preprozessor Variablen. Auf diese kann in der XML Konfiguration mittels \$ zugegriffen werden.";
$text['description-variables_advanced']['es-cl'] = "Defina variables de preprocesador aquí. Pueden ser accesadas en la configuración XML con \$.";
$text['description-variables_advanced']['es-mx'] = "Defina variables de preprocesador aquí. Pueden ser accesadas en la configuración XML con \$.";
$text['description-variables_advanced']['fr-ca'] = "Définir ici les variables préprocessées. Se retrouve dans la configuration XML avec \$.";
$text['description-variables_advanced']['fr-fr'] = "Définir ici les variables préprocessées. Se retrouve dans la configuration XML avec \$.";
$text['description-variables_advanced']['he-il'] = "הגדר כאן משתני קדם-מעבד. ניתן לגשת בתצורת xml עם \$.";
$text['description-variables_advanced']['it-it'] = "Definire qui le variabili per il preprocessore. Possono essere usate nella configurazione xml con \$.";
$text['description-variables_advanced']['nl-nl'] = "Definieer voorbewerkings variabelen. Kan in XML configuraties gebruikt worden met \$.";
$text['description-variables_advanced']['pl-pl'] = "Tutaj zdefiniuj zmienne preprocesora. Mogą być dostępne w konfiguracji xml z \$.";
$text['description-variables_advanced']['pt-br'] = "Defina as variáveis aqui. Podem ser acessadas na configuração XML com \$";
$text['description-variables_advanced']['pt-pt'] = "Defina as variáveis aqui. Podem ser acedidas na configuração xml com \$.";
$text['description-variables_advanced']['ro-ro'] = "Definiți aici variabilele preprocesorului. Poate fi accesat în configurația xml cu \$.";
$text['description-variables_advanced']['ru-ru'] = "Определите здесь параметры FreeSwitch. Доступ к файлу xml можно получить с помощью \$.";
$text['description-variables_advanced']['sv-se'] = "Definiera preprocessor variabler här. Kan nås i xml konfigurationen med \$.";
$text['description-variables_advanced']['uk-ua'] = "Задайте змінні препроцесора тут. Вони будуть доступними в конфігурації XML з символом \$.";
$text['description-variables_advanced']['zh-cn'] = "在这里定义预处理器变量。 可以在xml配置中用\$访问。";
$text['description-variables_advanced']['ja-jp'] = "ここでプリプロセッサ変数を定義します。 XML 設定で \$ を使用してアクセスできます。";
$text['description-variables_advanced']['ko-kr'] = "여기에서 전처리기 변수를 정의합니다. \$ 사용하여 xml 구성에서 액세스할 수 있습니다.";
$text['description-variables']['en-us'] = "Define preprocessor variables here. A switch restart is required for changes to take effect.";
$text['description-variables']['en-gb'] = "Define preprocessor variables here. A switch restart is required for changes to take effect.";

View File

@ -76,17 +76,17 @@ if (!class_exists('vars')) {
}
//delete multiple records
if (is_array($records) && @sizeof($records) != 0) {
if (!empty($records) && @sizeof($records) != 0) {
//build the delete array
foreach ($records as $x => $record) {
if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
if (!empty($record['checked']) && $record['checked'] == 'true' && is_uuid($record['uuid'])) {
$array[$this->table][$x][$this->uuid_prefix.'uuid'] = $record['uuid'];
}
}
//delete the checked rows
if (is_array($array) && @sizeof($array) != 0) {
if (!empty($array) && @sizeof($array) != 0) {
//execute delete
$database = new database;
@ -128,20 +128,20 @@ if (!class_exists('vars')) {
}
//toggle the checked records
if (is_array($records) && @sizeof($records) != 0) {
if (!empty($records) && @sizeof($records) != 0) {
//get current toggle state
foreach ($records as $x => $record) {
if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
if (!empty($record['checked']) && $record['checked'] == 'true' && is_uuid($record['uuid'])) {
$uuids[] = "'".$record['uuid']."'";
}
}
if (is_array($uuids) && @sizeof($uuids) != 0) {
if (!empty($uuids) && @sizeof($uuids) != 0) {
$sql = "select ".$this->uuid_prefix."uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." ";
$sql .= "where ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
$rows = $database->select($sql, null, 'all');
if (!empty($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) {
$states[$row['uuid']] = $row['toggle'];
}
@ -158,7 +158,7 @@ if (!class_exists('vars')) {
}
//save the changes
if (is_array($array) && @sizeof($array) != 0) {
if (!empty($array) && @sizeof($array) != 0) {
//save the array
$database = new database;
@ -201,22 +201,22 @@ if (!class_exists('vars')) {
}
//copy the checked records
if (is_array($records) && @sizeof($records) != 0) {
if (!empty($records) && @sizeof($records) != 0) {
//get checked records
foreach ($records as $x => $record) {
if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
if (!empty($record['checked']) && $record['checked'] == 'true' && is_uuid($record['uuid'])) {
$uuids[] = "'".$record['uuid']."'";
}
}
//create insert array from existing data
if (is_array($uuids) && @sizeof($uuids) != 0) {
if (!empty($uuids) && @sizeof($uuids) != 0) {
$sql = "select * from v_".$this->table." ";
$sql .= "where ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
$rows = $database->select($sql, null, 'all');
if (!empty($rows) && @sizeof($rows) != 0) {
foreach ($rows as $x => $row) {
//copy data
@ -224,7 +224,7 @@ if (!class_exists('vars')) {
//overwrite
$array[$this->table][$x][$this->uuid_prefix.'uuid'] = uuid();
$array[$this->table][$x]['var_description'] = base64_encode(trim(base64_decode($row['var_description'])).' ('.$text['label-copy'].')');
$array[$this->table][$x]['var_description'] = trim($row['var_description']).' ('.$text['label-copy'].')';
}
}
@ -232,7 +232,7 @@ if (!class_exists('vars')) {
}
//save the changes and set the message
if (is_array($array) && @sizeof($array) != 0) {
if (!empty($array) && @sizeof($array) != 0) {
//save the array
$database = new database;

View File

@ -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) 2008-2020
Portions created by the Initial Developer are Copyright (C) 2008-2023
the Initial Developer. All Rights Reserved.
Contributor(s):
@ -46,7 +46,7 @@
$text = $language->get();
//set the action as an add or an update
if (is_uuid($_REQUEST["id"])) {
if (!empty($_REQUEST["id"]) && is_uuid($_REQUEST["id"])) {
$action = "update";
$var_uuid = $_REQUEST["id"];
}
@ -54,8 +54,18 @@
$action = "add";
}
//define the variables
$var_category = '';
$var_name = '';
$var_value = '';
$var_command = '';
$var_hostname = '';
$var_enabled = '';
$var_order = '';
$var_description = '';
//set http values as php variables
if (count($_POST) > 0) {
if (!empty($_POST)) {
$var_category = trim($_POST["var_category"]);
$var_name = trim($_POST["var_name"]);
$var_value = trim($_POST["var_value"]);
@ -64,7 +74,6 @@
$var_enabled = trim($_POST["var_enabled"] ?: 'false');
$var_order = trim($_POST["var_order"]);
$var_description = trim($_POST["var_description"]);
$var_description = str_replace("''", "'", $var_description);
if (!empty($_POST["var_category_other"])) {
$var_category = trim($_POST["var_category_other"]);
@ -72,7 +81,7 @@
}
//process the post
if (count($_POST) > 0 && empty($_POST["persistformvar"])) {
if (!empty($_POST) && empty($_POST["persistformvar"])) {
//get the uuid
if ($action == "update") {
@ -131,10 +140,10 @@
$array['vars'][0]['var_name'] = $var_name;
$array['vars'][0]['var_value'] = $var_value;
$array['vars'][0]['var_command'] = $var_command;
$array['vars'][0]['var_hostname'] = $var_hostname != '' ? $var_hostname : null;
$array['vars'][0]['var_hostname'] = !empty($var_hostname) ? $var_hostname : null;
$array['vars'][0]['var_enabled'] = $var_enabled;
$array['vars'][0]['var_order'] = $var_order;
$array['vars'][0]['var_description'] = base64_encode($var_description);
$array['vars'][0]['var_description'] = $var_description;
//execute insert/update
$database = new database;
@ -158,7 +167,7 @@
}
//pre-populate the form
if (is_array($_GET) && is_uuid($_GET["id"]) && $_POST["persistformvar"] != "true") {
if (!empty($_GET["id"]) && is_uuid($_GET["id"]) && empty($_POST["persistformvar"])) {
$var_uuid = $_GET["id"];
$sql = "select * from v_vars ";
$sql .= "where var_uuid = :var_uuid ";
@ -173,7 +182,7 @@
$var_hostname = $row["var_hostname"];
$var_enabled = $row["var_enabled"];
$var_order = $row["var_order"];
$var_description = base64_decode($row["var_description"]);
$var_description = $row["var_description"];
}
unset($sql, $parameters);
}

View File

@ -46,15 +46,19 @@
$language = new text;
$text = $language->get();
//define the variables
$action = '';
$search = '';
//get posted data
if (is_array($_POST['vars'])) {
$action = $_POST['action'];
$search = $_POST['search'];
$vars = $_POST['vars'];
if (!empty($_POST['vars'])) {
$action = $_POST['action'] ?? '';
$search = $_POST['search'] ?? '';
$vars = $_POST['vars'] ?? '';
}
//process the http post data by action
if ($action != '' && is_array($vars) && @sizeof($vars) != 0) {
if (!empty($action)) {
switch ($action) {
case 'copy':
if (permission_exists('var_add')) {
@ -81,44 +85,56 @@
}
//get order and order by
$order_by = $_GET["order_by"];
$order = $_GET["order"];
$order_by = $_GET["order_by"] ?? '';
$order = $_GET["order"] ?? '';
//add the search string
$search = strtolower($_GET["search"]);
if (!empty($search)) {
$sql_search = "where (";
$sql_search .= " lower(var_category) like :search ";
$sql_search .= " or lower(var_name) like :search ";
$sql_search .= " or lower(var_value) like :search ";
$sql_search .= " or lower(var_hostname) like :search ";
$sql_search .= " or lower(var_enabled) like :search ";
$sql_search .= " or lower(var_description) like :search ";
$sql_search .= ") ";
$parameters['search'] = '%'.$search.'%';
}
//set from session variables
$list_row_edit_button = !empty($_SESSION['theme']['list_row_edit_button']['boolean']) ? $_SESSION['theme']['list_row_edit_button']['boolean'] : 'false';
//get the count
$sql = "select count(var_uuid) from v_vars ";
$sql .= $sql_search;
if (!empty($_GET["search"])) {
$search = strtolower($_GET["search"]);
$sql .= "where (";
$sql .= " lower(var_category) like :search ";
$sql .= " or lower(var_name) like :search ";
$sql .= " or lower(var_value) like :search ";
$sql .= " or lower(var_hostname) like :search ";
$sql .= " or lower(var_enabled) like :search ";
$sql .= " or lower(var_description) like :search ";
$sql .= ") ";
$parameters['search'] = '%'.$search.'%';
}
$database = new database;
$num_rows = $database->select($sql, $parameters, 'column');
$num_rows = $database->select($sql, $parameters ?? null, 'column');
//prepare to page the results
$rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50;
$param = $search ? "&search=".$search : null;
$param = $order_by ? "&order_by=".$order_by."&order=".$order : null;
$page = is_numeric($_GET['page']) ? $_GET['page'] : 0;
$page = empty($_GET['page']) ? $page = 0 : $page = $_GET['page'];
list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page);
list($paging_controls_mini, $rows_per_page) = paging($num_rows, $param, $rows_per_page, true);
$offset = $rows_per_page * $page;
//get the list
$sql = str_replace('count(var_uuid)', '*', $sql);
$sql = "select * from v_vars ";
if (!empty($_GET["search"])) {
$search = strtolower($_GET["search"]);
$sql .= "where (";
$sql .= " lower(var_category) like :search ";
$sql .= " or lower(var_name) like :search ";
$sql .= " or lower(var_value) like :search ";
$sql .= " or lower(var_hostname) like :search ";
$sql .= " or lower(var_enabled) like :search ";
$sql .= " or lower(var_description) like :search ";
$sql .= ") ";
$parameters['search'] = '%'.$search.'%';
}
$sql .= $order_by != '' ? order_by($order_by, $order) : " order by var_category, var_order asc, var_name asc ";
$sql .= limit_offset($rows_per_page, $offset);
$database = new database;
$vars = $database->select($sql, $parameters, 'all');
$vars = $database->select($sql, $parameters ?? null, 'all');
unset($sql);
//create token
@ -176,7 +192,7 @@
echo "<table class='list'>\n";
function write_header($modifier) {
global $text, $order_by, $order, $vars;
global $text, $order_by, $order, $vars, $list_row_edit_button;
$modifier = str_replace('/', '', $modifier);
$modifier = str_replace(' ', ' ', $modifier);
$modifier = str_replace(' ', '_', $modifier);
@ -186,7 +202,7 @@
echo "<tr class='list-header'>\n";
if (permission_exists('var_edit') || permission_exists('var_delete')) {
echo " <th class='checkbox'>\n";
echo " <input type='checkbox' id='checkbox_all_".$modifier."' name='checkbox_all' onclick=\"list_all_toggle('".$modifier."'); checkbox_on_change(this);\" ".($vars ?: "style='visibility: hidden;'").">\n";
echo " <input type='checkbox' id='checkbox_all_".$modifier."' name='checkbox_all' onclick=\"list_all_toggle('".$modifier."'); checkbox_on_change(this);\" ".(!empty($vars) ?: "style='visibility: hidden;'").">\n";
echo " </th>\n";
}
echo th_order_by('var_name', $text['label-name'], $order_by, $order, null, "class='pct-30'");
@ -194,12 +210,12 @@
echo th_order_by('var_hostname', $text['label-hostname'], $order_by, $order, null, "class='hide-sm-dn'");
echo th_order_by('var_enabled', $text['label-enabled'], $order_by, $order, null, "class='center'");
echo "<th class='hide-sm-dn'>".$text['label-description']."</th>\n";
if (permission_exists('var_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') {
if (permission_exists('var_edit') && $list_row_edit_button == 'true') {
echo "<td class='action-button'>&nbsp;</td>\n";
}
echo "</tr>\n";
}
if (is_array($vars) && @sizeof($vars) != 0) {
if (!empty($vars)) {
$previous_category = '';
foreach ($vars as $x => $row) {
//write category and column headings
@ -245,8 +261,8 @@
echo $text['label-'.$row['var_enabled']];
}
echo " </td>\n";
echo " <td class='description overflow hide-sm-dn'>".escape(base64_decode($row['var_description'] ?? ''))."</td>\n";
if (permission_exists('var_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') {
echo " <td class='description overflow hide-sm-dn'>".escape($row['var_description'] ?? '')."</td>\n";
if (permission_exists('var_edit') && $list_row_edit_button == 'true') {
echo " <td class='action-button'>\n";
echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'link'=>$list_row_url]);
echo " </td>\n";
@ -258,7 +274,6 @@
$x++;
}
}
unset($vars);
echo "</table>\n";
echo "<br />\n";