Archive for March, 2010

>Beginning SSH on Ubuntu

Posted: March 31, 2010 in Linux

>Installing OpenSSH

The Ubuntu (and MacOS X) flavor of SSH is called OpenSSH, a free, open-source implementation of the ssh protocol. It consists of two basic components, an openssh-client and an openssh-server. SSH clients communicate with SSH servers over encrypted network connections.

The openssh-client software should already be installed by default on Ubuntu. If you want to be able to accept SSH connections as well as request them, you’ll need the server software as well. The easiest way to ensure you have both is simply to run:

sudo apt-get install openssh-client openssh-server

Using SSH to Log into a Remote Computer

Once OpenSSH is installed, you can login to a remote SSH server by using the ssh command:

ssh remoteuser@remotebox

where remoteuser is the username of the remote account you’re trying to access, and remotebox is the remote server’s hostname or IP address.

For example, if you know that your Kubuntu desktop box (now running openssh-server) has a user account named joebanks and that the IP address of that computer on your private LAN is, you could login remotely to that account from your Linux/Mac laptop by typing:

ssh joebanks@

If you’re unsure of a computer’s local IP address, try running ifconfig on that machine. This will display the status of the active network interfaces, and the local IP address of that device will be listed after inet addr. It will most likely be in the form of 192.168.0.xx.

Or, if you’ve got a web hosting account that allows shell access (e.g., DreamHost) with a domain name like, your syntax might look like:


Now, the first time an SSH client encounters a new remote server, it will report that it’s never seen the machine before, by printing the following message:

