From d2e901aba497e88da63cab3d1394e8c286d84829 Mon Sep 17 00:00:00 2001
From: Johannes <hannes@cheat.at>
Date: Wed, 26 Apr 2023 08:47:08 +0000
Subject: [PATCH] 6497 sorting for php versions

---
 .../sql/incremental/upd_dev_collection.sql    |  1 +
 install/sql/ispconfig3.sql                    |  1 +
 interface/web/admin/form/server_php.tform.php | 16 ++++++++++++
 .../web/admin/lib/lang/ar_server_php.lng      |  3 +++
 .../web/admin/lib/lang/ar_server_php_list.lng |  1 +
 .../web/admin/lib/lang/bg_server_php.lng      |  3 +++
 .../web/admin/lib/lang/bg_server_php_list.lng |  1 +
 .../web/admin/lib/lang/br_server_php.lng      |  3 +++
 .../web/admin/lib/lang/ca_server_php.lng      |  3 +++
 .../web/admin/lib/lang/ca_server_php_list.lng |  1 +
 .../web/admin/lib/lang/cz_server_php.lng      |  3 +++
 .../web/admin/lib/lang/de_server_php.lng      |  3 +++
 .../web/admin/lib/lang/de_server_php_list.lng |  1 +
 .../web/admin/lib/lang/dk_server_php.lng      |  3 +++
 .../web/admin/lib/lang/dk_server_php_list.lng |  1 +
 .../web/admin/lib/lang/el_server_php.lng      |  3 +++
 .../web/admin/lib/lang/el_server_php_list.lng |  1 +
 .../web/admin/lib/lang/en_server_php.lng      |  3 +++
 .../web/admin/lib/lang/en_server_php_list.lng |  1 +
 .../web/admin/lib/lang/es_server_php.lng      |  3 +++
 .../web/admin/lib/lang/es_server_php_list.lng |  1 +
 .../web/admin/lib/lang/fi_server_php.lng      |  3 +++
 .../web/admin/lib/lang/fi_server_php_list.lng |  1 +
 .../web/admin/lib/lang/fr_server_php.lng      |  3 +++
 .../web/admin/lib/lang/fr_server_php_list.lng |  1 +
 .../web/admin/lib/lang/hr_server_php.lng      |  3 +++
 .../web/admin/lib/lang/hr_server_php_list.lng |  1 +
 .../web/admin/lib/lang/hu_server_php.lng      |  3 +++
 .../web/admin/lib/lang/hu_server_php_list.lng |  1 +
 .../web/admin/lib/lang/id_server_php.lng      |  3 +++
 .../web/admin/lib/lang/id_server_php_list.lng |  1 +
 .../web/admin/lib/lang/it_server_php.lng      |  3 +++
 .../web/admin/lib/lang/it_server_php_list.lng |  1 +
 .../web/admin/lib/lang/ja_server_php.lng      |  3 +++
 .../web/admin/lib/lang/ja_server_php_list.lng |  1 +
 .../web/admin/lib/lang/nl_server_php.lng      |  3 +++
 .../web/admin/lib/lang/nl_server_php_list.lng |  1 +
 .../web/admin/lib/lang/pl_server_php.lng      |  3 +++
 .../web/admin/lib/lang/pl_server_php_list.lng |  1 +
 .../web/admin/lib/lang/pt_server_php.lng      |  3 +++
 .../web/admin/lib/lang/pt_server_php_list.lng |  1 +
 .../web/admin/lib/lang/ro_server_php.lng      |  3 +++
 .../web/admin/lib/lang/ro_server_php_list.lng |  1 +
 .../web/admin/lib/lang/ru_server_php.lng      |  3 +++
 .../web/admin/lib/lang/ru_server_php_list.lng |  1 +
 .../web/admin/lib/lang/se_server_php.lng      |  3 +++
 .../web/admin/lib/lang/se_server_php_list.lng |  1 +
 .../web/admin/lib/lang/sk_server_php.lng      |  3 +++
 .../web/admin/lib/lang/sk_server_php_list.lng |  1 +
 .../web/admin/lib/lang/tr_server_php.lng      |  3 +++
 .../web/admin/lib/lang/tr_server_php_list.lng |  1 +
 interface/web/admin/server_php_edit.php       |  8 +++++-
 .../web/admin/templates/server_php_list.htm   |  6 +++--
 .../admin/templates/server_php_sort_edit.htm  | 11 ++++++++
 interface/web/sites/ajax_get_json.php         | 26 ++++++++++---------
 .../sites/templates/web_vhost_domain_edit.htm |  4 ++-
 56 files changed, 155 insertions(+), 16 deletions(-)
 create mode 100644 interface/web/admin/templates/server_php_sort_edit.htm

diff --git a/install/sql/incremental/upd_dev_collection.sql b/install/sql/incremental/upd_dev_collection.sql
index c3d8c5b210..e84a33ec41 100644
--- a/install/sql/incremental/upd_dev_collection.sql
+++ b/install/sql/incremental/upd_dev_collection.sql
@@ -1,2 +1,3 @@
 
 ALTER TABLE `mail_user` CHANGE `quota` `quota` BIGINT(20) NOT NULL DEFAULT '0';
+ALTER TABLE `server_php` ADD `sortprio` INT(20) NOT NULL DEFAULT '100' AFTER `active`;
diff --git a/install/sql/ispconfig3.sql b/install/sql/ispconfig3.sql
index e9ed67c86a..2055c6a9a3 100644
--- a/install/sql/ispconfig3.sql
+++ b/install/sql/ispconfig3.sql
@@ -1460,6 +1460,7 @@ CREATE TABLE `server_php` (
   `php_fpm_pool_dir` varchar(255) DEFAULT NULL,
   `php_fpm_socket_dir` varchar(255) DEFAULT NULL,
   `active` enum('n','y') NOT NULL DEFAULT 'y',
+  `sortprio` int(20) NOT NULL DEFAULT 100,
   PRIMARY KEY (`server_php_id`)
 ) DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
 
diff --git a/interface/web/admin/form/server_php.tform.php b/interface/web/admin/form/server_php.tform.php
index 2a37a1e6d1..67f22cbeb4 100644
--- a/interface/web/admin/form/server_php.tform.php
+++ b/interface/web/admin/form/server_php.tform.php
@@ -248,4 +248,20 @@ $form["tabs"]['php_fpm'] = array(
 		//#################################
 	)
 );
+$form["tabs"]['php_sort'] = array (
+    	'title' => "PHP Sort Priority",
+	'width' => 80,
+	'template' => "templates/server_php_sort_edit.htm",
+	'fields' => array(
+                   'sortprio' => array (
+			'datatype' => 'INTEGER',
+			'formtype' => 'TEXT',
+			'default' => '100',
+			'value'  => '',
+			'separator' => '',
+			'width'  => '10',
+			'maxlength' => '20'
+		),
+	)
+);
 ?>
