473,378 Members | 1,623 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Windows to Unix text doc parsing problem

Hi all,

i have been having trouble with a login script that works on my
windows machine, however when i upload it to the Unix server through
VPN, the same script won't work! It won't parse member.txt properly i
think. The password and usernames i am using are at the bottom of this
post.
Each time i go to login on the unix server, it clears the username and
password field. I have been attempting to solve the problem, but have
been baffled to see why there is such an issue. I have taken out the
HTML, and just given you the PHP script that i am running. The
original programming was done on Unix!.

My question to people on here is why does my script run on Windows and
not on Unix? How can i fix the problem?

Here is the source code i have been looking at:
\-------------------------------------------------------------------------------------------------------------------------------------------------------------------
<?
session_start();

if ($userid && $password)

{
//listf stores a reference to the file itself
$listf=fopen("username/member.txt","r");

#read the file
list($duserid,$dpassword)=fgetcsv($listf,1024,"|") ;

$duserid=trim($duserid);
$dpassword=trim($dpassword);

//keep reading until the end of the file is reached
while(!feof($listf)){

if(($userid==$duserid)&&($password==$dpassword))
{
$_SESSION['valid_user']=$userid;
break;
}
list($duserid,$dpassword)=fgetcsv($listf,1024,"|") ;
$duserid=trim($duserid);
$dpassword=trim($dpassword);
}
fclose($listf);
}

?>
------HTML-------
<?
$tempstr=$_SESSION['valid_user'];

if (isset($_SESSION['valid_user'])){
echo "You are logged in as: $tempstr<br>";
echo "<a href=\"admin_home.php\">Admin Home</a><br>";
}
else{
if (isset($userid)) {
// if they've tried and failed to log in
echo "Could not log you in";
}
else{
// they have not tried to log in yet or have logged out
echo "<table border=0 width=\"600\" cellspacing=0 cellpadding=0
border=0 valign=\"top\" align=\"center\">";
echo "<tr><td>You are not logged in.<br></td>";
echo "</table>";
}
// provide form to log in
echo "<form method=post action=\"login.php\">";
echo "<table border=0 width=\"600\" cellspacing=0 cellpadding=0
border=0 valign=\"top\" align=\"center\">";
echo "<tr><td>Userid:</td>";
echo "<td><input type=text name=userid></td></tr>";
echo "<tr><td>Password:</td>";
echo "<td><input type=password name=password></td></tr>";
echo "<tr><td colspan=2 align=right>";
echo "<input type=submit value=\"Log in\">";
//echo "<tr><td colspan=1 align=center>";
echo "<input type=reset value=\"Reset\"></td></tr>";
echo "</table></form>";
}
?>
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
Here is the Windows copy of the member.txt that only works with ASCII
block terminator at the end of the file:
------------------------------------------------------------------------------------------------------------------------------------------------------------------
ad********************************@utas.edu.au|Uni versity of Tasmania|
1
bh**********************************@utas.edu.au|C omputing|2
--------------------------------------------------------------------------------------------------------------------------------------------------------------------

Cheers,

Peri.

Apr 5 '07 #1
7 2047
programming wrote:
Hi all,

i have been having trouble with a login script that works on my
windows machine, however when i upload it to the Unix server through
VPN, the same script won't work! It won't parse member.txt properly i
think. The password and usernames i am using are at the bottom of this
post.
Each time i go to login on the unix server, it clears the username and
password field. I have been attempting to solve the problem, but have
been baffled to see why there is such an issue. I have taken out the
HTML, and just given you the PHP script that i am running. The
original programming was done on Unix!.

My question to people on here is why does my script run on Windows and
not on Unix? How can i fix the problem?

Here is the source code i have been looking at:
\-------------------------------------------------------------------------------------------------------------------------------------------------------------------
<?
session_start();

if ($userid && $password)

{
//listf stores a reference to the file itself
$listf=fopen("username/member.txt","r");

#read the file
list($duserid,$dpassword)=fgetcsv($listf,1024,"|") ;

$duserid=trim($duserid);
$dpassword=trim($dpassword);

//keep reading until the end of the file is reached
while(!feof($listf)){

if(($userid==$duserid)&&($password==$dpassword))
{
$_SESSION['valid_user']=$userid;
break;
}
list($duserid,$dpassword)=fgetcsv($listf,1024,"|") ;
$duserid=trim($duserid);
$dpassword=trim($dpassword);
}
fclose($listf);
}

