Go4Expert Member
1Dec2006,14:54   #21
ted_chou12's Avatar
can you write an eg. and send the file to me with zip?
Go4Expert Member
1Dec2006,15:17   #22
ted_chou12's Avatar
i just want a simple example. With the username and age in the text file and the codes that you have to include in the php page, thanks so much.
Go4Expert Member
2Dec2006,22:36   #23
ted_chou12's Avatar
spiderman, you not there...? HELP ASAP
Team Leader
3Dec2006,01:08   #24
pradeep's Avatar
Try this out, hope you got the point!

Code: PHP
<?
/*
**  Our text file's format is values separated by #
**  And example entry would look like this
**  pradeep#myPassword#Kolkata
*/


$TEXT_FILE = 'data.txt';
$aData = @file($TEXT_FILE); // collect all data into an array

// Dummy data
$user = 'pradeep';
$pwd = 'g4e';

foreach($aData as $v)
{
    list($u,$p,$c) = explode("#",$v); // split up the differnt parts of the data

    if($u == $user && $p == $pwd)
    {
        print "Matched";
        break;
    }
}

?>

Sample text file:
Code:
pradeep#g4e#Kolkata
shabbir#G4E#Kolkata
manindar#ABC#Mumbai
Go4Expert Member
3Dec2006,01:54   #25
ted_chou12's Avatar
hey, thanks a lot. it finally worked
Go4Expert Member
3Dec2006,21:37   #26
ted_chou12's Avatar
hi, again.
As i got this to work, things got more complicated, here
PHP Code:
<?php
$bData 
= @file("../admin/log_files/members_list.txt"); 
foreach(
$bData as $w){list($username1,$username2,$username3) = explode(":",$w);
$aData = @file("../admin/log_files/members_list.txt"); // collect all data into an array
foreach($aData as $v){list($username,$email,$time) = explode(":",$v); // split up the differnt parts of the data?
echo "<table><tr><td><font face=\"arial\" size=5><b>Last Modification:</b></td><td>$username</td></tr></font>";
echo 
"<tr><td><font face=\"arial\" size=5><b>Name:</b></td><td>$email</td></tr></font>";
echo 
"<tr><td><font face=\"arial\" size=5><b>Gender:</b></td><td>$time</td></tr></font></table>";}}
?>
Now I have two layers, I separated each username with # and the user data with :, and i want to ask if the "$username1,$username2,$username3..." part streches to infinity, what shall i put in?
Team Leader
4Dec2006,10:14   #27
pradeep's Avatar
Code: PHP
<?
// Simple just do this
$aUserList = explode("#",$v);
// This returns an array
?>
Go4Expert Member
4Dec2006,14:50   #28
ted_chou12's Avatar
oh, so you dont separte the data?
Go4Expert Member
4Dec2006,15:01   #29
ted_chou12's Avatar
Can you give me another example please?
I cant get it to work
ps. please do include the txt file as well, a big "pre"thanks!
Newbie Member
5Dec2006,12:51   #30
cyberience's Avatar
Good script, got a question though, if we have multiple servers with various configurations in load balancing, and we try to maintain a session, that session will be lost when either round robin on next connection is in effect, so sessions is not an option due to persistence issues, and we don't want to enable persistence through the firewall, as it is not under our control. so we would need to rely on the cookie credentials for every page call to validate the user log in!
also, due to distributed database architecture, we can not maintain credentials in the database either. So we would need to take the cookie credentials and validate on every page. and pass other data via http header.

What is the modification to this script if sessions are not available, but still maintain security?