diff --git a/interface/web/admin/lib/lang/ar_server_php.lng b/interface/web/admin/lib/lang/ar_server_php.lng
index 491be1aae2..4d71bb50b7 100644
--- a/interface/web/admin/lib/lang/ar_server_php.lng
+++ b/interface/web/admin/lib/lang/ar_server_php.lng
@@ -17,4 +17,7 @@ $wb['php_fpm_socket_dir_txt'] = 'PHP-FPM socket directory';
 $wb['active_txt'] = 'Active';
 $wb['php_in_use_error'] = 'This PHP-Version is in use.';
 $wb['php_name_in_use_error'] = 'The name can not be changed.';
+$wb['PHP Sort Priority'] = 'Priority';
+$wb['sortprio_txt'] = 'Priority';
+$wb['sortprio_long_txt'] = 'Priority of PHP version in the PHP version select box<br>Default PHP has prio 0 if enabled<br>Lower value is higher priority';
 ?>
diff --git a/interface/web/admin/lib/lang/ar_server_php_list.lng b/interface/web/admin/lib/lang/ar_server_php_list.lng
index 291302cbb7..d5e6ad3c7f 100644
--- a/interface/web/admin/lib/lang/ar_server_php_list.lng
+++ b/interface/web/admin/lib/lang/ar_server_php_list.lng
@@ -6,4 +6,5 @@ $wb['client_id_txt'] = 'Client';
 $wb['name_txt'] = 'PHP Name';
 $wb['active_txt'] = 'Active';
 $wb['usage_txt'] = 'Usage count';
+$wb['sortprio_txt'] = 'Priority';
 ?>
diff --git a/interface/web/admin/lib/lang/bg_server_php.lng b/interface/web/admin/lib/lang/bg_server_php.lng
index 491be1aae2..4d71bb50b7 100644
--- a/interface/web/admin/lib/lang/bg_server_php.lng
+++ b/interface/web/admin/lib/lang/bg_server_php.lng
@@ -17,4 +17,7 @@ $wb['php_fpm_socket_dir_txt'] = 'PHP-FPM socket directory';
 $wb['active_txt'] = 'Active';
 $wb['php_in_use_error'] = 'This PHP-Version is in use.';
 $wb['php_name_in_use_error'] = 'The name can not be changed.';
+$wb['PHP Sort Priority'] = 'Priority';
+$wb['sortprio_txt'] = 'Priority';
+$wb['sortprio_long_txt'] = 'Priority of PHP version in the PHP version select box<br>Default PHP has prio 0 if enabled<br>Lower value is higher priority';
 ?>
diff --git a/interface/web/admin/lib/lang/bg_server_php_list.lng b/interface/web/admin/lib/lang/bg_server_php_list.lng
index 291302cbb7..d5e6ad3c7f 100644
--- a/interface/web/admin/lib/lang/bg_server_php_list.lng
+++ b/interface/web/admin/lib/lang/bg_server_php_list.lng
@@ -6,4 +6,5 @@ $wb['client_id_txt'] = 'Client';
 $wb['name_txt'] = 'PHP Name';
 $wb['active_txt'] = 'Active';
 $wb['usage_txt'] = 'Usage count';
+$wb['sortprio_txt'] = 'Priority';
 ?>
diff --git a/interface/web/admin/lib/lang/br_server_php.lng b/interface/web/admin/lib/lang/br_server_php.lng
index d0a1015833..791db7e3ec 100644
--- a/interface/web/admin/lib/lang/br_server_php.lng
+++ b/interface/web/admin/lib/lang/br_server_php.lng
@@ -17,4 +17,7 @@ $wb['php_fpm_socket_dir_txt'] = 'PHP-FPM socket directory';
 $wb['active_txt'] = 'Ativo';
 $wb['php_in_use_error'] = 'Esta versão PHP está em uso.';
 $wb['php_name_in_use_error'] = 'O nome não pode ser modificado.';
+$wb['PHP Sort Priority'] = 'Priority';
+$wb['sortprio_txt'] = 'Priority';
+$wb['sortprio_long_txt'] = 'Priority of PHP version in the PHP version select box<br>Default PHP has prio 0 if enabled<br>Lower value is higher priority';
 ?>
diff --git a/interface/web/admin/lib/lang/ca_server_php.lng b/interface/web/admin/lib/lang/ca_server_php.lng
index 491be1aae2..4d71bb50b7 100644
--- a/interface/web/admin/lib/lang/ca_server_php.lng
+++ b/interface/web/admin/lib/lang/ca_server_php.lng
@@ -17,4 +17,7 @@ $wb['php_fpm_socket_dir_txt'] = 'PHP-FPM socket directory';
 $wb['active_txt'] = 'Active';
 $wb['php_in_use_error'] = 'This PHP-Version is in use.';
 $wb['php_name_in_use_error'] = 'The name can not be changed.';
+$wb['PHP Sort Priority'] = 'Priority';
+$wb['sortprio_txt'] = 'Priority';
+$wb['sortprio_long_txt'] = 'Priority of PHP version in the PHP version select box<br>Default PHP has prio 0 if enabled<br>Lower value is higher priority';
 ?>
diff --git a/interface/web/admin/lib/lang/ca_server_php_list.lng b/interface/web/admin/lib/lang/ca_server_php_list.lng
index 291302cbb7..d5e6ad3c7f 100644
--- a/interface/web/admin/lib/lang/ca_server_php_list.lng
+++ b/interface/web/admin/lib/lang/ca_server_php_list.lng
@@ -6,4 +6,5 @@ $wb['client_id_txt'] = 'Client';
 $wb['name_txt'] = 'PHP Name';
 $wb['active_txt'] = 'Active';
 $wb['usage_txt'] = 'Usage count';
+$wb['sortprio_txt'] = 'Priority';
 ?>
diff --git a/interface/web/admin/lib/lang/cz_server_php.lng b/interface/web/admin/lib/lang/cz_server_php.lng
index c1c67f05ef..6490928429 100644
--- a/interface/web/admin/lib/lang/cz_server_php.lng
+++ b/interface/web/admin/lib/lang/cz_server_php.lng
@@ -17,4 +17,7 @@ $wb['php_fpm_socket_dir_txt'] = 'PHP-FPM socket directory';
 $wb['active_txt'] = 'Aktivní';
 $wb['php_in_use_error'] = 'This PHP-Version is in use.';
 $wb['php_name_in_use_error'] = 'The name can not be changed.';
+$wb['PHP Sort Priority'] = 'Priority';
+$wb['sortprio_txt'] = 'Priority';
+$wb['sortprio_long_txt'] = 'Priority of PHP version in the PHP version select box<br>Default PHP has prio 0 if enabled<br>Lower value is higher priority';
 ?>
diff --git a/interface/web/admin/lib/lang/de_server_php.lng b/interface/web/admin/lib/lang/de_server_php.lng
index b3ad5d9913..4100957b9d 100644
--- a/interface/web/admin/lib/lang/de_server_php.lng
+++ b/interface/web/admin/lib/lang/de_server_php.lng
@@ -17,4 +17,7 @@ $wb['php_fpm_socket_dir_txt'] = 'PHP-FPM socket directory';
 $wb['active_txt'] = 'Aktiv';
 $wb['php_in_use_error'] = 'Diese PHP-Version wird noch benutzt.';
 $wb['php_name_in_use_error'] = 'Der Name kann nicht geändert werden.';
