symfonyとORM
Doctrineを使用して、フォームのe-mail'aをチェックする必要がありましたが、通常のsfValidatorEmailでは十分ではありません。 DoctrineデータモデルでEメールフィールドが「email:true」バリデーターで宣言されている場合、Doctrine自身がMXドメインレコードの存在をチェックし、存在しない場合は実行をスローします。 同意します、これは美しくありません(:ユーザーが登録データとテンプレートに一致する偽の電子メールアドレスを入力し、応答で「500 Inernal Server Error」を受け取ります。
偽のアドレスを正しく処理するために、ドメインのMXレコードの検証を追加することで標準のsfValidatorEmailバリデータを継承するsfValidatorEmailMxバリデータを作成しました。エントリがない場合、エラー「mx_error」と%domain%フィールドにドメイン名が生成されます。
バリデーターコード(lib / validator / sfValidatorEmailMx.class.php):
<?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .
<?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .
<?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .
<?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .
<?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .
<?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .
<?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .
<?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .
<?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .
<?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .
<?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .
<?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .
<?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .
<?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .
<?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .
<?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .
<?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .
<?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .
<?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .
<?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .
<?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .
<?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .
<?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .
<?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .
<?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .
<?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .
<?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .
<?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .
<?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .
<?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .
<?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .
<?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .
<?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .
<?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .
<?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .
<?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .
<?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .
<?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .
<?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .
<?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .
<?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .
<?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .
<?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .
<?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .
<?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .
使用法:
- <?php
- // ...
- $ this-> validatorSchema [ 'mail' ] = new sfValidatorEmailMx(array()、array(
- 「無効」 => 「電子メールが間違って入力されました。」 、
- 'max_length' => '電子メールの最大長%max_length%文字。 、
- 'mx_error' => 'server%domain%にメールが存在しない可能性があります。 、
- ));
*このソースコードは、 ソースコードハイライターで強調表示されました。
誰かが便利になるとうれしいです: