database connection in symfony 1.2

Propel

Propel has been upgraded to version 1.3, which replaces support for Creole with PDO.

Due to the removal of Creole, the following classes are removed:

class name equivalent
sfCreoleDatabase sfPropelDatabase
sfDebugConnection DebugPDO
sfMessageSource_Creole sfMessageSource_PDO
sfCreoleSessionStorage sfPDOSessionStorage

The propel:build-db task has been removed as this functionality is not yet provided by Propel 1.3.

The first step to upgrading is changing from Creole to PDO syntax in the database configuration from the project databases.yml file.

Locate the following:

all:
  propel:
    class:      sfPropelDatabase
    param:
      dsn:      mysql://username:password@localhost/example

Replace with the following:

dev:
  propel:
    param:
      classname: DebugPDO

test:
  propel:
    param:
      classname:  DebugPDO

all:
  propel:
    class: sfPropelDatabase
    param:
      dsn:        mysql:dbname=example;host=localhost
      username:   username
      password:   password
      encoding:   utf8
      persistent: true
      pooling:    true
      classname:  PropelPDO

Next, you must also upgrade the propel.ini with the PDO format DSN and updated configuration options.

Locate the following:

propel.database            = mysql
propel.database.createUrl  = mysql://username:password@localhost/
propel.database.url        = mysql://username:password@localhost/example

Replace with the following:

propel.database            = mysql
propel.database.driver     = mysql
propel.database.url        = mysql:dbname=example;host=localhost
propel.database.user       = username
propel.database.password   = password
propel.database.encoding   = utf8

Secure SSL(https) Redirect Filter for Symfony

please follow the steps given below to put up specific page to https or secure url:

1) First add the following settings to your app.yml file:

all:
  ssl:
    insecure_host:    www.avidindiainc.com/blog
    secure_host:      www.avidindiainc.com    
    secure_actions:
      - { module: shop, action: register }
      - { module: shop, action: checkout }
      - { module: register, action: updateCardDetails }

2) Next we add our filter code to lib/sslFilter.class.php (apps/[application name]/lib):

/**
 * Filter for redirecting to SSL for the pages that need it
 *
 * @author Sachin Makwana <sachin@avidindiainc.com>
 * @version 2
 */
class sslFilter extends sfFilter
{
  /**
   * Execute filter
   *
   * @param FilterChain $filterChain The symfony filter chain
   */
  public function execute ($filterChain)
  {
    // Only execute this filter once
    if ($this->isFirstCall() && SF_ENVIRONMENT != 'dev') {
      // Array of modules/actions that require move to SSL
      $ssl_actions = sfConfig::get('app_ssl_secure_actions');

      if (empty($_SERVER['HTTPS']) && count($_POST) < 1) {

        // We're not using SSL and not POSTing data - check if we should be using SSL
        foreach ($ssl_actions as $action) {
          if ($this->getContext()->getModuleName() == $action['module'] && $this->getContext()->getActionName() == $action['action']) {
            $new_url = sprintf('https://%s%s', sfConfig::get('app_ssl_secure_host'), $_SERVER['REQUEST_URI']);
            header('Location: ' . $new_url);
            exit;
          }
        }

        // Using secure host when not required - not good
        if ($_SERVER['HTTP_HOST'] == sfConfig::get('app_ssl_secure_host')) {
          $new_url = sprintf('http://%s%s', sfConfig::get('app_ssl_insecure_host'), $_SERVER['REQUEST_URI']);
          header('Location: ' . $new_url);
          exit;
        }
      } elseif (!empty($_SERVER['HTTPS']) && count($_POST) < 1) {

        // We're using SSL and not posting data
        $dont_redirect = false;
        foreach ($ssl_actions as $action) {
          if ($this->getContext()->getModuleName() == $action['module'] && $this->getContext()->getActionName() == $action['action']) {
            $dont_redirect = true;
          }
        }
        if ($dont_redirect == false) {
          // Redirect
          $new_url = sprintf('http://%s%s', sfConfig::get('app_ssl_insecure_host'), $_SERVER['REQUEST_URI']);
          header('Location: ' . $new_url);
          exit;
        }
      }
    }
    // Next filter
    $filterChain->execute();
  }
}

3) Finally, enable your sslFilter in the application’s config/filters.yml configuration file:

sslFilter:
  class:  sslFilter