/** * @return bool */ public function Load() { if (\file_exists($this->sFile) && \is_readable($this->sFile)) { if ($this->loadDataFromCache()) { return true; } $aData = \RainLoop\Utils::CustomParseIniFile($this->sFile, true); if (\is_array($aData) && 0 < \count($aData)) { foreach ($aData as $sSectionKey => $aSectionValue) { if (\is_array($aSectionValue)) { foreach ($aSectionValue as $sParamKey => $mParamValue) { $this->Set($sSectionKey, $sParamKey, $mParamValue); } } } unset($aData); if (\file_exists($this->sAdditionalFile) && \is_readable($this->sAdditionalFile)) { $aSubData = \RainLoop\Utils::CustomParseIniFile($this->sAdditionalFile, true); if (\is_array($aSubData) && 0 < \count($aSubData)) { foreach ($aSubData as $sSectionKey => $aSectionValue) { if (\is_array($aSectionValue)) { foreach ($aSectionValue as $sParamKey => $mParamValue) { $this->Set($sSectionKey, $sParamKey, $mParamValue); } } } } unset($aSubData); } $this->storeDataToCache(); return true; } } return false; }
/** * @param string $sFileName * @param array $aResultLang * * @return void */ public static function ReadAndAddLang($sFileName, &$aResultLang) { if (\file_exists($sFileName)) { $aLang = \RainLoop\Utils::CustomParseIniFile($sFileName, true); if (\is_array($aLang)) { foreach ($aLang as $sKey => $mValue) { if (\is_array($mValue)) { foreach ($mValue as $sSecKey => $mSecValue) { $aResultLang[$sKey . '/' . $sSecKey] = $mSecValue; } } else { $aResultLang[$sKey] = $mValue; } } } } }
/** * @param string $sName * @param bool $bFindWithWildCard = false * @param bool $bCheckDisabled = true * * @return \RainLoop\Model\Domain|null */ public function Load($sName, $bFindWithWildCard = false, $bCheckDisabled = true) { $mResult = null; $sDisabled = ''; $sFoundedValue = ''; $sRealFileName = $this->codeFileName($sName); if (\file_exists($this->sDomainPath . '/disabled')) { $sDisabled = @\file_get_contents($this->sDomainPath . '/disabled'); } if (\file_exists($this->sDomainPath . '/' . $sRealFileName . '.ini') && (!$bCheckDisabled || 0 === \strlen($sDisabled) || false === \strpos(',' . $sDisabled . ',', ',' . \MailSo\Base\Utils::IdnToAscii($sName, true) . ','))) { $aDomain = \RainLoop\Utils::CustomParseIniFile($this->sDomainPath . '/' . $sRealFileName . '.ini'); // fix misspellings (#119) if (\is_array($aDomain)) { if (isset($aDomain['smpt_host'])) { $aDomain['smtp_host'] = $aDomain['smpt_host']; } if (isset($aDomain['smpt_port'])) { $aDomain['smtp_port'] = $aDomain['smpt_port']; } if (isset($aDomain['smpt_secure'])) { $aDomain['smtp_secure'] = $aDomain['smpt_secure']; } if (isset($aDomain['smpt_auth'])) { $aDomain['smtp_auth'] = $aDomain['smpt_auth']; } } //--- $mResult = \RainLoop\Model\Domain::NewInstanceFromDomainConfigArray($sName, $aDomain); } else { if ($bFindWithWildCard) { $sNames = $this->getWildcardDomainsLine(); if (0 < \strlen($sNames)) { if (\RainLoop\Plugins\Helper::ValidateWildcardValues(\MailSo\Base\Utils::IdnToUtf8($sName, true), $sNames, $sFoundedValue) && 0 < \strlen($sFoundedValue)) { if (!$bCheckDisabled || 0 === \strlen($sDisabled) || false === \strpos(',' . $sDisabled . ',', ',' . $sFoundedValue . ',')) { $mResult = $this->Load($sFoundedValue, false); } } } } } return $mResult; }
/** * @param string $sFileName * @param array $aResultLang * * @return void */ public static function ReadAndAddLang($sFileName, &$aResultLang) { if (\file_exists($sFileName)) { $isYml = '.yml' === substr($sFileName, -4); if ($isYml) { $aLang = \spyc_load(\str_replace(array(': >-', ': |-'), array(': >', ': |'), \file_get_contents($sFileName))); if (\is_array($aLang)) { \reset($aLang); $sLangKey = key($aLang); if (isset($aLang[$sLangKey]) && is_array($aLang[$sLangKey])) { $aLang = $aLang[$sLangKey]; } else { $aLang = null; } } } else { $aLang = \RainLoop\Utils::CustomParseIniFile($sFileName, true); } if (\is_array($aLang)) { foreach ($aLang as $sKey => $mValue) { if (\is_array($mValue)) { foreach ($mValue as $sSecKey => $mSecValue) { $aResultLang[$sKey . '/' . $sSecKey] = $mSecValue; } } else { $aResultLang[$sKey] = $mValue; } } } } }