Thursday, April 26, 2007

HOW TO ENSURE THAT VIRUS DOES NOT SPREAD THRU YOUR ADDRESS BOOK

As you may know, when/if a worm virus gets into your computer it headsstraight for your email address book, and sends itself to everyone in there, thus infecting all your friends and associates.

This trick won't keep the virus from getting into your computer, butit will stop the virus from using your address book to spread further,and it will alert you to the fact that the worm has entered into your system.

Here's what you do:

First, open your address book and click on "New Contact," just as youwould do if you were adding a new friend to your list of emailaddresses.

In the window where you would type your friend's first name, type in "A".

For the screen name or email address, type AAAAAAA@A....

Save and Close the new entry.

Now, here's what you've done and why it works:

The "name" "A" will be placed at the top of your address book as entry#1.

This will be where the worm will start in an effort to send itself toall your friends. But, when it tries to send itself to AAAAAAA@A...,it will be undeliverable because of the phony email address youentered. If the first attempt fails (which it will because of the phony address), the worm goes no further and your friends will not beinfected.

Here's the second great advantage of this method:If an email cannot be delivered, you will be notified of this in yourInbox almost immediately as a Mailer Daemon. Hence, if you ever get anemai! l telling you that an email addressed to AAAAAAA@A... could not bedelivered, you know right away that you have the worm/virus in yoursystem. You can then take steps to get rid of it!

Saturday, April 21, 2007

PHP Integration to FCKeditor

PHP Integration to FCKeditor:

It is very easy to use FCKeditor in your PHP web pages. All the
integration files are available in the official distributed package.
Just follow these steps.

Step 1

Suppose that the editor is installed in the /FCKeditor/ path of your
web site. The first thing to do is to include the "PHP Integration
Module" file in the top of your page, just like this:

include("FCKeditor/fckeditor.php");
?>

Step 2

Now the FCKeditor is available and ready to use. So, just insert the
following code in your page to create an instance of the editor
(usually inside a FORM):

$oFCKeditor = new FCKeditor('FCKeditor1');
$oFCKeditor->BasePath = '/FCKeditor/';
$oFCKeditor->Value = 'Default text in editor';
$oFCKeditor->Create();
?>

"FCKeditor1" is the name used to post the editor data on forms.

Step 3

The editor is now ready to be used. Just open the page in your browser
to see it at work.

The complete sample

include("FCKeditor/fckeditor.php") ;
?>


$oFCKeditor = new FCKeditor('FCKeditor1') ;
$oFCKeditor->BasePath = '/FCKeditor/';
$oFCKeditor->Value = 'Default text in editor';
$oFCKeditor->Create() ;
?>






Handling the posted data

The editor instance just created will behave like a normal
field in a form. It will use the name you've used when creating it (in
the above sample, "FCKeditor1").

So, to retrieve its value you can do something like this:

$sValue = stripslashes( $_POST['FCKeditor1'] ) ;

Samples

You can find some samples on how to use the editor in the "_samples/
php" directory of the distributed package.

Other info

If you want to retrieve the resulting HTML instead of outputting it
directly to the browser (for example if you're using it in a template
engine such as Smarty), you can call the "CreateHtml" method instead:

$output = $oFCKeditor->CreateHtml() ;

*

To change the size of the editor in the page, insert the
following code before calling the Create() or CreateHtml() methods:

$oFCKeditor->Width = '100%' ;
$oFCKeditor->Height = '200' ;

and just change the values to your needs.

* To modify configuration settings in a separate file outside the
editor's directory, add them to the Config property of the editor
object:

$oFCKeditor->Config['CustomConfigurationsPath'] = '/myconfig.js' ;

*

To set the path for saving uploaded files uncomment the
following line in /FCKeditor/editor/filemanager/browser/default/
connectors/php/config.php.
*

(do the same in /FCKeditor/editor/filemanager/upload/php/
config.php, at least in version 2.3)

