php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #1418 REQUIRE function is outputting a byte into stream.
Submitted: 1999-05-16 07:41 UTC Modified: 1999-05-18 22:08 UTC
From: rod at 23net dot net Assigned: ssb (profile)
Status: Closed Package: Misbehaving function
PHP Version: 3.0.7 OS: UNIX
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: rod at 23net dot net
New email:
PHP Version: OS:

 

 [1999-05-16 07:41 UTC] rod at 23net dot net
Compilation definitions: MYSQL_INCLUDE=-I/usr/local/mysql/include
MYSQL_LFLAGS=-Wl,-rpath,/usr/local/mysql/lib -L/usr/local/mysql/lib
MYSQL_LIBS=-lmysqlclient 

APACHE_INCLUDE=-I../apache_1.3.6/src/include -I../apache_1.3.6/src/os/unix
APACHE_TARGET=../apache_1.3.6/src/modules/php3
Apache Version: Apache/1.3.6
Apache Release: 10306100
Apache API Version: 19990320
Hostname/port: 23net.net:80
User/Group: www(502)/502
Max Requests: per child: 100    keep alive: on    max per connection: 100
Timeouts: connection: 300    keep-alive: 15
Server Root: /etc/httpd
Loaded modules: mod_php3, mod_frontpage, mod_setenvif, mod_auth, mod_access, mod_alias, mod_userdir, mod_actions, mod_imap, mod_asis, mod_cgi, mod_dir, mod_autoindex, mod_include, mod_status, mod_negotiation, mod_mime, mod_log_config, mod_env, http_core

I use a script on each page to verify sessions.  It verifies the length of time since last activity and that the remote address has not changed.  If either condition is not met the user must relogin.  The start of the script is:

<?
	/*
	header.inc
	*/
header("Expires: Mon, 26 Jul 1998 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H;i:s") . "GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
Require ("includes/verifylogin.inc");
Require ("includes/dbfunctions.inc");
$db="xxxxx";
$linkid=OpenCnct();
SelectDB($linkid,$db);
VerifyUser($p,$db);
PRINT "<HTML><HEAD><TITLE>$pagename</TITLE></HEAD>";

The problem is that the "VerifyUser" function wouldn't execute a header contained within the function.  When I called the page thru Netscape it would inform me that the content length was 1.  (the byte was not a visible character.  In an attempt to find out where the offending byte was coming from I placed exit; in various locations in the script.  An exit; at any point prior to "Require ("includes/dbfunctions.inc")" resulted in "Document contains no data."  An exit; after that line gave me the 1 byte.  I placed exits inside the required file and always got "Document contains no data" including an exit before the closing "?>" in the file.  I changed the REQUIRE to INCLUDE and the script functioned correctly.  Somehow the REQUIRE function itself was adding the byte!

If you'd like to see more info on my configuration I have PHPINFO() set up at http://www.23net.net/test3.php3   

I do not have access to the php3.ini file on my host.

This is a copy of the dbfunctions.inc file:

<?
	/*
	dbfunctions.inc
	*/

function OpenDB($host="localhost",$name="xxx",$pw="xxx"){
	$linkid=mysql_pconnect($host,$name,$pw);
	return $linkid;
}

function SelectDB($linkid,$db="xxx"){
	$result=mysql_select_db($db,$linkid);
}

function VerifyUser($p,$db){
	$result=mysql_db_query($db,"Select lastaddr,lastused from users where uid=$p");
	$numrows=mysql_num_rows($result);
	}

	list($lastaddr,$lastused)=mysql_fetch_row($result);
	$remoteaddr=GETENV(REMOTE_ADDR);
	IF ($remoteaddr!=$lastaddr){
		$ref=getenv(SCRIPT_NAME);
		header("Location: https://server9000.net/23net/signin.php3?err=4&ref=$ref");
		exit;
	}
	$result=mysql_db_query($db,"Select NOW()+0");
	$now=mysql_fetch_row($result);
	IF ($now[0]>$lastused+1000){
		$ref=getenv(SCRIPT_NAME);
		header("Location: https://server9000.net/23net/signin.php3?err=4&ref=$ref");
		exit;
	}
	$result=mysql_db_query($db,"update users set lastused=null where uid=$p");
	
}

function GetUserName($p,$db){
	$result=mysql_db_query($db,"select uname from users where uid=$p");
	$user=mysql_fetch_row($result);
	return $user[0];
}
?>


Rod Kreisler

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1999-05-16 09:59 UTC] ssb at cvs dot php dot net
Are you 100% sure that none of your included files have
an extra newline at the end?
 [1999-05-18 22:08 UTC] rasmus at cvs dot php dot net
This was confirmed to be some stray whitespace
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue May 21 23:01:31 2024 UTC