安全问题修复

如果你在之前项目的action中使用了->sendMail()方法,必须要升级一个补丁http://trac.symfony-project.com/trac/changeset/4380?format=diff&new=4380

PHPMailer  如果调用了sendmail,那么有一个远程攻击漏洞,更多信息请查看http://larholm.com/2007/06/11/phpmailer-0day-remote-execution/

修复了以下bug

  • r4387: fixed input_date_range_tag – Illegal attributes in input tags (#1883)
  • r4385: fixed issue relating to lock files (#1874)
  • r4380: fixed vulnerability in phpmailer with sender (#1871)
  • r4323: fixed DOMDocument E_STRICT warning and trans-unit max id in XLIFF support
  • r4320: fixed sfToolkit::isUTF8() broken for strings larger than some number
  • r4305: added i18n schema for MySQL and SQLite in API documentation

验证数据库的某个字段是否已经存在了相同的数据

首先,在lib目录建立一个 sfCustomUniqueValidator.php

  1. < ?php
  2.   /**
  3. * sfCustomUniqueValidator checks if a record exist in the database with all the mentionned fields.
  4. *
  5. * ex: Check if a companie with company_name exist in country_id
  6. *   class:            sfCustomUniqueValidator
  7. *   param:
  8. *     class:          Companies    //the class on which the search is performed
  9. *     nb_fields:      2            //the number of fields on which the comparison is done
  10. *     field_1:        company_name //First field of the comparison
  11. *     field_2:        country_id   //Other country for the comparison
  12. *
  13. * @package    lib
  14. * @author     Joachim Martin
  15. * @date       15/06/2007
  16. */
  17.  
  18. class sfCustomUniqueValidator extends sfValidator {
  19.  
  20.    /**
  21.    * Executes this validator.
  22.    *
  23.    * @param mixed A file or parameter value/array
  24.    * @param error An error message reference
  25.    *
  26.    * @return bool true, if this validator executes successfully, otherwise false
  27.    */
  28.  
  29.     public function execute(&$value, &$error) {
  30.  
  31.         $className  = $this->getParameter('class').'Peer';
  32.  
  33.         //Get fields number
  34.         $nb_fields = $this->getParameter('nb_fields');
  35.  
  36.         //Define new criteria      
  37.         $c = new Criteria();
  38.  
  39.         //Loop on the fields
  40.         for($i = 1; $i < = $nb_fields ; $i++) {
  41.             //Retrieve field_$i
  42.             $check_param = $this->getParameterHolder()->get("field_$i");
  43.             $check_value = $this->getContext()->getRequest()->getParameter($check_param);
  44.  
  45.             //If check value defined       
  46.             if ($check_value != '') {  
  47.                 //Adding field to the criteria
  48.                 $columnName = call_user_func(array($className, 'translateFieldName'), $check_param, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_COLNAME);
  49.                 $c->add($columnName, $check_value);
  50.             }
  51.         }
  52.  
  53.         $object = call_user_func(array($className, 'doSelectOne'), $c);
  54.  
  55.         if ($object)
  56.         {
  57.           $tableMap = call_user_func(array($className, 'getTableMap'));
  58.           foreach ($tableMap->getColumns() as $column)
  59.           {
  60.             if (!$column->isPrimaryKey())
  61.             {
  62.               continue;
  63.             }
  64.  
  65.             $method = 'get'.$column->getPhpName();
  66.             $primaryKey = call_user_func(array($className, 'translateFieldName'), $column->getPhpName(), BasePeer::TYPE_PHPNAME, BasePeer::TYPE_FIELDNAME);
  67.             if ($object->$method() != $this->getContext()->getRequest()->getParameter($primaryKey))
  68.             {
  69.               $error = $this->getParameter('custom_unique_error');
  70.  
  71.               return false;
  72.             }
  73.           }
  74.         }
  75.  
  76.         return true;
  77.     } 
  78.  
  79.     public function initialize ($context, $parameters = null) {
  80.         // initialize parent
  81.         parent::initialize($context);
  82.  
  83.         //Set default parameters value
  84.         $this->setParameter('custom_unique_error','The value is not unique');
  85.  
  86.         $this->getParameterHolder()->add($parameters);
  87.  
  88.         // check parameters
  89.         if (!$this->getParameter('class'))
  90.         {
  91.           throw new sfValidatorException('The "class" parameter is mandatory for the sfCustomUniqueValidator validator.');
  92.         }
  93.  
  94.         if (!$this->getParameter('nb_fields'))
  95.         {
  96.           throw new sfValidatorException('The "nb_fields" parameter is mandatory for the sfCustomUniqueValidator validator.');
  97.         }
  98.  
  99.         return true;
  100.     }
  101. }

调用方法: Continue reading »

没有增加新功能,只是修复了一些bug

  • r4286: fixed sfBrowser keeps previous Dom is response is not XHTML (#1853)
  • r4282: fixed sfValidatorManager refuses zero values as null values (#1649)
  • r4277: fixed generator themes in the project data directory do not override data in plugin directory (#1813)
  • r4266: fixed $request->hasError() should return true on errors with empty message (#1864)
  • r4264: fixed usage of components in admin generator generator.yml (#1809)
  • r4262: added some unit tests for symfony escaping mecanism
  • r4250: fixed include_blank being forced to ‘true’ in admin generator (#1739)
  • r4242: fixed a typo in MySQL i18n message source
  • r4240: added an exception when a YAML file contains tabs instead of spaces when tabs are mixed with spaces
  • r4238: replaced all occurences of deprecated function
  • mysql_escape_string() by mysql_real_escape_string() (#1860)

  • r4236: fixed bug for adjacent CSS selector
  • r4228: fixed a bug in URL generation for route names having a star in the middle
  • r4205: fixed _edit_form.php in Admin Generator should have have an action of save, not edit (#1812)
  • r4203: fixed sf_check_lock and sf_check_symfony has no effect (#1675)
  • r4199, r4201: fixed input_date_tag with same name but different ids (#1568)
  • r4195: fixed link_to_if() inserts parameter in html (#1700)
  • updated lime to 1.0.4 (fixes php 5.2.2 support)

As for every 1.0.X release, after upgrading to 1.0.4, don’t forget to clear the cache of your projects.

郁闷,晚上出去玩儿,回来发现电动车上的电池被偷跑了,现在啥都有人偷呀,又破财了。

&lsquo; ‘ left single quote
&rsquo; ’ right single quote
&sbquo; , single low-9 quote
&ldquo; “ left double quote
&rdquo; ” right double quote
&bdquo; ” double low-9 quote
&dagger; + dagger
&Dagger; ++ double dagger
&permil; 0/00 per mill sign
&lsaquo; < single left-pointing angle quote
&rsaquo; > single right-pointing angle quote
&spades; ? black spade suit
&clubs; ? black club suit
&hearts; ? black heart suit
&diams; ? black diamond suit
&oline;  ̄ overline, = spacing overscore
&larr; ← leftward arrow
&uarr; ↑ upward arrow
&rarr; → rightward arrow
&darr; ↓ downward arrow
&trade; ^(TM) trademark sign
Continue reading »

这款心仪已久的键盘,终于在罗技键盘不好用的情况下,提了回来,希望能够通过这款新的键盘给自己的工作效率带来进一步的提高。

© 2011 刘敏的Blog Suffusion theme by Sayontan Sinha