Exemplo n.º 1
0
 public function getAttribute($attribute, &$source = null, $func = 'PDO::getAttribute', &$last_error = null)
 {
     if ($source == null) {
         $source =& $this->driver_options;
     }
     switch ($attribute) {
         case PDO::ATTR_AUTOCOMMIT:
             $result = mysqli_query($this->link, 'SELECT @@AUTOCOMMIT', MYSQLI_USE_RESULT);
             if (!$result) {
                 $this->set_driver_error(null, PDO::ERRMODE_EXCEPTION, $func);
             }
             $row = mysqli_fetch_row($result);
             mysqli_free_result($result);
             return intval($row[0]);
             break;
         case PDO::ATTR_CLIENT_VERSION:
             return mysqli_get_client_info();
             break;
         case PDO::ATTR_CONNECTION_STATUS:
             return mysqli_get_host_info($this->link);
             break;
         case PDO::ATTR_SERVER_INFO:
             return mysqli_stat($this->link);
             break;
         case PDO::ATTR_SERVER_VERSION:
             return mysqli_get_server_info($this->link);
             break;
         default:
             return parent::getAttribute($attribute, $source, $func, $last_error);
             break;
     }
 }
function dump_properties($mysqli)
{
    printf("\nClass variables:\n");
    $variables = array_keys(get_class_vars(get_class($mysqli)));
    sort($variables);
    foreach ($variables as $k => $var) {
        printf("%s = '%s'\n", $var, var_export(@$mysqli->{$var}, true));
    }
    printf("\nObject variables:\n");
    $variables = array_keys(get_object_vars($mysqli));
    foreach ($variables as $k => $var) {
        printf("%s = '%s'\n", $var, var_export(@$mysqli->{$var}, true));
    }
    printf("\nMagic, magic properties:\n");
    assert(@mysqli_affected_rows($mysqli) === @$mysqli->affected_rows);
    printf("mysqli->affected_rows = '%s'/%s ('%s'/%s)\n", @$mysqli->affected_rows, gettype(@$mysqli->affected_rows), @mysqli_affected_rows($mysqli), gettype(@mysqli_affected_rows($mysqli)));
    assert(@mysqli_get_client_info() === @$mysqli->client_info);
    printf("mysqli->client_info = '%s'/%s ('%s'/%s)\n", @$mysqli->client_info, gettype(@$mysqli->client_info), @mysqli_get_client_info(), gettype(@mysqli_get_client_info()));
    assert(@mysqli_get_client_version() === @$mysqli->client_version);
    printf("mysqli->client_version =  '%s'/%s ('%s'/%s)\n", @$mysqli->client_version, gettype(@$mysqli->client_version), @mysqli_get_client_version(), gettype(@mysqli_get_client_version()));
    assert(@mysqli_errno($mysqli) === @$mysqli->errno);
    printf("mysqli->errno = '%s'/%s ('%s'/%s)\n", @$mysqli->errno, gettype(@$mysqli->errno), @mysqli_errno($mysqli), gettype(@mysqli_errno($mysqli)));
    assert(@mysqli_error($mysqli) === @$mysqli->error);
    printf("mysqli->error = '%s'/%s ('%s'/%s)\n", @$mysqli->error, gettype(@$mysqli->error), @mysqli_error($mysqli), gettype(@mysqli_error($mysqli)));
    assert(@mysqli_field_count($mysqli) === @$mysqli->field_count);
    printf("mysqli->field_count = '%s'/%s ('%s'/%s)\n", @$mysqli->field_count, gettype(@$mysqli->field_count), @mysqli_field_count($mysqli), gettype(@mysqli_field_count($mysqli)));
    assert(@mysqli_insert_id($mysqli) === @$mysqli->insert_id);
    printf("mysqli->insert_id = '%s'/%s ('%s'/%s)\n", @$mysqli->insert_id, gettype(@$mysqli->insert_id), @mysqli_insert_id($mysqli), gettype(@mysqli_insert_id($mysqli)));
    assert(@mysqli_sqlstate($mysqli) === @$mysqli->sqlstate);
    printf("mysqli->sqlstate = '%s'/%s ('%s'/%s)\n", @$mysqli->sqlstate, gettype(@$mysqli->sqlstate), @mysqli_sqlstate($mysqli), gettype(@mysqli_sqlstate($mysqli)));
    assert(@mysqli_get_host_info($mysqli) === @$mysqli->host_info);
    printf("mysqli->host_info = '%s'/%s ('%s'/%s)\n", @$mysqli->host_info, gettype(@$mysqli->host_info), @mysqli_get_host_info($mysqli), gettype(@mysqli_get_host_info($mysqli)));
    /* note that the data types are different */
    assert(@mysqli_info($mysqli) == @$mysqli->info);
    printf("mysqli->info = '%s'/%s ('%s'/%s)\n", @$mysqli->info, gettype(@$mysqli->info), @mysqli_info($mysqli), gettype(@mysqli_info($mysqli)));
    assert(@mysqli_thread_id($mysqli) > @$mysqli->thread_id);
    assert(gettype(@$mysqli->thread_id) == gettype(@mysqli_thread_id($mysqli)));
    printf("mysqli->thread_id = '%s'/%s ('%s'/%s)\n", @$mysqli->thread_id, gettype(@$mysqli->thread_id), @mysqli_thread_id($mysqli), gettype(@mysqli_thread_id($mysqli)));
    assert(@mysqli_get_proto_info($mysqli) === @$mysqli->protocol_version);
    printf("mysqli->protocol_version = '%s'/%s ('%s'/%s)\n", @$mysqli->protocol_version, gettype(@$mysqli->protocol_version), @mysqli_get_proto_info($mysqli), gettype(@mysqli_get_proto_info($mysqli)));
    assert(@mysqli_get_server_info($mysqli) === @$mysqli->server_info);
    printf("mysqli->server_info = '%s'/%s ('%s'/%s)\n", @$mysqli->server_info, gettype(@$mysqli->server_info), @mysqli_get_server_info($mysqli), gettype(@mysqli_get_server_info($mysqli)));
    assert(@mysqli_get_server_version($mysqli) === @$mysqli->server_version);
    printf("mysqli->server_version = '%s'/%s ('%s'/%s)\n", @$mysqli->server_version, gettype(@$mysqli->server_version), @mysqli_get_server_version($mysqli), gettype(@mysqli_get_server_version($mysqli)));
    assert(@mysqli_warning_count($mysqli) === @$mysqli->warning_count);
    printf("mysqli->warning_count = '%s'/%s ('%s'/%s)\n", @$mysqli->warning_count, gettype(@$mysqli->warning_count), @mysqli_warning_count($mysqli), gettype(@mysqli_warning_count($mysqli)));
    printf("\nAccess to undefined properties:\n");
    printf("mysqli->unknown = '%s'\n", @$mysqli->unknown);
    @($mysqli->unknown = 13);
    printf("setting mysqli->unknown, @mysqli_unknown = '%s'\n", @$mysqli->unknown);
    $unknown = 'friday';
    @($mysqli->unknown = $unknown);
    printf("setting mysqli->unknown, @mysqli_unknown = '%s'\n", @$mysqli->unknown);
    printf("\nAccess hidden properties for MYSLQI_STATUS_INITIALIZED (TODO documentation):\n");
    assert(@mysqli_connect_error() === @$mysqli->connect_error);
    printf("mysqli->connect_error = '%s'/%s ('%s'/%s)\n", @$mysqli->connect_error, gettype(@$mysqli->connect_error), @mysqli_connect_error(), gettype(@mysqli_connect_error()));
    assert(@mysqli_connect_errno() === @$mysqli->connect_errno);
    printf("mysqli->connect_errno = '%s'/%s ('%s'/%s)\n", @$mysqli->connect_errno, gettype(@$mysqli->connect_errno), @mysqli_connect_errno(), gettype(@mysqli_connect_errno()));
}
Exemplo n.º 3
0
 function get_details()
 {
     $result = $this->_owner->query('SHOW VARIABLES', false, true);
     while ($row = $result->fetch_row()) {
         $details[$row[0]] = $row[1];
     }
     $result->free();
     $details['engine'] = 'MySQLi';
     $details['client'] = mysqli_get_client_info();
     $details['server'] = $this->_owner->connect_id->server_info;
     $details['unicode'] = version_compare($details['server'], '4.1') >= 0;
     $details['host'] = mysqli_get_host_info($this->_owner->connect_id);
     return $details;
 }
