Friday, September 25, 2009

Mysql services

* To start mysql server:

/etc/init.d/mysqld start

* To stop mysql server:

/etc/init.d/mysqld stop

* To restart mysql server

/etc/init.d/mysqld restart
or

/etc/init.d/mysql restart



To connect the database from other system /etc/mysql/my.cnf

comment this line #bind-address

and also execute the following queries in mysql database

>INSERT INTO `user`(`Host`,`User`,`Password`,`Select_priv`,`Insert_priv`,`Update_priv`,`Delete_priv`,`Create_priv`,`Drop_priv`,`Reload_priv`,`Shutdown_priv`,`Process_priv`,`File_priv`,`Grant_priv`,`References_priv`,`Index_priv`,`Alter_priv`,`Show_db_priv`,`Super_priv`,`Create_tmp_table_priv`,`Lock_tables_priv`,`Execute_priv`,`Repl_slave_priv`,`Repl_client_priv`,`Create_view_priv`,`Show_view_priv`,`Create_routine_priv`,`Alter_routine_priv`,`Create_user_priv`,`ssl_type`,`ssl_cipher`,`x509_issuer`,`x509_subject`,`max_questions`,`max_updates`,`max_connections`,`max_user_connections`) VALUES ( '%','root','*24','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','','','','','0','0','0','0');
> UPDATE `user` SET `Host`='%',`User`='root',`Password`='*2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19',`Select_priv`='Y',`Insert_priv`='Y',`Update_priv`='Y',`Delete_priv`='Y',`Create_priv`='Y',`Drop_priv`='Y',`Reload_priv`='Y',`Shutdown_priv`='Y',`Process_priv`='Y',`File_priv`='Y',`Grant_priv`='Y',`References_priv`='Y',`Index_priv`='Y',`Alter_priv`='Y',`Show_db_priv`='Y',`Super_priv`='Y',`Create_tmp_table_priv`='Y',`Lock_tables_priv`='Y',`Execute_priv`='Y',`Repl_slave_priv`='Y',`Repl_client_priv`='Y',`Create_view_priv`='Y',`Show_view_priv`='Y',`Create_routine_priv`='Y',`Alter_routine_priv`='Y',`Create_user_priv`='Y',`ssl_type`='',`ssl_cipher`='',`x509_issuer`='',`x509_subject`='',`max_questions`='0',`max_updates`='0',`max_connections`='0',`max_user_connections`='0' WHERE `Host`='%' AND `User`='root';

and now restart mysql using sudo /etc/init.d/mysql restart


Thursday, September 24, 2009

Count the number of checkbox checked and submit values

function check(){
count = 0;
str = '';
for(x=0; x3){
alert("You can choose a maximum of 3");
return false;
}
else {
alert("You chose " + count + ": " + str.substring(0,str.length-1));
document.form1.submit();
}


<form NAME="form1" id="form1" method="post" onsubmit="return check()">
<p>
<input type="checkbox" NAME="checkbox[]" value="red" />
Red<br />
<input type="checkbox" NAME="checkbox[]" value="green" />
Green<br />
<input type="checkbox" NAME="checkbox[]" value="blue" />
Blue<br />
<input type="checkbox" NAME="checkbox[]" value="black" />
Black<br />
<input type="checkbox" NAME="checkbox[]" value="white" />
White<br />
<input type="checkbox" NAME="checkbox[]" value="yellow" />
Yellow<br />
<input type="checkbox" NAME="checkbox[]" value="purple" />
Purple
p>
<p>
<input type="submit" NAME="Submit" value="Click Me" />
p>
form>

Wednesday, September 23, 2009

Set cron in Linux server

Set cron in Linux server:
=========================

1.sudo apt-get install cron

2. sudo apt-get install php5-cli

3.create testing.php file and give 777 permissions.
sudo chmod 777 /var/www/testing.php

4.sudo crontab -e
in that opened file type this following command

# m h dom mon dow command
* * * * * /var/www/testing.php

*- refers to every minute,every hour , every week.

1. ctrl+x to save ; press Y and give enter

Now your cron will work :)

Thursday, September 10, 2009

Connect FTP server and get the list of files

$conn = ftp_connect("hosting server Ip address") or die("Could not connect");
ftp_login($conn,"username","pwd");

$from_array = ftp_nlist($conn,"foldername");

ftp_close($conn);

Google Authetication Using Curl

First things first, in order to access the analytics data for the
intended profile you need to login using an API request. This basically
involves using your Google Account login e-mail and password. Using the
PHP class, this was a simple function called login() which took those parameters. Here is an adaption of the code used in this function from the class:

$ch = curl_init("https://www.google.com/accounts/ClientLogin");
curl_setopt($ch, CURLOPT_POST, true);

$data = array(
'accountType' => 'GOOGLE',
'Email' => $email,
'Passwd' => $password,
'service' => 'analytics',
'source' => ''
);

curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$output = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);

$auth = '';
if($info['http_code'] == 200) {
preg_match('/Auth=(.*)/', $output, $matches);
if(isset($matches[1])) {
$auth = $matches[1];
}
}

Once the login request is processed, we are given an authorization key
to use when requesting data ($auth), which gets set as an cURL option for
later requests, such as the requests for data, for session security purposes.

Hope this code helps.....

Friday, September 4, 2009

Change Project Configuration file in Symfony

Change path in Projetconfiguration file (for linux)

require_once '/usr/share/php/symfony/autoload/sfCoreAutoload.class.php';

//for windows
#require_once 'C:\wamp\bin\php\php5.2.6\PEAR\symfony/autoload/sfCoreAutoload.class.php';

Symfony 1.1 Installation commands for Ubuntu

Install pear

command for installing pear

apt-get install php-pear

pear upgrade PEAR
pear channel-discover pear.symfony-project.com

Install symfony 1.1.1

pear install symfony/symfony-1.1.1
pear install --alldeps http://phing.info/pear/phing-current.tgz

check this link for more details
http://trac.symfony-project.org/wiki/SymfonyUbuntu

how to share on Facebook

The URL format is as follows (giving the example of CNN.com, wrapping for ease of viewing):

http://www.facebook.com/sharer.php
?u=http%3A%2F%2Fwww.cnn.com%2F
&t=CNN%26s+website

The parameters are "u", which gives the URL of the page (encoded, of course), and "t", which gives the default title of the link (also encoded). So this particular example could be used to let somebody create a "Share" on Facebook, with the URL "http://www.cnn.com/" and the default title "CNN’s website".

If you try to follow that link, you’ll see that it actually suggests the title "CNN.com - Breaking News, U.S., World, Weather, Entertainment & Video News". This is because it was able to successfully retrieve the URL, and it used the title from that page. If Facebook is unable to reach the page, then it will use the "t" parameter instead. So you’ll probably want to provide a "t" just in case there is a network problem when Facebook tries to connect.

see the link for more details
http://www.facebook.com/share_partners.php

command to install ffmpeg in Ubuntu

sudo apt-get install php5-ffmpeg

Script to display a message while closing the browser

function closeBuilder()
{
window.close();
}


window.onbeforeunload = function (evt) {
var message = 'Are you sure you want to leave?';
if (typeof evt == 'undefined') {
evt = window.event;
}
if (evt) {
evt.returnValue = message;
}
return message;
}

symfony commands

command to create project

symfony init-project projectname

command to create application

Symfony init-app applicationname

command to create module

cd projectfoldername

symfony init-module aaplicationname modulename


command to create schema

symfony propel:build-schema

command to create model

symfony propel:build-model

command to create forms

symfony propel:build-forms

Server commands in ubuntu

command remove a file
rm -f -r {file-name}

To remove all files & subdirectories from a directory (MS-DOS deltree like command), enter:
$ rm -rf mydir

install VLC plugin
sudo apt-get install vlc vlc-plugin-esd mozilla-plugin-vlc

rename a foldername
mv soucefolder destinationfolder

To move files into server

database backup restore
mysql -u root dbname -p < /var/www/dbname.dump

database backup
mysqldump -u root dbname -p > dbname.dump
from remote server
mysqldump -P 3306 -h 127.0.0.1 -u dbusername -p dbname>db.sql

ssh username@hostname
pwd : password

to move files into server

scp -r /var/www/foldername username@hostname:/var/www/



install flash player10 in ubuntu
remove old flash player
sudo apt-get remove flashplugin-nonfree

download the.deb file from
http://www.adobe.com/shockwave/download/alternates/#fp

Open Firefox and type following at url box:
about:plugins

to install the dependencies
sudo apt-get install -f

install flash player 10

reference links
http://www.cyberciti.biz/tips/linux-install-flash-player-10.html
http://www.ubuntugeek.com/how-to-install-adobe-flash-player-10-in-ubuntu-804-hardy-heron.html
http://www.adobe.com/shockwave/download/alternates/#fp
sudo dpkg -i install_flash_player_10_linux.deb

Ubuntu plugin installation commands

install curl extension

sudo apt-get install php5-curl
sudo apt-get install curl libcurl3 libcurl3-dev php5-curl

install xslt extension

sudo apt-get install php5-xsl

command restart apache

sudo /etc/init.d/apache2 force-reload

path of the php.ini file
/etc/php5/apache2/php.ini

Increase you memory_limit in php.ini files to 32 MB
if your host now allowed you to change the php.ini files then
open your settings.php in sites/default folder

make ini_set("memory_limit","32M");

to see all the process
$ kill -9 pid
$ ps -A

installing GD library for ubuntu
Here are the steps to remedy it. This will install a GD pre-compiled working version. It is a complete bundled (forked) GD libraries:

1. Adding 2 lines to your file /etc/apt/sources.lst
deb http://packages.dotdeb.org stable all
deb-src http://packages.dotdeb.org stable all

2. If not already done removing your current GD package and its configurations.

sudo apt-get remove php5-gd
sudo apt-get --purge remove

3. Updating your current apt-get list

apt-get update

4. Installing working GD package.
apt-get install php5-gd

It will complain about non-authenticated sources, just ignore, it will also update some additional php libs.

When prompt select keep_current modified php.ini

5. Restarting Apache
/etc/init.d/apache2 restart

Ubuntu Linux: How to Install Flash Player for firefox

First, close running Firefox.

Open the terminal (shell prompt)
$ sudo apt-get install flashplugin-nonfree

To change the ip address in ubuntu

command to change the gateway

sudo gedit /etc/network/interfaces

command to change the DNS

sudo gedit /etc/resolv.conf

command to restart the server

sudo /etc/init.d/networking restart

Freeze a project in symfony

if you are using svn

remove all svn folder and /web/sf directory

remove the sf folder from the web

the command to freeze the project in ubuntu is

symfony project:freeze /usr/bin/symfony