From 92671f572370a48c595b2db454be769e69d87e83 Mon Sep 17 00:00:00 2001 From: James Date: Thu, 19 Apr 2012 15:18:53 -0400 Subject: [PATCH] CC-3681: the value range for the Master, Show Source posrts should be corrected (shrinked) - added validator that check if the value is between 1024 and 49151 --- .../forms/LiveStreamingPreferences.php | 44 +++++++++++-------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/airtime_mvc/application/forms/LiveStreamingPreferences.php b/airtime_mvc/application/forms/LiveStreamingPreferences.php index 7d22f6383..1818d1e6d 100644 --- a/airtime_mvc/application/forms/LiveStreamingPreferences.php +++ b/airtime_mvc/application/forms/LiveStreamingPreferences.php @@ -46,7 +46,7 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm $master_dj_port = new Zend_Form_Element_Text('master_harbor_input_port'); $master_dj_port->setLabel("Master Source Port") ->setValue($m_port) - ->setValidators(array(new Zend_Validate_Between(array('min'=>0, 'max'=>99999)))) + ->setValidators(array(new Zend_Validate_Between(array('min'=>1024, 'max'=>49151)))) ->addValidator('regex', false, array('pattern'=>'/^[0-9]+$/', 'messages'=>array('regexNotMatch'=>'Only numbers are allowed.'))) ->setDecorators(array('ViewHelper')); $this->addElement($master_dj_port); @@ -65,7 +65,7 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm $live_dj_port = new Zend_Form_Element_Text('dj_harbor_input_port'); $live_dj_port->setLabel("Show Source Port") ->setValue($l_port) - ->setValidators(array(new Zend_Validate_Between(array('min'=>0, 'max'=>99999)))) + ->setValidators(array(new Zend_Validate_Between(array('min'=>1024, 'max'=>49151)))) ->addValidator('regex', false, array('pattern'=>'/^[0-9]+$/', 'messages'=>array('regexNotMatch'=>'Only numbers are allowed.'))) ->setDecorators(array('ViewHelper')); $this->addElement($live_dj_port); @@ -117,27 +117,35 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm $element->addError("You cannot use same port as Master DJ port."); } if($master_harbor_input_port != ""){ - if($master_harbor_input_port != Application_Model_StreamSetting::GetMasterLiveSteamPort()){ - $sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); - $res = socket_bind($sock, 0, $master_harbor_input_port); - if(!$res){ - $element = $this->getElement("master_harbor_input_port"); - $element->addError("Port '$master_harbor_input_port' is not available."); - $isValid = false; + if(is_numeric($master_harbor_input_port)){ + if($master_harbor_input_port != Application_Model_StreamSetting::GetMasterLiveSteamPort()){ + $sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); + $res = socket_bind($sock, 0, $master_harbor_input_port); + if(!$res){ + $element = $this->getElement("master_harbor_input_port"); + $element->addError("Port '$master_harbor_input_port' is not available."); + $isValid = false; + } + socket_close($sock); } - socket_close($sock); + }else{ + $isValid = false; } } if($dj_harbor_input_port != ""){ - if($dj_harbor_input_port != Application_Model_StreamSetting::GetDJLiveSteamPort()){ - $sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); - $res = socket_bind($sock, 0, $dj_harbor_input_port); - if(!$res){ - $element = $this->getElement("dj_harbor_input_port"); - $element->addError("Port '$dj_harbor_input_port' is not available."); - $isValid = false; + if(is_numeric($dj_harbor_input_port)){ + if($dj_harbor_input_port != Application_Model_StreamSetting::GetDJLiveSteamPort()){ + $sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); + $res = socket_bind($sock, 0, $dj_harbor_input_port); + if(!$res){ + $element = $this->getElement("dj_harbor_input_port"); + $element->addError("Port '$dj_harbor_input_port' is not available."); + $isValid = false; + } + socket_close($sock); } - socket_close($sock); + }else{ + $isValid = false; } } return $isValid;