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

Tuesday, October 4, 2011

mssql server conncet to linux php

now install in linux machine(fedora/centos)

yum install freetds

and

yum install php-mssql (if not work then go menu system -> administartor add/remove software and search mssql and select php-mssql)

open
/etc/freetdsconf

and add the last

[conncetmssql]
host = 192.168.1.5
port = 1433
tds version = 4.2

> service httpd restart

example:

<?php
if (function_exists('mssql_connect')){
echo "Okay, function work";
} else {
echo "php-mssql not installed";
}

if(extension_loaded("mssql")) {
echo "MSSQL is Loaded<br>";
}
else {
echo "MSSQL not loaded<br>";
}

// Connecting, selecting database
$link = mssql_connect('conncetmssql', 'username', 'password') or die('Could not connect: ' . mssql_get_last_message());
echo 'Connected successfully';
mssql_select_db('yourdatabasename') or die('Could not select database');

echo "select db";
// Performing SQL query
$query = 'SELECT * FROM tablename';
$result = mssql_query($query) or die('Query failed: ' . mssql_error());

// Printing results in HTML
echo "<table>\n";
while ($line = mssql_fetch_array($result, MSSQL_ASSOC)) {
echo "\t<tr>\n";
foreach ($line as $col_value) {
echo "\t\t<td>$col_value</td>\n";
}
echo "\t</tr>\n";
}
echo "</table>\n";

// Free resultset
mssql_free_result($result);

// Closing connection
mssql_close($link);
?>

Configure a server alias to use TCP/IP sockets

Note To configure a server alias to use TCP/IP sockets, you must provide the server name and the TCP/IP port number.

1. Determine the TCP/IP port number of the instance of SQL Server.

SQL Server 2005
1. Open SQL Server Configuration Manager, and then expand SQL Server 2005 Network Configuration.
2. Click Protocols for InstanceName, and then double-click TCP/IP in the right panel.

Note InstanceName is a placeholder for the named instance of SQL Server 2005.
3. On the Protocol tab, notice the value of the Listen All item.
4. Click the IP Addresses tab:
* If the value of Listen All is yes, the TCP/IP port number for this instance of SQL Server 2005 is the value of the TCP Dynamic Ports item under IPAll.
* If the value of Listen All is no, the TCP/IP port number for this instance of SQL Server 2005 is the value of the TCP Dynamic Ports item for a specific IP address.
Note If the value of the TCP Dynamic Ports item is not set, you must set it yourself. For more information about how to configure a server to listen on a specific TCP port, visit the following Microsoft Developer Network (MSDN) Web site: http://msdn2.microsoft.com/en-us/library/ms177440.aspx (http://msdn2.microsoft.com/en-us/library/ms177440.aspx)
5. Click OK.

or more detail bellow two link

1. http://support.microsoft.com/kb/265808
2. http://msdn.microsoft.com/en-us/library/ms177440.aspx

Monday, August 8, 2011

Connection could not be established with host localhost

Connection could not be established with host localhost [permission denied]

in Linux

send mail in php

send mail from Swift_TransportException

check php.ini

SMTP localhost
smtp_port 25
sendmail_from no value
sendmail_path /usr/sbin/sendmail -t -i

sendmail service start and enabled

in firewall
Mail(SMTP) 25/tcp

SELinux
system default enforcing mode : Disabled

how to see xml preview in browser php

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