Home >Backend Development >PHP Tutorial >Warning: chmod() has been disabled for security reasons in_PHP教程

Warning: chmod() has been disabled for security reasons in_PHP教程

WBOY
WBOYOriginal
2016-07-13 17:11:061405browse

Warning: chmod() has been disabled for security reasons in D:\freehost\xxx\WindFile.php on line 102 According to the English meaning, we know that chmod() has been disabled for security reasons, then The solution is very simple, just disable chmod().

If you have server permissions, the operation method is very simple. Open PHP.INI and find this line:

The code is as follows Copy code
 代码如下 复制代码

disable_functions =

disable_functions =

Add the functions to be disabled at the end. If you want to disable multiple functions, use half-width commas to separate them

Give me an example:
 代码如下 复制代码

disable_functions = passthru,exec,system,popen,chroot,scandir,chgrp,chown,escapesh

ellcmd,escapeshellarg,shell_exec,proc_open,proc_get_status

The code is as follows Copy code

disable_functions = passthru,exec,system,popen,chroot,scandir,chgrp,chown,escapesh

ellcmd,escapeshellarg,shell_exec,proc_open,proc_get_status


If you don’t have server permissions, you can only start with the program. Below I use ecmall to solve this problem
 代码如下 复制代码
if ($errno == 2048)
    {
        return true;
    }

Step one: Find eccore/controller/message.base.php

Will
 代码如下 复制代码

if ($errno == 2048 || (($errno & error_reporting()) != $errno))
    {
        //不再需要通过_at方法来抵制错误
        //错误被屏蔽时就不抛出异常,该处理就允许你在代码中照常使用error_reporting来控制错误报告
        return true;
    }

The code is as follows Copy code
if ($errno == 2048)

{
        return true;

}
Replace
 代码如下 复制代码

function _at($fun)
{
    $arg = func_get_args();
    unset($arg[0]);
    restore_error_handler();
    $ret_val = @call_user_func_array($fun, $arg);
    reset_error_handler();

    return $ret_val;
}

with

The code is as follows Copy code
if ($errno == 2048 || (($errno & error_reporting()) != $errno))
 代码如下 复制代码

function _at($fun)
{
    $arg = func_get_args();
    unset($arg[0]);
    $ret_val = @call_user_func_array($fun, $arg);

    return $ret_val;


}

{ ​​​​ //No more need to use _at method to resist errors ​​​​ //No exception will be thrown when the error is masked. This processing allows you to use error_reporting in the code as usual to control error reporting         return true; }
Step 2: Find eccore/ecmall.php
The code is as follows Copy code
function _at($fun) { $arg = func_get_args(); ​ unset($arg[0]); Restore_error_handler(); $ret_val = @call_user_func_array($fun, $arg); ​ reset_error_handler(); return $ret_val; }
was changed to
The code is as follows Copy code
function _at($fun) { $arg = func_get_args(); ​ unset($arg[0]); $ret_val = @call_user_func_array($fun, $arg); return $ret_val; }

We try our best to avoid some dangerous functions during development to avoid having to change them later. Below I list the functions that are prohibited by general servers

The code is as follows
 代码如下 复制代码

disable_functions = system,exec,shell_exec,passthru,proc_open,proc_close, proc_get_status,checkdnsrr,getmxrr,getservbyname,getservbyport, syslog,popen,show_source,highlight_file,dl,socket_listen,socket_create,socket_bind,socket_accept, socket_connect, stream_socket_server, stream_socket_accept,stream_socket_client,ftp_connect, ftp_login,ftp_pasv,ftp_get,sys_getloadavg,disk_total_space, disk_free_space,posix_ctermid,posix_get_last_error,posix_getcwd, posix_getegid,posix_geteuid,posix_getgid, posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid, posix_getppid,posix_getpwnam,posix_getpwuid, posix_getrlimit, posix_getsid,posix_getuid,posix_isatty, posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid, posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname

Copy code
disable_functions = system,exec,shell_exec,passthru,proc_open,proc_close, proc_get_status,checkdnsrr,getmxrr,getservbyname,getservbyport, syslog,popen,show_source,highlight_file,dl,socket_listen,socket_create,socket_bind,socket_accept, socket_connect, stream_socket_server, stream_ socket_accept ,stream_socket_client,ftp_connect, ftp_login,ftp_pasv,ftp_get,sys_getloadavg,disk_total_space, disk_free_space,posix_ctermid,posix_get_last_error,posix_getcwd, posix_getegid,posix_geteuid,posix_getgid, posix_getgrgid,posix_getgrnam,posix_get groups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid, posix_getppid,posix_getpwnam,posix_getpwuid, posix_getrlimit , posix_getsid,posix_getuid,posix_isatty, posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid, posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname

http://www.bkjia.com/PHPjc/629637.htmlwww.bkjia.comtrue
http: //www.bkjia.com/PHPjc/629637.html
TechArticle
Warning: chmod() has been disabled for security reasons in D:\freehost\xxx\WindFile.php on line 102 According to the English meaning, we know that chmod() has been disabled for security reasons...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn