@@ -301,23 +301,25 @@ public function dns_aaaa_get($session_id, $primary_id)
301301 }
302302
303303 //* Add a record
304- public function dns_aaaa_add ($ session_id , $ client_id , $ params )
304+ public function dns_aaaa_add ($ session_id , $ client_id , $ params, $ update_serial = false )
305305 {
306306 if (!$ this ->checkPerm ($ session_id , 'dns_aaaa_add ' )) {
307307 throw new SoapFault ('permission_denied ' , 'You do not have the permissions to access this function. ' );
308308 return false ;
309309 }
310+ if ($ update_serial != false ) $ this ->increase_serial ($ session_id , $ client_id , $ params );
310311 return $ this ->insertQuery ('../dns/form/dns_aaaa.tform.php ' , $ client_id , $ params );
311312 }
312313
313314 //* Update a record
314- public function dns_aaaa_update ($ session_id , $ client_id , $ primary_id , $ params )
315+ public function dns_aaaa_update ($ session_id , $ client_id , $ primary_id , $ params, $ update_serial = false )
315316 {
316317 if (!$ this ->checkPerm ($ session_id , 'dns_aaaa_update ' )) {
317318 throw new SoapFault ('permission_denied ' , 'You do not have the permissions to access this function. ' );
318319 return false ;
319320 }
320321 $ affected_rows = $ this ->updateQuery ('../dns/form/dns_aaaa.tform.php ' , $ client_id , $ primary_id , $ params );
322+ if ($ update_serial != false ) $ this ->increase_serial ($ session_id , $ client_id , $ params );
321323 return $ affected_rows ;
322324 }
323325
@@ -349,22 +351,24 @@ public function dns_a_get($session_id, $primary_id)
349351 }
350352
351353 //* Add a record
352- public function dns_a_add ($ session_id , $ client_id , $ params )
354+ public function dns_a_add ($ session_id , $ client_id , $ params, $ update_serial = false )
353355 {
354356 if (!$ this ->checkPerm ($ session_id , 'dns_a_add ' )) {
355357 throw new SoapFault ('permission_denied ' , 'You do not have the permissions to access this function. ' );
356358 return false ;
357359 }
360+ if ($ update_serial != false ) $ this ->increase_serial ($ session_id , $ client_id , $ params );
358361 return $ this ->insertQuery ('../dns/form/dns_a.tform.php ' , $ client_id , $ params );
359362 }
360363
361364 //* Update a record
362- public function dns_a_update ($ session_id , $ client_id , $ primary_id , $ params )
365+ public function dns_a_update ($ session_id , $ client_id , $ primary_id , $ params, $ update_serial = false )
363366 {
364367 if (!$ this ->checkPerm ($ session_id , 'dns_a_update ' )) {
365368 throw new SoapFault ('permission_denied ' , 'You do not have the permissions to access this function. ' );
366369 return false ;
367370 }
371+ if ($ update_serial != false ) $ this ->increase_serial ($ session_id , $ client_id , $ params );
368372 $ affected_rows = $ this ->updateQuery ('../dns/form/dns_a.tform.php ' , $ client_id , $ primary_id , $ params );
369373 return $ affected_rows ;
370374 }
@@ -397,22 +401,24 @@ public function dns_alias_get($session_id, $primary_id)
397401 }
398402
399403 //* Add a record
400- public function dns_alias_add ($ session_id , $ client_id , $ params )
404+ public function dns_alias_add ($ session_id , $ client_id , $ params, $ update_serial = false )
401405 {
402406 if (!$ this ->checkPerm ($ session_id , 'dns_alias_add ' )) {
403407 throw new SoapFault ('permission_denied ' , 'You do not have the permissions to access this function. ' );
404408 return false ;
405409 }
410+ if ($ update_serial != false ) $ this ->increase_serial ($ session_id , $ client_id , $ params );
406411 return $ this ->insertQuery ('../dns/form/dns_alias.tform.php ' , $ client_id , $ params );
407412 }
408413
409414 //* Update a record
410- public function dns_alias_update ($ session_id , $ client_id , $ primary_id , $ params )
415+ public function dns_alias_update ($ session_id , $ client_id , $ primary_id , $ params, $ update_serial = false )
411416 {
412417 if (!$ this ->checkPerm ($ session_id , 'dns_alias_update ' )) {
413418 throw new SoapFault ('permission_denied ' , 'You do not have the permissions to access this function. ' );
414419 return false ;
415420 }
421+ if ($ update_serial != false ) $ this ->increase_serial ($ session_id , $ client_id , $ params );
416422 $ affected_rows = $ this ->updateQuery ('../dns/form/dns_alias.tform.php ' , $ client_id , $ primary_id , $ params );
417423 return $ affected_rows ;
418424 }
@@ -445,22 +451,24 @@ public function dns_cname_get($session_id, $primary_id)
445451 }
446452
447453 //* Add a record
448- public function dns_cname_add ($ session_id , $ client_id , $ params )
454+ public function dns_cname_add ($ session_id , $ client_id , $ params, $ update_serial = false )
449455 {
450456 if (!$ this ->checkPerm ($ session_id , 'dns_cname_add ' )) {
451457 throw new SoapFault ('permission_denied ' , 'You do not have the permissions to access this function. ' );
452458 return false ;
453459 }
460+ if ($ update_serial != false ) $ this ->increase_serial ($ session_id , $ client_id , $ params );
454461 return $ this ->insertQuery ('../dns/form/dns_cname.tform.php ' , $ client_id , $ params );
455462 }
456463
457464 //* Update a record
458- public function dns_cname_update ($ session_id , $ client_id , $ primary_id , $ params )
465+ public function dns_cname_update ($ session_id , $ client_id , $ primary_id , $ params, $ update_serial = false )
459466 {
460467 if (!$ this ->checkPerm ($ session_id , 'dns_cname_update ' )) {
461468 throw new SoapFault ('permission_denied ' , 'You do not have the permissions to access this function. ' );
462469 return false ;
463470 }
471+ if ($ update_serial != false ) $ this ->increase_serial ($ session_id , $ client_id , $ params );
464472 $ affected_rows = $ this ->updateQuery ('../dns/form/dns_cname.tform.php ' , $ client_id , $ primary_id , $ params );
465473 return $ affected_rows ;
466474 }
@@ -493,22 +501,24 @@ public function dns_hinfo_get($session_id, $primary_id)
493501 }
494502
495503 //* Add a record
496- public function dns_hinfo_add ($ session_id , $ client_id , $ params )
504+ public function dns_hinfo_add ($ session_id , $ client_id , $ params, $ update_serial = false )
497505 {
498506 if (!$ this ->checkPerm ($ session_id , 'dns_hinfo_add ' )) {
499507 throw new SoapFault ('permission_denied ' , 'You do not have the permissions to access this function. ' );
500508 return false ;
501509 }
510+ if ($ update_serial != false ) $ this ->increase_serial ($ session_id , $ client_id , $ params );
502511 return $ this ->insertQuery ('../dns/form/dns_hinfo.tform.php ' , $ client_id , $ params );
503512 }
504513
505514 //* Update a record
506- public function dns_hinfo_update ($ session_id , $ client_id , $ primary_id , $ params )
515+ public function dns_hinfo_update ($ session_id , $ client_id , $ primary_id , $ params, $ update_serial = false )
507516 {
508517 if (!$ this ->checkPerm ($ session_id , 'dns_hinfo_update ' )) {
509518 throw new SoapFault ('permission_denied ' , 'You do not have the permissions to access this function. ' );
510519 return false ;
511520 }
521+ if ($ update_serial != false ) $ this ->increase_serial ($ session_id , $ client_id , $ params );
512522 $ affected_rows = $ this ->updateQuery ('../dns/form/dns_hinfo.tform.php ' , $ client_id , $ primary_id , $ params );
513523 return $ affected_rows ;
514524 }
@@ -541,22 +551,24 @@ public function dns_mx_get($session_id, $primary_id)
541551 }
542552
543553 //* Add a record
544- public function dns_mx_add ($ session_id , $ client_id , $ params )
554+ public function dns_mx_add ($ session_id , $ client_id , $ params, $ update_serial = false )
545555 {
546556 if (!$ this ->checkPerm ($ session_id , 'dns_mx_add ' )) {
547557 throw new SoapFault ('permission_denied ' , 'You do not have the permissions to access this function. ' );
548558 return false ;
549559 }
560+ if ($ update_serial != false ) $ this ->increase_serial ($ session_id , $ client_id , $ params );
550561 return $ this ->insertQuery ('../dns/form/dns_mx.tform.php ' , $ client_id , $ params );
551562 }
552563
553564 //* Update a record
554- public function dns_mx_update ($ session_id , $ client_id , $ primary_id , $ params )
565+ public function dns_mx_update ($ session_id , $ client_id , $ primary_id , $ params, $ update_serial = false )
555566 {
556567 if (!$ this ->checkPerm ($ session_id , 'dns_mx_update ' )) {
557568 throw new SoapFault ('permission_denied ' , 'You do not have the permissions to access this function. ' );
558569 return false ;
559570 }
571+ if ($ update_serial != false ) $ this ->increase_serial ($ session_id , $ client_id , $ params );
560572 $ affected_rows = $ this ->updateQuery ('../dns/form/dns_mx.tform.php ' , $ client_id , $ primary_id , $ params );
561573 return $ affected_rows ;
562574 }
@@ -589,22 +601,24 @@ public function dns_ns_get($session_id, $primary_id)
589601 }
590602
591603 //* Add a record
592- public function dns_ns_add ($ session_id , $ client_id , $ params )
604+ public function dns_ns_add ($ session_id , $ client_id , $ params, $ update_serial = false )
593605 {
594606 if (!$ this ->checkPerm ($ session_id , 'dns_ns_add ' )) {
595607 throw new SoapFault ('permission_denied ' , 'You do not have the permissions to access this function. ' );
596608 return false ;
597609 }
610+ if ($ update_serial != false ) $ this ->increase_serial ($ session_id , $ client_id , $ params );
598611 return $ this ->insertQuery ('../dns/form/dns_ns.tform.php ' , $ client_id , $ params );
599612 }
600613
601614 //* Update a record
602- public function dns_ns_update ($ session_id , $ client_id , $ primary_id , $ params )
615+ public function dns_ns_update ($ session_id , $ client_id , $ primary_id , $ params, $ update_serial = false )
603616 {
604617 if (!$ this ->checkPerm ($ session_id , 'dns_ns_update ' )) {
605618 throw new SoapFault ('permission_denied ' , 'You do not have the permissions to access this function. ' );
606619 return false ;
607620 }
621+ if ($ update_serial != false ) $ this ->increase_serial ($ session_id , $ client_id , $ params );
608622 $ affected_rows = $ this ->updateQuery ('../dns/form/dns_ns.tform.php ' , $ client_id , $ primary_id , $ params );
609623 return $ affected_rows ;
610624 }
@@ -637,22 +651,24 @@ public function dns_ptr_get($session_id, $primary_id)
637651 }
638652
639653 //* Add a record
640- public function dns_ptr_add ($ session_id , $ client_id , $ params )
654+ public function dns_ptr_add ($ session_id , $ client_id , $ params, $ update_serial = false )
641655 {
642656 if (!$ this ->checkPerm ($ session_id , 'dns_ptr_add ' )) {
643657 throw new SoapFault ('permission_denied ' , 'You do not have the permissions to access this function. ' );
644658 return false ;
645659 }
660+ if ($ update_serial != false ) $ this ->increase_serial ($ session_id , $ client_id , $ params );
646661 return $ this ->insertQuery ('../dns/form/dns_ptr.tform.php ' , $ client_id , $ params );
647662 }
648663
649664 //* Update a record
650- public function dns_ptr_update ($ session_id , $ client_id , $ primary_id , $ params )
665+ public function dns_ptr_update ($ session_id , $ client_id , $ primary_id , $ params, $ update_serial = false )
651666 {
652667 if (!$ this ->checkPerm ($ session_id , 'dns_ptr_update ' )) {
653668 throw new SoapFault ('permission_denied ' , 'You do not have the permissions to access this function. ' );
654669 return false ;
655670 }
671+ if ($ update_serial != false ) $ this ->increase_serial ($ session_id , $ client_id , $ params );
656672 $ affected_rows = $ this ->updateQuery ('../dns/form/dns_ptr.tform.php ' , $ client_id , $ primary_id , $ params );
657673 return $ affected_rows ;
658674 }
@@ -685,22 +701,24 @@ public function dns_rp_get($session_id, $primary_id)
685701 }
686702
687703 //* Add a record
688- public function dns_rp_add ($ session_id , $ client_id , $ params )
704+ public function dns_rp_add ($ session_id , $ client_id , $ params, $ update_serial = false )
689705 {
690706 if (!$ this ->checkPerm ($ session_id , 'dns_rp_add ' )) {
691707 throw new SoapFault ('permission_denied ' , 'You do not have the permissions to access this function. ' );
692708 return false ;
693709 }
710+ if ($ update_serial != false ) $ this ->increase_serial ($ session_id , $ client_id , $ params );
694711 return $ this ->insertQuery ('../dns/form/dns_rp.tform.php ' , $ client_id , $ params );
695712 }
696713
697714 //* Update a record
698- public function dns_rp_update ($ session_id , $ client_id , $ primary_id , $ params )
715+ public function dns_rp_update ($ session_id , $ client_id , $ primary_id , $ params, $ update_serial = false )
699716 {
700717 if (!$ this ->checkPerm ($ session_id , 'dns_rp_update ' )) {
701718 throw new SoapFault ('permission_denied ' , 'You do not have the permissions to access this function. ' );
702719 return false ;
703720 }
721+ if ($ update_serial != false ) $ this ->increase_serial ($ session_id , $ client_id , $ params );
704722 $ affected_rows = $ this ->updateQuery ('../dns/form/dns_rp.tform.php ' , $ client_id , $ primary_id , $ params );
705723 return $ affected_rows ;
706724 }
@@ -733,22 +751,24 @@ public function dns_srv_get($session_id, $primary_id)
733751 }
734752
735753 //* Add a record
736- public function dns_srv_add ($ session_id , $ client_id , $ params )
754+ public function dns_srv_add ($ session_id , $ client_id , $ params, $ update_serial = false )
737755 {
738756 if (!$ this ->checkPerm ($ session_id , 'dns_srv_add ' )) {
739757 throw new SoapFault ('permission_denied ' , 'You do not have the permissions to access this function. ' );
740758 return false ;
741759 }
760+ if ($ update_serial != false ) $ this ->increase_serial ($ session_id , $ client_id , $ params );
742761 return $ this ->insertQuery ('../dns/form/dns_srv.tform.php ' , $ client_id , $ params );
743762 }
744763
745764 //* Update a record
746- public function dns_srv_update ($ session_id , $ client_id , $ primary_id , $ params )
765+ public function dns_srv_update ($ session_id , $ client_id , $ primary_id , $ params, $ update_serial = false )
747766 {
748767 if (!$ this ->checkPerm ($ session_id , 'dns_srv_update ' )) {
749768 throw new SoapFault ('permission_denied ' , 'You do not have the permissions to access this function. ' );
750769 return false ;
751770 }
771+ if ($ update_serial != false ) $ this ->increase_serial ($ session_id , $ client_id , $ params );
752772 $ affected_rows = $ this ->updateQuery ('../dns/form/dns_srv.tform.php ' , $ client_id , $ primary_id , $ params );
753773 return $ affected_rows ;
754774 }
@@ -781,22 +801,24 @@ public function dns_txt_get($session_id, $primary_id)
781801 }
782802
783803 //* Add a record
784- public function dns_txt_add ($ session_id , $ client_id , $ params )
804+ public function dns_txt_add ($ session_id , $ client_id , $ params, $ update_serial = false )
785805 {
786806 if (!$ this ->checkPerm ($ session_id , 'dns_txt_add ' )) {
787807 throw new SoapFault ('permission_denied ' , 'You do not have the permissions to access this function. ' );
788808 return false ;
789809 }
810+ if ($ update_serial != false ) $ this ->increase_serial ($ session_id , $ client_id , $ params );
790811 return $ this ->insertQuery ('../dns/form/dns_txt.tform.php ' , $ client_id , $ params );
791812 }
792813
793814 //* Update a record
794- public function dns_txt_update ($ session_id , $ client_id , $ primary_id , $ params )
815+ public function dns_txt_update ($ session_id , $ client_id , $ primary_id , $ params, $ update_serial = false )
795816 {
796817 if (!$ this ->checkPerm ($ session_id , 'dns_txt_update ' )) {
797818 throw new SoapFault ('permission_denied ' , 'You do not have the permissions to access this function. ' );
798819 return false ;
799820 }
821+ if ($ update_serial != false ) $ this ->increase_serial ($ session_id , $ client_id , $ params );
800822 $ affected_rows = $ this ->updateQuery ('../dns/form/dns_txt.tform.php ' , $ client_id , $ primary_id , $ params );
801823 return $ affected_rows ;
802824 }
@@ -882,6 +904,26 @@ public function dns_zone_set_status($session_id, $primary_id, $status) {
882904 }
883905 }
884906
907+ private function increase_serial ($ session_id , $ client_id , $ params ) {
908+ $ soa = $ this ->dns_zone_get ($ session_id , $ params ['zone ' ]);
909+ $ serial =$ soa ['serial ' ];
910+ $ serial_date = intval (substr ($ serial , 0 , 8 ));
911+ $ count = intval (substr ($ serial , 8 , 2 ));
912+ $ current_date = date ("Ymd " );
913+ if ($ serial_date >= $ current_date ){
914+ $ count += 1 ;
915+ if ($ count > 99 ) {
916+ $ serial_date += 1 ;
917+ $ count = 0 ;
918+ }
919+ $ count = str_pad ($ count , 2 , "0 " , STR_PAD_LEFT );
920+ $ new_serial = $ serial_date .$ count ;
921+ } else {
922+ $ new_serial = $ current_date .'01 ' ;
923+ }
924+ $ soa ['serial ' ] = $ new_serial ;
925+ $ this ->dns_zone_update ($ session_id , $ client_id , $ soa ['id ' ], $ soa );
926+ }
885927}
886928
887929?>
0 commit comments