コード例 #1
0
ファイル: Context.class.php プロジェクト: rhymix/rhymix
 /**
  * Convert IDNA (punycode) domain into UTF-8
  * 
  * @param string $domain Domain to convert
  * @return string Converted string
  */
 public static function decodeIdna($domain)
 {
     return Rhymix\Framework\URL::decodeIdna($domain);
 }
コード例 #2
0
 /**
  * Save the exception configuration.
  */
 public function procAdvanced_MailerAdminInsertExceptions()
 {
     // Get the current configuration.
     $config = $this->getConfig();
     $sending_methods = Rhymix\Framework\Mail::getSupportedDrivers();
     // Get and validate the list of exceptions.
     $exceptions = array();
     for ($i = 1; $i <= 3; $i++) {
         $method = strval(Context::get('exception_' . $i . '_method'));
         $domains = trim(Context::get('exception_' . $i . '_domains'));
         if ($method !== '' && $domains !== '') {
             if ($method !== 'default' && !isset($sending_methods[$method])) {
                 return new Object(-1, 'msg_advanced_mailer_sending_method_is_invalid');
             }
             if ($method !== 'default') {
                 foreach ($this->sending_methods[$method]['required'] as $conf_name) {
                     if (!Rhymix\Framework\Config::get("mail.{$method}.{$conf_name}")) {
                         return new Object(-1, sprintf(Context::getLang('msg_advanced_mailer_sending_method_is_not_configured'), Context::getLang('cmd_advanced_mailer_sending_method_' . $method)));
                     }
                 }
             }
             $exceptions[$i]['method'] = $method;
             $exceptions[$i]['domains'] = array();
             $domains = array_map('trim', preg_split('/[,\\n]/', $domains, null, PREG_SPLIT_NO_EMPTY));
             foreach ($domains as $domain) {
                 if (strpos($domain, 'xn--') !== false) {
                     $domain = Rhymix\Framework\URL::decodeIdna($domain);
                 }
                 $exceptions[$i]['domains'][] = $domain;
             }
         }
     }
     // Save the new configuration.
     $config->exceptions = $exceptions;
     $output = getController('module')->insertModuleConfig('advanced_mailer', $config);
     if ($output->toBool()) {
         $this->setMessage('success_registed');
     } else {
         return $output;
     }
     if (Context::get('success_return_url')) {
         $this->setRedirectUrl(Context::get('success_return_url'));
     } else {
         $this->setRedirectUrl(getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAdvanced_mailerAdminExceptions'));
     }
 }