public function checkDependencies() { $check = array(); array_push($check, array('success' => true, 'warning' => false, 'value' => __('Plugin version', 'useyourdrive'), 'description' => USEYOURDRIVE_VERSION)); if (version_compare(PHP_VERSION, '5.3.0') < 0) { array_push($check, array('success' => false, 'warning' => false, 'value' => __('PHP version', 'useyourdrive'), 'description' => phpversion() . ' ' . __('You need at least PHP 5.3 if you want to use Use-your-Drive', 'useyourdrive'))); } else { array_push($check, array('success' => true, 'warning' => false, 'value' => __('PHP version', 'useyourdrive'), 'description' => phpversion())); } /* Check if we can use CURL */ if (function_exists('curl_init')) { array_push($check, array('success' => true, 'warning' => false, 'value' => __('cURL PHP extension', 'useyourdrive'), 'description' => __('You have the cURL PHP extension installed and we can access Google with cURL', 'useyourdrive'))); } else { array_push($check, array('success' => false, 'warning' => false, 'value' => __('cURL PHP extension', 'useyourdrive'), 'description' => __("You don't have the cURL PHP extension installed (couldn't find function \"curl_init\"), please enable or install this extension", 'useyourdrive'))); } /* Check if we can use fOpen */ if (ini_get('allow_url_fopen')) { array_push($check, array('success' => true, 'warning' => false, 'value' => __('Is allow_url_fopen enabled?', 'useyourdrive'), 'description' => __('Yes, we can access Google with fopen', 'useyourdrive'))); } else { array_push($check, array('success' => false, 'warning' => false, 'value' => __('Is allow_url_fopen enabled?', 'useyourdrive'), 'description' => __("No, we can't access Google with fopen", 'useyourdrive'))); } /* Check which version of the Google API Client we are using */ if (class_exists('Google_Client') && method_exists('Google_Client', 'getLibraryVersion')) { $googleClient = new Google_Client(); array_push($check, array('success' => true, 'warning' => false, 'value' => __('Version Google Api Client', 'useyourdrive'), 'description' => $googleClient->getLibraryVersion())); } else { array_push($check, array('success' => false, 'warning' => false, 'value' => __('Version Google Api Client', 'useyourdrive'), 'description' => __("Before version 1.0.0", 'useyourdrive') . '. ' . __("Another plugin is loading an old Google Client library. Use-your-Drive isn't compatible with this version.", 'useyourdrive'))); } /* Check if temp dir is writeable */ $uploadir = wp_upload_dir(); if (!is_writable($uploadir['path'])) { array_push($check, array('success' => false, 'warning' => false, 'value' => __('Is TMP directory writable?', 'useyourdrive'), 'description' => __('TMP directory', 'useyourdrive') . ' \'' . $uploadir['path'] . '\' ' . __('isn\'t writable. You are not able to upload files to Drive.', 'useyourdrive') . ' ' . __('Make sure TMP directory is writable', 'useyourdrive'))); } else { array_push($check, array('success' => true, 'warning' => false, 'value' => __('Is TMP directory writable?', 'useyourdrive'), 'description' => __('TMP directory is writable', 'useyourdrive'))); } /* Check if cache dir is writeable */ if (!file_exists(USEYOURDRIVE_CACHEDIR)) { @mkdir(USEYOURDRIVE_CACHEDIR, 0755); } if (!is_writable(USEYOURDRIVE_CACHEDIR)) { @chmod(USEYOURDRIVE_CACHEDIR, 0755); if (!is_writable(USEYOURDRIVE_CACHEDIR)) { array_push($check, array('success' => false, 'warning' => false, 'value' => __('Is CACHE directory writable?', 'useyourdrive'), 'description' => __('CACHE directory', 'useyourdrive') . ' \'' . USEYOURDRIVE_CACHEDIR . '\' ' . __('isn\'t writable. The gallery will load very slowly.', 'useyourdrive') . ' ' . __('Make sure CACHE directory is writable', 'useyourdrive'))); } else { array_push($check, array('success' => true, 'warning' => false, 'value' => __('Is CACHE directory writable?', 'useyourdrive'), 'description' => __('CACHE directory is now writable', 'useyourdrive'))); } } else { array_push($check, array('success' => true, 'warning' => false, 'value' => __('Is CACHE directory writable?', 'useyourdrive'), 'description' => __('CACHE directory is writable', 'useyourdrive'))); } /* Check if cache index-file is writeable */ if (!is_readable(USEYOURDRIVE_CACHEDIR . '/index')) { @file_put_contents(USEYOURDRIVE_CACHEDIR . '/index', json_encode(array())); if (!is_readable(USEYOURDRIVE_CACHEDIR . '/index')) { array_push($check, array('success' => false, 'warning' => false, 'value' => __('Is CACHE-index file writable?', 'useyourdrive'), 'description' => __('-index file', 'useyourdrive') . ' \'' . USEYOURDRIVE_CACHEDIR . 'index' . '\' ' . __('isn\'t writable. The gallery will load very slowly.', 'useyourdrive') . ' ' . __('Make sure CACHE-index file is writable', 'useyourdrive'))); } else { array_push($check, array('success' => true, 'warning' => false, 'value' => __('Is CACHE-index file writable?', 'useyourdrive'), 'description' => __('CACHE-index file is now writable', 'useyourdrive'))); } } else { array_push($check, array('success' => true, 'warning' => false, 'value' => __('Is CACHE-index file writable?', 'useyourdrive'), 'description' => __('CACHE-index file is writable', 'useyourdrive'))); } /* Check if we can use ZIP class */ if (class_exists('ZipArchive')) { $message = __("You can use the ZIP function", 'useyourdrive'); array_push($check, array('success' => true, 'warning' => false, 'value' => __('Download files as ZIP', 'useyourdrive'), 'description' => $message)); } else { $message = __("You cannot download files as ZIP", 'useyourdrive'); array_push($check, array('success' => true, 'warning' => true, 'value' => __('Download files as ZIP', 'useyourdrive'), 'description' => $message)); } /* Check if Gravity Forms is installed and can be used */ if (class_exists("GFForms")) { $is_correct_version = false; if (class_exists('GFCommon')) { $is_correct_version = version_compare(GFCommon::$version, '1.9', '>='); } if ($is_correct_version) { $message = __("You can use Use-your-Drive in Gravity Forms (" . GFCommon::$version . ")", 'useyourdrive'); array_push($check, array('success' => true, 'warning' => false, 'value' => __('Gravity Forms integration', 'useyourdrive'), 'description' => $message)); } else { $message = __("You have Gravity Forms (" . GFCommon::$version . ") installed, but versions before 1.9 are not supported. Please update Gravity Forms if you want to use this plugin in combination with Gravity Forms", 'useyourdrive'); array_push($check, array('success' => false, 'warning' => true, 'value' => __('Gravity Forms integration', 'useyourdrive'), 'description' => $message)); } } else { $message = __("You don't have Gravity Forms installed", 'useyourdrive'); array_push($check, array('success' => false, 'warning' => false, 'value' => __('Gravity Forms integration', 'useyourdrive'), 'description' => $message)); } /* Create Table */ $html = '<table border="0" cellspacing="0" cellpadding="0">'; foreach ($check as $row) { $color = $row['success'] ? 'green' : 'red'; $color = $row['warning'] ? 'orange' : $color; $html .= '<tr style="vertical-align:top;"><td width="200" style="padding: 5px; color:' . $color . '"><strong>' . $row['value'] . '</strong></td><td style="padding: 5px;">' . $row['description'] . '</td></tr>'; } $html .= '</table>'; return $html; }