+$wb['PHP Sort Priority'] = 'Priorität';
+$wb['sortprio_txt'] = 'Sorting Priority';
+$wb['sortprio_long_txt'] = 'Priority of PHP Version in the PHP version select box<br>Default PHP has prio 0 if enabled<br>Lower value is higher priority';
 ?>
diff --git a/interface/web/admin/lib/lang/de_server_php_list.lng b/interface/web/admin/lib/lang/de_server_php_list.lng
index f9da54d84c..6b0a084746 100644
--- a/interface/web/admin/lib/lang/de_server_php_list.lng
+++ b/interface/web/admin/lib/lang/de_server_php_list.lng
@@ -6,4 +6,5 @@ $wb['client_id_txt'] = 'Kunde';
 $wb['name_txt'] = 'PHP Name';
 $wb['active_txt'] = 'Aktiv';
 $wb['usage_txt'] = 'Usage count';
+$wb['sortprio_txt'] = 'Priority';
 ?>
diff --git a/interface/web/admin/lib/lang/dk_server_php.lng b/interface/web/admin/lib/lang/dk_server_php.lng
index db6ef1f98a..e9b42a5133 100644
--- a/interface/web/admin/lib/lang/dk_server_php.lng
+++ b/interface/web/admin/lib/lang/dk_server_php.lng
@@ -17,4 +17,7 @@ $wb['php_fpm_socket_dir_txt'] = 'PHP-FPM socket directory';
 $wb['active_txt'] = 'Active';
 $wb['php_in_use_error'] = 'This PHP-Version is in use.';
 $wb['php_name_in_use_error'] = 'The name can not be changed.';
+$wb['PHP Sort Priority'] = 'Priority';
+$wb['sortprio_txt'] = 'Priority';
+$wb['sortprio_long_txt'] = 'Priority of PHP version in the PHP version select box<br>Default PHP has prio 0 if enabled<br>Lower value is higher priority';
 ?>
diff --git a/interface/web/admin/lib/lang/dk_server_php_list.lng b/interface/web/admin/lib/lang/dk_server_php_list.lng
index 65869ce2ed..4be3b3446b 100644
--- a/interface/web/admin/lib/lang/dk_server_php_list.lng
+++ b/interface/web/admin/lib/lang/dk_server_php_list.lng
@@ -6,4 +6,5 @@ $wb['client_id_txt'] = 'Kunde';
 $wb['name_txt'] = 'PHP Navn';
 $wb['active_txt'] = 'Active';
 $wb['usage_txt'] = 'Usage count';
+$wb['sortprio_txt'] = 'Priority';
 ?>
diff --git a/interface/web/admin/lib/lang/el_server_php.lng b/interface/web/admin/lib/lang/el_server_php.lng
index 491be1aae2..4d71bb50b7 100644
--- a/interface/web/admin/lib/lang/el_server_php.lng
+++ b/interface/web/admin/lib/lang/el_server_php.lng
@@ -17,4 +17,7 @@ $wb['php_fpm_socket_dir_txt'] = 'PHP-FPM socket directory';
 $wb['active_txt'] = 'Active';
 $wb['php_in_use_error'] = 'This PHP-Version is in use.';
 $wb['php_name_in_use_error'] = 'The name can not be changed.';
+$wb['PHP Sort Priority'] = 'Priority';
+$wb['sortprio_txt'] = 'Priority';
+$wb['sortprio_long_txt'] = 'Priority of PHP version in the PHP version select box<br>Default PHP has prio 0 if enabled<br>Lower value is higher priority';
 ?>
diff --git a/interface/web/admin/lib/lang/el_server_php_list.lng b/interface/web/admin/lib/lang/el_server_php_list.lng
index 291302cbb7..d5e6ad3c7f 100644
--- a/interface/web/admin/lib/lang/el_server_php_list.lng
+++ b/interface/web/admin/lib/lang/el_server_php_list.lng
@@ -6,4 +6,5 @@ $wb['client_id_txt'] = 'Client';
 $wb['name_txt'] = 'PHP Name';
 $wb['active_txt'] = 'Active';
 $wb['usage_txt'] = 'Usage count';
+$wb['sortprio_txt'] = 'Priority';
 ?>
diff --git a/interface/web/admin/lib/lang/en_server_php.lng b/interface/web/admin/lib/lang/en_server_php.lng
index 491be1aae2..4d71bb50b7 100644
--- a/interface/web/admin/lib/lang/en_server_php.lng
+++ b/interface/web/admin/lib/lang/en_server_php.lng
@@ -17,4 +17,7 @@ $wb['php_fpm_socket_dir_txt'] = 'PHP-FPM socket directory';
 $wb['active_txt'] = 'Active';
 $wb['php_in_use_error'] = 'This PHP-Version is in use.';
 $wb['php_name_in_use_error'] = 'The name can not be changed.';
+$wb['PHP Sort Priority'] = 'Priority';
+$wb['sortprio_txt'] = 'Priority';
+$wb['sortprio_long_txt'] = 'Priority of PHP version in the PHP version select box<br>Default PHP has prio 0 if enabled<br>Lower value is higher priority';
 ?>
diff --git a/interface/web/admin/lib/lang/en_server_php_list.lng b/interface/web/admin/lib/lang/en_server_php_list.lng
index 291302cbb7..d5e6ad3c7f 100644
--- a/interface/web/admin/lib/lang/en_server_php_list.lng
+++ b/interface/web/admin/lib/lang/en_server_php_list.lng
@@ -6,4 +6,5 @@ $wb['client_id_txt'] = 'Client';
 $wb['name_txt'] = 'PHP Name';
 $wb['active_txt'] = 'Active';
 $wb['usage_txt'] = 'Usage count';
+$wb['sortprio_txt'] = 'Priority';
 ?>
diff --git a/interface/web/admin/lib/lang/es_server_php.lng b/interface/web/admin/lib/lang/es_server_php.lng
index df2f0778f4..e75aa0e4e4 100644
--- a/interface/web/admin/lib/lang/es_server_php.lng
+++ b/interface/web/admin/lib/lang/es_server_php.lng
@@ -17,4 +17,7 @@ $wb['php_fpm_socket_dir_txt'] = 'PHP-FPM socket directory';
 $wb['active_txt'] = 'Active';
 $wb['php_in_use_error'] = 'This PHP-Version is in use.';
 $wb['php_name_in_use_error'] = 'The name can not be changed.';
+$wb['PHP Sort Priority'] = 'Priority';
+$wb['sortprio_txt'] = 'Priority';
+$wb['sortprio_long_txt'] = 'Priority of PHP version in the PHP version select box<br>Default PHP has prio 0 if enabled<br>Lower value is higher priority';
 ?>
