Skip to content

Commit

Permalink
Merge pull request #113 from thomasjacquin/exec-with-and-without-space
Browse files Browse the repository at this point in the history
functions.php: check for "exec" AND " exec"
  • Loading branch information
EricClaeys authored May 30, 2022
2 parents e6236d2 + e35bc58 commit bf5418a
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,29 @@
/*
* Does the exec() function work? It's needed to make thumbnails from video files.
*/
$yes_no = null;
function can_make_video_thumbnails() {
global $yes_no;
if ($yes_no !== null) return($yes_no);

$disabled = explode(',', ini_get('disable_functions'));
$exec_disabled = in_array('exec', $disabled);
// On some servers the disabled array contains leading spaces, so check both ways.
$exec_disabled = in_array('exec', $disabled) || in_array(' exec', $disabled);

if ($exec_disabled) {
echo "<script>console.log('exec() disabled');</script>";
return(false);
$yes_no = false;
} else {
// See if ffmpeg exists.
exec("which ffmpeg 2> /dev/null", $ret, $retvalue);
@exec("which ffmpeg 2> /dev/null", $ret, $retvalue);
if ($retvalue == 0) {
return(true);
$yes_no = true;
} else {
echo "<script>console.log('ffmpeg not found');</script>";
$yes_no = false;
}
}
return($yes_no);
}

/*
Expand Down

0 comments on commit bf5418a

Please sign in to comment.