Exemplo n.º 4
0
 public function search($table, $columns, $searchValue, $exclude = null, $exactMatch = false)
 {
     if (strpos(mysqli_get_client_info(), 'mysqlnd ') === false) {
         return false;
     }
     $bind = array();
     $result = array();
     $table = self::mysqli()->real_escape_string($table);
     // We can't prepare tables, so this will have to do
     $sql = "SELECT * FROM {$table} WHERE";
     foreach ($columns as $key => $col) {
         if ($key == count($columns) - 1) {
             $sql .= ' ' . $col . ' LIKE ? AND ' . $col . ' NOT LIKE ?';
         } else {
             $sql .= ' ' . $col . ' LIKE ? AND ' . $col . ' NOT LIKE ? OR';
         }
         $bind[0] = isset($bind[0]) ? $bind[0] . "ss" : 'ss';
         $bind[] = "%" . $searchValue . "%";
         if ($exclude == null) {
             $bind[] = "";
         } else {
             $bind[] = "%" . $exclude . "%";
         }
     }
     foreach ($bind as $key => $value) {
         $bind[$key] =& $bind[$key];
         // Makes them references for bind_param
     }
     if ($stmt = $this->mysqli()->prepare($sql)) {
         call_user_func_array(array($stmt, "bind_param"), $bind);
         // See what I did there? Dynamic bind_param. Nifty
         try {
             $stmt->execute();
         } catch (Exception $e) {
             return false;
         }
         $results = $stmt->get_result();
         while ($row = $results->fetch_array(MYSQLI_ASSOC)) {
             $result[] = $row;
         }
         return $result;
     }
     return false;
 }
Exemplo n.º 5
0
 private function _getInfoArray()
 {
     $info['User']['Browser'] = $_SERVER['HTTP_USER_AGENT'];
     $info['User']['Role'] = current_user()->role;
     $info['System']['Omeka'] = OMEKA_VERSION;
     $info['System']['PHP'] = phpversion() . ' (' . php_sapi_name() . ')';
     $uname = php_uname('s') . ' ' . php_uname('r') . ' ' . php_uname('m');
     $info['System']['OS'] = $uname;
     $info['System']['MySQL Server'] = $this->_db->getServerVersion();
     $info['System']['MySQL Client'] = mysqli_get_client_info();
     if (function_exists('apache_get_version')) {
         $apacheVersion = apache_get_version();
         if ($apacheVersion) {
             $info['System']['Apache'] = $apacheVersion;
         }
     }
     $this->_addExtensionInfo($info);
     $this->_addPluginInfo($info);
     $this->_addThemeInfo($info);
     return apply_filters('system_info', $info);
 }
Exemplo n.º 6
0
 public function mysql_server($num = '')
 {
     switch ($num) {
         case 1:
             return mysqli_get_server_info();
             //MySQL 服务器信息
             break;
         case 2:
             return mysqli_get_host_info();
             //取得 MySQL 主机信息
             break;
         case 3:
             return mysqli_get_client_info();
             //取得 MySQL 客户端信息
             break;
         case 4:
             return mysqli_get_proto_info();
             //取得 MySQL 协议信息
             break;
         default:
             return mysqli_get_client_info();
             //默认取得mysql版本信息
     }
 }
Exemplo n.º 7
0
 public function getDbInfo()
 {
     $charsets = $this->getCharsetInfo();
     $charset_str = array();
     foreach ($charsets as $name => $value) {
         $charset_str[] = "{$name} = {$value}";
     }
     return array("MySQLi Version" => @mysqli_get_client_info(), "MySQLi Host Info" => @mysqli_get_host_info($this->database), "MySQLi Server Info" => @mysqli_get_server_info($this->database), "MySQLi Client Encoding" => @mysqli_client_encoding($this->database), "MySQL Character Set Settings" => join(", ", $charset_str));
 }
Exemplo n.º 8
0
/**
 * Renders stage 2: either config details panel (on success) or database details
 * error message (on fail).
 */