diff --git a/interface/web/admin/lib/lang/es_server_php_list.lng b/interface/web/admin/lib/lang/es_server_php_list.lng
index 8d62ee8919..1efd239d31 100644
--- a/interface/web/admin/lib/lang/es_server_php_list.lng
+++ b/interface/web/admin/lib/lang/es_server_php_list.lng
@@ -6,4 +6,5 @@ $wb['name_txt'] = 'Versión de PHP';
 $wb['server_id_txt'] = 'Servidor';
 $wb['active_txt'] = 'Active';
 $wb['usage_txt'] = 'Usage count';
+$wb['sortprio_txt'] = 'Priority';
 ?>
diff --git a/interface/web/admin/lib/lang/fi_server_php.lng b/interface/web/admin/lib/lang/fi_server_php.lng
index 491be1aae2..4d71bb50b7 100644
--- a/interface/web/admin/lib/lang/fi_server_php.lng
+++ b/interface/web/admin/lib/lang/fi_server_php.lng
@@ -17,4 +17,7 @@ $wb['php_fpm_socket_dir_txt'] = 'PHP-FPM socket directory';
 $wb['active_txt'] = 'Active';
 $wb['php_in_use_error'] = 'This PHP-Version is in use.';
 $wb['php_name_in_use_error'] = 'The name can not be changed.';
+$wb['PHP Sort Priority'] = 'Priority';
+$wb['sortprio_txt'] = 'Priority';
+$wb['sortprio_long_txt'] = 'Priority of PHP version in the PHP version select box<br>Default PHP has prio 0 if enabled<br>Lower value is higher priority';
 ?>
diff --git a/interface/web/admin/lib/lang/fi_server_php_list.lng b/interface/web/admin/lib/lang/fi_server_php_list.lng
index 291302cbb7..d5e6ad3c7f 100644
--- a/interface/web/admin/lib/lang/fi_server_php_list.lng
+++ b/interface/web/admin/lib/lang/fi_server_php_list.lng
@@ -6,4 +6,5 @@ $wb['client_id_txt'] = 'Client';
 $wb['name_txt'] = 'PHP Name';
 $wb['active_txt'] = 'Active';
 $wb['usage_txt'] = 'Usage count';
+$wb['sortprio_txt'] = 'Priority';
 ?>
diff --git a/interface/web/admin/lib/lang/fr_server_php.lng b/interface/web/admin/lib/lang/fr_server_php.lng
index 491be1aae2..4d71bb50b7 100644
--- a/interface/web/admin/lib/lang/fr_server_php.lng
+++ b/interface/web/admin/lib/lang/fr_server_php.lng
@@ -17,4 +17,7 @@ $wb['php_fpm_socket_dir_txt'] = 'PHP-FPM socket directory';
 $wb['active_txt'] = 'Active';
 $wb['php_in_use_error'] = 'This PHP-Version is in use.';
 $wb['php_name_in_use_error'] = 'The name can not be changed.';
+$wb['PHP Sort Priority'] = 'Priority';
+$wb['sortprio_txt'] = 'Priority';
+$wb['sortprio_long_txt'] = 'Priority of PHP version in the PHP version select box<br>Default PHP has prio 0 if enabled<br>Lower value is higher priority';
 ?>
diff --git a/interface/web/admin/lib/lang/fr_server_php_list.lng b/interface/web/admin/lib/lang/fr_server_php_list.lng
index 291302cbb7..d5e6ad3c7f 100644
--- a/interface/web/admin/lib/lang/fr_server_php_list.lng
+++ b/interface/web/admin/lib/lang/fr_server_php_list.lng
@@ -6,4 +6,5 @@ $wb['client_id_txt'] = 'Client';
 $wb['name_txt'] = 'PHP Name';
 $wb['active_txt'] = 'Active';
 $wb['usage_txt'] = 'Usage count';
+$wb['sortprio_txt'] = 'Priority';
 ?>
diff --git a/interface/web/admin/lib/lang/hr_server_php.lng b/interface/web/admin/lib/lang/hr_server_php.lng
index 15ec1b30f5..9db79d4f9b 100644
--- a/interface/web/admin/lib/lang/hr_server_php.lng
+++ b/interface/web/admin/lib/lang/hr_server_php.lng
@@ -17,4 +17,7 @@ $wb['php_fpm_socket_dir_txt'] = 'PHP-FPM socket directory';
 $wb['active_txt'] = 'Active';
 $wb['php_in_use_error'] = 'This PHP-Version is in use.';
 $wb['php_name_in_use_error'] = 'The name can not be changed.';
+$wb['PHP Sort Priority'] = 'Priority';
+$wb['sortprio_txt'] = 'Priority';
+$wb['sortprio_long_txt'] = 'Priority of PHP version in the PHP version select box<br>Default PHP has prio 0 if enabled<br>Lower value is higher priority';
 ?>
diff --git a/interface/web/admin/lib/lang/hr_server_php_list.lng b/interface/web/admin/lib/lang/hr_server_php_list.lng
index 1851ac8395..4e5381c1f3 100644
--- a/interface/web/admin/lib/lang/hr_server_php_list.lng
+++ b/interface/web/admin/lib/lang/hr_server_php_list.lng
@@ -6,4 +6,5 @@ $wb['client_id_txt'] = 'Klijent';
 $wb['name_txt'] = 'PHP Name';
 $wb['active_txt'] = 'Active';
 $wb['usage_txt'] = 'Usage count';
+$wb['sortprio_txt'] = 'Priority';
 ?>
diff --git a/interface/web/admin/lib/lang/hu_server_php.lng b/interface/web/admin/lib/lang/hu_server_php.lng
index 491be1aae2..4d71bb50b7 100644
--- a/interface/web/admin/lib/lang/hu_server_php.lng
+++ b/interface/web/admin/lib/lang/hu_server_php.lng
@@ -17,4 +17,7 @@ $wb['php_fpm_socket_dir_txt'] = 'PHP-FPM socket directory';
 $wb['active_txt'] = 'Active';
 $wb['php_in_use_error'] = 'This PHP-Version is in use.';
 $wb['php_name_in_use_error'] = 'The name can not be changed.';
+$wb['PHP Sort Priority'] = 'Priority';
+$wb['sortprio_txt'] = 'Priority';
+$wb['sortprio_long_txt'] = 'Priority of PHP version in the PHP version select box<br>Default PHP has prio 0 if enabled<br>Lower value is higher priority';
 ?>
diff --git a/interface/web/admin/lib/lang/hu_server_php_list.lng b/interface/web/admin/lib/lang/hu_server_php_list.lng
index 291302cbb7..d5e6ad3c7f 100644
--- a/interface/web/admin/lib/lang/hu_server_php_list.lng
+++ b/interface/web/admin/lib/lang/hu_server_php_list.lng
@@ -6,4 +6,5 @@ $wb['client_id_txt'] = 'Client';
 $wb['name_txt'] = 'PHP Name';
 $wb['active_txt'] = 'Active';
 $wb['usage_txt'] = 'Usage count';
+$wb['sortprio_txt'] = 'Priority';
 ?>
