@@ -371,6 +371,84 @@ public function add_database_server_record() {
371371
372372
373373 }
374+
375+ public function detect_ips (){
376+ global $ conf ;
377+
378+ exec ("ip addr show | awk '/global/ { print $2 }' | cut -d '/' -f 1 " , $ output , $ retval );
379+
380+ if ($ retval == 0 ){
381+ if (is_array ($ output ) && !empty ($ output )){
382+ foreach ($ output as $ line ){
383+ $ line = trim ($ line );
384+ $ ip_type = '' ;
385+ if (filter_var ($ line , FILTER_VALIDATE_IP , FILTER_FLAG_IPV4 )) {
386+ $ ip_type = 'IPv4 ' ;
387+ }
388+ if (filter_var ($ line , FILTER_VALIDATE_IP , FILTER_FLAG_IPV6 )) {
389+ $ ip_type = 'IPv6 ' ;
390+ }
391+ if ($ ip_type == '' ) continue ;
392+ if ($ this ->db ->dbHost != $ this ->dbmaster ->dbHost ){
393+ $ this ->dbmaster ->query ('INSERT INTO server_ip (
394+ sys_userid, sys_groupid, sys_perm_user, sys_perm_group,
395+ sys_perm_other, server_id, client_id, ip_type, ip_address,
396+ virtualhost, virtualhost_port
397+ ) VALUES (
398+ 1,
399+ 1,
400+ "riud",
401+ "riud",
402+ "",
403+ ?,
404+ 0,
405+ ?,
406+ ?,
407+ "y",
408+ "80,443"
409+ ) ' , $ conf ['server_id ' ], $ ip_type , $ line );
410+ $ server_ip_id = $ this ->dbmaster ->insertID ();
411+ $ this ->db ->query ('INSERT INTO server_ip (
412+ server_php_id, sys_userid, sys_groupid, sys_perm_user, sys_perm_group,
413+ sys_perm_other, server_id, client_id, ip_type, ip_address,
414+ virtualhost, virtualhost_port
415+ ) VALUES (
416+ ?,
417+ 1,
418+ 1,
419+ "riud",
420+ "riud",
421+ "",
422+ ?,
423+ 0,
424+ ?,
425+ ?,
426+ "y",
427+ "80,443"
428+ ) ' , $ server_ip_id , $ conf ['server_id ' ], $ ip_type , $ line );
429+ } else {
430+ $ this ->db ->query ('INSERT INTO server_ip (
431+ sys_userid, sys_groupid, sys_perm_user, sys_perm_group,
432+ sys_perm_other, server_id, client_id, ip_type, ip_address,
433+ virtualhost, virtualhost_port
434+ ) VALUES (
435+ 1,
436+ 1,
437+ "riud",
438+ "riud",
439+ "",
440+ ?,
441+ 0,
442+ ?,
443+ ?,
444+ "y",
445+ "80,443"
446+ ) ' , $ conf ['server_id ' ], $ ip_type , $ line );
447+ }
448+ }
449+ }
450+ }
451+ }
374452
375453 public function grant_master_database_rights ($ verbose = false ) {
376454 global $ conf ;
0 commit comments