pureuseradmin-cvs Mailing List for PureUserAdmin (Page 2)
Status: Abandoned
Brought to you by:
mvanbaak
You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(7) |
Jul
(2) |
Aug
(1) |
Sep
|
Oct
(30) |
Nov
|
Dec
|
---|
From: Michiel v. B. <mva...@us...> - 2004-10-03 16:10:21
|
Update of /cvsroot/pureuseradmin/PureUserAdmin/docs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27598/docs Log Message: Directory /cvsroot/pureuseradmin/PureUserAdmin/docs added to the repository |
From: Michiel v. B. <mva...@us...> - 2004-10-03 16:10:02
|
Update of /cvsroot/pureuseradmin/PureUserAdmin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26964 Modified Files: pureuserclass.php Log Message: Implemented all base functions needed for normal admin use. Index: pureuserclass.php =================================================================== RCS file: /cvsroot/pureuseradmin/PureUserAdmin/pureuserclass.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** pureuserclass.php 3 Oct 2004 09:32:00 -0000 1.1 --- pureuserclass.php 3 Oct 2004 16:06:33 -0000 1.2 *************** *** 1,11 **** <? Class pureuseradmin { ! const DEBUG = 1; public $settings = Array(); public $uids = Array(); public $gids = Array(); function __construct() { /* global settings */ --- 1,154 ---- <? + /** + * Manage virtual users for PureFTPd. + * + * This class provides every function you need to manage virtual users. + * It can handle users stored in a MySQL or PostgreSQL database. + * @version 0.2.0 + * @license http://www.gnu.org/licenses/gpl.html GPL + * @link http://pureuseradmin.sourceforge.net Project home. + * @author Michiel van Baak <mva...@us...> + * @copyright Copyright 2004, Michiel van Baak + */ Class pureuseradmin { ! const DEBUG = 0; ! /** ! * This variable is filled in the constructor. It can be changed with a public function. ! * @var array all settings needed ! * @access public ! */ public $settings = Array(); + /** + * This variable is filled in the constructor. + * @var array uids on the system. + * @access public + */ public $uids = Array(); + /** + * This variable is filled in the constructor. + * @var array gids on the system. + * @access public + */ public $gids = Array(); + /** + * Generate a password statement for the database query. + * <code> $pass = self::mkpass("password"); </code> + * @param string $passwd The password to insert into the database. + * @return string The string to use in the sql statement. + * @access private + */ + private function mkpass ($passwd) { + if ($this->settings["pwcrypt"] == "password") { + $ret = "password('".$passwd."')"; + } elseif ($this->settings["pwcrypt"] == "cleartext") { + $ret = "'".$passwd."'"; + } elseif ($this->settings["pwcrypt"] == "md5") { + $ret = "'".md5($userinfo["password"])."'"; + } else { + //error + error("update user-password","Please provide a valid password encryption method in the configuration section"); + } + return $ret; + } + + /** + * Database connection + * + * Make connection to the database server, select the right database and include the file + * with database specific functions. + * <code> self::dbinit(); </code> + * @access private + */ + private function db_init () { + if ($this->settings["sql_type"] == "mysql") { + $db = mysql_pconnect($this->settings["sql_server"], $this->settings["sql_user"], $this->settings["sql_pass"]) or die("Cannot connect to MySQL Server"); + mysql_select_db($this->settings["sql_dbase"], $db) or die("Database ".$this->settings["sql_dbase"]." cannot be selected"); + include("functions_mysql.php"); + } elseif ($this->settings["sql_type"] == "postgres") { + $db = pg_pconnect("host=".$this->settings["sql_server"]." dbname=".$this->settings["sql_dbase"]." user=".$this->settings["sql_user"]." password=".$this->settings["sql_pass"]) or die("Cannot connect to PostgreSQL Server or cannot select database ".$this->settings["sql_dbase"]); + include("functions_postgres.php"); + } + } + + /** + * PHP database support + * + * Check wether the needed database module is loaded as php module. + * If not, try to load it now. + * <code> self::load_sql($sql_type); </code> + * @param string $sql_type database server type. "mysql" or "postgres" + * @access private + */ + private function load_sql ($sql_type) { + if ($sql_type == "mysql") { + // check for mysql module and try to load it when absent + if (!extension_loaded("mysql")) { + @dl("mysql"); + } + // if by now it still isn't loaded we miss the module. + if (!extension_loaded("mysql")) { + gen_error("MySQL support unavailable"); + exit(); + } + } elseif($sql_type == "postgres") { + // check for postgresql module and try to load it when absent + if (!extension_loaded("pgsql")) { + @dl("pgsql"); + } + // if by now it still isn't loaded we miss the module. + if (!extension_loaded("pgsql")) { + gen_error("PostgreSQL support unavailable"); + exit(); + } + } else { + // unsupported database type + gen_error("We dont support database system $sql_type"); + exit(); + } + } + + /** + * Load all the uids and usernames on the system. + * <code> self::load_uids(); </code> + * @return array uids as key and usernames as value. + * @access private + */ + private function load_uids() { + $lines = file("/etc/passwd"); + foreach ($lines as $line) { + $elements = explode(":", $line); + $uids[$elements[2]] = $elements[0]; + } + ksort($uids); + return $uids; + } + + /** + * Load all the gids and groupnames on the system. + * <code> self::load_gids(); </code> + * @return array gids as key and groupnames as value. + * @access private + */ + private function load_gids() { + $lines = file("/etc/group"); + foreach ($lines as $line) { + $elements = explode(":", $line); + $gids[$elements[2]] = $elements[0]; + } + ksort($gids); + return $gids; + } + + /** + * Class constructor + * + * This function is called as soon as an instance of the class is created. + * It will init the settings, connect to the database and load the uids and gids on the system. + * <code> $instance = new pureuseradmin(); </code> + * @access protected + */ function __construct() { /* global settings */ *************** *** 32,70 **** $this->settings["page_size"] = "20"; // records on 1 page in userlist /* load uids*/ ! $lines = file("/etc/passwd"); ! foreach ($lines as $line) { ! $elements = explode(":", $line); ! $uids[$elements[2]] = $elements[0]; ! } ! ksort($uids); ! //$this->uids = $uids; /* load gids */ ! $lines = file("/etc/group"); ! foreach ($lines as $line) { ! $elements = explode(":", $line); ! $gids[$elements[2]] = $elements[0]; ! } ! ksort($gids); ! //$this->gids = $gids; } public function changeSetting ($setting, $value) { $this->settings[$setting] = $value; } ! private function mkpass ($passwd) { ! if ($this->settings["pwcrypt"] == "password") { ! $ret = "password('".$passwd."')"; ! } elseif ($this->settings["pwcrypt"] == "cleartext") { ! $ret = "'".$passwd."'"; ! } elseif ($this->settings["pwcrypt"] == "md5") { ! $ret = "'".md5($userinfo["password"])."'"; ! } else { ! //error ! error("update user-password","Please provide a valid password encryption method in the configuration section"); ! } ! return $ret; ! } ! public function save_user ($userinfo) { if (!count($userinfo)) { --- 175,205 ---- $this->settings["page_size"] = "20"; // records on 1 page in userlist /* load uids*/ ! $this->uids = self::load_uids(); /* load gids */ ! $this->gids = self::load_gids(); ! /* load database library */ ! self::load_sql($this->settings["sql_type"]); ! /* connect to database server and select database */ ! self::db_init(); } + /** + * Overwrite a predefined setting, + * <code> $instance->changeSetting("setting", "value"); </code> + * @param string $setting The setting to overwrite. + * @param string $value The new value. + * @access public + */ public function changeSetting ($setting, $value) { $this->settings[$setting] = $value; } ! /** ! * Save a user in the database. ! * <code> $result = $instance->save_user($userinfo); </code> ! * @param array $userinfo ! * @return boolean true when success, false on error. ! * @access public ! */ public function save_user ($userinfo) { if (!count($userinfo)) { *************** *** 75,81 **** if ($userinfo["update"]) { $sql = "UPDATE ".$this->settings["sql_table"]." SET "; ! $sql .= "uid=".$this->userinfo["uid"]; ! $sql .= ", gid=".$this->userinfo["gid"]; ! $sql .= ", dir='".$this->userinfo["dir"]."'"; // are we going to reset the password ? if ($userinfo["password"]) { --- 210,216 ---- if ($userinfo["update"]) { $sql = "UPDATE ".$this->settings["sql_table"]." SET "; ! $sql .= "uid=".$userinfo["uid"]; ! $sql .= ", gid=".$userinfo["gid"]; ! $sql .= ", dir='".$userinfo["dir"]."'"; // are we going to reset the password ? if ($userinfo["password"]) { *************** *** 114,122 **** } return true; ! } } - print("<html><body><pre>"); - $a = new pureuseradmin(); - print("</pre></body></html>"); ?> \ No newline at end of file --- 249,333 ---- } return true; ! } ! ! /** ! * Delete a user from the database. ! * <code> $result = $instance->delete_user($userinfo); </code> ! * @param array $userinfo ! * @return boolean true when success, false on error. ! * @access public ! */ ! public function delete_user($userinfo) { ! $sql = "DELETE FROM ".$this->settings["sql_table"]." WHERE username='".$userinfo["username"]."'"; ! $res = sql_query($sql); ! return true; ! } ! ! /** ! * Get a user from the database. ! * <code> $userlist = $instance->get_user($userinfo); </code> ! * @param array $userinfo ! * @return array A user with all info that is in the database. ! * @access public ! */ ! public function get_user($userinfo) { ! $sql = "SELECT * FROM ".$this->settings["sql_table"]." WHERE username='".$userinfo["username"]."'"; ! $res = sql_query($sql); ! $userinfo = sql_fetch_assoc($res); ! return $userinfo; ! } ! ! /** ! * Get all users from the database, in alphabetic order. ! * <code> $userlist = $instance->get_all_users(); </code> ! * @return array All users with all info that is in the database. ! * @access public ! */ ! public function get_all_users() { ! $sql = "SELECT * FROM ".$this->settings["sql_table"]." ORDER BY username"; ! $res = sql_query($sql); ! $users = Array(); ! while ($row = sql_fetch_assoc($res)) { ! $users[] = $row; ! } ! return $users; ! } ! ! /** ! * Check what type of access the user has. ! * <code> $permission = $instance->check_access("/home/test",1001,1001); </code> ! * @param string $homedir The home directory of the user processed. ! * @param int $uid The main userid of the user. ! * @param int $gid The main groupid of the user. ! * @return array owner,group,world octal permission and read and write flag. ! * @access public ! */ ! public function check_access ($homedir, $uid, $gid) { ! if (file_exists($homedir)) { ! $fuid = fileowner($homedir); ! $fgid = filegroup($homedir); ! $fperms = fileperms($homedir); ! $fperm = substr(sprintf("%o",$fperms),2); ! $rights["owner"] = substr($fperm,0,1); ! $rights["group"] = substr($fperm,1,1); ! $rights["world"] = substr($fperm,2,1); ! $rights["read"] = 0; ! $rights["write"] = 0; ! if ($rights["world"] > 6) { $rights["write"] = 1; } ! if ($rights["world"] > 4) { $rights["read"] = 1; } ! if ($uid == $fuid) { ! if ($rights["owner"] > 6) { $rights["write"] = 1; } ! if ($rights["owner"] > 4) { $rights["read"] = 1; } ! } ! if ($gid == $fgid) { ! if ($rights["group"] > 6) { $rights["write"] = 1; } ! if ($rights["group"] > 4) { $rights["read"] = 1; } ! } ! } else { ! $rights["error"] = "No such directory"; ! } ! return $rights; ! } } ?> \ No newline at end of file |
From: Michiel v. B. <mva...@us...> - 2004-10-03 16:09:28
|
Update of /cvsroot/pureuseradmin/PureUserAdmin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27347 Modified Files: functions_mysql.php Log Message: Changed the debug check to respect the Class constant DEBUG Index: functions_mysql.php =================================================================== RCS file: /cvsroot/pureuseradmin/PureUserAdmin/functions_mysql.php,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** functions_mysql.php 3 Jun 2004 17:34:08 -0000 1.1.1.1 --- functions_mysql.php 3 Oct 2004 16:07:45 -0000 1.2 *************** *** 1,6 **** <? function sql_trigger_error($query, $err){ ! global $debug; ! if ($debug){ $h = "<br>"; $h.= "<b>Query Mysql/Function:</b>"; --- 1,5 ---- <? function sql_trigger_error($query, $err){ ! if (pureuseradmin::DEBUG){ $h = "<br>"; $h.= "<b>Query Mysql/Function:</b>"; *************** *** 39,43 **** function sql_query($query) { - global $debug; $result = mysql_query($query) or sql_trigger_error($query, mysql_error()); return $result; --- 38,41 ---- *************** *** 82,86 **** function sql_error($filename, $linenumber, $query="") { - global $debug; return 1; } --- 80,83 ---- |
From: Michiel v. B. <mva...@us...> - 2004-10-03 16:07:53
|
Update of /cvsroot/pureuseradmin/PureUserAdmin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26735 Added Files: index.php Log Message: Page to show how the class can be used to make a simple admin tool. --- NEW FILE: index.php --- <? require("pureuserclass.php"); $a = new pureuseradmin(); switch ($_POST["action"]) { case "edit_user" : edit_user($_POST["username"]); break; case "save_user" : $a->save_user($_POST["userinfo"]); gen_list(); break; case "delete_user" : $a->delete_user($_POST["userinfo"]); gen_list(); break; case "search" : gen_list($_REQUEST["searchstring"],$_REQUEST["start"]); break; default : welcome(); break; } function html_header ($title) { global $a; ?> <?="<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <title>PureUserAdmin - <?=$title?></title> <style type="text/css"> .copyright { bottom: 0px; right: 0px; height: 15px; border-top: 3px solid #6699CC; border-bottom: 3px solid #6699CC; background-color: #336699; color: #E4E9EB; } html, body, form { height: 100%; width: 100%; margin: 0px 0px 0px 0px; } td { background-color: #FFFFFF; } .pagetable { height: 100%; width: 100%; } .logo { height: 50px; width: 100%; left: 50%; } .maintd { width: 100%; right: 50%; height: 100%; } .links { border-top: 3px solid #6699CC; border-bottom: 3px solid #6699CC; background-color: #336699; color: #E4E9EB; } .listtdleft { border-left: 1px solid #000000; border-right: 1px solid #000000; border-bottom: 1px solid #000000; } .listtd { border-right: 1px solid #000000; border-bottom: 1px solid #000000; } .headertdleft { border-left: 1px solid #000000; border-top: 3px solid #6699CC; border-bottom: 3px solid #6699CC; background-color: #336699; color: #E4E9EB; } .headertd { border-top: 3px solid #6699CC; border-bottom: 3px solid #6699CC; background-color: #336699; color: #E4E9EB; } .headertdright { border-right: 1px solid #000000; border-top: 3px solid #6699CC; border-bottom: 3px solid #6699CC; background-color: #336699; color: #E4E9EB; } a.toplinks { color: #E4E9EB; font-weight: bold; } </style> <script language="Javascript1.2" type="text/javascript"> // function to alter form field values function set(item, waarde){ if (document.forms.pageform){ eval("document.forms.pageform."+item+".value='"+waarde+"'"); } } function verzend(){ if (document.forms.pageform){ document.forms.pageform.submit(); } } </script> </head> <body bgcolor="#ffffff" > <table id="secondary-links-table" summary="Navigation elements." border="0" cellpadding="0" cellspacing="0" class="pagetable"><tr> <td class="logo" align="center"><img src="logo.gif" alt="logo" border="0" /></td> </tr><tr> <td class="links" align="center" valign="middle"> <a class="toplinks" href="<?=$_SERVER["PHP_SELF"]?>">[ Home ]</a> <a class="toplinks" href="Javascript:set('username','');set('action', 'edit_user');verzend();">[ New User ]</a> <a class="toplinks" href="Javascript:set('action', 'search');verzend();">[ Userlist ]</a> <a class="toplinks" href="http://pureuseradmin.sourceforge.net">[ Project Page ]</a> </td> </tr><tr> <td class="maintd" align="center"> <div style="vertical-align: middle"> <form name="pageform" id="pageform" method="post" action="index.php"> <input type="hidden" name="action" value="<?=$_POST["action"]?>" /> <input type="hidden" name="username" value="<?=$_POST["username"]?>" /> <? } function html_footer () { global $a; ?> </form> </div> </td> </tr><tr> <td class="copyright" align="right"> <a class="toplinks" href="<?=$a->settings["homepage"]?>">PureUserAdmin <?=$a->settings["version"]?></a>, by Michiel van Baak, © 2004, released under the <a class="toplinks" href="http://www.gnu.org/copyleft/gpl.html">GPL.</a> </td> </tr></table> </body> </html> <? } function welcome () { global $a; html_header("welcome"); ?> <table border="0" cellspacing="0" cellpadding="2"><tr> <td class="headertdleft">Settings</td> <td class="headertdright"> </td> </tr><tr> <td class="listtdleft" align="right">Debugging: </td> <td class="listtd"><?=pureuseradmin::DEBUG?></td> </tr><tr> <td class="listtdleft" align="right">Program version: </td> <td class="listtd"><?=$a->settings["version"]?></td> </tr><tr> <td class="listtdleft" align="right">FTP server address: </td> <td class="listtd"><?=$a->settings["ftp_hostname"]?></td> </tr><tr> <td class="listtdleft" align="right">Admin email address: </td> <td class="listtd"><?=$a->settings["admin_email"]?></td> </tr><tr> <td class="listtdleft" align="right">Database type: </td> <td class="listtd"><?=$a->settings["sql_type"]?></td> </tr><tr> <td class="listtdleft" align="right">Database server: </td> <td class="listtd"><?=$a->settings["sql_server"]?></td> </tr><tr> <td class="listtdleft" align="right">Database name: </td> <td class="listtd"><?=$a->settings["sql_dbase"]?></td> </tr><tr> <td class="listtdleft" align="right">Database table: </td> <td class="listtd"><?=$a->settings["sql_table"]?></td> </tr><tr> <td class="listtdleft" align="right">Password crypt method: </td> <td class="listtd"><?=$a->settings["pwcrypt"]?></td> </tr><tr> <td class="listtdleft" align="right">Check homedir access: </td> <td class="listtd"><? echo ($a->settings["check_access"]) ? "yes" : "no"; ?></td> </tr><tr> <td class="listtdleft" align="right">Email user: </td> <td class="listtd"><? echo ($a->settings["notify_user"]) ? "yes" : "no"; ?></td> </tr><tr> <td class="listtdleft" align="right">Default uid: </td> <td class="listtd"><?=$a->uids[$a->settings["default_uid"]]?> (<?=$a->settings["default_uid"]?>)</td> </tr><tr> <td class="listtdleft" align="right">Default gid: </td> <td class="listtd"><?=$a->gids[$a->settings["default_gid"]]?> (<?=$a->settings["default_gid"]?>)</td> </tr></table> <? html_footer(); } function edit_user ($username = "") { global $a; if (strlen($username)) { $userget["username"] = $username; $userinfo = $a->get_user($userget); html_header("edit user"); ?><input type="hidden" name="userinfo[update]" value="1" /><? } else { // new user html_header("new user"); ?><input type="hidden" name="userinfo[update]" value="0" /><? } ?> <table border="0" cellspacing="0" cellpadding="2"><tr> <td class="headertdleft"><? if (strlen($userinfo)) { ?>Edit<? } else { ?>New<? } ?> User</td> <td class="headertdright"> </td> </tr><tr> <td class="listtdleft" align="right">username: </td> <? if (strlen($userinfo)) { ?> <td class="listtd"><input type="hidden" name="userinfo[username]" value="<?=$userinfo["username"]?>" /><?=$userinfo["username"]?></td> <? } else { ?> <td class="listtd"><input type="text" name="userinfo[username]" value="<?=$userinfo["username"]?>" /></td> <? } ?> </tr><tr> <td class="listtdleft" align="right">password*: </td> <td class="listtd"><input type="password" name="userinfo[password]" /></td> </tr><tr> <td class="listtdleft" align="right">retype password*: </td> <td class="listtd"><input type="password" name="userinfo[password1]" /></td> </tr><tr> <td class="listtdleft" align="right">email: </td> <td class="listtd"><input type="text" name="userinfo[email]" /></td> </tr><tr> <td class="listtdleft" align="right">uid: </td> <td class="listtd"> <select name="userinfo[uid]"> <? if (!array_key_exists($userinfo["uid"], $a->uids)) { ?><option value="<?=$userinfo["uid"]?>" SELECTED><?=$userinfo["uid"]?></option><? } foreach ($a->uids as $key=>$val) { ?><option value="<?=$key?>" <? if ($userinfo["uid"]==$key) { echo("SELECTED"); } ?>><?=$val?></option><? } ?> <option></option> </select> </td> </tr><tr> <td class="listtdleft" align="right">gid: </td> <td class="listtd"> <select name="userinfo[gid]"> <? if (!array_key_exists($userinfo["gid"], $a->gids)) { ?><option value="<?=$userinfo["gid"]?>" SELECTED><?=$userinfo["gid"]?></option><? } foreach ($a->gids as $key=>$val) { ?><option value="<?=$key?>" <? if ($userinfo["gid"]==$key) { echo("SELECTED"); } ?>><?=$val?></option><? } ?> <option></option> </select> </td> </tr><tr> <td class="listtdleft" align="right">homedir: </td> <td class="listtd"><input type="text" name="userinfo[dir]" value="<?=$userinfo["dir"]?>" /></td> </tr><tr> <td colspan="2" class="listtdleft"> <table border="0" cellspacing="0" cellpadding="0" width="100%"><tr> <td width="33%" align="left"><a href="Javascript:set('action','save_user');verzend();">save</a></td> <td width="33%" align="center"><a href="Javascript:set('action', 'gen_list');verzend();">back</a></td> <td align="right"><a href="Javascript:set('action','delete_user');verzend();">delete</a></td> </tr></table> </td> </tr></table> * leave blank to keep current password <? html_footer(); } function gen_list ($search = "", $start = 0) { global $a; if (!$start) { $start = 0; } html_header("userlist"); ?> <input type="hidden" name="start" value="<?=$start?>"> <table border="0" cellspacing="0" cellpadding="2"><tr> <td class="headertdleft" width="33%"> </td> <td class="headertd" width="33%"><div align="center">search</div></td> <td class="headertdright"> </td> </tr><tr> <td class="listtdleft">searchstring</td> <td class="listtd"><input type="text" name="searchstring" value="<?=$search?>"></td> <td class="listtd"><a href="javascript:set('action','search');verzend();">go</a></td> </tr></table> <br /> <table border="0" cellspacing="0" cellpadding="2"><tr><td class="headertdleft">username</td><td class="headertd">uid</td><td class="headertd">gid</td><td class="headertdright">homedir</td></tr> <? if ($search) { $sql_s = " WHERE username LIKE '%$search%' "; } else { $sql_s = ""; } //how many users do we have $all_users = $a->get_all_users(); $usernr = count($all_users); foreach ($all_users as $user) { if ($a->settings["check_access"]) { $user_rights = $a->check_access($user["dir"],$user["uid"],$user["gid"]); if ($user_rights["error"]) { $right = $user_rights["error"]; } else { if ($user_rights["write"]) { $right = "user can read and write files in homedir"; } elseif ($user_rights["read"]) { $right = "user can only read files in homedir"; } else { $right = "<font color=\"red\">user has no access to homedir</font>"; } } } ?> <tr> <td class="listtdleft"><a href="javascript:set('action','edit_user');set('username','<?=$user["username"]?>');verzend();"><?=$user["username"]?></a></td> <td class="listtd"><? echo $a->uids[$user["uid"]] ? $a->uids[$user["uid"]] : $user["uid"]; ?></td> <td class="listtd"><? echo $a->gids[$user["gid"]] ? $a->gids[$user["gid"]] : $user["gid"]; ?></td> <td class="listtd"><?=$user["dir"]?> <? if ($a->settings["check_access"]) { ?>(<?=$right?>)<? } ?></td> </tr> <? } if ($start && $start+$a->settings["page_size"]<$usernr) { ?> <tr> <td class="listtdleft" colspan="3"> <? if ($start) { ?> <a href="javascript:set('start','<?=($start-$a->settings["page_size"])?>');verzend();">back <?=$a->settings["page_size"]?> records</a> <? } ?> </td> <td class="listtd"><div align="right"> <? if ($start+$a->settings["page_size"]<$usernr) { ?> <a href="javascript:set('start','<?=($start+$a->settings["page_size"])?>');verzend();">forward <?=$a->settings["page_size"]?> records</a> <? } ?> </div></td> </tr> <? } ?> </table><? html_footer(); } ?> |
From: Michiel v. B. <mva...@us...> - 2004-10-03 09:33:09
|
Update of /cvsroot/pureuseradmin/PureUserAdmin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32284 Added Files: pureuserclass.php Log Message: started to make a Class so ppl can make their own app without having to worry about the inner logic --- NEW FILE: pureuserclass.php --- <? Class pureuseradmin { const DEBUG = 1; public $settings = Array(); public $uids = Array(); public $gids = Array(); function __construct() { /* global settings */ $this->settings["version"] = "%%VERSION"; $this->settings["homepage"] = "%%HOMEPAGE"; $this->settings["check_access"]= "1"; // 0 = disabled, 1 = enabled - check if user has read/write access in homedir $this->settings["notify_user"] = "1"; // 0 = disabled, 1 = enabled - email user with password etc. Database needs field "email" $this->settings["admin_email"] = "yo...@do...d"; $this->settings["ftp_hostname"]= "your.ftp.server"; /* database settigs */ $this->settings["sql_type"] = "mysql"; // PureFTPd only supports MySQL and PostgreSQL (mysql and postgres) $this->settings["sql_server"] = "127.0.0.1"; $this->settings["sql_user"] = "ftpdaemon"; $this->settings["sql_pass"] = "showmethelogins"; $this->settings["sql_dbase"] = "ftp_users"; $this->settings["sql_table"] = "logins"; /* user settings */ $this->settings["pwcrypt"] = "password"; // password = MySQL's password() // cleartext = plain text // md5 $this->settings["default_uid"] = "32767"; // we use nobody (on OpenBSD) $this->settings["default_gid"] = "32767"; // we use nobody (on OpenBSD) $this->settings["page_size"] = "20"; // records on 1 page in userlist /* load uids*/ $lines = file("/etc/passwd"); foreach ($lines as $line) { $elements = explode(":", $line); $uids[$elements[2]] = $elements[0]; } ksort($uids); //$this->uids = $uids; /* load gids */ $lines = file("/etc/group"); foreach ($lines as $line) { $elements = explode(":", $line); $gids[$elements[2]] = $elements[0]; } ksort($gids); //$this->gids = $gids; } public function changeSetting ($setting, $value) { $this->settings[$setting] = $value; } private function mkpass ($passwd) { if ($this->settings["pwcrypt"] == "password") { $ret = "password('".$passwd."')"; } elseif ($this->settings["pwcrypt"] == "cleartext") { $ret = "'".$passwd."'"; } elseif ($this->settings["pwcrypt"] == "md5") { $ret = "'".md5($userinfo["password"])."'"; } else { //error error("update user-password","Please provide a valid password encryption method in the configuration section"); } return $ret; } public function save_user ($userinfo) { if (!count($userinfo)) { return false; //error, $userinfo is an array with fields from edit form } // update or insert ? if ($userinfo["update"]) { $sql = "UPDATE ".$this->settings["sql_table"]." SET "; $sql .= "uid=".$this->userinfo["uid"]; $sql .= ", gid=".$this->userinfo["gid"]; $sql .= ", dir='".$this->userinfo["dir"]."'"; // are we going to reset the password ? if ($userinfo["password"]) { if ($userinfo["password"] == $userinfo["password1"]) { $sql .= ", password=".self::mkpass($userinfo["password"]); } } $sql .= " WHERE username='".$userinfo["username"]."'"; } else { // check if name is already in DB. $sql = "SELECT COUNT(*) FROM ".$this->settings["sql_table"]." WHERE username='".$userinfo["username"]."'"; //$res = sql_query($sql); //$aantal = sql_result($res,0); if ($aantal) { return false; //error } else { $sql = "INSERT INTO ".$this->settings["sql_table"]." (username,password,uid,gid,dir) VALUES ("; $sql .= "'".$userinfo["username"]."', "; $sql .= self::mkpass($userinfo["password"]).", "; $sql .= $userinfo["uid"].", ".$userinfo["gid"].", '".$userinfo["dir"]."'"; $sql .= ")"; } } $res = sql_query($sql); if ($this->settings["notify_user"] && strlen($userinfo["email"])) { // send email $subject = $this->settings["ftp_hostname"]." FTP information"; $body = "Hi ".$userinfo["username"].",\n\n"; $body .= "Here is some information you will need to login with FTP:\n"; $body .= "hostname: ".$this->settings["ftp_hostname"]."\n"; $body .= "username: ".$userinfo["username"]."\n"; $body .= "password: ".$userinfo["password"]."\n\n"; $body .= "This information was sent to you by PureUserAdmin ".$this->settings["version"]." (c) 2004 by Michiel van Baak"; mail($userinfo["email"], $subject, $body, "From: ".$this->settings["admin_email"]."\r\n", "-f".$this->settings["admin_email"]); } return true; } } print("<html><body><pre>"); $a = new pureuseradmin(); print("</pre></body></html>"); ?> |
From: Michiel v. B. <mva...@us...> - 2004-08-30 18:36:50
|
Update of /cvsroot/pureuseradmin/PureUserAdmin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27300 Added Files: .cvsignore Log Message: added to exclude eclipse files --- NEW FILE: .cvsignore --- .project |
From: Michiel v. B. <mva...@us...> - 2004-07-06 17:39:31
|
Update of /cvsroot/pureuseradmin/PureUserAdmin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24078 Modified Files: pc.php Log Message: added page limits to userlist Index: pc.php =================================================================== RCS file: /cvsroot/pureuseradmin/PureUserAdmin/pc.php,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** pc.php 1 Jul 2004 21:00:46 -0000 1.8 --- pc.php 6 Jul 2004 17:39:22 -0000 1.9 *************** *** 49,52 **** --- 49,53 ---- $settings["default_uid"] = "32767"; // we use nobody (on OpenBSD) $settings["default_gid"] = "32767"; // we use nobody (on OpenBSD) + $settings["page_size"] = "20"; // records on 1 page in userlist /* }}} */ *************** *** 68,72 **** case "delete_user" : delete_user($_POST["userinfo"]); break; case "check_access": check_access($_REQUEST["dir"], $_REQUEST["uid"], $_REQUEST["gid"]); break; ! case "search" : gen_list($_REQUEST["searchstring"]); break; default : welcome(); break; } --- 69,73 ---- case "delete_user" : delete_user($_POST["userinfo"]); break; case "check_access": check_access($_REQUEST["dir"], $_REQUEST["uid"], $_REQUEST["gid"]); break; ! case "search" : gen_list($_REQUEST["searchstring"],$_REQUEST["start"]); break; default : welcome(); break; } *************** *** 336,339 **** --- 337,343 ---- function gen_list ($search = "", $start = 0) { global $settings; + if (!$start) { + $start = 0; + } $sql_table = $settings["sql_table"]; $uids = load_uids(); *************** *** 342,345 **** --- 346,350 ---- html_header("userlist"); ?> + <input type="hidden" name="start" value="<?=$start?>"> <table border="0" cellspacing="0" cellpadding="2"><tr> <td class="headertdleft" width="33%"> </td> *************** *** 359,363 **** $sql_s = ""; } ! $sql = "SELECT * FROM $sql_table $sql_s ORDER BY username LIMIT $start,20"; $res = sql_query($sql); while ($row = sql_fetch_assoc($res)) { --- 364,372 ---- $sql_s = ""; } ! //how many users do we have ! $sql = "SELECT COUNT(username) FROM $sql_table"; ! $res = sql_query($sql); ! $usernr = sql_result($res,0); ! $sql = "SELECT * FROM $sql_table $sql_s ORDER BY username LIMIT $start,".$settings["page_size"]; $res = sql_query($sql); while ($row = sql_fetch_assoc($res)) { *************** *** 385,389 **** <? } ! ?></table><? html_footer(); --- 394,413 ---- <? } ! if ($start && $start+$settings["page_size"]<$usernr) { ! ?> ! <tr> ! <td class="listtdleft" colspan="3"> ! <? if ($start) { ?> ! <a href="javascript:set('start','<?=($start-$settings["page_size"])?>');verzend();">back <?=$settings["page_size"]?> records</a> ! <? } ?> ! </td> ! <td class="listtd"><div align="right"> ! <? if ($start+$settings["page_size"]<$usernr) { ?> ! <a href="javascript:set('start','<?=($start+$settings["page_size"])?>');verzend();">forward <?=$settings["page_size"]?> records</a> ! <? } ?> ! </div></td> ! </tr> ! <? } ?> ! </table><? html_footer(); |
From: Michiel v. B. <mva...@us...> - 2004-07-01 21:00:58
|
Update of /cvsroot/pureuseradmin/PureUserAdmin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18021 Modified Files: pc.php Log Message: added a search box to the userlist. search also works :) Index: pc.php =================================================================== RCS file: /cvsroot/pureuseradmin/PureUserAdmin/pc.php,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** pc.php 13 Jun 2004 14:48:33 -0000 1.7 --- pc.php 1 Jul 2004 21:00:46 -0000 1.8 *************** *** 68,72 **** case "delete_user" : delete_user($_POST["userinfo"]); break; case "check_access": check_access($_REQUEST["dir"], $_REQUEST["uid"], $_REQUEST["gid"]); break; ! case "search" : gen_list(); break; default : welcome(); break; } --- 68,72 ---- case "delete_user" : delete_user($_POST["userinfo"]); break; case "check_access": check_access($_REQUEST["dir"], $_REQUEST["uid"], $_REQUEST["gid"]); break; ! case "search" : gen_list($_REQUEST["searchstring"]); break; default : welcome(); break; } *************** *** 341,346 **** html_header("userlist"); ! ?><table border="0" cellspacing="0" cellpadding="2"><tr><td class="headertdleft">username</td><td class="headertd">uid</td><td class="headertd">gid</td><td class="headertdright">homedir</td></tr><? ! $sql = "SELECT * FROM $sql_table ORDER BY username LIMIT $start,20"; $res = sql_query($sql); while ($row = sql_fetch_assoc($res)) { --- 341,363 ---- html_header("userlist"); ! ?> ! <table border="0" cellspacing="0" cellpadding="2"><tr> ! <td class="headertdleft" width="33%"> </td> ! <td class="headertd" width="33%"><div align="center">search</div></td> ! <td class="headertdright"> </td> ! </tr><tr> ! <td class="listtdleft">searchstring</td> ! <td class="listtd"><input type="text" name="searchstring" value="<?=$search?>"></td> ! <td class="listtd"><a href="javascript:set('action','search');verzend();">go</a></td> ! </tr></table> ! <br /> ! <table border="0" cellspacing="0" cellpadding="2"><tr><td class="headertdleft">username</td><td class="headertd">uid</td><td class="headertd">gid</td><td class="headertdright">homedir</td></tr> ! <? ! if ($search) { ! $sql_s = " WHERE username LIKE '%$search%' "; ! } else { ! $sql_s = ""; ! } ! $sql = "SELECT * FROM $sql_table $sql_s ORDER BY username LIMIT $start,20"; $res = sql_query($sql); while ($row = sql_fetch_assoc($res)) { *************** *** 496,499 **** --- 513,517 ---- } else { //error + error("update user-password","Please provide a valid password encryption method in the configuration section"); } } *************** *** 518,521 **** --- 536,540 ---- } else { // error + error("insert user-password","Please provide a valid password encryption method in the configuration section"); } $sql .= $userinfo["uid"].", ".$userinfo["gid"].", '".$userinfo["dir"]."'"; *************** *** 650,653 **** --- 669,696 ---- } + /*}}} + *----------------------------------------------------------------------------- + * Name : error + * Desc : Displays error dialog. + * Params : title = dialog title + * : text = error text + * Returns: - + * Remarks: - + *----------------------------------------------------------------------------- + {{{*/ + function error ($title, $text) { + global $settings; + html_header("error"); + ?><table border="0" cellspacing="0" cellpadding="2"><tr><td class="headertdleft"> </td><td class="headertdright"><?=$title?></td></tr> + <tr> + <td class="listtdleft"></td> + <td class="listtd"> + <?=$text?> + </td> + </tr></table> + <? + html_footer(); + } + /* }}} The End. */ ?> |
From: Michiel v. B. <mva...@us...> - 2004-06-13 15:12:58
|
Update of /cvsroot/pureuseradmin/PureUserAdmin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21276 Modified Files: CHANGELOG README Log Message: v 0.0.4 Index: README =================================================================== RCS file: /cvsroot/pureuseradmin/PureUserAdmin/README,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** README 12 Jun 2004 17:47:01 -0000 1.4 --- README 13 Jun 2004 15:12:50 -0000 1.5 *************** *** 38,42 **** Modifying ftp accounts Deleting ftp accounts ! Check access rights on homedir * 3. Requirements. --- 38,43 ---- Modifying ftp accounts Deleting ftp accounts ! Check access rights on homedir ! Notify users with their ftp info * 3. Requirements. Index: CHANGELOG =================================================================== RCS file: /cvsroot/pureuseradmin/PureUserAdmin/CHANGELOG,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** CHANGELOG 12 Jun 2004 17:47:01 -0000 1.3 --- CHANGELOG 13 Jun 2004 15:12:50 -0000 1.4 *************** *** 2,5 **** --- 2,9 ---- [%%VERSION] <%%EMAIL> + * added welcome screen + * added email notification + + [0.0.3] <mvanbaak (ay) users (dot) sourceforge (dot) net> * changed vars to match my release system |
From: Michiel v. B. <mva...@us...> - 2004-06-13 14:48:41
|
Update of /cvsroot/pureuseradmin/PureUserAdmin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32705 Modified Files: pc.php Log Message: added email notification Index: pc.php =================================================================== RCS file: /cvsroot/pureuseradmin/PureUserAdmin/pc.php,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** pc.php 13 Jun 2004 13:38:46 -0000 1.6 --- pc.php 13 Jun 2004 14:48:33 -0000 1.7 *************** *** 32,35 **** --- 32,38 ---- $settings["homepage"] = "%%HOMEPAGE"; $settings["check_access"]= "1"; // 0 = disabled, 1 = enabled - check if user has read/write access in homedir + $settings["notify_user"] = "1"; // 0 = disabled, 1 = enabled - email user with password etc. Database needs field "email" + $settings["admin_email"] = "yo...@do...d"; + $settings["ftp_hostname"]= "your.ftp.server"; /* database settigs */ $settings["sql_type"] = "mysql"; // PureFTPd only supports MySQL and PostgreSQL (mysql and postgres) *************** *** 413,416 **** --- 416,422 ---- <td class="listtd"><input type="password" name="userinfo[password1]" /></td> </tr><tr> + <td class="listtdleft" align="right">email: </td> + <td class="listtd"><input type="text" name="userinfo[email]" /></td> + </tr><tr> <td class="listtdleft" align="right">uid: </td> <td class="listtd"> *************** *** 518,521 **** --- 524,538 ---- } $res = sql_query($sql); + if ($settings["notify_user"] && strlen($userinfo["email"])) { + // send email + $subject = $settings["ftp_hostname"]." FTP information"; + $body = "Hi ".$userinfo["username"].",\n\n"; + $body .= "Here is some information you will need to login with FTP:\n"; + $body .= "hostname: ".$settings["ftp_hostname"]."\n"; + $body .= "username: ".$userinfo["username"]."\n"; + $body .= "password: ".$userinfo["password"]."\n\n"; + $body .= "This information was sent to you by PureUserAdmin ".$settings["version"]." (c) 2004 by Michiel van Baak"; + mail($userinfo["email"], $subject, $body, "From: ".$settings["admin_email"]."\r\n", "-f".$settings["admin_email"]); + } gen_list(); } *************** *** 596,599 **** --- 613,622 ---- <td class="listtd"><?=$settings["version"]?></td> </tr><tr> + <td class="listtdleft" align="right">FTP server address: </td> + <td class="listtd"><?=$settings["ftp_hostname"]?></td> + </tr><tr> + <td class="listtdleft" align="right">Admin email address: </td> + <td class="listtd"><?=$settings["admin_email"]?></td> + </tr><tr> <td class="listtdleft" align="right">Database type: </td> <td class="listtd"><?=$settings["sql_type"]?></td> *************** *** 614,617 **** --- 637,643 ---- <td class="listtd"><? echo ($settings["check_access"]) ? "yes" : "no"; ?></td> </tr><tr> + <td class="listtdleft" align="right">Email user: </td> + <td class="listtd"><? echo ($settings["notify_user"]) ? "yes" : "no"; ?></td> + </tr><tr> <td class="listtdleft" align="right">Default uid: </td> <td class="listtd"><?=$uids[$settings["default_uid"]]?> (<?=$settings["default_uid"]?>)</td> |
From: Michiel v. B. <mva...@us...> - 2004-06-13 13:38:54
|
Update of /cvsroot/pureuseradmin/PureUserAdmin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31590 Modified Files: pc.php Log Message: made a nice welcome screen changed search link to point touserlist Index: pc.php =================================================================== RCS file: /cvsroot/pureuseradmin/PureUserAdmin/pc.php,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** pc.php 12 Jun 2004 17:47:01 -0000 1.5 --- pc.php 13 Jun 2004 13:38:46 -0000 1.6 *************** *** 65,69 **** case "delete_user" : delete_user($_POST["userinfo"]); break; case "check_access": check_access($_REQUEST["dir"], $_REQUEST["uid"], $_REQUEST["gid"]); break; ! default : gen_list(); break; } --- 65,70 ---- case "delete_user" : delete_user($_POST["userinfo"]); break; case "check_access": check_access($_REQUEST["dir"], $_REQUEST["uid"], $_REQUEST["gid"]); break; ! case "search" : gen_list(); break; ! default : welcome(); break; } *************** *** 280,284 **** <a class="toplinks" href="<?=$_SERVER["PHP_SELF"]?>">[ Home ]</a> <a class="toplinks" href="Javascript:set('username','');set('action', 'edit_user');verzend();">[ New User ]</a> ! <a class="toplinks" href="">[ Search ]</a> <a class="toplinks" href="http://pureuseradmin.sourceforge.net">[ Project Page ]</a> </td> --- 281,285 ---- <a class="toplinks" href="<?=$_SERVER["PHP_SELF"]?>">[ Home ]</a> <a class="toplinks" href="Javascript:set('username','');set('action', 'edit_user');verzend();">[ New User ]</a> ! <a class="toplinks" href="Javascript:set('action', 'search');verzend();">[ Userlist ]</a> <a class="toplinks" href="http://pureuseradmin.sourceforge.net">[ Project Page ]</a> </td> *************** *** 572,575 **** --- 573,627 ---- return $rights; } + + /*}}} + *----------------------------------------------------------------------------- + * Name : welcome + * Desc : default page + * Params : - + * Returns: - + * Remarks: - + *----------------------------------------------------------------------------- + {{{*/ + function welcome () { + global $settings; + $uids = load_uids(); + $gids = load_gids(); + html_header("welcome"); + ?> + <table border="0" cellspacing="0" cellpadding="2"><tr> + <td class="headertdleft">Settings</td> + <td class="headertdright"> </td> + </tr><tr> + <td class="listtdleft" align="right">Program version: </td> + <td class="listtd"><?=$settings["version"]?></td> + </tr><tr> + <td class="listtdleft" align="right">Database type: </td> + <td class="listtd"><?=$settings["sql_type"]?></td> + </tr><tr> + <td class="listtdleft" align="right">Database server: </td> + <td class="listtd"><?=$settings["sql_server"]?></td> + </tr><tr> + <td class="listtdleft" align="right">Database name: </td> + <td class="listtd"><?=$settings["sql_dbase"]?></td> + </tr><tr> + <td class="listtdleft" align="right">Database table: </td> + <td class="listtd"><?=$settings["sql_table"]?></td> + </tr><tr> + <td class="listtdleft" align="right">Password crypt method: </td> + <td class="listtd"><?=$settings["pwcrypt"]?></td> + </tr><tr> + <td class="listtdleft" align="right">Check homedir access: </td> + <td class="listtd"><? echo ($settings["check_access"]) ? "yes" : "no"; ?></td> + </tr><tr> + <td class="listtdleft" align="right">Default uid: </td> + <td class="listtd"><?=$uids[$settings["default_uid"]]?> (<?=$settings["default_uid"]?>)</td> + </tr><tr> + <td class="listtdleft" align="right">Default gid: </td> + <td class="listtd"><?=$gids[$settings["default_gid"]]?> (<?=$settings["default_gid"]?>)</td> + </tr></table> + <? + html_footer(); + } + /* }}} The End. */ ?> |
From: Michiel v. B. <mva...@us...> - 2004-06-12 17:47:10
|
Update of /cvsroot/pureuseradmin/PureUserAdmin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6127 Modified Files: CHANGELOG README pc.php Log Message: changed vars so they can be altered with my release script Index: README =================================================================== RCS file: /cvsroot/pureuseradmin/PureUserAdmin/README,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** README 10 Jun 2004 21:11:30 -0000 1.3 --- README 12 Jun 2004 17:47:01 -0000 1.4 *************** *** 1,6 **** ! PureUserAdmin v 0.0.2 ! Copyright (c) 2004, Michiel van Baak <mvanbaak (AT) users (DOT) sourceforge (DOT) net> Licensed under the General Public License (GPL), see COPYING file provided with this program. --- 1,6 ---- ! PureUserAdmin v %%VERSION ! Copyright (c) 2004, Michiel van Baak <%%EMAIL> Licensed under the General Public License (GPL), see COPYING file provided with this program. *************** *** 121,125 **** licensed under the General Public License (GPL) ! Copyright (C), 2004 by Michiel van Baak <mvanbaak (AT) users (DOT) sourceforge (DOT) net> This program is free software; you can redistribute it and/or --- 121,125 ---- licensed under the General Public License (GPL) ! Copyright (C), 2004 by Michiel van Baak <%%EMAIL> This program is free software; you can redistribute it and/or *************** *** 147,152 **** Michiel van Baak ! Email: mvanbaak (AT) users (DOT) sourceforge (DOT) net ! HomePage: http://lunteren.vanbaak.info Please report any bugs, requests and general comments by using the project --- 147,152 ---- Michiel van Baak ! Email: %%EMAIL ! HomePage: %%MYHOMEPAGE Please report any bugs, requests and general comments by using the project *************** *** 156,160 **** please read the Contributing section in this README. ! Project HomePage: http://pureuseradmin.sf.net --- 156,160 ---- please read the Contributing section in this README. ! Project HomePage: %%HOMEPAGE *************** *** 176,178 **** And of course all the others who helped me. ! --- 176,178 ---- And of course all the others who helped me. ! %%DATE Index: pc.php =================================================================== RCS file: /cvsroot/pureuseradmin/PureUserAdmin/pc.php,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** pc.php 10 Jun 2004 21:11:30 -0000 1.4 --- pc.php 12 Jun 2004 17:47:01 -0000 1.5 *************** *** 29,34 **** $debug=1; /* global settings */ ! $settings["version"] = "0.0.2"; ! $settings["homepage"] = "http://pureuseradmin.sf.net"; $settings["check_access"]= "1"; // 0 = disabled, 1 = enabled - check if user has read/write access in homedir /* database settigs */ --- 29,34 ---- $debug=1; /* global settings */ ! $settings["version"] = "%%VERSION"; ! $settings["homepage"] = "%%HOMEPAGE"; $settings["check_access"]= "1"; // 0 = disabled, 1 = enabled - check if user has read/write access in homedir /* database settigs */ Index: CHANGELOG =================================================================== RCS file: /cvsroot/pureuseradmin/PureUserAdmin/CHANGELOG,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CHANGELOG 10 Jun 2004 21:11:29 -0000 1.2 --- CHANGELOG 12 Jun 2004 17:47:01 -0000 1.3 *************** *** 1,4 **** --- 1,7 ---- PureUserAdmin: ChangeLog + [%%VERSION] <%%EMAIL> + * changed vars to match my release system + [0.0.2] <mvanbaak (at) users (dot) sourceforge (dot) net> * added check for homedir rights |
From: Michiel v. B. <mva...@us...> - 2004-06-10 21:11:38
|
Update of /cvsroot/pureuseradmin/PureUserAdmin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32590 Modified Files: CHANGELOG README pc.php Log Message: added permission check on homedir v0.0.2 Index: README =================================================================== RCS file: /cvsroot/pureuseradmin/PureUserAdmin/README,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** README 5 Jun 2004 09:31:50 -0000 1.2 --- README 10 Jun 2004 21:11:30 -0000 1.3 *************** *** 1,3 **** ! PureUserAdmin v 0.0.1 --- 1,3 ---- ! PureUserAdmin v 0.0.2 *************** *** 38,41 **** --- 38,42 ---- Modifying ftp accounts Deleting ftp accounts + Check access rights on homedir * 3. Requirements. *************** *** 74,80 **** When the main goal is reached it would be nice to make a directory ! creation/checking function so a new user will have it's homedir ! setup or the program will display an error when the homedir is ! already there and the new user doesn't have permissions there. 6. For administrators. --- 75,82 ---- When the main goal is reached it would be nice to make a directory ! creation/checking function (checking realized in 0.0.2) so a new ! user will have it's homedir setup or the program will display an ! error when the homedir is already there and the new user ! doesn't have permissions there. 6. For administrators. *************** *** 165,171 **** --- 167,176 ---- Testing: -------- + zeepee` (http://leonieke.net) Various suggestions and patches: -------------------------------- + Nancy (my wonderful wife) - she came up with the name + The drupal xtemplate crew - interface ideas And of course all the others who helped me. Index: pc.php =================================================================== RCS file: /cvsroot/pureuseradmin/PureUserAdmin/pc.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** pc.php 8 Jun 2004 15:41:47 -0000 1.3 --- pc.php 10 Jun 2004 21:11:30 -0000 1.4 *************** *** 29,34 **** $debug=1; /* global settings */ ! $settings["version"] = "0.0.1"; $settings["homepage"] = "http://pureuseradmin.sf.net"; /* database settigs */ $settings["sql_type"] = "mysql"; // PureFTPd only supports MySQL and PostgreSQL (mysql and postgres) --- 29,35 ---- $debug=1; /* global settings */ ! $settings["version"] = "0.0.2"; $settings["homepage"] = "http://pureuseradmin.sf.net"; + $settings["check_access"]= "1"; // 0 = disabled, 1 = enabled - check if user has read/write access in homedir /* database settigs */ $settings["sql_type"] = "mysql"; // PureFTPd only supports MySQL and PostgreSQL (mysql and postgres) *************** *** 60,67 **** /* {{{ determine action */ switch ($_POST["action"]) { ! case "edit_user" : edit_user($_POST["username"]); break; ! case "save_user" : save_user($_POST["userinfo"]); break; ! case "delete_user" : delete_user($_POST["userinfo"]); break; ! default : gen_list(); break; } --- 61,69 ---- /* {{{ determine action */ switch ($_POST["action"]) { ! case "edit_user" : edit_user($_POST["username"]); break; ! case "save_user" : save_user($_POST["userinfo"]); break; ! case "delete_user" : delete_user($_POST["userinfo"]); break; ! case "check_access": check_access($_REQUEST["dir"], $_REQUEST["uid"], $_REQUEST["gid"]); break; ! default : gen_list(); break; } *************** *** 339,342 **** --- 341,358 ---- $res = sql_query($sql); while ($row = sql_fetch_assoc($res)) { + if ($settings["check_access"]) { + $user_rights = check_access($row["dir"],$row["uid"],$row["gid"]); + if ($user_rights["error"]) { + $right = $user_rights["error"]; + } else { + if ($user_rights["write"]) { + $right = "user can read and write files in homedir"; + } elseif ($user_rights["read"]) { + $right = "user can only read files in homedir"; + } else { + $right = "<font color=\"red\">user has no access to homedir</font>"; + } + } + } ?> <tr> *************** *** 344,348 **** <td class="listtd"><? echo $uids[$row["uid"]] ? $uids[$row["uid"]] : $row["uid"]; ?></td> <td class="listtd"><? echo $gids[$row["gid"]] ? $gids[$row["gid"]] : $row["gid"]; ?></td> ! <td class="listtd"><?=$row["dir"]?></td> </tr> <? --- 360,364 ---- <td class="listtd"><? echo $uids[$row["uid"]] ? $uids[$row["uid"]] : $row["uid"]; ?></td> <td class="listtd"><? echo $gids[$row["gid"]] ? $gids[$row["gid"]] : $row["gid"]; ?></td> ! <td class="listtd"><?=$row["dir"]?> <? if ($settings["check_access"]) { ?>(<?=$right?>)<? } ?></td> </tr> <? *************** *** 519,523 **** gen_list(); } ! /* }}} The End. */ ?> --- 535,575 ---- gen_list(); } ! /*}}} ! *----------------------------------------------------------------------------- ! * Name : check_access ! * Desc : check if user has read/write access to homedir ! * Params : dir = homedir ! * : uid = userid of user ! * : gid = groupid of user ! * Returns: $rights = array with octal rights and wrtie/read flag ! * Remarks: if homedir is not found it will return $rights["error"] ! *----------------------------------------------------------------------------- ! {{{*/ ! function check_access ($homedir, $uid, $gid) { ! if (file_exists($homedir)) { ! $fuid = fileowner($homedir); ! $fgid = filegroup($homedir); ! $fperms = fileperms($homedir); ! $fperm = substr(sprintf("%o",$fperms),2); ! $rights["owner"] = substr($fperm,0,1); ! $rights["group"] = substr($fperm,1,1); ! $rights["world"] = substr($fperm,2,1); ! $rights["read"] = 0; ! $rights["write"] = 0; ! if ($rights["world"] > 6) { $rights["write"] = 1; } ! if ($rights["world"] > 4) { $rights["read"] = 1; } ! if ($uid == $fuid) { ! if ($rights["owner"] > 6) { $rights["write"] = 1; } ! if ($rights["owner"] > 4) { $rights["read"] = 1; } ! } ! if ($gid == $fgid) { ! if ($rights["group"] > 6) { $rights["write"] = 1; } ! if ($rights["group"] > 4) { $rights["read"] = 1; } ! } ! } else { ! $rights["error"] = "No such directory"; ! } ! return $rights; ! } /* }}} The End. */ ?> Index: CHANGELOG =================================================================== RCS file: /cvsroot/pureuseradmin/PureUserAdmin/CHANGELOG,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** CHANGELOG 3 Jun 2004 17:34:08 -0000 1.1.1.1 --- CHANGELOG 10 Jun 2004 21:11:29 -0000 1.2 *************** *** 1,4 **** --- 1,8 ---- PureUserAdmin: ChangeLog + [0.0.2] <mvanbaak (at) users (dot) sourceforge (dot) net> + * added check for homedir rights + * changed look + [0.0.1] <mvanbaak (at) users (dot) sourceforge (dot) net> * Initial Release |
From: Michiel v. B. <mva...@us...> - 2004-06-08 15:42:45
|
Update of /cvsroot/pureuseradmin/PureUserAdmin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27563 Modified Files: pc.php Log Message: interface update Index: pc.php =================================================================== RCS file: /cvsroot/pureuseradmin/PureUserAdmin/pc.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** pc.php 5 Jun 2004 09:31:50 -0000 1.2 --- pc.php 8 Jun 2004 15:41:47 -0000 1.3 *************** *** 186,189 **** --- 186,193 ---- right: 0px; height: 15px; + border-top: 3px solid #6699CC; + border-bottom: 3px solid #6699CC; + background-color: #336699; + color: #E4E9EB; } html, body, form { *************** *** 200,204 **** } .logo { ! height: 100px; width: 100%; left: 50%; --- 204,208 ---- } .logo { ! height: 50px; width: 100%; left: 50%; *************** *** 207,210 **** --- 211,255 ---- width: 100%; right: 50%; + height: 100%; + } + .links { + border-top: 3px solid #6699CC; + border-bottom: 3px solid #6699CC; + background-color: #336699; + color: #E4E9EB; + } + .listtdleft { + border-left: 1px solid #000000; + border-right: 1px solid #000000; + border-bottom: 1px solid #000000; + } + .listtd { + border-right: 1px solid #000000; + border-bottom: 1px solid #000000; + + } + .headertdleft { + border-left: 1px solid #000000; + border-top: 3px solid #6699CC; + border-bottom: 3px solid #6699CC; + background-color: #336699; + color: #E4E9EB; + } + .headertd { + border-top: 3px solid #6699CC; + border-bottom: 3px solid #6699CC; + background-color: #336699; + color: #E4E9EB; + } + .headertdright { + border-right: 1px solid #000000; + border-top: 3px solid #6699CC; + border-bottom: 3px solid #6699CC; + background-color: #336699; + color: #E4E9EB; + } + a.toplinks { + color: #E4E9EB; + font-weight: bold; } </style> *************** *** 224,230 **** </script> </head> ! <body> ! <table border="0" cellspacing="0" cellpadding="0" class="pagetable"><tr> ! <td class="logo" align="center"><a href="pc.php"><img src="logo.gif" border="0" alt="logo" /></a></td> </tr><tr> <td class="maintd" align="center"> --- 269,284 ---- </script> </head> ! ! ! <body bgcolor="#ffffff" > ! <table id="secondary-links-table" summary="Navigation elements." border="0" cellpadding="0" cellspacing="0" class="pagetable"><tr> ! <td class="logo" align="center"><img src="logo.gif" alt="logo" border="0" /></td> ! </tr><tr> ! <td class="links" align="center" valign="middle"> ! <a class="toplinks" href="<?=$_SERVER["PHP_SELF"]?>">[ Home ]</a> ! <a class="toplinks" href="Javascript:set('username','');set('action', 'edit_user');verzend();">[ New User ]</a> ! <a class="toplinks" href="">[ Search ]</a> ! <a class="toplinks" href="http://pureuseradmin.sourceforge.net">[ Project Page ]</a> ! </td> </tr><tr> <td class="maintd" align="center"> *************** *** 255,260 **** </tr><tr> <td class="copyright" align="right"> ! <a href="<?=$settings["homepage"]?>">PureUserAdmin <?=$settings["version"]?></a>, ! by Michiel van Baak, © 2004, released under the <a href="http://www.gnu.org/copyleft/gpl.html">GPL.</a> </td> </tr></table> --- 309,314 ---- </tr><tr> <td class="copyright" align="right"> ! <a class="toplinks" href="<?=$settings["homepage"]?>">PureUserAdmin <?=$settings["version"]?></a>, ! by Michiel van Baak, © 2004, released under the <a class="toplinks" href="http://www.gnu.org/copyleft/gpl.html">GPL.</a> </td> </tr></table> *************** *** 264,268 **** } ! /*}}}<F9> *----------------------------------------------------------------------------- * Name : gen_list --- 318,322 ---- } ! /*}}} *----------------------------------------------------------------------------- * Name : gen_list *************** *** 281,286 **** html_header("userlist"); ! ?><a href="Javascript:set('username','');set('action', 'edit_user');verzend();">New user</a><? ! ?><table border="0" cellspacing="1" cellpadding="2" bgcolor="#000000"><tr><td>username</td><td>uid</td><td>gid</td><td>homedir</td></tr><? $sql = "SELECT * FROM $sql_table ORDER BY username LIMIT $start,20"; $res = sql_query($sql); --- 335,339 ---- html_header("userlist"); ! ?><table border="0" cellspacing="0" cellpadding="2"><tr><td class="headertdleft">username</td><td class="headertd">uid</td><td class="headertd">gid</td><td class="headertdright">homedir</td></tr><? $sql = "SELECT * FROM $sql_table ORDER BY username LIMIT $start,20"; $res = sql_query($sql); *************** *** 288,295 **** ?> <tr> ! <td><a href="javascript:set('action','edit_user');set('username','<?=$row["username"]?>');verzend();"><?=$row["username"]?></a></td> ! <td><? echo $uids[$row["uid"]] ? $uids[$row["uid"]] : $row["uid"]; ?></td> ! <td><? echo $gids[$row["gid"]] ? $gids[$row["gid"]] : $row["gid"]; ?></td> ! <td><?=$row["dir"]?></td> </tr> <? --- 341,348 ---- ?> <tr> ! <td class="listtdleft"><a href="javascript:set('action','edit_user');set('username','<?=$row["username"]?>');verzend();"><?=$row["username"]?></a></td> ! <td class="listtd"><? echo $uids[$row["uid"]] ? $uids[$row["uid"]] : $row["uid"]; ?></td> ! <td class="listtd"><? echo $gids[$row["gid"]] ? $gids[$row["gid"]] : $row["gid"]; ?></td> ! <td class="listtd"><?=$row["dir"]?></td> </tr> <? *************** *** 326,345 **** } ?> ! <table border="0" cellspacing="1" cellpadding="2" bgcolor="#000000"><tr> ! <td align="right">username: </td> <? if (strlen($userinfo)) { ?> ! <td><input type="hidden" name="userinfo[username]" value="<?=$userinfo["username"]?>" /><?=$userinfo["username"]?></td> <? } else { ?> ! <td><input type="text" name="userinfo[username]" value="<?=$userinfo["username"]?>" /></td> <? } ?> </tr><tr> ! <td align="right">password*: </td> ! <td><input type="password" name="userinfo[password]" /></td> </tr><tr> ! <td align="right">retype password*: </td> ! <td><input type="password" name="userinfo[password1]" /></td> </tr><tr> ! <td align="right">uid: </td> ! <td> <select name="userinfo[uid]"> <? --- 379,401 ---- } ?> ! <table border="0" cellspacing="0" cellpadding="2"><tr> ! <td class="headertdleft"><? if (strlen($userinfo)) { ?>Edit<? } else { ?>New<? } ?> User</td> ! <td class="headertdright"> </td> ! </tr><tr> ! <td class="listtdleft" align="right">username: </td> <? if (strlen($userinfo)) { ?> ! <td class="listtd"><input type="hidden" name="userinfo[username]" value="<?=$userinfo["username"]?>" /><?=$userinfo["username"]?></td> <? } else { ?> ! <td class="listtd"><input type="text" name="userinfo[username]" value="<?=$userinfo["username"]?>" /></td> <? } ?> </tr><tr> ! <td class="listtdleft" align="right">password*: </td> ! <td class="listtd"><input type="password" name="userinfo[password]" /></td> </tr><tr> ! <td class="listtdleft" align="right">retype password*: </td> ! <td class="listtd"><input type="password" name="userinfo[password1]" /></td> </tr><tr> ! <td class="listtdleft" align="right">uid: </td> ! <td class="listtd"> <select name="userinfo[uid]"> <? *************** *** 355,360 **** </td> </tr><tr> ! <td align="right">gid: </td> ! <td> <select name="userinfo[gid]"> <? --- 411,416 ---- </td> </tr><tr> ! <td class="listtdleft" align="right">gid: </td> ! <td class="listtd"> <select name="userinfo[gid]"> <? *************** *** 370,377 **** </td> </tr><tr> ! <td align="right">homedir: </td> ! <td><input type="text" name="userinfo[dir]" value="<?=$userinfo["dir"]?>" /></td> </tr><tr> ! <td colspan="2"> <table border="0" cellspacing="0" cellpadding="0" width="100%"><tr> <td width="33%" align="left"><a href="Javascript:set('action','save_user');verzend();">save</a></td> --- 426,433 ---- </td> </tr><tr> ! <td class="listtdleft" align="right">homedir: </td> ! <td class="listtd"><input type="text" name="userinfo[dir]" value="<?=$userinfo["dir"]?>" /></td> </tr><tr> ! <td colspan="2" class="listtdleft"> <table border="0" cellspacing="0" cellpadding="0" width="100%"><tr> <td width="33%" align="left"><a href="Javascript:set('action','save_user');verzend();">save</a></td> |
From: Michiel v. B. <mva...@us...> - 2004-06-05 09:31:59
|
Update of /cvsroot/pureuseradmin/PureUserAdmin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17072 Modified Files: README pc.php Log Message: README: added install directions pc.php: better comment on variables Index: README =================================================================== RCS file: /cvsroot/pureuseradmin/PureUserAdmin/README,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** README 3 Jun 2004 17:34:08 -0000 1.1.1.1 --- README 5 Jun 2004 09:31:50 -0000 1.2 *************** *** 47,51 **** * PHP4, with mysql.so module (or build in support). * MySQL daemon. ! * PureFTPd with mysql/postgresql/puredb auth config * A webbrowser --- 47,51 ---- * PHP4, with mysql.so module (or build in support). * MySQL daemon. ! * PureFTPd with mysql/postgresql auth config * A webbrowser *************** *** 61,64 **** --- 61,66 ---- ------------------------------------------------------------------------------- + Just unpack it somewhere in your www root. + Edit pc.php to reflect your system. 5. Project goals. *************** *** 87,90 **** --- 89,93 ---- * Run it over SSL ONLY! * Do not run your webserver as user nobody! + * Don't forget to restrict access with .htaccess/.htpasswd Also read the beautiful NO WARRANTY disclaimer in the GPL. ;) Index: pc.php =================================================================== RCS file: /cvsroot/pureuseradmin/PureUserAdmin/pc.php,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** pc.php 3 Jun 2004 17:34:08 -0000 1.1.1.1 --- pc.php 5 Jun 2004 09:31:50 -0000 1.2 *************** *** 43,48 **** // cleartext = plain text // md5 ! $settings["default_uid"] = "32767"; // we use nobody ! $settings["default_gid"] = "32767"; // we use nobody /* }}} */ --- 43,48 ---- // cleartext = plain text // md5 ! $settings["default_uid"] = "32767"; // we use nobody (on OpenBSD) ! $settings["default_gid"] = "32767"; // we use nobody (on OpenBSD) /* }}} */ |