diff --git a/interface/web/admin/lib/lang/id_server_php.lng b/interface/web/admin/lib/lang/id_server_php.lng
index 491be1aae2..4d71bb50b7 100644
--- a/interface/web/admin/lib/lang/id_server_php.lng
+++ b/interface/web/admin/lib/lang/id_server_php.lng
@@ -17,4 +17,7 @@ $wb['php_fpm_socket_dir_txt'] = 'PHP-FPM socket directory';
 $wb['active_txt'] = 'Active';
 $wb['php_in_use_error'] = 'This PHP-Version is in use.';
 $wb['php_name_in_use_error'] = 'The name can not be changed.';
+$wb['PHP Sort Priority'] = 'Priority';
+$wb['sortprio_txt'] = 'Priority';
+$wb['sortprio_long_txt'] = 'Priority of PHP version in the PHP version select box<br>Default PHP has prio 0 if enabled<br>Lower value is higher priority';
 ?>
diff --git a/interface/web/admin/lib/lang/id_server_php_list.lng b/interface/web/admin/lib/lang/id_server_php_list.lng
index 291302cbb7..d5e6ad3c7f 100644
--- a/interface/web/admin/lib/lang/id_server_php_list.lng
+++ b/interface/web/admin/lib/lang/id_server_php_list.lng
@@ -6,4 +6,5 @@ $wb['client_id_txt'] = 'Client';
 $wb['name_txt'] = 'PHP Name';
 $wb['active_txt'] = 'Active';
 $wb['usage_txt'] = 'Usage count';
+$wb['sortprio_txt'] = 'Priority';
 ?>
diff --git a/interface/web/admin/lib/lang/it_server_php.lng b/interface/web/admin/lib/lang/it_server_php.lng
index 7569ba9b52..d4feb7cb0c 100644
--- a/interface/web/admin/lib/lang/it_server_php.lng
+++ b/interface/web/admin/lib/lang/it_server_php.lng
@@ -17,4 +17,7 @@ $wb['php_fpm_socket_dir_txt'] = 'PHP-FPM socket directory';
 $wb['active_txt'] = 'Attivo';
 $wb['php_in_use_error'] = 'Questa versione PHP è in uso.';
 $wb['php_name_in_use_error'] = 'Il nome non può essere cambiato.';
+$wb['PHP Sort Priority'] = 'Priority';
+$wb['sortprio_txt'] = 'Priority';
+$wb['sortprio_long_txt'] = 'Priority of PHP version in the PHP version select box<br>Default PHP has prio 0 if enabled<br>Lower value is higher priority';
 ?>
diff --git a/interface/web/admin/lib/lang/it_server_php_list.lng b/interface/web/admin/lib/lang/it_server_php_list.lng
index 5ff1ebe314..ca117bf38a 100644
--- a/interface/web/admin/lib/lang/it_server_php_list.lng
+++ b/interface/web/admin/lib/lang/it_server_php_list.lng
@@ -6,4 +6,5 @@ $wb['client_id_txt'] = 'Cliente';
 $wb['name_txt'] = 'Nome PHP';
 $wb['active_txt'] = 'Active';
 $wb['usage_txt'] = 'Usage count';
+$wb['sortprio_txt'] = 'Priority';
 ?>
diff --git a/interface/web/admin/lib/lang/ja_server_php.lng b/interface/web/admin/lib/lang/ja_server_php.lng
index 491be1aae2..4d71bb50b7 100644
--- a/interface/web/admin/lib/lang/ja_server_php.lng
+++ b/interface/web/admin/lib/lang/ja_server_php.lng
@@ -17,4 +17,7 @@ $wb['php_fpm_socket_dir_txt'] = 'PHP-FPM socket directory';
 $wb['active_txt'] = 'Active';
 $wb['php_in_use_error'] = 'This PHP-Version is in use.';
 $wb['php_name_in_use_error'] = 'The name can not be changed.';
+$wb['PHP Sort Priority'] = 'Priority';
+$wb['sortprio_txt'] = 'Priority';
+$wb['sortprio_long_txt'] = 'Priority of PHP version in the PHP version select box<br>Default PHP has prio 0 if enabled<br>Lower value is higher priority';
 ?>
diff --git a/interface/web/admin/lib/lang/ja_server_php_list.lng b/interface/web/admin/lib/lang/ja_server_php_list.lng
index 291302cbb7..d5e6ad3c7f 100644
--- a/interface/web/admin/lib/lang/ja_server_php_list.lng
+++ b/interface/web/admin/lib/lang/ja_server_php_list.lng
@@ -6,4 +6,5 @@ $wb['client_id_txt'] = 'Client';
 $wb['name_txt'] = 'PHP Name';
 $wb['active_txt'] = 'Active';
 $wb['usage_txt'] = 'Usage count';
+$wb['sortprio_txt'] = 'Priority';
 ?>
diff --git a/interface/web/admin/lib/lang/nl_server_php.lng b/interface/web/admin/lib/lang/nl_server_php.lng
index 491be1aae2..4d71bb50b7 100644
--- a/interface/web/admin/lib/lang/nl_server_php.lng
+++ b/interface/web/admin/lib/lang/nl_server_php.lng
@@ -17,4 +17,7 @@ $wb['php_fpm_socket_dir_txt'] = 'PHP-FPM socket directory';
 $wb['active_txt'] = 'Active';
 $wb['php_in_use_error'] = 'This PHP-Version is in use.';
 $wb['php_name_in_use_error'] = 'The name can not be changed.';
+$wb['PHP Sort Priority'] = 'Priority';
+$wb['sortprio_txt'] = 'Priority';
+$wb['sortprio_long_txt'] = 'Priority of PHP version in the PHP version select box<br>Default PHP has prio 0 if enabled<br>Lower value is higher priority';
 ?>
diff --git a/interface/web/admin/lib/lang/nl_server_php_list.lng b/interface/web/admin/lib/lang/nl_server_php_list.lng
index 291302cbb7..d5e6ad3c7f 100644
--- a/interface/web/admin/lib/lang/nl_server_php_list.lng
+++ b/interface/web/admin/lib/lang/nl_server_php_list.lng
@@ -6,4 +6,5 @@ $wb['client_id_txt'] = 'Client';
 $wb['name_txt'] = 'PHP Name';
 $wb['active_txt'] = 'Active';
 $wb['usage_txt'] = 'Usage count';
+$wb['sortprio_txt'] = 'Priority';
 ?>
diff --git a/interface/web/admin/lib/lang/pl_server_php.lng b/interface/web/admin/lib/lang/pl_server_php.lng
index de4ce60ac1..d86e2cf01f 100644
--- a/interface/web/admin/lib/lang/pl_server_php.lng
+++ b/interface/web/admin/lib/lang/pl_server_php.lng
@@ -17,4 +17,7 @@ $wb['php_fpm_socket_dir_txt'] = 'PHP-FPM socket directory';
 $wb['active_txt'] = 'Active';
 $wb['php_in_use_error'] = 'This PHP-Version is in use.';
 $wb['php_name_in_use_error'] = 'The name can not be changed.';