?>
------HTML-------
<?
$tempstr=$_SESSION['valid_user'];

if (isset($_SESSION['valid_user'])){
echo "You are logged in as: $tempstr<br>";
echo "<a href=\"admin_home.php\">Admin Home</a><br>";
}
else{
if (isset($userid)) {
// if they've tried and failed to log in
echo "Could not log you in";
}
else{
// they have not tried to log in yet or have logged out
echo "<table border=0 width=\"600\" cellspacing=0 cellpadding=0
border=0 valign=\"top\" align=\"center\">";
echo "<tr><td>You are not logged in.<br></td>";
echo "</table>";
}
// provide form to log in
echo "<form method=post action=\"login.php\">";
echo "<table border=0 width=\"600\" cellspacing=0 cellpadding=0
border=0 valign=\"top\" align=\"center\">";
echo "<tr><td>Userid:</td>";
echo "<td><input type=text name=userid></td></tr>";
echo "<tr><td>Password:</td>";
echo "<td><input type=password name=password></td></tr>";
echo "<tr><td colspan=2 align=right>";
echo "<input type=submit value=\"Log in\">";
//echo "<tr><td colspan=1 align=center>";
echo "<input type=reset value=\"Reset\"></td></tr>";
echo "</table></form>";
}
?>
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
Here is the Windows copy of the member.txt that only works with ASCII
block terminator at the end of the file:
------------------------------------------------------------------------------------------------------------------------------------------------------------------
ad********************************@utas.edu.au|Uni versity of Tasmania|
1
bh**********************************@utas.edu.au|C omputing|2
--------------------------------------------------------------------------------------------------------------------------------------------------------------------

Cheers,

Peri.
Peri,

You have register_globals enabled on your Windows machine (VERY BAD) and
disabled on your Unix machine (VERY GOOD).

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Apr 5 '07 #2
On Apr 5, 1:46 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
programming wrote:
Hi all,
i have been having trouble with a login script that works on my
windows machine, however when i upload it to the Unix server through
VPN, the same script won't work! It won't parse member.txt properly i
think. The password and usernames i am using are at the bottom of this
post.
Each time i go to login on the unix server, it clears the username and
password field. I have been attempting to solve the problem, but have
been baffled to see why there is such an issue. I have taken out the
HTML, and just given you the PHP script that i am running. The
original programming was done on Unix!.
My question to people on here is why does my script run on Windows and
not on Unix? How can i fix the problem?
Here is the source code i have been looking at:
\-------------------------------------------------------------------------------------------------------------------------------------------------------------------
<?
session_start();
if ($userid && $password)
{
//listf stores a reference to the file itself
$listf=fopen("username/member.txt","r");
#read the file
list($duserid,$dpassword)=fgetcsv($listf,1024,"|") ;
$duserid=trim($duserid);
$dpassword=trim($dpassword);
//keep reading until the end of the file is reached
while(!feof($listf)){
if(($userid==$duserid)&&($password==$dpassword))
{
$_SESSION['valid_user']=$userid;
break;
}
list($duserid,$dpassword)=fgetcsv($listf,1024,"|") ;
$duserid=trim($duserid);
$dpassword=trim($dpassword);
}
fclose($listf);
}
?>
------HTML-------
<?
$tempstr=$_SESSION['valid_user'];
if (isset($_SESSION['valid_user'])){
echo "You are logged in as: $tempstr<br>";
echo "<a href=\"admin_home.php\">Admin Home</a><br>";
}
else{
if (isset($userid)) {
// if they've tried and failed to log in
echo "Could not log you in";
}
else{
// they have not tried to log in yet or have logged out
echo "<table border=0 width=\"600\" cellspacing=0 cellpadding=0
border=0 valign=\"top\" align=\"center\">";
echo "<tr><td>You are not logged in.<br></td>";
echo "</table>";
}
// provide form to log in
echo "<form method=post action=\"login.php\">";
echo "<table border=0 width=\"600\" cellspacing=0 cellpadding=0
border=0 valign=\"top\" align=\"center\">";
echo "<tr><td>Userid:</td>";
echo "<td><input type=text name=userid></td></tr>";
echo "<tr><td>Password:</td>";
echo "<td><input type=password name=password></td></tr>";
echo "<tr><td colspan=2 align=right>";
echo "<input type=submit value=\"Log in\">";
//echo "<tr><td colspan=1 align=center>";
echo "<input type=reset value=\"Reset\"></td></tr>";
echo "</table></form>";
}
?>
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
Here is the Windows copy of the member.txt that only works with ASCII
block terminator at the end of the file:
------------------------------------------------------------------------------------------------------------------------------------------------------------------
admin|1234|School|Computing|bhk...@utas.edu.au|Uni versity of Tasmania|
1
bhkang|abcd1234|Kang|ByeongHo|bhk...@utas.edu.au|C omputing|2
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
Cheers,
Peri.