The authenticity of host ‘remotebox (’ can’t be established.
RSA key fingerprint is 53:b4:ad:c8:51:17:99:4b:c9:08:ac:c1:b6:05:71:9b.
Are you sure you want to continue connecting (yes/no)?

This is just an extra security measure to ensure that you’re actually connecting to the machine you think you are. If you type yes (the most common response), you’ll see the following:

Warning: Permanently added ‘remotebox’ (RSA) to the list of known hosts.

Subsequent login attempts to this machine will omit the warning message. You’ll then be asked for the remoteuser’s password:

remoteuser@remotebox’s password:

And after correctly entering it, like magic, you’ll be logged into the remote machine, and instead of your local machine’s command prompt, you’ll see the following:


And, voila! You can execute commands on the remote machine just as you would on your local box. To close the connection to the remote server, type exit, or use Ctrl-D.

Copying Files

To transfer files and directories from your local machine to the remote server and vice-versa, you’ll use SSH’s “secure copy” command, or scp. To copy a single file from your local machine to the server, use the following syntax:

scp file.txt remoteuser@remotebox:/directory

where file.txt is the name of a file in the current directory of your local machine, remoteuser@remotebox is the username and hostname or IP address of the server (just like in the above ssh examples, and /directory is the directory path on the server where you want your file copied.

For example, if you want to copy the local file.txt to the /home/joebanks/docs directory on the server you logged into above, you’ll run the following command from a local terminal session:

scp file.txt joebanks@

You can be as verbose as you want with the local and remote filenames and directories, even changing the filename in the process, like so:

scp ~/docs/oldfile.txt joebanks@

To copy a file from the server to your local machine, use the following syntax:

scp remoteuser@remotebox:file.txt /local/directory

where remoteuser@remotebox is the username and hostname or IP address of the server, file.txt is a file in the /home/remoteuser directory, and /local/directory is the local directory path into which the file will be copied.

Again, you can be as verbose as necessary, for example:

scp joebanks@ /home/joe/downloads

Copying Directories

To copy an entire directory (and all of its contents) from the local machine to the remote server, use the recursive -r switch, like so:

scp -r /local/directory remoteuser@remotebox:/remote/directory

where /local/directory is the path to the local directory you want copied, and /remote/directory is the remote directory into which you want the directory to be copied.

To copy an entire directory (and all of its contents) from the remote server to the local machine, use the following:

scp -r remoteuser@remotebox:/remote/directory /local/directory

where /remote/directory is the path to the remote directory you want copied, and /local/directory is the local directory into which you want the directory to be copied.


>PHPMyAdmin Installation on Fedora

Posted: March 30, 2010 in Linux

>Step One
To install PHPMyAdmin using yum, simply issue
# yum -y install phpMyAdmin.noarch
Step Two
PHPMyAdmin Security Access
By default installation, phpmyadmin administration page can only be accessed from localhost via web browser for added security. If you wish to access phpmyadmin page from multiple hosts, modify phpmyadmin conf page as shown below
# vi /etc/httpd/conf.d/phpMyAdmin.conf
and edit the necessary settings. For example, if you require phpmyadmin web page to be accessible from a computer host with an IP address of, edit phpMyAdmin.conf to reflect the below similar lines
#order deny,allow
#deny from all
Allow from All
allow from
allow from

and next add the Allow from All Line

   Order Deny,Allow
   Allow from All
< /Directory>
Save, exit and reload apache web server.
# service httpd restart

>Enable mode_rewrite module in xampp

Posted: March 25, 2010 in Apache

>If you running XAMPP on Windows and unable to figure out how to enable mod_rewrite in apache then here is the solution and it is very simple

Search for httpd.conf file in xampp folder it should be located at xampp/apache/conf and open file in any editor and search for below line:

#LoadModule rewrite_module modules/

and just remove the “#” symbol then it will be like

LoadModule rewrite_module modules/

Next, search for “AllowOverride None” and change it to “AllowOverride All”. It is correct once and wrong twice in the file.

Once you have made these changes, save httpd.conf file and restart Apache for mod_rewrite to take effect.

>Iframe Popup’s

Posted: March 23, 2010 in Iframe Popup


<span style=”color: #330099; font-weight: bold;”>This is the Ifram panel which has to be written in Aspx page or Masterpage</span>

<asp:panel borderstyle=”None” id=”pnlPopup” runat=”server” style=”display: none;”>

<ajaxtoolkit:modalpopupextender backgroundcssclass=”modalpopupclass” id=”mpePopup” popupcontrolid=”pnlPopup” runat=”server” targetcontrolid=”hdnMPE”>
<asp:button id=”hdnMPE” runat=”server” style=”display: none;”>

<span style=”color: #330099; font-weight: bold;”>===  Script for opening popup  ====</span>

<script language=”javascript” type=”text/javascript”>
function funPopup(id) {

var frm = document.getElementById(‘ctl00_ContentPlaceHolder1_ifrmPopup’);
frm.src = “../ModalPopups/Delete.aspx”; <span style=”color: rgb(51, 0, 153);”> (Your page URL which has to be opened)</span> = “220px”; = “750px”;
var obj1 = $find(‘ctl00_ContentPlaceHolder1_mpePopup’);
if (obj1 != null) {;
return false;

================  Popup css ==================


================ Add in webConfig  ============

<add assembly=”AjaxControlToolkit” namespace=”AjaxControlToolkit” tagprefix=”ajaxToolkit”>

================ Method to call for image ===========

<asp:imagebutton id=”img” imagealign=”Middle” imageurl=”~/Images/Image.gif” runat=”server”>

===============  .cs (Page Load)  ===========

imgDelete.Attributes.Add(“onclick”, “javascript:return funPopup()”);

<span style=”color: #330099; font-weight: bold;”>=====For closing popup (this has to be written in popup.aspx page)====== </span>

<script language=”javascript” type=”text/javascript”>
function funPopupClose() {
window.parent.document.getElementById(‘ctl00_ContentPlaceHolder1_ifrmPopup’).src = “”;
var objF = window.parent.$find(‘ctl00_ContentPlaceHolder1_mpePopup’);
return false;

>Here you can find the Gadgets from Goolgle which you can integrate in website very easily.

>Create Multisite in Drupal

Posted: March 22, 2010 in Drupal

>To create multisite in drupal we need to change hosts configuration file as follows:
Windows/System32/drivers/etc/hosts (for windows)
And add new line like loclahost subdomain

after that just craete a folder called subdomian in drupal6/sites, then copy the settings.php file in newly created folder.Once done all the above steps Just type the URL like http;//subdomain/drupal6 in your browser then it will install new site.

If you want to create a url like just http://subdomain then you need create the Virtualhost in httpd.conf file like,

< VirtualHost *:80 >
DocumentRoot C:/xampp/htdocs/drupal6
ServerName subdomain

< /VirtualHost >

> Backing up your database is something you should do often. Like most things, there are a lot of ways to do this, but using the command-line is one of the best. Why? Because it helps you get around potential problems like execution timeouts for tools like phpMyAdmin, and potential network dropouts from using a local administration tool like MySQL Workbench.

mysqldump -h localhost -u username -p database_name > backup_db.sql

take a backup in compress mode:

mysqldump -u username -h localhost -p database_name | gzip -9 > backup_db.sql.gz


mysqldump -u username -p database_name | gzip -c backup.sql.gz 

Now, to explain what’s going on here! The “mysqldump” program is a tool for creating database backups. The parameters being used are:

  • “-u” switch means you’re going to specify a username to connect with, which must follow, like “-u mysqluser” above
  • “-p” switch means you’re either going to immediately specify the password to use (with no space), or it’ll prompt you for one
  • The final parameter used in the example above is the name of the database to backup (of course!)

If you ran the command above, you would’ve seen the contents of your database go whizzing by on the screen. That’s good, because we know that part works (actually connecting to the database), but it’s also bad, because… where did it go? Answer: nowhere! It scrolled past, and that was it. Now we need to capture it and put it in a file.
To place the contents of the output into a file, for back-up purposes, we need to use what’s called a redirection.


>Convert Array to XML format

Posted: March 22, 2010 in PHP

>function print_r_xml($arr,$wrapper=”data”,$cycle = 1)
    //useful vars
    $new_line = “\n”;

    //start building content
    if($cycle == 1) { $output = ‘<\?xml version=”1.0″ encoding=”UTF-8″ ?>’.$new_line; } 
    $output.= tabify($cycle – 1).”<“.$wrapper.”>”.$new_line;
    foreach($arr as $key => $val)
            $output.= tabify($cycle).'<‘.htmlspecialchars($key).’>’.$val.'</’.htmlspecialchars($key).’>’.$new_line;
            $output.= print_r_xml($val,$key,$cycle + 1).$new_line;
    $output.= tabify($cycle – 1).'</’.$wrapper.’>’;

    //return the value
    return $output;

/* tabify */
function tabify($num_tabs)
    for($x = 1; $x <= $num_tabs; $x++) { $return.= “\t”; }
    return $return;

/* test */
$_POST = array(
                ‘title’=>’Web Developer’,
echo print_r_xml($_POST);

>Make one php file and give it to name whatever you want like details_cp.php, this file is just for details of your cPanel and FTP and other things. So the content of details_cp.php would be given below

$cpuser = “cpanel username”; //cPanel Username
$cppass = “cpanel Password”; //cPanel Username
$domain = “”; // Domain name you want to take backup
$skin = “x2″; // no need to change

$ftpuser = “FTP username”; // FTP username
$ftppass = “FTP password”; // FTP username
$ftphost = “FTP host”; // FTP Host
$ftpmode = “passiveftp”;
$ftpdir = “/subdir”;

$notifyemail = “”; // Email which will use in case of any error.

$delbackup = 1;

$secure = 0; // If you are using secure ssl connection

$debug = 0;

After that you have to create second file, which is then main backup script,

if ($secure) {
$url = “ssl://”.$domain;
$port = 2083;
} else {
$url = $domain;
$port = 2082;

if ($delbackup) {
$conn_id = ftp_connect($ftphost);
if ($conn_id) {
$ok = ftp_login($conn_id, $ftpuser, $ftppass);
if ($ok) {
if (!empty($ftpdir)) {
$ok = ftp_chdir($conn_id,$ftpdir);
if ($ok) {
$dirlist = ftp_nlist($conn_id, “backup*”);
if (!empty($dirlist[0])) @ftp_delete($conn_id,$dirlist[0]);

$socket = fsockopen($url,$port);
if (!$socket) { echo “Cannot connect to $url\n”; exit; }
$authstr = $cpuser.”:”.$cppass;
$pass = base64_encode($authstr);
$request_data = “dest=”.urlencode($ftpmode).”&email=”.urlencode($notifyemail);
$request_data .= “&server=”.urlencode($ftphost).”&user=”.urlencode($ftpuser);
$request_data .= “&pass=”.urlencode($ftppass);
if (!empty($ftpdir)) $request_data .= “&rdir=”.urlencode($ftpdir);
$request_data .= “&submit=”.urlencode(‘Generate Backup’);

fputs($socket,”POST /frontend/”.$skin.”/backup/dofullbackup.html HTTP/1.1\r\n”);
fputs($socket,”Host: $domain\r\n”);
fputs($socket,”Authorization: Basic $pass\r\n”);
fputs($socket,”Content-type: application/x-www-form-urlencoded\r\n”);
fputs($socket,”Content-length: “.strlen($request_data).”\r\n\r\n”.$request_data);

while (!feof($socket)) {
$response = fgets($socket,4096);
if ($debug) echo $response;

Then upload these to files and just run backup_cp.php it will create the .zip file in our root directory

>Jquery: Ajax Function

Posted: March 16, 2010 in Jquery, JS

type: “POST”,
url: “some.php”,
data: “name=John&location=Boston”,
success: function(msg){
alert( “Data Saved: ” + msg );

for more detailed Information: