plugins->registerEvent('web_domain_insert',$this->plugin_name,'insert'); $app->plugins->registerEvent('web_domain_update',$this->plugin_name,'update'); $app->plugins->registerEvent('web_domain_delete',$this->plugin_name,'delete'); } function insert($event_name,$data) { global $app, $conf; $app->uses('system'); // Get the UID of the parent user $uid = intval($app->system->getuid($data['new']['puser'])); if($uid > 999) { $command = 'useradd'; $command .= ' --home '.escapeshellcmd($data['new']['dir']); $command .= ' --gid '.escapeshellcmd($data['new']['pgroup']); $command .= ' --non-unique '; $command .= ' --password '.escapeshellcmd($data['new']['password']); $command .= ' --shell '.escapeshellcmd($data['new']['shell']); $command .= ' --uid '.escapeshellcmd($uid); $command .= ' '.escapeshellcmd($data['new']['username']); exec($command); $app->log("Added shelluser: ".$data['new']['username'],LOGLEVEL_DEBUG); } else { $app->log("UID = $uid for shelluser:".$data['new']['username']." not allowed.",LOGLEVEL_ERROR); } } function update($event_name,$data) { global $app, $conf; $app->uses('system'); // Get the UID of the parent user $uid = intval($app->system->getuid($data['new']['puser'])); if($uid > 999) { $command = 'usermod'; $command .= ' --home '.escapeshellcmd($data['new']['dir']); $command .= ' --gid '.escapeshellcmd($data['new']['pgroup']); $command .= ' --non-unique '; $command .= ' --password '.escapeshellcmd($data['new']['password']); $command .= ' --shell '.escapeshellcmd($data['new']['shell']); $command .= ' --uid '.escapeshellcmd($uid); $command .= ' --login '.escapeshellcmd($data['new']['username']); $command .= ' '.escapeshellcmd($data['old']['username']); exec($command); $app->log("Updated shelluser: ".$data['new']['username'],LOGLEVEL_DEBUG); } else { $app->log("UID = $uid for shelluser:".$data['new']['username']." not allowed.",LOGLEVEL_ERROR); } } function delete($event_name,$data) { global $app, $conf; $app->uses('system'); // Get the UID of the user $userid = intval($app->system->getuid($data['old']['username'])); if($userid > 999) { $command = 'userdel'; $command .= ' '.escapeshellcmd($data['old']['username']); exec($command); $app->log("Deleted shelluser: ".$data['old']['username'],LOGLEVEL_DEBUG); } else { $app->log("UID = $userid for shelluser:".$data['new']['username']." not allowed.",LOGLEVEL_ERROR); } } } // end class ?>