function printConfig()
{
    $_SESSION['ddb'] = ps('ddb');
    $_SESSION['duser'] = ps('duser');
    $_SESSION['dpass'] = ps('dpass');
    $_SESSION['dhost'] = ps('dhost');
    $_SESSION['dprefix'] = ps('dprefix');
    $_SESSION['siteurl'] = ps('siteurl');
    $GLOBALS['textarray'] = setup_load_lang($_SESSION['lang']);
    global $txpcfg;
    echo txp_setup_progress_meter(2) . n . '<div class="txp-setup">';
    if (!isset($txpcfg['db'])) {
        @(include txpath . '/config.php');
    }
    if (!empty($txpcfg['db'])) {
        echo graf(span(null, array('class' => 'ui-icon ui-icon-alert')) . ' ' . setup_gTxt('already_installed', array('{txpath}' => txpath)), array('class' => 'alert-block warning')) . setup_back_button(__FUNCTION__) . n . '</div>';
        exit;
    }
    // TODO: @see http://forum.textpattern.com/viewtopic.php?pid=263205#p263205
    //    if ('' === $_SESSION['dhost'] || '' === $_SESSION['duser'] || '' === $_SESSION['ddb']) {
    //        echo graf(
    //                span(null, array('class' => 'ui-icon ui-icon-alert')).' '.
    //                setup_gTxt('missing_db_details'),
    //                array('class' => 'alert-block warning')
    //            ).
    //            n.setup_back_button(__FUNCTION__).
    //            n.'</div>';
    //
    //        exit;
    //    }
    echo hed(setup_gTxt("checking_database"), 2);
    if (strpos($_SESSION['dhost'], ':') === false) {
        $dhost = $_SESSION['dhost'];
        $dport = ini_get("mysqli.default_port");
    } else {
        list($dhost, $dport) = explode(':', $_SESSION['dhost'], 2);
        $dport = intval($dport);
    }
    $dsocket = ini_get("mysqli.default_socket");
    $mylink = mysqli_init();
    if (@mysqli_real_connect($mylink, $dhost, $_SESSION['duser'], $_SESSION['dpass'], '', $dport, $dsocket)) {
        $_SESSION['dclient_flags'] = 0;
    } elseif (@mysqli_real_connect($mylink, $dhost, $_SESSION['duser'], $_SESSION['dpass'], '', $dport, $dsocket, MYSQLI_CLIENT_SSL)) {
        $_SESSION['dclient_flags'] = 'MYSQLI_CLIENT_SSL';
    } else {
        echo graf(span(null, array('class' => 'ui-icon ui-icon-closethick')) . ' ' . setup_gTxt('db_cant_connect'), array('class' => 'alert-block error')) . setup_back_button(__FUNCTION__) . n . '</div>';
        exit;
    }
    echo graf(span(null, array('class' => 'ui-icon ui-icon-check')) . ' ' . setup_gTxt('db_connected'), array('class' => 'alert-block success'));
    if (!($_SESSION['dprefix'] == '' || preg_match('#^[a-zA-Z_][a-zA-Z0-9_]*$#', $_SESSION['dprefix']))) {
        echo graf(span(null, array('class' => 'ui-icon ui-icon-closethick')) . ' ' . setup_gTxt('prefix_bad_characters', array('{dbprefix}' => strong(txpspecialchars($_SESSION['dprefix']))), 'raw'), array('class' => 'alert-block error')) . setup_back_button(__FUNCTION__) . n . '</div>';
        exit;
    }
    if (!($mydb = mysqli_select_db($mylink, $_SESSION['ddb']))) {
        echo graf(span(null, array('class' => 'ui-icon ui-icon-closethick')) . ' ' . setup_gTxt('db_doesnt_exist', array('{dbname}' => strong(txpspecialchars($_SESSION['ddb']))), 'raw'), array('class' => 'alert-block error')) . setup_back_button(__FUNCTION__) . n . '</div>';
        exit;
    }
    $tables_exist = mysqli_query($mylink, "DESCRIBE `" . $_SESSION['dprefix'] . "textpattern`");
    if ($tables_exist) {
        echo graf(span(null, array('class' => 'ui-icon ui-icon-closethick')) . ' ' . setup_gTxt('tables_exist', array('{dbname}' => strong(txpspecialchars($_SESSION['ddb']))), 'raw'), array('class' => 'alert-block error')) . setup_back_button(__FUNCTION__) . n . '</div>';
        exit;
    }
    // On MySQL 5.5.3+ use real UTF-8 tables, if the client supports it.
    $_SESSION['dbcharset'] = "utf8mb4";
    // Lower versions only support UTF-8 limited to 3 bytes per character
    if (mysqli_get_server_version($mylink) < 50503) {
        $_SESSION['dbcharset'] = "utf8";
    } else {
        if (false !== strpos(mysqli_get_client_info($mylink), 'mysqlnd')) {
            // mysqlnd 5.0.9+ required
            if (mysqli_get_client_version($mylink) < 50009) {
                $_SESSION['dbcharset'] = "utf8";
            }
        } else {
            // libmysqlclient 5.5.3+ required
            if (mysqli_get_client_version($mylink) < 50503) {
                $_SESSION['dbcharset'] = "utf8";
            }
        }
    }
    echo graf(span(null, array('class' => 'ui-icon ui-icon-check')) . ' ' . setup_gTxt('using_db', array('{dbname}' => strong(txpspecialchars($_SESSION['ddb']))), 'raw') . ' (' . $_SESSION['dbcharset'] . ')', array('class' => 'alert-block success'));
    echo setup_config_contents() . n . '</div>';
}
if (empty($expected_methods) && empty($methods)) {
    printf("ok\n");
}
printf("\nClass variables:\n");
$variables = array_keys(get_class_vars(get_class($driver)));
sort($variables);
foreach ($variables as $k => $var) {
    printf("%s\n", $var);
}
printf("\nObject variables:\n");
$variables = array_keys(get_object_vars($driver));
foreach ($variables as $k => $var) {
    printf("%s\n", $var);
}
printf("\nMagic, magic properties:\n");
assert(mysqli_get_client_info() === $driver->client_info);
printf("driver->client_info = '%s'\n", $driver->client_info);
assert(mysqli_get_client_version() === $driver->client_version);
printf("driver->client_version = '%s'\n", $driver->client_version);
assert($driver->driver_version > 0);
printf("driver->driver_version = '%s'\n", $driver->driver_version);
assert(in_array($driver->report_mode, array(MYSQLI_REPORT_ALL, MYSQLI_REPORT_STRICT, MYSQLI_REPORT_ERROR, MYSQLI_REPORT_INDEX, MYSQLI_REPORT_OFF)));
printf("driver->report_mode = '%s'\n", $driver->report_mode);
$driver->report_mode = MYSQLI_REPORT_STRICT;
assert($driver->report_mode === MYSQLI_REPORT_STRICT);
assert(is_bool($driver->embedded));
printf("driver->embedded = '%s'\n", $driver->embedded);
printf("driver->reconnect = '%s'\n", $driver->reconnect);
printf("\nAccess to undefined properties:\n");
printf("driver->unknown = '%s'\n", @$driver->unknown);
print "done!";
Exemplo n.º 10
0
 /**
  * 获得当前的环境信息
  *
  * @return array
  */
 private function _getCurrentEnvironment()
 {
     $lowestEnvironment = $this->_getLowestEnvironment();
     $mysql_isok = true;
     if (function_exists('mysql_get_client_info')) {
         $mysql = mysql_get_client_info();
     } elseif (function_exists('mysqli_get_client_info')) {
         $mysql = mysqli_get_client_info();
     } else {
         $mysql = 'unknow';
         $mysql_isok = false;
     }
     if (function_exists('gd_info')) {
         $gdinfo = gd_info();
         $gd = $gdinfo['GD Version'];
         $gd_isok = true;
     } else {
         $gd = '2.1.1-dev';
         $gd_isok = true;
     }
     $upload = ini_get('file_uploads') ? ini_get('upload_max_filesize') : 'unknow';
     $space = floor(@disk_free_space(FCPATH) / (1024 * 1024));
     $space = $space ? $space . 'M' : 'unknow';
     return array('os' => PHP_OS, 'php' => phpversion(), 'mysql' => $mysql, 'gd' => $gd, 'upload' => $upload, 'space' => $space, 'os_isok' => true, 'php_isok' => version_compare(phpversion(), $lowestEnvironment['php']) < 0 ? false : true, 'mysql_isok' => $mysql_isok, 'gd_isok' => $gd_isok, 'upload_isok' => intval($upload) >= intval($lowestEnvironment['upload']) ? true : false, 'space_isok' => intval($space) >= intval($lowestEnvironment['space']) ? true : false);
 }
