Go Back   FlashFXP Forums > > > >

Bug Reports If you discover any bugs that we are not aware of, please post it here so it may be corrected.

Reply
 
Thread Tools Rate Thread Display Modes
Old 05-08-2004, 01:02 PM   #1
St0rm
Disabled
 
Join Date: Nov 2003
Posts: 105
Default Can't add ips and groups when creating new user with php

The topic basically says it all..
When creating a new user using the php extension, the 'ips' line of the userfile doesn't get written, and the 'groups' line always just contains 'groups' (instead of 'groups 0 1 101' or whatever).
St0rm is offline   Reply With Quote
Old 05-08-2004, 04:42 PM   #2
ADDiCT
Senior Member
FlashFXP Beta Tester
ioFTPD Scripter
 
Join Date: Aug 2003
Posts: 517
Default

Add the lines yourself? This is what i used to copy an existing 'template' user:

(It sets the IP-list for the new user to the IP of the browser client.)

PHP Code:
...

$template_uid 101;

...

// create new user
$new_uid io_user_create($_POST["username"]);

// ... check for errors ($new_uid < 0) ...

// read data
$userfile io_user_open($template_uid);
$contents io_user_print($userfile);
io_user_close($userfile);

// initialise new lines; windows uses \r\n for newline
$passline "password ".io_sha1($_POST["password"])."\r";
$ipline   "ips *@".$_SERVER["REMOTE_ADDR"]."\r";
$tagline  "tagline ".$_POST["tagline"]."\r";

// replace/add lines
$lines explode("\n"$contents);
$size count($lines);
for(
$i=0$i $size$i++)
{
    if     (
strtolower(substr($lines[$i],0,9)) == "password ")  { $lines[$i] = $passline$passline ""; }
    elseif (
strtolower(substr($lines[$i],0,4)) == "ips ")       { $lines[$i] = $ipline;   $ipline   ""; }
    elseif (
strtolower(substr($lines[$i],0,8)) == "tagline ")   { $lines[$i] = $tagline;  $tagline  ""; }
}
$contents  implode("\n"$lines);
if (
strlen($passline)>0$contents .= $passline."\n";   // incase there was no such line yet.
if (strlen($ipline)  >0$contents .= $ipline  ."\n";   // ..
if (strlen($tagline) >0$contents .= $tagline ."\n";   // ..

// write data
$userfile io_user_open($new_uid);
io_user_lock($userfile);
io_user_save($userfile$contents);
io_user_unlock($userfile);
io_user_close($userfile); 
ADDiCT is offline   Reply With Quote
Old 05-09-2004, 06:55 AM   #3
St0rm
Disabled
 
Join Date: Nov 2003
Posts: 105
Default

Forget about the ips thingy, it was a mistake by me, but i still can't add groups to the userfile.. I'm using this code:
PHP Code:
<?php

$uid 
io_user_create($_POST["username"]);

if (
$uid >= 0)
{
  
$uhandle io_user_open($uid);
  
io_user_lock($uhandle);
  
$userfile explode("\n"io_user_print($uhandle));
  
$userfile[2] = "tagline " $_POST["tagline"];
  
$userfile[4] = "password " io_sha1($_POST["password"]);
  
$userfile[8] = "groups " $_POST["group"];  // this one isn't working
  
$userfile[9] = "flags " $_POST["flags"];
  
$userfile implode("\n"$userfile);
  
io_user_save($uhandle$userfile);
  
io_user_unlock($uhandle);
}

?>
Everything works, except for the $userfile[8] line..
St0rm is offline   Reply With Quote
Old 05-09-2004, 07:09 AM   #4
ADDiCT
Senior Member
FlashFXP Beta Tester
ioFTPD Scripter
 
Join Date: Aug 2003
Posts: 517
Default

i don't think u can assume the "groups ..." line will always be at index 8

and i don't open the same userfile twice:
- open the template userfile, read all data, close template userfile (uid = 101)
- modify that data, write it to the new userfile (uid = 102 or 103 or ...)
(but i do re-use the $userfile variable for both files)
ADDiCT is offline   Reply With Quote
Old 05-09-2004, 07:14 AM   #5
St0rm
Disabled
 
Join Date: Nov 2003
Posts: 105
Default

I think you can assume it's at line 8, cause I'm creating a new user, not editing one.

And I noticed about the userfile opening when I was re-reading your code.. I think I was editing my message when you were writing yours
St0rm is offline   Reply With Quote
Reply

Tags
creating, groups, line, php, user

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 01:45 PM.

Parts of this site powered by vBulletin Mods & Addons from DragonByte Technologies Ltd. (Details)