+$wb['PHP Sort Priority'] = 'Priority';
+$wb['sortprio_txt'] = 'Priority';
+$wb['sortprio_long_txt'] = 'Priority of PHP version in the PHP version select box<br>Default PHP has prio 0 if enabled<br>Lower value is higher priority';
 ?>
diff --git a/interface/web/admin/lib/lang/pl_server_php_list.lng b/interface/web/admin/lib/lang/pl_server_php_list.lng
index 291302cbb7..d5e6ad3c7f 100644
--- a/interface/web/admin/lib/lang/pl_server_php_list.lng
+++ b/interface/web/admin/lib/lang/pl_server_php_list.lng
@@ -6,4 +6,5 @@ $wb['client_id_txt'] = 'Client';
 $wb['name_txt'] = 'PHP Name';
 $wb['active_txt'] = 'Active';
 $wb['usage_txt'] = 'Usage count';
+$wb['sortprio_txt'] = 'Priority';
 ?>
diff --git a/interface/web/admin/lib/lang/pt_server_php.lng b/interface/web/admin/lib/lang/pt_server_php.lng
index 491be1aae2..4d71bb50b7 100644
--- a/interface/web/admin/lib/lang/pt_server_php.lng
+++ b/interface/web/admin/lib/lang/pt_server_php.lng
@@ -17,4 +17,7 @@ $wb['php_fpm_socket_dir_txt'] = 'PHP-FPM socket directory';
 $wb['active_txt'] = 'Active';
 $wb['php_in_use_error'] = 'This PHP-Version is in use.';
 $wb['php_name_in_use_error'] = 'The name can not be changed.';
+$wb['PHP Sort Priority'] = 'Priority';
+$wb['sortprio_txt'] = 'Priority';
+$wb['sortprio_long_txt'] = 'Priority of PHP version in the PHP version select box<br>Default PHP has prio 0 if enabled<br>Lower value is higher priority';
 ?>
diff --git a/interface/web/admin/lib/lang/pt_server_php_list.lng b/interface/web/admin/lib/lang/pt_server_php_list.lng
index 291302cbb7..d5e6ad3c7f 100644
--- a/interface/web/admin/lib/lang/pt_server_php_list.lng
+++ b/interface/web/admin/lib/lang/pt_server_php_list.lng
@@ -6,4 +6,5 @@ $wb['client_id_txt'] = 'Client';
 $wb['name_txt'] = 'PHP Name';
 $wb['active_txt'] = 'Active';
 $wb['usage_txt'] = 'Usage count';
+$wb['sortprio_txt'] = 'Priority';
 ?>
diff --git a/interface/web/admin/lib/lang/ro_server_php.lng b/interface/web/admin/lib/lang/ro_server_php.lng
index 491be1aae2..4d71bb50b7 100644
--- a/interface/web/admin/lib/lang/ro_server_php.lng
+++ b/interface/web/admin/lib/lang/ro_server_php.lng
@@ -17,4 +17,7 @@ $wb['php_fpm_socket_dir_txt'] = 'PHP-FPM socket directory';
 $wb['active_txt'] = 'Active';
 $wb['php_in_use_error'] = 'This PHP-Version is in use.';
 $wb['php_name_in_use_error'] = 'The name can not be changed.';
+$wb['PHP Sort Priority'] = 'Priority';
+$wb['sortprio_txt'] = 'Priority';
+$wb['sortprio_long_txt'] = 'Priority of PHP version in the PHP version select box<br>Default PHP has prio 0 if enabled<br>Lower value is higher priority';
 ?>
diff --git a/interface/web/admin/lib/lang/ro_server_php_list.lng b/interface/web/admin/lib/lang/ro_server_php_list.lng
index 291302cbb7..d5e6ad3c7f 100644
--- a/interface/web/admin/lib/lang/ro_server_php_list.lng
+++ b/interface/web/admin/lib/lang/ro_server_php_list.lng
@@ -6,4 +6,5 @@ $wb['client_id_txt'] = 'Client';
 $wb['name_txt'] = 'PHP Name';
 $wb['active_txt'] = 'Active';
 $wb['usage_txt'] = 'Usage count';
+$wb['sortprio_txt'] = 'Priority';
 ?>
diff --git a/interface/web/admin/lib/lang/ru_server_php.lng b/interface/web/admin/lib/lang/ru_server_php.lng
index c5c4942b8e..ca1a8147a3 100644
--- a/interface/web/admin/lib/lang/ru_server_php.lng
+++ b/interface/web/admin/lib/lang/ru_server_php.lng
@@ -17,4 +17,7 @@ $wb['php_fpm_socket_dir_txt'] = 'PHP-FPM socket directory';
 $wb['active_txt'] = 'Active';
 $wb['php_in_use_error'] = 'This PHP-Version is in use.';
 $wb['php_name_in_use_error'] = 'The name can not be changed.';
+$wb['PHP Sort Priority'] = 'Priority';
+$wb['sortprio_txt'] = 'Priority';
+$wb['sortprio_long_txt'] = 'Priority of PHP version in the PHP version select box<br>Default PHP has prio 0 if enabled<br>Lower value is higher priority';
 ?>
diff --git a/interface/web/admin/lib/lang/ru_server_php_list.lng b/interface/web/admin/lib/lang/ru_server_php_list.lng
index 5be582f23d..1a2068057f 100644
--- a/interface/web/admin/lib/lang/ru_server_php_list.lng
+++ b/interface/web/admin/lib/lang/ru_server_php_list.lng
@@ -6,4 +6,5 @@ $wb['client_id_txt'] = 'ID Клиента';
 $wb['name_txt'] = 'Имя PHP';
 $wb['active_txt'] = 'Active';
 $wb['usage_txt'] = 'Usage count';
+$wb['sortprio_txt'] = 'Priority';
 ?>
diff --git a/interface/web/admin/lib/lang/se_server_php.lng b/interface/web/admin/lib/lang/se_server_php.lng
index 491be1aae2..4d71bb50b7 100644
--- a/interface/web/admin/lib/lang/se_server_php.lng
+++ b/interface/web/admin/lib/lang/se_server_php.lng
@@ -17,4 +17,7 @@ $wb['php_fpm_socket_dir_txt'] = 'PHP-FPM socket directory';
 $wb['active_txt'] = 'Active';
 $wb['php_in_use_error'] = 'This PHP-Version is in use.';
 $wb['php_name_in_use_error'] = 'The name can not be changed.';
+$wb['PHP Sort Priority'] = 'Priority';
+$wb['sortprio_txt'] = 'Priority';
+$wb['sortprio_long_txt'] = 'Priority of PHP version in the PHP version select box<br>Default PHP has prio 0 if enabled<br>Lower value is higher priority';
 ?>
diff --git a/interface/web/admin/lib/lang/se_server_php_list.lng b/interface/web/admin/lib/lang/se_server_php_list.lng
index b2f8b55112..86adb0f2a6 100644
--- a/interface/web/admin/lib/lang/se_server_php_list.lng
+++ b/interface/web/admin/lib/lang/se_server_php_list.lng
@@ -6,4 +6,5 @@ $wb['client_id_txt'] = 'Kund';
 $wb['name_txt'] = 'PHP-namn';
 $wb['active_txt'] = 'Active';
 $wb['usage_txt'] = 'Usage count';
+$wb['sortprio_txt'] = 'Priority';
 ?>
diff --git a/interface/web/admin/lib/lang/sk_server_php.lng b/interface/web/admin/lib/lang/sk_server_php.lng
index 491be1aae2..4d71bb50b7 100644
--- a/interface/web/admin/lib/lang/sk_server_php.lng
+++ b/interface/web/admin/lib/lang/sk_server_php.lng
@@ -17,4 +17,7 @@ $wb['php_fpm_socket_dir_txt'] = 'PHP-FPM socket directory';
 $wb['active_txt'] = 'Active';
 $wb['php_in_use_error'] = 'This PHP-Version is in use.';
 $wb['php_name_in_use_error'] = 'The name can not be changed.';
+$wb['PHP Sort Priority'] = 'Priority';
+$wb['sortprio_txt'] = 'Priority';
+$wb['sortprio_long_txt'] = 'Priority of PHP version in the PHP version select box<br>Default PHP has prio 0 if enabled<br>Lower value is higher priority';
 ?>
diff --git a/interface/web/admin/lib/lang/sk_server_php_list.lng b/interface/web/admin/lib/lang/sk_server_php_list.lng
index 291302cbb7..d5e6ad3c7f 100644
--- a/interface/web/admin/lib/lang/sk_server_php_list.lng
+++ b/interface/web/admin/lib/lang/sk_server_php_list.lng
@@ -6,4 +6,5 @@ $wb['client_id_txt'] = 'Client';
 $wb['name_txt'] = 'PHP Name';
 $wb['active_txt'] = 'Active';
 $wb['usage_txt'] = 'Usage count';
+$wb['sortprio_txt'] = 'Priority';
 ?>
diff --git a/interface/web/admin/lib/lang/tr_server_php.lng b/interface/web/admin/lib/lang/tr_server_php.lng
index 71b130e3d2..914d28f167 100644
--- a/interface/web/admin/lib/lang/tr_server_php.lng
+++ b/interface/web/admin/lib/lang/tr_server_php.lng
@@ -17,4 +17,7 @@ $wb['php_fpm_socket_dir_txt'] = 'PHP-FPM socket directory';
 $wb['active_txt'] = 'Etkin';
 $wb['php_in_use_error'] = 'This PHP-Version is in use.';
 $wb['php_name_in_use_error'] = 'The name can not be changed.';
+$wb['PHP Sort Priority'] = 'Priority';
+$wb['sortprio_txt'] = 'Priority';
+$wb['sortprio_long_txt'] = 'Priority of PHP version in the PHP version select box<br>Default PHP has prio 0 if enabled<br>Lower value is higher priority';
 ?>
diff --git a/interface/web/admin/lib/lang/tr_server_php_list.lng b/interface/web/admin/lib/lang/tr_server_php_list.lng
index 4468e7ead9..82fb3cc32e 100644
--- a/interface/web/admin/lib/lang/tr_server_php_list.lng
+++ b/interface/web/admin/lib/lang/tr_server_php_list.lng
@@ -6,4 +6,5 @@ $wb['client_id_txt'] = 'Müşteri';
 $wb['name_txt'] = 'PHP Adı';
 $wb['active_txt'] = 'Etkin';
 $wb['usage_txt'] = 'Usage count';
+$wb['sortprio_txt'] = 'Priority';
 ?>
