/** * Check if server has MySQL 5.0+ * */ function yourls_check_database_version() { global $ydb; // Attempt to get MySQL server version, check result and if error count increased $num_errors1 = count($ydb->captured_errors); $version = yourls_get_database_version(); $num_errors2 = count($ydb->captured_errors); if ($version == NULL || $num_errors2 > $num_errors1) { yourls_die(yourls__('Incorrect DB config, or could not connect to DB'), yourls__('Fatal error'), 503); } return version_compare('5.0', $version) <= 0; }
<?php define('YOURLS_ADMIN', true); define('YOURLS_INSTALLING', true); require_once dirname(dirname(__FILE__)) . '/includes/load-yourls.php'; require_once YOURLS_INC . '/functions-install.php'; $error = array(); $warning = array(); $success = array(); // Check pre-requisites if (!yourls_check_database_version()) { $error[] = yourls_s('%s version is too old. Ask your server admin for an upgrade.', 'MySQL'); yourls_debug_log('MySQL version: ' . yourls_get_database_version()); } if (!yourls_check_php_version()) { $error[] = yourls_s('%s version is too old. Ask your server admin for an upgrade.', 'PHP'); yourls_debug_log('PHP version: ' . phpversion()); } // Is YOURLS already installed ? if (yourls_is_installed()) { $error[] = yourls__('YOURLS already installed.'); // check if .htaccess exists, recreate otherwise. No error checking. if (!file_exists(YOURLS_ABSPATH . '/.htaccess')) { yourls_create_htaccess(); } } // Start install if possible and needed if (isset($_REQUEST['install']) && count($error) == 0) { // Create/update .htaccess file if (yourls_create_htaccess()) { $success[] = yourls__('File <tt>.htaccess</tt> successfully created/updated.');