Пример #1
0
/**
 * Main function for the routines functionality
 *
 * @param string $type 'FUNCTION' for functions,
 *                     'PROCEDURE' for procedures,
 *                     null for both
 *
 * @return void
 */
function PMA_RTN_main($type)
{
    global $db;
    PMA_RTN_setGlobals();
    /**
     * Process all requests
     */
    PMA_RTN_handleEditor();
    PMA_RTN_handleExecute();
    PMA_RTN_handleExport();
    /**
     * Display a list of available routines
     */
    $columns = "`SPECIFIC_NAME`, `ROUTINE_NAME`, `ROUTINE_TYPE`, ";
    $columns .= "`DTD_IDENTIFIER`, `ROUTINE_DEFINITION`";
    $where = "ROUTINE_SCHEMA " . PMA_Util::getCollateForIS() . "=" . "'" . PMA_Util::sqlAddSlashes($db) . "'";
    if (PMA_isValid($type, array('FUNCTION', 'PROCEDURE'))) {
        $where .= " AND `ROUTINE_TYPE`='" . $type . "'";
    }
    $items = $GLOBALS['dbi']->fetchResult("SELECT {$columns} FROM `INFORMATION_SCHEMA`.`ROUTINES` WHERE {$where};");
    echo PMA_RTE_getList('routine', $items);
    /**
     * Display the form for adding a new routine, if the user has the privileges.
     */
    echo PMA_RTN_getFooterLinks();
    /**
     * Display a warning for users with PHP's old "mysql" extension.
     */
    if (!PMA_DatabaseInterface::checkDbExtension('mysqli')) {
        trigger_error(__('You are using PHP\'s deprecated \'mysql\' extension, ' . 'which is not capable of handling multi queries. ' . '[strong]The execution of some stored routines may fail![/strong] ' . 'Please use the improved \'mysqli\' extension to ' . 'avoid any problems.'), E_USER_WARNING);
    }
}
/**
 * Main function for the routines functionality
 *
 * @param string $type 'FUNCTION' for functions,
 *                     'PROCEDURE' for procedures,
 *                     null for both
 *
 * @return void
 */