Exemplo n.º 11
0
function executemysql($getinfo, $getdumps, $getschema)
{
    //BEGIN GET DB INFO
    global $getDumpsFrom;
    global $curdatetime;
    global $sugar_config;
    global $progress_bar_percent;
    global $sod_guid;
    global $db;
    if ($db->dbType != "mysql") {
        if ($getinfo) {
            sodUpdateProgressBar(MYSQL_INFO_WEIGHT);
        }
        if ($getschema) {
            sodUpdateProgressBar(MYSQL_SCHEMA_WEIGHT);
        }
        if ($getdumps) {
            sodUpdateProgressBar(MYSQL_DUMPS_WEIGHT);
        }
        return;
    }
    $mysqlInfoDir = create_cache_directory("diagnostic/" . $sod_guid . "/diagnostic" . $curdatetime . "/MySQL/");
    //create directory for table definitions
    if ($getschema) {
        $tablesSchemaDir = create_cache_directory("diagnostic/" . $sod_guid . "/diagnostic" . $curdatetime . "/MySQL/TableSchema/");
    }
    //BEGIN GET MYSQL INFO
    //make sure they checked the box to get basic info
    if ($getinfo) {
        ob_start();
        echo "MySQL Version: " . (function_exists('mysqli_get_client_info') ? @mysqli_get_client_info() : @mysql_get_client_info()) . "<BR>";
        echo "MySQL Host Info: " . (function_exists('mysqli_get_host_info') ? @mysqli_get_host_info($db->getDatabase()) : @mysql_get_host_info()) . "<BR>";
        echo "MySQL Server Info: " . (function_exists('mysqli_get_client_info') ? @mysqli_get_client_info() : @mysql_get_client_info()) . "<BR>";
        echo "MySQL Client Encoding: " . (function_exists('mysqli_character_set_name') ? @mysqli_character_set_name($db->getDatabase()) : @mysql_client_encoding()) . "<BR>";
        /* Uncomment to get current processes as well
           echo "<BR>MySQL Processes<BR>";
           $res = $db->query('SHOW PROCESSLIST');
           echo "<table border=\"1\"><tr><th>Id</th><th>Host</th><th>db</th><th>Command</th><th>Time</th></tr>";
           if($db->getRowCount($res) > 0)
           {
             while($row = $db->fetchByAssoc($res))
             {
               printf("<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>",
                      $row['Id'], $row['Host'], $row['db'], $row['Command'], $row['Time']
                      );
             }
             echo "</table><br>";
           }
           else
           {
             echo "</table>";
             echo "No processes running<br>";
           }
           */
        echo "<BR>MySQL Character Set Settings<BR>";
        $res = $db->query("show variables like 'character\\_set\\_%'");
        echo "<table border=\"1\"><tr><th>Variable Name</th><th>Value</th></tr>";
        while ($row = $db->fetchByAssoc($res)) {
            printf("<tr><td>%s</td><td>%s</td></tr>", $row['Variable_name'], $row['Value']);
        }
        echo "</table>";
        $content = ob_get_contents();
        ob_clean();
        $handle = sugar_fopen($mysqlInfoDir . "MySQL-General-info.html", "w");
        if (fwrite($handle, $content) === FALSE) {
            echo "Cannot write to file " . $mysqlInfoDir . "_MySQL-General-info.html<br>";
        }
        fclose($handle);
        //BEGIN UPDATING PROGRESS BAR
        sodUpdateProgressBar(MYSQL_INFO_WEIGHT);
        //END UPDATING PROGRESS BAR
    }
    //END GET MYSQL INFO
    if ($getschema) {
        //BEGIN GET ALL TABLES SCHEMAS
        $all_tables = $db->getTablesArray();
        global $theme_path;
        ob_start();
        echo "<style>";
        echo file_get_contents($theme_path . "style.css");
        echo "</style>";
        foreach ($all_tables as $tablename) {
            //setting up table header for each file
            echo "<table border=\"0\" cellpadding=\"0\" class=\"tabDetailView\">";
            echo "<tr>MySQL " . $tablename . " Definitions:</tr>" . "<tr><td class=\"tabDetailViewDL\"><b>Field</b></td>" . "<td class=\"tabDetailViewDL\">Type</td>" . "<td class=\"tabDetailViewDL\">Null</td>" . "<td class=\"tabDetailViewDL\">Key</td>" . "<td class=\"tabDetailViewDL\">Default</td>" . "<td class=\"tabDetailViewDL\">Extra</td></tr>";
            $describe = $db->query("describe " . $tablename);
            while ($inner_row = $db->fetchByAssoc($describe)) {
                $inner_row = array_values($inner_row);
                echo "<tr><td class=\"tabDetailViewDF\"><b>" . $inner_row[0] . "</b></td>";
                echo "<td class=\"tabDetailViewDF\">" . $inner_row[1] . "</td>";
                echo "<td class=\"tabDetailViewDF\">" . $inner_row[2] . "</td>";
                echo "<td class=\"tabDetailViewDF\">" . $inner_row[3] . "</td>";
                echo "<td class=\"tabDetailViewDF\">" . $inner_row[4] . "</td>";
                echo "<td class=\"tabDetailViewDF\">" . $inner_row[5] . "</td></tr>";
            }
            echo "</table>";
            echo "<BR><BR>";
        }
        $content = ob_get_contents();
        ob_clean();
        $handle = sugar_fopen($tablesSchemaDir . "MySQLTablesSchema.html", "w");
        if (fwrite($handle, $content) === FALSE) {
            echo "Cannot write to file " . $tablesSchemaDir . "MySQLTablesSchema.html<br>";
        }
        fclose($handle);
        //END GET ALL TABLES SCHEMAS
        //BEGIN UPDATING PROGRESS BAR
        sodUpdateProgressBar(MYSQL_SCHEMA_WEIGHT);
        //END UPDATING PROGRESS BAR
    }
    if ($getdumps) {
        //BEGIN GET TABLEDUMPS
        $tableDumpsDir = create_cache_directory("diagnostic/" . $sod_guid . "/diagnostic" . $curdatetime . "/MySQL/TableDumps/");
        foreach ($getDumpsFrom as $table) {
            ob_start();
            //calling function defined above to get the string for dump
            echo getFullTableDump($table);
            $content = ob_get_contents();
            ob_clean();
            $handle = sugar_fopen($tableDumpsDir . $table . ".html", "w");
            if (fwrite($handle, $content) === FALSE) {
                echo "Cannot write to file " . $tableDumpsDir . $table . "html<br>";
            }
            fclose($handle);
        }
        //END GET TABLEDUMPS
        //BEGIN UPDATING PROGRESS BAR
        sodUpdateProgressBar(MYSQL_DUMPS_WEIGHT);
        //END UPDATING PROGRESS BAR
    }
    //END GET DB INFO
}
Exemplo n.º 12
0
<?php

