Advanced PHP Help needed
Moderator: General Moderators
Advanced PHP Help needed
I need to create a php web interface that will allow me to create ftp accounts, passwords, ect. I know all the parts about the sql data, however can someone point me in the right direction where to look for help on the php scripting where it interfaces with the linux server and creates the accounts.
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Not 100% this should be in T&D until I see what exactly you're looking for but I'd just do this using shell commands.... the only hurdle is getting around the privileges that apache runs under.
I use backticks to execute shell commands:
If you need to add real linux accounts here's a handy function from php.net for getting the password salted in the correct form for the /etc/shadow file.
I use backticks to execute shell commands:
Code: Select all
echo `ls -l`;Code: Select all
function makeSalt($type=CRYPT_SALT_LENGTH) {
switch($type) {
case 8:
$saltlen=9; $saltprefix='$1$'; $saltsuffix='$'; break;
case 2:
default: // by default, fall back on Standard DES (should work everywhere)
$saltlen=2; $saltprefix=''; $saltsuffix=''; break;
#
}
$salt='';
while(strlen($salt)<$saltlen) $salt.=chr(rand(64,126));
return $saltprefix.$salt.$saltsuffix;
}
$password_string = crypt($password, makeSalt(8));
$data = $user.':'.$password_string.':::::::'."\n"; //fwrite() this to /etc/shadowAdvanced Script
So you can basically execute bash commands from a php script on the web?
What I want to do is make a simple web interface that will create ftp users, delete ftp users, create directories within a certian account ect? My preferred method because thats what I know most is php.
Chris
What I want to do is make a simple web interface that will create ftp users, delete ftp users, create directories within a certian account ect? My preferred method because thats what I know most is php.
Chris
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Not necessarily... I can see a way to apply a different userid to just one script if you put that script under a different directory. suexec with CGI can do this, and many shared hosts apply the same principles in order to make PHP run under the userid of the account holdersweatje wrote:You biggest problem will be permissions. You have to give the user running the web server the rights to perform all of the actions you are asking, and then anybody with the capability of putting PHP scripts onto the server will have all of the same rights.