function testMissingExtentionWithExtra() { $ext = 'php_ext'; $extra = 'Appended Extra String'; $this->setExpectedException('PHPUnit_Framework_Error', 'The [a@' . PMA_getPHPDocLink('book.' . $ext . '.php') . '@Documentation][em]' . $ext . '[/em][/a] extension is missing. Please check your PHP configuration.' . ' ' . $extra); PMA_warnMissingExtension($ext, false, $extra); $this->assertTrue(true); }
/** * Test for PMA_warnMissingExtension * * @return void */ function testMissingExtensionFatalWithExtra() { $ext = 'php_ext'; $extra = 'Appended Extra String'; $warn = 'The <a href="' . PMA_getPHPDocLink('book.' . $ext . '.php') . '" target="Documentation"><em>' . $ext . '</em></a> extension is missing. Please check your PHP configuration.' . ' ' . $extra; ob_start(); PMA_warnMissingExtension($ext, true, $extra); $printed = ob_get_contents(); ob_end_clean(); $this->assertGreaterThan(0, mb_strpos($printed, $warn)); }
* */ date_default_timezone_set(@date_default_timezone_get()); /******************************************************************************/ /* parsing configuration file LABEL_parsing_config_file */ /** * We really need this one! */ if (!function_exists('preg_replace')) { PMA_warnMissingExtension('pcre', true); } /** * JSON is required in several places. */ if (!function_exists('json_encode')) { PMA_warnMissingExtension('json', true); } /** * @global PMA_Config $GLOBALS['PMA_Config'] * force reading of config file, because we removed sensitive values * in the previous iteration */ $GLOBALS['PMA_Config'] = new PMA_Config(CONFIG_FILE); if (!defined('PMA_MINIMUM_COMMON')) { $GLOBALS['PMA_Config']->checkPmaAbsoluteUri(); } /** * BC - enable backward compatibility * exports all configuration settings into $GLOBALS ($GLOBALS['cfg']) */ $GLOBALS['PMA_Config']->enableBc();
/** * Checks that required PHP extensions are there. * @return void */ function PMA_checkExtensions() { /** * Warning about mbstring. */ if (!function_exists('mb_detect_encoding')) { PMA_warnMissingExtension('mbstring', true); } /** * We really need this one! */ if (!function_exists('preg_replace')) { PMA_warnMissingExtension('pcre', true); } /** * JSON is required in several places. */ if (!function_exists('json_encode')) { PMA_warnMissingExtension('json', true); } }
} /** * check timezone setting * this could produce an E_STRICT - but only once, * if not done here it will produce E_STRICT on every date/time function * * @todo need to decide how we should handle this (without @) */ date_default_timezone_set(@date_default_timezone_get()); /******************************************************************************/ /* parsing configuration file LABEL_parsing_config_file */ /** * We really need this one! */ if (!function_exists('preg_replace')) { PMA_warnMissingExtension('pcre', true); } /** * @global PMA_Config $GLOBALS['PMA_Config'] * force reading of config file, because we removed sensitive values * in the previous iteration */ $GLOBALS['PMA_Config'] = new PMA_Config(CONFIG_FILE); if (!defined('PMA_MINIMUM_COMMON')) { $GLOBALS['PMA_Config']->checkPmaAbsoluteUri(); } /** * BC - enable backward compatibility * exports all configuration settings into $GLOBALS ($GLOBALS['cfg']) */ $GLOBALS['PMA_Config']->enableBc();
if (!PMA_DBI_checkDbExtension($GLOBALS['cfg']['Server']['extension'])) { // if it fails try alternative extension ... // and display an error ... /** * @todo add different messages for alternative extension * and complete fail (no alternative extension too) */ PMA_warnMissingExtension($GLOBALS['cfg']['Server']['extension'], false, PMA_CommonFunctions::getInstance()->showDocu('faqmysql')); if ($GLOBALS['cfg']['Server']['extension'] === 'mysql') { $alternativ_extension = 'mysqli'; } else { $alternativ_extension = 'mysql'; } if (!PMA_DBI_checkDbExtension($alternativ_extension)) { // if alternative fails too ... PMA_warnMissingExtension($GLOBALS['cfg']['Server']['extension'], true, PMA_CommonFunctions::getInstance()->showDocu('faqmysql')); } $GLOBALS['cfg']['Server']['extension'] = $alternativ_extension; unset($alternativ_extension); } /** * Including The DBI Plugin */ require_once './libraries/dbi/' . $GLOBALS['cfg']['Server']['extension'] . '.dbi.lib.php'; /** * runs a query * * @param string $query SQL query to execte * @param mixed $link optional database link to use * @param int $options optional query options * @param bool $cache_affected_rows whether to cache affected rows
sprintf( __('Server running with Suhosin. Please refer to %sdocumentation%s for possible issues.'), '[a@./Documentation.html#faq1_38@_blank]', '[/a]' ), E_USER_WARNING ); } /** * Warning about mcrypt. */ if (! function_exists('mcrypt_encrypt') && ! $GLOBALS['cfg']['McryptDisableWarning'] ) { PMA_warnMissingExtension('mcrypt'); } /** * Warning about incomplete translations. * * The data file is created while creating release by ./scripts/remove-incomplete-mo */ if (file_exists('libraries/language_stats.inc.php')) { include 'libraries/language_stats.inc.php'; /* * This message is intentionally not translated, because we're * handling incomplete translations here and focus on english * speaking users. */ if (isset($GLOBALS['language_stats'][$lang])
} /** * Load SOAP client. */ if (class_exists('SOAPClient')) { $GLOBALS['sqlvalidator_error'] = false; $GLOBALS['sqlvalidator_soap'] = 'PHP'; } else { @(include_once 'SOAP/Client.php'); if (class_exists('SOAP_Client')) { $GLOBALS['sqlvalidator_soap'] = 'PEAR'; $GLOBALS['sqlvalidator_error'] = false; } else { $GLOBALS['sqlvalidator_soap'] = 'NONE'; $GLOBALS['sqlvalidator_error'] = true; PMA_warnMissingExtension('soap'); } } if (!$GLOBALS['sqlvalidator_error']) { // Ok, we have SOAP Support, so let's use it! /** * @package PhpMyAdmin */ class PMA_SQLValidator { var $url; var $service_name; var $wsdl; var $output_type; var $username; var $password;
if (!PMA_DBI_checkDbExtension($GLOBALS['cfg']['Server']['extension'])) { // if it fails try alternative extension ... // and display an error ... /** * @todo add different messages for alternative extension * and complete fail (no alternative extension too) */ PMA_warnMissingExtension($GLOBALS['cfg']['Server']['extension'], false, PMA_Util::showDocu('faqmysql')); if ($GLOBALS['cfg']['Server']['extension'] === 'mysql') { $alternativ_extension = 'mysqli'; } else { $alternativ_extension = 'mysql'; } if (!PMA_DBI_checkDbExtension($alternativ_extension)) { // if alternative fails too ... PMA_warnMissingExtension($GLOBALS['cfg']['Server']['extension'], true, PMA_Util::showDocu('faqmysql')); } $GLOBALS['cfg']['Server']['extension'] = $alternativ_extension; unset($alternativ_extension); } /** * Including The DBI Plugin */ include_once './libraries/dbi/' . $GLOBALS['cfg']['Server']['extension'] . '.dbi.lib.php'; } /** * runs a query * * @param string $query SQL query to execte * @param mixed $link optional database link to use * @param int $options optional query options
if (!DatabaseInterface::checkDbExtension($extension)) { $docurl = PMA\libraries\Util::getDocuLink('faq', 'faqmysql'); $doclink = sprintf(__('See %sour documentation%s for more information.'), '[a@' . $docurl . '@documentation]', '[/a]'); if (PMA_PHP_INT_VERSION < 70000) { $extension = 'mysql'; if (!PMA\libraries\DatabaseInterface::checkDbExtension($extension)) { // warn about both extensions missing and exit PMA_warnMissingExtension('mysqli|mysql', true, $doclink); } elseif (empty($_SESSION['mysqlwarning'])) { trigger_error(__('You are using the mysql extension which is deprecated in ' . 'phpMyAdmin. Please consider installing the mysqli ' . 'extension.') . ' ' . $doclink, E_USER_WARNING); // tell the user just once per session $_SESSION['mysqlwarning'] = true; } } else { // mysql extension is not part of PHP 7+, so warn and exit PMA_warnMissingExtension('mysqli', true, $doclink); } } /** * Including The DBI Plugin */ switch ($extension) { case 'mysql': $extension = new DBIMysql(); break; case 'mysqli': include_once 'libraries/dbi/DBIMysqli.lib.php'; $extension = new DBIMysqli(); break; } }
$PMA_recoding_engine = PMA_CHARSET_NONE; PMA_warnMissingExtension('iconv'); } } elseif ($GLOBALS['cfg']['RecodingEngine'] == 'recode') { if (@function_exists('recode_string')) { $PMA_recoding_engine = PMA_CHARSET_RECODE; } else { $PMA_recoding_engine = PMA_CHARSET_NONE; PMA_warnMissingExtension('recode'); } } elseif ($GLOBALS['cfg']['RecodingEngine'] == 'mb') { if (@function_exists('mb_convert_encoding')) { $PMA_recoding_engine = PMA_CHARSET_MB; } else { $PMA_recoding_engine = PMA_CHARSET_NONE; PMA_warnMissingExtension('mbstring'); } } elseif ($GLOBALS['cfg']['RecodingEngine'] == 'auto') { if (@function_exists('iconv')) { if (@stristr(PHP_OS, 'AIX') && @strcasecmp(ICONV_IMPL, 'unknown') == 0 && @strcasecmp(ICONV_VERSION, 'unknown') == 0) { $PMA_recoding_engine = PMA_CHARSET_ICONV_AIX; } else { $PMA_recoding_engine = PMA_CHARSET_ICONV; } } elseif (@function_exists('recode_string')) { $PMA_recoding_engine = PMA_CHARSET_RECODE; } elseif (@function_exists('mb_convert_encoding')) { $PMA_recoding_engine = PMA_CHARSET_MB; } else { $PMA_recoding_engine = PMA_CHARSET_NONE; }
if (@function_exists('iconv')) { if (@stristr(PHP_OS, 'AIX') && @strcasecmp(ICONV_IMPL, 'unknown') == 0 && @strcasecmp(ICONV_VERSION, 'unknown') == 0) { $PMA_recoding_engine = PMA_CHARSET_ICONV_AIX; } else { $PMA_recoding_engine = PMA_CHARSET_ICONV; } } else { $PMA_recoding_engine = PMA_CHARSET_NONE; PMA_warnMissingExtension('iconv'); } } elseif ($cfg['RecodingEngine'] == 'recode') { if (@function_exists('recode_string')) { $PMA_recoding_engine = PMA_CHARSET_RECODE; } else { $PMA_recoding_engine = PMA_CHARSET_NONE; PMA_warnMissingExtension('recode'); } } elseif ($cfg['RecodingEngine'] == 'auto') { if (@function_exists('iconv')) { if (@stristr(PHP_OS, 'AIX') && @strcasecmp(ICONV_IMPL, 'unknown') == 0 && @strcasecmp(ICONV_VERSION, 'unknown') == 0) { $PMA_recoding_engine = PMA_CHARSET_ICONV_AIX; } else { $PMA_recoding_engine = PMA_CHARSET_ICONV; } } elseif (@function_exists('recode_string')) { $PMA_recoding_engine = PMA_CHARSET_RECODE; } else { $PMA_recoding_engine = PMA_CHARSET_NONE; } } else { $PMA_recoding_engine = PMA_CHARSET_NONE;
// and display an error ... $docurl = PMA_Util::getDocuLink('faq', 'faqmysql'); $doclink = sprintf(__('See %sour documentation%s for more information.'), '[a@' . $docurl . '@documentation]', '[/a]'); /** * @todo add different messages for alternative extension * and complete fail (no alternative extension too) */ PMA_warnMissingExtension($GLOBALS['cfg']['Server']['extension'], false, $doclink); if ($GLOBALS['cfg']['Server']['extension'] === 'mysql') { $alternativ_extension = 'mysqli'; } else { $alternativ_extension = 'mysql'; } if (!PMA_DBI_checkDbExtension($alternativ_extension)) { // if alternative fails too ... PMA_warnMissingExtension($GLOBALS['cfg']['Server']['extension'], true, $doclink); } $GLOBALS['cfg']['Server']['extension'] = $alternativ_extension; unset($alternativ_extension); } /** * Including The DBI Plugin */ include_once './libraries/dbi/' . $GLOBALS['cfg']['Server']['extension'] . '.dbi.lib.php'; } /** * runs a query * * @param string $query SQL query to execte * @param mixed $link optional database link to use * @param int $options optional query options
/** * Simple handler of chart errors. * @param array $errors all occured errors */ function PMA_handle_chart_err($errors) { if (in_array(ERR_NO_GD, $errors)) { PMA_warnMissingExtension('GD', false, __('GD extension is needed for charts.')); } else { if (in_array(ERR_NO_JSON, $errors)) { PMA_warnMissingExtension('JSON', false, __('JSON encoder is needed for chart tooltips.')); } } }
// and display an error ... $docurl = PMA_Util::getDocuLink('faq', 'faqmysql'); $doclink = sprintf(__('See %sour documentation%s for more information.'), '[a@' . $docurl . '@documentation]', '[/a]'); /** * @todo add different messages for alternative extension * and complete fail (no alternative extension too) */ PMA_warnMissingExtension($extensionName, false, $doclink); if ($extensionName === 'mysql') { $alternativ_extension = 'mysqli'; } else { $alternativ_extension = 'mysql'; } if (!PMA_DatabaseInterface::checkDbExtension($alternativ_extension)) { // if alternative fails too ... PMA_warnMissingExtension($extensionName, true, $doclink); } $GLOBALS['cfg']['Server']['extension'] = $alternativ_extension; unset($alternativ_extension); } /** * Including The DBI Plugin */ switch ($GLOBALS['cfg']['Server']['extension']) { case 'mysql': include_once './libraries/dbi/DBIMysql.class.php'; $extension = new PMA_DBI_Mysql(); break; case 'mysqli': include_once './libraries/dbi/DBIMysqli.class.php'; $extension = new PMA_DBI_Mysqli();
/** * Initializes encoding engine detecting available backends. * * @return void */ public static function initEngine() { $engine = 'auto'; if (isset($GLOBALS['cfg']['RecodingEngine'])) { $engine = $GLOBALS['cfg']['RecodingEngine']; } /* Use user configuration */ if (isset(self::$_enginemap[$engine])) { if (@function_exists(self::$_enginemap[$engine][0])) { self::$_engine = self::$_enginemap[$engine][1]; return; } else { PMA_warnMissingExtension(self::$_enginemap[$engine][2]); } } /* Autodetection */ foreach (self::$_engineorder as $engine) { if (@function_exists(self::$_enginemap[$engine][0])) { self::$_engine = self::$_enginemap[$engine][1]; return; } } /* Fallback to none conversion */ self::$_engine = self::ENGINE_NONE; }