$test_table_name = 'test_mysqli_driver_table_1';
require "table.inc";
if (!is_object($driver = new mysqli_driver())) {
    printf("[001] Failed to create mysqli_driver object\n");
}
$client_info = mysqli_get_client_info();
if (($tmp = $driver->client_info) !== $client_info) {
    printf("[002] Expecting %s/%s, got %s/%s\n", gettype($client_info), $client_info, gettype($tmp), $tmp);
}
$client_version = mysqli_get_client_version();
if (($tmp = $driver->client_version) !== $client_version) {
    printf("[003] Expecting %s/%s, got %s/%s\n", gettype($client_version), $client_version, gettype($tmp), $tmp);
}
if (!is_int($tmp = $driver->driver_version) || 0 == $tmp) {
    printf("[004] Expecting int/any, got %s/%s\n", gettype($tmp), $tmp);
}
$all_modes = array(MYSQLI_REPORT_INDEX, MYSQLI_REPORT_ERROR, MYSQLI_REPORT_STRICT, MYSQLI_REPORT_ALL, MYSQLI_REPORT_OFF);
$report_mode = $driver->report_mode;
if (!is_int($report_mode)) {
    printf("[005] Expecting int/any, got %s/%s\n", gettype($report_mode), $report_mode);
}
if (!in_array($report_mode, $all_modes)) {
    printf("[006] Illegal report mode returned? Got %s, expected %s\n", $report_mode, implode(', ', $all_modes));
}
$driver->report_mode = MYSQLI_REPORT_STRICT;
$ok = false;
try {
    if ($link = my_mysqli_connect($host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket)) {
        printf("[007] Can connect to the server using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n", $host, $user . 'unknown_really', $db, $port, $socket);
Exemplo n.º 13
0
/**
 * returns a string that represents the client library version
 * @uses    mysqli_get_client_info()
 * @return  string          MySQL client library version
 */
function PMA_DBI_get_client_info()
{
    return mysqli_get_client_info();
}
Exemplo n.º 14
0
 function bps_mysqli_get_client_info()
 {
     if (function_exists('mysqli_get_client_info')) {
         return mysqli_get_client_info();
     }
 }
 function mysql_get_client_info()
 {
     return mysqli_get_client_info($GLOBALS['_MySQLCON_']);
 }
Exemplo n.º 16
0
 function mysql_get_client_info(\mysqli $link = null)
 {
     return mysqli_get_client_info(\Dshafik\MySQL::getConnection($link));
 }
Exemplo n.º 17
0
 public function getServerInfo($type = null)
 {
     if ($this->conn_id && $this->state == self::OPEN) {
         switch ($type) {
             case self::CLIENT_VERSION:
                 return mysqli_get_client_info();
                 break;
             case self::HOST_INFO:
                 return mysqli_get_host_info($this->conn_id);
                 break;
             case self::PROTOCOL_VERSION:
                 return mysqli_get_proto_info($this->conn_id);
                 break;
             case self::SERVER_VERSION:
             default:
                 return mysqli_get_server_info($this->conn_id);
                 break;
         }
         return '';
     }
     //throw new PhPBURN_Exception() TODO CREATE EXCETION CLASS AND INPUT AN EXCEPTION HERE;
 }
Exemplo n.º 18
0
function exceptionHandler($exception)
{
    global $CONF;
    if (!headers_sent()) {
        if (!class_exists('HTTP', false)) {
            require_once 'includes/classes/HTTP.class.php';
        }
        HTTP::sendHeader('HTTP/1.1 503 Service Unavailable');
    }
    if (method_exists($exception, 'getSeverity')) {
        $errno = $exception->getSeverity();
    } else {
        $errno = E_USER_ERROR;
    }
    $errorType = array(E_ERROR => 'ERROR', E_WARNING => 'WARNING', E_PARSE => 'PARSING ERROR', E_NOTICE => 'NOTICE', E_CORE_ERROR => 'CORE ERROR', E_CORE_WARNING => 'CORE WARNING', E_COMPILE_ERROR => 'COMPILE ERROR', E_COMPILE_WARNING => 'COMPILE WARNING', E_USER_ERROR => 'USER ERROR', E_USER_WARNING => 'USER WARNING', E_USER_NOTICE => 'USER NOTICE', E_STRICT => 'STRICT NOTICE', E_RECOVERABLE_ERROR => 'RECOVERABLE ERROR');
    try {
        if (!class_exists('Config', false)) {
            throw new Exception("No config class");
        }
        $VERSION = Config::get('VERSION');
    } catch (Exception $e) {
        if (file_exists(ROOT_PATH . 'install/VERSION')) {
            $VERSION = file_get_contents(ROOT_PATH . 'install/VERSION') . ' (FILE)';
        } else {
            $VERSION = 'UNKNOWN';
        }
    }
    try {
        if (!class_exists('Config', false)) {
            throw new Exception("No config class");
        }
        $gameName = Config::get('game_name');
    } catch (Exception $e) {
        $gameName = '-';
    }
    $DIR = MODE == 'INSTALL' ? '..' : '.';
    ob_start();
    echo '<!DOCTYPE html>
<!--[if lt IE 7 ]> <html lang="de" class="no-js ie6"> <![endif]-->
<!--[if IE 7 ]>    <html lang="de" class="no-js ie7"> <![endif]-->
<!--[if IE 8 ]>    <html lang="de" class="no-js ie8"> <![endif]-->
<!--[if IE 9 ]>    <html lang="de" class="no-js ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html lang="de" class="no-js"> <!--<![endif]-->
<head>
	<title>' . $errorType[$errno] . '</title>
	<meta name="generator" content="2Moons ' . $VERSION . '">
	<!-- 
		This website is powered by 2Moons ' . $VERSION . '
		2Moons is a free Space Browsergame initially created by Jan Kr�pke and licensed under GNU/GPL.
		2Moons is copyright 2009-2013 of Jan Kröpke. Extensions are copyright of their respective owners.
		Information and contribution at http://2moons.cc/
	-->
	<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body id="overview" class="full">
<style>
body {
    background:#0F0F3D;
    color:#ffffff;
    font-family:courier;
    font-size:12pt;
    text-align:center;
    margin:100px;
}

blink {
    color:yellow;
}

.neg {
    background:#fff;
    color:#0F0F3D;
    padding:2px 8px;
    font-weight:bold;
}

p {
    margin:30px 100px;
    text-align:left;
}

a,a:hover {
    color:inherit;
    font:inherit;
}

.menu {
    text-align:center;
    margin-top:50px;
}
</style>

<span class="neg">' . $errorType[$errno] . '</span>
<p>Seems something went wrong! Copy paste this error and send via Support Ticket, so we can fix this issue.</p>

		<p class="left">
			<b>Issue: </b>' . $exception->getMessage() . '<br>
			<b>File: </b>' . $exception->getFile() . ' (Line ' . $exception->getLine() . ')<br>
			<b>URL: </b>' . PROTOCOL . HTTP_HOST . $_SERVER['REQUEST_URI'] . '<br>
			<b>PHP: Version </b>' . PHP_VERSION . ' [ ' . php_sapi_name() . ' ]<br>
			<b>MySQL: </b>' . mysqli_get_client_info() . '<br><br>
			<b>Debug Track:</b><br>' . makebr(htmlspecialchars($exception->getTraceAsString())) . '
		</p>

		<div class="menu">
<a href="' . $DIR . '/game.php">Return to Game</a> | 
<a href="' . $DIR . '/game.php?page=ticket">Contact Support Ticket</a> 
</div>

</body>
</html>';
    echo str_replace(array('\\', ROOT_PATH, substr(ROOT_PATH, 0, 15)), array('/', '/', 'FILEPATH '), ob_get_clean());
    $errorText = date("[d-M-Y H:i:s]", TIMESTAMP) . ' ' . $errorType[$errno] . ': "' . strip_tags($exception->getMessage()) . "\"\r\n";
    $errorText .= 'File: ' . $exception->getFile() . ' | Line: ' . $exception->getLine() . "\r\n";
    $errorText .= 'URL: ' . PROTOCOL . HTTP_HOST . $_SERVER['REQUEST_URI'] . ' | Version: ' . $VERSION . "\r\n";
    $errorText .= "Stack trace:\r\n";
    $errorText .= str_replace(ROOT_PATH, '/', htmlspecialchars(str_replace('\\', '/', $exception->getTraceAsString()))) . "\r\n";
    if (is_writable('includes/error.log')) {
        file_put_contents('includes/error.log', $errorText, FILE_APPEND);
    }
}
Exemplo n.º 19
0
//die(print_r($mysqlExists));
$tests['mysqlExists'] = !empty($mysqlExists) && preg_match('/^(mysql is )/i', $mysqlExists[0]) == 1;
//$tests['mysqlExists'] = false;
if ($tests['mysqlExists']) {
    // Get MySQL version
    $mysqlVersion = array();
    @exec('mysql -V', $mysqlVersion);
    //die(print_r($mysqlVersion));
    if (!empty($mysqlVersion)) {
        preg_match('/\\d+\\.\\d+.\\d+/', $mysqlVersion[0], $mysqlVersionNo);
    }
    // Check for PHP MySQLi extension
    $tests['phpMySQLi'] = extension_loaded("mysqli");
    //$tests['phpMySQLi'] = false;
    if ($tests['phpMySQLi']) {
        $mysqlVersionNo = array(mysqli_get_client_info());
        //die(print_r($mysqlVersionNo));
        // Check database connection
        $mysqli = new mysqli(Config::_SERVER, Config::_DB_USER, Config::_DB_PASSWORD, Config::_DATABASE);
        $tests['dbconnect'] = is_null($mysqli->connect_error);
        //$tests['dbconnect'] = false;
        if ($tests['dbconnect']) {
            // Check for "ips" database table
            $tests['ipsTable'] = $mysqli->query("SELECT * FROM " . Config::_DB_IPS_TABLE) !== false;
            //$tests['ipsTable'] = false;
        }
    }
}
// Check for id3v2
$id3v2Location = array();
@exec('type id3v2', $id3v2Location);
Exemplo n.º 20
0
 /**
  * 获得当前的环境信息
  *
  * @return array
  */
 private function _getCurrentEnvironment()
 {
     $lowestEnvironment = $this->_getLowestEnvironment();
     $space = floor(@disk_free_space(FCPATH) / (1024 * 1024));
     $space = $space ? $space . 'M' : 'unknow';
     $currentUpload = ini_get('file_uploads') ? ini_get('upload_max_filesize') : 'unknow';
     $upload_ischeck = intval($currentUpload) >= intval($lowestEnvironment['upload']) ? true : false;
     $space_ischeck = intval($space) >= intval($lowestEnvironment['space']) ? true : false;
     $version_ischeck = version_compare(phpversion(), $lowestEnvironment['version']) < 0 ? false : true;
     $pdo_mysql_ischeck = extension_loaded('pdo_mysql');
     if (function_exists('mysql_get_client_info')) {
         $mysql = mysql_get_client_info();
         $mysql_ischeck = true;
     } elseif (function_exists('mysqli_get_client_info')) {
         $mysql = mysqli_get_client_info();
         $mysql_ischeck = true;
     } elseif ($pdo_mysql_ischeck) {
         $mysql_ischeck = true;
         $mysql = 'unknow';
     } else {
         $mysql_ischeck = false;
         $mysql = 'unknow';
     }
     if (function_exists('gd_info')) {
         $gdinfo = gd_info();
         $gd = $gdinfo['GD Version'];
         $gd_ischeck = version_compare($lowestEnvironment['gd'], $gd) < 0 ? false : true;
     } else {
         $gd_ischeck = false;
         $gd = 'unknow';
     }
     return array('gd' => $gd, 'os' => PHP_OS, 'json' => function_exists('json_encode'), 'space' => $space, 'mysql' => $mysql, 'upload' => $currentUpload, 'version' => phpversion(), 'pdo_mysql' => $pdo_mysql_ischeck, 'gd_ischeck' => $gd_ischeck, 'os_ischeck' => true, 'space_ischeck' => $space_ischeck, 'mysql_ischeck' => $mysql_ischeck, 'version_ischeck' => $version_ischeck, 'upload_ischeck' => $upload_ischeck, 'pdo_mysql_ischeck' => $pdo_mysql_ischeck);
 }
 /**
  * Does the database server claim to have support for UTF-8 Multibyte (utf8mb4) collation?
  *
  * libmysql supports utf8mb4 since 5.5.3 (same version as the MySQL server). mysqlnd supports utf8mb4 since 5.0.9.
  *
  * @return  boolean
  *
  * @since   CMS 3.5.0
  */
 private function serverClaimsUtf8mb4Support()
 {
     $client_version = mysqli_get_client_info();
     $server_version = $this->getVersion();
     if (version_compare($server_version, '5.5.3', '<')) {
         return false;
     } else {
         if (strpos($client_version, 'mysqlnd') !== false) {
             $client_version = preg_replace('/^\\D+([\\d.]+).*/', '$1', $client_version);
             return version_compare($client_version, '5.0.9', '>=');
         } else {
             return version_compare($client_version, '5.5.3', '>=');
         }
     }
 }
Exemplo n.º 22
0
Arquivo: p.php Projeto: php360/ltnmp
    <td width="32%">MySQL 数据库:</td>

    <td width="18%"><?php 
echo isfun("mysql_close");
?>

    <?php 
if (function_exists("mysql_get_server_info")) {
    $s = @mysql_get_server_info();
    $s = $s ? '&nbsp; mysql_server 版本:' . $s : '';
    $c = '&nbsp; mysql_client 版本:' . @mysql_get_client_info();
    echo $s;
} elseif (function_exists("mysqli_get_server_info")) {
    $s = @mysqli_get_server_info();
    $s = $s ? '&nbsp; mysql_server 版本:' . $s : '';
    $c = '&nbsp; mysql_client 版本:' . @mysqli_get_client_info();
    echo $s;
}
?>

	</td>

    <td width="32%">ODBC 数据库:</td>

    <td width="18%"><?php 
echo isfun("odbc_close");
?>
</td>

  </tr>
Exemplo n.º 23
0
 /**
  * returns a string that represents the client library version
  *
  * @return string MySQL client library version
  */
 public function getClientInfo()
 {
     return mysqli_get_client_info();
 }
Exemplo n.º 24
0
 * @license         http://www.gnu.org/licenses/gpl.html
 * @platform        WebsiteBaker 2.8.x
 * @version         0.4.1
 * @lastmodified    August 23, 2016
 *
 */
// Must include code to stop this file being access directly
if (defined('WB_PATH') == false) {
    die("Cannot access this file directly");
}
if (is_object($database->DbHandle)) {
    $title = "MySQLi Info";
    $server_info = mysqli_get_server_info($database->DbHandle);
    $host_info = mysqli_get_host_info($database->DbHandle);
    $proto_info = mysqli_get_proto_info($database->DbHandle);
    $client_info = mysqli_get_client_info($database->DbHandle);
    $client_encoding = mysqli_character_set_name($database->DbHandle);
    $status = explode('  ', mysqli_stat($database->DbHandle));
} else {
    $title = "MySQL Info";
    $server_info = mysql_get_server_info();
    $host_info = mysql_get_host_info();
    $proto_info = mysql_get_proto_info();
    $client_info = mysql_get_client_info();
    $client_encoding = mysql_client_encoding();
    $status = explode('  ', mysql_stat());
}
$strictMode = $database->get_one('SELECT @@sql_mode');
$strict_info = (strpos($strictMode, 'STRICT_TRANS_TABLES') !== false or strpos($strictMode, 'STRICT_ALL_TABLES') !== false) ? "MySQL strict mode active" : "MySQL strict mode not active\n";
?>
<table cellpadding="3" border="0">
Exemplo n.º 25
0
 *
 *
 * @link http://www.subrion.org/
 *
 ******************************************************************************/
define('IA_VER', '402');
$iaOutput->layout()->title = 'Installation Wizard';
$iaOutput->steps = array('check' => 'Pre-Installation Check', 'license' => 'Subrion License', 'configuration' => 'Configuration', 'finish' => 'Script Installation', 'plugins' => 'Plugins Installation');
$error = false;
$message = '';
$builtinPlugins = array('kcaptcha', 'fancybox', 'personal_blog', 'elfinder');
switch ($step) {
    case 'check':
        $checks = array('server' => array());
        $sections = array('server' => array('title' => 'Server Configuration', 'desc' => 'If any of these items are highlighted in red then please take actions to correct them. Failure to do so could lead to your installation not functioning correctly.'), 'recommended' => array('title' => 'Recommended Settings', 'desc' => 'These settings are recommended for PHP in order to ensure full compatibility with Subrion CMS. However, Subrion CMS will still operate if your settings do not quite match the recommended.'), 'directory' => array('title' => 'Directory &amp; File Permissions', 'desc' => 'In order for Subrion CMS to function correctly it needs to be able to access or write to certain files or directories. If you see "Unwritable" you need to change the permissions on the file or directory to allow Subrion CMS to write to it.'));
        $checks['server']['mysql_version'] = array('required' => function_exists('mysqli_connect'), 'class' => true, 'name' => 'Mysql version', 'value' => function_exists('mysqli_connect') ? '<td class="success">' . substr(mysqli_get_client_info(), 0, false === ($pos = strpos(mysqli_get_client_info(), '-')) ? 10 : $pos) . '</td>' : '<td class="danger">MySQL 5.x or upper required</td>');
        $checks['server']['php_version'] = array('required' => version_compare('5.0', PHP_VERSION, '<'), 'class' => true, 'name' => 'PHP version', 'value' => version_compare('5.0', PHP_VERSION, '<') ? '<td class="success">' . PHP_VERSION . '</td>' : '<td class="danger">PHP version is not compatible. PHP 5.x needed. (Current version ' . PHP_VERSION . ')</td>');
        $checks['server']['remote'] = array('name' => 'Remote files access support', 'value' => iaHelper::hasAccessToRemote() ? '<td class="success">Available</td>' : '<td class="danger">Unavailable (highly recommended to enable "CURL" extension or "allow_url_fopen")</td>');
        $checks['server']['xml'] = array('name' => 'XML support', 'value' => extension_loaded('xml') ? '<td class="success">Available</td>' : '<td class="danger">Unavailable (recommended)</td>');
        $checks['server']['mysql_support'] = array('name' => 'MySQL support (MySQLi)', 'value' => function_exists('mysqli_connect') ? '<td class="success">Available</td>' : '<td class="danger">Unavailable (required)</td>');
        $checks['server']['gd'] = array('name' => 'GD extension', 'value' => extension_loaded('gd') ? '<td class="success">Available</td>' : '<td class="danger">Unavailable (highly recommended)</td>');
        $checks['server']['mbstring'] = array('name' => 'Mbstring extension', 'value' => extension_loaded('mbstring') ? '<td class="success">Available</td>' : '<td class="danger">Unavailable (not required) </td>');
        $recommendedSettings = array(array('File Uploads', 'file_uploads', 'ON'), array('Magic Quotes GPC', 'magic_quotes_gpc', 'OFF'), array('Register Globals', 'register_globals', 'OFF'));
        foreach ($recommendedSettings as $item) {
            $checks['recommended'][$item[1]] = array('name' => $item[0] . ':</td><td>' . $item[2] . '', 'value' => (iaHelper::getIniSetting($item[1]) == $item[2] ? '<td class="success">' : '<td class="danger">') . iaHelper::getIniSetting($item[1]) . '</td>');
        }
        $directory = array(array('tmp' . IA_DS, '', true), array('uploads' . IA_DS, '', true), array('backup' . IA_DS, ' (optional)', false), array('plugins' . IA_DS, ' (optional)', false), array('includes' . IA_DS . 'config.inc.php', ' (optional)', false));
        foreach ($directory as $item) {
            $text = '';
            $isWritable = false;
            if (file_exists(IA_HOME . $item[0])) {
Exemplo n.º 26
0
 /**
  *	Return version of database client driver
  *
  *	@return	        string      Version string
  */
 function getDriverInfo()
 {
     return mysqli_get_client_info($this->db);
 }
Exemplo n.º 27
0
 /**
  * @return string
  * @throws Exception
  */
 protected function getMySQLClientVersion()
 {
     if (extension_loaded("mysql")) {
         return mysql_get_client_info();
     }
     if (extension_loaded("mysqli")) {
         return mysqli_get_client_info();
     }
     throw new Exception('PHP extension "mysqli" is required!');
 }
Exemplo n.º 28
0
    } else {
        echo '
		<p class="box background-pomegranate color-clouds">Phoenix is unable to run. Your PHP version is < 5.0</td>
		<p class="color-asbestos">PHP Version: ' . $php_version . '</p>';
        $php_compat = false;
    }
}
// No MySQL
if (!class_exists('mysqli')) {
    echo '
		<p class="box background-pomegranate color-clouds">Your server does not support MySQL.</td>';
    $mysql_compat = false;
    // Yes MySQL
} else {
    // Version
    $mysql_version = mysqli_get_client_info();
    $mysql_version = trim(substr($mysql_version, 0, strpos($mysql_version, '-')), 'mysqlnd ');
    echo '
		<p class="box background-green-sea color-clouds">Your server supports MySQL.</td>
		<p class="color-asbestos">MySQL Version: ' . $mysql_version . '</p>';
    $mysql_compat = true;
    // Tables Exist
    $tables = array('peers', 'tasks', 'torrents');
    $actual = 0;
    foreach ($tables as $table) {
        $sql = 'SELECT TABLE_NAME ' . 'FROM `information_schema`.`TABLES` ' . 'WHERE TABLE_SCHEMA = \'' . $settings['db_name'] . '\' ' . 'AND TABLE_NAME = \'' . $settings['db_prefix'] . $table . '\';';
        $result = mysqli_query($connection, $sql);
        $count = mysqli_num_rows($result);
        if (!$count) {
            echo '
		<p class="box background-pomegranate color-clouds">The table "' . $table . '" is not installed.</td>';
Exemplo n.º 29
0
 /**
  * Determine if a database supports a particular feature.
  *
  * @since 2.7.0
  * @since 4.1.0 Support was added for the 'utf8mb4' feature.
  *
  * @see wpdb::db_version()
  *
  * @param string $db_cap The feature to check for. Accepts 'collation',
  *                       'group_concat', 'subqueries', 'set_charset',
  *                       or 'utf8mb4'.
  * @return int|false Whether the database feature is supported, false otherwise.
  */
 public function has_cap($db_cap)
 {
     $version = $this->db_version();
     switch (strtolower($db_cap)) {
         case 'collation':
             // @since 2.5.0
         // @since 2.5.0
         case 'group_concat':
             // @since 2.7.0
         // @since 2.7.0
         case 'subqueries':
             // @since 2.7.0
             return version_compare($version, '4.1', '>=');
         case 'set_charset':
             return version_compare($version, '5.0.7', '>=');
         case 'utf8mb4':
             // @since 4.1.0
             if (version_compare($version, '5.5.3', '<')) {
                 return false;
             }
             if ($this->use_mysqli) {
                 $client_version = mysqli_get_client_info();
             } else {
                 $client_version = mysql_get_client_info();
             }
             /*
              * libmysql has supported utf8mb4 since 5.5.3, same as the MySQL server.
              * mysqlnd has supported utf8mb4 since 5.0.9.
              */
             if (false !== strpos($client_version, 'mysqlnd')) {
                 $client_version = preg_replace('/^\\D+([\\d.]+).*/', '$1', $client_version);
                 return version_compare($client_version, '5.0.9', '>=');
             } else {
                 return version_compare($client_version, '5.5.3', '>=');
             }
     }
     return false;
 }
Exemplo n.º 30
0
 /**
  * Connexion à la base de données
  * 
  * @param array $infos    Informations de connexion
  * @param array $options  Options de connexion/utilisation
  * 
  * @access public
  * @return boolean
  */
 function connect($infos = null, $options = null)
 {
     if (is_array($infos)) {
         foreach (array('host', 'username', 'passwd', 'port') as $info) {
             ${$info} = isset($infos[$info]) ? $infos[$info] : null;
         }
     }
     $connect = 'mysqli_connect';
     if (is_array($options)) {
         $this->options = array_merge($this->options, $options);
     }
     if (!($this->link = $connect($host, $username, $passwd, $this->dbname, $port))) {
         $this->errno = mysqli_connect_errno();
         $this->error = mysqli_connect_error();
         $this->link = null;
     } else {
         $this->serverVersion = mysqli_get_server_info($this->link);
         $this->clientVersion = mysqli_get_client_info();
         if (!empty($this->options['charset'])) {
             $this->encoding($this->options['charset']);
         }
     }
 }