Dynadot โ€” .com Transfer

Reset a remote string [+rep, +NP$]

Spacemail by SpaceshipSpacemail by Spaceship
Watch

cvxdes

Established Member
Impact
14
Im making a SQL-Less CMS in a certant sence, and i need a function to update the password var in another file. Does anyone know a function to do this?

I'll add rep to people who try to help, and donate some NP$
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
Hmm... Could have it required to enter both the old password and new password, then do something like below:

PHP:
<?php

$file = "data/blah/passwords.txt";

$fp = fopen($file, "w");
$data = fread($fp, filesize($file));
$data2 = str_replace($old_pwd, $new_pwd, $data);
fwrite($fp, $data2);
fclose($fp);

?>

Not sure on that, but maybe you can get something from it :)
 
1
•••
^Thanks. I got this idea:

PHP:
$pass1 = file("/home2/****/passwords.txt");
$user1 = file("/home2/****/usernames.txt");
$pass = $pass1[count($pass1)-1];
$user = $user1[count($user1)-1];
$info = array(
'pass' => $pass,
'user' => $user,
);

And in the admin file,
PHP:
$filename = "/home2/****/passwords.txt";
  $fp = fopen($filename,'a');
  fputs($fp,$input['password']);
  fclose($fp);
  ?>

thanks anyways though.
 
0
•••
I would store user data in a flatfile like this:
id|level|username|passwordhash|email|otherinfo
ex:
Code:
0|admin|admin|098f6bcd4621d373cade4e832627b4f6|[email protected]|blah
1|user|bob|098f6bcd4621d373cade4e832627b4f6|[email protected]|blah
2|user|joe|098f6bcd4621d373cade4e832627b4f6|[email protected]|blah

Then you could ask for the old password and new password, then do something like
PHP:
<?php
$userid = 1;
$oldpass = "oldpass";
$newpass = "newpass";

$userdb = file("./users.txt");
$editfile = fopen("./users.txt", "w"); 
foreach ($userdb as $line) {
  $userarray = explode("|",$line);
  if($userarray[0]!=$userid) {
    fwrite($editfile,$line); 
  } else {
    if($userarray[3]==md5($oldpass)){
      echo "Password successfully changed!";
      fwrite($editfile,$userarray[0]."|".$userarray[1]."|".$userarray[2]."|".md5($newpass)."|".$userarray[4]."|".$userarray[5]."\n"); 
    } else {
      echo "You did not supply the correct password.";
      fwrite($editfile,$line); 
    }
  }
}
?>
 
0
•••
Jim is good at flat file stuff >_<

He's made flatFileHost, started flatBB, and I think his tagger is flat.
 
0
•••
Jim_ said:
I would store user data in a flatfile like this:
id|level|username|passwordhash|email|otherinfo
ex:
Code:
0|admin|admin|098f6bcd4621d373cade4e832627b4f6|[email protected]|blah
1|user|bob|098f6bcd4621d373cade4e832627b4f6|[email protected]|blah
2|user|joe|098f6bcd4621d373cade4e832627b4f6|[email protected]|blah

Then you could ask for the old password and new password, then do something like
PHP:
<?php
$userid = 1;
$oldpass = "oldpass";
$newpass = "newpass";

$userdb = file("./users.txt");
$editfile = fopen("./users.txt", "w"); 
foreach ($userdb as $line) {
  $userarray = explode("|",$line);
  if($userarray[0]!=$userid) {
    fwrite($editfile,$line); 
  } else {
    if($userarray[3]==md5($oldpass)){
      echo "Password successfully changed!";
      fwrite($editfile,$userarray[0]."|".$userarray[1]."|".$userarray[2]."|".md5($newpass)."|".$userarray[4]."|".$userarray[5]."\n"); 
    } else {
      echo "You did not supply the correct password.";
      fwrite($editfile,$line); 
    }
  }
}
?>


How would i make that multiple users?

like if i wanted to do $userid = $input['id']; how would i?
 
0
•••
I don't get what you're asking. :S
 
0
•••
Flat file has its pros and cons.

One example for each is below

PRO: Simpler than MySQL or other database types
CON: A limited number of simultaneous connections can be made than a true database.

-Steve
 
0
•••
Another option would be SQLite. :)
 
0
•••
Nevermind, lol. I think i got it... I'll post back in an hour
 
0
•••
Dynadot โ€” .com TransferDynadot โ€” .com Transfer
Domain Recover
NameMaxi - Your Domain Has Buyers
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back