Peri,

You have register_globals enabled on your Windows machine (VERY BAD) and
disabled on your Unix machine (VERY GOOD).

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================
Ok Jerry thanks for the advice, it is strange that most of the code i
have adapted here comes from some tutorial work i have been doing, and
that
it suppose to be tested initially on the Unix server. So, you are
telling me that the problem is not in the program reading the text
file, but a security
problem that exists within the script and the PHP ini file has been
set to off with register globals....

Apr 5 '07 #3
programming wrote:
On Apr 5, 1:46 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
>programming wrote:
>>Hi all,
i have been having trouble with a login script that works on my
windows machine, however when i upload it to the Unix server through
VPN, the same script won't work! It won't parse member.txt properly i
think. The password and usernames i am using are at the bottom of this
post.
Each time i go to login on the unix server, it clears the username and
password field. I have been attempting to solve the problem, but have
been baffled to see why there is such an issue. I have taken out the
HTML, and just given you the PHP script that i am running. The
original programming was done on Unix!.
My question to people on here is why does my script run on Windows and
not on Unix? How can i fix the problem?
Here is the source code i have been looking at:
\-------------------------------------------------------------------------------------------------------------------------------------------------------------------
<?
session_start();
if ($userid && $password)
{
//listf stores a reference to the file itself
$listf=fopen("username/member.txt","r");
#read the file
list($duserid,$dpassword)=fgetcsv($listf,1024,"| ");
$duserid=trim($duserid);
$dpassword=trim($dpassword);
//keep reading until the end of the file is reached
while(!feof($listf)){
if(($userid==$duserid)&&($password==$dpassword))
{
$_SESSION['valid_user']=$userid;
break;
}
list($duserid,$dpassword)=fgetcsv($listf,1024,"|") ;
$duserid=trim($duserid);
$dpassword=trim($dpassword);
}
fclose($listf);
}
?>
------HTML-------
<?
$tempstr=$_SESSION['valid_user'];
if (isset($_SESSION['valid_user'])){
echo "You are logged in as: $tempstr<br>";
echo "<a href=\"admin_home.php\">Admin Home</a><br>";
}
else{
if (isset($userid)) {
// if they've tried and failed to log in
echo "Could not log you in";
}
else{
// they have not tried to log in yet or have logged out
echo "<table border=0 width=\"600\" cellspacing=0 cellpadding=0
border=0 valign=\"top\" align=\"center\">";
echo "<tr><td>You are not logged in.<br></td>";
echo "</table>";
}
// provide form to log in
echo "<form method=post action=\"login.php\">";
echo "<table border=0 width=\"600\" cellspacing=0 cellpadding=0
border=0 valign=\"top\" align=\"center\">";
echo "<tr><td>Userid:</td>";
echo "<td><input type=text name=userid></td></tr>";
echo "<tr><td>Password:</td>";
echo "<td><input type=password name=password></td></tr>";
echo "<tr><td colspan=2 align=right>";
echo "<input type=submit value=\"Log in\">";
//echo "<tr><td colspan=1 align=center>";
echo "<input type=reset value=\"Reset\"></td></tr>";
echo "</table></form>";
}
?>
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
Here is the Windows copy of the member.txt that only works with ASCII
block terminator at the end of the file:
------------------------------------------------------------------------------------------------------------------------------------------------------------------
admin|1234|School|Computing|bhk...@utas.edu.au|U niversity of Tasmania|
1
bhkang|abcd1234|Kang|ByeongHo|bhk...@utas.edu.au |Computing|2
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
Cheers,
Peri.
Peri,

