Пример #1
0
 public static function checkDomainIsCorrect($sName, $sLang, $type = false)
 {
     global $wgUser;
     wfProfileIn(__METHOD__);
     $sResponse = "";
     if (strlen($sName) === 0) {
         #-- empty field
         $sResponse = wfMsg('autocreatewiki-empty-field');
     } elseif (strlen($sName) < 3) {
         #-- too short
         $sResponse = wfMsg('autocreatewiki-name-too-short');
     } elseif (strlen($sName) > 50) {
         #-- too short
         $sResponse = wfMsg('autocreatewiki-name-too-long');
     } elseif (preg_match('/[^a-z0-9-]/i', $sName)) {
         #-- invalid name
         $sResponse = wfMsg('autocreatewiki-bad-name');
     } elseif (in_array($sName, array_keys(Language::getLanguageNames()))) {
         #-- invalid name
         $sResponse = wfMsg('autocreatewiki-violate-policy');
     } elseif (!in_array('staff', $wgUser->getGroups()) && self::checkBadWords($sName, "domain") === false) {
         #-- invalid name (bad words)
         $sResponse = wfMsg('autocreatewiki-violate-policy');
     } else {
         $iExists = AutoCreateWiki::domainExists($sName, $sLang, $type);
         if (!empty($iExists)) {
             #--- domain exists
             $sResponse = wfMsg('autocreatewiki-name-taken', !is_null($sLang) && $sLang != 'en' ? sprintf("%s.%s", $sLang, $sName) : $sName);
         }
     }
     wfProfileOut(__METHOD__);
     return $sResponse;
 }
Пример #2
0
 /**
  * check if domain is not taken or is creatable
  */
 private function checkDomain()
 {
     global $wgUser;
     $status = 0;
     wfProfileIn(__METHOD__);
     if (strlen($this->mDomain) === 0) {
         // empty field
         $status = self::ERROR_DOMAIN_IS_EMPTY;
     } elseif (strlen($this->mDomain) < 3) {
         // too short
         $status = self::ERROR_DOMAIN_TOO_SHORT;
     } elseif (strlen($this->mDomain) > 50) {
         // too long
         $status = self::ERROR_DOMAIN_TOO_LONG;
     } elseif (preg_match('/[^a-z0-9-]/i', $this->mDomain)) {
         // invalid name
         $status = self::ERROR_DOMAIN_BAD_NAME;
     } elseif (in_array($this->mDomain, array_keys(Language::getLanguageNames()))) {
         // invalid name (name is used language)
         $status = self::ERROR_DOMAIN_POLICY_VIOLATIONS;
     } elseif (!$wgUser->isAllowed("staff") && AutoCreateWiki::checkBadWords($this->mDomain, "domain") === false) {
         // invalid name (bad words)
         $status = self::ERROR_DOMAIN_POLICY_VIOLATIONS;
     } else {
         if (AutoCreateWiki::domainExists($this->mDomain, $this->mLanguage)) {
             $status = self::ERROR_DOMAIN_NAME_TAKEN;
         }
     }
     wfProfileOut(__METHOD__);
     return $status;
 }
Пример #3
0
 public static function checkDomainExists($sName, $sLang, $type)
 {
     return AutoCreateWiki::domainExists($sName, $sLang, $type);
 }