123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- <?php
- function plupload_requirements($phase) {
- $requirements = array();
- $t = get_t();
- if ($phase == 'runtime') {
- $requirements['plupload'] = array(
- 'title' => $t('Plupload library'),
- 'value' => $t('Unknown'),
- );
- $requirements['plupload']['severity'] = REQUIREMENT_OK;
- $libraries = plupload_library();
- $library = $libraries['plupload'];
-
-
- if (!_plupload_requirements_installed()) {
- $message = 'The <a href="@url">@title</a> library (version @version or higher) is not installed.';
- $args = array(
- '@title' => $library['title'],
- '@url' => url($library['website']),
- '@version' => $library['version'],
- );
- $requirements['plupload']['description'] = $t($message, $args);
- $requirements['plupload']['severity'] = REQUIREMENT_ERROR;
- }
- elseif (($installed_version = _plupload_requirements_version()) === NULL) {
- $requirements['plupload']['description'] = $t('Plupload version could not be determined.');
- $requirements['plupload']['severity'] = REQUIREMENT_INFO;
- }
- elseif (!version_compare($library['version'], $installed_version, '<=')) {
- $requirements['plupload']['description'] = $t('Plupload @version or higher is required.', array('@version' => $library['version']));
- $requirements['plupload']['severity'] = REQUIREMENT_INFO;
- }
- $requirements['plupload']['value'] = empty($installed_version) ? $t('Not found') : $installed_version;
- if (file_exists(_plupload_library_path() . '/examples/upload.php')) {
- $requirements['plupload_examples'] = array(
- 'title' => $t('Plupload example folder'),
- 'value' => $t('Example folder found'),
- 'description' => $t('Plupload library contains example files, these could constitute a security risk to your site as per <a href="!url">PSA-2011-02</a>. Please remove the !path folder immediately.', array(
- '!url' => 'http://drupal.org/node/1189632',
- '!path' => _plupload_library_path() . '/examples'
- )),
- 'severity' => REQUIREMENT_ERROR
- );
- }
- }
- return $requirements;
- }
- function _plupload_requirements_installed() {
- $libraries = plupload_library();
- $library = $libraries['plupload'];
-
- $testfile = key($library['js']);
- if (!file_exists($testfile)) {
- return FALSE;
- }
- return TRUE;
- }
- function _plupload_requirements_version() {
- $library_path = _plupload_library_path();
- $jspath = $library_path . '/js/plupload.js';
-
- $configcontents = @file_get_contents($jspath);
- if (!$configcontents) {
- return NULL;
- }
-
- $matches = array();
- if (preg_match('#VERSION:\"(\d+[\.\d+]*)\"#', $configcontents, $matches)) {
- return $matches[1];
- }
- return NULL;
- }
|