diff --git a/interface/web/admin/server_php_edit.php b/interface/web/admin/server_php_edit.php
index a9e7b38bbb..8ad055624d 100644
--- a/interface/web/admin/server_php_edit.php
+++ b/interface/web/admin/server_php_edit.php
@@ -54,7 +54,13 @@ class page_action extends tform_actions {
 		parent::onSubmit();
 	}
 	function onBeforeUpdate() {
-		global $app;
+                
+                global $app;
+                
+                //check if Prio tab got update/save if yes disable datalog update - not needed
+                if(isset($this->dataRecord["sortprio"])) {
+                        $app->tform->formDef['db_history'] = 'no';
+                }
 
 		//* Check if the server has been changed
 		// We do this only for the admin or reseller users, as normal clients can not change the server ID anyway
diff --git a/interface/web/admin/templates/server_php_list.htm b/interface/web/admin/templates/server_php_list.htm
index a2595a8474..5f6fae91db 100644
--- a/interface/web/admin/templates/server_php_list.htm
+++ b/interface/web/admin/templates/server_php_list.htm
@@ -19,6 +19,7 @@
                         <th data-column="server_id"><tmpl_var name="server_id_txt"></th>
                         <th class="small-col" data-column="client_id"><tmpl_var name="client_id_txt"></th>
                         <th data-column="name"><tmpl_var name="name_txt"></th>
+                        <th class="small-col" data-column="sortprio"><tmpl_var name="sortprio_txt"></th>
                         <th data-column="usage"><tmpl_var name="usage_txt"></th>
                         <th class="text-right">{tmpl_var name='search_limit'}</th>
                     </tr>
@@ -27,7 +28,7 @@
                         <td><select class="form-control" name="search_server_id">{tmpl_var name='search_server_id'}</select></td>
                         <td><select class="form-control" name="search_client_id">{tmpl_var name='search_client_id'}</select></td>
                         <td><input class="form-control" type="text" name="search_name" value="{tmpl_var name='search_name'}" /></td>
-                        <td></td>
+                        <td></td><td></td>
                         <td class="text-right">
                             <button type="button" class="btn btn-default formbutton-default formbutton-narrow" name="Filter" id="Filter" value="{tmpl_var name="filter_txt"}" data-submit-form="pageForm" data-form-action="admin/server_php_list.php"><span class="icon icon-filter"></span></button>
                         </td>
@@ -40,7 +41,8 @@
                             <td><a href="#" data-load-content="admin/server_php_edit.php?id={tmpl_var name='id'}">{tmpl_var name="server_id"}</a></td>
                             <td><a href="#" data-load-content="admin/server_php_edit.php?id={tmpl_var name='id'}">{tmpl_var name="client_id"}</a></td>
                             <td><a href="#" data-load-content="admin/server_php_edit.php?id={tmpl_var name='id'}">{tmpl_var name="name"}</a></td>
-                            <td><a href="#" data-load-content="admin/server_php_edit.php?id={tmpl_var name='id'}">{tmpl_var name="usage"}</a></td>
+                            <td class="text-center"><a href="#" data-load-content="admin/server_php_edit.php?id={tmpl_var name='id'}">{tmpl_var name="sortprio"}</a></td>
+                            <td class="text-center"><a href="#" data-load-content="admin/server_php_edit.php?id={tmpl_var name='id'}">{tmpl_var name="usage"}</a></td>
                             <td class="text-right">
                                 <a class="btn btn-default formbutton-danger formbutton-narrow" href="javascript: ISPConfig.confirm_action('admin/server_php_del.php?id={tmpl_var name='id'}&_csrf_id={tmpl_var name='csrf_id'}&_csrf_key={tmpl_var name='csrf_key'}&phpsessid={tmpl_var name='phpsessid'}','{tmpl_var name='delete_confirmation'}');"><span class="icon icon-delete"></span></a>
                             </td>
diff --git a/interface/web/admin/templates/server_php_sort_edit.htm b/interface/web/admin/templates/server_php_sort_edit.htm
new file mode 100644
index 0000000000..c7ca24adfa
--- /dev/null
+++ b/interface/web/admin/templates/server_php_sort_edit.htm
@@ -0,0 +1,11 @@
+            <div class="form-group">
+                <label for="name" class="col-sm-3 control-label">{tmpl_var name='sortprio_txt'}</label>
+                <div class="col-sm-9"><input type="number" name="sortprio" id="sortprio" data-html="true" data-toggle="tooltip" data-placement="top"  title="{tmpl_var name='sortprio_long_txt'}" value="{tmpl_var name='sortprio'}" class="form-control" /></div>
+            </div>
+            
+        <input type="hidden" name="id" value="{tmpl_var name='id'}">
+            
+        <div class="clear"><div class="right">
+            <button class="btn btn-default formbutton-success" type="button" value="{tmpl_var name='btn_save_txt'}" data-submit-form="pageForm" data-form-action="admin/server_php_edit.php">{tmpl_var name='btn_save_txt'}</button>
+            <button class="btn btn-default formbutton-default" type="button" value="{tmpl_var name='btn_cancel_txt'}" data-load-content="admin/server_php_list.php">{tmpl_var name='btn_cancel_txt'}</button>
+        </div></div>
diff --git a/interface/web/sites/ajax_get_json.php b/interface/web/sites/ajax_get_json.php
index 936a584f20..f1d8433c8a 100644
--- a/interface/web/sites/ajax_get_json.php
+++ b/interface/web/sites/ajax_get_json.php
@@ -64,7 +64,7 @@ if($type == 'getserverid'){
 }
 
 if($type == 'getserverphp'){
-	$json = '{';
+	$json = '{"phpversion":['; //Wrap Objects into Array because chrome reorder objects itself
 
 	$server_type = 'apache';
 	$web_config = $app->getconf->get_server_config($server_id, 'web');
@@ -74,10 +74,10 @@ if($type == 'getserverphp'){
 
 	//* Client: If the logged in user is not admin and has no sub clients (no reseller)
 	if($_SESSION["s"]["user"]["typ"] != 'admin' && !$app->auth->has_clients($_SESSION['s']['user']['userid'])) {
-		$sql_where = " AND (client_id = 0 OR client_id = ".$app->functions->intval($_SESSION["s"]["user"]["client_id"]) . ")";
+		$sql_where = " AND (client_id = 0 OR client_id = ".$app->functions->intval($_SESSION["s"]["user"]["client_id"]) . ") ORDER BY sortprio";
 		//* Reseller: If the logged in user is not admin and has sub clients (is a reseller)
 	} elseif ($_SESSION["s"]["user"]["typ"] != 'admin' && $app->auth->has_clients($_SESSION['s']['user']['userid'])) {
-		$client = $app->db->queryOneRecord("SELECT client_id FROM sys_group WHERE groupid = ?", $client_group_id);
+		$client = $app->db->queryOneRecord("SELECT client_id FROM sys_group WHERE groupid = ? ORDER BY sortprio", $client_group_id);
 		//$sql_where = " AND (client_id = 0 OR client_id = ".$_SESSION["s"]["user"]["client_id"];
 		$sql_where = " AND (client_id = 0";
 		if($app->functions->intval($client['client_id']) > 0) $sql_where .= " OR client_id = ".$app->functions->intval($client['client_id']);
@@ -89,7 +89,7 @@ if($type == 'getserverphp'){
 		//$sql_where = " AND (client_id = 0 OR client_id = ".$_SESSION["s"]["user"]["client_id"];
 		$sql_where = " AND (client_id = 0";
 		if($app->functions->intval($client['client_id']) > 0) $sql_where .= " OR client_id = ".$app->functions->intval($client['client_id']);
-		$sql_where .= ")";
+		$sql_where .= ") ORDER BY sortprio";
 	}
 
 	$php_records = array();
@@ -98,10 +98,11 @@ if($type == 'getserverphp'){
 	} elseif($php_type == 'fast-cgi'){
 		$php_records = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fastcgi_binary != '' AND php_fastcgi_ini_dir != '' AND server_id = ? AND active = 'y'".$sql_where, $server_id);
 	}
+        $usePHPDefault=false;
+        $usePHPDefaultDone=false;
 	if (empty($web_config['php_default_hide']) || 'n' === $web_config['php_default_hide']) {
-		$php_records[]=array('name' => $app->functions->htmlentities($web_config['php_default_name']));
+                $usePHPDefault=true;
 	}
-	uasort($php_records, 'sort_php');
 	$php_select = "";
 	if(is_array($php_records) && !empty($php_records)) {
 		foreach( $php_records as $php_record) {
@@ -110,16 +111,17 @@ if($type == 'getserverphp'){
 			} else {
 				$php_version = $php_record['server_php_id'];
 			}
-			if($php_record['name'] != $web_config['php_default_name']) {
-				$json .= '"'.$php_version.'": "'.$php_record['name'].'",';
-			} else {
-				$json .= '"0": "'.$php_record['name'].'",';
-			}
+                        if ($php_record['sortprio'] > 0 && $usePHPDefault && $usePHPDefaultDone == false)  //if DefaultPHP is enable insert it on virtual position 0
+                        {
+                            $json .= '{"0": "'.$web_config['php_default_name'].'"},';
+                            $usePHPDefaultDone = true;
+                        }
+			$json .= '{"'.$php_version.'": "'.$php_record['name'].'"},';
 		}
 	}
 	unset($php_records);
 	if(substr($json, -1) == ',') $json = substr($json, 0, -1);
-	$json .= '}';
+	$json .= ']}';
 }
 
 if($type == 'getphptype'){
diff --git a/interface/web/sites/templates/web_vhost_domain_edit.htm b/interface/web/sites/templates/web_vhost_domain_edit.htm
index c4421aac74..356e03e2dc 100644
--- a/interface/web/sites/templates/web_vhost_domain_edit.htm
+++ b/interface/web/sites/templates/web_vhost_domain_edit.htm
@@ -456,7 +456,9 @@
             //var options = '<option value="">Default</option>';
 			var options = '';
             var serverphpidselected = '';
-            $.each(data, function(key, val) {
+            $.each(data.phpversion, function(akey,aval) {
+                key=Object.getOwnPropertyNames(aval)[0];
+                val=aval[key];
 				<tmpl_if name="id">
                 if($('#server_php_id').val() == key){
                     serverphpidselected = ' selected="selected"';
-- 
GitLab