--TEST-- mysqli_real_connect() --SKIPIF-- --INI-- mysqli.allow_local_infile=1 --FILE-- num_rows); mysqli_next_result($link); $res = mysqli_store_result($link); var_dump($res->num_rows); } mysqli_close($link); if (!$link = mysqli_init()) printf("[018] mysqli_init() failed\n"); if (ini_get('open_basedir')) { // CLIENT_LOCAL_FILES should be blocked - but how to test it ?! if (!mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, 128)) printf("[019] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $filename = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'mysqli_real_connect_phpt'; if (!$fp = fopen($filename, 'w')) printf("[020] Cannot open temporary file %s\n", $filename); fwrite($fp, '100;z'); fclose($fp); // how do we test if gets forbidden because of a missing right or the flag, this test is partly bogus ? if (mysqli_query($link, "LOAD DATA LOCAL INFILE '$filename' INTO TABLE test FIELDS TERMINATED BY ';'")) printf("[021] LOAD DATA INFILE should have been forbidden!\n"); unlink($filename); } mysqli_close($link); @var_dump($link); if ($IS_MYSQLND) { ini_set('mysqli.default_host', 'p:' . $host); $link = mysqli_init(); if (!@mysqli_real_connect($link)) { printf("[022] Usage of mysqli.default_host=p:%s (persistent) failed\n", $host) ; } else { if (!$res = mysqli_query($link, "SELECT 'mysqli.default_host (persistent)' AS 'testing'")) printf("[023] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_fetch_assoc($res); if ($tmp['testing'] !== 'mysqli.default_host (persistent)') { printf("[024] Result looks strange - check manually, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); var_dump($tmp); } mysqli_free_result($res); mysqli_close($link); } ini_set('mysqli.default_host', 'p:'); $link = mysqli_init(); if (@mysqli_real_connect($link)) { printf("[025] Usage of mysqli.default_host=p: did not fail\n") ; mysqli_close($link); } @mysqli_close($link); } if (NULL !== ($tmp = mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket))) printf("[026] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --CLEAN-- --EXPECTF-- Warning: mysqli_real_connect(): (%s/%d): Access denied for user '%s'@'%s' (using password: YES) in %s on line %d object(mysqli)#%d (%d) { ["affected_rows"]=> NULL ["client_info"]=> %s ["client_version"]=> int(%d) ["connect_errno"]=> int(%d) ["connect_error"]=> NULL ["errno"]=> %s ["error"]=> %s ["error_list"]=> NULL ["field_count"]=> NULL ["host_info"]=> NULL ["info"]=> NULL ["insert_id"]=> NULL ["server_info"]=> NULL ["server_version"]=> NULL ["stat"]=> NULL ["sqlstate"]=> NULL ["protocol_version"]=> NULL ["thread_id"]=> NULL ["warning_count"]=> NULL } Warning: mysqli_real_connect(): Couldn't fetch mysqli in %s on line %d done!