phantomjs_capture.install in PhantomJS Capture 7
File
phantomjs_capture.install
View source
<?php
function phantomjs_capture_install() {
$directory = file_default_scheme() . '://phantomjs';
$test_directory = file_default_scheme() . '://phantomjs/test';
file_prepare_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS, TRUE);
file_prepare_directory($test_directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS, TRUE);
}
function phantomjs_capture_requirements($phase) {
$requirements = [];
$enabled = _is_exec_enabled();
$url = "http://php.net/manual/en/function.exec.php";
if ($enabled) {
$message = t('The !url command is available.', [
'!url' => l('exec()', $url),
]);
}
else {
$message = t('The !url command is not available or the user has no permission to use it, you will be unable to use the phantomjs binary.', [
'!url' => l('exec()', $url),
]);
}
$requirements['phantomjs_capture'] = [
'title' => t('PhantomJS Capture'),
'value' => $message,
'severity' => $enabled ? REQUIREMENT_OK : REQUIREMENT_ERROR,
];
return $requirements;
}
function _is_exec_enabled() {
$safe_mode = ini_get('safe_mode');
if ($safe_mode && drupal_strtolower($safe_mode) != 'off') {
return FALSE;
}
$disabled = explode(',', ini_get('disable_functions'));
return !in_array('exec', $disabled);
}