user1561329
user1561329

Reputation: 89

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?

Upvotes: 2

Views: 15427

Answers (2)

Parag Petkar
Parag Petkar

Reputation: 111

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.

Upvotes: 11

Niet the Dark Absol
Niet the Dark Absol

Reputation: 324630

The error means exactly what it says. Whoever set up your server (probably your webhost) has disabled the use of the exec function. In other words, you can't use exec.

You could probably work around it by using glob to get the file of files, or filesize to get the size (in bytes) of the file.

Upvotes: 3

Related Questions