// $Config['UserFilesPath'] = '/UserFiles/' ;

*

Depending on your version, you may also need to set
$Config['Enabled'] to true in /FCKeditor/editor/filemanager/browser/
default/connectors/php/config.php.
*

(do the same in /FCKeditor/editor/filemanager/upload/php/
config.php, at least in version 2.3)

// SECURITY: You must explicitly enable this "connector". (Set it to
"true").
$Config['Enabled'] = true ;

Note: Set the permission of the upload directory properly. You should
also uncomment the settings of LinkBrowserURL and the ImageBrowserURL
in the /FCKeditor_2.0fc/fckconfig.js file for the browsing and
uploading function to work properly.

Also set _FileBrowserLanguage and _QuickUploadLanguage to php in the
fckconfig.js file.

var _FileBrowserLanguage = 'php' ;
var _QuickUploadLanguage = 'php' ;

See Built-in File Browser for more information.

Important Note for PHP with Safe Mode activated: You'll have to
create /UserFiles/File, /UserFiles/Flash, /UserFiles/Image and /
UserFiles/Media in order for the filebrowser to work. Of course,
you'll also have to set the correct permissions for these directories.
Furthermore, don't use the "Create new folder" button. The folder
would be created but couldn't be used (Safe Mode restriction).

PHP output buffering

The output buffering functions of php aren't well known (yet), but are
nevertheless extremely useful. These functions give you more control
over the output generated by your scripts than you would normally
have, and in some cases, this control is essential. Not only do you
have control over when, where, and why your output is displayed, but
you can also control how the output is handled. In this tutorial I
hope to cover the general idea behind output buffering, as well as a
few common uses.

Lets begin with a common problem, and an easy way to fix it. Some of
you may notice this common mistake, because a lot of the people new to
php have made it:

PHP Example: (!)

echo "You will now be directed to google.com...\n";
header("Location: http://sanjeev-naroliya.blogspot.com/");
?>

Those of you who know your way around php a bit will know that you
cannot use the header() function after there is any output. Output in
this script begins with "". The script above would result in an error
of "cannot add header information, headers already sent". Here is how
to use the output buffering functions to get around this problem:

PHP Example: (!)

//start output buffering
ob_start();
?>
echo "You will now be directed to google.com...\n";
header("Location: http://sanjeev-naroliya.blogspot.com/");
?>

//send the contents of the buffer to the browser
ob_end_flush();
?>


Please do not take this example literally as a way to get around the
error, it'd be much easier to just move the header() function to the
top, or use a meta refresh, but it's the principle that I would like
you to grasp. Lets break this down into small peices.
ob_start();
This function opens up a new buffer. All output of the script will be
put into this buffer, so that you may act upon it later. Think of this
like a giant string in which all of the output of your script will be
appended to. In the previous example, the output would be "You will
now be directed to google.com...".

at the end you see the ob_end_flush() function. This function is used
to 'flush' (send) data to the browser, and to close the buffer.

As you have noticed, you cannot do much with these two functions
alone. Now comes the fun part. The Output Buffering API in php comes
with some nice functions to give you a lot of control over the way you
handle your scripts, Read on if you want to check these out in
detail.

I think the best way to teach more about output buffering would be to
show you examples and explain them later. Many people will be able to
identify what the code is supposed to do before even reading the
explanations, output buffering is just that easy. Lets begin:

PHP Example: (!)

//start output buffering
ob_start();
//call the get_database_content function
get_database_content();
//call the page_end function
page_end();

function get_database_content() {
mysql_connect('some host','user','pass');
$query = mysql_query("SELECT * FROM users WHERE userid='12'");
while( $thingy = $mysql_fetch_array($query) ) {
echo $thingy;
}
}

function page_end() {
if(mysql_error() > 0) {
ob_end_clean();
echo "ERROR: ".mysql_error();
} else {
ob_end_flush();
}
}

