2009年8月28日 星期五

sfGuardPlugin Data-Dump & Data-Load UserPassword error solution

Please rewrite signin function from sfGuardPlugin/lib/model/plugin/PluginsfGuardUser.php as following:

(For Propel)
public function setPassword($password)
  {
    if (!$password && 0 == strlen($password))
    {
      return;
    }
/*
 * iba: if salt is set then probly the passwort is already encrpted
 * thus call setPassword without user_funx algorythm
 */
    /*--- Add Here ---*/
    $fromdump = false;
    if($this->isNew() && $this->getSalt()){
      $fromdump=true;
    }
    /*----------------*/

    if (!$salt = $this->getSalt())
    {
      $salt = md5(rand(100000, 999999).$this->getUsername());
      $this->setSalt($salt);
    }
    $algorithm = sfConfig::get('app_sf_guard_plugin_algorithm_callable', 'sha1');
    $algorithmAsStr = is_array($algorithm) ? $algorithm[0].'::'.$algorithm[1] : $algorithm;
    if (!is_callable($algorithm))
    {
      throw new sfException(sprintf('The algorithm callable "%s" is not callable.', $algorithmAsStr));
    }
    $this->setAlgorithm($algorithmAsStr);

/*
 * iba: if passwort is already encrypted dont encrypt it again.
 */
    /*--- Add Here ---*/
    if($fromdump){
      parent::setPassword($password);
    }
    /*----------------*/

    else{
      parent::setPassword(call_user_func_array($algorithm, array($salt.$password)));
    }   
    
  }

2009年8月5日 星期三

New way to loadHelper for symfony 1.2

In Action class file:

Before -
sfLoader::loadHelper("helper");

New way -
sfContext::getInstance()->getConfiguration()
->loadHelpers("helper");

2009年8月3日 星期一

Unix 系統切換開機進入文字或 X-windows 模式

Red Hat、 Fedora、Mandruke 或 Mandriv

/etc/inittab 中包括":initdefault"一行,更改"id:"和":initdefault:"之間的數字。
如果你想開機自動進入文字模式,轉為3。
如果你想開機自動進入圖像(X Window)模式,轉為5。
id:3:initdefault
所有Unix/Linux都有最少0-6七個run level,不同run level代表不同執行模式。 Red Hat等定了run level 3為文字模式,而run level 5為 X-Window圖像模式。 inittab中的initdefault控制了開始預設進入那個run level, 所以改變這個數值就可以切換開機自動進入那個模式。

Debian 或 Ubuntu

Debian或Ubuntu是利用SysVinit啟動X Display Manager,亦即是所謂的圖像模式登入畫面。
只要你安裝任何一個X-Display Manager(包括xdm、gdm、kdm和wdm),
系統開機時就會自動執行,進入圖像模式。如果你想開機自動進入文字模式,
你可以選擇移除所有X-Display Manager。
apt-get remove xdm gdm kdm wdm
或者關閉開機自動啟動任何一個 X Display Manager。