Friday, July 13, 2012

how to remove unwanted toolbar in firefox

In firefox address bar

type:- about:config

search in filter and remove or modify value of unwanted toolbar in firefox

Monday, May 21, 2012

ssl on symfony

copy bellow file in symfony apps/lib forder

filename: sslFilter.class.php

<?php
/**
 * Description of sslFilter
 */
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()) {
      // 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;
          }
        }

      } 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();
  }
}
?>

in filter.yml file

rendering: ~
web_debug: ~
security:  ~

# generally, you will want to insert your own filters here
sslFilter:
  class:  sslFilter

cache:     ~
common:    ~
flash:     ~
execution: ~

app.yml file
# default values
all:
  ssl:
    insecure_host:    www.myhostname.com
    secure_host:      www.myhostname.com
    secure_actions:
      - { module: securemodule, action: secureaction }
      - { module: sslmodulename, action: sslactionname }

php odbc connection

php odbc in linux

yum install unixODBC

yum install php-odbc

in /etc/odbcinst.ini file

# Driver from the mysql-connector-odbc package
# Setup from the unixODBC package
[MySQL]
Description     = ODBC for MySQL
Driver          = /usr/lib/libmyodbc5.so
Setup           = /usr/lib/libodbcmyS.so
Driver64        = /usr/lib64/libmyodbc5.so
Setup64         = /usr/lib64/libodbcmyS.so
FileUsage       = 1

edit /etc/odbc.ini


mysqlmyodbc = MySQL

[mysqlmyodbc]
Driver      = /usr/lib/libmyodbc5.so
Server      = localhost
Port        = 3306
User        = username
Password    = password
Database    = databasename
Option      = 3
Socket      = /var/run/mysqld/mysqld.sock


save the /etc/odbc.ini file

service httpd restart
service mysqld restart

test php file

<?php

$conn = odbc_connect("DRIVER={MySQL};Server=localhost;Database=databasename", "username", "password");
/* $sql = "SELECT 1 as test";
 $rs = odbc_exec($conn,$sql);
 odbc_fetch_row($rs);
 echo "\nTest\n—--\n" . odbc_result($rs,"test") . "\n";
 */

$sql = "SELECT * from table_name";
$result = odbc_exec($conn,$sql);
if($result)
{
    while($row = (odbc_fetch_array($result)))
    {
        foreach ($row as $k=>$v)
        {
            echo $k."=>".$v;
            echo "<br/>";
        }
    }
}
?>

Monday, January 2, 2012

symfony sfDoctrineGuardPlugin module wise permission

if you want to moudle wise permission to user in symfony

its work in symfony 1.4 and sfDoctrineGuardPlugin 5.0

add permission (permssion name is credential name)

and group (group name is module name)

now create one filterfile (filterfile add in /apps/appname(frontend|backend)/lib) folder

<?php

class groupcheckFilter extends sfFilter
{
public function execute($filterChain)
{
// Filters don't have direct access to the request and user objects.
// You will need to use the context object to get them
$context = $this->getContext();
$request = $context->getRequest();
$user = $context->getUser();
//$user->getAllPermissionNames();
$user_group = $user->getGroupNames();
echo $module = $context->getModuleName();
//secure file in default folder so bellow if condition and redirect path
if (!in_array($module,$user_group) && $module != 'default')
{
return $context->getController()->redirect('/default/secure/');
}else {
// Execute next filter
$filterChain->execute();
}
}
}

?>

file save with groupcheckfilter.class.php

in app.yml file add bellow line after security: or # insert your own filters here

groupcheck:
class: groupcheckFilter

how to see xml preview in browser php

xml preview view in browser $xml = new DOMDocument('1.0', 'UTF-8');                 $xml->preserveWhiteSpace = false; ...