Thursday, June 20, 2013

User Agent Based Browser List


Here is a website which maps browser name with user Agent Name.This will be helpful for finding browser name from Apache(Web Server) access logs.

http://www.useragentstring.com/pages/Browserlist/



Monday, June 17, 2013

A server with all TCP ports open


Server portquiz.positon.org server listens on all TCP ports, allowing you to test any outbound TCP port.

For checking Outbound TCP connection from your server to port 3306

use : > telnet  portquiz.positon.org 3306

Tuesday, June 11, 2013

Rsync Command with Different SSH port


 Rsync Command with Different SSH port

/usr/bin/rsync -avz --rsh='ssh -pPORTNUMBER' username@hostname:remotepath localpath

eg:
/usr/bin/rsync -avz --rsh='ssh -p52222 ' xyz@xyz.com:/home/xyz/public_html/project /home/admin/project/

Saturday, June 8, 2013

Mysql Database management In Single PHP File

Adminer is one of the best tool for Managing Mysql database.For connecting to a database just copy latest adminer php file to your PHP Web server document web-root


Enabling Case sensitive support for mysql in Wamp

For enabling case sensitive support for mysql in Wamp update mysql.ini(WAMP–>MYSQL–>mysql.ini) in wamp with lower_case_table_names=2
Reference:

SoftException in Application.cpp:629: Directory is writeable by group

“SoftException in Application.cpp:629: Directory  is writeable by group”. generally happens in CGI server with suPHP and Fastcgi Servers.
Fix:
By Changing executable files/folders permission from 777 to 755 will fix such issues.
Reason:
  1. Both suPHP and Fastcgi Servers has the security and ownership benefits.
  2. PHP files are executed as cpanel Users.
  3. Files and folders with 777 permission excluded from execution
Here’s an easy forward-compatible way to use JSON (json_encode() and json_decode()) in versions of PHP earlier than 5.2.
And then add the following to your custom functions:
JSON DECODE

if (!function_exists('json_decode'))
  {
     
       function json_decode($content, $assoc=false)
                   {
                       require_once 'classes/JSON.php';
                       if ($assoc)
                         {
                            $json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
                         }
                     else
                        {
                           $json = new Services_JSON;
                        }
                     return $json->decode($content);
                 }
}

JSON ENCODE

if (!function_exists('json_encode'))
{
    function json_encode($content)
       {
         require_once 'classes/JSON.php';
        $json = new Services_JSON;
        return $json->encode($content);
       }
}
That’s it! Your code will continue to work, even when you eventually upgrade to PHP 5.2

Code for checking outgoing port enabled or not through php



$fp = fsockopen("SomeLiveSite", 80, $errornumber, $errorstring, 30);
if (!$fp) {
    echo "$errorstring($errornumber)
\n";
} else {
    echo "Sucess";
    fclose($fp);
}

Using Rsync and SSH Keys


Using Rsync with SSH keys
rsync -avz -e “ssh -i /home/thisuser/cron/thishost-rsync-key” remoteuser@remotehost:/remote/dir /this/dir/