How does the server open PHP's Fsockopen function? Use the Send Mailbox class

Source: Internet
Author: User
Tags install openssl phpinfo

How does the server open PHP's Fsockopen function? If you want to use some mail classes, then many of the requirements support PHP's Fsockopen function. However, the server is not enabled by default. Here are the methods that are opened in 2 from the Internet for different users.

Echo Phpinfo (); Check Disable_functions, if there is a fsock,fsockopen, you need to remove the two functions, restart Apache, and then continue to the following:

Method One:

The first step:

Find in php.ini file

Allow_url_fopen = On

To make its value on

Step Two:

Find in php.ini file

Extension=php_openssl.dll

If preceded by a semicolon, remove the semicolon

Step Three:

Restart the Web server, Apache or IIS

There is another situation, namely method two:

1. VI php.ini

Find Allow_url_fopen This parameter is set to ON, i.e.

Allow_url_fopen = On

2. Let your PHP support the opensll extension.

By default, there is no OpenSSL extension, only the installation can be recompiled.

Yum Install OpenSSL Openssl-devel

Cd/usr/local/src/php-5.2.14/ext/openssl

/usr/local/php/bin/phpize

./configure–with-openssl–with-php-config=/usr/local/bin/php-config

Make && make install

Look at the hint, copy the compiled openssl.so to the extension_dir you specified in the php.ini

3. VI php.ini

Join

Extension=openssl.so

4. Restart the Web server

abstract : the Fsockopen () function is used to open a socket connection, and another function Pfsockopen () has a similar function, except that the latter is a "continuous" (persistent) fsockopen () function, It does not immediately disconnect after the script has finished running.

One
The first step
Locate the php.ini file, open it with Notepad, look for allow_url_fopen = Look at the back is off also on, if it is on, directly see the next step, if it is off then modify it to on, you need to note that the complete is allow_url_fopen = on equals left and right there are spaces.
Allow_url_fopen = On
Step Two
Continue in the php.ini file, find, find Extension=php_openssl.dll find out later everyone notice, extension=php_openssl.dll this piece of code before there will be A; Number, just put this; The number is deleted and then saved.
Extension=php_openssl.dll
Step Three
Restart IIS if it is IIS
If it's Apache, restart Apache.

Two
Fsockopen () function with socket Analog HTTP protocol (POST)
Can be similar to the real HTTP operation, can be used for collection, mass forum post and so on ... The Fsockopen () function is used to open a socket connection, and another function Pfsockopen () has a similar function, except that the latter is a "continuous" (persistent) fsockopen () function. It does not immediately disconnect after the script has finished running.

The Fsockopen () function has a relatively large security problem, such as being used by hackers for phpddos attacks, so many host providers disable this function.

So how do you know if your host provider has disabled this function?

We can create a new. php file in any of the web directories, and enter the following code in it:

<?php

Echo Phpinfo ();

?>

After saving and then accessing the page in the browser, you can see that the page is rendered with the current PHP configuration information, press CTRL+F to search for allow_url_fopen or disable_functions, as shown in the following:

In the Allow_url_fopen column, if the value is on, and Disable_functions does not have fsockopen function in the list of disabled functions, the Fsockopen () function is available, otherwise fsockopen () The function may be disabled.

So how do you enable or disable this function?

We need to find php.ini this PHP configuration file, if you need to disable it, you need to make the following modifications:

1. Change Allow_url_fopen=on to Allow_url_fopen=off

2. Add Fsockopen after disable_functions=

If you want to enable it, you only need to do the opposite.

How does the server open PHP's Fsockopen function? Use the Send Mailbox class

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.