function PMA_RTN_main($type)
{
    global $db;
    PMA_RTN_setGlobals();
    /**
     * Process all requests
     */
    PMA_RTN_handleEditor();
    PMA_RTN_handleExecute();
    PMA_RTN_handleExport();
    /**
     * Display a list of available routines
     */
    if (!PMA_isValid($type, array('FUNCTION', 'PROCEDURE'))) {
        $type = null;
    }
    $items = $GLOBALS['dbi']->getRoutines($db, $type);
    echo PMA_RTE_getList('routine', $items);
    /**
     * Display the form for adding a new routine, if the user has the privileges.
     */
    echo PMA_RTN_getFooterLinks();
    /**
     * Display a warning for users with PHP's old "mysql" extension.
     */
    if (!PMA_DatabaseInterface::checkDbExtension('mysqli')) {
        trigger_error(__('You are using PHP\'s deprecated \'mysql\' extension, ' . 'which is not capable of handling multi queries. ' . '[strong]The execution of some stored routines may fail![/strong] ' . 'Please use the improved \'mysqli\' extension to ' . 'avoid any problems.'), E_USER_WARNING);
    }
}
Пример #3
0
    echo '           (' . $mysql_charset_map['utf-8'] . ')' . '        </span>' . '    </li>' . '  </ul>' . ' </div>';
}
if ($GLOBALS['cfg']['ShowServerInfo'] || $GLOBALS['cfg']['ShowPhpInfo']) {
    echo '<div class="group">';
    echo '<h2>' . __('Web server') . '</h2>';
    echo '<ul>';
    if ($GLOBALS['cfg']['ShowServerInfo']) {
        PMA_printListItem($_SERVER['SERVER_SOFTWARE'], 'li_web_server_software');
        if ($server > 0) {
            $client_version_str = $GLOBALS['dbi']->getClientInfo();
            if (preg_match('#\\d+\\.\\d+\\.\\d+#', $client_version_str)) {
                $client_version_str = 'libmysql - ' . $client_version_str;
            }
            PMA_printListItem(__('Database client version:') . ' ' . $client_version_str, 'li_mysql_client_version');
            $php_ext_string = __('PHP extension:') . ' ';
            if (PMA_DatabaseInterface::checkDbExtension('mysqli')) {
                $extension = 'mysqli';
            } else {
                $extension = 'mysql';
            }
            $php_ext_string .= $extension . ' ' . PMA_Util::showPHPDocu('book.' . $extension . '.php');
            PMA_printListItem($php_ext_string, 'li_used_php_extension');
        }
    }
    if ($cfg['ShowPhpInfo']) {
        PMA_printListItem(__('Show PHP information'), 'li_phpinfo', 'phpinfo.php' . $common_url_query, null, '_blank');
    }
    echo '  </ul>';
    echo ' </div>';
}
echo '<div class="group pmagroup">';
Пример #4
0
 /**
  * Test database connection
  *
  * @param string $connect_type 'tcp' or 'socket'
  * @param string $host         host name
  * @param string $port         tcp port to use
  * @param string $socket       socket to use
  * @param string $user         username to use
  * @param string $pass         password to use
  * @param string $error_key    key to use in return array
  *
  * @return bool|array
  */
 public static function testDBConnection($connect_type, $host, $port, $socket, $user, $pass = null, $error_key = 'Server')
 {
     //    static::testPHPErrorMsg();
     $error = null;
     if (PMA_DatabaseInterface::checkDbExtension('mysqli')) {
         $socket = empty($socket) || $connect_type == 'tcp' ? null : $socket;
         $port = empty($port) || $connect_type == 'socket' ? null : $port;
         $extension = 'mysqli';
     } else {
         $socket = empty($socket) || $connect_type == 'tcp' ? null : ':' . ($socket[0] == '/' ? '' : '/') . $socket;
         $port = empty($port) || $connect_type == 'socket' ? null : ':' . $port;
         $extension = 'mysql';
     }
     // dead code (drizzle extension)
     if ($extension == 'drizzle') {
         while (1) {
             $drizzle = @drizzle_create();
             if (!$drizzle) {
                 $error = __('Could not initialize Drizzle connection library!');
                 break;
             }
             $conn = $socket ? @drizzle_con_add_uds($socket, $user, $pass, null, 0) : @drizzle_con_add_tcp($drizzle, $host, $port, $user, $pass, null, 0);
             if (!$conn) {
                 $error = __('Could not connect to the database server!');
                 drizzle_free($drizzle);
                 break;
             }
             // connection object is set up but we have to send some query
             // to actually connect
             $res = @drizzle_query($conn, 'SELECT 1');
             if (!$res) {
                 $error = __('Could not connect to the database server!');
             } else {
                 drizzle_result_free($res);
             }
             drizzle_con_free($conn);
             drizzle_free($drizzle);
             break;
         }
     } else {
         if ($extension == 'mysql') {
             $conn = @mysql_connect($host . $port . $socket, $user, $pass);
             if (!$conn) {
                 $error = __('Could not connect to the database server!');
             } else {
                 mysql_close($conn);
             }
         } else {
             $conn = @mysqli_connect($host, $user, $pass, null, $port, $socket);
             if (!$conn) {
                 $error = __('Could not connect to the database server!');
             } else {
                 mysqli_close($conn);
             }
         }
     }
     //    static::testPHPErrorMsg(false);
     if (isset($php_errormsg)) {
         $error .= " - {$php_errormsg}";
     }
     return is_null($error) ? true : array($error_key => $error);
 }
    /**
     * For testsuite we use dummy driver which can fake some queries.
     */
    include_once './libraries/dbi/DBIDummy.class.php';
    $extension = new PMA_DBI_Dummy();
} else {
    /**
     * First check for the mysqli extension, as it's the one recommended
     * for the MySQL server's version that we support
     */
    $extension = 'mysqli';
    if (!PMA_DatabaseInterface::checkDbExtension($extension)) {
        $docurl = PMA_Util::getDocuLink('faq', 'faqmysql');
        $doclink = sprintf(__('See %sour documentation%s for more information.'), '[a@' . $docurl . '@documentation]', '[/a]');
        $extension = 'mysql';
        if (!PMA_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;
        }
    }
    /**
     * Including The DBI Plugin
     */
    switch ($extension) {
        case 'mysql':
            include_once './libraries/dbi/DBIMysql.class.php';
            $extension = new PMA_DBI_Mysql();
Пример #6
0
 /**
  * Test database connection
  *
  * @param string $connect_type 'tcp' or 'socket'
  * @param string $host         host name
  * @param string $port         tcp port to use
  * @param string $socket       socket to use
  * @param string $user         username to use
  * @param string $pass         password to use
  * @param string $error_key    key to use in return array
  *
  * @return bool|array
  */
 public static function testDBConnection($connect_type, $host, $port, $socket, $user, $pass = null, $error_key = 'Server')
 {
     //    static::testPHPErrorMsg();
     $error = null;
     if (PMA_DatabaseInterface::checkDbExtension('mysqli')) {
         $socket = empty($socket) || $connect_type == 'tcp' ? null : $socket;
         $port = empty($port) || $connect_type == 'socket' ? null : $port;
         $extension = 'mysqli';
     } else {
         $socket = empty($socket) || $connect_type == 'tcp' ? null : ':' . ($socket[0] == '/' ? '' : '/') . $socket;
         $port = empty($port) || $connect_type == 'socket' ? null : ':' . $port;
         $extension = 'mysql';
     }
     if ($extension == 'mysql') {
         $conn = @mysql_connect($host . $port . $socket, $user, $pass);
         if (!$conn) {
             $error = __('Could not connect to the database server!');
         } else {
             mysql_close($conn);
         }
     } else {
         $conn = @mysqli_connect($host, $user, $pass, null, $port, $socket);
         if (!$conn) {
             $error = __('Could not connect to the database server!');
         } else {
             mysqli_close($conn);
         }
     }
     //    static::testPHPErrorMsg(false);
     if (isset($php_errormsg)) {
         $error .= " - {$php_errormsg}";
     }
     return is_null($error) ? true : array($error_key => $error);
 }
Пример #7
0
 if (!PMA_DatabaseInterface::checkDbExtension($extensionName)) {
     // if it fails try alternative extension ...
     // 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':