| | |
| | | var $server_conf; |
| | | var $data; |
| | | |
| | | function system(){ |
| | | /** |
| | | * Construct for this class |
| | | * |
| | | * @return system |
| | | */ |
| | | public function system(){ |
| | | global $go_info; |
| | | $this->server_id = $go_info["isp"]["server_id"]; |
| | | $this->server_conf = $go_info["isp"]["server_conf"]; |
| | |
| | | $this->server_conf["group_datei"] = '/etc/group'; |
| | | } |
| | | |
| | | function hostname(){ |
| | | /** |
| | | * Get the hostname from the server |
| | | * |
| | | * @return string |
| | | */ |
| | | public function hostname(){ |
| | | $dist = $this->server_conf["dist"]; |
| | | |
| | | ob_start(); |
| | |
| | | return $hostname; |
| | | } |
| | | |
| | | function adduser($user_username, $uid, $gid, $username, $homedir, $shell, $passwort = '*'){ |
| | | /** |
| | | * Add an user to the system |
| | | * |
| | | */ |
| | | public function adduser($user_username, $uid, $gid, $username, $homedir, $shell, $passwort = '*'){ |
| | | global $app; |
| | | if($this->is_user($user_username)){ |
| | | return false; |
| | |
| | | $new_passwd = "\n$user_username:$passwort:$uid:$gid::0:0:$username:$homedir:$shell\n"; |
| | | } |
| | | $app->file->af($shadow_datei, $new_passwd); |
| | | |
| | | // TB: leere Zeilen entfernen |
| | | $app->file->remove_blank_lines($shadow_datei); |
| | | $app->file->remove_blank_lines($user_datei); |
| | |
| | | //$this->order_users_groups(); |
| | | if($shadow_datei != "/etc/shadow"){ |
| | | $app->file->af($shadow_datei, "\n"); |
| | | |
| | | // TB: leere Zeilen entfernen |
| | | $app->file->remove_blank_lines($shadow_datei); |
| | | |
| | | $app->log->caselog("pwd_mkdb $shadow_datei &> /dev/null", $this->FILE, __LINE__); |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Update users when someone edit it |
| | | * |
| | | */ |
| | | function updateuser($user_username, $uid, $gid, $username, $homedir, $shell, $passwort = '*'){ |
| | | //* First delete the users |
| | | $this->deluser($user_username); |
| | | //* Add the user again |
| | | $this->adduser($user_username, $uid, $gid, $username, $homedir, $shell, $passwort); |
| | | } |
| | | |
| | | /** |
| | | * Lock the user |
| | | * |
| | | */ |
| | | function deactivateuser($user_username){ |
| | | $passwort = str_rot13($this->getpasswd($user_username)); |
| | | $user_attr = $this->get_user_attributes($user_username); |
| | |
| | | $this->deluser($user_username); |
| | | $this->adduser($user_username, $uid, $gid, $username, $homedir, $shell, $passwort); |
| | | } |
| | | |
| | | /** |
| | | * Delete a user from the system |
| | | * |
| | | */ |
| | | function deluser($user_username){ |
| | | global $app; |
| | | if($this->is_user($user_username)){ |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Add a usergroup to the system |
| | | * |
| | | */ |
| | | function addgroup($group, $gid, $members = ''){ |
| | | global $app; |
| | | if($this->is_group($group)){ |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Update usersgroup in way to delete and add it again |
| | | * |
| | | */ |
| | | function updategroup($group, $gid, $members = ''){ |
| | | $this->delgroup($group); |
| | | $this->addgroup($group, $gid, $members); |
| | | } |
| | | |
| | | /** |
| | | * Delete a usergroup from the system |
| | | * |
| | | */ |
| | | function delgroup($group){ |
| | | global $app; |
| | | if($this->is_group($group)){ |
| | |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Order usergroups |
| | | * |
| | | */ |
| | | function order_users_groups(){ |
| | | global $app; |
| | | $user_datei = $this->server_conf["passwd_datei"]; |
| | |
| | | unset($arr); |
| | | } |
| | | |
| | | /** |
| | | * Find a user / group id |
| | | * |
| | | */ |
| | | function find_uid_gid($min, $max){ |
| | | global $app; |
| | | if($min < $max && $min >= 0 && $max >= 0 && $min <= 65536 && $max <= 65536 && is_int($min) && is_int($max)){ |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Check if the users is really a user into the system |
| | | * |
| | | */ |
| | | function is_user($user){ |
| | | global $app; |
| | | $user_datei = $this->server_conf["passwd_datei"]; |
| | |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * Check if the group is on this system |
| | | * |
| | | */ |
| | | function is_group($group){ |
| | | global $app; |
| | | $group_datei = $this->server_conf["group_datei"]; |
| | |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * Get the groups of an user |
| | | * |
| | | */ |
| | | function get_user_groups($username){ |
| | | global $app; |
| | | $user_groups = array(); |
| | |
| | | return ''; |
| | | } |
| | | |
| | | /** |
| | | * Get a user password |
| | | * |
| | | */ |
| | | function getpasswd($user){ |
| | | global $app; |
| | | if($this->is_user($user)){ |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Get the user id from an user |
| | | * |
| | | */ |
| | | function getuid($user){ |
| | | global $app; |
| | | if($this->is_user($user)){ |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Get all information from a user |
| | | * |
| | | */ |
| | | function get_user_attributes($user){ |
| | | global $app; |
| | | if($this->is_user($user)){ |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Edit the owner of a file |
| | | * |
| | | */ |
| | | function chown($file, $owner, $group = ''){ |
| | | $owner_change = @chown($file, $owner); |
| | | if($group != ""){ |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Add an user to a specific group |
| | | * |
| | | */ |
| | | function add_user_to_group($group, $user = 'admispconfig'){ |
| | | global $app; |
| | | $group_file = $app->file->rf($this->server_conf["group_datei"]); |
| | |
| | | } |
| | | } |
| | | |
| | | /**boot autostart etc |
| | | * |
| | | */ |
| | | function rc_edit($service, $rl, $action){ |
| | | // $action = "on|off"; |
| | | global $app; |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Filter information from the commands |
| | | * |
| | | */ |
| | | function grep($content, $string, $params = ''){ |
| | | global $app; |
| | | // params: i, v, w |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Strip content from fields |
| | | * |
| | | */ |
| | | function cut($content, $field, $delimiter = ':'){ |
| | | global $app; |
| | | $content = $app->file->unix_nl($content); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Get the content off a file |
| | | * |
| | | */ |
| | | function cat($file){ |
| | | global $app; |
| | | return $app->file->rf($file); |
| | | } |
| | | |
| | | /** |
| | | * Control services to restart etc |
| | | * |
| | | */ |
| | | function daemon_init($daemon, $action){ |
| | | // $action = start|stop|restart|reload |
| | | //* $action = start|stop|restart|reload |
| | | global $app; |
| | | $dist = $this->server_conf["dist"]; |
| | | $dist_init_scripts = $this->server_conf["dist_init_scripts"]; |
| | |
| | | return bindec($f1).".".bindec($f2).".".bindec($f3).".".bindec($f4); |
| | | } |
| | | |
| | | /** |
| | | * Make a broadcast address from an IP number in combination with netmask |
| | | * |
| | | */ |
| | | function broadcast($ip, $netmask){ |
| | | $netmask = $this->netmask($netmask); |
| | | $binary_netmask = $this->binary_netmask($netmask); |
| | |
| | | return bindec($f1).".".bindec($f2).".".bindec($f3).".".bindec($f4); |
| | | } |
| | | |
| | | /** |
| | | * Get the network address information |
| | | * |
| | | */ |
| | | function network_info(){ |
| | | $dist = $this->server_conf["dist"]; |
| | | ob_start(); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Configure the network settings from the system |
| | | * |
| | | */ |
| | | function network_config(){ |
| | | $ifconfig = $this->network_info(); |
| | | if($ifconfig){ |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Scan the trash for virusses infection |
| | | * |
| | | */ |
| | | function make_trashscan(){ |
| | | global $app; |
| | | //trashscan erstellen |
| | |
| | | exec("chmod 755 $datei"); |
| | | } |
| | | |
| | | /** |
| | | * Get the current time |
| | | * |
| | | */ |
| | | function get_time(){ |
| | | $addr = "http://www.ispconfig.org/"; |
| | | $timeout = 1; |