?>


In this example a buffer is opened with ob_start, and then functions
are called to control the output. get_database_content will connect to
a database and echo some data, and then page_end will check to see if
all went well. If there was an error while using the database, the
buffer is cleared, and an error message is displayed. If all went
well, the buffer is sent to the browser with ob_end_flush().

PHP Example: (!)

ob_end_clean();


The ob_end_clean function empties (hence 'clean') and then closes the
buffer without sending the content to the browser.

Here is another example, introducing two new functions.

PHP Example: (!)

//start output buffering
ob_start();
//call the get_database_content function
get_database_content();
//call the page_end function
page_end();

function get_database_content() {
mysql_connect('some host','user','pass');
$query = mysql_query("SELECT * FROM users WHERE userid='12'");
while( $thingy = $mysql_fetch_array($query) ) {
echo $thingy;
}
}

function page_end() {
if(mysql_error > 0){
ob_clean();
echo "ERROR: ".mysql_error();
ob_flush();
} else {
ob_flush();
}
}
ob_end_clean();
?>


This example is basically same as the last, except it uses ob_flush
and ob_clean. ob_flush will send the contents of the buffer to the
browser and empty the buffer, but will not close the buffer. ob_clean
will empty the contents of the buffer without sending the output to
the browser. It also does not close the buffer. At the end the buffer
is closed with ob_end_clean.

Another function which you will use often while using output buffering
is ob_get_contents. Let's take a look at some example code:

PHP Example: (!)

//start output buffering
ob_start();
echo "wwooooo";
echo "hoo!";
ob_flush();
//call the get_database_contents function
get_database_contents();
//call the page_end function
page_end();

function get_database_content() {
mysql_connect('some host','user','pass');
$query = mysql_query("SELECT * FROM users WHERE userid='12'");
while( $thingy = $mysql_fetch_array($query) ) {
echo $thingy;
}
}

function page_end(){
$stuff = ob_get_contents();
$file = fopen("data.txt","w");
fwrite($file, $stuff);
fclose($file);
}
ob_end_clean();
?>


As you can see, ob_get_contents returns the content of the buffer. If
there is no buffer open, ob_get_contents will return false. There are
a few more functions that I won't go into detail over, which I will
list below, with a brief explanation.

flush
This function will try to put all output in the buffer to the browser.
ob_implicit_flush
This function turns explicit flushing on or off, if no flag is given
as a parameter it will default as on. With ob_implicit_flush the
buffer will be flushed after each call to output, and explicitly
calling flush() is no longer needed.
ob_get_length
This will return the length of the output buffer, or false if there is
no active buffer.
ob_get_level
This function returns the nesting level of the output buffering
mechanism. meaning, it will return the level of nested output
buffering, if you have more than one open buffer.
ob_get_status
This function returns an array of either the status of currenly open
buffers or FALSE.
NOTE: this function is EXPERIMENTAL. The name and functionality can be
changed in future versions of php, or it could be dropped altogether.

There is really only one more area of interest I would like to hit on
output buffering, and that is ob_gzhandler. You can read about it on
the next page. Ob_gzhandler is (in my opinion) the best part of output
buffering. Read on.

Ob_gzhandler can be used to automatically compress data before it is
sent to the browser, decreasing loading time, on browsers which
support it (the function will determine which type of compression your
browser can handle: gzip, deflate, or none at all). This is an
extremely useful function for any website which uses large amounts of
dynamic data. A quick example:

PHP Example: (!)

//start output buffering with the ob_gzhandler callback
ob_start("ob_gzhandler");
echo "this data is compressed.";
ob_end_flush();
?>


A small warning: although your server will have less bandwidth being
used, the CPU load will be drastically increased।

Saturday, April 07, 2007

google strange search results

i just want to share this search term, click here n here to see the worlds most famous websites in single search term.

i know this for a long time and thinking to share it but always forget to do so. now its here...