Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
507 views
in Technique[技术] by (71.8m points)

php - Warning: exec() has been disabled for security reasons

I get this error on my page:

Warning: exec() has been disabled for security reasons in /home/a2297145/public_html/android/index.php on line 2036

Here's the code:

//
// Determine the size of a file
// 
public static function getFileSize($file)
{
    $sizeInBytes = filesize($file);

    // If filesize() fails (with larger files), try to get the size from unix command line.
    if (EncodeExplorer::getConfig("large_files") == true || !$sizeInBytes || $sizeInBytes < 0) {
        $sizeInBytes=exec("ls -l '$file' | awk '{print $5}'");
    }
    return $sizeInBytes;
}

Can you help me to solve this?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

This error can be resolved in two ways:

  1. Either check for "disable_functions" list in "php.ini" file on your server and remove "exec" or "shell_exec" from the list. Remember to restart your PHP-CGI to apply those changes.

OR

  1. Login into WHM and type "multiPHP Manager" search box in top left corner and go to multiPHP manager. Choose the domain inside php version section in which you want to disable exec() or shell_exec(). and click on edit PHP-FPM and scroll down to disable_functions and remove exec() or shell_exec() by editing list there.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...