/** * Checks that the server running on hostname:port is actually XBMC and not * some other software. We do this by looking at the authentication realm * string. * @param string $attribute the attribute being validated ("username" in * this case) */ public function checkServerType($attribute) { if (!$this->areAttributesValid(array('hostname', 'port'))) { return; } $webserver = new WebServer($this->hostname, $this->port); // Check that the server requires authentication if (!$webserver->requiresAuthentication()) { $this->addError($attribute, Yii::t('Backend', 'The server does not ask for authentication')); } else { // Check the authentication realm $realm = $webserver->getAuthenticationRealm(); if (strtolower($realm) !== 'xbmc') { $message = 'The server at ' . $webserver->getHostInfo() . " doesn't seem to be an XBMC instance"; // Log whatever string the server identified as for debugging purposes Yii::log($message . ' (the server identified as "' . $realm . '")', CLogger::LEVEL_ERROR, 'Backend'); $this->addError($attribute, $message); } } }