2

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?

Nikola K.
  • 7,093
  • 13
  • 31
  • 39
user1561329
  • 89
  • 1
  • 1
  • 7
  • 6
    You will have to talk to your host provider... they have disabled the use of the exec command... Read what the warning is telling you ;) – craig1231 Jul 29 '12 at 18:06
  • 2
    Get a provider that has a 64bit PHP install, and that function will become pointless. – Marc B Jul 29 '12 at 18:08
  • 3
    Duplicate: http://stackoverflow.com/questions/1837451/exec-has-been-disabled-for-security-reasons-undefined-variable – Nikola K. Jul 29 '12 at 18:08

2 Answers2

11

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.
Eugene Kaurov
  • 2,356
  • 28
  • 39
Parag Petkar
  • 111
  • 2
  • 4
  • Nice... Thanks @Parag Petkar. This totally helped me find the solution to my own problem. – Vince Nov 11 '19 at 02:28
  • excellent answer. I searched all the php and fpm config files I could find, but I went to WHM, followed your instructions and there it was! – Brian Apr 12 '20 at 00:55
3

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.

Niet the Dark Absol
  • 320,036
  • 81
  • 464
  • 592