You have register_globals enabled on your Windows machine (VERY BAD) and
disabled on your Unix machine (VERY GOOD).

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================

Ok Jerry thanks for the advice, it is strange that most of the code i
have adapted here comes from some tutorial work i have been doing, and
that
it suppose to be tested initially on the Unix server. So, you are
telling me that the problem is not in the program reading the text
file, but a security
problem that exists within the script and the PHP ini file has been
set to off with register globals....
Yep. But it has nothing to do with Unix vs. Windows. register_globals
used to default to on (in fact in early releases of PHP you didn't have
a choice). More recent versions default to off, and it's the best way
to have it.

And there are a lot of bad PHP tutorials on the web - more than any
other language I've seen. Seems anyone with 2 weeks of PHP experience
(and no prior programming) considers them selves "expert" enough to
write tutorials.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Apr 5 '07 #4
programming schreef:
i have been having trouble
<?
While debugging it can be helpfull to start your script with the
following (or make sure your php configuration has the same settings)

ini_set('display_errors', true);
ini_set('error_reporting', E_ALL);
if ($userid && $password)
As already mentionned, $userid and $password are probably undefined at
this point, and you should test if $_POST['userid'] and
$_POST['password'] exist...
$listf=fopen("username/member.txt","r");
Since you're using a relative path, you may want to check your
include_path setting too...
--
Tim Van Wassenhove <url:http://www.timvw.be/>
Apr 6 '07 #5
On Apr 6, 7:40 pm, Tim Van Wassenhove <t...@users.sourceforge.net>
wrote:
<snip>
While debugging it can be helpfull to start your script with the
following (or make sure your php configuration has the same settings)

ini_set('display_errors', true);
ini_set('error_reporting', E_ALL);
<snip>

Back to PHP again?

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

Apr 6 '07 #6
R. Rajesh Jeba Anbiah schreef:
Back to PHP again?
Never left ;)

(Just a bit busy looking at the 'others' (mainly asp.net) how they do
webdevelopment ;)
--
Tim Van Wassenhove <url:http://www.timvw.be/>
Apr 7 '07 #7
On Apr 7, 12:33 pm, Tim Van Wassenhove <t...@users.sourceforge.net>
wrote:
R.RajeshJebaAnbiahschreef:
Back to PHP again?

Never left ;)

(Just a bit busy looking at the 'others' (mainly asp.net) how they do
webdevelopment ;)
Nice to know:) Apologies for the late response. I'm too busy
lurking CakePHP:)

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

Apr 13 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Michael Appelmans | last post by:
I'm a php novice and am developing a shopping cart application for a client who is hosted on a unix server. The hosting service requires that each php file have #!/usr/local/bin/php at the top....
2
by: Ken Lindner | last post by:
I have a need to become familiar with SQL Server 2000 for work. Needless to say I am new to SQL Server any version, but not IT in general. My employer has provided me with the SQL Server 2000...
383
by: John Bailo | last post by:
The war of the OSes was won a long time ago. Unix has always been, and will continue to be, the Server OS in the form of Linux. Microsoft struggled mightily to win that battle -- creating a...
1
by: wtnt | last post by:
Hello. I've searched all over and haven't seen another thread with this problem. Please bear with me as I try to explain. thanks. :) I have some programs that need to be cross-platform...
3
by: Chris Paul | last post by:
I'm having trouble with PHP & PostgreSQL/OpenLDAP/Apache on Windows. I've set this up countless times on BSD (piece of cake) but I'm trying to do this on Windows now so that my developer can work...
2
by: Trevor | last post by:
Argh! This problem is driving me nuts! Can you help? In November of 2003, I installed a web service on Windows Server 2003 built in VB.NET for v1.1.4322 of the framework. It contains a timer...
2
by: frikk | last post by:
Hey everyone, (Sorry about the first message if it made it - i got cut off early). I have a homework problem for my Operating Systems class. I am supposed to use a command such as "ps -aux" and...
5
by: e_matthes | last post by:
Hello, I have a function which uses a regular expression to validate text input. Here's a short code sample testing the regex: <?php $dirty = "hello"; $clean = getCleanText($dirty, 0,50);...
1
by: RolfK | last post by:
Hello Experts, I have a small problem with copy of CDATA sections. (I'm using XSLT2.0 ) My output target is defined as txt. In my xml source is a CDATA section to be put as it is into the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.