1--TEST-- 2ensure an error is returned when mysqli.allow_local_infile is off 3--SKIPIF-- 4<?php 5require_once('skipif.inc'); 6require_once('skipifconnectfailure.inc'); 7 8$link = mysqli_init(); 9if (!my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)) { 10 die(sprintf("skip Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error())); 11} 12 13require_once('local_infile_tools.inc'); 14if ($msg = check_local_infile_support($link, $engine)) 15 die(sprintf("skip %s, [%d] %s", $msg, $link->errno, $link->error)); 16 17?> 18--INI-- 19mysqli.allow_local_infile=0 20--FILE-- 21<?php 22 require_once("connect.inc"); 23 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) { 24 printf("[001] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); 25 } 26 if (!$link->query("DROP TABLE IF EXISTS test")) { 27 printf("[002] [%d] %s\n", $link->errno, $link->error); 28 } 29 if (!$link->query("CREATE TABLE test (dump1 INT UNSIGNED NOT NULL PRIMARY KEY) ENGINE=" . $engine)) { 30 printf("[003] [%d] %s\n", $link->errno, $link->error); 31 } 32 if (FALSE == file_put_contents('bug77956.data', "waa? meukee!")) 33 printf("[004] Failed to create CVS file\n"); 34 if (!$link->query("SELECT 1 FROM DUAL")) 35 printf("[005] [%d] %s\n", $link->errno, $link->error); 36 if (!$link->query("LOAD DATA LOCAL INFILE 'bug77956.data' INTO TABLE test")) { 37 printf("[006] [%d] %s\n", $link->errno, $link->error); 38 echo "done"; 39 } else { 40 echo "bug"; 41 } 42 $link->close(); 43?> 44--CLEAN-- 45<?php 46require_once('connect.inc'); 47if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) { 48 printf("[clean] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", 49 $host, $user, $db, $port, $socket); 50} 51if (!$link->query($link, 'DROP TABLE IF EXISTS test')) { 52 printf("[clean] Failed to drop old test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 53} 54$link->close(); 55unlink('bug77956.data'); 56?> 57--EXPECTF-- 58Warning: mysqli::query(): LOAD DATA LOCAL INFILE forbidden in %s on line %d 59[006] [2000] LOAD DATA LOCAL INFILE is forbidden, check mysqli.allow_local_infile 60done 61